Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
MonodomainProblem.cpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#include "MonodomainProblem.hpp"
37
38#include "Exception.hpp"
39#include "ReplicatableVector.hpp"
40#include "MonodomainSolver.hpp"
41#include "OperatorSplittingMonodomainSolver.hpp"
42
43
44template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
46{
47 mpMonodomainTissue = new MonodomainTissue<ELEMENT_DIM,SPACE_DIM>(this->mpCellFactory, HeartConfig::Instance()->GetUseStateVariableInterpolation());
48 return mpMonodomainTissue;
49}
50
51template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
53{
54 assert(mpMonodomainTissue);
55 /*
56 * NOTE: The this->mpBoundaryConditionsContainer.get() lines below convert a
57 * boost::shared_ptr to a normal pointer, as this is what the solvers are
58 * expecting. We have to be a bit careful though as boost could decide to delete
59 * them whenever it feels like as it won't count the assembers as using them.
60 *
61 * As long as they are kept as member variables here for as long as they are
62 * required in the solvers it should all work OK.
63 */
64
65 if (HeartConfig::Instance()->GetUseReactionDiffusionOperatorSplitting())
66 {
68 mpMonodomainTissue,
69 this->mpBoundaryConditionsContainer.get());
70 }
71 else
72 {
73 return new MonodomainSolver<ELEMENT_DIM,SPACE_DIM>(this->mpMesh,
74 mpMonodomainTissue,
75 this->mpBoundaryConditionsContainer.get());
76 }
77}
78
79template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
81 : AbstractCardiacProblem<ELEMENT_DIM, SPACE_DIM, 1>(pCellFactory),
82 mpMonodomainTissue(NULL)
83{
84}
85
86template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
88 : AbstractCardiacProblem<ELEMENT_DIM, SPACE_DIM, 1>(),
89 mpMonodomainTissue(NULL)
90{
91}
92
93template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
97
98template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
100{
101 assert(mpMonodomainTissue != NULL);
102 return mpMonodomainTissue;
103}
104
105template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
107{
109 {
110 std::cout << "Solved to time " << time << "\n" << std::flush;
111 }
112
113 double v_max, v_min;
114
115 VecMax( this->mSolution, CHASTE_PETSC_NULLPTR, &v_max );
116 VecMin( this->mSolution, CHASTE_PETSC_NULLPTR, &v_min );
117
119 {
120 std::cout << " V = " << "[" <<v_min << ", " << v_max << "]" << "\n" << std::flush;
121 }
122}
123
124template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
130
131template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
133{
134 this->mpWriter->PutUnlimitedVariable(time);
135 this->mpWriter->PutVector(this->mVoltageColumnId, voltageVec);
137}
138
139// Explicit instantiation
140template class MonodomainProblem<1,1>;
141template class MonodomainProblem<1,2>;
142template class MonodomainProblem<1,3>;
143template class MonodomainProblem<2,2>;
144template class MonodomainProblem<3,3>;
145
146// Serialization for Boost >= 1.36
#define CHASTE_PETSC_NULLPTR
A macro to define PETSc null pointer based on the PETSc version.
#define EXPORT_TEMPLATE_CLASS2(CLASS, E, S)
void DefineExtraVariablesWriterColumns(bool extending)
virtual void DefineWriterColumns(bool extending)
static HeartConfig * Instance()
AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, 1 > * CreateSolver()
MonodomainTissue< ELEMENT_DIM, SPACE_DIM > * GetMonodomainTissue()
AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM > * CreateCardiacTissue()
virtual void WriteOneStep(double time, Vec voltageVec)
void WriteInfo(double time)
virtual void DefineWriterColumns(bool extending)
static bool AmMaster()