Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
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 SetBoundaryConditions (std::vector< boost::shared_ptr< AbstractCellPopulationBoundaryCondition< ELEMENT_DIM, SPACE_DIM > > > *pBoundaryConditions)
 
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::map< Node< SPACE_DIM > *, c_vector< double, SPACE_DIM > > SaveCurrentNodeLocations ()
 
void ImposeBoundaryConditions (std::map< Node< SPACE_DIM > *, c_vector< double, SPACE_DIM > > &rOldNodeLocations)
 
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
 
std::vector< boost::shared_ptr< AbstractCellPopulationBoundaryCondition< ELEMENT_DIM, SPACE_DIM > > > * mpBoundaryConditions
 
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 56 of file AbstractNumericalMethod.hpp.

Constructor & Destructor Documentation

◆ AbstractNumericalMethod()

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.

◆ ~AbstractNumericalMethod()

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

◆ ComputeForcesIncludingDamping()

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 134 of file AbstractNumericalMethod.cpp.

◆ DetectStepSizeExceptions()

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 201 of file AbstractNumericalMethod.cpp.

◆ GetUseUpdateNodeLocation()

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 232 of file AbstractNumericalMethod.cpp.

◆ HasAdaptiveTimestep()

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 101 of file AbstractNumericalMethod.cpp.

◆ ImposeBoundaryConditions()

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::ImposeBoundaryConditions ( std::map< Node< SPACE_DIM > *, c_vector< double, SPACE_DIM > > &  rOldNodeLocations)
protected

Helper method to apply boundary conditions. Used in higher order methods like RK4.

Parameters
rOldNodeLocationsthe node locations prior to being updated.

Definition at line 122 of file AbstractNumericalMethod.cpp.

◆ OutputNumericalMethodInfo()

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 238 of file AbstractNumericalMethod.cpp.

◆ OutputNumericalMethodParameters()

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 248 of file AbstractNumericalMethod.cpp.

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

◆ SafeNodePositionUpdate()

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 194 of file AbstractNumericalMethod.cpp.

◆ SaveCurrentLocations()

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 178 of file AbstractNumericalMethod.cpp.

◆ SaveCurrentNodeLocations()

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::map< Node< SPACE_DIM > *, c_vector< double, SPACE_DIM > > AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::SaveCurrentNodeLocations ( )
protected

Helper method to store the node locations used when applying the boundary conditions in higher order methods.

Returns
the current node locations.

Definition at line 107 of file AbstractNumericalMethod.cpp.

◆ serialize()

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

◆ SetBoundaryConditions()

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void AbstractNumericalMethod< ELEMENT_DIM, SPACE_DIM >::SetBoundaryConditions ( std::vector< boost::shared_ptr< AbstractCellPopulationBoundaryCondition< ELEMENT_DIM, SPACE_DIM > > > *  pBoundaryConditions)

Sets the pointer to the boundary conditions applied by this method

Parameters
pBoundaryConditionsPointer to the simulation's boundary condition collection

Definition at line 89 of file AbstractNumericalMethod.cpp.

◆ SetCellPopulation()

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.

◆ SetForceCollection()

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.

◆ SetUseAdaptiveTimestep()

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 95 of file AbstractNumericalMethod.cpp.

◆ SetUseUpdateNodeLocation()

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 226 of file AbstractNumericalMethod.cpp.

◆ UpdateAllNodePositions()

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 Symbol Documentation

◆ boost::serialization::access

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

Needed for serialization.

Definition at line 63 of file AbstractNumericalMethod.hpp.

◆ TestNumericalMethods

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
friend class TestNumericalMethods
friend

Definition at line 58 of file AbstractNumericalMethod.hpp.

Member Data Documentation

◆ mGhostNodeForcesEnabled

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 111 of file AbstractNumericalMethod.hpp.

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

◆ mpBoundaryConditions

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

Pointer to the boundary conditions to apply

Definition at line 88 of file AbstractNumericalMethod.hpp.

◆ mpCellPopulation

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 82 of file AbstractNumericalMethod.hpp.

◆ mpForceCollection

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 85 of file AbstractNumericalMethod.hpp.

◆ mUseAdaptiveTimestep

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 94 of file AbstractNumericalMethod.hpp.

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

◆ mUseUpdateNodeLocation

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 105 of file AbstractNumericalMethod.hpp.

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


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