|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjabble.Evolver
jabble.IteratedCrankNicholson
public abstract class IteratedCrankNicholson
This class implements the Iterated Crank-Nicholson template algorithm. It provides the common iteration and averaging pattern for the algorithm, leaving out only the part relative to the specific equation.
Given a finite difference expression ut+dt = ut + dt f(ut), where ut is a field at the time t, ut+dt is the same field at the following time step, and f the stencil used to calculate du, the Iterated Crank-Nicholson is defined as:
ut+dt = ICN(ut, dt, f, k):
where:
In the Jabble framework, this class will take care of performing the iteration and the averaging. One needs to specify:
Notice that more than one field can be calculated at the same time.
The following is a sample code for an IteratedCrankNicholson class that solves the Advection equation dphi / dt = dphi / dx :
public class AdvectionCartesian1DICN extends IteratedCrankNicholson {
// Constant representing the X direction
private static final int X = 0;
// The fields on which to use the ICN method
private Field previousPhi;
private Field phi;
private Field averagePhi;
// The time differential
private Field dt;
// The finite difference expression
//used during the iterations
protected void calculateNewFields(Point point) {
double dtValue = dt.at(point);
double phiValue = previousPhi.at(point);
phiValue += dtValue * centeredDifference(averagePhi, X);
phi.setAt(point,phiValue);
}
}
Reference:
| Field Summary |
|---|
| Fields inherited from class jabble.Evolver |
|---|
constantsMap, dDirs, fieldArrayMap, fieldMap, grid, stopTrigger |
| Constructor Summary | |
|---|---|
protected |
IteratedCrankNicholson()
Creates a new Iterated Crank-Nicholson evolver, with the default of 2 iterations. |
protected |
IteratedCrankNicholson(int nIterations)
Creates a new Iterated Crank-Nicholson evolver, specifying the number of iterations. |
| Method Summary | |
|---|---|
protected void |
calculateNewFields()
Implements the skeleton of the template algorythm. |
protected abstract void |
calculateNewFields(Point point)
Calculate the new value of the fields at the given point. |
| Methods inherited from class jabble.Evolver |
|---|
evolve, evolve, evolve, getNPreviousSlicesNeeded, initializeFieldArray, initializeFieldArray, skipBoundaryPoint |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected IteratedCrankNicholson(int nIterations)
nIterations - number of iterations for the Iterated Crank-Nicholson algorithmprotected IteratedCrankNicholson()
| Method Detail |
|---|
protected abstract void calculateNewFields(Point point)
point - the point at which to calculate the value of the new fields.protected final void calculateNewFields()
calculateNewFields in class Evolver
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||