ElectroMechanicsProblemDefinition.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "ElectroMechanicsProblemDefinition.hpp"
00037 #include "LabelBasedContractionCellFactory.hpp"
00038
00039 template<unsigned DIM>
00040 ElectroMechanicsProblemDefinition<DIM>::ElectroMechanicsProblemDefinition(QuadraticMesh<DIM>& rMesh)
00041 : SolidMechanicsProblemDefinition<DIM>(rMesh),
00042 mContractionModelOdeTimeStep(-1.0),
00043 mMechanicsSolveTimestep(-1.0),
00044 mDeformationAffectsConductivity(false),
00045 mDeformationAffectsCellModels(false),
00046 mpDefaultMaterialLaw(NULL),
00047 mReadFibreSheetInformationFromFile(false),
00048 mNumIncrementsForInitialDeformation(1),
00049 mApplyCrossFibreTension(false),
00050 mSheetTensionFraction(DOUBLE_UNSET),
00051 mSheetNormalTensionFraction(DOUBLE_UNSET),
00052 mpContractionCellFactory(NULL),
00053 mWeMadeCellFactory(false),
00054 mSolverType(IMPLICIT)
00055 {
00056 }
00057
00058 template<unsigned DIM>
00059 ElectroMechanicsProblemDefinition<DIM>::~ElectroMechanicsProblemDefinition()
00060 {
00061 if(mpDefaultMaterialLaw)
00062 {
00063 delete mpDefaultMaterialLaw;
00064 }
00065
00066 if (mWeMadeCellFactory)
00067 {
00068 delete mpContractionCellFactory;
00069 }
00070 }
00071
00072 template<unsigned DIM>
00073 void ElectroMechanicsProblemDefinition<DIM>::SetContractionModel(ContractionModelName contractionModel, double timestep)
00074 {
00075 assert(timestep > 0.0);
00076 SetContractionModelOdeTimestep(timestep);
00077
00078 if (contractionModel == NASH2004 || contractionModel == CONSTANT)
00079 {
00080
00081 SetSolverType(EXPLICIT);
00082 }
00083
00084
00085 assert(mpContractionCellFactory==NULL);
00086
00087 AbstractContractionCellFactory<DIM>* p_factory = new LabelBasedContractionCellFactory<DIM>(contractionModel);
00088 mWeMadeCellFactory = true;
00089 SetContractionCellFactory(p_factory);
00090 }
00091
00092 template<unsigned DIM>
00093 void ElectroMechanicsProblemDefinition<DIM>::SetUseDefaultCardiacMaterialLaw(CompressibilityType compressibilityType)
00094 {
00095 if(mpDefaultMaterialLaw)
00096 {
00097 delete mpDefaultMaterialLaw;
00098 }
00099
00100 if(compressibilityType == INCOMPRESSIBLE)
00101 {
00102 mpDefaultMaterialLaw = new NashHunterPoleZeroLaw<DIM>();
00103 this->SetMaterialLaw(INCOMPRESSIBLE, mpDefaultMaterialLaw);
00104 }
00105 else
00106 {
00107 mpDefaultMaterialLaw = new CompressibleExponentialLaw<DIM>();
00108 this->SetMaterialLaw(COMPRESSIBLE, mpDefaultMaterialLaw);
00109 }
00110 }
00111
00112 template<unsigned DIM>
00113 void ElectroMechanicsProblemDefinition<DIM>::SetDeformationAffectsElectrophysiology(bool deformationAffectsConductivity, bool deformationAffectsCellModels)
00114 {
00115 mDeformationAffectsConductivity = deformationAffectsConductivity;
00116 mDeformationAffectsCellModels = deformationAffectsCellModels;
00117 }
00118
00119 template<unsigned DIM>
00120 void ElectroMechanicsProblemDefinition<DIM>::SetMechanicsSolveTimestep(double timestep)
00121 {
00122 assert(timestep > 0.0);
00123 mMechanicsSolveTimestep = timestep;
00124 }
00125
00126 template<unsigned DIM>
00127 void ElectroMechanicsProblemDefinition<DIM>::SetVariableFibreSheetDirectionsFile(const FileFinder& rFibreSheetDirectionsFile, bool definedPerQuadraturePoint)
00128 {
00129 mReadFibreSheetInformationFromFile = true;
00130 mFibreSheetDirectionsFile = rFibreSheetDirectionsFile;
00131 mFibreSheetDirectionsDefinedPerQuadraturePoint = definedPerQuadraturePoint;
00132 }
00133
00134 template<unsigned DIM>
00135 void ElectroMechanicsProblemDefinition<DIM>::SetApplyIsotropicCrossFibreTension(bool applyCrossFibreTension, double crossFibreTensionFraction)
00136 {
00137 mApplyCrossFibreTension = applyCrossFibreTension;
00138 mSheetTensionFraction = crossFibreTensionFraction;
00139 mSheetNormalTensionFraction = crossFibreTensionFraction;
00140 }
00141
00142 template<unsigned DIM>
00143 void ElectroMechanicsProblemDefinition<DIM>::SetApplyAnisotropicCrossFibreTension(bool applyCrossFibreTension, double sheetTensionFraction, double sheetNormalTensionFraction)
00144 {
00145 if (DIM!=3)
00146 {
00147 EXCEPTION("You can only apply anisotropic cross fibre tensions in a 3D simulation.");
00148 }
00149 mApplyCrossFibreTension = applyCrossFibreTension;
00150 mSheetTensionFraction = sheetTensionFraction;
00151 mSheetNormalTensionFraction = sheetNormalTensionFraction;
00152 }
00153
00154 template<unsigned DIM>
00155 void ElectroMechanicsProblemDefinition<DIM>::SetContractionCellFactory(AbstractContractionCellFactory<DIM>* pCellFactory)
00156 {
00157
00158 assert(mpContractionCellFactory == NULL);
00159
00160 mpContractionCellFactory = pCellFactory;
00161 mpContractionCellFactory->SetMechanicsMesh(static_cast<QuadraticMesh<DIM>*>(&(this->mrMesh)));
00162 }
00163
00164 template<unsigned DIM>
00165 void ElectroMechanicsProblemDefinition<DIM>::Validate()
00166 {
00167 SolidMechanicsProblemDefinition<DIM>::Validate();
00168
00169 if(mMechanicsSolveTimestep < 0.0)
00170 {
00171 EXCEPTION("Timestep for mechanics solve hasn't been set yet");
00172 }
00173
00174 if(mContractionModelOdeTimeStep < 0.0)
00175 {
00176 std::string message = "Contraction model or contraction model ODE timestep have not been set. "
00177 "Make sure SetContractionModel(), or SetContractionCellFactory() AND SetContractionModelOdeTimestep "
00178 "are called. (Pass in a timestep even if contraction model is algebraic and won't use it). ";
00179 EXCEPTION(message);
00180 }
00181
00182 if(mDeformationAffectsConductivity && this->GetCompressibilityType()==COMPRESSIBLE)
00183 {
00184
00185
00186
00187 EXCEPTION("Deformation affecting the conductivity is currently not implemented fully for compressible problems");
00188 }
00189
00190 if(mDeformationAffectsCellModels && mReadFibreSheetInformationFromFile && mFibreSheetDirectionsDefinedPerQuadraturePoint)
00191 {
00192
00193 std::stringstream message;
00194 message << "Deformation affecting cell models cannot be done when fibres-sheet information is defined for each quadrature point.";
00195 message << "Define fibre-sheet information for each element instead.";
00196 EXCEPTION(message.str());
00197 }
00198 }
00199
00201
00203
00204 template class ElectroMechanicsProblemDefinition<2>;
00205 template class ElectroMechanicsProblemDefinition<3>;