jabble
Class Field

java.lang.Object
  extended by jabble.Field

public abstract class Field
extends java.lang.Object

Represents a scalar field defined on all of the point of the Grid.

In Jabble, objects from the Field classes are usually created by the framwork. A user will typically write an Evolver to write code that solves a new equation, in which case Field objects are automatically initialized (see the Evolver documentation). A user that simply need to specify initial condition for an equation for which an Evolver is already written, might not even need Field objects at all.

In case that one needs to create a field, he can do so with the static methods Field.createField(...). This might happen if one is writing a new completely method to solve equations, but it's not the norm.

In general, we try to have the framework to manage the full life-cycle of Field object so it can manage memory management efficiently, and take care of things such as storing the data to file. Plus, the Field being an abstract class, and the framework deciding which implementation class to use, allows us to experiment with different data structure implementation without affecting the physics code. We also envision that Jabble could choose a different implementation at runtime, depending on the problem at hand. Notice that there is no penalty associated with Field being an abstract class, as the Jabble code is carefully constructed so that the implementation code can still be inlined at runtime.


Constructor Summary
Field()
           
 
Method Summary
abstract  double at(Point p)
          Returns the value of the field at the given point.
abstract  void copyData(Field sourceField)
          Changes all values of the field to match the given one.
static Field createField(Field field)
          Creates a new field that is the copy of the given Field.
static Field createField(java.lang.String name, double[] data, Grid grid)
          Creates a new field with the given name, data and Grid.
static Field createField(java.lang.String name, Grid grid)
          Creates a new field with a value of zero at each point of the Grid.
abstract  Grid getGrid()
          Returns the Grid on which the Field is defined.
abstract  java.lang.String getName()
          The name of the field.
abstract  void load(java.nio.DoubleBuffer buffer)
          Loads the field values from the buffer.
abstract  void setAt(Point p, double value)
          Changes the value of the field at the given point.
abstract  void store(java.nio.DoubleBuffer buffer)
          Saves the field values to the buffer.
 java.lang.String toString()
          Returns the name of the Field, the Grid on which is defined and the values around the origin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Field

public Field()
Method Detail

createField

public static Field createField(java.lang.String name,
                                Grid grid)
Creates a new field with a value of zero at each point of the Grid.

Parameters:
name - The name of the field (will be used to identify it in the Slice object)
grid - The Grid on which the field is defined.

createField

public static Field createField(Field field)
Creates a new field that is the copy of the given Field. That is, the new field will have the same name, will be defined on the same Grid and the data will be initialized to the data of the argument Field data.

Parameters:
field - The template field from which to create the new one

createField

public static Field createField(java.lang.String name,
                                double[] data,
                                Grid grid)
Creates a new field with the given name, data and Grid. The data array will be used directly by the new field, without a copy. So any modification on the data array will mean changing values in the Field.

Parameters:
name - the name to give to the field
data - array containing all the values of the field across the grid
grid - the grid on which the field is defined

at

public abstract double at(Point p)
Returns the value of the field at the given point.

Parameters:
p - A point on the grid
Returns:
The value of the field at that point

setAt

public abstract void setAt(Point p,
                           double value)
Changes the value of the field at the given point.

Parameters:
p - A point on the grid
value - The new value for the field

getName

public abstract java.lang.String getName()
The name of the field.

Returns:
a String representing the field

copyData

public abstract void copyData(Field sourceField)
Changes all values of the field to match the given one.

Parameters:
sourceField - the field from which to copy

getGrid

public abstract Grid getGrid()
Returns the Grid on which the Field is defined.

Returns:
The Grid on which the Field is defined.

load

public abstract void load(java.nio.DoubleBuffer buffer)
Loads the field values from the buffer. Method used by the ResultStore to load the data.

Parameters:
buffer - the buffer to load from

store

public abstract void store(java.nio.DoubleBuffer buffer)
Saves the field values to the buffer. Method used by the ResultStore to save the data.

Parameters:
buffer - the buffer to save to

toString

public java.lang.String toString()
Returns the name of the Field, the Grid on which is defined and the values around the origin.

Overrides:
toString in class java.lang.Object
Returns:
The String representation of the Field.