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