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.");
77 assert(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;
120template<
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);
164template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
168 if (mpMixedDimensionMesh == NULL)
170 EXCEPTION(
"AbstractPurkinjeCellFactory must take a MixedDimensionMesh");
172 mLocalPurkinjeNodes.clear();
174 iter != mpMixedDimensionMesh->GetCableElementIteratorEnd();
177 mLocalPurkinjeNodes.insert((*iter)->GetNodeGlobalIndex(0u));
178 mLocalPurkinjeNodes.insert((*iter)->GetNodeGlobalIndex(1u));
185template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
190 unsigned node_index = pNode->
GetIndex();
191 if (mLocalPurkinjeNodes.count(node_index)>0)
193 return CreatePurkinjeCellForTissueNode(pNode, pCardiacCell);
197 return new FakeBathCell(this->mpSolver, this->mpZeroStimulus);
201template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
204 if (mpMixedDimensionMesh == NULL)
206 EXCEPTION(
"The mixed dimension mesh object has not been set in the cell factory");
208 return mpMixedDimensionMesh;
211template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
216 std::map<unsigned, double>::iterator iter = mJunctionMap.find(pNode->
GetIndex());
217 if (iter != mJunctionMap.end())
219 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