36 #include "ExtendedBidomainTissue.hpp" 38 #include "DistributedVector.hpp" 39 #include "OrthotropicConductivityTensors.hpp" 40 #include "AxisymmetricConductivityTensors.hpp" 41 #include "AbstractStimulusFunction.hpp" 42 #include "ChastePoint.hpp" 43 #include "AbstractChasteRegion.hpp" 44 #include "HeartEventHandler.hpp" 46 template <
unsigned SPACE_DIM>
51 mpIntracellularConductivityTensorsSecondCell(NULL),
52 mUserSuppliedExtracellularStimulus(false)
56 assert(pCellFactorySecondCell != NULL);
57 assert(pCellFactorySecondCell->
GetMesh() != NULL);
59 assert(pExtracellularStimulusFactory != NULL);
60 assert(pExtracellularStimulusFactory->
GetMesh() != NULL);
71 for (
unsigned local_index = 0; local_index < num_local_nodes; local_index++)
73 unsigned global_index = local_index + ownership_range_low;
97 delete (*cell_iterator);
116 template <
unsigned SPACE_DIM>
118 std::vector<AbstractCardiacCellInterface*> & rSecondCellsDistributed,
119 std::vector<boost::shared_ptr<AbstractStimulusFunction> > & rExtraStimuliDistributed,
120 std::vector<double> & rGgapsDistributed,
122 c_vector<double, SPACE_DIM> intracellularConductivitiesSecondCell)
146 template <
unsigned SPACE_DIM>
148 std::vector<double> rGgapValues)
150 assert( rGgapHeterogeneityRegions.size() == rGgapValues.size() );
155 template <
unsigned SPACE_DIM>
159 assert(this->
mpMesh != NULL);
166 for (
unsigned local_index = 0; local_index < num_local_nodes; local_index++)
168 unsigned global_index = ownership_range_low + local_index;
193 template <
unsigned SPACE_DIM>
205 case cp::media_type::Orthotropic:
209 assert(ortho_file.
Exists());
214 case cp::media_type::Axisymmetric:
218 assert(axi_file.
Exists());
223 case cp::media_type::NoFibreOrientation:
239 std::vector<c_vector<double, SPACE_DIM> > hetero_intra_conductivities;
241 c_vector<double, SPACE_DIM> intra_conductivities;
248 assert(hetero_intra_conductivities.size()==0);
249 hetero_intra_conductivities.resize(num_elements, intra_conductivities);
252 catch(std::bad_alloc &badAlloc)
255 std::cout <<
"Failed to allocate std::vector of size " << num_elements << std::endl;
263 std::vector<boost::shared_ptr<AbstractChasteRegion<SPACE_DIM> > > conductivities_heterogeneity_areas;
264 std::vector< c_vector<double,3> > intra_h_conductivities;
265 std::vector< c_vector<double,3> > extra_h_conductivities;
267 intra_h_conductivities,
268 extra_h_conductivities);
269 unsigned local_element_index = 0;
277 for (
unsigned region_index=0; region_index< conductivities_heterogeneity_areas.size(); region_index++)
279 if (conductivities_heterogeneity_areas[region_index]->DoesContain(element_centroid))
282 for (
unsigned i=0; i<SPACE_DIM; i++)
284 hetero_intra_conductivities[local_element_index][i] = intra_h_conductivities[region_index][i];
288 local_element_index++;
302 template <
unsigned SPACE_DIM>
308 template <
unsigned SPACE_DIM>
314 template <
unsigned SPACE_DIM>
320 template <
unsigned SPACE_DIM>
326 template <
unsigned SPACE_DIM>
333 template <
unsigned SPACE_DIM>
341 case cp::media_type::Orthotropic:
345 assert(ortho_file.
Exists());
350 case cp::media_type::Axisymmetric:
354 assert(axi_file.
Exists());
359 case cp::media_type::NoFibreOrientation:
372 c_vector<double, SPACE_DIM> extra_conductivities;
378 std::vector<c_vector<double, SPACE_DIM> > hetero_extra_conductivities;
384 assert(hetero_extra_conductivities.size()==0);
386 hetero_extra_conductivities.resize(num_elements, extra_conductivities);
389 catch(std::bad_alloc &badAlloc)
391 std::cout <<
"Failed to allocate std::vector of size " << num_elements << std::endl;
399 std::vector<boost::shared_ptr<AbstractChasteRegion<SPACE_DIM> > > conductivities_heterogeneity_areas;
400 std::vector< c_vector<double,3> > intra_h_conductivities;
401 std::vector< c_vector<double,3> > extra_h_conductivities;
403 intra_h_conductivities,
404 extra_h_conductivities);
405 unsigned local_element_index = 0;
407 iter != (this->
mpMesh)->GetElementIteratorEnd();
413 for (
unsigned region_index=0; region_index< conductivities_heterogeneity_areas.size(); region_index++)
416 if (conductivities_heterogeneity_areas[region_index]->DoesContain(element_centroid))
419 for (
unsigned i=0; i<SPACE_DIM; i++)
421 hetero_extra_conductivities[local_element_index][i] = extra_h_conductivities[region_index][i];
425 local_element_index++;
437 template <
unsigned SPACE_DIM>
445 delete (*cell_iterator);
459 template <
unsigned SPACE_DIM>
462 for (
unsigned i = 0; i < SPACE_DIM; i++)
468 template <
unsigned SPACE_DIM>
474 template <
unsigned SPACE_DIM>
488 template <
unsigned SPACE_DIM>
502 template <
unsigned SPACE_DIM>
508 template <
unsigned SPACE_DIM>
514 template <
unsigned SPACE_DIM>
525 index != dist_solution.
End();
548 this->
UpdateCaches(index.Global, index.Local, nextTime);
563 template <
unsigned SPACE_DIM>
572 template <
unsigned SPACE_DIM>
581 template <
unsigned SPACE_DIM>
587 template <
unsigned SPACE_DIM>
593 template <
unsigned SPACE_DIM>
599 template <
unsigned SPACE_DIM>
605 template <
unsigned SPACE_DIM>
611 template <
unsigned SPACE_DIM>
617 template <
unsigned SPACE_DIM>
623 template <
unsigned SPACE_DIM>
629 template <
unsigned SPACE_DIM>
635 template <
unsigned SPACE_DIM>
641 template <
unsigned SPACE_DIM>
647 template <
unsigned SPACE_DIM>
653 template <
unsigned SPACE_DIM>
659 template <
unsigned SPACE_DIM>
665 template <
unsigned SPACE_DIM>
671 template <
unsigned SPACE_DIM>
void SetFibreOrientationFile(const FileFinder &rFibreOrientationFile)
virtual void FinaliseCellCreation(std::vector< AbstractCardiacCellInterface * > *pCellsDistributed, unsigned lo, unsigned hi)
AbstractConductivityTensors< SPACE_DIM, SPACE_DIM > * mpExtracellularConductivityTensors
ReplicatableVector mIionicCacheReplicatedSecondCell
std::vector< boost::shared_ptr< AbstractChasteRegion< SPACE_DIM > > > mGgapHeterogeneityRegions
ElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
virtual AbstractCardiacCellInterface * CreateCardiacCellForNode(Node< SPACE_DIM > *pNode)
ReplicatableVector & rGetExtracellularStimulusCacheReplicated()
void CreateIntracellularConductivityTensorSecondCell()
void SetAmGap(double value)
cp::media_type GetConductivityMedia() const
DistributedVectorFactory * mpDistributedVectorFactory
void SetNonConstantConductivities(std::vector< c_vector< double, SPACE_DIM > > *pNonConstantConductivities)
ReplicatableVector & rGetIionicCacheReplicatedSecondCell()
virtual unsigned GetNumberOfCells()
virtual void SolveCellSystems(Vec existingSolution, double time, double nextTime, bool updateVoltage=false)
c_vector< double, SPACE_DIM > GetIntracellularConductivitiesSecondCell() const
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * GetMesh()
std::vector< AbstractCardiacCellInterface * > mCellsDistributedSecondCell
ReplicatableVector & rGetGgapCacheReplicated()
void Replicate(unsigned lo, unsigned hi)
void ReplicateAdditionalCaches()
void GetIntracellularConductivities(c_vector< double, 3 > &rIntraConductivities) const
void GetExtracellularConductivities(c_vector< double, 3 > &rExtraConductivities) const
void SetGgapHeterogeneities(std::vector< boost::shared_ptr< AbstractChasteRegion< SPACE_DIM > > > &rGgapHeterogeneityRegions, std::vector< double > rGgapValues)
ElementIterator GetElementIteratorEnd()
DistributedVector CreateDistributedVector(Vec vec, bool readOnly=false)
AbstractCardiacCellInterface * GetCardiacSecondCell(unsigned globalIndex)
c_vector< double, SPACE_DIM > mIntracellularConductivitiesSecondCell
Node< SPACE_DIM > * GetNode(unsigned index) const
void CreateGGapConductivities()
virtual unsigned GetNumElements() const
const c_matrix< double, SPACE_DIM, SPACE_DIM > & rGetExtracellularConductivityTensor(unsigned elementIndex)
void CreateExtracellularConductivityTensors()
static void BeginEvent(unsigned event)
void SetAmSecondCell(double value)
virtual ~ExtendedBidomainTissue()
std::vector< double > mGgapDistributed
void UpdateCaches(unsigned globalIndex, unsigned localIndex, double nextTime)
virtual void Init(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)=0
void UpdateAdditionalCaches(unsigned globalIndex, unsigned localIndex, double nextTime)
std::vector< boost::shared_ptr< AbstractStimulusFunction > > mExtracellularStimuliDistributed
AbstractConductivityTensors< SPACE_DIM, SPACE_DIM > * mpIntracellularConductivityTensorsSecondCell
void GetConductivityHeterogeneities(std::vector< boost::shared_ptr< AbstractChasteRegion< DIM > > > &conductivitiesHeterogeneityAreas, std::vector< c_vector< double, 3 > > &intraConductivities, std::vector< c_vector< double, 3 > > &extraConductivities) const
boost::shared_ptr< AbstractStimulusFunction > GetExtracellularStimulus(unsigned globalIndex)
void SetCmSecondCell(double value)
std::vector< AbstractCardiacCellInterface * > mCellsDistributed
std::string mFibreFilePathNoExtension
bool HasTheUserSuppliedExtracellularStimulus()
const std::vector< AbstractCardiacCellInterface * > & rGetSecondCellsDistributed() const
ReplicatableVector mExtracellularStimulusCacheReplicated
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
ReplicatableVector mGgapCacheReplicated
const std::vector< boost::shared_ptr< AbstractStimulusFunction > > & rGetExtracellularStimulusDistributed() const
unsigned GetProblemSize() const
void SetCmFirstCell(double value)
ReplicatableVector & rGetIntracellularStimulusCacheReplicatedSecondCell()
c_matrix< double, SPACE_DIM, SPACE_DIM > & rGetModifiedConductivityTensor(unsigned elementIndex, const c_matrix< double, SPACE_DIM, SPACE_DIM > &rOriginalConductivity, unsigned domainIndex)
void SetConstantConductivities(c_vector< double, 1 > constantConductivities)
std::vector< double > mGgapValues
AbstractTetrahedralMesh< ELEMENT_DIM, ELEMENT_DIM > * mpMesh
const std::vector< double > & rGetGapsDistributed() const
virtual boost::shared_ptr< AbstractStimulusFunction > CreateStimulusForNode(Node< SPACE_DIM > *pNode)
ReplicatableVector mIntracellularStimulusCacheReplicatedSecondCell
bool IsMeshProvided() const
AbstractConductivityModifier< ELEMENT_DIM, ELEMENT_DIM > * mpConductivityModifier
unsigned GetLocalOwnership() const
void Resize(unsigned size)
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * GetMesh()
ChastePoint< SPACE_DIM > GetPoint() const
static void EndEvent(unsigned event)
void SetIntracellularConductivitiesSecondCell(c_vector< double, SPACE_DIM > conductivities)
void SetUserSuppliedExtracellularStimulus(bool flag)
const c_matrix< double, SPACE_DIM, SPACE_DIM > & rGetIntracellularConductivityTensorSecondCell(unsigned elementIndex)
bool mUserSuppliedExtracellularStimulus
static HeartConfig * Instance()
virtual unsigned GetNumberOfCells()
bool GetConductivityHeterogeneitiesProvided() const
void SetAmFirstCell(double value)
void SetGGap(double value)
ExtendedBidomainTissue(AbstractCardiacCellFactory< SPACE_DIM > *pCellFactory, AbstractCardiacCellFactory< SPACE_DIM > *pCellFactorySecondCell, AbstractStimulusFactory< SPACE_DIM > *pExtracellularStimulusFactory)