libMesh
Loading...
Searching...
No Matches
elem_cutter.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
20#ifndef LIBMESH_ELEM_CUTTER_H
21#define LIBMESH_ELEM_CUTTER_H
22
23#include "libmesh/libmesh_config.h"
24
25#if defined(LIBMESH_HAVE_TRIANGLE) && defined(LIBMESH_HAVE_TETGEN)
26
27// libMesh includes
28#include "libmesh/libmesh_common.h"
29#include "libmesh/point.h"
30
31// TIMPI includes
32#include "timpi/communicator.h"
33
34// C++ includes
35#include <vector>
36#include <memory>
37
38namespace libMesh
39{
40
41// Forward declarations
42class Elem;
43class ReplicatedMesh;
44class TriangleInterface;
45class TetGenMeshInterface;
46
47// This is for backwards compatibility, but if your code relies on
48// forward declarations in our headers then fix it.
49class SerialMesh;
50
62{
63public:
64
69 ElemCutter();
70
75
81 bool is_inside (const Elem & elem,
82 const std::vector<Real> & vertex_distance_func) const;
83
89 bool is_outside (const Elem & elem,
90 const std::vector<Real> & vertex_distance_func) const;
91
97 bool is_cut (const Elem & elem,
98 const std::vector<Real> & vertex_distance_func) const;
99
109 void operator()(const Elem & elem_in,
110 const std::vector<Real> & vertex_distance_func);
111
117 const std::vector<Elem const *> & inside_elements () const
118 { return _inside_elem; }
119
125 const std::vector<Elem const *> & outside_elements() const
126 { return _outside_elem; }
127
128protected:
129
134 void find_intersection_points(const Elem & elem,
135 const std::vector<Real> & vertex_distance_func);
136
140 void cut_1D(const Elem & elem,
141 const std::vector<Real> & vertex_distance_func);
142
146 void cut_2D(const Elem & elem,
147 const std::vector<Real> & vertex_distance_func);
148
152 void cut_3D(const Elem & elem,
153 const std::vector<Real> & vertex_distance_func);
154
155 std::vector<Elem const *> _inside_elem;
156 std::vector<Elem const *> _outside_elem;
157
158 Parallel::Communicator _comm_self; // defaults to MPI_COMM_SELF
159
160 std::unique_ptr<ReplicatedMesh> _inside_mesh_2D;
161 std::unique_ptr<TriangleInterface> _triangle_inside;
162
163 std::unique_ptr<ReplicatedMesh> _outside_mesh_2D;
164 std::unique_ptr<TriangleInterface> _triangle_outside;
165
166 std::unique_ptr<ReplicatedMesh> _inside_mesh_3D;
167 std::unique_ptr<TetGenMeshInterface> _tetgen_inside;
168
169 std::unique_ptr<ReplicatedMesh> _outside_mesh_3D;
170 std::unique_ptr<TetGenMeshInterface> _tetgen_outside;
171
172 std::vector<Point> _intersection_pts;
173};
174
175
176} // namespace libMesh
177
178#endif // LIBMESH_HAVE_TRIANGLE && LIBMESH_HAVE_TETGEN
179#endif // LIBMESH_ELEM_CUTTER_H
This class implements cutting a single element into a collection of subelements.
Definition elem_cutter.h:62
void find_intersection_points(const Elem &elem, const std::vector< Real > &vertex_distance_func)
Finds the points where the cutting surface intersects the element edges.
bool is_outside(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
Definition elem_cutter.C:74
bool is_inside(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
Definition elem_cutter.C:59
std::unique_ptr< TriangleInterface > _triangle_inside
void cut_1D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
cutting algorithm in 1D.
std::unique_ptr< TetGenMeshInterface > _tetgen_inside
std::vector< Point > _intersection_pts
const std::vector< Elem const * > & inside_elements() const
std::unique_ptr< ReplicatedMesh > _outside_mesh_2D
bool is_cut(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
Definition elem_cutter.C:89
~ElemCutter()
Destructor.
ElemCutter()
Constructor.
Definition elem_cutter.C:40
std::unique_ptr< TetGenMeshInterface > _tetgen_outside
std::vector< Elem const * > _outside_elem
std::unique_ptr< TriangleInterface > _triangle_outside
const std::vector< Elem const * > & outside_elements() const
void cut_2D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
cutting algorithm in 2D.
Parallel::Communicator _comm_self
std::unique_ptr< ReplicatedMesh > _inside_mesh_2D
std::unique_ptr< ReplicatedMesh > _outside_mesh_3D
std::vector< Elem const * > _inside_elem
void operator()(const Elem &elem_in, const std::vector< Real > &vertex_distance_func)
This function implements cutting an element by a signed distance function.
std::unique_ptr< ReplicatedMesh > _inside_mesh_3D
void cut_3D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
cutting algorithm in 3D.
This is the base class from which all geometric element types are derived.
Definition elem.h:96
The libMesh namespace provides an interface to certain functionality in the library.