37 #include "AbstractPurkinjeCellFactory.hpp" 38 #include "PurkinjeVentricularJunctionStimulus.hpp" 39 #include "MultiStimulus.hpp" 40 #include "HeartConfig.hpp" 41 #include "Warnings.hpp" 43 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
46 mpMixedDimensionMesh(NULL)
50 template<
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;
118 template<
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);
162 template<
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));
183 template<
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);
199 template<
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;
209 template<
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);
double GetPurkinjeSurfaceAreaToVolumeRatio()
AbstractCardiacCellInterface * CreatePurkinjeCellForNode(Node< SPACE_DIM > *pNode, AbstractCardiacCellInterface *pCardiacCell)
std::pair< NodeCableIterator, NodeCableIterator > CableRangeAtNode
std::string GetAbsolutePath() const
#define EXCEPTION(message)
MixedDimensionMesh< ELEMENT_DIM, SPACE_DIM > * GetMixedDimensionMesh()
void SetStimulusFunction(boost::shared_ptr< AbstractStimulusFunction > pStimulus)
std::string GetMeshName() const
std::multimap< const Node< SPACE_DIM > *, Element< 1u, SPACE_DIM > * >::iterator NodeCableIterator
void CreateJunctionFromFile(const Node< SPACE_DIM > *pNode, AbstractCardiacCellInterface *pPurkinjeCell, AbstractCardiacCellInterface *pCardiacCell)
void SetMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
virtual void SetMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
boost::shared_ptr< AbstractStimulusFunction > GetStimulusFunction()
unsigned GetIndex() const
void CreateJunction(const Node< SPACE_DIM > *pNode, AbstractCardiacCellInterface *pPurkinjeCell, AbstractCardiacCellInterface *pCardiacCell, double resistance)
static HeartConfig * Instance()
std::vector< Element< 1, SPACE_DIM > * >::const_iterator CableElementIterator