public abstract class AbstractStepInterpolator extends java.lang.Object implements StepInterpolator, java.lang.Cloneable
The various ODE integrators provide objects extending this class to the step handlers. The handlers can use these objects to retrieve the state vector at intermediate times between the previous and the current grid points (dense output).
FirstOrderIntegrator,
SecondOrderIntegrator,
StepHandler,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected double[] |
currentState
current state
|
protected double |
currentTime
current time
|
protected double |
h
current time step
|
protected double[] |
interpolatedState
interpolated state
|
protected double |
interpolatedTime
interpolated time
|
protected double |
previousTime
previous time
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractStepInterpolator()
Simple constructor.
|
protected |
AbstractStepInterpolator(AbstractStepInterpolator interpolator)
Copy constructor.
|
protected |
AbstractStepInterpolator(double[] y,
boolean forward)
Simple constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Copy the instance.
|
protected abstract void |
computeInterpolatedState(double theta,
double oneMinusThetaH)
Compute the state at the interpolated time.
|
protected void |
doFinalize()
Really finalize the step.
|
void |
finalizeStep()
Finalize the step.
|
double |
getCurrentTime()
Get the current grid point time.
|
double[] |
getInterpolatedState()
Get the state vector of the interpolated point.
|
double |
getInterpolatedTime()
Get the time of the interpolated point.
|
double |
getPreviousTime()
Get the previous grid point time.
|
boolean |
isForward()
Check if the natural integration direction is forward.
|
protected double |
readBaseExternal(java.io.ObjectInput in)
Read the base state of the instance.
|
abstract void |
readExternal(java.io.ObjectInput in) |
protected void |
reinitialize(double[] y,
boolean forward)
Reinitialize the instance
|
void |
setInterpolatedTime(double time)
Set the time of the interpolated point.
|
void |
shift()
Shift one step forward.
|
void |
storeTime(double t)
Store the current step time.
|
protected void |
writeBaseExternal(java.io.ObjectOutput out)
Save the base state of the instance.
|
abstract void |
writeExternal(java.io.ObjectOutput out) |
protected double previousTime
protected double currentTime
protected double h
protected double[] currentState
protected double interpolatedTime
protected double[] interpolatedState
protected AbstractStepInterpolator()
reinitialize(double[], boolean) method should be called before using the
instance in order to initialize the internal arrays. This
constructor is used only in order to delay the initialization in
some cases. As an example, the RungeKuttaFehlbergIntegrator uses the prototyping design pattern
to create the step interpolators by cloning an uninitialized
model and latter initializing the copy.protected AbstractStepInterpolator(double[] y,
boolean forward)
y - reference to the integrator array holding the state at
the end of the stepforward - integration direction indicatorprotected AbstractStepInterpolator(AbstractStepInterpolator interpolator)
The copied interpolator should have been finalized before the
copy, otherwise the copy will not be able to perform correctly
any derivative computation and will throw a NullPointerException later. Since we don't want this constructor
to throw the exceptions finalization may involve and since we
don't want this method to modify the state of the copied
interpolator, finalization is not done
automatically, it remains under user control.
The copy is a deep copy: its arrays are separated from the original arrays of the instance.
interpolator - interpolator to copy from.protected void reinitialize(double[] y,
boolean forward)
y - reference to the integrator array holding the state at
the end of the stepforward - integration direction indicatorpublic java.lang.Object clone()
The copied interpolator should have been finalized before the
copy, otherwise the copy will not be able to perform correctly any
interpolation and will throw a NullPointerException
later. Since we don't want this constructor to throw the
exceptions finalization may involve and since we don't want this
method to modify the state of the copied interpolator,
finalization is not done automatically, it
remains under user control.
The copy is a deep copy: its arrays are separated from the original arrays of the instance.
This method has been redeclared as public instead of protected.
clone in class java.lang.Objectpublic void shift()
storeTimepublic void storeTime(double t)
t - current timepublic double getPreviousTime()
getPreviousTime in interface StepInterpolatorpublic double getCurrentTime()
getCurrentTime in interface StepInterpolatorpublic double getInterpolatedTime()
setInterpolatedTime(double) has not been called, it returns
the current grid point time.getInterpolatedTime in interface StepInterpolatorpublic void setInterpolatedTime(double time)
throws DerivativeException
Setting the time outside of the current step is now allowed (it was not allowed up to version 5.4 of Mantissa), but should be used with care since the accuracy of the interpolator will probably be very poor far from this step. This allowance has been added to simplify implementation of search algorithms near the step endpoints.
setInterpolatedTime in interface StepInterpolatortime - time of the interpolated pointDerivativeException - if this call induces an automatic
step finalization that throws onepublic boolean isForward()
This method provides the integration direction as specified by the integrator itself, it avoid some nasty problems in degenerated cases like null steps due to cancellation at step initialization, step control or switching function triggering.
isForward in interface StepInterpolatorprotected abstract void computeInterpolatedState(double theta,
double oneMinusThetaH)
throws DerivativeException
theta - normalized interpolation abscissa within the step
(theta is zero at the previous time step and one at the current time step)oneMinusThetaH - time gap between the interpolated time and
the current timeDerivativeException - this exception is propagated to the caller if the
underlying user function triggers onepublic double[] getInterpolatedState()
getInterpolatedState in interface StepInterpolatorgetInterpolatedTime()public final void finalizeStep()
throws DerivativeException
Some Runge-Kutta-Fehlberg integrators need fewer functions
evaluations than their counterpart step interpolators. These
interpolators should perform the last evaluations they need by
themselves only if they need them. This method triggers these
extra evaluations. It can be called directly by the user step
handler and it is called automatically if setInterpolatedTime(double) is called.
Once this method has been called, no other evaluation will be performed on this step. If there is a need to have some side effects between the step handler and the differential equations (for example update some data in the equations once the step has been done), it is advised to call this method explicitly from the step handler before these side effects are set up. If the step handler induces no side effect, then this method can safely be ignored, it will be called transparently as needed.
Warning: since the step interpolator provided
to the step handler as a parameter of the handleStep is valid only for the duration
of the handleStep call, one cannot
simply store a reference and reuse it later. One should first
finalize the instance, then copy this finalized instance into a
new object that can be kept.
This method calls the protected doFinalize
method if it has never been called during this step and set a
flag indicating that it has been called once. It is the doFinalize method which should perform the
evaluations. This wrapping prevents from calling doFinalize several times and hence evaluating the
differential equations too often. Therefore, subclasses are not
allowed not reimplement it, they should rather reimplement doFinalize.
DerivativeException - this exception is propagated to the
caller if the underlying user function triggers oneprotected void doFinalize()
throws DerivativeException
DerivativeException - this exception is propagated to the
caller if the underlying user function triggers onepublic abstract void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOExceptionpublic abstract void readExternal(java.io.ObjectInput in)
throws java.io.IOException
readExternal in interface java.io.Externalizablejava.io.IOExceptionprotected void writeBaseExternal(java.io.ObjectOutput out)
throws java.io.IOException
out - stream where to save the statejava.io.IOException - in case of write errorprotected double readBaseExternal(java.io.ObjectInput in)
throws java.io.IOException
setInterpolatedTime(double) method later,
once all rest of the object state has been set up properly.in - stream where to read the state fromjava.io.IOException - in case of read errorCopyright © 2001-2007 Luc Maisonobe. All Rights Reserved.