MonodomainProblem.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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 // Explicit instantiation
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 

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5