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
00036 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00037 AbstractCardiacTissue<ELEMENT_DIM,SPACE_DIM>* MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::CreateCardiacTissue()
00038 {
00039 mpMonodomainTissue = new MonodomainTissue<ELEMENT_DIM,SPACE_DIM>(this->mpCellFactory);
00040 return mpMonodomainTissue;
00041 }
00042
00043 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00044 AbstractDynamicLinearPdeSolver<ELEMENT_DIM, SPACE_DIM, 1>* MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::CreateSolver()
00045 {
00046 assert(mpMonodomainTissue);
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 if(!this->mUseMatrixBasedRhsAssembly)
00058 {
00059 BasicMonodomainSolver<ELEMENT_DIM,SPACE_DIM>* p_solver
00060 = new BasicMonodomainSolver<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,
00061 mpMonodomainTissue,
00062 this->mpBoundaryConditionsContainer.get(),
00063 2);
00064 return p_solver;
00065 }
00066 else
00067 {
00068 MatrixBasedMonodomainSolver<ELEMENT_DIM,SPACE_DIM>* p_solver
00069 = new MatrixBasedMonodomainSolver<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,
00070 mpMonodomainTissue,
00071 this->mpBoundaryConditionsContainer.get(),
00072 2);
00074
00075
00076
00077 return p_solver;
00078 }
00079 }
00080
00081 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00082 MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::MonodomainProblem(AbstractCardiacCellFactory<ELEMENT_DIM,SPACE_DIM>* pCellFactory)
00083 : AbstractCardiacProblem<ELEMENT_DIM, SPACE_DIM, 1>(pCellFactory),
00084 mpMonodomainTissue(NULL)
00085 {
00086 }
00087
00088 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00089 MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::MonodomainProblem()
00090 : AbstractCardiacProblem<ELEMENT_DIM, SPACE_DIM, 1>(),
00091 mpMonodomainTissue(NULL)
00092 {
00093 }
00094
00095 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00096 MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::~MonodomainProblem()
00097 {
00098 }
00099
00100 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00101 MonodomainTissue<ELEMENT_DIM,SPACE_DIM> * MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::GetMonodomainTissue()
00102 {
00103 assert(mpMonodomainTissue != NULL);
00104 return mpMonodomainTissue;
00105 }
00106
00107 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00108 void MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::WriteInfo(double time)
00109 {
00110 if (PetscTools::AmMaster())
00111 {
00112 std::cout << "Solved to time " << time << "\n" << std::flush;
00113 }
00114
00115 double v_max, v_min;
00116
00117 VecMax( this->mSolution, PETSC_NULL, &v_max );
00118 VecMin( this->mSolution, PETSC_NULL, &v_min );
00119
00120 if (PetscTools::AmMaster())
00121 {
00122 std::cout << " V = " << "[" <<v_min << ", " << v_max << "]" << "\n" << std::flush;
00123 }
00124 }
00125
00126 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00127 void MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::DefineWriterColumns(bool extending)
00128 {
00129 AbstractCardiacProblem<ELEMENT_DIM,SPACE_DIM,1>::DefineWriterColumns(extending);
00130 AbstractCardiacProblem<ELEMENT_DIM,SPACE_DIM,1>::DefineExtraVariablesWriterColumns(extending);
00131 }
00132
00133 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00134 void MonodomainProblem<ELEMENT_DIM, SPACE_DIM>::WriteOneStep(double time, Vec voltageVec)
00135 {
00136 this->mpWriter->PutUnlimitedVariable(time);
00137 this->mpWriter->PutVector(this->mVoltageColumnId, voltageVec);
00138 AbstractCardiacProblem<ELEMENT_DIM,SPACE_DIM,1>::WriteExtraVariablesOneStep();
00139 }
00140
00141
00143
00145
00146 template class MonodomainProblem<1,1>;
00147 template class MonodomainProblem<1,2>;
00148 template class MonodomainProblem<1,3>;
00149 template class MonodomainProblem<2,2>;
00150 template class MonodomainProblem<3,3>;
00151
00152
00153
00154
00155 #include "SerializationExportWrapperForCpp.hpp"
00156 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 1, 1)
00157 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 1, 2)
00158 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 1, 3)
00159 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 2, 2)
00160 EXPORT_TEMPLATE_CLASS2(MonodomainProblem, 3, 3)