Chaste Release::3.1
ElectroMechanicsProblemDefinition.cpp
00001 /*
00002 
00003 Copyright (c) 2005-2012, 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 "ElectroMechanicsProblemDefinition.hpp"
00037 
00038 template<unsigned DIM>
00039 ElectroMechanicsProblemDefinition<DIM>::ElectroMechanicsProblemDefinition(QuadraticMesh<DIM>& rMesh)
00040     : SolidMechanicsProblemDefinition<DIM>(rMesh),
00041       mContractionModelOdeTimeStep(-1.0),
00042       mMechanicsSolveTimestep(-1.0),
00043       mDeformationAffectsConductivity(false),
00044       mDeformationAffectsCellModels(false),
00045       mpDefaultMaterialLaw(NULL),
00046       mReadFibreSheetInformationFromFile(false),
00047       mNumIncrementsForInitialDeformation(1),
00048       mApplyCrossFibreTension(false)
00049 {
00050 }
00051 
00052 template<unsigned DIM>
00053 ElectroMechanicsProblemDefinition<DIM>::~ElectroMechanicsProblemDefinition()
00054 {
00055     if(mpDefaultMaterialLaw)
00056     {
00057         delete mpDefaultMaterialLaw;
00058     }
00059 }
00060 
00061 template<unsigned DIM>
00062 void ElectroMechanicsProblemDefinition<DIM>::SetContractionModel(ContractionModelName contractionModel, double timestep)
00063 {
00064     assert(timestep > 0.0);
00065     mContractionModel = contractionModel;
00066     mContractionModelOdeTimeStep = timestep;
00067 }
00068 
00069 template<unsigned DIM>
00070 void ElectroMechanicsProblemDefinition<DIM>::SetUseDefaultCardiacMaterialLaw(CompressibilityType compressibilityType)
00071 {
00072     if(mpDefaultMaterialLaw)
00073     {
00074         delete mpDefaultMaterialLaw;
00075     }
00076 
00077     if(compressibilityType == INCOMPRESSIBLE)
00078     {
00079         mpDefaultMaterialLaw = new NashHunterPoleZeroLaw<DIM>();
00080         this->SetMaterialLaw(INCOMPRESSIBLE, mpDefaultMaterialLaw);
00081     }
00082     else
00083     {
00084         mpDefaultMaterialLaw = new CompressibleExponentialLaw<DIM>();
00085         this->SetMaterialLaw(COMPRESSIBLE, mpDefaultMaterialLaw);
00086     }
00087 }
00088 
00089 template<unsigned DIM>
00090 void ElectroMechanicsProblemDefinition<DIM>::SetDeformationAffectsElectrophysiology(bool deformationAffectsConductivity, bool deformationAffectsCellModels)
00091 {
00092     mDeformationAffectsConductivity = deformationAffectsConductivity;
00093     mDeformationAffectsCellModels = deformationAffectsCellModels;
00094 }
00095 
00096 template<unsigned DIM>
00097 void ElectroMechanicsProblemDefinition<DIM>::SetMechanicsSolveTimestep(double timestep)
00098 {
00099     assert(timestep > 0.0);
00100     mMechanicsSolveTimestep = timestep;
00101 }
00102 
00103 template<unsigned DIM>
00104 void ElectroMechanicsProblemDefinition<DIM>::SetVariableFibreSheetDirectionsFile(const FileFinder& rFibreSheetDirectionsFile, bool definedPerQuadraturePoint)
00105 {
00106     mReadFibreSheetInformationFromFile = true;
00107     mFibreSheetDirectionsFile = rFibreSheetDirectionsFile;
00108     mFibreSheetDirectionsDefinedPerQuadraturePoint = definedPerQuadraturePoint;
00109 }
00110 
00111 template<unsigned DIM>
00112 void ElectroMechanicsProblemDefinition<DIM>::SetApplyCrossFibreTension(bool applyCrossFibreTension, double crossFibreTensionFraction)
00113 {
00114     mApplyCrossFibreTension = applyCrossFibreTension;
00115     mCrossFibreTensionFraction = crossFibreTensionFraction;
00116 }
00117 
00118 template<unsigned DIM>
00119 void ElectroMechanicsProblemDefinition<DIM>::Validate()
00120 {
00121     SolidMechanicsProblemDefinition<DIM>::Validate();
00122 
00123     if(mMechanicsSolveTimestep < 0.0)
00124     {
00125         EXCEPTION("Timestep for mechanics solve hasn't been set yet");
00126     }
00127 
00128     if(mContractionModelOdeTimeStep < 0.0)
00129     {
00130         EXCEPTION("Contraction model hasn't been set yet");
00131     }
00132 
00133     if(mDeformationAffectsConductivity && this->GetCompressibilityType()==COMPRESSIBLE)
00134     {
00135         // the conductivity depends on the deformation gradient and also scales in some way with
00136         // J=det(F), which is not equal to 1 in the compressible case. The F dependence
00137         // is implemented but the J dependence is not yet.
00138         EXCEPTION("Deformation affecting the conductivity is currently not implemented fully for compressible problems");
00139     }
00140 
00141     if(mDeformationAffectsCellModels && mReadFibreSheetInformationFromFile && mFibreSheetDirectionsDefinedPerQuadraturePoint)
00142     {
00143         // This combination is not allowed. For explanation see doxygen for SetDeformationAffectsElectrophysiology()
00144         std::stringstream message;
00145         message << "Deformation affecting cell models cannot be done when fibres-sheet information is defined for each quadrature point.";
00146         message << "Define fibre-sheet information for each element instead.";
00147         EXCEPTION(message.str());
00148     }
00149 }
00150 
00152 // Explicit instantiation
00154 
00155 template class ElectroMechanicsProblemDefinition<2>;
00156 template class ElectroMechanicsProblemDefinition<3>;