Class AbstractStepInterpolator
- java.lang.Object
-
- org.spaceroots.mantissa.ode.AbstractStepInterpolator
-
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, StepInterpolator
- Direct Known Subclasses:
- DummyStepInterpolator
public abstract class AbstractStepInterpolator extends java.lang.Object implements StepInterpolator, java.lang.Cloneable
This abstract class represents an interpolator over the last step during an ODE integration.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).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description java.lang.Objectclone()Copy the instance.voidfinalizeStep()Finalize the step.doublegetCurrentTime()Get the current grid point time.double[]getInterpolatedState()Get the state vector of the interpolated point.doublegetInterpolatedTime()Get the time of the interpolated point.doublegetPreviousTime()Get the previous grid point time.booleanisForward()Check if the natural integration direction is forward.abstract voidreadExternal(java.io.ObjectInput in)voidsetInterpolatedTime(double time)Set the time of the interpolated point.voidshift()Shift one step forward.voidstoreTime(double t)Store the current step time.abstract voidwriteExternal(java.io.ObjectOutput out)
-
-
-
Method Detail
-
clone
public java.lang.Object clone()
Copy the instance.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
NullPointerExceptionlater. 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.
- Overrides:
clonein classjava.lang.Object- Returns:
- a copy of the instance.
-
shift
public void shift()
Shift one step forward. Copy the current time into the previous time, hence preparing the interpolator for future calls tostoreTime
-
storeTime
public void storeTime(double t)
Store the current step time.- Parameters:
t- current time
-
getPreviousTime
public double getPreviousTime()
Get the previous grid point time.- Specified by:
getPreviousTimein interfaceStepInterpolator- Returns:
- previous grid point time
-
getCurrentTime
public double getCurrentTime()
Get the current grid point time.- Specified by:
getCurrentTimein interfaceStepInterpolator- Returns:
- current grid point time
-
getInterpolatedTime
public double getInterpolatedTime()
Get the time of the interpolated point. IfsetInterpolatedTime(double)has not been called, it returns the current grid point time.- Specified by:
getInterpolatedTimein interfaceStepInterpolator- Returns:
- interpolation point time
-
setInterpolatedTime
public void setInterpolatedTime(double time) throws DerivativeExceptionSet the time of the interpolated point.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.
- Specified by:
setInterpolatedTimein interfaceStepInterpolator- Parameters:
time- time of the interpolated point- Throws:
DerivativeException- if this call induces an automatic step finalization that throws one
-
isForward
public boolean isForward()
Check if the natural integration direction is forward.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.
- Specified by:
isForwardin interfaceStepInterpolator- Returns:
- true if the integration variable (time) increases during integration
-
getInterpolatedState
public double[] getInterpolatedState()
Get the state vector of the interpolated point.- Specified by:
getInterpolatedStatein interfaceStepInterpolator- Returns:
- state vector at time
getInterpolatedTime()
-
finalizeStep
public final void finalizeStep() throws DerivativeExceptionFinalize the step.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
handleStepis valid only for the duration of thehandleStepcall, 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
doFinalizemethod if it has never been called during this step and set a flag indicating that it has been called once. It is thedoFinalizemethod which should perform the evaluations. This wrapping prevents from callingdoFinalizeseveral times and hence evaluating the differential equations too often. Therefore, subclasses are not allowed not reimplement it, they should rather reimplementdoFinalize.- Throws:
DerivativeException- this exception is propagated to the caller if the underlying user function triggers one
-
writeExternal
public abstract void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public abstract void readExternal(java.io.ObjectInput in) throws java.io.IOException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG