www.mooseframework.org
MeshCut3DUserObject.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "GeometricCutUserObject.h"
13 
14 #include <array>
15 
17 class Function;
18 
19 template <>
20 InputParameters validParams<MeshCut3DUserObject>();
21 
29 {
30 public:
31  MeshCut3DUserObject(const InputParameters & parameters);
32 
33  virtual void initialSetup() override;
34  virtual void initialize() override;
35  virtual const std::vector<Point>
36  getCrackFrontPoints(unsigned int num_crack_front_points) const override;
37 
38  virtual bool cutElementByGeometry(const Elem * elem,
39  std::vector<Xfem::CutEdge> & cut_edges,
40  std::vector<Xfem::CutNode> & cut_nodes,
41  Real time) const override;
42  virtual bool cutElementByGeometry(const Elem * elem,
43  std::vector<Xfem::CutFace> & cut_faces,
44  Real time) const override;
45  virtual bool cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_edges,
46  std::vector<Xfem::CutEdge> & cut_edges,
47  Real time) const override;
48  virtual bool cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_faces,
49  std::vector<Xfem::CutFace> & cut_faces,
50  Real time) const override;
51 
52 protected:
54  std::unique_ptr<MeshBase> _cut_mesh;
55 
57  const unsigned int _cut_elem_nnode = 3;
58  const unsigned int _cut_elem_dim = 2;
59 
61  MooseMesh & _mesh;
62 
64  const unsigned int _elem_dim = 3;
65 
67  const Real _const_intersection = 0.01;
68 
71 
73  unsigned int _n_step_growth;
74 
76  bool _stop;
77  bool _grow;
78 
80  std::vector<dof_id_type> _boundary;
81 
83  std::set<Xfem::CutEdge> _boundary_edges;
84 
86  std::map<dof_id_type, std::vector<dof_id_type>> _boundary_map;
87 
89  std::vector<std::vector<dof_id_type>> _active_boundary;
90 
92  std::vector<std::vector<Point>> _active_direction;
93 
95  std::vector<unsigned int> _inactive_boundary_pos;
96 
98  std::vector<std::vector<dof_id_type>> _front;
99 
103  virtual bool intersectWithEdge(const Point & p1,
104  const Point & p2,
105  const std::vector<Point> & _vertices,
106  Point & pint) const;
107 
111  bool findIntersection(const Point & p1,
112  const Point & p2,
113  const std::vector<Point> & vertices,
114  Point & pint) const;
115 
119  bool isInsideEdge(const Point & p1, const Point & p2, const Point & p) const;
120 
124  Real getRelativePosition(const Point & p1, const Point & p2, const Point & p) const;
125 
129  bool isInsideCutPlane(const std::vector<Point> & _vertices, const Point & p) const;
130 
137  void findBoundaryNodes();
138 
142  void findBoundaryEdges();
143 
147  void sortBoundaryNodes();
148 
152  Real findDistance(dof_id_type node1, dof_id_type node2);
153 
157  void refineBoundary();
158 
164 
169 
173  void growFront();
174 
178  void sortFrontNodes();
179 
183  void findFrontIntersection();
184 
188  void refineFront();
189 
193  void triangulation();
194 
198  void joinBoundary();
199 
203  const Function & _func_x;
204  const Function & _func_y;
205  const Function & _func_z;
206 };
MeshCut3DUserObject::findBoundaryNodes
void findBoundaryNodes()
Find boundary nodes of the cutter mesh This is a simple algorithm simply based on the added angle = 3...
Definition: MeshCut3DUserObject.C:331
MeshCut3DUserObject::findActiveBoundaryDirection
void findActiveBoundaryDirection()
Find growth direction at each active node.
Definition: MeshCut3DUserObject.C:678
MeshCut3DUserObject::getRelativePosition
Real getRelativePosition(const Point &p1, const Point &p2, const Point &p) const
Get the relative position of p from p1.
Definition: MeshCut3DUserObject.C:296
MeshCut3DUserObject::refineFront
void refineFront()
Refine the mesh at the front.
Definition: MeshCut3DUserObject.C:897
MeshCut3DUserObject
MeshCut3DUserObject: (1) reads in a mesh describing the crack surface, (2) uses the mesh to do initia...
Definition: MeshCut3DUserObject.h:28
MeshCut3DUserObject::_func_y
const Function & _func_y
Definition: MeshCut3DUserObject.h:204
MeshCut3DUserObject::isInsideEdge
bool isInsideEdge(const Point &p1, const Point &p2, const Point &p) const
Check if point p is inside the edge p1-p2.
Definition: MeshCut3DUserObject.C:288
MeshCut3DUserObject::_func_z
const Function & _func_z
Definition: MeshCut3DUserObject.h:205
validParams< MeshCut3DUserObject >
InputParameters validParams< MeshCut3DUserObject >()
Definition: MeshCut3DUserObject.C:26
MeshCut3DUserObject::refineBoundary
void refineBoundary()
If boundary nodes are too sparse, add nodes in between.
Definition: MeshCut3DUserObject.C:564
MeshCut3DUserObject::_grow
bool _grow
Definition: MeshCut3DUserObject.h:77
MeshCut3DUserObject::findBoundaryEdges
void findBoundaryEdges()
Find boundary edges of the cutter mesh.
Definition: MeshCut3DUserObject.C:373
MeshCut3DUserObject::_size_control
Real _size_control
Used for cutter mesh refinement and front advancement.
Definition: MeshCut3DUserObject.h:70
MeshCut3DUserObject::findActiveBoundaryNodes
void findActiveBoundaryNodes()
Find all active boundary nodes in the cutter mesh Find boundary nodes that will grow; nodes outside o...
Definition: MeshCut3DUserObject.C:618
GeometricCutUserObject.h
GeometricCutUserObject
Definition: GeometricCutUserObject.h:106
MeshCut3DUserObject::MeshCut3DUserObject
MeshCut3DUserObject(const InputParameters &parameters)
Definition: MeshCut3DUserObject.C:44
MeshCut3DUserObject::_front
std::vector< std::vector< dof_id_type > > _front
New boundary after growth.
Definition: MeshCut3DUserObject.h:98
MeshCut3DUserObject::_active_boundary
std::vector< std::vector< dof_id_type > > _active_boundary
Active boundary nodes where growth is allowed.
Definition: MeshCut3DUserObject.h:89
MeshCut3DUserObject::initialSetup
virtual void initialSetup() override
Definition: MeshCut3DUserObject.C:78
MeshCut3DUserObject::_mesh
MooseMesh & _mesh
The structural mesh.
Definition: MeshCut3DUserObject.h:61
MeshCut3DUserObject::_boundary_edges
std::set< Xfem::CutEdge > _boundary_edges
Edges at the boundary.
Definition: MeshCut3DUserObject.h:83
MeshCut3DUserObject::_boundary
std::vector< dof_id_type > _boundary
Boundary nodes of the cutter mesh.
Definition: MeshCut3DUserObject.h:80
MeshCut3DUserObject::sortBoundaryNodes
void sortBoundaryNodes()
Sort boundary nodes to be in the right order along the boundary.
Definition: MeshCut3DUserObject.C:493
MeshCut3DUserObject::findDistance
Real findDistance(dof_id_type node1, dof_id_type node2)
Find distance between two nodes.
Definition: MeshCut3DUserObject.C:553
MeshCut3DUserObject::findIntersection
bool findIntersection(const Point &p1, const Point &p2, const std::vector< Point > &vertices, Point &pint) const
Find directional intersection along the positive extension of the vector from p1 to p2.
Definition: MeshCut3DUserObject.C:256
MeshCut3DUserObject::isInsideCutPlane
bool isInsideCutPlane(const std::vector< Point > &_vertices, const Point &p) const
Check if point p is inside a plane.
Definition: MeshCut3DUserObject.C:304
MeshCut3DUserObject::_const_intersection
const Real _const_intersection
Used to define intersection points.
Definition: MeshCut3DUserObject.h:67
MeshCut3DUserObject::initialize
virtual void initialize() override
Definition: MeshCut3DUserObject.C:90
MeshCut3DUserObject::_cut_elem_dim
const unsigned int _cut_elem_dim
Definition: MeshCut3DUserObject.h:58
MeshCut3DUserObject::_boundary_map
std::map< dof_id_type, std::vector< dof_id_type > > _boundary_map
A map of boundary nodes and their neighbors.
Definition: MeshCut3DUserObject.h:86
MeshCut3DUserObject::_func_x
const Function & _func_x
Parsed functions of front growth.
Definition: MeshCut3DUserObject.h:203
MeshCut3DUserObject::_active_direction
std::vector< std::vector< Point > > _active_direction
Growth direction for active boundaries.
Definition: MeshCut3DUserObject.h:92
MeshCut3DUserObject::_n_step_growth
unsigned int _n_step_growth
Number of steps to grow the mesh.
Definition: MeshCut3DUserObject.h:73
MeshCut3DUserObject::sortFrontNodes
void sortFrontNodes()
Sort the front nodes.
Definition: MeshCut3DUserObject.C:784
MeshCut3DUserObject::_cut_mesh
std::unique_ptr< MeshBase > _cut_mesh
The cutter mesh.
Definition: MeshCut3DUserObject.h:54
MeshCut3DUserObject::joinBoundary
void joinBoundary()
Join active boundaries and inactive boundaries to be the new boundary.
Definition: MeshCut3DUserObject.C:1045
MeshCut3DUserObject::cutFragmentByGeometry
virtual bool cutFragmentByGeometry(std::vector< std::vector< Point >> &frag_edges, std::vector< Xfem::CutEdge > &cut_edges, Real time) const override
Check to see whether a fragment of a 2D element should be cut based on geometric conditions.
Definition: MeshCut3DUserObject.C:206
MeshCut3DUserObject::findFrontIntersection
void findFrontIntersection()
Find front-structure intersections.
Definition: MeshCut3DUserObject.C:790
MeshCut3DUserObject::_cut_elem_nnode
const unsigned int _cut_elem_nnode
The cutter mesh has triangluar elements only.
Definition: MeshCut3DUserObject.h:57
MeshCut3DUserObject::_stop
bool _stop
variables to help control the work flow
Definition: MeshCut3DUserObject.h:76
MeshCut3DUserObject::intersectWithEdge
virtual bool intersectWithEdge(const Point &p1, const Point &p2, const std::vector< Point > &_vertices, Point &pint) const
Check if a line intersects with an element.
Definition: MeshCut3DUserObject.C:225
MeshCut3DUserObject::triangulation
void triangulation()
Create tri3 elements between the new front and the old front.
Definition: MeshCut3DUserObject.C:958
MeshCut3DUserObject::_elem_dim
const unsigned int _elem_dim
The structural mesh must be 3D only.
Definition: MeshCut3DUserObject.h:64
MeshCut3DUserObject::getCrackFrontPoints
virtual const std::vector< Point > getCrackFrontPoints(unsigned int num_crack_front_points) const override
get a set of points along a crack front from a XFEM GeometricCutUserObject
Definition: MeshCut3DUserObject.C:1085
MeshCut3DUserObject::cutElementByGeometry
virtual bool cutElementByGeometry(const Elem *elem, std::vector< Xfem::CutEdge > &cut_edges, std::vector< Xfem::CutNode > &cut_nodes, Real time) const override
Check to see whether a specified 2D element should be cut based on geometric conditions.
Definition: MeshCut3DUserObject.C:124
MeshCut3DUserObject::growFront
void growFront()
Grow the cutter mesh.
Definition: MeshCut3DUserObject.C:745
MeshCut3DUserObject::_inactive_boundary_pos
std::vector< unsigned int > _inactive_boundary_pos
Inactive boundary.
Definition: MeshCut3DUserObject.h:95