Chaste Commit::f2ff7ee04e70ac9d06c57344df8d017dbb12b97b
AbstractCardiacCellFactory.cpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#include "AbstractCardiacCellFactory.hpp"
37#include "FakeBathCell.hpp"
38#include "AbstractCvodeCell.hpp"
39#include "HeartConfig.hpp"
40
41template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
43 Node<SPACE_DIM>* pNode)
44{
46 {
47 return new FakeBathCell(this->mpSolver, this->mpZeroStimulus);
48 }
49 else
50 {
51 AbstractCardiacCellInterface* p_cell = CreateCardiacCellForTissueNode(pNode);
52#ifdef CHASTE_CVODE
53 if (dynamic_cast<AbstractCvodeCell*>(p_cell))
54 {
55#if CHASTE_SUNDIALS_VERSION >= 20400
56 // Tell the single cell model solver not to re-initialise on subsequent Solve calls.
57 // Unfortunately the oldest CVODE we currently support (2.5.0 in Sundials 2.3.0) doesn't
58 // work very well this this enabled, so we will go without and take a performance hit.
59 static_cast<AbstractCvodeCell*>(p_cell)->SetMinimalReset(true);
60#endif // SUNDIALS_VERSION
61 // Use the PDE timestep as the [maximum] CVODE timestep.
62 static_cast<AbstractCvodeCell*>(p_cell)->SetTimestep(HeartConfig::Instance()->GetPdeTimeStep());
63 }
64#endif // CHASTE_CVODE
65 return p_cell;
66 }
67}
68
69template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
71 std::vector< AbstractCardiacCellInterface* >* pCellsDistributed,
72 unsigned lo,
73 unsigned hi)
74{
75}
76
77template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
79{
80 EXCEPTION("To get here you have probably asked for Epi/Mid/Endo CellularHeterogeneities in your HeartConfig "
81 "options or configuration .xml file, to use this you will need to provide a method"
82 " `FillInCellularTransmuralAreas()` in your cell factory to override this one.");
83}
84
85template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
87{
88 assert(mpMesh != NULL);
89 return mpMesh->GetNumNodes();
90}
91
92template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
94 boost::shared_ptr<AbstractIvpOdeSolver> pSolver)
95 : mpMesh(NULL),
96 mpHeartGeometryInformation(NULL),
97 mpZeroStimulus(new ZeroStimulus),
98 mpSolver(pSolver)
99{
101
102template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
106
107template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
112
113template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
115{
116 if (mpMesh == NULL)
117 {
118 EXCEPTION("The mesh object has not been set in the cell factory");
119 }
120 return mpMesh;
121}
122
123template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
126 mpHeartGeometryInformation = pHeartGeometryInformation;
127}
128
129template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
131{
132 if (mpHeartGeometryInformation == NULL)
133 {
134 EXCEPTION("HeartGeometryInformation object has not been set in the cell factory");
135 }
136 return mpHeartGeometryInformation;
138
139// Explicit instantiation
#define EXCEPTION(message)
virtual AbstractCardiacCellInterface * CreateCardiacCellForNode(Node< SPACE_DIM > *pNode)
virtual void SetMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * GetMesh()
virtual void FinaliseCellCreation(std::vector< AbstractCardiacCellInterface * > *pCellsDistributed, unsigned lo, unsigned hi)
void SetHeartGeometryInformation(HeartGeometryInformation< SPACE_DIM > *pHeartGeometryInformation)
AbstractCardiacCellFactory(boost::shared_ptr< AbstractIvpOdeSolver > pSolver=boost::shared_ptr< AbstractIvpOdeSolver >(new EulerIvpOdeSolver))
HeartGeometryInformation< SPACE_DIM > * GetHeartGeometryInformation()
double GetPdeTimeStep() const
static HeartConfig * Instance()
static bool IsRegionBath(HeartRegionType regionId)
Definition Node.hpp:59
unsigned GetRegion() const
Definition Node.cpp:437