Chaste  Release::2017.1
CardiacElectroMechanicsProblem.hpp
1 /*
2 
3 Copyright (c) 2005-2017, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, 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 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 
37 #ifndef CARDIACELECTROMECHANICSPROBLEM_HPP_
38 #define CARDIACELECTROMECHANICSPROBLEM_HPP_
39 
40 #include <vector>
41 #include <string>
42 #include "UblasIncludes.hpp"
43 
44 #include "AbstractCardiacCellFactory.hpp"
45 #include "MonodomainProblem.hpp"
46 #include "TetrahedralMesh.hpp"
47 #include "QuadraticMesh.hpp"
48 #include "AbstractOdeBasedContractionModel.hpp"
49 #include "AbstractCardiacMechanicsSolver.hpp"
50 #include "AbstractCardiacMechanicsSolverInterface.hpp"
51 #include "FineCoarseMeshPair.hpp"
52 #include "AbstractConductivityModifier.hpp"
53 #include "ElectroMechanicsProblemDefinition.hpp"
54 
59 typedef enum ElectricsProblemType_
60 {
61  MONODOMAIN,
62  BIDOMAIN,
63  BIDOMAIN_WITH_BATH
64  //EXTENDED_BIDOMAIN
65 } ElectricsProblemType;
66 
93 template<unsigned DIM, unsigned ELEC_PROB_DIM=1>
95  : public AbstractConductivityModifier<DIM,DIM> // this only inherits from this class so it can be passed to the tissue to
96  // allow deformation-based altering of the conductivity
97 {
98 friend class TestAbstractContractionCellFactory;
99 friend class TestCardiacElectroMechanicsProblem;
100 friend class TestCardiacElectroMechanicsFurtherFunctionality;
101 friend class TestElectroMechanicsExactSolution;
102 
103 protected :
105  CompressibilityType mCompressibilityType;
106 
109 
116 
119 
124  std::vector<double> mInterpolatedCalciumConcs;
125 
130  std::vector<double> mInterpolatedVoltages;
131 
136 
139 
141  bool mHasBath;
142 
145 
147  std::string mOutputDirectory;
154 
156  static const int WRITE_EVERY_NTH_TIME = 1; //hardcoded for the time being ///\todo, allow user to set this
157 
161  c_vector<double,DIM> mWatchedLocation;
168 
171 
175  std::vector<c_matrix<double,DIM,DIM> > mDeformationGradientsForEachMechanicsElement;
176 
178  c_matrix<double,DIM,DIM> mModifiedConductivityTensor;
179 
183  void DetermineWatchedNodes();
184 
185 
192  void WriteWatchedLocationData(double time, Vec voltage);
193 
194 
195 public :
196 
207  CardiacElectroMechanicsProblem(CompressibilityType compressibilityType,
208  ElectricsProblemType electricsProblemType,
209  TetrahedralMesh<DIM,DIM>* pElectricsMesh,
210  QuadraticMesh<DIM>* pMechanicsMesh,
211  AbstractCardiacCellFactory<DIM>* pCellFactory,
212  ElectroMechanicsProblemDefinition<DIM>* pProblemDefinition,
213  std::string outputDirectory);
214 
224 
229  void Initialise();
230 
234  void Solve();
235 
241  double Max(std::vector<double>& vec);
242 
244  void SetNoElectricsOutput();
245 
256  void SetWatchedPosition(c_vector<double,DIM> watchedLocation);
257 
265  void SetOutputDeformationGradientsAndStress(double timestep);
266 
268  std::vector<c_vector<double,DIM> >& rGetDeformedPosition();
269 
270 
279  c_matrix<double,DIM,DIM>& rCalculateModifiedConductivityTensor(unsigned elementIndex, const c_matrix<double,DIM,DIM>& rOriginalConductivity, unsigned domainIndex);
280 
281 
285  virtual void PrepareForSolve(){}
286 
291  virtual void OnEndOfTimeStep(unsigned counter)
292  {
293  }
294 
301  {
302  assert(mpMechanicsSolver);
303  return mpMechanicsSolver;
304  }
305 };
306 
307 #endif /*CARDIACELECTROMECHANICSPROBLEM_HPP_*/
AbstractCardiacMechanicsSolverInterface< DIM > * mpCardiacMechSolver
virtual void OnEndOfTimeStep(unsigned counter)
void WriteWatchedLocationData(double time, Vec voltage)
double Max(std::vector< double > &vec)
std::vector< c_vector< double, DIM > > & rGetDeformedPosition()
CardiacElectroMechanicsProblem(CompressibilityType compressibilityType, ElectricsProblemType electricsProblemType, TetrahedralMesh< DIM, DIM > *pElectricsMesh, QuadraticMesh< DIM > *pMechanicsMesh, AbstractCardiacCellFactory< DIM > *pCellFactory, ElectroMechanicsProblemDefinition< DIM > *pProblemDefinition, std::string outputDirectory)
ElectroMechanicsProblemDefinition< DIM > * mpProblemDefinition
AbstractNonlinearElasticitySolver< DIM > * GetMechanicsSolver()
void SetOutputDeformationGradientsAndStress(double timestep)
std::vector< c_matrix< double, DIM, DIM > > mDeformationGradientsForEachMechanicsElement
c_matrix< double, DIM, DIM > & rCalculateModifiedConductivityTensor(unsigned elementIndex, const c_matrix< double, DIM, DIM > &rOriginalConductivity, unsigned domainIndex)
AbstractNonlinearElasticitySolver< DIM > * mpMechanicsSolver
AbstractCardiacProblem< DIM, DIM, ELEC_PROB_DIM > * mpElectricsProblem
c_matrix< double, DIM, DIM > mModifiedConductivityTensor
TetrahedralMesh< DIM, DIM > * mpElectricsMesh
void SetWatchedPosition(c_vector< double, DIM > watchedLocation)