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);
65 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
70 assert(this->mpLinearSystem->rGetLhsMatrix() != NULL);
71 assert(this->mpLinearSystem->rGetRhsVector() != NULL);
72 assert(currentSolution != NULL);
80 mpBidomainAssembler->SetMatrixToAssemble(this->mpLinearSystem->rGetLhsMatrix());
81 mpBidomainAssembler->AssembleMatrix();
85 assert(SPACE_DIM==ELEMENT_DIM);
90 this->mpLinearSystem->SwitchWriteModeLhsMatrix();
114 if(!(this->mBathSimulation))
117 index!= dist_vec_matrix_based.
End();
120 double V = distributed_current_solution_vm[index];
121 double F = - Am*this->mpBidomainTissue->rGetIionicCacheReplicated()[index.Global]
122 - this->mpBidomainTissue->rGetIntracellularStimulusCacheReplicated()[index.Global];
125 dist_vec_matrix_based_phie[index] = 0.0;
131 index!= dist_vec_matrix_based.
End();
137 double V = distributed_current_solution_vm[index];
138 double F = - Am*this->mpBidomainTissue->rGetIionicCacheReplicated()[index.Global]
139 - this->mpBidomainTissue->rGetIntracellularStimulusCacheReplicated()[index.Global];
145 dist_vec_matrix_based_vm[index] = 0.0;
148 dist_vec_matrix_based_phie[index] = 0.0;
153 dist_vec_matrix_based.
Restore();
158 MatMult(mMassMatrix, mVecForConstructingRhs, this->mpLinearSystem->rGetRhsVector());
168 mpBidomainNeumannSurfaceTermAssembler->ResetBoundaryConditionsContainer(this->mpBoundaryConditions);
169 mpBidomainNeumannSurfaceTermAssembler->SetVectorToAssemble(this->mpLinearSystem->rGetRhsVector(),
false);
170 mpBidomainNeumannSurfaceTermAssembler->AssembleVector();
176 if(mpBidomainCorrectionTermAssembler)
178 mpBidomainCorrectionTermAssembler->SetVectorToAssemble(this->mpLinearSystem->rGetRhsVector(),
false);
180 mpBidomainCorrectionTermAssembler->AssembleVector();
183 this->mpLinearSystem->FinaliseRhsVector();
185 this->mpBoundaryConditions->ApplyDirichletToLinearProblem(*(this->mpLinearSystem), computeMatrix);
187 if(this->mBathSimulation)
189 this->mpLinearSystem->FinaliseLhsMatrix();
190 this->FinaliseForBath(computeMatrix,
true);
195 this->mpLinearSystem->FinaliseLhsMatrix();
197 this->mpLinearSystem->FinaliseRhsVector();
201 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
239 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
242 delete mpBidomainAssembler;
243 delete mpBidomainNeumannSurfaceTermAssembler;
245 if(mVecForConstructingRhs)
251 if(mpBidomainCorrectionTermAssembler)
253 delete mpBidomainCorrectionTermAssembler;
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()