Chaste Commit::29c3c4ab2bee00ddd311a035a1e522c03cbe928a
AbstractCardiacCellFactory.cpp
1/*
2
3Copyright (c) 2005-2026, 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 if (dynamic_cast<AbstractCvodeCell*>(p_cell))
53 {
54 // Tell the single cell model solver not to re-initialise on subsequent Solve calls.
55 static_cast<AbstractCvodeCell*>(p_cell)->SetMinimalReset(true);
56 // Use the PDE timestep as the [maximum] CVODE timestep.
57 static_cast<AbstractCvodeCell*>(p_cell)->SetTimestep(HeartConfig::Instance()->GetPdeTimeStep());
58 }
59 return p_cell;
60 }
61}
62
63template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
65 std::vector< AbstractCardiacCellInterface* >* pCellsDistributed,
66 unsigned lo,
67 unsigned hi)
68{
69}
70
71template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
73{
74 EXCEPTION("To get here you have probably asked for Epi/Mid/Endo CellularHeterogeneities in your HeartConfig "
75 "options or configuration .xml file, to use this you will need to provide a method"
76 " `FillInCellularTransmuralAreas()` in your cell factory to override this one.");
77}
78
79template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
81{
82 assert(mpMesh != NULL);
83 return mpMesh->GetNumNodes();
84}
85
86template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
88 boost::shared_ptr<AbstractIvpOdeSolver> pSolver)
89 : mpMesh(NULL),
90 mpHeartGeometryInformation(NULL),
91 mpZeroStimulus(new ZeroStimulus),
92 mpSolver(pSolver)
93{
94}
95
96template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
101template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
106
107template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
109{
110 if (mpMesh == NULL)
111 {
112 EXCEPTION("The mesh object has not been set in the cell factory");
113 }
114 return mpMesh;
115}
116
117template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
119{
120 mpHeartGeometryInformation = pHeartGeometryInformation;
121}
122
123template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
126 if (mpHeartGeometryInformation == NULL)
127 {
128 EXCEPTION("HeartGeometryInformation object has not been set in the cell factory");
129 }
130 return mpHeartGeometryInformation;
131}
132
133// 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