37 #include "SolidMechanicsProblemDefinition.hpp"
38 #include "AbstractIncompressibleMaterialLaw.hpp"
39 #include "AbstractCompressibleMaterialLaw.hpp"
42 template<
unsigned DIM>
45 mSolveUsingSnes(false)
51 template<
unsigned DIM>
54 assert(rFixedNodes.size()==rFixedNodeLocations.size());
55 this->mDirichletNodes = rFixedNodes;
57 this->mDirichletNodeValues.clear();
58 for (
unsigned i=0; i<this->mDirichletNodes.size(); i++)
60 unsigned index = this->mDirichletNodes[i];
61 c_vector<double,DIM> displacement;
62 for(
unsigned j=0; j<DIM; j++)
64 double location = rFixedNodeLocations[i](j);
68 if(location != this->FREE)
70 displacement(j) = location - this->mrMesh.GetNode(index)->rGetLocation()[j];
74 displacement(j) = this->FREE;
77 this->mDirichletNodeValues.push_back(displacement);
82 template<
unsigned DIM>
86 mIsHomogeneousMaterial =
true;
87 mCompressibilityType = compressibilityType;
89 mIncompressibleMaterialLaws.clear();
90 mCompressibleMaterialLaws.clear();
94 if(compressibilityType==INCOMPRESSIBLE)
97 CheckCastSuccess(compressibilityType, p_law);
98 mIncompressibleMaterialLaws.push_back(p_law);
103 CheckCastSuccess(compressibilityType, p_law);
104 mCompressibleMaterialLaws.push_back(p_law);
109 template<
unsigned DIM>
113 mIsHomogeneousMaterial =
false;
114 mCompressibilityType = compressibilityType;
116 mIncompressibleMaterialLaws.clear();
117 mCompressibleMaterialLaws.clear();
119 assert(this->mrMesh.GetNumElements()==rMaterialLaws.size());
121 if(compressibilityType==INCOMPRESSIBLE)
123 for(
unsigned i=0; i<rMaterialLaws.size(); i++)
125 assert(rMaterialLaws[i]);
127 CheckCastSuccess(compressibilityType, p_law);
128 mIncompressibleMaterialLaws.push_back(p_law);
133 for(
unsigned i=0; i<rMaterialLaws.size(); i++)
135 assert(rMaterialLaws[i]);
137 CheckCastSuccess(compressibilityType, p_law);
138 mCompressibleMaterialLaws.push_back(p_law);
146 template<
unsigned DIM>
150 assert(mIncompressibleMaterialLaws.size()!=0 || mCompressibleMaterialLaws.size()!=0 );
151 return mIsHomogeneousMaterial;
154 template<
unsigned DIM>
158 assert(mIncompressibleMaterialLaws.size()!=0 || mCompressibleMaterialLaws.size()!=0 );
159 return mCompressibilityType;
165 template<
unsigned DIM>
168 assert(mCompressibilityType==INCOMPRESSIBLE);
169 assert(mIncompressibleMaterialLaws.size()>0);
170 assert(mCompressibleMaterialLaws.size()==0);
172 if(mIsHomogeneousMaterial)
174 return mIncompressibleMaterialLaws[0];
178 assert(elementIndex < this->mrMesh.GetNumNodes());
179 return mIncompressibleMaterialLaws[elementIndex];
183 template<
unsigned DIM>
186 assert(mCompressibilityType==COMPRESSIBLE);
187 assert(mIncompressibleMaterialLaws.size()==0);
188 assert(mCompressibleMaterialLaws.size()>0);
190 if(mIsHomogeneousMaterial)
192 return mCompressibleMaterialLaws[0];
196 assert(elementIndex < this->mrMesh.GetNumNodes());
197 return mCompressibleMaterialLaws[elementIndex];
201 template<
unsigned DIM>
205 if(compressibilityType==INCOMPRESSIBLE && pMaterialLaw==NULL)
208 EXCEPTION(
"Compressibility type was declared as INCOMPRESSIBLE but a compressible material law was given");
211 if(compressibilityType==COMPRESSIBLE && pMaterialLaw==NULL)
214 EXCEPTION(
"Incompressibility type was declared as COMPRESSIBLE but an incompressible material law was given");
219 template<
unsigned DIM>
224 if((mIncompressibleMaterialLaws.size()==0) && (mCompressibleMaterialLaws.size()==0))
226 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)