Class Solution

java.lang.Object
  extended bySolution
Direct Known Subclasses:
FluidSolution, ParticleSolution, SamplingSolution

public abstract class Solution
extends java.lang.Object

Solution -- Is an abstract class containing all the solutions and solvers.

See Also:
FluidSolution, ParticleSolution

Field Summary
protected  double[] df
          Derivative time level n @see #f
protected  double[] dfm
          Derivative time level n-1 @see #fm
protected  double[] dfp
          Derivative time level n+1 @see #fp
protected  double[] dg
          Extra Derivative time level n @see #g
protected  double[] dgm
          Extra Derivative time level n-1 @see #gm
protected  double[] dgp
          Extra Derivative time level n+1 @see #gp
protected  double[] dx
          The mesh intervals @see #mesh
protected  double[] f
          Function time level n
protected  double[] f0
          Function time level 0 (IC) @see #f
protected  double[] fm
          Function time level n-1
protected  double[] fp
          Function time level n+1
protected  double[] g
          Extra Function time level n
protected  double[] gm
          Extra Function time level n-1
protected  double[] gp
          Extra Function time level n+1
protected  java.lang.String ic
          Initial condition name @see #setIC
protected  double[] initialMoments
          Store initial moments
private  int lastStep
          The current step in the time discretization
protected  Mesh mesh
          The underlying mesh for the solution
protected  java.lang.String method
          Numerical method name @see #setMethod
protected  java.lang.String scheme
          Numerical scheme name @see #setScheme
protected  double time
          Absolute time @see #setTime
protected  java.lang.String topic
          The topic to be solved @see #setTopic
protected  double[] x
          The mesh points @see #mesh
protected  double x_0
          x of lower left corner of plot area
protected  double x_1
          x of upper right corner of plot area
protected  int xOffset
          Horizontal offset of plot area
protected  int xSize
          Horizontal scale of plot area
protected  double y_0
          y of lower left corner of plot area
protected  double y_1
          y of upper right corner of plot area
protected  int yOffset
          Vertical offset of plot area
protected  int ySize
          Vertical scale of plot area
 
Constructor Summary
Solution(RunData runData)
          Creates an instance of a Solution object with all the attributes.
 
Method Summary
protected  double calculateMoments(int m)
          Internal function to calculate the initial moments of f[] or their deviation from the beginning of the evolution.
abstract  void discretize(ShapeFunction function)
          Discretize the initial shape and initialize the moments
 double getTime()
          Get the current physical time
 double getValue(double arg)
          Linear interpolation of the solution.
 double getValue(int index)
          Gives the value of the function for an index
 int[] getWinSize()
          Returns window size
abstract  boolean hasOption(java.lang.String option)
          Tells whether the solution implements a option
 boolean incTime(double time)
          Increment the current physical time
protected  double[] limits(boolean headers)
          Calculates the solution boundaries.
 double[] measure(int x, int y)
          Get physical coordinates from mouse coordinates
 double momentsDeviation(int m)
          Calculates the deviation from the m:th initial moment.
abstract  boolean next(RunData runData)
          Advance the solution forward one step in time.
 void output(int step)
          Print the solution in ASCII to java console
 void plot(java.awt.Canvas plotArea, java.awt.Image offScrImage, boolean headers)
          Plots the solution
abstract  boolean previous(RunData runData)
          Take the solution backward one step to initialize schemes with 3 time levels.
 void rescale(boolean headers)
          Set the corners of the plot area
 void setIC(java.lang.String ic)
          Set the initial condision as a string.
 void setMethod(java.lang.String method)
          Set the numerical method as a string.
 void setScheme(java.lang.String scheme)
          Set the numerical scheme as a string.
 boolean setTime(double time)
          Set the current physical time
 void setTopic(java.lang.String topic)
          Set the topic as a string.
 void updateHeaders(RunData runData, int step)
          Updates the information for the headers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

topic

protected java.lang.String topic
The topic to be solved @see #setTopic


method

protected java.lang.String method
Numerical method name @see #setMethod


scheme

protected java.lang.String scheme
Numerical scheme name @see #setScheme


ic

protected java.lang.String ic
Initial condition name @see #setIC


time

protected double time
Absolute time @see #setTime


f0

protected double[] f0
Function time level 0 (IC) @see #f


fm

protected double[] fm
Function time level n-1


f

protected double[] f
Function time level n


fp

protected double[] fp
Function time level n+1


dfm

protected double[] dfm
Derivative time level n-1 @see #fm


df

protected double[] df
Derivative time level n @see #f


dfp

protected double[] dfp
Derivative time level n+1 @see #fp


gm

protected double[] gm
Extra Function time level n-1


g

protected double[] g
Extra Function time level n


gp

protected double[] gp
Extra Function time level n+1


dgm

protected double[] dgm
Extra Derivative time level n-1 @see #gm


dg

