8#ifndef __ELASTICMATERIALS_HPP__
9#define __ELASTICMATERIALS_HPP__
11#include <boost/program_options.hpp>
12namespace po = boost::program_options;
17#define MAT_KIRCHHOFF "KIRCHHOFF"
18#define MAT_HOOKE "HOOKE"
19#define MAT_NEOHOOKEAN "NEOHOOKEAN"
41 boost::shared_ptr<NonlinearElasticElement::
42 FunctionsToCalculatePiolaKirchhoffI<adouble>>>
78 virtual MoFEMErrorCode
iNit() {
83 boost::make_shared<NonlinearElasticElement::
84 FunctionsToCalculatePiolaKirchhoffI<adouble>>();
90 boost::make_shared<NeoHookean<adouble>>();
92 boost::make_shared<NeoHookean<double>>();
93 std::ostringstream avilable_materials;
94 avilable_materials <<
"set elastic material < ";
98 double>>>::iterator mit;
101 avilable_materials << mit->first <<
" ";
103 avilable_materials <<
">";
106 "Elastic Materials Configuration",
"none");
107 char default_material[255];
108 PetscBool def_mat_set;
109 CHKERR PetscOptionsString(
110 "-default_material", avilable_materials.str().c_str(),
"",
111 defMaterial.c_str(), default_material, 255, &def_mat_set);
117 "material <%s> not implemented", default_material);
120 char config_file[255];
121 CHKERR PetscOptionsString(
"-elastic_material_configuration",
122 "elastic materials configure file name",
"",
128 ierr = PetscOptionsEnd();
169 po::options_description config_file_options;
172 std::ostringstream str_order;
173 str_order <<
"block_" << it->getMeshsetId() <<
".displacemet_order";
174 config_file_options.add_options()(
175 str_order.str().c_str(),
176 po::value<int>(&
blockData[it->getMeshsetId()].oRder)
177 ->default_value(-1));
179 std::ostringstream str_material;
180 str_material <<
"block_" << it->getMeshsetId() <<
".material";
181 config_file_options.add_options()(
182 str_material.str().c_str(),
183 po::value<std::string>(&
blockData[it->getMeshsetId()].mAterial)
186 std::ostringstream str_ym;
187 str_ym <<
"block_" << it->getMeshsetId() <<
".young_modulus";
188 config_file_options.add_options()(
189 str_ym.str().c_str(),
190 po::value<double>(&
blockData[it->getMeshsetId()].yOung)
191 ->default_value(-1));
193 std::ostringstream str_pr;
194 str_pr <<
"block_" << it->getMeshsetId() <<
".poisson_ratio";
195 config_file_options.add_options()(
196 str_pr.str().c_str(),
197 po::value<double>(&
blockData[it->getMeshsetId()].pOisson)
198 ->default_value(-2));
200 std::ostringstream str_density;
201 str_density <<
"block_" << it->getMeshsetId() <<
".density";
202 config_file_options.add_options()(
203 str_density.str().c_str(),
204 po::value<double>(&
blockData[it->getMeshsetId()].dEnsity)
205 ->default_value(-1));
207 std::ostringstream str_dashG;
208 str_dashG <<
"block_" << it->getMeshsetId() <<
".dashG";
209 config_file_options.add_options()(
210 str_dashG.str().c_str(),
211 po::value<double>(&
blockData[it->getMeshsetId()].dashG)
212 ->default_value(-1));
214 std::ostringstream str_dashPoisson;
215 str_dashPoisson <<
"block_" << it->getMeshsetId() <<
".dashPoisson";
216 config_file_options.add_options()(
217 str_dashPoisson.str().c_str(),
218 po::value<double>(&
blockData[it->getMeshsetId()].dashPoisson)
219 ->default_value(-2));
221 std::ostringstream str_ax;
222 str_ax <<
"block_" << it->getMeshsetId() <<
".a_x";
223 config_file_options.add_options()(
224 str_ax.str().c_str(),
225 po::value<double>(&
blockData[it->getMeshsetId()].aX)
228 std::ostringstream str_ay;
229 str_ay <<
"block_" << it->getMeshsetId() <<
".a_y";
230 config_file_options.add_options()(
231 str_ay.str().c_str(),
232 po::value<double>(&
blockData[it->getMeshsetId()].aY)
235 std::ostringstream str_az;
236 str_az <<
"block_" << it->getMeshsetId() <<
".a_z";
237 config_file_options.add_options()(
238 str_az.str().c_str(),
239 po::value<double>(&
blockData[it->getMeshsetId()].aZ)
242 po::parsed_options parsed =
243 parse_config_file(file, config_file_options,
true);
246 std::vector<std::string> additional_parameters;
247 additional_parameters =
248 collect_unrecognized(parsed.options, po::include_positional);
249 for (std::vector<std::string>::iterator vit = additional_parameters.begin();
250 vit != additional_parameters.end(); vit++) {
251 CHKERR PetscPrintf(PETSC_COMM_WORLD,
252 "** WARNING Unrecognized option %s\n", vit->c_str());
262 PetscBool flg = PETSC_TRUE;
264 CHKERR PetscOptionsGetInt(PETSC_NULL, PETSC_NULL,
"-order", &disp_order,
266 if (flg != PETSC_TRUE) {
270 if (
blockData[it->getMeshsetId()].oRder == -1)
272 if (
blockData[it->getMeshsetId()].oRder == disp_order)
275 it->getMeshsetId(),
blockData[it->getMeshsetId()].oRder);
277 rval =
mField.
get_moab().get_entities_by_handle(it->meshset, block_ents,
280 Range ents_to_set_order;
282 block_ents, 3,
false, ents_to_set_order, moab::Interface::UNION);
283 ents_to_set_order = ents_to_set_order.subset_by_type(MBTET);
285 block_ents, 2,
false, ents_to_set_order, moab::Interface::UNION);
287 block_ents, 1,
false, ents_to_set_order, moab::Interface::UNION);
308#ifdef __NONLINEAR_ELASTIC_HPP
310 virtual MoFEMErrorCode
311 setBlocks(std::map<int, NonlinearElasticElement::BlockData> &set_of_blocks) {
322 int id = it->getMeshsetId();
324 CHKERR it->getAttributeDataStructure(mydata);
327 meshset, MBTET, set_of_blocks[
id].tEts,
true);
328 set_of_blocks[id].iD = id;
329 set_of_blocks[id].E = mydata.data.Young;
330 set_of_blocks[id].PoissonRatio = mydata.data.Poisson;
332 set_of_blocks[id].E =
blockData[id].yOung;
334 set_of_blocks[id].PoissonRatio =
blockData[id].pOisson;
338 set_of_blocks[id].materialAdoublePtr =
342 "Block Id %d Young Modulus %3.2g Poisson Ratio %3.2f "
343 "Material model %s Nb. of elements %d\n",
344 id, set_of_blocks[
id].
E, set_of_blocks[
id].PoissonRatio,
346 set_of_blocks[
id].tEts.size());
349 set_of_blocks[id].materialDoublePtr =
351 set_of_blocks[id].materialAdoublePtr =
355 set_of_blocks[id].materialAdoublePtr =
358 set_of_blocks[id].materialDoublePtr =
360 set_of_blocks[id].materialAdoublePtr =
364 "field with that space is not implemented");
372#ifdef __CONVECTIVE_MASS_ELEMENT_HPP
375 setBlocks(std::map<int, ConvectiveMassElement::BlockData> &set_of_blocks) {
386 int id = it->getMeshsetId();
389 meshset, MBTET, set_of_blocks[
id].tEts,
true);
390 Block_BodyForces mydata;
391 CHKERR it->getAttributeDataStructure(mydata);
392 set_of_blocks[id].rho0 = mydata.data.density;
393 set_of_blocks[id].a0.resize(3);
394 set_of_blocks[id].a0[0] = mydata.data.acceleration_x;
395 set_of_blocks[id].a0[1] = mydata.data.acceleration_y;
396 set_of_blocks[id].a0[2] = mydata.data.acceleration_z;
398 set_of_blocks[id].rho0 =
blockData[id].dEnsity;
399 std::ostringstream str_ax;
400 str_ax <<
"block_" << it->getMeshsetId() <<
".a_x";
401 std::ostringstream str_ay;
402 str_ay <<
"block_" << it->getMeshsetId() <<
".a_y";
403 std::ostringstream str_az;
404 str_az <<
"block_" << it->getMeshsetId() <<
".a_z";
405 if (
vM.count(str_ax.str().c_str())) {
406 set_of_blocks[id].a0[0] =
blockData[id].aX;
408 if (
vM.count(str_ay.str().c_str())) {
409 set_of_blocks[id].a0[1] =
blockData[id].aY;
411 if (
vM.count(str_az.str().c_str())) {
412 set_of_blocks[id].a0[2] =
blockData[id].aZ;
416 "Block Id %d Density %3.2g a_x = %3.2g a_y = %3.2g a_z = "
417 "%3.2g Nb. of elements %d\n",
418 id, set_of_blocks[
id].rho0, set_of_blocks[
id].a0[0],
419 set_of_blocks[
id].a0[1], set_of_blocks[
id].a0[2],
420 set_of_blocks[
id].tEts.size());
428#ifdef __KELVIN_VOIGT_DAMPER_HPP__
431 std::map<int, KelvinVoigtDamper::BlockMaterialData> &set_of_blocks) {
443 int id = it->getMeshsetId();
445 if (it->getName().compare(0, 6,
"DAMPER") == 0) {
447 std::vector<double> data;
448 CHKERR it->getAttributes(data);
449 if (data.size() < 2) {
450 SETERRQ(PETSC_COMM_SELF, 1,
"Data inconsistency");
453 it->meshset, MBTET, set_of_blocks[it->getMeshsetId()].tEts,
true);
455 set_of_blocks[it->getMeshsetId()].gBeta = data[0];
456 set_of_blocks[it->getMeshsetId()].vBeta = data[1];
462 mField.
get_moab().get_entities_by_type(meshset, MBTET, tEts,
true);
466 set_of_blocks[it->getMeshsetId()].tEts = tEts;
467 set_of_blocks[it->getMeshsetId()].gBeta =
blockData[id].dashG;
468 set_of_blocks[it->getMeshsetId()].vBeta =
blockData[id].dashPoisson;
473 "Block Id %d Damper Shear Modulus = %3.2g Poisson ratio = %3.2g\n",
474 id, set_of_blocks[
id].gBeta, set_of_blocks[
id].vBeta);
Implementation of linear elastic material.
static MoFEMErrorCode setBlocks(MoFEM::Interface &m_field, boost::shared_ptr< map< int, BlockData > > &block_sets_ptr)
#define MOFEM_LOG_C(channel, severity, format,...)
Implementation of Neo-Hookean elastic material.
static PetscErrorCode ierr
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ BODYFORCESSET
block name is "BODY_FORCES"
@ MAT_ELASTICSET
block name is "MAT_ELASTIC"
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual bool check_field(const std::string &name) const =0
check if field is in database
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Manage setting parameters and constitutive equations for nonlinear/linear elastic materials.
std::map< std::string, boost::shared_ptr< NonlinearElasticElement::FunctionsToCalculatePiolaKirchhoffI< adouble > > > aDoubleMaterialModel
virtual MoFEMErrorCode readConfigFile()
read Elastic materials declaration for blocks and meshsets
std::map< std::string, boost::shared_ptr< NonlinearElasticElement::FunctionsToCalculatePiolaKirchhoffI< double > > > doubleMaterialModel
Hash map of materials for evaluation with double.
virtual MoFEMErrorCode iNit()
MoFEMErrorCode setBlocksOrder()
MoFEM::Interface & mField
virtual ~ElasticMaterials()
std::map< int, BlockOptionData > blockData
Material parameters on blocks.
PetscBool isConfigFileSet
True if config file is set from command line.
ElasticMaterials(MoFEM::Interface &m_field, std::string def_material=MAT_KIRCHHOFF)
bool iNitialized
true if class is initialized
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Deprecated interface functions.
Implementation of elastic (non-linear) St. Kirchhoff equation.