37 #include "AbstractPurkinjeCellFactory.hpp"
38 #include "PurkinjeVentricularJunctionStimulus.hpp"
39 #include "MultiStimulus.hpp"
40 #include "HeartConfig.hpp"
41 #include "Warnings.hpp"
45 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
48 mpMixedDimensionMesh(NULL)
52 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
55 std::string pvj_file_name;
56 bool file_specified =
true;
65 file_specified =
false;
69 if (!file_specified || !junction_file.
Exists() )
72 WARNING(
"No Purkinje-Ventricular junction (.pvj) file found. Junctions must be specified manually.");
78 if(!junction_stream.good())
84 while(junction_stream.good())
86 std::string this_line;
87 getline(junction_stream, this_line);
89 if (this_line==
"" || this_line==
"\r")
91 if (junction_stream.eof())
100 std::stringstream line(this_line);
107 if(mpMixedDimensionMesh->rGetNodePermutation().size() != 0)
109 unsigned mapped_node_id = mpMixedDimensionMesh->rGetNodePermutation()[node_id];
111 mJunctionMap[mapped_node_id] = resistance;
115 mJunctionMap[node_id] = resistance;
120 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
129 assert(mpMixedDimensionMesh);
131 CableRangeAtNode cable_range = mpMixedDimensionMesh->GetCablesAtNode(pNode);
132 double total_cross_sectional_area = 0.0;
134 iter != cable_range.second;
139 total_cross_sectional_area += M_PI*cable_radius*cable_radius;
146 p_pvj_purkinje_stim->SetAppliedToPurkinjeCellModel();
147 p_pvj_ventricular_stim->SetVentricularCellModel(pCardiacCell);
148 p_pvj_ventricular_stim->SetPurkinjeCellModel(pPurkinjeCell);
149 p_pvj_purkinje_stim->SetVentricularCellModel(pCardiacCell);
150 p_pvj_purkinje_stim->SetPurkinjeCellModel(pPurkinjeCell);
153 boost::shared_ptr<MultiStimulus> p_multi_stim_ventricular(
new MultiStimulus);
154 p_multi_stim_ventricular->AddStimulus(p_pvj_ventricular_stim);
158 boost::shared_ptr<MultiStimulus> p_multi_stim_purkinje(
new MultiStimulus);
159 p_multi_stim_purkinje->AddStimulus(p_pvj_purkinje_stim);
165 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
169 if (mpMixedDimensionMesh == NULL)
171 EXCEPTION(
"AbstractPurkinjeCellFactory must take a MixedDimensionMesh");
173 mLocalPurkinjeNodes.clear();
175 iter != mpMixedDimensionMesh->GetCableElementIteratorEnd();
178 mLocalPurkinjeNodes.insert((*iter)->GetNodeGlobalIndex(0u));
179 mLocalPurkinjeNodes.insert((*iter)->GetNodeGlobalIndex(1u));
187 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
192 unsigned node_index = pNode->
GetIndex();
193 if (mLocalPurkinjeNodes.count(node_index)>0)
195 return CreatePurkinjeCellForTissueNode(pNode, pCardiacCell);
199 return new FakeBathCell(this->mpSolver, this->mpZeroStimulus);
204 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
207 if (mpMixedDimensionMesh == NULL)
209 EXCEPTION(
"The mixed dimension mesh object has not been set in the cell factory");
211 return mpMixedDimensionMesh;
214 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
219 std::map<unsigned, double>::iterator iter = mJunctionMap.find(pNode->
GetIndex());
220 if(iter != mJunctionMap.end())
222 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