37 #include "ExtendedBidomainProblem.hpp" 38 #include "ExtendedBidomainSolver.hpp" 39 #include "AbstractDynamicLinearPdeSolver.hpp" 40 #include "HeartConfig.hpp" 42 #include "DistributedVector.hpp" 43 #include "ReplicatableVector.hpp" 45 template<
unsigned DIM>
49 mpSecondCellFactory(pSecondCellFactory),
50 mpExtendedBidomainTissue(NULL),
51 mUserSpecifiedSecondCellConductivities(false),
52 mUserHasSetBidomainValuesExplicitly(false),
53 mpExtracellularStimulusFactory(NULL),
54 mRowForAverageOfPhiZeroed(INT_MAX),
55 mApplyAveragePhieZeroConstraintAfterSolving(false),
56 mUserSuppliedExtracellularStimulus(false),
62 template<
unsigned DIM>
77 template<
unsigned DIM>
84 std::vector<DistributedVector::Stripe> stripe;
97 stripe[2][index] = 0.0;
101 return initial_condition;
104 template<
unsigned DIM>
121 std::vector<unsigned> grounded_indices;
122 for (
unsigned global_node_index = 0; global_node_index < this->
mpMesh->GetNumNodes(); global_node_index++)
124 if (this->
mpMesh->GetDistributedVectorFactory()->IsGlobalIndexLocal(global_node_index))
126 for (
unsigned region_index = 0; region_index <grounded_regions.size(); region_index++)
128 if (grounded_regions[region_index]->DoesContain(this->
mpMesh->GetNode(global_node_index)->GetPoint()))
130 grounded_indices.push_back( this->
mpMesh->GetNode(global_node_index)->GetIndex() );
140 template<
unsigned DIM>
162 c_vector<double, DIM> intra_conductivities;
196 template<
unsigned DIM>
209 template <
unsigned DIM>
212 if (rGgapHeterogeneityRegions.size() != rGgapValues.size() )
214 EXCEPTION (
"Gap junction heterogeneity areas must be of the same number as the heterogeneity values");
220 template <
unsigned DIM>
227 template<
unsigned DIM>
259 template<
unsigned DIM>
268 template<
unsigned DIM>
271 for (
unsigned i = 0; i < DIM; i++)
278 template<
unsigned DIM>
283 for (
unsigned i=0; i<nodes.size(); i++)
291 template<
unsigned DIM>
305 template<
unsigned DIM>
312 template<
unsigned DIM>
317 std::cout <<
"Solved to time " << time <<
"\n" << std::flush;
320 double V_max_first_cell, V_min_first_cell, V_max_second_cell, V_min_second_cell, phi_e_min, phi_e_max;
322 VecStrideMax( this->
mSolution, 0, PETSC_NULL, &V_max_first_cell );
323 VecStrideMin( this->
mSolution, 0, PETSC_NULL, &V_min_first_cell );
325 VecStrideMax( this->
mSolution, 1, PETSC_NULL, &V_max_second_cell );
326 VecStrideMin( this->
mSolution, 1, PETSC_NULL, &V_min_second_cell );
328 VecStrideMax( this->
mSolution, 2, PETSC_NULL, &phi_e_max );
329 VecStrideMin( this->
mSolution, 2, PETSC_NULL, &phi_e_min );
333 std::cout <<
" V first cell = " <<
"[" <<V_min_first_cell <<
", " << V_max_first_cell <<
"]" <<
";\n" 334 <<
" V second cell = " <<
"[" <<V_min_second_cell <<
", " << V_max_second_cell <<
"]" <<
";\n" 335 <<
" Phi_e = " <<
"[" <<phi_e_min <<
", " << phi_e_max <<
"]" <<
";\n" 340 template<
unsigned DIM>
380 template<
unsigned DIM>
386 Vec ordered_voltages = this->
mpMesh->GetDistributedVectorFactory()->CreateVec(3);
387 DistributedVector wrapped_ordered_solution = this->
mpMesh->GetDistributedVectorFactory()->CreateDistributedVector(ordered_voltages);
388 DistributedVector wrapped_solution = this->
mpMesh->GetDistributedVectorFactory()->CreateDistributedVector(voltageVec);
399 index != wrapped_solution.
End();
402 wrapped_ordered_solution_first_stripe[index] = V_first_cell_stripe[index];
403 wrapped_ordered_solution_second_stripe[index] = V_second_cell_stripe[index];
404 wrapped_ordered_solution_third_stripe[index] = phi_e_stripe[index];
407 wrapped_ordered_solution.
Restore();
417 template<
unsigned DIM>
431 EXCEPTION(
"Bidomain external voltage is not bounded in this simulation - use KSP *absolute* tolerance");
437 template<
unsigned DIM>
443 template<
unsigned DIM>
unsigned mVoltageColumnId_Phie
void SetExtendedBidomainParameters(double Am1, double Am2, double AmGap, double Cm1, double Cm2, double Ggap)
void CreateIntracellularConductivityTensorSecondCell()
void SetAmGap(double value)
virtual AbstractDynamicLinearPdeSolver< DIM, DIM, 3 > * CreateSolver()
void SetHasBath(bool hasBath)
Hdf5DataWriter * mpWriter
virtual AbstractCardiacTissue< DIM > * CreateCardiacTissue()
AbstractStimulusFactory< DIM > * mpExtracellularStimulusFactory
ExtendedBidomainTissue< DIM > * GetExtendedBidomainTissue()
void SetExtracellularStimulusFactory(AbstractStimulusFactory< DIM > *pFactory)
int GetVariableByName(const std::string &rVariableName)
void SetFixedExtracellularPotentialNodes(std::vector< unsigned > fixedExtracellularPotentialNodes)
void SetRowForAverageOfPhiZeroed(unsigned rowMeanPhiEZero)
void ProcessExtracellularStimulus()
void GetIntracellularConductivities(c_vector< double, 3 > &rIntraConductivities) const
void SetGgapHeterogeneities(std::vector< boost::shared_ptr< AbstractChasteRegion< SPACE_DIM > > > &rGgapHeterogeneityRegions, std::vector< double > rGgapValues)
DistributedVector CreateDistributedVector(Vec vec, bool readOnly=false)
bool mUserSpecifiedSecondCellConductivities
AbstractCardiacCellInterface * GetCardiacSecondCell(unsigned globalIndex)
virtual double GetVoltage()=0
void CreateGGapConductivities()
#define EXCEPTION(message)
int mRowForAverageOfPhiZeroed
void SetAmSecondCell(double value)
unsigned mVoltageColumnId_Vm1
virtual void WriteOneStep(double time, Vec voltageVec)
void SetIntracellularConductivitiesForSecondCell(c_vector< double, DIM > conductivities)
virtual void PreSolveChecks()
bool mUserHasSetBidomainValuesExplicitly
Vec CreateInitialCondition()
void SetGgapHeterogeneities(std::vector< boost::shared_ptr< AbstractChasteRegion< DIM > > > &rGgapHeterogeneityRegions, std::vector< double > &rGgapValues)
void SetNodeForAverageOfPhiZeroed(unsigned node)
void SetCmSecondCell(double value)
bool mUserSuppliedExtracellularStimulus
virtual void DefineWriterColumns(bool extending)
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * mpMesh
AbstractExtendedBidomainSolver< DIM, DIM > * mpSolver
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
ExtendedBidomainProblem()
void SetCmFirstCell(double value)
virtual ~ExtendedBidomainProblem()
BccType mpBoundaryConditionsContainer
int DefineVariable(const std::string &rVariableName, const std::string &rVariableUnits)
std::vector< unsigned > mNodesToOutput
void SetFixedExtracellularPotentialNodes(std::vector< unsigned > nodes)
void SetMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
unsigned mVoltageColumnId_Vm2
std::vector< boost::shared_ptr< AbstractChasteRegion< DIM > > > mGgapHeterogeneityRegions
unsigned EstimateTimeSteps() const
std::vector< AbstractChasteRegion< SPACE_DIM > * > GetRegionsToBeGrounded()
AbstractCardiacCellFactory< ELEMENT_DIM, SPACE_DIM > * mpCellFactory
void DefineFixedDimension(long dimensionSize)
virtual void SetMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
std::vector< signed int > mVariablesIDs
virtual void SetCompatibleExtracellularStimulus()
ExtendedBidomainTissue< DIM > * mpExtendedBidomainTissue
AbstractCardiacCellFactory< DIM, DIM > * mpSecondCellFactory
void PutStripedVector(std::vector< int > variableIDs, Vec petscVector)
void SetIntracellularConductivitiesSecondCell(c_vector< double, SPACE_DIM > conductivities)
void WriteInfo(double time)
void SetUserSuppliedExtracellularStimulus(bool flag)
void WriteExtraVariablesOneStep()
AbstractCardiacCellInterface * GetCardiacCell(unsigned globalIndex)
void PutUnlimitedVariable(double value)
unsigned mApplyAveragePhieZeroConstraintAfterSolving
static HeartConfig * Instance()
bool GetUseRelativeTolerance() const
std::vector< double > mGgapHeterogenousValues
c_vector< double, DIM > mIntracellularConductivitiesSecondCell
void SetAmFirstCell(double value)
std::vector< unsigned > mFixedExtracellularPotentialNodes
void SetGGap(double value)
void DefineExtraVariablesWriterColumns(bool extending)
void DefineUnlimitedDimension(const std::string &rVariableName, const std::string &rVariableUnits, unsigned estimatedLength=1)