net.algart.model3d.common.movement.model
Class MovementIntegratorWrapper

java.lang.Object
  extended by net.algart.model3d.common.movement.model.MovementIntegratorWrapper
All Implemented Interfaces:
MovementIntegrator

public abstract class MovementIntegratorWrapper
extends java.lang.Object
implements MovementIntegrator

Wrapper, all method of which just call the same methods of some parent integrator. The only addition is that performIteration() method of this class also calls beforeIteration() and afterIteration() methods before and after calling parent.performIteration(). By default these methods do nothing, but you can override them to perform some additional corrections in the item set.

AlgART Laboratory 2010

Since:
JDK 1.5
Version:
1.0
Author:
Daniel Alievsky

Field Summary
Modifier and Type Field and Description
protected  MovementIntegrator parent
          The parent integrator, specified in the argument of the constructor.
 
Constructor Summary
Modifier Constructor and Description
protected MovementIntegratorWrapper(MovementIntegrator parent)
          Creates new instance of this class.
 
Method Summary
Modifier and Type Method and Description
protected  void afterIteration()
          This method is called by performIteration() method after that it calls parent.performIteration().
protected  void beforeIteration()
          This method is called by performIteration() method before that it calls parent.performIteration().
 void copyBasicSettings(MovementIntegrator source)
          Copies all basic settings, that can be accessed via getXxx/setXxx methods of this interface, from the specified object.
 double getAccelerationLimit()
          Returns the acceleration limit Amax.
 long getCounterOfCheckedNeighbours()
          Returns the internal thread-safe counter of "neighbour" item pairs, which were checked by MovementIntegrator.performIteration() method while calculation of the right side of the motion equations.
 long getCounterOfProcessedInteractions()
          Returns the internal thread-safe counter of really interacted item pairs, which were really processed by MovementIntegrator.performIteration() method while calculation of the right side of the motion equations, that is for which calculateForce method was really called and returned true.
 long getCounterOfProcessedItems()
          Returns the internal thread-safe counter of items, which were processed by MovementIntegrator.performIteration() method while calculation of the right side of the motion equations.
 long getCounterOfProcessedSymmetricInteractions()
          An analog of the counter MovementIntegrator.getCounterOfProcessedInteractions(), counting only pairs, which were processed in more efficient way thanks to symmetric interaction rules.
 double getDeltaT()
          Returns the time step Δt for one iteration of integration.
 java.util.List<InteractionRule> getInteractionRules()
          Returns the list of interaction rules, used by this object.
 ItemSet getItemSet()
          Returns the item set, processed by this object.
 int getNumberOfParallelTasks()
          Returns the current number of parallel threads, which is recommended this object to use for optimizing calculations on multiprocessor systems.
 double getT()
          Returns the current time t in the physical model.
 double getVelocityLimit()
          Returns the velocity limit Vmax.
 boolean getViscousForces()
          Returns true if this object works in the mode of viscous forces.
 void performIteration()
          Performs one iteration of integration.
 void resetCounters()
          Resets to 0 all internal counters, returned by MovementIntegrator.getCounterOfProcessedItems(), MovementIntegrator.getCounterOfCheckedNeighbours(), MovementIntegrator.getCounterOfProcessedInteractions() and MovementIntegrator.getCounterOfProcessedSymmetricInteractions() methods.
 void setAccelerationLimit(double accelerationLimit)
          Sets the acceleration limit Amax to the given value.
 void setDeltaT(double deltaT)
          Sets the current time Δt for one iteration of integration.
 void setNumberOfParallelTasks(int numberOfParallelTasks)
          Sets the number of parallel threads, which should be used, if possible, for optimizing calculations on multiprocessor systems.
 void setT(double t)
          Sets the current time t in the physical model.
 void setVelocityLimit(double velocityLimit)
          Sets the velocity limit Vmax to the given value.
 void setViscousForces(boolean viscousForces)
          Sets the mode of viscous forces ("pseudo-Newton's" motion equations), if the argument is true, or the usual mode (standard Newton's laws), if the argument is false See comments to this interface for more details.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.algart.model3d.common.movement.model.MovementIntegrator
isErrorInformationAvailable, maxLastCoordinateError, maxLastVelocityError, meanLastCoordinateError, meanLastVelocityError
 

Field Detail

parent

protected final MovementIntegrator parent
The parent integrator, specified in the argument of the constructor.

Constructor Detail

MovementIntegratorWrapper

protected MovementIntegratorWrapper(MovementIntegrator parent)
Creates new instance of this class.

Parameters:
parent - the instance of MovementIntegrator interface that will perform all operations.
Method Detail

getItemSet

public ItemSet getItemSet()
Description copied from interface: MovementIntegrator
Returns the item set, processed by this object. Usually it is set while instantiation and cannot be changed in future. But you can change this item set by methods of ItemSet interface.

Specified by:
getItemSet in interface MovementIntegrator
Returns:
the reference to ItemSet object, processed by this object.

getInteractionRules

public java.util.List<InteractionRule> getInteractionRules()
Description copied from interface: MovementIntegrator
Returns the list of interaction rules, used by this object. Usually it is set while instantiation and cannot be changed in future.

The result is an immutable view (Collections.unmodifiableList) or a clone of the internal collection, stored by this object: you cannot modify the set of used interaction rules via the result of this method.

The elements of the returned list are never null.

Specified by:
getInteractionRules in interface MovementIntegrator
Returns:
the list of interaction rules, used by this object.

getNumberOfParallelTasks

public int getNumberOfParallelTasks()
Description copied from interface: MovementIntegrator
Returns the current number of parallel threads, which is recommended this object to use for optimizing calculations on multiprocessor systems.

The returned value is always positive (>0).

Specified by:
getNumberOfParallelTasks in interface MovementIntegrator
Returns:
the current number of parallel threads for multiprocessor optimization.

setNumberOfParallelTasks

public void setNumberOfParallelTasks(int numberOfParallelTasks)
Description copied from interface: MovementIntegrator
Sets the number of parallel threads, which should be used, if possible, for optimizing calculations on multiprocessor systems. This value should not be greater than the number of available processors or processor kernels.

If this argument is 0, it is automatically replaced with Runtime.getRuntime().availableProcessors(): the number of available processors. Note that in this case MovementIntegrator.getNumberOfParallelTasks() method will return not 0, but the actual number of available processors.

Specified by:
setNumberOfParallelTasks in interface MovementIntegrator
Parameters:
numberOfParallelTasks - the desired number of parallel threads for multiprocessor optimization.

getViscousForces

public boolean getViscousForces()
Description copied from interface: MovementIntegrator
Returns true if this object works in the mode of viscous forces. See comments to this interface for more details.

Specified by:
getViscousForces in interface MovementIntegrator
Returns:
whether this object works in the mode of viscous forces.

setViscousForces

public void setViscousForces(boolean viscousForces)
Description copied from interface: MovementIntegrator
Sets the mode of viscous forces ("pseudo-Newton's" motion equations), if the argument is true, or the usual mode (standard Newton's laws), if the argument is false See comments to this interface for more details.

Specified by:
setViscousForces in interface MovementIntegrator
Parameters:
viscousForces - whether you this object should be switched in the mode of viscous forces.

getAccelerationLimit

public double getAccelerationLimit()
Description copied from interface: MovementIntegrator
Returns the acceleration limit Amax. It can be Double.POSITIVE_INFINITY: it means that the accelerations are not limited. See comments to this interface for more details.

Specified by:
getAccelerationLimit in interface MovementIntegrator
Returns:
the acceleration limit Amax.

setAccelerationLimit

public void setAccelerationLimit(double accelerationLimit)
Description copied from interface: MovementIntegrator
Sets the acceleration limit Amax to the given value. You can pass Double.POSITIVE_INFINITY: it means that the accelerations will be not limited. See comments to this interface for more details.

Specified by:
setAccelerationLimit in interface MovementIntegrator
Parameters:
accelerationLimit - new acceleration limit Amax.

getVelocityLimit

public double getVelocityLimit()
Description copied from interface: MovementIntegrator
Returns the velocity limit Vmax. It can be Double.POSITIVE_INFINITY: it means that the velocities are not limited. See comments to this interface for more details.

Specified by:
getVelocityLimit in interface MovementIntegrator
Returns:
the velocity limit Amax.

setVelocityLimit

public void setVelocityLimit(double velocityLimit)
Description copied from interface: MovementIntegrator
Sets the velocity limit Vmax to the given value. You can pass Double.POSITIVE_INFINITY: it means that the velocities will be not limited. See comments to this interface for more details.

Specified by:
setVelocityLimit in interface MovementIntegrator
Parameters:
velocityLimit - new velocity limit Vmax.

getT

public double getT()
Description copied from interface: MovementIntegrator
Returns the current time t in the physical model. It is usually 0.0 after creating new object and automatically updated (increased by Δt) by MovementIntegrator.performIteration() method.

Specified by:
getT in interface MovementIntegrator
Returns:
the current time t.
See Also:
MovementIntegrator.getDeltaT()

setT

public void setT(double t)
Description copied from interface: MovementIntegrator
Sets the current time t in the physical model.

Specified by:
setT in interface MovementIntegrator
Parameters:
t - new value of the current time t.

getDeltaT

public double getDeltaT()
Description copied from interface: MovementIntegrator
Returns the time step Δt for one iteration of integration. It is usually specified while instantiating new object. It cannot be negative.

Specified by:
getDeltaT in interface MovementIntegrator
Returns:
the time step Δt.

setDeltaT

public void setDeltaT(double deltaT)
Description copied from interface: MovementIntegrator
Sets the current time Δt for one iteration of integration.

Specified by:
setDeltaT in interface MovementIntegrator
Parameters:
deltaT - new value of the time step Δt.

copyBasicSettings

public void copyBasicSettings(MovementIntegrator source)
Description copied from interface: MovementIntegrator
Copies all basic settings, that can be accessed via getXxx/setXxx methods of this interface, from the specified object. In other words, this method is equivalent to the following calls:
 setNumberOfParallelTasks(source.getNumberOfParallelTasks());
 setViscousForces(source.getViscousForces());
 setAccelerationLimit(source.getAccelerationLimit());
 setVelocityLimit(source.getVelocityLimit());
 setT(source.getT());
 setDeltaT(source.getDeltaT());
 

Specified by:
copyBasicSettings in interface MovementIntegrator
Parameters:
source - another movement integrator, the basic settings of which should be copied into this one.

getCounterOfProcessedItems

public long getCounterOfProcessedItems()
Description copied from interface: MovementIntegrator
Returns the internal thread-safe counter of items, which were processed by MovementIntegrator.performIteration() method while calculation of the right side of the motion equations.

Note that MovementIntegrator.performIteration() can calculate the right side of the equations several times (as in Runge-Kutta algorithms), and then every item will be also counted several times. Usually the items, which do not have coordinates of centers and velocities or do not have masses, are not counted.

This counter is 0 after creating new instance of this class and can be set to 0 by MovementIntegrator.resetCounters() method.

This method is provided for profiling and debugging needs only. It works as described above in the implementations, offered by this package, but there is no guarantee that it will return correct values in all implementations. If the implementation does not provide this counter, this method should return 0 always.

Specified by:
getCounterOfProcessedItems in interface MovementIntegrator
Returns:
the counter of processed items.

getCounterOfCheckedNeighbours

public long getCounterOfCheckedNeighbours()
Description copied from interface: MovementIntegrator
Returns the internal thread-safe counter of "neighbour" item pairs, which were checked by MovementIntegrator.performIteration() method while calculation of the right side of the motion equations. This number depends on the implementation of ItemSet interface: good implementations, like GridItemSet, allow to check only restricted number of items while finding all "neighbours" of the given item, which can interact with it.

Note that the "neighbour" pair is counted independently for both its elements. In other words, it two items act to each other, their pair is counter twice.

Note that MovementIntegrator.performIteration() can calculate the right side of the equations several times (as in Runge-Kutta algorithms), and then every neighbour item pair will be also counted several times.

This counter is 0 after creating new instance of this class and can be set to 0 by MovementIntegrator.resetCounters() method.

This method is provided for profiling and debugging needs only. It works as described above in the implementations, offered by this package, but there is no guarantee that it will return correct values in all implementations. If the implementation does not provide this counter, this method should return 0 always.

Specified by:
getCounterOfCheckedNeighbours in interface MovementIntegrator
Returns:
the counter of processed "neighbour" item pairs.

getCounterOfProcessedInteractions

public long getCounterOfProcessedInteractions()
Description copied from interface: MovementIntegrator
Returns the internal thread-safe counter of really interacted item pairs, which were really processed by MovementIntegrator.performIteration() method while calculation of the right side of the motion equations, that is for which calculateForce method was really called and returned true.

Note that an interacted pair is counted independently for both items. In other words, it two items act to each other, their pair is counter twice.

Note that an interacted pair is counted again for every interaction rule, applicable for this pair. So, if there are K>1 rules, in which calculateForce method returned true for the given pair, then this pair will be counted K times.

Note that MovementIntegrator.performIteration() can calculate the right side of the equations several times (as in Runge-Kutta algorithms), and then every neighbour item pair will be also counted several times.

This counter is 0 after creating new instance of this class and can be set to 0 by MovementIntegrator.resetCounters() method.

This method is provided for profiling and debugging needs only. It works as described above in the implementations, offered by this package, but there is no guarantee that it will return correct values in all implementations. If the implementation does not provide this counter, this method should return 0 always.

Specified by:
getCounterOfProcessedInteractions in interface MovementIntegrator
Returns:
the counter of processed really interacted item pairs.

getCounterOfProcessedSymmetricInteractions

public long getCounterOfProcessedSymmetricInteractions()
Description copied from interface: MovementIntegrator
An analog of the counter MovementIntegrator.getCounterOfProcessedInteractions(), counting only pairs, which were processed in more efficient way thanks to symmetric interaction rules. Namely, some implementations of this interface can use the fact, that some interaction is symmetric (implements SymmetricInteractionRule), and calculate the interaction force only once. The force F' of acting of the 2nd item to the 1st one is produced from the force F of acting of the 1st item to the 2nd one by changing the sign: F'=−F. In this case, the counter, returned by this method, is increased by 2 for each such interaction rule, as well as the counter, returned by MovementIntegrator.getCounterOfProcessedInteractions() method. But some "neighbour" item pairs cannot be processed in such a manner, for example, when the first item is processed (moved) by one processor in multiprocessor system and the second one is processed by another processor. In such situation, this counter is not increased, though the counter, returned by MovementIntegrator.getCounterOfProcessedInteractions() method, is increased by 2 (by 1 for each from two items). So, this method can help to measure optimization, achieved thanks to usage of symmetric interaction rules.

This counter is 0 after creating new instance of this class and can be set to 0 by MovementIntegrator.resetCounters() method.

This method is provided for profiling and debugging needs only. It works as described above in the implementations, offered by this package, but there is no guarantee that it will return correct values in all implementations. If the implementation does not provide this counter, this method should return 0 always.

Specified by:
getCounterOfProcessedSymmetricInteractions in interface MovementIntegrator
Returns:
the counter of processed really interacted item pairs, for which the interaction force was not calculated twice, because of using symmetric interaction rules.

resetCounters

public void resetCounters()
Description copied from interface: MovementIntegrator
Resets to 0 all internal counters, returned by MovementIntegrator.getCounterOfProcessedItems(), MovementIntegrator.getCounterOfCheckedNeighbours(), MovementIntegrator.getCounterOfProcessedInteractions() and MovementIntegrator.getCounterOfProcessedSymmetricInteractions() methods.

Specified by:
resetCounters in interface MovementIntegrator

performIteration

public void performIteration()
Description copied from interface: MovementIntegrator
Performs one iteration of integration. This method sets the current time t to tt and correspondingly corrects the coordinates and velocities of all items in the processed item set, having centers and velocities and having masses, according to the motion equations. See comments to this interface for more details.

Specified by:
performIteration in interface MovementIntegrator

beforeIteration

protected void beforeIteration()
This method is called by performIteration() method before that it calls parent.performIteration(). This default implementation does nothing.


afterIteration

protected void afterIteration()
This method is called by performIteration() method after that it calls parent.performIteration(). This default implementation does nothing.



Hot at AlgART: HTML для чайников | Trinity for non-Christians | Диалог с Богом | Religion and Geometry