Chaste  Release::2018.1
AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM > Class Template Referenceabstract

#include <AbstractNumericalMethod.hpp>

+ Inheritance diagram for AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >:
+ Collaboration diagram for AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >:

Public Member Functions

 AbstractNumericalMethod ()
 
virtual ~AbstractNumericalMethod ()
 
void SetCellPopulation (AbstractOffLatticeCellPopulation< ELEMENT_DIM, SPACE_DIM > *pPopulation)
 
void SetForceCollection (std::vector< boost::shared_ptr< AbstractForce< ELEMENT_DIM, SPACE_DIM > > > *pForces)
 
void SetUseAdaptiveTimestep (bool useAdaptiveTimestep)
 
void SetUseUpdateNodeLocation (bool useUpdateNodeLocation)
 
bool GetUseUpdateNodeLocation ()
 
bool HasAdaptiveTimestep ()
 
virtual void UpdateAllNodePositions (double dt)=0
 
void OutputNumericalMethodInfo (out_stream &rParamsFile)
 
virtual void OutputNumericalMethodParameters (out_stream &rParamsFile)
 
- Public Member Functions inherited from Identifiable
virtual ~Identifiable ()
 
std::string GetIdentifier () const
 

Protected Member Functions

std::vector< c_vector< double,
SPACE_DIM > > 
ComputeForcesIncludingDamping ()
 
std::vector< c_vector< double,
SPACE_DIM > > 
SaveCurrentLocations ()
 
void SafeNodePositionUpdate (unsigned nodeIndex, c_vector< double, SPACE_DIM > newPosition)
 
void DetectStepSizeExceptions (unsigned nodeIndex, c_vector< double, SPACE_DIM > &displacement, double dt)
 

Protected Attributes

AbstractOffLatticeCellPopulation
< ELEMENT_DIM, SPACE_DIM > * 
mpCellPopulation
 
std::vector< boost::shared_ptr
< AbstractForce< ELEMENT_DIM,
SPACE_DIM > > > * 
mpForceCollection
 
bool mUseAdaptiveTimestep
 
bool mUseUpdateNodeLocation
 
bool mGhostNodeForcesEnabled
 

Private Member Functions

template<class Archive >
void serialize (Archive &archive, const unsigned int version)
 

Friends

class TestNumericalMethods
 
class boost::serialization::access
 

Detailed Description

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
class AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >

An abstract class representing a numerical method for off lattice cell based simulations.

Numerical methods have access to the cell population and the force collection. The method is then responsible for evaluating forces at whatever times and positions are required, then updating all node positions.

Definition at line 55 of file AbstractNumericalMethod.hpp.

Constructor & Destructor Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::AbstractNumericalMethod ( )

Constructor. No input parameters are required, allowing the numerical method to be created first, then passed to the simulation. The cell population and force collection pointers are then set by the simulation in its constructor.

Definition at line 45 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::~AbstractNumericalMethod ( )
virtual

Destructor.

Definition at line 56 of file AbstractNumericalMethod.cpp.

Member Function Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::vector< c_vector< double, SPACE_DIM > > AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::ComputeForcesIncludingDamping ( )
protected

Computes and returns the force on each node, including the damping factor

Returns
A vector of applied forces

Here we deal with the special case forces on ghost nodes. Note that 'particles' are dealt with like normal cells.

Todo:
#2087 Consider removing dynamic_cast and instead adding a virtual method ApplyForcesToNonCellNodes()

Definition at line 101 of file AbstractNumericalMethod.cpp.

References GenericEventHandler< 11, CellBasedEventHandler >::BeginEvent(), and GenericEventHandler< 11, CellBasedEventHandler >::EndEvent().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::DetectStepSizeExceptions ( unsigned  nodeIndex,
c_vector< double, SPACE_DIM > &  displacement,
double  dt 
)
protected

Detects whether a node has exceeded the acceptable displacement for one timestep. If a step size exception has occurred, it either causes the simulation to terminate or, in adaptive simulations, the exception is caught and the step size is reduced in response.

Parameters
nodeIndexIndex of the node being examined
displacementDisplacement of the node this step
dtTime step size

Definition at line 168 of file AbstractNumericalMethod.cpp.

References StepSizeException::IsTerminal(), and StepSizeException::what().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
bool AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::GetUseUpdateNodeLocation ( )

Get mUseUpdateNodeLocation.

Returns
whether the population method UpdateNodeLocations() is being used

Definition at line 199 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
bool AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::HasAdaptiveTimestep ( )
Returns
whether the numerical method uses an adaptive time step.

