00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "MonodomainProblem.hpp"
00030
00031 #include "Exception.hpp"
00032 #include "ReplicatableVector.hpp"
00033 #include "BasicMonodomainSolver.hpp"
00034 #include "MatrixBasedMonodomainSolver.hpp"
00035 #include "OperatorSplittingMonodomainSolver.hpp"
00036
00037
00038 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00039 AbstractCardiacTissue<ELEMENT_DIM,SPACE_DIM>* MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::CreateCardiacTissue()
00040 {
00041 mpMonodomainTissue = new MonodomainTissue<ELEMENT_DIM,SPACE_DIM>(this->mpCellFactory, HeartConfig::Instance()->GetUseStateVariableInterpolation());
00042 return mpMonodomainTissue;
00043 }
00044
00045 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00046 AbstractDynamicLinearPdeSolver<ELEMENT_DIM, SPACE_DIM, 1>* MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::CreateSolver()
00047 {
00048 assert(mpMonodomainTissue);
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 if(!this->mUseMatrixBasedRhsAssembly)
00060 {
00061 return new BasicMonodomainSolver<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,
00062 mpMonodomainTissue,
00063 this->mpBoundaryConditionsContainer.get(),
00064 2);
00065 }
00066 else if (HeartConfig::Instance()->GetUseReactionDiffusionOperatorSplitting())
00067 {
00068 return new OperatorSplittingMonodomainSolver<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,
00069 mpMonodomainTissue,
00070 this->mpBoundaryConditionsContainer.get(),
00071 2);
00072 }
00073 else
00074 {
00075 return new MatrixBasedMonodomainSolver<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,
00076 mpMonodomainTissue,
00077 this->mpBoundaryConditionsContainer.get(),
00078 2);
00079 }
00080 }
00081
00082 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00083 MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::MonodomainProblem(AbstractCardiacCellFactory<ELEMENT_DIM,SPACE_DIM>* pCellFactory)
00084 : AbstractCardiacProblem<ELEMENT_DIM, SPACE_DIM, 1>(pCellFactory),
00085 mpMonodomainTissue(NULL)
00086 {
00087 }
00088
00089 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00090 MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::MonodomainProblem()
00091 : AbstractCardiacProblem<ELEMENT_DIM, SPACE_DIM, 1>(),
00092 mpMonodomainTissue(NULL)
00093 {
00094 }
00095
00096 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00097 MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::~MonodomainProblem()
00098 {
00099 }
00100
00101 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00102 MonodomainTissue<ELEMENT_DIM,SPACE_DIM> * MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::GetMonodomainTissue()
00103 {
00104 assert(mpMonodomainTissue != NULL);
00105 return mpMonodomainTissue;
00106 }
00107
00108 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00109 void MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::WriteInfo(double time)
00110 {
00111 if (PetscTools::AmMaster())
00112 {
00113 std::cout << "Solved to time " << time << "\n" << std::flush;
00114 }
00115
00116 double v_max, v_min;
00117
00118 VecMax( this->mSolution, PETSC_NULL, &v_max );
00119 VecMin( this->mSolution, PETSC_NULL, &v_min );
00120
00121 if (PetscTools::AmMaster())
00122 {
00123 std::cout << " V = " << "[" <<v_min << ", " << v_max << "]" << "\n" << std::flush;
00124 }
00125 }
00126
00127 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00128 void MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::DefineWriterColumns(bool extending)
00129 {
00130 AbstractCardiacProblem<ELEMENT_DIM,SPACE_DIM,1>::DefineWriterColumns(extending);
00131 AbstractCardiacProblem<ELEMENT_DIM,SPACE_DIM,1>::DefineExtraVariablesWriterColumns(extending);
00132 }
00133
00134 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00135 void MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::WriteOneStep(double time, Vec voltageVec)
00136 {
00137 this->mpWriter->PutUnlimitedVariable(time);
00138 this->mpWriter->PutVector(this->mVoltageColumnId, voltageVec);
00139 AbstractCardiacProblem<ELEMENT_DIM,SPACE_DIM,1>::WriteExtraVariablesOneStep();
00140 }
00141
00142
00144
00146
00147 template class MonodomainProblem<1,1>;
00148 template class MonodomainProblem<1,2>;
00149 template class MonodomainProblem<1,3>;
00150 template class MonodomainProblem<2,2>;
00151 template class MonodomainProblem<3,3>;
00152
00153
00154
00155
00156 #include "SerializationExportWrapperForCpp.hpp"
00157 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 1, 1)
00158 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 1, 2)
00159 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 1, 3)
00160 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 2, 2)
00161 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 3, 3)