v0.14.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | List of all members
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=MAT_KIRCHHOFF)
 
virtual ~ElasticMaterials ()
 
virtual MoFEMErrorCode iNit ()
 
virtual MoFEMErrorCode readConfigFile ()
 read Elastic materials declaration for blocks and meshsets More...
 
MoFEMErrorCode setBlocksOrder ()
 

Public Attributes

MoFEM::InterfacemField
 
std::string defMaterial
 
std::string configFile
 
bool iNitialized
 true if class is initialized More...
 
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. More...
 
std::map< int, BlockOptionDatablockData
 Material parameters on blocks. More...
 
PetscBool isConfigFileSet
 True if config file is set from command line. More...
 
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 = MAT_KIRCHHOFF 
)
inline

Definition at line 33 of file ElasticMaterials.hpp.

35 : mField(m_field), defMaterial(def_material),
36 configFile("elastic_material.in"), iNitialized(false) {}
std::string configFile
MoFEM::Interface & mField
std::string defMaterial
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 CHKERR PetscOptionsBegin(mField.get_comm(), "",
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);
112 if (def_mat_set) {
113 defMaterial = default_material;
115 aDoubleMaterialModel.end()) {
116 SETERRQ1(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 ierr = PetscOptionsEnd();
129 CHKERRG(ierr);
131 }
#define MAT_KIRCHHOFF
#define MAT_NEOHOOKEAN
#define MAT_HOOKE
static PetscErrorCode ierr
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
#define CHKERR
Inline error check.
Definition: definitions.h:535
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
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:172
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 154 of file ElasticMaterials.hpp.

154 {
156
157 ifstream file(configFile.c_str());
158 if (isConfigFileSet) {
159 if (!file.good()) {
160 SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "file < %s > not found",
161 configFile.c_str());
162 }
163 } else {
164 if (!file.good()) {
166 }
167 }
168
169 po::options_description config_file_options;
171
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));
178
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)
184 ->default_value(defMaterial));
185
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));
192
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));
199
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));
206
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));
213
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));
220
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)
226 ->default_value(0));
227
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)
233 ->default_value(0));
234
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)
240 ->default_value(0));
241 }
242 po::parsed_options parsed =
243 parse_config_file(file, config_file_options, true);
244 store(parsed, vM);
245 po::notify(vM);
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());
253 }
254
256 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ BLOCKSET
Definition: definitions.h:148
@ MOFEM_NOT_FOUND
Definition: definitions.h:33
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#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 258 of file ElasticMaterials.hpp.

258 {
260
261 // set app. order
262 PetscBool flg = PETSC_TRUE;
263 PetscInt disp_order;
264 CHKERR PetscOptionsGetInt(PETSC_NULL, PETSC_NULL, "-order", &disp_order,
265 &flg);
266 if (flg != PETSC_TRUE) {
267 disp_order = 1;
268 }
270 if (blockData[it->getMeshsetId()].oRder == -1)
271 continue;
272 if (blockData[it->getMeshsetId()].oRder == disp_order)
273 continue;
274 PetscPrintf(mField.get_comm(), "Set block %d oRder to %d\n",
275 it->getMeshsetId(), blockData[it->getMeshsetId()].oRder);
276 Range block_ents;
277 rval = mField.get_moab().get_entities_by_handle(it->meshset, block_ents,
278 true);
279 CHKERRG(rval);
280 Range ents_to_set_order;
281 CHKERR mField.get_moab().get_adjacencies(
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);
284 CHKERR mField.get_moab().get_adjacencies(
285 block_ents, 2, false, ents_to_set_order, moab::Interface::UNION);
286 CHKERR mField.get_moab().get_adjacencies(
287 block_ents, 1, false, ents_to_set_order, moab::Interface::UNION);
288 if (mField.check_field("DISPLACEMENT")) {
289 CHKERR mField.set_field_order(ents_to_set_order, "DISPLACEMENT",
290 blockData[it->getMeshsetId()].oRder);
291 }
292 if (mField.check_field("SPATIAL_POSITION")) {
293 CHKERR mField.set_field_order(ents_to_set_order, "SPATIAL_POSITION",
294 blockData[it->getMeshsetId()].oRder);
295 }
296 if (mField.check_field("DOT_SPATIAL_POSITION")) {
297 CHKERR mField.set_field_order(ents_to_set_order, "DOT_SPATIAL_POSITION",
298 blockData[it->getMeshsetId()].oRder);
299 }
300 if (mField.check_field("SPATIAL_VELOCITY")) {
301 CHKERR mField.set_field_order(ents_to_set_order, "SPATIAL_VELOCITY",
302 blockData[it->getMeshsetId()].oRder);
303 }
304 }
306 }
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: