#include <AdaptiveBidomainProblem.hpp>
Inherits BidomainProblem< 3 >.
Class which specifies and solves a bidomain problem using adaptivity.
The solution vector is of the form: (V_1, phi_1, V_2, phi_2, ......, V_N, phi_N), where V_j is the voltage at node j and phi_j is the extracellular potential at node j
Adaptivity occurs at each printing time step (to avoid having to add a variable to the XML schema at this stage): this will need tidying up at some point in the future
Definition at line 87 of file AdaptiveBidomainProblem.hpp.
AdaptiveBidomainProblem::AdaptiveBidomainProblem | ( | AbstractCardiacCellFactory< 3 > * | pCellFactory, | |
bool | hasBath = false | |||
) |
Constructor
pCellFactory | User defined cell factory which shows how the tissue should create cells. | |
hasBath | Whether the simulation has a bath (if this is true, all elements with attribute = 1 will be set to be bath elements (the rest should have attribute = 0)). |
Definition at line 54 of file AdaptiveBidomainProblem.cpp.
References BidomainProblem< 3 >::mFixedExtracellularPotentialNodes, and mpAdaptiveMesh.
AdaptiveBidomainProblem::~AdaptiveBidomainProblem | ( | ) |
void AdaptiveBidomainProblem::AdaptMesh | ( | ) |
Adapt the mesh, recontruct the mesh, cell factory, boundary conditions container, bidomain tissue and solver and call InitializeSolutionOnAdaptedMesh()
If the adapt fails for any reason then nothing is done (i.e. we don't recreate objects that remain unchanged)
Definition at line 201 of file AdaptiveBidomainProblem.cpp.
References AdaptiveTetrahedralMesh::AdaptMesh(), GenericEventHandler< 16, HeartEventHandler >::BeginEvent(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::ConstructFromMeshReader(), GenericEventHandler< 16, HeartEventHandler >::EndEvent(), AdaptiveTetrahedralMesh::GetAdaptSuccess(), AdaptiveTetrahedralMesh::GetNumNodes(), AdaptiveTetrahedralMesh::GetVtkUnstructuredGrid(), InitializeSolutionOnAdaptedMesh(), HeartConfig::Instance(), mpAdaptiveMesh, BidomainProblem< 3 >::mpBidomainTissue, AbstractCardiacProblem< DIM, DIM, 2 >::mpBoundaryConditionsContainer, AbstractCardiacProblem< DIM, DIM, 2 >::mpCardiacTissue, AbstractCardiacProblem< DIM, DIM, 2 >::mpCellFactory, AbstractCardiacProblem< DIM, DIM, 2 >::mpMesh, mpSolver, mUseNeumannBoundaryConditions, AbstractCardiacProblem< DIM, DIM, 2 >::mWriteInfo, NEVER_REACHED, AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::SetTimeStep(), and SetupNeumannBoundaryConditionOnMesh().
Referenced by Solve().
void AdaptiveBidomainProblem::AddCurrentSolutionToAdaptiveMesh | ( | Vec | solution | ) |
Add the values of all state variables into the adaptive mesh (as VTK node point data) so that they can (a) be used to drive mesh adaption; and/or (b) be interpolated onto the new mesh nodes.
solution | The current solution vector |
Definition at line 89 of file AdaptiveBidomainProblem.cpp.
References AdaptiveTetrahedralMesh::AddPointData(), GenericEventHandler< 16, HeartEventHandler >::BeginEvent(), GenericEventHandler< 16, HeartEventHandler >::EndEvent(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::GetCardiacCell(), AbstractCardiacCellInterface::GetVoltageIndex(), mpAdaptiveMesh, BidomainProblem< 3 >::mpBidomainTissue, AbstractCardiacProblem< DIM, DIM, 2 >::mpMesh, and AbstractUntemplatedParameterisedSystem::rGetStateVariableNames().
Referenced by Solve().
void AdaptiveBidomainProblem::DoNotAdaptMesh | ( | ) |
Method to stop any further adapts taking place
Definition at line 78 of file AdaptiveBidomainProblem.cpp.
References mIsMeshAdapting.
double AdaptiveBidomainProblem::GetGradation | ( | ) |
Return value of mGradation
Definition at line 294 of file AdaptiveBidomainProblem.cpp.
References HeartConfig::GetGradationForAdaptivity(), and HeartConfig::Instance().
double AdaptiveBidomainProblem::GetMaxEdgeLength | ( | ) |
Return value of mMaxEdgeLength
Definition at line 284 of file AdaptiveBidomainProblem.cpp.
References HeartConfig::GetMaxEdgeLengthForAdaptivity(), and HeartConfig::Instance().
unsigned AdaptiveBidomainProblem::GetMaxMeshNodes | ( | ) |
Return value of mMaxMeshNodes
Definition at line 299 of file AdaptiveBidomainProblem.cpp.
References HeartConfig::GetMaxNodesForAdaptivity(), and HeartConfig::Instance().
double AdaptiveBidomainProblem::GetMinEdgeLength | ( | ) |
Return value of mMinEdgeLength
Definition at line 289 of file AdaptiveBidomainProblem.cpp.
References HeartConfig::GetMinEdgeLengthForAdaptivity(), and HeartConfig::Instance().
unsigned AdaptiveBidomainProblem::GetNumAdaptSweeps | ( | ) |
Return value of mNumAdaptSweeps
Definition at line 304 of file AdaptiveBidomainProblem.cpp.
References HeartConfig::GetNumberOfAdaptiveSweeps(), and HeartConfig::Instance().
double AdaptiveBidomainProblem::GetSigma | ( | ) |
Return value of mSigma
Definition at line 279 of file AdaptiveBidomainProblem.cpp.
References HeartConfig::GetSigmaForAdaptivity(), and HeartConfig::Instance().
double AdaptiveBidomainProblem::GetTargetError | ( | ) |
Return value of mError
Definition at line 274 of file AdaptiveBidomainProblem.cpp.
References HeartConfig::GetTargetErrorForAdaptivity(), and HeartConfig::Instance().
void AdaptiveBidomainProblem::InitializeSolutionOnAdaptedMesh | ( | VtkMeshReader< 3, 3 > * | reader | ) |
Extract the values of state variables from VTK format following adaption and initialize the values of mSolution and the cardiac cell models at each mesh node for simulation on the new mesh
reader |
Definition at line 133 of file AdaptiveBidomainProblem.cpp.
References DistributedVector::Begin(), GenericEventHandler< 16, HeartEventHandler >::BeginEvent(), DistributedVector::End(), GenericEventHandler< 16, HeartEventHandler >::EndEvent(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::GetCardiacCell(), VtkMeshReader< ELEMENT_DIM, SPACE_DIM >::GetPointData(), AbstractCardiacCellInterface::GetVoltageIndex(), BidomainProblem< 3 >::mpBidomainTissue, AbstractCardiacProblem< DIM, DIM, 2 >::mpMesh, AbstractCardiacProblem< DIM, DIM, 2 >::mSolution, DistributedVector::Restore(), AbstractUntemplatedParameterisedSystem::rGetStateVariableNames(), and AbstractParameterisedSystem< VECTOR >::SetStateVariable().
Referenced by AdaptMesh(), and Solve().
void AdaptiveBidomainProblem::LoadSimulationFromVtuFile | ( | ) |
Restore a simulation previously saved as a .vtu file. Generates mesh and initial conditions (on V, phi and ODE state variables).
Location of .vtu file is assumed to have been set by HeartConfig::SetMesh(). The alternative (constructing its own mesh) doesn't make much sense since the .vtu file must contain a mesh in order to store the variable values at each point of it.
Definition at line 345 of file AdaptiveBidomainProblem.cpp.
References AbstractCardiacProblem< DIM, DIM, 2 >::Initialise(), and mInitializeFromVtu.
void AdaptiveBidomainProblem::SetNeumannStimulusMagnitudeAndDuration | ( | double | magnitude, | |
double | duration, | |||
double | period = DBL_MAX | |||
) |
Initialize magnitude and duration of a Neumann stimulus (must have called UseNeumannBoundaryConditions() or UseNeumannBoundaryConditions( true ) for this to have any effect)
magnitude | Value of mNeumannStimulusMagnitude | |
duration | Value of mNeumannStimulusDuration | |
period | Optional parameter used to specify after how long a regular stimulus is repeated |
Definition at line 261 of file AdaptiveBidomainProblem.cpp.
References HeartConfig::Instance(), mNeumannStimulusDuration, mNeumannStimulusMagnitude, and mNeumannStimulusPeriod.
void AdaptiveBidomainProblem::SetupNeumannBoundaryConditionOnMesh | ( | ) |
Create a new boundary conditions container to handle the specified Neumann boundary conditions on the mesh. Needs to be called every time a new mesh is constructed (i.e. after every successful adapt)
Definition at line 309 of file AdaptiveBidomainProblem.cpp.
References mNeumannStimulusIndex, mNeumannStimulusLowerValue, mNeumannStimulusUpperValue, AbstractCardiacProblem< DIM, DIM, 2 >::mpBoundaryConditionsContainer, AbstractCardiacProblem< DIM, DIM, 2 >::mpMesh, mpNeumannStimulus, and mpNeumannStimulusBoundaryCondition.
Referenced by AdaptMesh(), and Solve().
void AdaptiveBidomainProblem::Solve | ( | ) |
Performs some checks by calling the PreSolveChecks method, creates a solver to which it passes the boundary conditions specified by the user (otherwise it passes the defauls bcc), then at each printing step calls the AdaptMesh method and the Solve method in the solver class to solve the system up until the next printing time step (for the moment, printing time steps and adapt time steps are synonymous)
Also outputs VTK files that record the solution (and the mesh) at each printing time step
Reimplemented from AbstractCardiacProblem< DIM, DIM, 2 >.
Definition at line 351 of file AdaptiveBidomainProblem.cpp.
References AdaptMesh(), AddCurrentSolutionToAdaptiveMesh(), TimeStepper::AdvanceOneTimeStep(), GenericEventHandler< 16, HeartEventHandler >::BeginEvent(), AdaptiveTetrahedralMesh::CalculateSENListAndSids(), AbstractCardiacProblem< DIM, DIM, 2 >::CloseFilesAndPostProcess(), AdaptiveTetrahedralMesh::ConstructFromMesh(), AdaptiveTetrahedralMesh::ConstructFromVtuFile(), BidomainProblem< 3 >::CreateInitialCondition(), GenericEventHandler< 16, HeartEventHandler >::EndEvent(), TimeStepper::GetNextTime(), OutputFileHandler::GetOutputDirectoryFullPath(), HeartConfig::GetOutputFilenamePrefix(), TimeStepper::GetTime(), InitializeSolutionOnAdaptedMesh(), HeartConfig::Instance(), TimeStepper::IsTimeAtEnd(), mInitializeFromVtu, mIsMeshAdapting, mNeumannStimulusDuration, mNeumannStimulusIndex, mNeumannStimulusLowerValue, mNeumannStimulusMagnitude, mNeumannStimulusPeriod, mNeumannStimulusUpperValue, mOutputDirectory, mOutputFilenamePrefix, mpAdaptiveMesh, BidomainProblem< 3 >::mpBidomainTissue, AbstractCardiacProblem< DIM, DIM, 2 >::mpBoundaryConditionsContainer, AbstractCardiacProblem< DIM, DIM, 2 >::mpDefaultBoundaryConditionsContainer, AbstractCardiacProblem< DIM, DIM, 2 >::mpMesh, mpNeumannStimulus, AbstractCardiacProblem< DIM, DIM, 2 >::mPrintOutput, mpSolver, AbstractCardiacProblem< DIM, DIM, 2 >::mSolution, mUseNeumannBoundaryConditions, AbstractCardiacProblem< DIM, DIM, 2 >::mWriteInfo, BidomainProblem< 3 >::OnEndOfTimestep(), BidomainProblem< 3 >::PreSolveChecks(), ProgressReporter::PrintFinalising(), PetscTools::ReplicateException(), GenericEventHandler< 16, HeartEventHandler >::Reset(), AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::SetInitialCondition(), AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::SetTimes(), AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::SetTimeStep(), SetupNeumannBoundaryConditionOnMesh(), AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), ProgressReporter::Update(), BidomainProblem< 3 >::WriteInfo(), and AdaptiveTetrahedralMesh::WriteMeshToFile().
void AdaptiveBidomainProblem::UseNeumannBoundaryCondition | ( | unsigned | index = 0 |
) |
Specify that Neumann boundary conditions will be used. Use with caution: not all Neumann boundary conditions lead to a well-posed problem. Best used only on cuboid geometries, when a stimulus is applied to the face x_i=a and the face x_i=b is grounded.
index | The value i when applying the Neumann BCs to x_i=a and x_i=b (a<b) (default = 0) |
Definition at line 268 of file AdaptiveBidomainProblem.cpp.
References mNeumannStimulusIndex, and mUseNeumannBoundaryConditions.
Whether or not we are initializing from a .vtu file
Definition at line 105 of file AdaptiveBidomainProblem.hpp.
Referenced by LoadSimulationFromVtuFile(), and Solve().
bool AdaptiveBidomainProblem::mIsMeshAdapting [private] |
Whether the mesh is to be adapted or not
Definition at line 103 of file AdaptiveBidomainProblem.hpp.
Referenced by DoNotAdaptMesh(), and Solve().
Duration of any Neumann stimulus
Definition at line 118 of file AdaptiveBidomainProblem.hpp.
Referenced by SetNeumannStimulusMagnitudeAndDuration(), and Solve().
The value i when applying Neumann boundary conditions to x_i=a and x_i=b (a<b)
Definition at line 110 of file AdaptiveBidomainProblem.hpp.
Referenced by SetupNeumannBoundaryConditionOnMesh(), Solve(), and UseNeumannBoundaryCondition().
The value a when applying Neumann boundary conditions to x_i=a and x_i=b (a<b)
Definition at line 112 of file AdaptiveBidomainProblem.hpp.
Referenced by SetupNeumannBoundaryConditionOnMesh(), and Solve().
Magnitude of any Neumann stimulus
Definition at line 116 of file AdaptiveBidomainProblem.hpp.
Referenced by SetNeumannStimulusMagnitudeAndDuration(), and Solve().
Period of any repeating Neumannn stimulus
Definition at line 120 of file AdaptiveBidomainProblem.hpp.
Referenced by SetNeumannStimulusMagnitudeAndDuration(), and Solve().
The value b when applying Neumann boundary conditions to x_i=a and x_i=b (a<b)
Definition at line 114 of file AdaptiveBidomainProblem.hpp.
Referenced by SetupNeumannBoundaryConditionOnMesh(), and Solve().
std::string AdaptiveBidomainProblem::mOutputDirectory [private] |
Determine whether or not an edge of the mesh is of sufficient quality. Edge is "good" if the error metric associated with it is in the range [ 1 - mGoodEdgeRange , 1 + mGoodEdgeRange ] Proportion of edges that must be deemed "bad" (i.e. not good) before an adapt takes place Directory in which output files should be saved.
Definition at line 136 of file AdaptiveBidomainProblem.hpp.
Referenced by Solve().
std::string AdaptiveBidomainProblem::mOutputFilenamePrefix [private] |
Filename prefix for output files
Definition at line 139 of file AdaptiveBidomainProblem.hpp.
Referenced by Solve().
Adaptive tetrahedral mesh: used to interface with adaptivity library
Definition at line 101 of file AdaptiveBidomainProblem.hpp.
Referenced by AdaptiveBidomainProblem(), AdaptMesh(), AddCurrentSolutionToAdaptiveMesh(), Solve(), and ~AdaptiveBidomainProblem().
Neumann stimulus function
Definition at line 122 of file AdaptiveBidomainProblem.hpp.
Referenced by SetupNeumannBoundaryConditionOnMesh(), and Solve().
Neumann boundary condition
Definition at line 124 of file AdaptiveBidomainProblem.hpp.
Referenced by SetupNeumannBoundaryConditionOnMesh().
BidomainSolver<3,3>* AdaptiveBidomainProblem::mpSolver [private] |
We need to save the solver that is being used to switch off the electrodes (by adding default boundary conditions to the solver)
Reimplemented from BidomainProblem< 3 >.
Definition at line 98 of file AdaptiveBidomainProblem.hpp.
Referenced by AdaptMesh(), and Solve().
Whether we are applying Neumann bounadry conditions or not (default = false)
Definition at line 108 of file AdaptiveBidomainProblem.hpp.
Referenced by AdaptMesh(), Solve(), and UseNeumannBoundaryCondition().