v0.15.0
Loading...
Searching...
No Matches
arc_length_interface.cpp
Go to the documentation of this file.
1/** \file arc_length_interface.cpp
2 * \brief Example of arc-length with interface element
3
4 \todo Mak it work with multi-grid and distributed mesh
5
6 \todo Make more clever step adaptation
7
8*/
9
10
11
13using namespace MoFEM;
14
16#include <Hooke.hpp>
18
19using namespace boost::numeric;
20
21static char help[] = "\
22 -my_file mesh file name\n\
23 -my_sr reduction of step size\n\
24 -my_its_d desired number of steps\n\
25 -my_ms maximal number of steps\n\n";
26
27#define DATAFILENAME "load_disp.txt"
28
29namespace CohesiveElement {
30
35 boost::shared_ptr<ArcLengthCtx> &arc_ptr)
36 : ArcLengthIntElemFEMethod(m_field.get_moab(), arc_ptr), mField(m_field) {
37
38 for (_IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_(mField, "LoadPath", cit)) {
39 EntityHandle meshset = cit->getMeshset();
40 Range nodes;
41 rval = mOab.get_entities_by_type(meshset, MBVERTEX, nodes, true);
43 postProcNodes.merge(nodes);
44 }
45
46 PetscPrintf(PETSC_COMM_WORLD, "Nb. PostProcNodes %lu\n",
47 postProcNodes.size());
48 };
49
52 FILE *datafile;
53 PetscFOpen(PETSC_COMM_SELF, DATAFILENAME, "a+", &datafile);
54 const auto bit_number_lambda = mField.get_field_bit_number("LAMBDA");
55
56 boost::shared_ptr<NumeredDofEntity_multiIndex> numered_dofs_rows =
57 problemPtr->getNumeredRowDofsPtr();
58 auto lit = numered_dofs_rows->lower_bound(
59 FieldEntity::getLoBitNumberUId(bit_number_lambda));
60 auto hi_lit = numered_dofs_rows->upper_bound(
61 FieldEntity::getHiBitNumberUId(bit_number_lambda));
62
63 if (lit == numered_dofs_rows->end()) {
64 fclose(datafile);
66 } else if (std::distance(lit, hi_lit) != 1) {
67 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
68 "Only one DOF is expected");
69 }
70
71 Range::iterator nit = postProcNodes.begin();
72 for (; nit != postProcNodes.end(); nit++) {
73 NumeredDofEntityByEnt::iterator dit, hi_dit;
74 dit = numered_dofs_rows->get<Ent_mi_tag>().lower_bound(*nit);
75 hi_dit = numered_dofs_rows->get<Ent_mi_tag>().upper_bound(*nit);
76 double coords[3];
77 CHKERR mOab.get_coords(&*nit, 1, coords);
78 for (; dit != hi_dit; dit++) {
79 PetscPrintf(PETSC_COMM_WORLD, "%s [ %d ] %6.4e -> ",
80 lit->get()->getName().c_str(), lit->get()->getDofCoeffIdx(),
81 lit->get()->getFieldData());
82 PetscPrintf(PETSC_COMM_WORLD, "%s [ %d ] %6.4e ",
83 dit->get()->getName().c_str(), dit->get()->getDofCoeffIdx(),
84 dit->get()->getFieldData());
85 PetscPrintf(PETSC_COMM_WORLD, "-> %3.4f %3.4f %3.4f\n", coords[0],
86 coords[1], coords[2]);
87 PetscFPrintf(PETSC_COMM_WORLD, datafile, "%6.4e %6.4e ",
88 dit->get()->getFieldData(), lit->get()->getFieldData());
89 }
90 }
91 PetscFPrintf(PETSC_COMM_WORLD, datafile, "\n");
92 fclose(datafile);
94 }
95};
96
98
101 boost::shared_ptr<ArcLengthCtx> arcPtr;
102
103 AssembleRhsVectors(MoFEM::Interface &m_field, Vec &body_force,
104 boost::shared_ptr<ArcLengthCtx> &arc_ptr)
105 : mField(m_field), bodyForce(body_force), arcPtr(arc_ptr) {}
106
109
110 switch (snes_ctx) {
111 case CTX_SNESNONE: {
112 } break;
113 case CTX_SNESSETFUNCTION: {
114 CHKERR VecZeroEntries(snes_f);
115 CHKERR VecGhostUpdateBegin(snes_f, INSERT_VALUES, SCATTER_FORWARD);
116 CHKERR VecGhostUpdateEnd(snes_f, INSERT_VALUES, SCATTER_FORWARD);
117 } break;
118 default:
119 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
120 }
121
123 }
124
127 switch (snes_ctx) {
128 case CTX_SNESNONE: {
129 } break;
130 case CTX_SNESSETFUNCTION: {
131 if (snes_f) {
132 CHKERR VecGhostUpdateBegin(snes_f, ADD_VALUES, SCATTER_REVERSE);
133 CHKERR VecGhostUpdateEnd(snes_f, ADD_VALUES, SCATTER_REVERSE);
134 CHKERR VecAssemblyBegin(snes_f);
135 CHKERR VecAssemblyEnd(snes_f);
136 // add F_lambda
137 CHKERR VecAXPY(snes_f, arcPtr->getFieldData(), arcPtr->F_lambda);
138 CHKERR VecAXPY(snes_f, -1., bodyForce);
139 PetscPrintf(PETSC_COMM_WORLD, "\tlambda = %6.4e\n",
140 arcPtr->getFieldData());
141 // snes_f norm
142 double fnorm;
143 CHKERR VecNorm(snes_f, NORM_2, &fnorm);
144 PetscPrintf(PETSC_COMM_WORLD, "\tfnorm = %6.4e\n", fnorm);
145 }
146 } break;
147 default:
148 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
149 }
150
152 }
153};
154
155} // namespace CohesiveElement
156
157using namespace CohesiveElement;
158
159int main(int argc, char *argv[]) {
160
161 const string default_options = "-ksp_type fgmres \n"
162 "-pc_type lu \n"
163 "-pc_factor_mat_solver_type mumps\n"
164 "-mat_mumps_icntl_20 0\n"
165 "-ksp_monitor \n"
166 "-ksp_atol 1e-10 \n"
167 "-ksp_rtol 1e-10 \n"
168 "-snes_monitor \n"
169 "-snes_type newtonls \n"
170 "-snes_linesearch_type l2 \n"
171 "-snes_linesearch_monitor \n"
172 "-snes_max_it 16 \n"
173 "-snes_atol 1e-8 \n"
174 "-snes_rtol 1e-8 \n"
175 "-snes_converged_reason \n";
176
177 string param_file = "param_file.petsc";
178 if (!static_cast<bool>(ifstream(param_file))) {
179 std::ofstream file(param_file.c_str(), std::ios::ate);
180 if (file.is_open()) {
181 file << default_options;
182 file.close();
183 }
184 }
185 MoFEM::Core::Initialize(&argc, &argv, param_file.c_str(), help);
186
187 try {
188
189 moab::Core mb_instance;
190 moab::Interface &moab = mb_instance;
191 int rank;
192 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
193
194 // Reade parameters from line command
195 PetscBool flg = PETSC_TRUE;
196 char mesh_file_name[255];
197 CHKERR PetscOptionsGetString(PETSC_NULLPTR, PETSC_NULLPTR, "-my_file",
198 mesh_file_name, 255, &flg);
199 if (flg != PETSC_TRUE) {
200 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
201 "*** ERROR -my_file (MESH FILE NEEDED)");
202 }
203
204 PetscScalar step_size_reduction;
205 CHKERR PetscOptionsGetReal(PETSC_NULLPTR, PETSC_NULLPTR, "-my_sr",
206 &step_size_reduction, &flg);
207 if (flg != PETSC_TRUE) {
208 step_size_reduction = 1.;
209 }
210
211 PetscInt max_steps;
212 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, PETSC_NULLPTR, "-my_ms", &max_steps,
213 &flg);
214 if (flg != PETSC_TRUE) {
215 max_steps = 5;
216 }
217
218 int its_d;
219 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-my_its_d", &its_d, &flg);
220 if (flg != PETSC_TRUE) {
221 its_d = 6;
222 }
223
224 PetscInt order;
225 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, PETSC_NULLPTR, "-my_order", &order,
226 &flg);
227 if (flg != PETSC_TRUE) {
228 order = 2;
229 }
230
231 // Check if new start or restart. If new start, delete previous
232 // load_disp.txt
233 if (std::string(mesh_file_name).find("restart") == std::string::npos) {
234 remove(DATAFILENAME);
235 }
236
237 // Read mesh to MOAB
238 const char *option;
239 option = "";
240 CHKERR moab.load_file(mesh_file_name, 0, option);
241
242 // Data stored on mesh for restart
243 Tag th_step_size, th_step;
244 double def_step_size = 1;
245 rval = moab.tag_get_handle("_STEPSIZE", 1, MB_TYPE_DOUBLE, th_step_size,
246 MB_TAG_CREAT | MB_TAG_MESH, &def_step_size);
247 if (rval == MB_ALREADY_ALLOCATED)
248 rval = MB_SUCCESS;
249 CHKERRG(rval);
250 int def_step = 1;
251 rval = moab.tag_get_handle("_STEP", 1, MB_TYPE_INTEGER, th_step,
252 MB_TAG_CREAT | MB_TAG_MESH, &def_step);
253 if (rval == MB_ALREADY_ALLOCATED)
254 rval = MB_SUCCESS;
255 CHKERRG(rval);
256 const void *tag_data_step_size[1];
257 EntityHandle root = 0;
258 CHKERR moab.tag_get_by_ptr(th_step_size, &root, 1, tag_data_step_size);
259 double &step_size = *(double *)tag_data_step_size[0];
260 const void *tag_data_step[1];
261 CHKERR moab.tag_get_by_ptr(th_step, &root, 1, tag_data_step);
262 int &step = *(int *)tag_data_step[0];
263 // end of data stored for restart
264 CHKERR PetscPrintf(PETSC_COMM_WORLD,
265 "Start step %D and step_size = %6.4e\n", step,
266 step_size);
267
268 // Create MoFEM 2database
269 MoFEM::Core core(moab);
270 MoFEM::Interface &m_field = core;
271
272 PrismInterface *interface_ptr;
273 CHKERR m_field.getInterface(interface_ptr);
274
275 Tag th_my_ref_level;
276 BitRefLevel def_bit_level = 0;
277 CHKERR m_field.get_moab().tag_get_handle(
278 "_MY_REFINEMENT_LEVEL", sizeof(BitRefLevel), MB_TYPE_OPAQUE,
279 th_my_ref_level, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES,
280 &def_bit_level);
281 const EntityHandle root_meshset = m_field.get_moab().get_root_set();
282 BitRefLevel *ptr_bit_level0;
283 CHKERR m_field.get_moab().tag_get_by_ptr(th_my_ref_level, &root_meshset, 1,
284 (const void **)&ptr_bit_level0);
285 BitRefLevel &bit_level0 = *ptr_bit_level0;
286 BitRefLevel problem_bit_level = bit_level0;
287
288 if (step == 1) {
289
290 // ref meshset ref level 0
291 CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
292 0, 3, BitRefLevel().set(0));
293
294 std::vector<BitRefLevel> bit_levels;
295 bit_levels.push_back(BitRefLevel().set(0));
296
297 int ll = 1;
298
300 m_field, SIDESET | INTERFACESET, cit)) {
301 CHKERR PetscPrintf(PETSC_COMM_WORLD, "Insert Interface %d\n",
302 cit->getMeshsetId());
303 EntityHandle cubit_meshset = cit->getMeshset();
304 {
305 // get tet entities form back bit_level
306 EntityHandle ref_level_meshset = 0;
307 CHKERR moab.create_meshset(MESHSET_SET, ref_level_meshset);
309 ->getEntitiesByTypeAndRefLevel(bit_levels.back(),
310 BitRefLevel().set(), MBTET,
311 ref_level_meshset);
313 ->getEntitiesByTypeAndRefLevel(bit_levels.back(),
314 BitRefLevel().set(), MBPRISM,
315 ref_level_meshset);
316 Range ref_level_tets;
317 CHKERR moab.get_entities_by_handle(ref_level_meshset, ref_level_tets,
318 true);
319 // get faces and test to split
320 CHKERR interface_ptr->getSides(cubit_meshset, bit_levels.back(), true,
321 0);
322 // set new bit level
323 bit_levels.push_back(BitRefLevel().set(ll++));
324 // split faces and
325 CHKERR interface_ptr->splitSides(ref_level_meshset, bit_levels.back(),
326 cubit_meshset, true, true, 0);
327 // clean meshsets
328 CHKERR moab.delete_entities(&ref_level_meshset, 1);
329 }
330 // Update cubit meshsets
331 for (_IT_CUBITMESHSETS_FOR_LOOP_(m_field, ciit)) {
332 EntityHandle cubit_meshset = ciit->meshset;
334 ->updateMeshsetByEntitiesChildren(cubit_meshset,
335 bit_levels.back(),
336 cubit_meshset, MBMAXTYPE, true);
337 }
338 }
339
340 bit_level0 = bit_levels.back();
341 problem_bit_level = bit_level0;
342
343 /***/
344 // Define problem
345
346 // Fields
347 CHKERR m_field.add_field("DISPLACEMENT", H1, AINSWORTH_LEGENDRE_BASE, 3);
348 CHKERR m_field.add_field("MESH_NODE_POSITIONS", H1,
350
351 CHKERR m_field.add_field("LAMBDA", NOFIELD, NOBASE, 1);
352
353 // Field for ArcLength
354 CHKERR
355 m_field.add_field("X0_DISPLACEMENT", H1, AINSWORTH_LEGENDRE_BASE, 3);
356
357 // FE
358 CHKERR m_field.add_finite_element("ELASTIC");
359
360 // Define rows/cols and element data
362 "DISPLACEMENT");
364 "DISPLACEMENT");
366 "DISPLACEMENT");
368 "ELASTIC", "MESH_NODE_POSITIONS");
369 CHKERR m_field.modify_finite_element_add_field_row("ELASTIC", "LAMBDA");
370 CHKERR m_field.modify_finite_element_add_field_col("ELASTIC", "LAMBDA");
371 // this is for paremtis
372 CHKERR m_field.modify_finite_element_add_field_data("ELASTIC", "LAMBDA");
373
374 // FE Interface
375 CHKERR m_field.add_finite_element("INTERFACE");
377 "DISPLACEMENT");
379 "DISPLACEMENT");
381 "DISPLACEMENT");
383 "INTERFACE", "MESH_NODE_POSITIONS");
384
385 // FE ArcLength
386 CHKERR m_field.add_finite_element("ARC_LENGTH");
387
388 // Define rows/cols and element data
389 CHKERR m_field.modify_finite_element_add_field_row("ARC_LENGTH",
390 "LAMBDA");
391 CHKERR m_field.modify_finite_element_add_field_col("ARC_LENGTH",
392 "LAMBDA");
393
394 // elem data
395 CHKERR
396 m_field.modify_finite_element_add_field_data("ARC_LENGTH", "LAMBDA");
397
398 // define problems
399 CHKERR m_field.add_problem("ELASTIC_MECHANICS");
400
401 // set finite elements for problem
402 CHKERR m_field.modify_problem_add_finite_element("ELASTIC_MECHANICS",
403 "ELASTIC");
404 CHKERR m_field.modify_problem_add_finite_element("ELASTIC_MECHANICS",
405 "INTERFACE");
406 CHKERR m_field.modify_problem_add_finite_element("ELASTIC_MECHANICS",
407 "ARC_LENGTH");
408 // set refinement level for problem
409 CHKERR m_field.modify_problem_ref_level_add_bit("ELASTIC_MECHANICS",
410 problem_bit_level);
411
412 /***/
413 // Declare problem
414
415 // add entities (by tets) to the field
416 CHKERR m_field.add_ents_to_field_by_type(0, MBTET, "DISPLACEMENT");
417 CHKERR m_field.add_ents_to_field_by_type(0, MBTET, "X0_DISPLACEMENT");
418 CHKERR m_field.add_ents_to_field_by_type(0, MBTET, "MESH_NODE_POSITIONS");
419
420 // add finite elements entities
422 problem_bit_level, BitRefLevel().set(), "ELASTIC", MBTET);
424 problem_bit_level, BitRefLevel().set(), "INTERFACE", MBPRISM);
425
426 // Setting up LAMBDA field and ARC_LENGTH interface
427 {
428 // Add dummy no-field vertex
429 EntityHandle no_field_vertex;
430 {
431 const double coords[] = {0, 0, 0};
432 CHKERR m_field.get_moab().create_vertex(coords, no_field_vertex);
433 Range range_no_field_vertex;
434 range_no_field_vertex.insert(no_field_vertex);
435 CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevel(
436 range_no_field_vertex, BitRefLevel().set());
437
438 EntityHandle lambda_meshset = m_field.get_field_meshset("LAMBDA");
439 CHKERR m_field.get_moab().add_entities(lambda_meshset,
440 range_no_field_vertex);
441 }
442 // this entity will carray data for this finite element
443 EntityHandle meshset_fe_arc_length;
444 {
445 CHKERR moab.create_meshset(MESHSET_SET, meshset_fe_arc_length);
446 CHKERR moab.add_entities(meshset_fe_arc_length, &no_field_vertex, 1);
447 CHKERR m_field.getInterface<BitRefManager>()->setBitLevelToMeshset(
448 meshset_fe_arc_length, BitRefLevel().set());
449 }
450 // finally add created meshset to the ARC_LENGTH finite element
452 meshset_fe_arc_length, "ARC_LENGTH", false);
453 }
454
455 // set app. order
456 // see Hierarchic Finite Element Bases on Unstructured Tetrahedral Meshes
457 // (Mark Ainsworth & Joe Coyle)
458 CHKERR m_field.set_field_order(0, MBTET, "DISPLACEMENT", order);
459 CHKERR m_field.set_field_order(0, MBTRI, "DISPLACEMENT", order);
460 CHKERR m_field.set_field_order(0, MBEDGE, "DISPLACEMENT", order);
461 CHKERR m_field.set_field_order(0, MBVERTEX, "DISPLACEMENT", 1);
462
463 CHKERR m_field.set_field_order(0, MBTET, "X0_DISPLACEMENT", order);
464 CHKERR m_field.set_field_order(0, MBTRI, "X0_DISPLACEMENT", order);
465 CHKERR m_field.set_field_order(0, MBEDGE, "X0_DISPLACEMENT", order);
466 CHKERR m_field.set_field_order(0, MBVERTEX, "X0_DISPLACEMENT", 1);
467
468 CHKERR m_field.set_field_order(0, MBTET, "MESH_NODE_POSITIONS", 2);
469 CHKERR m_field.set_field_order(0, MBTRI, "MESH_NODE_POSITIONS", 2);
470 CHKERR m_field.set_field_order(0, MBEDGE, "MESH_NODE_POSITIONS", 2);
471 CHKERR m_field.set_field_order(0, MBVERTEX, "MESH_NODE_POSITIONS", 1);
472
473 // Elements with boundary conditions
474 CHKERR MetaNeumannForces::addNeumannBCElements(m_field, "DISPLACEMENT");
475 CHKERR MetaNodalForces::addElement(m_field, "DISPLACEMENT");
476
477 CHKERR m_field.modify_problem_add_finite_element("ELASTIC_MECHANICS",
478 "FORCE_FE");
479 CHKERR m_field.modify_problem_add_finite_element("ELASTIC_MECHANICS",
480 "PRESSURE_FE");
481 CHKERR m_field.modify_finite_element_add_field_row("FORCE_FE", "LAMBDA");
482 CHKERR m_field.modify_finite_element_add_field_col("FORCE_FE", "LAMBDA");
483 CHKERR m_field.modify_finite_element_add_field_data("FORCE_FE", "LAMBDA");
484
485 CHKERR m_field.modify_finite_element_add_field_row("PRESSURE_FE",
486 "LAMBDA");
487 CHKERR m_field.modify_finite_element_add_field_col("PRESSURE_FE",
488 "LAMBDA");
489 CHKERR m_field.modify_finite_element_add_field_data("PRESSURE_FE",
490 "LAMBDA");
491 CHKERR m_field.add_finite_element("BODY_FORCE");
492 CHKERR m_field.modify_finite_element_add_field_row("BODY_FORCE",
493 "DISPLACEMENT");
494 CHKERR m_field.modify_finite_element_add_field_col("BODY_FORCE",
495 "DISPLACEMENT");
496 CHKERR m_field.modify_finite_element_add_field_data("BODY_FORCE",
497 "DISPLACEMENT");
498 CHKERR m_field.modify_problem_add_finite_element("ELASTIC_MECHANICS",
499 "BODY_FORCE");
500
502 m_field, BLOCKSET | BODYFORCESSET, it)) {
503 Range tets;
504 CHKERR m_field.get_moab().get_entities_by_type(it->meshset, MBTET, tets,
505 true);
506 CHKERR m_field.add_ents_to_finite_element_by_type(tets, MBTET,
507 "BODY_FORCE");
508 }
509 }
510
511 /****/
512 // build database
513
514 // build field
515 CHKERR m_field.build_fields();
516 Projection10NodeCoordsOnField ent_method_material(m_field,
517 "MESH_NODE_POSITIONS");
518 CHKERR m_field.loop_dofs("MESH_NODE_POSITIONS", ent_method_material);
519
520 // build finite elemnts
522
523 // build adjacencies
524 CHKERR m_field.build_adjacencies(problem_bit_level);
525
526 /****/
527 ProblemsManager *prb_mng_ptr;
528 CHKERR m_field.getInterface(prb_mng_ptr);
529 // build problem
530 CHKERR prb_mng_ptr->buildProblem("ELASTIC_MECHANICS", true);
531 // partition
532 CHKERR prb_mng_ptr->partitionProblem("ELASTIC_MECHANICS");
533 CHKERR prb_mng_ptr->partitionFiniteElements("ELASTIC_MECHANICS", false, 0,
534 m_field.get_comm_size());
535 // what are ghost nodes, see Petsc Manual
536 CHKERR prb_mng_ptr->partitionGhostDofs("ELASTIC_MECHANICS");
537
538 // print bcs
539 MeshsetsManager *mmanager_ptr;
540 CHKERR m_field.getInterface(mmanager_ptr);
541 CHKERR mmanager_ptr->printDisplacementSet();
542 CHKERR mmanager_ptr->printForceSet();
543 // print block sets with materials
544 CHKERR mmanager_ptr->printMaterialsSet();
545
546 // create matrices
547 Vec F, F_body_force, D;
548 CHKERR m_field.getInterface<VecManager>()->vecCreateGhost(
549 "ELASTIC_MECHANICS", COL, &F);
550 CHKERR VecDuplicate(F, &D);
551 CHKERR VecDuplicate(F, &F_body_force);
552 Mat Aij;
554 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>("ELASTIC_MECHANICS",
555 &Aij);
556
557 // Assemble F and Aij
558 double young_modulus = 1;
559 double poisson_ratio = 0.0;
560
561 boost::ptr_vector<CohesiveInterfaceElement::PhysicalEquation>
562 interface_materials;
563
564 // FIXME this in fact allow only for one type of interface,
565 // problem is Young Modulus in interface mayoung_modulusterial
567 cout << std::endl << *it << std::endl;
568
569 // Get block name
570 string name = it->getName();
571
572 if (name.compare(0, 11, "MAT_ELASTIC") == 0) {
573 Mat_Elastic mydata;
574 CHKERR it->getAttributeDataStructure(mydata);
575 cout << mydata;
576 young_modulus = mydata.data.Young;
577 poisson_ratio = mydata.data.Poisson;
578 } else if (name.compare(0, 10, "MAT_INTERF") == 0) {
579 Mat_Interf mydata;
580 CHKERR it->getAttributeDataStructure(mydata);
581 cout << mydata;
582
583 interface_materials.push_back(
585 interface_materials.back().h = 1;
586 interface_materials.back().youngModulus = mydata.data.alpha;
587 interface_materials.back().beta = mydata.data.beta;
588 interface_materials.back().ft = mydata.data.ft;
589 interface_materials.back().Gf = mydata.data.Gf;
590
591 EntityHandle meshset = it->getMeshset();
592 Range tris;
593 rval = moab.get_entities_by_type(meshset, MBTRI, tris, true);
594 CHKERRG(rval);
595 Range ents3d;
596 rval = moab.get_adjacencies(tris, 3, false, ents3d,
597 moab::Interface::UNION);
598 CHKERRG(rval);
599 interface_materials.back().pRisms = ents3d.subset_by_type(MBPRISM);
600 }
601 }
602
603 { // FIXME
604 boost::ptr_vector<CohesiveInterfaceElement::PhysicalEquation>::iterator
605 pit = interface_materials.begin();
606 for (; pit != interface_materials.end(); pit++) {
607 pit->youngModulus = young_modulus;
608 }
609 }
610
611 boost::shared_ptr<ArcLengthCtx> arc_ctx = boost::shared_ptr<ArcLengthCtx>(
612 new ArcLengthCtx(m_field, "ELASTIC_MECHANICS"));
613 boost::scoped_ptr<ArcLengthElement> my_arc_method_ptr(
614 new ArcLengthElement(m_field, arc_ctx));
615 ArcLengthSnesCtx snes_ctx(m_field, "ELASTIC_MECHANICS", arc_ctx);
616 AssembleRhsVectors pre_post_proc_fe(m_field, F_body_force, arc_ctx);
617
618 DirichletDisplacementBc my_dirichlet_bc(m_field, "DISPLACEMENT", Aij, D, F);
619 CHKERR m_field.get_problem("ELASTIC_MECHANICS",
620 &my_dirichlet_bc.problemPtr);
621 CHKERR my_dirichlet_bc.iNitialize();
622 boost::shared_ptr<Hooke<adouble>> hooke_adouble_ptr(new Hooke<adouble>);
623 boost::shared_ptr<Hooke<double>> hooke_double_ptr(new Hooke<double>);
624 NonlinearElasticElement elastic(m_field, 2);
625 {
626 int id = 0;
627 elastic.setOfBlocks[id].iD = id;
628 elastic.setOfBlocks[id].E = young_modulus;
629 elastic.setOfBlocks[id].PoissonRatio = poisson_ratio;
630 elastic.setOfBlocks[id].materialDoublePtr = hooke_double_ptr;
631 elastic.setOfBlocks[id].materialAdoublePtr = hooke_adouble_ptr;
632 CHKERR m_field.get_moab().get_entities_by_type(
633 m_field.get_finite_element_meshset("ELASTIC"), MBTET,
634 elastic.setOfBlocks[id].tEts, true);
635 CHKERR addHOOpsVol("MESH_NODE_POSITIONS", elastic.getLoopFeRhs(), true,
636 false, false, false);
637 CHKERR addHOOpsVol("MESH_NODE_POSITIONS", elastic.getLoopFeRhs(), true,
638 false, false, false);
639 CHKERR addHOOpsVol("MESH_NODE_POSITIONS", elastic.getLoopFeEnergy(), true,
640 false, false, false);
641 CHKERR elastic.setOperators("DISPLACEMENT", "MESH_NODE_POSITIONS", false,
642 true);
643 }
644 CohesiveInterfaceElement cohesive_elements(m_field);
645 CHKERR cohesive_elements.addOps("DISPLACEMENT", interface_materials);
646
647 PetscInt M, N;
648 CHKERR MatGetSize(Aij, &M, &N);
649 PetscInt m, n;
650 MatGetLocalSize(Aij, &m, &n);
651 boost::scoped_ptr<ArcLengthMatShell> mat_ctx(
652 new ArcLengthMatShell(Aij, arc_ctx, "ELASTIC_MECHANICS"));
653 Mat ShellAij;
654 CHKERR MatCreateShell(PETSC_COMM_WORLD, m, n, M, N, (void *)mat_ctx.get(),
655 &ShellAij);
656 CHKERR MatShellSetOperation(ShellAij, MATOP_MULT,
657 (void (*)(void))ArcLengthMatMultShellOp);
658
659 // body forces
660 BodyForceConstantField body_forces_methods(m_field);
662 m_field, BLOCKSET | BODYFORCESSET, it)) {
663 CHKERR body_forces_methods.addBlock("DISPLACEMENT", F_body_force,
664 it->getMeshsetId());
665 }
666 CHKERR VecZeroEntries(F_body_force);
667 CHKERR VecGhostUpdateBegin(F_body_force, INSERT_VALUES, SCATTER_FORWARD);
668 CHKERR VecGhostUpdateEnd(F_body_force, INSERT_VALUES, SCATTER_FORWARD);
669 CHKERR m_field.loop_finite_elements("ELASTIC_MECHANICS", "BODY_FORCE",
670 body_forces_methods.getLoopFe());
671 CHKERR VecGhostUpdateBegin(F_body_force, ADD_VALUES, SCATTER_REVERSE);
672 CHKERR VecGhostUpdateEnd(F_body_force, ADD_VALUES, SCATTER_REVERSE);
673 CHKERR VecAssemblyBegin(F_body_force);
674 CHKERR VecAssemblyEnd(F_body_force);
675
676 // surface forces
677 boost::ptr_map<std::string, NeumannForcesSurface> neumann_forces;
678 string fe_name_str = "FORCE_FE";
679 neumann_forces.insert(fe_name_str, new NeumannForcesSurface(m_field));
680 CHKERR addHOOpsFace3D("MESH_NODE_POSITIONS",
681 neumann_forces.at(fe_name_str).getLoopFe(), false,
682 false);
684 it)) {
685 CHKERR neumann_forces.at(fe_name_str)
686 .addForce("DISPLACEMENT", arc_ctx->F_lambda, it->getMeshsetId());
687 }
688 fe_name_str = "PRESSURE_FE";
689 neumann_forces.insert(fe_name_str, new NeumannForcesSurface(m_field));
690 CHKERR addHOOpsFace3D("MESH_NODE_POSITIONS",
691 neumann_forces.at(fe_name_str).getLoopFe(), false,
692 false);
694 m_field, SIDESET | PRESSURESET, it)) {
695 CHKERR neumann_forces.at(fe_name_str)
696 .addPressure("DISPLACEMENT", arc_ctx->F_lambda, it->getMeshsetId());
697 }
698 // add nodal forces
699 boost::ptr_map<std::string, NodalForce> nodal_forces;
700 fe_name_str = "FORCE_FE";
701 nodal_forces.insert(fe_name_str, new NodalForce(m_field));
703 it)) {
704 CHKERR nodal_forces.at(fe_name_str)
705 .addForce("DISPLACEMENT", arc_ctx->F_lambda, it->getMeshsetId());
706 }
707
708 SNES snes;
709 CHKERR SNESCreate(PETSC_COMM_WORLD, &snes);
710 CHKERR SNESSetApplicationContext(snes, &snes_ctx);
711 CHKERR SNESSetFunction(snes, F, SnesRhs, &snes_ctx);
712 CHKERR SNESSetJacobian(snes, ShellAij, Aij, SnesMat, &snes_ctx);
713 CHKERR SNESSetFromOptions(snes);
714
715 KSP ksp;
716 CHKERR SNESGetKSP(snes, &ksp);
717 PC pc;
718 CHKERR KSPGetPC(ksp, &pc);
719 boost::scoped_ptr<PCArcLengthCtx> pc_ctx(
720 new PCArcLengthCtx(ShellAij, Aij, arc_ctx));
721 CHKERR PCSetType(pc, PCSHELL);
722 CHKERR PCShellSetContext(pc, pc_ctx.get());
723 CHKERR PCShellSetApply(pc, PCApplyArcLength);
724 CHKERR PCShellSetSetUp(pc, PCSetupArcLength);
725
726 // Rhs
727 SnesCtx::FEMethodsSequence &loops_to_do_Rhs =
728 snes_ctx.getComputeRhs();
729 snes_ctx.getPreProcComputeRhs().push_back(&my_dirichlet_bc);
730 snes_ctx.getPreProcComputeRhs().push_back(&pre_post_proc_fe);
731 loops_to_do_Rhs.push_back(SnesCtx::PairNameFEMethodPtr(
732 "INTERFACE", &cohesive_elements.getFeRhs()));
733 loops_to_do_Rhs.push_back(
734 SnesCtx::PairNameFEMethodPtr("ELASTIC", &elastic.getLoopFeRhs()));
735 loops_to_do_Rhs.push_back(
736 SnesCtx::PairNameFEMethodPtr("ARC_LENGTH", my_arc_method_ptr.get()));
737 snes_ctx.getPostProcComputeRhs().push_back(&pre_post_proc_fe);
738 snes_ctx.getPostProcComputeRhs().push_back(&my_dirichlet_bc);
739
740 // Mat
741 SnesCtx::FEMethodsSequence &loops_to_do_Mat =
742 snes_ctx.getSetOperators();
743 snes_ctx.getPreProcSetOperators().push_back(&my_dirichlet_bc);
744 loops_to_do_Mat.push_back(SnesCtx::PairNameFEMethodPtr(
745 "INTERFACE", &cohesive_elements.getFeLhs()));
746 loops_to_do_Mat.push_back(
747 SnesCtx::PairNameFEMethodPtr("ELASTIC", &elastic.getLoopFeLhs()));
748 loops_to_do_Mat.push_back(
749 SnesCtx::PairNameFEMethodPtr("ARC_LENGTH", my_arc_method_ptr.get()));
750 snes_ctx.getPostProcSetOperators().push_back(&my_dirichlet_bc);
751
752 double gamma = 0.5, reduction = 1;
753 // step = 1;
754 if (step == 1) {
755 step_size = step_size_reduction;
756 } else {
757 reduction = step_size_reduction;
758 step++;
759 }
760
761 boost::ptr_map<std::string, NeumannForcesSurface>::iterator mit =
762 neumann_forces.begin();
763 CHKERR VecZeroEntries(arc_ctx->F_lambda);
764 CHKERR VecGhostUpdateBegin(arc_ctx->F_lambda, INSERT_VALUES,
765 SCATTER_FORWARD);
766 CHKERR VecGhostUpdateEnd(arc_ctx->F_lambda, INSERT_VALUES, SCATTER_FORWARD);
767 for (; mit != neumann_forces.end(); mit++) {
768 CHKERR m_field.loop_finite_elements("ELASTIC_MECHANICS", mit->first,
769 mit->second->getLoopFe());
770 }
771 CHKERR VecGhostUpdateBegin(arc_ctx->F_lambda, ADD_VALUES, SCATTER_REVERSE);
772 CHKERR VecGhostUpdateEnd(arc_ctx->F_lambda, ADD_VALUES, SCATTER_REVERSE);
773 CHKERR VecAssemblyBegin(arc_ctx->F_lambda);
774 CHKERR VecAssemblyEnd(arc_ctx->F_lambda);
775 for (std::vector<int>::iterator vit = my_dirichlet_bc.dofsIndices.begin();
776 vit != my_dirichlet_bc.dofsIndices.end(); vit++) {
777 CHKERR VecSetValue(arc_ctx->F_lambda, *vit, 0, INSERT_VALUES);
778 }
779 CHKERR VecAssemblyBegin(arc_ctx->F_lambda);
780 CHKERR VecAssemblyEnd(arc_ctx->F_lambda);
781 // F_lambda2
782 CHKERR VecDot(arc_ctx->F_lambda, arc_ctx->F_lambda, &arc_ctx->F_lambda2);
783 PetscPrintf(PETSC_COMM_WORLD, "\tFlambda2 = %6.4e\n", arc_ctx->F_lambda2);
784
785 if (step > 1) {
786 CHKERR m_field.getInterface<VecManager>()->setLocalGhostVector(
787 "ELASTIC_MECHANICS", COL, D, INSERT_VALUES, SCATTER_FORWARD);
788 CHKERR m_field.getInterface<VecManager>()->setOtherGlobalGhostVector(
789 "ELASTIC_MECHANICS", "DISPLACEMENT", "X0_DISPLACEMENT", COL,
790 arc_ctx->x0, INSERT_VALUES, SCATTER_FORWARD);
791 double x0_nrm;
792 CHKERR VecNorm(arc_ctx->x0, NORM_2, &x0_nrm);
793 CHKERR PetscPrintf(PETSC_COMM_WORLD,
794 "\tRead x0_nrm = %6.4e dlambda = %6.4e\n", x0_nrm,
795 arc_ctx->dLambda);
796 CHKERR arc_ctx->setAlphaBeta(1, 0);
797 } else {
798 CHKERR arc_ctx->setS(0);
799 CHKERR arc_ctx->setAlphaBeta(0, 1);
800 }
801 CHKERR SnesRhs(snes, D, F, &snes_ctx);
802
803 PostProcVolumeOnRefinedMesh post_proc(m_field);
805 CHKERR post_proc.addFieldValuesPostProc("DISPLACEMENT");
806 CHKERR post_proc.addFieldValuesGradientPostProc("DISPLACEMENT");
807 // add postpocessing for sresses
808 post_proc.getOpPtrVector().push_back(new PostProcHookStress(
809 m_field, post_proc.postProcMesh, post_proc.mapGaussPts, "DISPLACEMENT",
810 post_proc.commonData));
811
812 bool converged_state = false;
813 for (; step < max_steps; step++) {
814
815 if (step == 1) {
816 CHKERR PetscPrintf(PETSC_COMM_WORLD, "Load Step %D step_size = %6.4e\n",
817 step, step_size);
818 CHKERR arc_ctx->setS(step_size);
819 CHKERR arc_ctx->setAlphaBeta(0, 1);
820 CHKERR VecCopy(D, arc_ctx->x0);
821 double dlambda;
822 CHKERR my_arc_method_ptr->calculate_init_dlambda(&dlambda);
823 CHKERR my_arc_method_ptr->set_dlambda_to_x(D, dlambda);
824 } else if (step == 2) {
825 CHKERR arc_ctx->setAlphaBeta(1, 0);
826 CHKERR my_arc_method_ptr->calculate_dx_and_dlambda(D);
827 CHKERR my_arc_method_ptr->calculate_lambda_int(step_size);
828 CHKERR arc_ctx->setS(step_size);
829 double dlambda = arc_ctx->dLambda;
830 double dx_nrm;
831 CHKERR VecNorm(arc_ctx->dx, NORM_2, &dx_nrm);
832 CHKERR PetscPrintf(PETSC_COMM_WORLD,
833 "Load Step %D step_size = %6.4e dlambda0 = %6.4e "
834 "dx_nrm = %6.4e dx2 = %6.4e\n",
835 step, step_size, dlambda, dx_nrm, arc_ctx->dx2);
836 CHKERR VecCopy(D, arc_ctx->x0);
837 CHKERR VecAXPY(D, 1., arc_ctx->dx);
838 CHKERR my_arc_method_ptr->set_dlambda_to_x(D, dlambda);
839 } else {
840 CHKERR my_arc_method_ptr->calculate_dx_and_dlambda(D);
841 CHKERR my_arc_method_ptr->calculate_lambda_int(step_size);
842 // step_size0_1/step_size0 = step_stize1/step_size
843 // step_size0_1 = step_size0*(step_stize1/step_size)
844 step_size *= reduction;
845 CHKERR arc_ctx->setS(step_size);
846 double dlambda = reduction * arc_ctx->dLambda;
847 CHKERR VecScale(arc_ctx->dx, reduction);
848 double dx_nrm;
849 CHKERR VecNorm(arc_ctx->dx, NORM_2, &dx_nrm);
850 CHKERR PetscPrintf(PETSC_COMM_WORLD,
851 "Load Step %D step_size = %6.4e dlambda0 = %6.4e "
852 "dx_nrm = %6.4e dx2 = %6.4e\n",
853 step, step_size, dlambda, dx_nrm, arc_ctx->dx2);
854 CHKERR VecCopy(D, arc_ctx->x0);
855 CHKERR VecAXPY(D, 1., arc_ctx->dx);
856 CHKERR my_arc_method_ptr->set_dlambda_to_x(D, dlambda);
857 }
858
859 CHKERR SNESSolve(snes, PETSC_NULLPTR, D);
860
861 // Distribute displacements on all processors
862 CHKERR m_field.getInterface<VecManager>()->setGlobalGhostVector(
863 "ELASTIC_MECHANICS", COL, D, INSERT_VALUES, SCATTER_REVERSE);
864 CHKERR m_field.loop_finite_elements("ELASTIC_MECHANICS", "INTERFACE",
865 cohesive_elements.getFeHistory(), 0,
866 m_field.get_comm_size());
867 // Remove nodes of damaged prisms
868 CHKERR my_arc_method_ptr->remove_damaged_prisms_nodes();
869
870 int its;
871 CHKERR SNESGetIterationNumber(snes, &its);
872 CHKERR PetscPrintf(PETSC_COMM_WORLD, "number of Newton iterations = %D\n",
873 its);
874
875 SNESConvergedReason reason;
876 CHKERR SNESGetConvergedReason(snes, &reason);
877
878 if (reason < 0) {
879 CHKERR arc_ctx->setAlphaBeta(1, 0);
880 reduction = 0.1;
881 converged_state = false;
882 continue;
883 } else {
884 if (step > 1 && converged_state) {
885 reduction = pow((double)its_d / (double)(its + 1), gamma);
886 CHKERR PetscPrintf(PETSC_COMM_WORLD, "reduction step_size = %6.4e\n",
887 reduction);
888 }
889
890 // Save data on mesh
891 CHKERR m_field.getInterface<VecManager>()->setGlobalGhostVector(
892 "ELASTIC_MECHANICS", COL, D, INSERT_VALUES, SCATTER_REVERSE);
893 CHKERR m_field.getInterface<VecManager>()->setOtherGlobalGhostVector(
894 "ELASTIC_MECHANICS", "DISPLACEMENT", "X0_DISPLACEMENT", COL,
895 arc_ctx->x0, INSERT_VALUES, SCATTER_REVERSE);
896 converged_state = true;
897 }
898 //
899 if (reason > 0) {
900 FILE *datafile;
901 PetscFOpen(PETSC_COMM_SELF, DATAFILENAME, "a+", &datafile);
902 PetscFPrintf(PETSC_COMM_WORLD, datafile, "%d %d ", reason, its);
903 fclose(datafile);
904 CHKERR my_arc_method_ptr->postProcessLoadPath();
905 }
906
907 if (step % 1 == 0) {
908
909 CHKERR m_field.loop_finite_elements("ELASTIC_MECHANICS", "ELASTIC",
910 post_proc);
911 std::ostringstream ss;
912 ss << "out_values_" << step << ".h5m";
913 CHKERR post_proc.writeFile(ss.str().c_str());
914 }
915 }
916
917 // Save data on mesh
918 CHKERR m_field.getInterface<VecManager>()->setGlobalGhostVector(
919 "ELASTIC_MECHANICS", COL, D, INSERT_VALUES, SCATTER_REVERSE);
920
921 // detroy matrices
922 CHKERR VecDestroy(&F);
923 CHKERR VecDestroy(&D);
924 CHKERR VecDestroy(&F_body_force);
925 CHKERR MatDestroy(&Aij);
926 CHKERR SNESDestroy(&snes);
927 CHKERR MatDestroy(&ShellAij);
928 }
930
932
933 return 0;
934}
MoFEMErrorCode PCApplyArcLength(PC pc, Vec pc_f, Vec pc_x)
MoFEMErrorCode ArcLengthMatMultShellOp(Mat A, Vec x, Vec f)
MoFEMErrorCode PCSetupArcLength(PC pc)
Implementation of linear interface element.
Implementation of linear elastic material.
Implementation of arc-lebgth control for cohesive elements.
int main()
static char help[]
#define DATAFILENAME
@ COL
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base nme:nme847.
Definition definitions.h:60
@ NOBASE
Definition definitions.h:59
#define MOAB_THROW(err)
Check error code of MoAB function and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ NOFIELD
scalar or vector of scalars describe (no true field)
Definition definitions.h:84
@ H1
continuous field
Definition definitions.h:85
#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.
@ PRESSURESET
@ BODYFORCESSET
block name is "BODY_FORCES"
@ FORCESET
@ NODESET
@ SIDESET
@ BLOCKSET
@ INTERFACESET
@ MOFEM_INVALID_DATA
Definition definitions.h:36
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr int order
@ F
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual EntityHandle get_finite_element_meshset(const std::string name) const =0
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_MESHSET(const EntityHandle meshset, const std::string &name, const bool recursive=false)=0
add MESHSET element to finite element database given by name
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_bit_ref(const BitRefLevel bit, const BitRefLevel mask, const std::string name, EntityType type, int verb=DEFAULT_VERBOSITY)=0
add TET entities from given refinement level to finite element database given by name
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_field)=0
set finite element field data
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
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 MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
MoFEMErrorCode addFieldValuesPostProc(const std::string field_name, Vec v=PETSC_NULLPTR)
Add operator to post-process L2, H1, Hdiv, Hcurl field value.
MoFEMErrorCode addFieldValuesGradientPostProc(const std::string field_name, Vec v=PETSC_NULLPTR)
Add operator to post-process L2 or H1 field gradient.
MoFEMErrorCode writeFile(const std::string file_name, const char *file_type="MOAB", const char *file_options="PARALLEL=WRITE_PART")
wrote results in (MOAB) format, use "file_name.h5m"
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
#define _IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_(MESHSET_MANAGER, NAME, IT)
Iterator that loops over Cubit BlockSet having a particular name.
#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_FOR_LOOP_(MESHSET_MANAGER, IT)
Iterator that loops over all the Cubit MeshSets 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.
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
MoFEMErrorCode partitionProblem(const std::string name, int verb=VERBOSE)
partition problem dofs (collective)
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elements
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
virtual MoFEMErrorCode modify_problem_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
add ref level to problem
virtual MoFEMErrorCode modify_problem_add_finite_element(const std::string name_problem, const std::string &fe_name)=0
add finite element to problem, this add entities assigned to finite element to a particular problem
double D
const double n
refractive index of diffusive medium
char mesh_file_name[255]
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
PetscErrorCode SnesMat(SNES snes, Vec x, Mat A, Mat B, void *ctx)
This is MoFEM implementation for the left hand side (tangent matrix) evaluation in SNES solver.
Definition SnesCtx.cpp:483
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
PetscErrorCode SnesRhs(SNES snes, Vec x, Vec f, void *ctx)
This is MoFEM implementation for the right hand side (residual vector) evaluation in SNES solver.
Definition SnesCtx.cpp:223
MoFEMErrorCode addHOOpsFace3D(const std::string field, E &e, bool hcurl, bool hdiv)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
MoFEMErrorCode addHOOpsVol(const std::string field, E &e, bool h1, bool hcurl, bool hdiv, bool l2)
double young_modulus
Young modulus.
Definition plastic.cpp:125
double poisson_ratio
Poisson ratio.
Definition plastic.cpp:126
FTensor::Index< 'm', 3 > m
const int N
Definition speed_test.cpp:3
Store variables for ArcLength analysis.
shell matrix for arc-length method
Body forces elements.
Definition BodyForce.hpp:12
MyVolumeFE & getLoopFe()
Definition BodyForce.hpp:23
MoFEMErrorCode addBlock(const std::string field_name, Vec F, int ms_id)
Definition BodyForce.hpp:94
ArcLengthElement(MoFEM::Interface &m_field, boost::shared_ptr< ArcLengthCtx > &arc_ptr)
MoFEMErrorCode postProcess()
function is run at the end of loop
AssembleRhsVectors(MoFEM::Interface &m_field, Vec &body_force, boost::shared_ptr< ArcLengthCtx > &arc_ptr)
boost::shared_ptr< ArcLengthCtx > arcPtr
MoFEMErrorCode preProcess()
function is run at the beginning of loop
MoFEMErrorCode addOps(const std::string field_name, boost::ptr_vector< CohesiveInterfaceElement::PhysicalEquation > &interfaces)
Driver function settting all operators needed for interface element.
Set Dirichlet boundary conditions on displacements.
std::vector< int > dofsIndices
virtual MoFEMErrorCode iNitialize()
Hook equation.
Definition Hooke.hpp:21
static MoFEMErrorCode addNeumannBCElements(MoFEM::Interface &m_field, const std::string field_name, const std::string mesh_nodals_positions="MESH_NODE_POSITIONS", Range *intersect_ptr=NULL)
Declare finite element.
static MoFEMErrorCode addElement(MoFEM::Interface &m_field, const std::string field_name, Range *intersect_ptr=NULL)
Add element taking information from NODESET.
const Problem * problemPtr
raw pointer to problem
Managing BitRefLevels.
virtual int get_comm_size() const =0
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
virtual moab::Interface & get_moab()=0
virtual EntityHandle get_field_meshset(const std::string name) const =0
get field meshset
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MoFEMErrorCode add_field(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
Core (interface) class.
Definition Core.hpp:82
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:118
Deprecated interface functions.
structure for User Loop Methods on finite elements
static UId getHiBitNumberUId(const FieldBitNumber bit_number)
static UId getLoBitNumberUId(const FieldBitNumber bit_number)
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
Elastic material data structure.
Linear interface data structure.
Matrix manager is used to build and partition problems.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode printForceSet() const
print meshsets with force boundary conditions data structure
MoFEMErrorCode printMaterialsSet() const
print meshsets with material data structure set on it
MoFEMErrorCode printDisplacementSet() const
print meshsets with displacement boundary conditions data structure
Create interface from given surface and insert flat prisms in-between.
MoFEMErrorCode getSides(const int msId, const CubitBCType cubit_bc_type, const BitRefLevel mesh_bit_level, const bool recursive, int verb=QUIET)
Store tetrahedra from each side of the interface separately in two child meshsets of the parent meshs...
MoFEMErrorCode splitSides(const EntityHandle meshset, const BitRefLevel &bit, const int msId, const CubitBCType cubit_bc_type, const bool add_interface_entities, const bool recursive=false, int verb=QUIET)
Split nodes and other entities of tetrahedra on both sides of the interface and insert flat prisms in...
Problem manager is used to build and partition problems.
Projection of edge entities with one mid-node on hierarchical basis.
MoFEM::FEMethodsSequence FEMethodsSequence
Definition SnesCtx.hpp:18
Vec & snes_f
residual
SNESContext snes_ctx
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.
Finite element and operators to apply force/pressures applied to surfaces.
Force applied to nodes.
structure grouping operators and data used for calculation of nonlinear elastic element
MyVolumeFE & getLoopFeLhs()
get lhs volume element
std::map< int, BlockData > setOfBlocks
maps block set id with appropriate BlockData
MyVolumeFE & getLoopFeRhs()
get rhs volume element
MyVolumeFE & getLoopFeEnergy()
get energy fe
MoFEMErrorCode setOperators(const std::string spatial_position_field_name, const std::string material_position_field_name="MESH_NODE_POSITIONS", const bool ale=false, const bool field_disp=false)
Set operators to calculate left hand tangent matrix and right hand residual.
structure for Arc Length pre-conditioner
Operator post-procesing stresses for Hook isotropic material.
std::vector< EntityHandle > mapGaussPts
MoFEMErrorCode generateReferenceElementMesh()
Generate reference mesh on single element.