Chaste  Release::2017.1
AbstractCardiacMechanicsSolver.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 #ifndef ABSTRACTCARDIACMECHANICSSOLVER_HPP_
37 #define ABSTRACTCARDIACMECHANICSSOLVER_HPP_
38 
39 #include <map>
40 #include "IncompressibleNonlinearElasticitySolver.hpp"
41 #include "CompressibleNonlinearElasticitySolver.hpp"
42 #include "QuadraticBasisFunction.hpp"
43 #include "LinearBasisFunction.hpp"
44 #include "AbstractContractionModel.hpp"
45 #include "FibreReader.hpp"
46 #include "FineCoarseMeshPair.hpp"
47 #include "AbstractCardiacMechanicsSolverInterface.hpp"
48 #include "HeartRegionCodes.hpp"
49 #include "ElectroMechanicsProblemDefinition.hpp"
50 
51 
58 typedef struct DataAtQuadraturePoint_
59 {
61 // bool Active;/**<whether this quad point is active or not*/
62  double Stretch;
66 
67 
80 template<class ELASTICITY_SOLVER, unsigned DIM>
82 {
83 protected:
84  static const unsigned NUM_VERTICES_PER_ELEMENT = ELASTICITY_SOLVER::NUM_VERTICES_PER_ELEMENT;
96  std::map<unsigned,DataAtQuadraturePoint> mQuadPointToDataAtQuadPointMap;
97 
101  std::map<unsigned,DataAtQuadraturePoint>::iterator mMapIterator;
102 
105 
108 
110  double mCurrentTime;
111 
113  double mNextTime;
114 
116  double mOdeTimestep;
117 
122  c_matrix<double,DIM,DIM> mConstantFibreSheetDirections;
123 
128  std::vector<c_matrix<double,DIM,DIM> >* mpVariableFibreSheetDirections;
129 
135 
137  c_vector<double,DIM> mCurrentElementFibreDirection;
138 
140  c_vector<double,DIM> mCurrentElementSheetDirection;
141 
144 
145 
150 
155  virtual bool IsImplicitSolver()=0;
156 
157 
172  void AddActiveStressAndStressDerivative(c_matrix<double,DIM,DIM>& rC,
173  unsigned elementIndex,
174  unsigned currentQuadPointGlobalIndex,
175  c_matrix<double,DIM,DIM>& rT,
177  bool addToDTdE);
178 
179 
187  void SetupChangeOfBasisMatrix(unsigned elementIndex, unsigned currentQuadPointGlobalIndex);
188 
194  void Initialise();
195 
208  virtual void GetActiveTensionAndTensionDerivs(double currentFibreStretch,
209  unsigned currentQuadPointGlobalIndex,
210  bool assembleJacobian,
211  double& rActiveTension,
212  double& rDerivActiveTensionWrtLambda,
213  double& rDerivActiveTensionWrtDLambdaDt)=0;
214 public:
223  ElectroMechanicsProblemDefinition<DIM>& rProblemDefinition,
224  std::string outputDirectory);
225 
230 
238  void SetFineCoarseMeshPair(FineCoarseMeshPair<DIM>* pMeshPair);
239 
242  {
243  return mTotalQuadPoints;
244  }
245 
248  {
249  return this->mpQuadratureRule;
250  }
251 
255  std::map<unsigned,DataAtQuadraturePoint>& rGetQuadPointToDataAtQuadPointMap()
256  {
257  return mQuadPointToDataAtQuadPointMap;
258  }
259 
260 
267  void SetConstantFibreSheetDirections(const c_matrix<double,DIM,DIM>& rFibreSheetMatrix);
268 
280  void SetVariableFibreSheetDirections(const FileFinder& rOrthoFile, bool definedPerQuadraturePoint);
281 
294  void SetCalciumAndVoltage(std::vector<double>& rCalciumConcentrations,
295  std::vector<double>& rVoltages);
296 
304  virtual void Solve(double time, double nextTime, double odeTimestep)=0;
305 
325  void ComputeDeformationGradientAndStretchInEachElement(std::vector<c_matrix<double,DIM,DIM> >& rDeformationGradients,
326  std::vector<double>& rStretches);
327 };
328 
329 
330 #endif /*ABSTRACTCARDIACMECHANICSSOLVER_HPP_*/
c_vector< double, DIM > mCurrentElementSheetNormalDirection
std::vector< c_matrix< double, DIM, DIM > > * mpVariableFibreSheetDirections
std::map< unsigned, DataAtQuadraturePoint >::iterator mMapIterator
ElectroMechanicsProblemDefinition< DIM > & mrElectroMechanicsProblemDefinition
std::map< unsigned, DataAtQuadraturePoint > mQuadPointToDataAtQuadPointMap
c_matrix< double, DIM, DIM > mConstantFibreSheetDirections
virtual GaussianQuadratureRule< DIM > * GetQuadratureRule()
AbstractContractionModel * ContractionModel
std::map< unsigned, DataAtQuadraturePoint > & rGetQuadPointToDataAtQuadPointMap()