36 #include "MonodomainPurkinjeSolver.hpp" 37 #include "MonodomainPurkinjeVolumeMassMatrixAssembler.hpp" 38 #include "MonodomainPurkinjeCableMassMatrixAssembler.hpp" 39 #include "PetscMatTools.hpp" 43 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
46 assert(this->mpLinearSystem->rGetLhsMatrix() != NULL);
47 assert(this->mpLinearSystem->rGetRhsVector() != NULL);
54 mpVolumeAssembler->SetMatrixToAssemble(this->mpLinearSystem->rGetLhsMatrix(),
false);
55 mpVolumeAssembler->AssembleMatrix();
57 mpCableAssembler->SetMatrixToAssemble(this->mpLinearSystem->rGetLhsMatrix(),
false);
60 mpCableAssembler->AssembleMatrix();
62 SetIdentityBlockToLhsMatrix();
63 this->mpLinearSystem->FinaliseLhsMatrix();
68 volume_mass_matrix_assembler.
Assemble();
72 cable_mass_matrix_assembler.
Assemble();
101 index!= dist_vec_matrix_based.
End();
104 double V_volume = distributed_current_solution_volume[index];
105 double F_volume = - Am*this->mpMonodomainTissue->rGetIionicCacheReplicated()[index.Global]
106 - this->mpMonodomainTissue->rGetIntracellularStimulusCacheReplicated()[index.Global];
109 double V_cable = distributed_current_solution_cable[index];
110 double F_cable = - Am*this->mpMonodomainTissue->rGetPurkinjeIionicCacheReplicated()[index.Global]
111 - this->mpMonodomainTissue->rGetPurkinjeIntracellularStimulusCacheReplicated()[index.Global];
116 dist_vec_matrix_based.
Restore();
121 MatMult(mMassMatrix, mVecForConstructingRhs, this->mpLinearSystem->rGetRhsVector());
131 mpNeumannSurfaceTermsAssembler->SetVectorToAssemble(this->mpLinearSystem->rGetRhsVector(),
false);
132 mpNeumannSurfaceTermsAssembler->AssembleVector();
135 this->mpLinearSystem->FinaliseRhsVector();
139 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
142 this->mpLinearSystem->FinaliseLhsMatrix();
145 VecDuplicate(mVecForConstructingRhs, &diagonal);
146 MatGetDiagonal(this->mpLinearSystem->rGetLhsMatrix(), diagonal);
151 this->mpLinearSystem->GetOwnershipRange(lo, hi);
152 for (
int row=lo; row<hi; row++)
163 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
166 if (this->mpLinearSystem != NULL)
187 this->mpLinearSystem->SetMatrixIsSymmetric(
true);
191 VecDuplicate(initialSolution, &mVecForConstructingRhs);
194 VecGetOwnershipRange(initialSolution, &ownership_range_lo, &ownership_range_hi);
195 PetscInt local_size = ownership_range_hi - ownership_range_lo;
197 2*this->mpMesh->CalculateMaximumNodeConnectivityPerProcess(),
198 local_size, local_size);
202 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
209 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
216 mpMonodomainTissue(pTissue),
217 mpBoundaryConditions(pBoundaryConditions)
220 assert(pBoundaryConditions);
223 EXCEPTION(
"State-variable interpolation is not yet supported with Purkinje");
237 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
virtual ~MonodomainPurkinjeSolver()
double GetPurkinjeSurfaceAreaToVolumeRatio()
NaturalNeumannSurfaceTermAssembler< ELEMENT_DIM, SPACE_DIM, 2 > * mpNeumannSurfaceTermsAssembler
MixedDimensionMesh< ELEMENT_DIM, SPACE_DIM > * mpMixedMesh
DistributedVector CreateDistributedVector(Vec vec, bool readOnly=false)
virtual void InitialiseForSolve(Vec initialSolution=nullptr)
MonodomainPurkinjeCableAssembler< ELEMENT_DIM, SPACE_DIM > * mpCableAssembler
#define EXCEPTION(message)
static void BeginEvent(unsigned event)
void SetupLinearSystem(Vec currentSolution, bool computeMatrix)
MonodomainPurkinjeVolumeAssembler< ELEMENT_DIM, SPACE_DIM > * mpVolumeAssembler
static double GetNextTime()
static double GetPdeTimeStepInverse()
void PrepareForSetupLinearSystem(Vec currentSolution)
Vec mVecForConstructingRhs
double GetPurkinjeCapacitance()
void SetCacheReplication(bool doCacheReplication)
double GetCapacitance() const
double GetSurfaceAreaToVolumeRatio() const
static void EndEvent(unsigned event)
MonodomainPurkinjeSolver(MixedDimensionMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, MonodomainTissue< ELEMENT_DIM, SPACE_DIM > *pTissue, BoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, 2 > *pBoundaryConditions)
void SetIdentityBlockToLhsMatrix()
void SetMatrixToAssemble(Mat &rMatToAssemble, bool zeroMatrixBeforeAssembly=true)
MonodomainTissue< ELEMENT_DIM, SPACE_DIM > * mpMonodomainTissue
static HeartConfig * Instance()
virtual void InitialiseForSolve(Vec initialSolution)