Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
BidomainProblem.hpp
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
37#ifndef BIDOMAINPROBLEM_HPP_
38#define BIDOMAINPROBLEM_HPP_
39
41#include <boost/serialization/base_object.hpp>
42
43#include <vector>
44#include <boost/shared_ptr.hpp>
45#include <boost/serialization/shared_ptr.hpp>
46
47#include "AbstractCardiacProblem.hpp"
48#include "AbstractCardiacTissue.hpp"
49#include "AbstractBidomainSolver.hpp"
50#include "AbstractCardiacCellFactory.hpp"
51#include "Electrodes.hpp"
52#include "BidomainTissue.hpp"
53#include "HeartRegionCodes.hpp"
54#include "DistributedTetrahedralMesh.hpp"
55
64template<unsigned DIM>
65class BidomainProblem : public AbstractCardiacProblem<DIM,DIM, 2>
66{
69
70 // #1082
71 friend class TestPCTwoLevelsBlockDiagonal;
72
79 template<class Archive>
80 void save(Archive & archive, const unsigned int version) const
81 {
82 archive & boost::serialization::base_object<AbstractCardiacProblem<DIM, DIM, 2> >(*this);
83 archive & mpBidomainTissue;
84 //archive & mExtracelluarColumnId; // Created by InitialiseWriter, called from Solve
86 archive & mHasBath;
87 archive & mpElectrodes;
88 }
89
96 template<class Archive>
97 void load(Archive & archive, const unsigned int version)
98 {
99 archive & boost::serialization::base_object<AbstractCardiacProblem<DIM, DIM, 2> >(*this);
100 archive & mpBidomainTissue;
101 //archive & mExtracelluarColumnId; // Created by InitialiseWriter, called from Solve
103 archive & mHasBath;
104 archive & mpElectrodes;
105
106 if (mHasBath)
107 {
108 // We only save element annotations, so annotate bath nodes from these
110 }
111 }
112 BOOST_SERIALIZATION_SPLIT_MEMBER()
113
114 friend class TestBidomainWithBathProblem;
115 friend class TestCardiacSimulationArchiver;
116
117protected:
120
130
133
135 boost::shared_ptr<Electrodes<DIM> > mpElectrodes;
136
143
148 void AnalyseMeshForBath();
149
156
159
161 virtual AbstractDynamicLinearPdeSolver<DIM,DIM,2>* CreateSolver();
162
163public:
173 BidomainProblem(AbstractCardiacCellFactory<DIM>* pCellFactory, bool hasBath=false);
174
179
190 void SetFixedExtracellularPotentialNodes(std::vector<unsigned> nodes);
191
199 void SetNodeForAverageOfPhiZeroed(unsigned node);
200
205
210 void WriteInfo(double time);
211
217 virtual void DefineWriterColumns(bool extending);
218
226 virtual void WriteOneStep(double time, Vec voltageVec);
227
232 void PreSolveChecks();
233
241 void AtBeginningOfTimestep(double time);
242
250 void OnEndOfTimestep(double time);
251
259 void SetUpAdditionalStoppingTimes(std::vector<double>& rAdditionalStoppingTimes);
260
278 template<class Archive>
279 void LoadExtraArchiveForBidomain(Archive & archive, unsigned version);
280
284 bool GetHasBath();
285
290 void SetElectrodes();
291};
292
293#include "SerializationExportWrapper.hpp" // Must be last
295
296
297template<unsigned DIM>
298template<class Archive>
299void BidomainProblem<DIM>::LoadExtraArchiveForBidomain(Archive & archive, unsigned version)
300{
301 // Not all bidomain problems have electrodes...
302 if (mpElectrodes)
303 {
304 // Electrodes will always have a BCC object by this point
305 assert(mpElectrodes->GetBoundaryConditionsContainer());
306 // We might need to get some of the boundary conditions from this archive, but it might be
307 // the case that the problem's BCC is the same object as the Electrodes' (if they are turned
308 // on) in which case we need to do 'nothing'.
309 boost::shared_ptr<BoundaryConditionsContainer<DIM, DIM, 2> > p_bcc;
310 archive >> p_bcc;
311 if (mpElectrodes->GetBoundaryConditionsContainer() != this->mpBoundaryConditionsContainer)
312 {
313 // The BCs will only actually be different if using a distributed tetrahedral mesh
315 if (p_dist_mesh)
316 {
317 mpElectrodes->GetBoundaryConditionsContainer()->MergeFromArchive(archive, this->mpMesh);
318 }
319 else
320 {
321 // Load into the temporary container, which will get thrown away shortly
322 p_bcc->LoadFromArchive(archive, this->mpMesh);
324 }
325 }
326 }
327}
328
329#endif /*BIDOMAINPROBLEM_HPP_*/
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * mpMesh
void SetNodeForAverageOfPhiZeroed(unsigned node)
void SetUpAdditionalStoppingTimes(std::vector< double > &rAdditionalStoppingTimes)
BidomainTissue< DIM > * mpBidomainTissue
void AtBeginningOfTimestep(double time)
unsigned mExtracelluarColumnId
AbstractBidomainSolver< DIM, DIM > * mpSolver
virtual AbstractDynamicLinearPdeSolver< DIM, DIM, 2 > * CreateSolver()
unsigned mRowForAverageOfPhiZeroed
void LoadExtraArchiveForBidomain(Archive &archive, unsigned version)
boost::shared_ptr< Electrodes< DIM > > mpElectrodes
virtual void DefineWriterColumns(bool extending)
void load(Archive &archive, const unsigned int version)
std::vector< unsigned > mFixedExtracellularPotentialNodes
virtual AbstractCardiacTissue< DIM > * CreateCardiacTissue()
void OnEndOfTimestep(double time)
void SetFixedExtracellularPotentialNodes(std::vector< unsigned > nodes)
void WriteInfo(double time)
friend class boost::serialization::access
void save(Archive &archive, const unsigned int version) const
BidomainTissue< DIM > * GetBidomainTissue()
virtual void WriteOneStep(double time, Vec voltageVec)