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 ELEM_DIM, unsigned SPACE_DIM>
00037 AbstractCardiacPde<ELEM_DIM,SPACE_DIM>* MonodomainProblem<ELEM_DIM, SPACE_DIM>::CreateCardiacPde()
00038 {
00039 mpMonodomainPde = new MonodomainPde<ELEM_DIM,SPACE_DIM>(this->mpCellFactory);
00040 return mpMonodomainPde;
00041 }
00042
00043 template<unsigned ELEM_DIM, unsigned SPACE_DIM>
00044 AbstractDynamicAssemblerMixin<ELEM_DIM, SPACE_DIM, 1>* MonodomainProblem<ELEM_DIM, SPACE_DIM>::CreateAssembler()
00045 {
00046 assert(mpMonodomainPde);
00047
00048 if(!this->mUseMatrixBasedRhsAssembly)
00049 {
00050 MonodomainDg0Assembler<ELEM_DIM,SPACE_DIM>* p_assembler
00051 = new MonodomainDg0Assembler<ELEM_DIM,SPACE_DIM>(this->mpMesh,
00052 mpMonodomainPde,
00053 this->mpBoundaryConditionsContainer,
00054 2);
00055 return p_assembler;
00056 }
00057 else
00058 {
00059 MonodomainMatrixBasedAssembler<ELEM_DIM,SPACE_DIM>* p_assembler
00060 = new MonodomainMatrixBasedAssembler<ELEM_DIM,SPACE_DIM>(this->mpMesh,
00061 mpMonodomainPde,
00062 this->mpBoundaryConditionsContainer,
00063 2);
00064 return p_assembler;
00065 }
00066 }
00067
00068 template<unsigned ELEM_DIM, unsigned SPACE_DIM>
00069 MonodomainProblem<ELEM_DIM, SPACE_DIM>::MonodomainProblem(AbstractCardiacCellFactory<ELEM_DIM,SPACE_DIM>* pCellFactory)
00070 : AbstractCardiacProblem<ELEM_DIM, SPACE_DIM, 1>(pCellFactory),
00071 mpMonodomainPde(NULL)
00072 {
00073 }
00074
00075 template<unsigned ELEM_DIM, unsigned SPACE_DIM>
00076 MonodomainProblem<ELEM_DIM, SPACE_DIM>::~MonodomainProblem()
00077 {
00078 }
00079
00080 template<unsigned ELEM_DIM, unsigned SPACE_DIM>
00081 MonodomainPde<ELEM_DIM,SPACE_DIM> * MonodomainProblem<ELEM_DIM, SPACE_DIM>::GetMonodomainPde()
00082 {
00083 assert(mpMonodomainPde != NULL);
00084 return mpMonodomainPde;
00085 }
00086
00087 template<unsigned ELEM_DIM, unsigned SPACE_DIM>
00088 void MonodomainProblem<ELEM_DIM, SPACE_DIM>::WriteInfo(double time)
00089 {
00090 std::cout << "Solved to time " << time << "\n" << std::flush;
00091 ReplicatableVector voltage_replicated;
00092 voltage_replicated.ReplicatePetscVector(this->mSolution);
00093 double v_max = -DBL_MAX, v_min = DBL_MAX;
00094 for (unsigned i=0; i<this->mpMesh->GetNumNodes(); i++)
00095 {
00096 double v=voltage_replicated[i];
00097 #define COVERAGE_IGNORE
00098 if (std::isnan(v))
00099 {
00100 EXCEPTION("Not-a-number encountered");
00101 }
00102 #undef COVERAGE_IGNORE
00103 if ( v > v_max)
00104 {
00105 v_max = v;
00106 }
00107 if ( v < v_min)
00108 {
00109 v_min = v;
00110 }
00111 }
00112 std::cout << " V = " << "[" <<v_min << ", " << v_max << "]" << "\n" << std::flush;
00113 }
00114
00115
00117
00119
00120 template class MonodomainProblem<1,1>;
00121 template class MonodomainProblem<1,2>;
00122 template class MonodomainProblem<1,3>;
00123 template class MonodomainProblem<2,2>;
00124 template class MonodomainProblem<3,3>;
00125