v0.14.0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
FractureMechanics::GetSmoothingElementsSkin Struct Reference
Collaboration diagram for FractureMechanics::GetSmoothingElementsSkin:
[legend]

Public Member Functions

 GetSmoothingElementsSkin (CrackPropagation &cp)
 
MoFEMErrorCode getOptions ()
 
MoFEMErrorCode operator() (Range &fix_material_nodes, const bool fix_small_g=true, const bool debug=false) const
 

Public Attributes

CrackPropagationcP
 
double gcFixThreshold
 

Detailed Description

Definition at line 242 of file CrackPropagation.cpp.

Constructor & Destructor Documentation

◆ GetSmoothingElementsSkin()

FractureMechanics::GetSmoothingElementsSkin::GetSmoothingElementsSkin ( CrackPropagation cp)
inline

Definition at line 245 of file CrackPropagation.cpp.

245 : cP(cp), gcFixThreshold(0.5) {
246 ierr = getOptions();
247 CHKERRABORT(PETSC_COMM_WORLD, ierr);
248 }
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76

Member Function Documentation

◆ getOptions()

MoFEMErrorCode FractureMechanics::GetSmoothingElementsSkin::getOptions ( )
inline

Definition at line 250 of file CrackPropagation.cpp.

250 {
252 ierr =
253 PetscOptionsBegin(PETSC_COMM_WORLD, "", "Fixing nodes options", "none");
254 CHKERRG(ierr);
255 CHKERR PetscOptionsScalar("-gc_fix_threshold",
256 "fix nodes below given threshold", "",
257 gcFixThreshold, &gcFixThreshold, PETSC_NULL);
258 CHKERR PetscPrintf(PETSC_COMM_WORLD,
259 "### Input parameter: -gc_fix_threshold %6.4e \n",
261
262 ierr = PetscOptionsEnd();
263 CHKERRG(ierr);
265 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535

◆ operator()()

MoFEMErrorCode FractureMechanics::GetSmoothingElementsSkin::operator() ( Range fix_material_nodes,
const bool  fix_small_g = true,
const bool  debug = false 
) const
inline

Definition at line 267 of file CrackPropagation.cpp.

269 {
270 MoFEM::Interface &m_field = cP.mField;
272
273 Skinner skin(&m_field.get_moab());
274 Range tets_level, prisms_level;
275 CHKERR m_field.getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
276 cP.mapBitLevel["material_domain"], BitRefLevel().set(), MBTET,
277 tets_level);
278 CHKERR m_field.getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
279 cP.mapBitLevel["material_domain"], BitRefLevel().set(), MBPRISM,
280 prisms_level);
281
282 prisms_level = intersect(prisms_level, cP.contactElements);
283 tets_level.merge(prisms_level);
284
285 Range mesh_skin;
286 CHKERR skin.find_skin(0, tets_level, false, mesh_skin);
287
288 mesh_skin = mesh_skin.subset_by_type(MBTRI);
289
290 Range faces_to_remove, contact_faces;
291 faces_to_remove = unite(cP.crackFaces, cP.bodySkin);
292 contact_faces = unite(cP.contactMasterFaces, cP.contactSlaveFaces);
293 faces_to_remove = subtract(faces_to_remove, contact_faces);
294
295 mesh_skin = subtract(mesh_skin, faces_to_remove);
296
297 CHKERR m_field.get_moab().get_connectivity(mesh_skin, fix_material_nodes);
298 // fix fixed edges nodes
299 Range fixed_edges = cP.getInterface<CPMeshCut>()->getFixedEdges();
300 Range fixed_edges_nodes;
301 CHKERR m_field.get_moab().get_connectivity(fixed_edges, fixed_edges_nodes,
302 true);
303
304 Range crack_faces_and_fixed_edges_nodes;
305 CHKERR m_field.get_moab().get_connectivity(
306 cP.crackFaces, crack_faces_and_fixed_edges_nodes, true);
307 crack_faces_and_fixed_edges_nodes =
308 intersect(crack_faces_and_fixed_edges_nodes, fixed_edges_nodes);
309
310 Range crack_faces_edges;
311 CHKERR m_field.get_moab().get_adjacencies(
312 cP.crackFaces, 1, false, crack_faces_edges, moab::Interface::UNION);
313 Range not_fixed_edges = intersect(crack_faces_edges, fixed_edges);
314 Range not_fixed_edges_nodes;
315 CHKERR m_field.get_moab().get_connectivity(not_fixed_edges,
316 not_fixed_edges_nodes, true);
317 crack_faces_and_fixed_edges_nodes =
318 subtract(crack_faces_and_fixed_edges_nodes, not_fixed_edges_nodes);
319 fix_material_nodes.merge(crack_faces_and_fixed_edges_nodes);
320
321 Range not_fixed_edges_skin;
322 CHKERR skin.find_skin(0, not_fixed_edges, false, not_fixed_edges_skin);
323 fix_material_nodes.merge(
324 subtract(not_fixed_edges_skin, cP.crackFrontNodes));
325 if (debug && !m_field.get_comm_rank()) {
326 EntityHandle meshset;
327 CHKERR m_field.get_moab().create_meshset(MESHSET_SET, meshset);
328 CHKERR m_field.get_moab().add_entities(meshset, mesh_skin);
329 CHKERR m_field.get_moab().write_file("fixed_faces.vtk", "VTK", "",
330 &meshset, 1);
331 CHKERR m_field.get_moab().delete_entities(&meshset, 1);
332 }
333
334 // fix corner nodes
335 fix_material_nodes.merge(cP.getInterface<CPMeshCut>()->getCornerNodes());
336
337 // fix nodes on kinematic and static boundary conditions
338 auto bc_fix_nodes = [&m_field,
339 &fix_material_nodes](const EntityHandle meshset) {
341 Range ents;
342 CHKERR m_field.get_moab().get_entities_by_handle(meshset, ents, true);
343 Range nodes;
344 CHKERR m_field.get_moab().get_connectivity(ents, nodes);
345 fix_material_nodes.merge(nodes);
347 };
349 m_field, NODESET | DISPLACEMENTSET, it)) {
350 CHKERR bc_fix_nodes(it->getMeshset());
351 }
352
353 if (!cP.isSurfaceForceAle) {
355 NODESET | FORCESET, it)) {
356 CHKERR bc_fix_nodes(it->getMeshset());
357 }
358 }
359
360 if (!cP.isPressureAle) {
361 // fix nodes on surfaces under pressure
363 m_field, SIDESET | PRESSURESET, it)) {
364 CHKERR bc_fix_nodes(it->getMeshset());
365 }
366 }
367
368 // fix nodes on contact surfaces
369 if (cP.fixContactNodes) {
370 Range contact_nodes;
371 CHKERR m_field.get_moab().get_connectivity(cP.contactElements,
372 contact_nodes);
373 fix_material_nodes.merge(contact_nodes);
374 }
375
376 if (!cP.areSpringsAle) {
377 // fix nodes on spring nodes
379 if (bit->getName().compare(0, 9, "SPRING_BC") == 0) {
380 CHKERR bc_fix_nodes(bit->meshset);
381 }
382 }
383 }
384
385 {
386 Range contact_nodes;
387 CHKERR m_field.get_moab().get_connectivity(cP.mortarContactElements,
388 contact_nodes);
389 fix_material_nodes.merge(contact_nodes);
390 }
391
392 // fix nodes on the constrained interface
393 if (!cP.constrainedInterface.empty()) {
394 Range interface_nodes;
395 CHKERR m_field.get_moab().get_connectivity(cP.constrainedInterface,
396 interface_nodes);
397 fix_material_nodes.merge(interface_nodes);
398 }
399
400 auto add_nodes_on_opposite_side_of_prism = [&m_field, &fix_material_nodes,
401 this](bool only_contact_prisms =
402 false) {
404 Range adj_prisms;
405 CHKERR m_field.get_moab().get_adjacencies(
406 fix_material_nodes, 3, false, adj_prisms, moab::Interface::UNION);
407 adj_prisms = adj_prisms.subset_by_type(MBPRISM);
408 if (only_contact_prisms) {
409 adj_prisms = intersect(adj_prisms, cP.contactElements);
410 }
411 for (auto p : adj_prisms) {
412 int num_nodes;
413 const EntityHandle *conn;
414 CHKERR m_field.get_moab().get_connectivity(p, conn, num_nodes, false);
415 Range add_nodes;
416 for (int n = 0; n != 3; ++n) {
417 if (fix_material_nodes.find(conn[n]) != fix_material_nodes.end()) {
418 add_nodes.insert(conn[3 + n]);
419 }
420 if (fix_material_nodes.find(conn[3 + n]) !=
421 fix_material_nodes.end()) {
422 add_nodes.insert(conn[n]);
423 }
424 }
425 fix_material_nodes.merge(add_nodes);
426 }
428 };
429
430 CHKERR add_nodes_on_opposite_side_of_prism();
431
433 if (fix_small_g) {
434
435 if (!cP.mField.get_comm_rank()) {
436 auto copy_map = [&fix_material_nodes](const auto &map) {
437 std::map<EntityHandle, double> map_copy;
438 for (auto &m : map) {
439 if (fix_material_nodes.find(m.first) == fix_material_nodes.end()) {
440 map_copy[m.first] = m.second;
441 }
442 }
443 return map_copy;
444 };
445
446 const std::map<EntityHandle, double> map_j = copy_map(cP.mapJ);
447 const std::map<EntityHandle, double> map_g1 = copy_map(cP.mapG1);
448
449 auto find_max = [](const auto &map) {
450 double max = 0;
451 for (auto &m : map)
452 max = fmax(m.second, max);
453 return max;
454 };
455
456 const double max_j = find_max(map_j);
457 const double max_g1 = find_max(map_g1);
458
459 for (auto &m : map_j) {
460 if ((m.second < gcFixThreshold * max_j) &&
461 (map_g1.at(m.first) < gcFixThreshold * max_g1)) {
462 fix_material_nodes.insert(m.first);
463 } else {
465 }
466 }
467
468 if (map_j.empty() || map_g1.empty() || cP.fractionOfFixedNodes == 0) {
469 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
470 "No points to move on crack front");
471 }
472
473 cP.fractionOfFixedNodes /= map_j.size();
474 }
475
476 Vec vec;
477 CHKERR VecCreateMPI(cP.mField.get_comm(), PETSC_DETERMINE, 1, &vec);
478 if (!cP.mField.get_comm_rank()) {
479 CHKERR VecSetValue(vec, cP.mField.get_comm_rank(),
480 cP.fractionOfFixedNodes, INSERT_VALUES);
481 }
482 CHKERR VecMax(vec, PETSC_NULL, &cP.fractionOfFixedNodes);
483 CHKERR VecDestroy(&vec);
484 }
485
486 CHKERR add_nodes_on_opposite_side_of_prism(true);
487
489 }
static Index< 'p', 3 > p
@ PRESSURESET
Definition: definitions.h:152
@ FORCESET
Definition: definitions.h:151
@ NODESET
Definition: definitions.h:146
@ SIDESET
Definition: definitions.h:147
@ DISPLACEMENTSET
Definition: definitions.h:150
@ BLOCKSET
Definition: definitions.h:148
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
static const bool debug
FTensor::Index< 'n', SPACE_DIM > n
FTensor::Index< 'm', SPACE_DIM > m
#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.
auto bit
set bit
const FTensor::Tensor2< T, Dim, Dim > Vec
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
std::map< std::string, BitRefLevel > mapBitLevel
map< EntityHandle, double > mapJ
hashmap of J - release energy at nodes
Range constrainedInterface
Range of faces on the constrained interface.
PetscBool isPressureAle
If true surface pressure is considered in ALE.
map< EntityHandle, double > mapG1
hashmap of g1 - release energy at nodes
PetscBool areSpringsAle
If true surface spring is considered in ALE.
PetscBool isSurfaceForceAle
If true surface pressure is considered in ALE.
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Deprecated interface functions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

Member Data Documentation

◆ cP

CrackPropagation& FractureMechanics::GetSmoothingElementsSkin::cP

Definition at line 243 of file CrackPropagation.cpp.

◆ gcFixThreshold

double FractureMechanics::GetSmoothingElementsSkin::gcFixThreshold

Definition at line 244 of file CrackPropagation.cpp.


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