37#include "AbstractPurkinjeCellFactory.hpp"
38#include "PurkinjeVentricularJunctionStimulus.hpp"
39#include "MultiStimulus.hpp"
40#include "HeartConfig.hpp"
41#include "Warnings.hpp"
43template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
46 mpMixedDimensionMesh(NULL)
50template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
53 std::string pvj_file_name;
54 bool file_specified =
true;
63 file_specified =
false;
67 if (!file_specified || !junction_file.
Exists() )
70 WARNING(
"No Purkinje-Ventricular junction (.pvj) file found. Junctions must be specified manually.");
76 if (!junction_stream.good())
82 while (junction_stream.good())
84 std::string this_line;
85 getline(junction_stream, this_line);
87 if (this_line==
"" || this_line==
"\r")
89 if (junction_stream.eof())
98 std::stringstream line(this_line);
105 if (mpMixedDimensionMesh->rGetNodePermutation().size() != 0)
107 unsigned mapped_node_id = mpMixedDimensionMesh->rGetNodePermutation()[node_id];
109 mJunctionMap[mapped_node_id] = resistance;
113 mJunctionMap[node_id] = resistance;
118template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
127 assert(mpMixedDimensionMesh);
129 CableRangeAtNode cable_range = mpMixedDimensionMesh->GetCablesAtNode(pNode);
130 double total_cross_sectional_area = 0.0;
132 iter != cable_range.second;
137 total_cross_sectional_area += M_PI*cable_radius*cable_radius;
144 p_pvj_purkinje_stim->SetAppliedToPurkinjeCellModel();
145 p_pvj_ventricular_stim->SetVentricularCellModel(pCardiacCell);
146 p_pvj_ventricular_stim->SetPurkinjeCellModel(pPurkinjeCell);
147 p_pvj_purkinje_stim->SetVentricularCellModel(pCardiacCell);
148 p_pvj_purkinje_stim->SetPurkinjeCellModel(pPurkinjeCell);
151 boost::shared_ptr<MultiStimulus> p_multi_stim_ventricular(
new MultiStimulus);
152 p_multi_stim_ventricular->AddStimulus(p_pvj_ventricular_stim);
156 boost::shared_ptr<MultiStimulus> p_multi_stim_purkinje(
new MultiStimulus);
157 p_multi_stim_purkinje->AddStimulus(p_pvj_purkinje_stim);
162template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
166 if (mpMixedDimensionMesh == NULL)
168 EXCEPTION(
"AbstractPurkinjeCellFactory must take a MixedDimensionMesh");
170 mLocalPurkinjeNodes.clear();
172 iter != mpMixedDimensionMesh->GetCableElementIteratorEnd();
175 mLocalPurkinjeNodes.insert((*iter)->GetNodeGlobalIndex(0u));
176 mLocalPurkinjeNodes.insert((*iter)->GetNodeGlobalIndex(1u));
183template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
188 unsigned node_index = pNode->
GetIndex();
189 if (mLocalPurkinjeNodes.count(node_index)>0)
191 return CreatePurkinjeCellForTissueNode(pNode, pCardiacCell);
195 return new FakeBathCell(this->mpSolver, this->mpZeroStimulus);
199template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
202 if (mpMixedDimensionMesh == NULL)
204 EXCEPTION(
"The mixed dimension mesh object has not been set in the cell factory");
206 return mpMixedDimensionMesh;
209template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
214 std::map<unsigned, double>::iterator iter = mJunctionMap.find(pNode->
GetIndex());
215 if (iter != mJunctionMap.end())
217 CreateJunction(pNode, pPurkinjeCell, pCardiacCell, iter->second);
#define EXCEPTION(message)
virtual void SetMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
boost::shared_ptr< AbstractStimulusFunction > GetStimulusFunction()
void SetStimulusFunction(boost::shared_ptr< AbstractStimulusFunction > pStimulus)
void CreateJunctionFromFile(const Node< SPACE_DIM > *pNode, AbstractCardiacCellInterface *pPurkinjeCell, AbstractCardiacCellInterface *pCardiacCell)
AbstractCardiacCellInterface * CreatePurkinjeCellForNode(Node< SPACE_DIM > *pNode, AbstractCardiacCellInterface *pCardiacCell)
void SetMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
MixedDimensionMesh< ELEMENT_DIM, SPACE_DIM > * GetMixedDimensionMesh()
void CreateJunction(const Node< SPACE_DIM > *pNode, AbstractCardiacCellInterface *pPurkinjeCell, AbstractCardiacCellInterface *pCardiacCell, double resistance)
std::string GetAbsolutePath() const
std::string GetMeshName() const
double GetPurkinjeSurfaceAreaToVolumeRatio()
static HeartConfig * Instance()
std::vector< Element< 1, SPACE_DIM > * >::const_iterator CableElementIterator
std::pair< NodeCableIterator, NodeCableIterator > CableRangeAtNode
std::multimap< constNode< SPACE_DIM > *, Element< 1u, SPACE_DIM > * >::iterator NodeCableIterator
unsigned GetIndex() const