Definition at line 95 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::OutputNumericalMethodInfo ( out_stream &  rParamsFile)

Saves the name of the numerical method to the parameters file

Parameters
rParamsFileReference to the parameter output filestream

Definition at line 205 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::OutputNumericalMethodParameters ( out_stream &  rParamsFile)
virtual

Saves any additional numerical method details to the parameters file.

Parameters
rParamsFileReference to the parameter output filestream

Reimplemented in ForwardEulerNumericalMethod< ELEMENT_DIM, SPACE_DIM >.

Definition at line 215 of file AbstractNumericalMethod.cpp.

Referenced by ForwardEulerNumericalMethod< ELEMENT_DIM, SPACE_DIM >::OutputNumericalMethodParameters().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::SafeNodePositionUpdate ( unsigned  nodeIndex,
c_vector< double, SPACE_DIM >  newPosition 
)
protected

Updates a single node's position, taking into account periodic boundary conditions

Parameters
nodeIndexIndex of the node to update
newPositionC_vector holding the new node position

Definition at line 161 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::vector< c_vector< double, SPACE_DIM > > AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::SaveCurrentLocations ( )
protected

Saves the current location of each cell in the population in a vector.

Returns
A vector of cell positions

Definition at line 145 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
template<class Archive >
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::serialize ( Archive &  archive,
const unsigned int  version 
)
inlineprivate
template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::SetCellPopulation ( AbstractOffLatticeCellPopulation< ELEMENT_DIM, SPACE_DIM > *  pPopulation)

Sets the pointer to the cell population updated by this method

Parameters
pPopulationPointer to an AbstractOffLattice cell population

Definition at line 61 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::SetForceCollection ( std::vector< boost::shared_ptr< AbstractForce< ELEMENT_DIM, SPACE_DIM > > > *  pForces)

Sets the pointer to the force collection applied by this method

Parameters
pForcesPointer to the simulation's force collection

Definition at line 83 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::SetUseAdaptiveTimestep ( bool  useAdaptiveTimestep)

Set mUseAdaptiveTimestep.

Parameters
useAdaptiveTimestepwhether to use an adaptive time step

Definition at line 89 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::SetUseUpdateNodeLocation ( bool  useUpdateNodeLocation)

Set mUseUpdateNodeLocation.

Parameters
useUpdateNodeLocationwhether to use the population method UpdateNodeLocations()

Definition at line 193 of file AbstractNumericalMethod.cpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
virtual void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::UpdateAllNodePositions ( double  dt)
pure virtual

Updates node positions according to Newton's 2nd law with overdamping.

As this method is pure virtual, it must be overridden in subclasses.

Parameters
dtTime step size

Implemented in ForwardEulerNumericalMethod< ELEMENT_DIM, SPACE_DIM >.

Friends And Related Function Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
friend class boost::serialization::access
friend

Needed for serialization.

Definition at line 62 of file AbstractNumericalMethod.hpp.

Member Data Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
bool AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::mGhostNodeForcesEnabled
protected

A boolean indicating whether this cell population type contains ghost nodes. Initialized to true in the AbstractNumericalMethod constructor.

Definition at line 107 of file AbstractNumericalMethod.hpp.

Referenced by AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::serialize().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
AbstractOffLatticeCellPopulation<ELEMENT_DIM,SPACE_DIM>* AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::mpCellPopulation
protected

Pointer to the cell population being updated by this method

Definition at line 81 of file AbstractNumericalMethod.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
std::vector<boost::shared_ptr<AbstractForce<ELEMENT_DIM, SPACE_DIM> > >* AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::mpForceCollection
protected

Pointer to the force collection to apply

Definition at line 84 of file AbstractNumericalMethod.hpp.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
bool AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::mUseAdaptiveTimestep
protected

Whether the numerical method uses an adaptive time step. Initialized to false in the AbstractNumericalMethod constructor.

Definition at line 90 of file AbstractNumericalMethod.hpp.

Referenced by AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::serialize().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
bool AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::mUseUpdateNodeLocation
protected

A boolean flag indicating whether non-forward Euler methods are supported for this type of cell population. Allows us to fall back to the old method of updating node positions for populations that require it (This is only for NodeBasedCellPopulationWithBuskeUpdates).

Initialized to false in the AbstractNumericalMethod constructor.

Todo:
#2087 Consider replacing this with static_casts

Definition at line 101 of file AbstractNumericalMethod.hpp.

Referenced by AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::serialize().


The documentation for this class was generated from the following files: