v0.15.0
Loading...
Searching...
No Matches
ElasticMaterials Struct Reference

Manage setting parameters and constitutive equations for nonlinear/linear elastic materials. More...

#include "users_modules/basic_finite_elements/nonlinear_elastic_materials/src/ElasticMaterials.hpp"

Collaboration diagram for ElasticMaterials:
[legend]

Classes

struct  BlockOptionData
 

Public Member Functions

 ElasticMaterials (MoFEM::Interface &m_field, std::string def_material="KIRCHHOFF")
 
virtual ~ElasticMaterials ()
 
virtual MoFEMErrorCode iNit ()
 
virtual MoFEMErrorCode readConfigFile ()
 read Elastic materials declaration for blocks and meshsets
 
MoFEMErrorCode setBlocksOrder ()
 

Public Attributes

MoFEM::InterfacemField
 
std::string defMaterial
 
std::string configFile
 
bool iNitialized
 true if class is initialized
 
std::map< std::string, boost::shared_ptr< NonlinearElasticElement::FunctionsToCalculatePiolaKirchhoffI< adouble > > > aDoubleMaterialModel
 
std::map< std::string, boost::shared_ptr< NonlinearElasticElement::FunctionsToCalculatePiolaKirchhoffI< double > > > doubleMaterialModel
 Hash map of materials for evaluation with double.
 
std::map< int, BlockOptionDatablockData
 Material parameters on blocks.
 
PetscBool isConfigFileSet
 True if config file is set from command line.
 
po::variables_map vM
 

Detailed Description

Manage setting parameters and constitutive equations for nonlinear/linear elastic materials.

Examples
Remodeling.cpp, and nonlinear_dynamics.cpp.

Definition at line 24 of file ElasticMaterials.hpp.

Constructor & Destructor Documentation

◆ ElasticMaterials()

ElasticMaterials::ElasticMaterials ( MoFEM::Interface & m_field,
std::string def_material = "KIRCHHOFF" )
inline

Definition at line 33 of file ElasticMaterials.hpp.

35 : mField(m_field), defMaterial(def_material),
36 configFile("elastic_material.in"), iNitialized(false) {}
MoFEM::Interface & mField
bool iNitialized
true if class is initialized

◆ ~ElasticMaterials()

virtual ElasticMaterials::~ElasticMaterials ( )
inlinevirtual

Definition at line 38 of file ElasticMaterials.hpp.

38{}

Member Function Documentation

◆ iNit()

virtual MoFEMErrorCode ElasticMaterials::iNit ( )
inlinevirtual

Initialize model parameters

Returns
[description]

Definition at line 78 of file ElasticMaterials.hpp.

78 {
80 // add new material below
81 string mat_name;
83 boost::make_shared<NonlinearElasticElement::
84 FunctionsToCalculatePiolaKirchhoffI<adouble>>();
85 doubleMaterialModel[MAT_KIRCHHOFF] = boost::make_shared<
87 aDoubleMaterialModel[MAT_HOOKE] = boost::make_shared<Hooke<adouble>>();
88 doubleMaterialModel[MAT_HOOKE] = boost::make_shared<Hooke<double>>();
90 boost::make_shared<NeoHookean<adouble>>();
92 boost::make_shared<NeoHookean<double>>();
93 std::ostringstream avilable_materials;
94 avilable_materials << "set elastic material < ";
95 std::map<std::string,
96 boost::shared_ptr<
98 double>>>::iterator mit;
99 mit = doubleMaterialModel.begin();
100 for (; mit != doubleMaterialModel.end(); mit++) {
101 avilable_materials << mit->first << " ";
102 }
103 avilable_materials << ">";
104
105 PetscOptionsBegin(mField.get_comm(), "", "Elastic Materials Configuration",
106 "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);
112 if (def_mat_set) {
113 defMaterial = default_material;
115 aDoubleMaterialModel.end()) {
116 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
117 "material <%s> not implemented", default_material);
118 }
119 }
120 char config_file[255];
121 CHKERR PetscOptionsString("-elastic_material_configuration",
122 "elastic materials configure file name", "",
123 configFile.c_str(), config_file, 255,
125 if (isConfigFileSet) {
126 configFile = config_file;
127 }
128 PetscOptionsEnd();
130 }
#define MAT_KIRCHHOFF
#define MAT_NEOHOOKEAN
#define MAT_HOOKE
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
std::map< std::string, boost::shared_ptr< NonlinearElasticElement::FunctionsToCalculatePiolaKirchhoffI< adouble > > > aDoubleMaterialModel
std::map< std::string, boost::shared_ptr< NonlinearElasticElement::FunctionsToCalculatePiolaKirchhoffI< double > > > doubleMaterialModel
Hash map of materials for evaluation with double.
PetscBool isConfigFileSet
True if config file is set from command line.
virtual MPI_Comm & get_comm() const =0
Implementation of elastic (non-linear) St. Kirchhoff equation.

◆ readConfigFile()

virtual MoFEMErrorCode ElasticMaterials::readConfigFile ( )
inlinevirtual

read Elastic materials declaration for blocks and meshsets

File parameters:

[block_1]
displacemet_order = 1/2 .. N
material = KIRCHHOFF/HOOKE/NEOHOOKEAN
density = 1
a_x = 0
a_y = 0
a_z = 10
double young_modulus
Young modulus.
Definition plastic.cpp:125
double poisson_ratio
Poisson ratio.
Definition plastic.cpp:126
const int N
Definition speed_test.cpp:3

To read material configuration file you need to use option:

-elastic_material_configuration name_of_config_file

Definition at line 153 of file ElasticMaterials.hpp.

153 {
155
156 ifstream file(configFile.c_str());
157 if (isConfigFileSet) {
158 if (!file.good()) {
159 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "file < %s > not found",
160 configFile.c_str());
161 }
162 } else {
163 if (!file.good()) {
165 }
166 }
167
168 po::options_description config_file_options;
170
171 std::ostringstream str_order;
172 str_order << "block_" << it->getMeshsetId() << ".displacemet_order";
173 config_file_options.add_options()(
174 str_order.str().c_str(),
175 po::value<int>(&blockData[it->getMeshsetId()].oRder)
176 ->default_value(-1));
177
178 std::ostringstream str_material;
179 str_material << "block_" << it->getMeshsetId() << ".material";
180 config_file_options.add_options()(
181 str_material.str().c_str(),
182 po::value<std::string>(&blockData[it->getMeshsetId()].mAterial)
183 ->default_value(defMaterial));
184
185 std::ostringstream str_ym;
186 str_ym << "block_" << it->getMeshsetId() << ".young_modulus";
187 config_file_options.add_options()(
188 str_ym.str().c_str(),
189 po::value<double>(&blockData[it->getMeshsetId()].yOung)
190 ->default_value(-1));
191
192 std::ostringstream str_pr;
193 str_pr << "block_" << it->getMeshsetId() << ".poisson_ratio";
194 config_file_options.add_options()(
195 str_pr.str().c_str(),
196 po::value<double>(&blockData[it->getMeshsetId()].pOisson)
197 ->default_value(-2));
198
199 std::ostringstream str_density;
200 str_density << "block_" << it->getMeshsetId() << ".density";
201 config_file_options.add_options()(
202 str_density.str().c_str(),
203 po::value<double>(&blockData[it->getMeshsetId()].dEnsity)
204 ->default_value(-1));
205
206 std::ostringstream str_dashG;
207 str_dashG << "block_" << it->getMeshsetId() << ".dashG";
208 config_file_options.add_options()(
209 str_dashG.str().c_str(),
210 po::value<double>(&blockData[it->getMeshsetId()].dashG)
211 ->default_value(-1));
212
213 std::ostringstream str_dashPoisson;
214 str_dashPoisson << "block_" << it->getMeshsetId() << ".dashPoisson";
215 config_file_options.add_options()(
216 str_dashPoisson.str().c_str(),
217 po::value<double>(&blockData[it->getMeshsetId()].dashPoisson)
218 ->default_value(-2));
219
220 std::ostringstream str_ax;
221 str_ax << "block_" << it->getMeshsetId() << ".a_x";
222 config_file_options.add_options()(
223 str_ax.str().c_str(),
224 po::value<double>(&blockData[it->getMeshsetId()].aX)
225 ->default_value(0));
226
227 std::ostringstream str_ay;
228 str_ay << "block_" << it->getMeshsetId() << ".a_y";
229 config_file_options.add_options()(
230 str_ay.str().c_str(),
231 po::value<double>(&blockData[it->getMeshsetId()].aY)
232 ->default_value(0));
233
234 std::ostringstream str_az;
235 str_az << "block_" << it->getMeshsetId() << ".a_z";
236 config_file_options.add_options()(
237 str_az.str().c_str(),
238 po::value<double>(&blockData[it->getMeshsetId()].aZ)
239 ->default_value(0));
240 }
241 po::parsed_options parsed =
242 parse_config_file(file, config_file_options, true);
243 store(parsed, vM);
244 po::notify(vM);
245 std::vector<std::string> additional_parameters;
246 additional_parameters =
247 collect_unrecognized(parsed.options, po::include_positional);
248 for (std::vector<std::string>::iterator vit = additional_parameters.begin();
249 vit != additional_parameters.end(); vit++) {
250 CHKERR PetscPrintf(PETSC_COMM_WORLD,
251 "** WARNING Unrecognized option %s\n", vit->c_str());
252 }
253
255 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ BLOCKSET
@ MOFEM_NOT_FOUND
Definition definitions.h:33
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#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.
std::map< int, BlockOptionData > blockData
Material parameters on blocks.
po::variables_map vM

◆ setBlocksOrder()

MoFEMErrorCode ElasticMaterials::setBlocksOrder ( )
inline

Definition at line 257 of file ElasticMaterials.hpp.

257 {
259
260 // set app. order
261 PetscBool flg = PETSC_TRUE;
262 PetscInt disp_order;
263 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, PETSC_NULLPTR, "-order", &disp_order,
264 &flg);
265 if (flg != PETSC_TRUE) {
266 disp_order = 1;
267 }
269 if (blockData[it->getMeshsetId()].oRder == -1)
270 continue;
271 if (blockData[it->getMeshsetId()].oRder == disp_order)
272 continue;
273 PetscPrintf(mField.get_comm(), "Set block %d oRder to %d\n",
274 it->getMeshsetId(), blockData[it->getMeshsetId()].oRder);
275 Range block_ents;
276 rval = mField.get_moab().get_entities_by_handle(it->meshset, block_ents,
277 true);
278 CHKERRG(rval);
279 Range ents_to_set_order;
280 CHKERR mField.get_moab().get_adjacencies(
281 block_ents, 3, false, ents_to_set_order, moab::Interface::UNION);
282 ents_to_set_order = ents_to_set_order.subset_by_type(MBTET);
283 CHKERR mField.get_moab().get_adjacencies(
284 block_ents, 2, false, ents_to_set_order, moab::Interface::UNION);
285 CHKERR mField.get_moab().get_adjacencies(
286 block_ents, 1, false, ents_to_set_order, moab::Interface::UNION);
287 if (mField.check_field("DISPLACEMENT")) {
288 CHKERR mField.set_field_order(ents_to_set_order, "DISPLACEMENT",
289 blockData[it->getMeshsetId()].oRder);
290 }
291 if (mField.check_field("SPATIAL_POSITION")) {
292 CHKERR mField.set_field_order(ents_to_set_order, "SPATIAL_POSITION",
293 blockData[it->getMeshsetId()].oRder);
294 }
295 if (mField.check_field("DOT_SPATIAL_POSITION")) {
296 CHKERR mField.set_field_order(ents_to_set_order, "DOT_SPATIAL_POSITION",
297 blockData[it->getMeshsetId()].oRder);
298 }
299 if (mField.check_field("SPATIAL_VELOCITY")) {
300 CHKERR mField.set_field_order(ents_to_set_order, "SPATIAL_VELOCITY",
301 blockData[it->getMeshsetId()].oRder);
302 }
303 }
305 }
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
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
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
virtual moab::Interface & get_moab()=0

Member Data Documentation

◆ aDoubleMaterialModel

std::map<std::string, boost::shared_ptr<NonlinearElasticElement:: FunctionsToCalculatePiolaKirchhoffI<adouble> > > ElasticMaterials::aDoubleMaterialModel

Hash map of materials for evaluation with adouble, i.e. ADOL-C

Definition at line 43 of file ElasticMaterials.hpp.

◆ blockData

std::map<int, BlockOptionData> ElasticMaterials::blockData

Material parameters on blocks.

Definition at line 69 of file ElasticMaterials.hpp.

◆ configFile

std::string ElasticMaterials::configFile

Definition at line 29 of file ElasticMaterials.hpp.

◆ defMaterial

std::string ElasticMaterials::defMaterial

default material, if block is set to elastic, this material is used as default

Definition at line 27 of file ElasticMaterials.hpp.

◆ doubleMaterialModel

std::map< std::string, boost::shared_ptr< NonlinearElasticElement::FunctionsToCalculatePiolaKirchhoffI<double> > > ElasticMaterials::doubleMaterialModel

Hash map of materials for evaluation with double.

Definition at line 50 of file ElasticMaterials.hpp.

◆ iNitialized

bool ElasticMaterials::iNitialized

true if class is initialized

Definition at line 31 of file ElasticMaterials.hpp.

◆ isConfigFileSet

PetscBool ElasticMaterials::isConfigFileSet

True if config file is set from command line.

Definition at line 71 of file ElasticMaterials.hpp.

◆ mField

MoFEM::Interface& ElasticMaterials::mField

Definition at line 26 of file ElasticMaterials.hpp.

◆ vM

po::variables_map ElasticMaterials::vM

Definition at line 72 of file ElasticMaterials.hpp.


The documentation for this struct was generated from the following file: