v0.14.0
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 244 of file CrackPropagation.cpp.

Constructor & Destructor Documentation

◆ GetSmoothingElementsSkin()

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

Definition at line 247 of file CrackPropagation.cpp.

247  : cP(cp), gcFixThreshold(0.5) {
248  ierr = getOptions();
249  CHKERRABORT(PETSC_COMM_WORLD, ierr);
250  }

Member Function Documentation

◆ getOptions()

MoFEMErrorCode FractureMechanics::GetSmoothingElementsSkin::getOptions ( )
inline

Definition at line 252 of file CrackPropagation.cpp.

252  {
254  ierr =
255  PetscOptionsBegin(PETSC_COMM_WORLD, "", "Fixing nodes options", "none");
256  CHKERRG(ierr);
257  CHKERR PetscOptionsScalar("-gc_fix_threshold",
258  "fix nodes below given threshold", "",
259  gcFixThreshold, &gcFixThreshold, PETSC_NULL);
260  CHKERR PetscPrintf(PETSC_COMM_WORLD,
261  "### Input parameter: -gc_fix_threshold %6.4e \n",
263 
264  ierr = PetscOptionsEnd();
265  CHKERRG(ierr);
267  }

◆ operator()()

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

Definition at line 269 of file CrackPropagation.cpp.

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

Member Data Documentation

◆ cP

CrackPropagation& FractureMechanics::GetSmoothingElementsSkin::cP

Definition at line 245 of file CrackPropagation.cpp.

◆ gcFixThreshold

double FractureMechanics::GetSmoothingElementsSkin::gcFixThreshold

Definition at line 246 of file CrackPropagation.cpp.


The documentation for this struct was generated from the following file:
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
SIDESET
@ SIDESET
Definition: definitions.h:160
EntityHandle
FractureMechanics::CrackPropagation::crackFaces
Range crackFaces
Definition: CrackPropagation.hpp:1160
FractureMechanics::CrackPropagation::fixContactNodes
PetscBool fixContactNodes
Definition: CrackPropagation.hpp:1235
PRESSURESET
@ PRESSURESET
Definition: definitions.h:165
MoFEM::CoreInterface::get_comm
virtual MPI_Comm & get_comm() const =0
FractureMechanics::CrackPropagation::mapBitLevel
std::map< std::string, BitRefLevel > mapBitLevel
Definition: CrackPropagation.hpp:180
_IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
Definition: MeshsetsManager.hpp:49
MoFEM::CoreInterface::get_comm_rank
virtual int get_comm_rank() const =0
FractureMechanics::CrackPropagation::mapJ
map< EntityHandle, double > mapJ
hashmap of J - release energy at nodes
Definition: CrackPropagation.hpp:1189
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
FractureMechanics::CrackPropagation::mortarContactElements
Range mortarContactElements
Definition: CrackPropagation.hpp:1245
FractureMechanics::CrackPropagation::areSpringsAle
PetscBool areSpringsAle
If true surface spring is considered in ALE.
Definition: CrackPropagation.hpp:126
FractureMechanics::CrackPropagation::mField
MoFEM::Interface & mField
Definition: CrackPropagation.hpp:106
NODESET
@ NODESET
Definition: definitions.h:159
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
FractureMechanics::CrackPropagation::isSurfaceForceAle
PetscBool isSurfaceForceAle
If true surface pressure is considered in ALE.
Definition: CrackPropagation.hpp:128
FractureMechanics::CrackPropagation::contactMasterFaces
Range contactMasterFaces
Definition: CrackPropagation.hpp:1242
FORCESET
@ FORCESET
Definition: definitions.h:164
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
DISPLACEMENTSET
@ DISPLACEMENTSET
Definition: definitions.h:163
FractureMechanics::GetSmoothingElementsSkin::gcFixThreshold
double gcFixThreshold
Definition: CrackPropagation.cpp:246
FractureMechanics::CrackPropagation::constrainedInterface
Range constrainedInterface
Range of faces on the constrained interface.
Definition: CrackPropagation.hpp:1301
debug
static const bool debug
Definition: dm_create_subdm.cpp:12
FractureMechanics::GetSmoothingElementsSkin::getOptions
MoFEMErrorCode getOptions()
Definition: CrackPropagation.cpp:252
convert.n
n
Definition: convert.py:82
FractureMechanics::CrackPropagation::bodySkin
Range bodySkin
Definition: CrackPropagation.hpp:1159
FractureMechanics::CrackPropagation::contactSlaveFaces
Range contactSlaveFaces
Definition: CrackPropagation.hpp:1243
Range
FractureMechanics::CrackPropagation::mapG1
map< EntityHandle, double > mapG1
hashmap of g1 - release energy at nodes
Definition: CrackPropagation.hpp:1187
_IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_
#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.
Definition: MeshsetsManager.hpp:71
BLOCKSET
@ BLOCKSET
Definition: definitions.h:161
FractureMechanics::GetSmoothingElementsSkin::cP
CrackPropagation & cP
Definition: CrackPropagation.cpp:245
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
MoFEM::BitRefManager
Managing BitRefLevels.
Definition: BitRefManager.hpp:21
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
FractureMechanics::CrackPropagation::contactElements
Range contactElements
Definition: CrackPropagation.hpp:1241
FractureMechanics::CrackPropagation::crackFrontNodes
Range crackFrontNodes
Definition: CrackPropagation.hpp:1164
FractureMechanics::CrackPropagation::fractionOfFixedNodes
double fractionOfFixedNodes
Definition: CrackPropagation.hpp:1186
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
FractureMechanics::CrackPropagation::isPressureAle
PetscBool isPressureAle
If true surface pressure is considered in ALE.
Definition: CrackPropagation.hpp:125