ExplicitCardiacMechanicsSolver.cpp

00001 /*
00002 
00003 Copyright (c) 2005-2015, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 #include "ExplicitCardiacMechanicsSolver.hpp"
00037 
00038 template<class ELASTICITY_SOLVER,unsigned DIM>
00039 ExplicitCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>::ExplicitCardiacMechanicsSolver(QuadraticMesh<DIM>& rQuadMesh,
00040                                                                                       ElectroMechanicsProblemDefinition<DIM>& rProblemDefinition,
00041                                                                                       std::string outputDirectory)
00042     : AbstractCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>(rQuadMesh,
00043                                                             rProblemDefinition,
00044                                                             outputDirectory)
00045 {
00046 
00047 }
00048 
00049 template<class ELASTICITY_SOLVER,unsigned DIM>
00050 ExplicitCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>::~ExplicitCardiacMechanicsSolver()
00051 {
00052 }
00053 
00054 template<class ELASTICITY_SOLVER,unsigned DIM>
00055 void ExplicitCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>::GetActiveTensionAndTensionDerivs(double currentFibreStretch,
00056                                                                                              unsigned currentQuadPointGlobalIndex,
00057                                                                                              bool assembleJacobian,
00058                                                                                              double& rActiveTension,
00059                                                                                              double& rDerivActiveTensionWrtLambda,
00060                                                                                              double& rDerivActiveTensionWrtDLambdaDt)
00061 {
00062     // The iterator should be pointing to the right place (note: it is incremented at the end of this method)
00063     // This iterator is used so that we don't have to search the map
00064     assert(this->mMapIterator->first==currentQuadPointGlobalIndex);
00065     DataAtQuadraturePoint& r_data_at_quad_point = this->mMapIterator->second;
00066 
00067     // the active tensions have already been computed for each contraction model, so can
00068     // return it straightaway..
00069     rActiveTension = r_data_at_quad_point.ContractionModel->GetActiveTension();
00070 
00071     // these are unset
00072     rDerivActiveTensionWrtLambda = 0.0;
00073     rDerivActiveTensionWrtDLambdaDt = 0.0;
00074 
00075     // store the value of given for this quad point, so that it can be used when computing
00076     // the active tension at the next timestep
00077     r_data_at_quad_point.Stretch = currentFibreStretch;
00078 
00079     // increment the iterator
00080     this->mMapIterator++;
00081     if(this->mMapIterator==this->mQuadPointToDataAtQuadPointMap.end())
00082     {
00083         this->mMapIterator = this->mQuadPointToDataAtQuadPointMap.begin();
00084     }
00085 
00086 }
00087 
00088 template<class ELASTICITY_SOLVER,unsigned DIM>
00089 void ExplicitCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>::Solve(double time, double nextTime, double odeTimestep)
00090 {
00091     assert(time < nextTime);
00092     this->mCurrentTime = time;
00093     this->mNextTime = nextTime;
00094     this->mOdeTimestep = odeTimestep;
00095 
00096     // assemble the residual again so that mStretches is set (in GetActiveTensionAndTensionDerivs)
00097     // using the current deformation.
00098     this->AssembleSystem(true,false);
00099 
00100     // integrate contraction models
00101     for(std::map<unsigned,DataAtQuadraturePoint>::iterator iter = this->mQuadPointToDataAtQuadPointMap.begin();
00102         iter != this->mQuadPointToDataAtQuadPointMap.end();
00103         iter++)
00104     {
00105         AbstractContractionModel* p_contraction_model = iter->second.ContractionModel;
00106         double stretch = iter->second.Stretch;
00107         p_contraction_model->SetStretchAndStretchRate(stretch, 0.0 /*dlam_dt*/);
00108         p_contraction_model->RunAndUpdate(time, nextTime, odeTimestep);
00109     }
00110 
00111     // solve
00112     ELASTICITY_SOLVER::Solve();
00113 }
00114 
00115 
00116 
00117 template class ExplicitCardiacMechanicsSolver<IncompressibleNonlinearElasticitySolver<2>,2>;
00118 template class ExplicitCardiacMechanicsSolver<IncompressibleNonlinearElasticitySolver<3>,3>;
00119 template class ExplicitCardiacMechanicsSolver<CompressibleNonlinearElasticitySolver<2>,2>;
00120 template class ExplicitCardiacMechanicsSolver<CompressibleNonlinearElasticitySolver<3>,3>;

Generated by  doxygen 1.6.2