protected double[] dg
Extra Derivative time level n @see #g


dgp

protected double[] dgp
Extra Derivative time level n+1 @see #gp


mesh

protected Mesh mesh
The underlying mesh for the solution


x

protected double[] x
The mesh points @see #mesh


dx

protected double[] dx
The mesh intervals @see #mesh


initialMoments

protected double[] initialMoments
Store initial moments


xSize

protected int xSize
Horizontal scale of plot area


ySize

protected int ySize
Vertical scale of plot area


xOffset

protected int xOffset
Horizontal offset of plot area


yOffset

protected int yOffset
Vertical offset of plot area


x_0

protected double x_0
x of lower left corner of plot area


x_1

protected double x_1
x of upper right corner of plot area


y_0

protected double y_0
y of lower left corner of plot area


y_1

protected double y_1
y of upper right corner of plot area


lastStep

private int lastStep
The current step in the time discretization

Constructor Detail

Solution

public Solution(RunData runData)
Creates an instance of a Solution object with all the attributes.

Parameters:
runData - The run time parameters
Method Detail

calculateMoments

protected double calculateMoments(int m)
Internal function to calculate the initial moments of f[] or their deviation from the beginning of the evolution.

Parameters:
m - The order of the moment
Returns:
The value or deviation of the m:th moment of f[]
See Also:
momentsDeviation(int)

momentsDeviation

public double momentsDeviation(int m)
Calculates the deviation from the m:th initial moment.

Parameters:
m - The order of the moment
Returns:
The deviation of the m:th moment from the beginning

limits

protected double[] limits(boolean headers)
Calculates the solution boundaries.

Returns:
A vector with {min(solution), max(solution)}

setTopic

public void setTopic(java.lang.String topic)
Set the topic as a string.

Parameters:
topic - The name of the equation
See Also:
vmarket.RNDWALK

setMethod

public void setMethod(java.lang.String method)
Set the numerical method as a string.

Parameters:
method - The name of the numerical method
Returns:
True

setScheme

public void setScheme(java.lang.String scheme)
Set the numerical scheme as a string.

Parameters:
scheme - The name of the numerical scheme
Returns:
True

setIC

public void setIC(java.lang.String ic)
Set the initial condision as a string.

Parameters:
ic - The name of the initial condition
Returns:
True

setTime

public boolean setTime(double time)
Set the current physical time

Parameters:
time - Current time
Returns:
True

incTime

public boolean incTime(double time)
Increment the current physical time

Parameters:
time - Current time to add
Returns:
True

getTime

public double getTime()
Get the current physical time

Returns:
current time

discretize

public abstract void discretize(ShapeFunction function)
Discretize the initial shape and initialize the moments

Parameters:
function - The initial shape to be approximated

updateHeaders

public void updateHeaders(RunData runData,
                          int step)
Updates the information for the headers

Parameters:
runData - List of run parameters
step - The current step in the simulation
See Also:
plot(java.awt.Canvas, java.awt.Image, boolean)

next

public abstract boolean next(RunData runData)
Advance the solution forward one step in time. The equation is set by the internal variable equation_ and the numerical scheme by the internal variable scheme_

Parameters:
runData - List of run parameters
Returns:
True if a scheme is implemented for that equation
See Also:
RunData

previous

public abstract boolean previous(RunData runData)
Take the solution backward one step to initialize schemes with 3 time levels. The equation is set by the internal variable equation_ and the numerical scheme by the internal variable scheme_

Parameters:
runData - List of run parameters
Returns:
True if an initialisation scheme is implemented for that equation
See Also:
RunData

getValue

public double getValue(int index)
Gives the value of the function for an index

Parameters:
index - The index for which to get the value
Returns:
The value of the function at a given index

getValue

public double getValue(double arg)
Linear interpolation of the solution. Assumes a uniform mesh.

Parameters:
arg - Argument
Returns:
A linear interpolation of the function for a given argument

hasOption

public abstract boolean hasOption(java.lang.String option)
Tells whether the solution implements a option

Parameters:
option - The the option to implement
Returns:
True if the option is implemented
See Also:
vmarket.topicNames, vmarket.schemeNames

rescale

public void rescale(boolean headers)
Set the corners of the plot area


getWinSize

public int[] getWinSize()
Returns window size

See Also:
plot(java.awt.Canvas, java.awt.Image, boolean)

measure

public double[] measure(int x,
                        int y)
Get physical coordinates from mouse coordinates

Parameters:
x - horizontal mouse coordinate
y - vertical mouse coordinate
See Also:
plot(java.awt.Canvas, java.awt.Image, boolean)

output

public void output(int step)
Print the solution in ASCII to java console


plot

public void plot(java.awt.Canvas plotArea,
                 java.awt.Image offScrImage,
                 boolean headers)
Plots the solution

Parameters:
plotArea - The plot area
offScrImage - The off screen image to draw on
headers - Whether to draw headers