Chaste Release::3.1
CellBasedPdeHandler< DIM > Class Template Reference

#include <CellBasedPdeHandler.hpp>

Inheritance diagram for CellBasedPdeHandler< DIM >:
Collaboration diagram for CellBasedPdeHandler< DIM >:

List of all members.

Public Member Functions

 CellBasedPdeHandler (AbstractCellPopulation< DIM > *pCellPopulation, bool deleteMemberPointersInDestructor=false)
virtual ~CellBasedPdeHandler ()
const AbstractCellPopulation
< DIM > * 
GetCellPopulation () const
TetrahedralMesh< DIM, DIM > * GetCoarsePdeMesh ()
void OpenResultsFiles (std::string outputDirectory)
void CloseResultsFiles ()
bool GetWriteAverageRadialPdeSolution ()
bool GetWriteDailyAverageRadialPdeSolution ()
void UpdateCellPdeElementMap ()
bool GetImposeBcsOnCoarseBoundary ()
unsigned GetNumRadialIntervals ()
virtual void SolvePdeAndWriteResultsToFile (unsigned samplingTimestepMultiple)
unsigned FindCoarseElementContainingCell (CellPtr pCell)
virtual Vec GetPdeSolution (const std::string &rName="")
void SetWriteAverageRadialPdeSolution (const std::string &rName, unsigned numRadialIntervals=10, bool writeDailyResults=false)
void SetImposeBcsOnCoarseBoundary (bool setBcsOnCoarseBoundary)
virtual void UseCoarsePdeMesh (double stepSize, ChasteCuboid< DIM > meshCuboid, bool centreOnCellPopulation=false)
void AddPdeAndBc (PdeAndBoundaryConditions< DIM > *pPdeAndBc)
virtual void OutputParameters (out_stream &rParamsFile)

Protected Member Functions

void InitialiseCellPdeElementMap ()
virtual void WritePdeSolution (double time)
void WriteAverageRadialPdeSolution (double time)
bool PdeSolveNeedsCoarseMesh ()

Protected Attributes

AbstractCellPopulation< DIM > * mpCellPopulation
std::vector
< PdeAndBoundaryConditions
< DIM > * > 
mPdeAndBcCollection
out_stream mpVizPdeSolutionResultsFile
out_stream mpAverageRadialPdeSolutionResultsFile
bool mWriteAverageRadialPdeSolution
bool mWriteDailyAverageRadialPdeSolution
std::string mAverageRadialSolutionVariableName
bool mSetBcsOnCoarseBoundary
unsigned mNumRadialIntervals
TetrahedralMesh< DIM, DIM > * mpCoarsePdeMesh
std::map< CellPtr, unsignedmCellPdeElementMap
bool mDeleteMemberPointersInDestructor

Private Member Functions

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

Friends

class TestCellBasedPdeHandler
class TestOffLatticeSimulationWithPdes
class TestOnLatticeSimulationWithPdes
class boost::serialization::access

Detailed Description

template<unsigned DIM>
class CellBasedPdeHandler< DIM >

A helper class, containing code for handling the numerical solution of one or more PDEs (using the finite element method) associated with a cell-based simulation object.

By letting AbstractCellBasedSimulation have a pointer to an object of this type as a member variable, we separate out all PDE-related functionality into this class, and thus obviate the need for specialized cell-based simulation subclasses.

Definition at line 59 of file CellBasedPdeHandler.hpp.


Constructor & Destructor Documentation

template<unsigned DIM>
CellBasedPdeHandler< DIM >::CellBasedPdeHandler ( AbstractCellPopulation< DIM > *  pCellPopulation,
bool  deleteMemberPointersInDestructor = false 
)

Constructor.

Parameters:
pCellPopulationpointer to a cell population
deleteMemberPointersInDestructorwhether to delete member pointers in the destructor (defaults to false)

