37 #include "SolidMechanicsProblemDefinition.hpp"
38 #include "AbstractIncompressibleMaterialLaw.hpp"
39 #include "AbstractCompressibleMaterialLaw.hpp"
41 template<
unsigned DIM>
44 mSolveUsingSnes(false)
48 template<
unsigned DIM>
51 assert(rFixedNodes.size()==rFixedNodeLocations.size());
52 this->mDirichletNodes = rFixedNodes;
54 this->mDirichletNodeValues.clear();
55 for (
unsigned i=0; i<this->mDirichletNodes.size(); i++)
57 unsigned index = this->mDirichletNodes[i];
58 c_vector<double,DIM> displacement;
59 for (
unsigned j=0; j<DIM; j++)
61 double location = rFixedNodeLocations[i](j);
64 if (location != this->FREE)
66 displacement(j) = location - this->mrMesh.GetNode(index)->rGetLocation()[j];
70 displacement(j) = this->FREE;
73 this->mDirichletNodeValues.push_back(displacement);
77 template<
unsigned DIM>
81 mIsHomogeneousMaterial =
true;
82 mCompressibilityType = compressibilityType;
84 mIncompressibleMaterialLaws.clear();
85 mCompressibleMaterialLaws.clear();
89 if (compressibilityType == INCOMPRESSIBLE)
92 CheckCastSuccess(compressibilityType, p_law);
93 mIncompressibleMaterialLaws.push_back(p_law);
98 CheckCastSuccess(compressibilityType, p_law);
99 mCompressibleMaterialLaws.push_back(p_law);
103 template<
unsigned DIM>
107 mIsHomogeneousMaterial =
false;
108 mCompressibilityType = compressibilityType;
110 mIncompressibleMaterialLaws.clear();
111 mCompressibleMaterialLaws.clear();
113 assert(this->mrMesh.GetNumElements() == rMaterialLaws.size());
115 if (compressibilityType == INCOMPRESSIBLE)
117 for (
unsigned i=0; i<rMaterialLaws.size(); i++)
119 assert(rMaterialLaws[i]);
121 CheckCastSuccess(compressibilityType, p_law);
122 mIncompressibleMaterialLaws.push_back(p_law);
127 for (
unsigned i=0; i<rMaterialLaws.size(); i++)
129 assert(rMaterialLaws[i]);
131 CheckCastSuccess(compressibilityType, p_law);
132 mCompressibleMaterialLaws.push_back(p_law);
137 template<
unsigned DIM>
141 assert(mIncompressibleMaterialLaws.size()!=0 || mCompressibleMaterialLaws.size()!=0 );
142 return mIsHomogeneousMaterial;
145 template<
unsigned DIM>
149 assert(mIncompressibleMaterialLaws.size()!=0 || mCompressibleMaterialLaws.size()!=0 );
150 return mCompressibilityType;
153 template<
unsigned DIM>
156 assert(mCompressibilityType==INCOMPRESSIBLE);
157 assert(mIncompressibleMaterialLaws.size()>0);
158 assert(mCompressibleMaterialLaws.size()==0);
160 if (mIsHomogeneousMaterial)
162 return mIncompressibleMaterialLaws[0];
166 assert(elementIndex < this->mrMesh.GetNumNodes());
167 return mIncompressibleMaterialLaws[elementIndex];
171 template<
unsigned DIM>
174 assert(mCompressibilityType == COMPRESSIBLE);
175 assert(mIncompressibleMaterialLaws.size() == 0);
176 assert(mCompressibleMaterialLaws.size() > 0);
178 if (mIsHomogeneousMaterial)
180 return mCompressibleMaterialLaws[0];
184 assert(elementIndex < this->mrMesh.GetNumNodes());
185 return mCompressibleMaterialLaws[elementIndex];
189 template<
unsigned DIM>
193 if ((compressibilityType==INCOMPRESSIBLE) && (pMaterialLaw==
nullptr))
196 EXCEPTION(
"Compressibility type was declared as INCOMPRESSIBLE but a compressible material law was given");
199 if ((compressibilityType==COMPRESSIBLE) && (pMaterialLaw==
nullptr))
202 EXCEPTION(
"Incompressibility type was declared as COMPRESSIBLE but an incompressible material law was given");
206 template<
unsigned DIM>
211 if ((mIncompressibleMaterialLaws.size()==0) && (mCompressibleMaterialLaws.size()==0))
213 EXCEPTION(
"No material law has been set");
bool IsHomogeneousMaterial()
void SetFixedNodes(std::vector< unsigned > &rFixedNodes, std::vector< c_vector< double, DIM > > &rFixedNodeLocation)
#define EXCEPTION(message)
AbstractIncompressibleMaterialLaw< DIM > * GetIncompressibleMaterialLaw(unsigned elementIndex)
void SetMaterialLaw(CompressibilityType compressibilityType, AbstractMaterialLaw< DIM > *pMaterialLaw)
CompressibilityType GetCompressibilityType()
AbstractCompressibleMaterialLaw< DIM > * GetCompressibleMaterialLaw(unsigned elementIndex)
void CheckCastSuccess(CompressibilityType compressibilityType, AbstractMaterialLaw< DIM > *pMaterialLaw)
SolidMechanicsProblemDefinition(AbstractTetrahedralMesh< DIM, DIM > &rMesh)