ElectroMechanicsProblemDefinition.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #include "ElectroMechanicsProblemDefinition.hpp"
00030 
00031 template<unsigned DIM>
00032 ElectroMechanicsProblemDefinition<DIM>::ElectroMechanicsProblemDefinition(QuadraticMesh<DIM>& rMesh)
00033     : SolidMechanicsProblemDefinition<DIM>(rMesh),
00034       mContractionModelOdeTimeStep(-1.0),
00035       mMechanicsSolveTimestep(-1.0),
00036       mDeformationAffectsConductivity(false),
00037       mDeformationAffectsCellModels(false),
00038       mpDefaultMaterialLaw(NULL),
00039       mReadFibreSheetInformationFromFile(false)
00040 {
00041 }
00042 
00043 template<unsigned DIM>
00044 ElectroMechanicsProblemDefinition<DIM>::~ElectroMechanicsProblemDefinition()
00045 {
00046     if(mpDefaultMaterialLaw)
00047     {
00048         delete mpDefaultMaterialLaw;
00049     }
00050 }
00051 
00052 template<unsigned DIM>
00053 void ElectroMechanicsProblemDefinition<DIM>::SetContractionModel(ContractionModelName contractionModel, double timestep)
00054 {
00055     assert(timestep > 0.0);
00056     mContractionModel = contractionModel;
00057     mContractionModelOdeTimeStep = timestep;
00058 }
00059 
00060 template<unsigned DIM>
00061 void ElectroMechanicsProblemDefinition<DIM>::SetUseDefaultCardiacMaterialLaw(CompressibilityType compressibilityType)
00062 {
00063     if(mpDefaultMaterialLaw)
00064     {
00065         delete mpDefaultMaterialLaw;
00066     }
00067 
00068     if(compressibilityType == INCOMPRESSIBLE)
00069     {
00070         mpDefaultMaterialLaw = new NashHunterPoleZeroLaw<DIM>();
00071         this->SetMaterialLaw(INCOMPRESSIBLE, mpDefaultMaterialLaw);
00072     }
00073     else
00074     {
00075         mpDefaultMaterialLaw = new CompressibleExponentialLaw<DIM>();
00076         this->SetMaterialLaw(COMPRESSIBLE, mpDefaultMaterialLaw);
00077     }
00078 }
00079 
00080 template<unsigned DIM>
00081 void ElectroMechanicsProblemDefinition<DIM>::SetDeformationAffectsElectrophysiology(bool deformationAffectsConductivity, bool deformationAffectsCellModels)
00082 {
00083     mDeformationAffectsConductivity = deformationAffectsConductivity;
00084     mDeformationAffectsCellModels = deformationAffectsCellModels;
00085 }
00086 
00087 template<unsigned DIM>
00088 void ElectroMechanicsProblemDefinition<DIM>::SetMechanicsSolveTimestep(double timestep)
00089 {
00090     assert(timestep > 0.0);
00091     mMechanicsSolveTimestep = timestep;
00092 }
00093 
00094 template<unsigned DIM>
00095 void ElectroMechanicsProblemDefinition<DIM>::SetVariableFibreSheetDirectionsFile(std::string fibreSheetDirectionsFile, bool definedPerQuadraturePoint)
00096 {
00097     mReadFibreSheetInformationFromFile = true;
00098     mFibreSheetDirectionsFile = fibreSheetDirectionsFile;
00099     mFibreSheetDirectionsDefinedPerQuadraturePoint = definedPerQuadraturePoint;
00100 }
00101 
00102 template<unsigned DIM>
00103 void ElectroMechanicsProblemDefinition<DIM>::Validate()
00104 {
00105     SolidMechanicsProblemDefinition<DIM>::Validate();
00106 
00107     if(mMechanicsSolveTimestep < 0.0)
00108     {
00109         EXCEPTION("Timestep for mechanics solve hasn't been set yet");
00110     }
00111 
00112     if(mContractionModelOdeTimeStep < 0.0)
00113     {
00114         EXCEPTION("Contraction model hasn't been set yet");
00115     }
00116 
00117     if(mDeformationAffectsConductivity && this->GetCompressibilityType()==COMPRESSIBLE)
00118     {
00119         // the conductivity depends on the deformation gradient and also scales in some way with
00120         // J=det(F), which is not equal to 1 in the compressible case. The F dependence
00121         // is implemented but the J dependence is not yet.
00122         EXCEPTION("Deformation affecting the conductivity is currently not implemented fully for compressible problems");
00123     }
00124 
00125     if(mDeformationAffectsCellModels && mReadFibreSheetInformationFromFile && mFibreSheetDirectionsDefinedPerQuadraturePoint)
00126     {
00127         // This combination is not allowed. For explanation see doxygen for SetDeformationAffectsElectrophysiology()
00128         std::stringstream message;
00129         message << "Deformation affecting cell models cannot be done when fibres-sheet information is defined for each quadrature point.";
00130         message << "Define fibre-sheet information for each element instead.";
00131         EXCEPTION(message.str());
00132     }
00133 }
00134 
00136 // Explicit instantiation
00138 
00139 template class ElectroMechanicsProblemDefinition<2>;
00140 template class ElectroMechanicsProblemDefinition<3>;
Generated on Thu Dec 22 13:00:06 2011 for Chaste by  doxygen 1.6.3