37 #include "BidomainSolver.hpp" 38 #include "BidomainAssembler.hpp" 39 #include "BidomainWithBathAssembler.hpp" 40 #include "PetscMatTools.hpp" 42 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
45 if (this->mpLinearSystem != NULL)
53 Vec& r_template = this->mpLinearSystem->rGetRhsVector();
54 VecDuplicate(r_template, &mVecForConstructingRhs);
57 VecGetOwnershipRange(r_template, &ownership_range_lo, &ownership_range_hi);
58 PetscInt local_size = ownership_range_hi - ownership_range_lo;
60 2*this->mpMesh->CalculateMaximumNodeConnectivityPerProcess(),
61 local_size, local_size);
64 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
69 assert(this->mpLinearSystem->rGetLhsMatrix() != NULL);
70 assert(this->mpLinearSystem->rGetRhsVector() != NULL);
71 assert(currentSolution != NULL);
79 mpBidomainAssembler->SetMatrixToAssemble(this->mpLinearSystem->rGetLhsMatrix());
80 mpBidomainAssembler->AssembleMatrix();
84 assert(SPACE_DIM==ELEMENT_DIM);
89 this->mpLinearSystem->SwitchWriteModeLhsMatrix();
113 if (!(this->mBathSimulation))
116 index!= dist_vec_matrix_based.
End();
119 double V = distributed_current_solution_vm[index];
120 double F = - Am*this->mpBidomainTissue->rGetIionicCacheReplicated()[index.Global]
121 - this->mpBidomainTissue->rGetIntracellularStimulusCacheReplicated()[index.Global];
124 dist_vec_matrix_based_phie[index] = 0.0;
130 index!= dist_vec_matrix_based.
End();
136 double V = distributed_current_solution_vm[index];
137 double F = - Am*this->mpBidomainTissue->rGetIionicCacheReplicated()[index.Global]
138 - this->mpBidomainTissue->rGetIntracellularStimulusCacheReplicated()[index.Global];
144 dist_vec_matrix_based_vm[index] = 0.0;
147 dist_vec_matrix_based_phie[index] = 0.0;
152 dist_vec_matrix_based.
Restore();
157 MatMult(mMassMatrix, mVecForConstructingRhs, this->mpLinearSystem->rGetRhsVector());
167 mpBidomainNeumannSurfaceTermAssembler->ResetBoundaryConditionsContainer(this->mpBoundaryConditions);
168 mpBidomainNeumannSurfaceTermAssembler->SetVectorToAssemble(this->mpLinearSystem->rGetRhsVector(),
false);
169 mpBidomainNeumannSurfaceTermAssembler->AssembleVector();
175 if (mpBidomainCorrectionTermAssembler)
177 mpBidomainCorrectionTermAssembler->SetVectorToAssemble(this->mpLinearSystem->rGetRhsVector(),
false);
179 mpBidomainCorrectionTermAssembler->AssembleVector();
182 this->mpLinearSystem->FinaliseRhsVector();
184 this->mpBoundaryConditions->ApplyDirichletToLinearProblem(*(this->mpLinearSystem), computeMatrix);
186 if (this->mBathSimulation)
188 this->mpLinearSystem->FinaliseLhsMatrix();
189 this->FinaliseForBath(computeMatrix,
true);
194 this->mpLinearSystem->FinaliseLhsMatrix();
196 this->mpLinearSystem->FinaliseRhsVector();
199 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
237 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * mpMesh
static bool IsRegionBath(HeartRegionType regionId)
BidomainAssembler< ELEMENT_DIM, SPACE_DIM > * mpBidomainAssembler
void InitialiseForSolve(Vec initialSolution)
DistributedVector CreateDistributedVector(Vec vec, bool readOnly=false)
static void BeginEvent(unsigned event)
BidomainNeumannSurfaceTermAssembler< ELEMENT_DIM, SPACE_DIM > * mpBidomainNeumannSurfaceTermAssembler
BidomainTissue< SPACE_DIM > * mpBidomainTissue
Vec mVecForConstructingRhs
BidomainCorrectionTermAssembler< ELEMENT_DIM, SPACE_DIM > * mpBidomainCorrectionTermAssembler
bool GetUseStateVariableInterpolation() const
void SetupLinearSystem(Vec currentSolution, bool computeMatrix)
BidomainSolver(bool bathSimulation, AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, BidomainTissue< SPACE_DIM > *pTissue, BoundaryConditionsContainer< ELEMENT_DIM, SPACE_DIM, 2 > *pBoundaryConditions)
static double GetPdeTimeStepInverse()
void SetCacheReplication(bool doCacheReplication)
double GetCapacitance() const
double GetSurfaceAreaToVolumeRatio() const
static void EndEvent(unsigned event)
void InitialiseForSolve(Vec initialSolution)
void SetMatrixToAssemble(Mat &rMatToAssemble, bool zeroMatrixBeforeAssembly=true)
static HeartConfig * Instance()