Todo:
change to exceptions (#1891)

Definition at line 46 of file CellBasedPdeHandler.cpp.

References AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM >::GetNumRealCells(), and CellBasedPdeHandler< DIM >::mpCellPopulation.

template<unsigned DIM>
CellBasedPdeHandler< DIM >::~CellBasedPdeHandler ( ) [virtual]

Destructor.

Definition at line 63 of file CellBasedPdeHandler.cpp.


Member Function Documentation

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::AddPdeAndBc ( PdeAndBoundaryConditions< DIM > *  pPdeAndBc)

Pass a PDE and associated boundary conditions to the simulation.

Parameters:
pPdeAndBca pointer to a PdeAndBoundaryConditions object

Definition at line 97 of file CellBasedPdeHandler.cpp.

References EXCEPTION, and PdeAndBoundaryConditions< DIM >::rGetDependentVariableName().

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::CloseResultsFiles ( )

Close results files. Called by AbstractCellBasedSimulation::Solve().

Definition at line 212 of file CellBasedPdeHandler.cpp.

References PetscTools::AmMaster(), and SimulationTime::Instance().

template<unsigned DIM>
unsigned CellBasedPdeHandler< DIM >::FindCoarseElementContainingCell ( CellPtr  pCell)

Find the index of the coarse mesh element containing a given cell.

Parameters:
pCellthe cell
Returns:
the element index.

Definition at line 525 of file CellBasedPdeHandler.cpp.

References AbstractElement< ELEMENT_DIM, SPACE_DIM >::GetNode().

template<unsigned DIM>
const AbstractCellPopulation< DIM > * CellBasedPdeHandler< DIM >::GetCellPopulation ( ) const

Get a pointer to the cell population.

Returns:
a const pointer to mpCellPopulation

Definition at line 85 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
TetrahedralMesh< DIM, DIM > * CellBasedPdeHandler< DIM >::GetCoarsePdeMesh ( )
Returns:
mpCoarsePdeMesh

Definition at line 91 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
bool CellBasedPdeHandler< DIM >::GetImposeBcsOnCoarseBoundary ( )
Returns:
mSetBcsOnCoarseBoundary

Definition at line 716 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
unsigned CellBasedPdeHandler< DIM >::GetNumRadialIntervals ( )
Returns:
mNumRadialIntervals

Definition at line 722 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
Vec CellBasedPdeHandler< DIM >::GetPdeSolution ( const std::string &  rName = "") [virtual]

Get the solution to the PDE at this time step.

Parameters:
rNameThe name of the dependent variable for the PDE in the vector mPdeAndBcCollection. This defaults to an empty string in the case there is only one PDE.

Definition at line 114 of file CellBasedPdeHandler.cpp.

References EXCEPTION.

template<unsigned DIM>
bool CellBasedPdeHandler< DIM >::GetWriteAverageRadialPdeSolution ( )
Returns:
mWriteAverageRadialPdeSolution

Definition at line 704 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
bool CellBasedPdeHandler< DIM >::GetWriteDailyAverageRadialPdeSolution ( )
Returns:
mWriteDailyAverageRadialPdeSolution

Definition at line 710 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::InitialiseCellPdeElementMap ( ) [protected]

Initialise mCellPdeElementMap.

This method is only called Solve(), but is written as a separate method for testing purposes.

Definition at line 136 of file CellBasedPdeHandler.cpp.

References AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM >::Begin(), and EXCEPTION.

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::OpenResultsFiles ( std::string  outputDirectory)

Open results files and write initial conditions to file. Called by AbstractCellBasedSimulation::Solve().

Parameters:
outputDirectorythe output directory, relative to where Chaste output is stored

Definition at line 171 of file CellBasedPdeHandler.cpp.

References PetscTools::AmMaster(), EXCEPTION, SimulationTime::GetTime(), SimulationTime::Instance(), OutputFileHandler::OpenOutputFile(), and AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMesh().

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::OutputParameters ( out_stream &  rParamsFile) [virtual]

Output parameters to file.

Parameters:
rParamsFilethe file stream to which the parameters are output

Definition at line 728 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
bool CellBasedPdeHandler< DIM >::PdeSolveNeedsCoarseMesh ( ) [protected]
Returns:
Whether the population being used requires the use of separate `coarse` mesh to solve PDEs

Definition at line 741 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
template<class Archive >
void CellBasedPdeHandler< DIM >::serialize ( Archive &  archive,
const unsigned int  version 
) [inline, private]

Archive the member variables.

Parameters:
archivethe archive
versionthe current version of this class

Definition at line 77 of file CellBasedPdeHandler.hpp.

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::SetImposeBcsOnCoarseBoundary ( bool  setBcsOnCoarseBoundary)

Impose the PDE boundary conditions on the edge of the cell population when using the coarse mesh. The default option is to impose the condition on the boundary of the coarse mesh.

Parameters:
setBcsOnCoarseBoundarywhether to impose the BCs on the edge of the cell population

Definition at line 639 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::SetWriteAverageRadialPdeSolution ( const std::string &  rName,
unsigned  numRadialIntervals = 10,
bool  writeDailyResults = false 
)

Write the final (and optionally also the daily) average radial PDE solution to file.

Parameters:
rNameThe name of the quantity that we are averaging.
numRadialIntervalsThe number of radial intervals in which the average PDE solution is calculated (defaults to 10)
writeDailyResultsWhether to record the average radial PDE solution at the end of each day of the simulation (defaults to false)

Definition at line 630 of file CellBasedPdeHandler.cpp.

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::SolvePdeAndWriteResultsToFile ( unsigned  samplingTimestepMultiple) [virtual]

Solve the PDE and write the solution to file.

Parameters:
samplingTimestepMultiplethe ratio of the number of actual timesteps to the number of timesteps at which results are written to file.

Todo:
enable this (#1891)
Todo:
enable the coarse PDE mesh to change size, e.g. for a growing domain (#630/#1891)
Todo:
enable this in the case where a coarse PDE mesh is used
Todo:
Worry about round-off errors (#1891)

Definition at line 293 of file CellBasedPdeHandler.cpp.

References BoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::AddDirichletBoundaryCondition(), BoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::AddNeumannBoundaryCondition(), AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM >::Begin(), Element< ELEMENT_DIM, SPACE_DIM >::CalculateInterpolationWeights(), PetscTools::Destroy(), PdeAndBoundaryConditions< DIM >::DestroySolution(), EXCEPTION, PdeAndBoundaryConditions< DIM >::GetBoundaryCondition(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetBoundaryElementIteratorBegin(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetBoundaryElementIteratorEnd(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetBoundaryNodeIteratorBegin(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetBoundaryNodeIteratorEnd(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetElement(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNode(), AbstractElement< ELEMENT_DIM, SPACE_DIM >::GetNodeGlobalIndex(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetNumElements(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNumNodes(), PdeAndBoundaryConditions< DIM >::GetPde(), PdeAndBoundaryConditions< DIM >::GetSolution(), SimulationTime::GetTime(), SimulationTime::GetTimeStep(), SimulationTime::GetTimeStepsElapsed(), SimulationTime::Instance(), PdeAndBoundaryConditions< DIM >::IsNeumannBoundaryCondition(), PdeAndBoundaryConditions< DIM >::SetSolution(), and PdeAndBoundaryConditions< DIM >::SetUpSourceTermsForAveragedSourcePde().

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::UpdateCellPdeElementMap ( )

Update the mCellPdeElementMap

This method should be called before sending the element map to a PDE class to ensure map is up to date.

Definition at line 157 of file CellBasedPdeHandler.cpp.

References AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM >::Begin().

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::UseCoarsePdeMesh ( double  stepSize,
ChasteCuboid< DIM >  meshCuboid,
bool  centreOnCellPopulation = false 
) [virtual]

Solve the PDE problem on a coarse mesh.

Parameters:
stepSizehorizontal and vertical distance between mesh points
meshCuboidthe cuboid defining the size and location of the mesh.
centreOnCellPopulationwhether to centre the coarse mesh on the centre of the cell population.

Definition at line 227 of file CellBasedPdeHandler.cpp.

References AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructRegularSlabMesh(), EXCEPTION, ChasteCuboid< SPACE_DIM >::GetWidth(), NEVER_REACHED, ChastePoint< DIM >::rGetLocation(), ChasteCuboid< SPACE_DIM >::rGetLowerCorner(), and ChasteCuboid< SPACE_DIM >::rGetUpperCorner().

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::WriteAverageRadialPdeSolution ( double  time) [protected]

Write the average radial PDE solution to file at a specified time.

Parameters:
timeThe time at which to record the average radial PDE solution

Definition at line 645 of file CellBasedPdeHandler.cpp.

References AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM >::Begin().

template<unsigned DIM>
void CellBasedPdeHandler< DIM >::WritePdeSolution ( double  time) [protected, virtual]

Write the PDE solution to file at a specified time.

Parameters:
timeThe time at which to record the PDE solution

Todo:
consider whether a different initial condition is more appropriate (#1891)

Definition at line 557 of file CellBasedPdeHandler.cpp.

References PetscTools::AmMaster(), AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM >::Begin(), and PdeAndBoundaryConditions< DIM >::GetSolution().


Friends And Related Function Documentation

template<unsigned DIM>
friend class boost::serialization::access [friend]

Needed for serialization.

Definition at line 69 of file CellBasedPdeHandler.hpp.


Member Data Documentation

template<unsigned DIM>
std::string CellBasedPdeHandler< DIM >::mAverageRadialSolutionVariableName [protected]

The name of the quantity that gets averaged.

Definition at line 108 of file CellBasedPdeHandler.hpp.

Referenced by CellBasedPdeHandler< SPACE_DIM >::serialize().

template<unsigned DIM>
std::map<CellPtr, unsigned> CellBasedPdeHandler< DIM >::mCellPdeElementMap [protected]

Map between cells and the elements of the coarse PDE mesh containing them.

Definition at line 120 of file CellBasedPdeHandler.hpp.

template<unsigned DIM>
bool CellBasedPdeHandler< DIM >::mDeleteMemberPointersInDestructor [protected]

Whether to delete member pointers in the destructor. Used in archiving.

Definition at line 126 of file CellBasedPdeHandler.hpp.

template<unsigned DIM>
unsigned CellBasedPdeHandler< DIM >::mNumRadialIntervals [protected]

Number of radial 'bins' used to calculate the average radial PDE solution.

Definition at line 114 of file CellBasedPdeHandler.hpp.

Referenced by CellBasedPdeHandler< SPACE_DIM >::serialize().

template<unsigned DIM>
out_stream CellBasedPdeHandler< DIM >::mpAverageRadialPdeSolutionResultsFile [protected]

File that the average radial PDE solution is written out to.

Definition at line 99 of file CellBasedPdeHandler.hpp.

template<unsigned DIM>
AbstractCellPopulation<DIM>* CellBasedPdeHandler< DIM >::mpCellPopulation [protected]

Pointer to a cell population.

Definition at line 90 of file CellBasedPdeHandler.hpp.

Referenced by CellBasedPdeHandler< DIM >::CellBasedPdeHandler().

template<unsigned DIM>
TetrahedralMesh<DIM,DIM>* CellBasedPdeHandler< DIM >::mpCoarsePdeMesh [protected]

Coarse mesh on which to solve the PDE.

Definition at line 117 of file CellBasedPdeHandler.hpp.

template<unsigned DIM>
std::vector<PdeAndBoundaryConditions<DIM>*> CellBasedPdeHandler< DIM >::mPdeAndBcCollection [protected]

Vector of pointers to linear elliptic PDE objects with additional boundary condition information.

Definition at line 93 of file CellBasedPdeHandler.hpp.

Referenced by CellBasedPdeHandler< SPACE_DIM >::serialize().

template<unsigned DIM>
out_stream CellBasedPdeHandler< DIM >::mpVizPdeSolutionResultsFile [protected]

File that the values of the PDE solution are written out to.

Definition at line 96 of file CellBasedPdeHandler.hpp.

template<unsigned DIM>
bool CellBasedPdeHandler< DIM >::mSetBcsOnCoarseBoundary [protected]

Whether to set the boundary condition on the edge of the coarse mesh rather than the cell population.

Definition at line 111 of file CellBasedPdeHandler.hpp.

Referenced by CellBasedPdeHandler< SPACE_DIM >::serialize().

template<unsigned DIM>
bool CellBasedPdeHandler< DIM >::mWriteAverageRadialPdeSolution [protected]

Whether to write to file the average radial PDE solution.

Definition at line 102 of file CellBasedPdeHandler.hpp.

Referenced by CellBasedPdeHandler< SPACE_DIM >::serialize().

template<unsigned DIM>
bool CellBasedPdeHandler< DIM >::mWriteDailyAverageRadialPdeSolution [protected]

Whether to write the average radial PDE solution daily.

Definition at line 105 of file CellBasedPdeHandler.hpp.

Referenced by CellBasedPdeHandler< SPACE_DIM >::serialize().


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