libMesh
elem_cutter.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2013 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 // Local includes
28 #include "libmesh/libmesh_common.h"
29 #include "libmesh/point.h"
30 #include "libmesh/auto_ptr.h"
31 #include "libmesh/parallel.h"
32 
33 // C++ includes
34 #include <vector>
35 
36 namespace libMesh
37 {
38 
39 // Forward declarations
40 class Elem;
41 class ReplicatedMesh;
42 class TriangleInterface;
43 class TetGenMeshInterface;
44 
45 // This is for backwards compatibility, but if your code relies on
46 // forward declarations in our headers then fix it.
47 class SerialMesh;
48 
60 {
61 public:
62 
67  ElemCutter();
68 
72  ~ElemCutter();
73 
79  bool is_inside (const Elem & elem,
80  const std::vector<Real> & vertex_distance_func) const;
81 
87  bool is_outside (const Elem & elem,
88  const std::vector<Real> & vertex_distance_func) const;
89 
95  bool is_cut (const Elem & elem,
96  const std::vector<Real> & vertex_distance_func) const;
97 
107  void operator()(const Elem & elem_in,
108  const std::vector<Real> & vertex_distance_func);
109 
115  const std::vector<Elem const *> & inside_elements () const
116  { return _inside_elem; }
117 
123  const std::vector<Elem const *> & outside_elements() const
124  { return _outside_elem; }
125 
126 protected:
127 
132  void find_intersection_points(const Elem & elem,
133  const std::vector<Real> & vertex_distance_func);
134 
138  void cut_1D(const Elem & elem,
139  const std::vector<Real> & vertex_distance_func);
140 
144  void cut_2D(const Elem & elem,
145  const std::vector<Real> & vertex_distance_func);
146 
150  void cut_3D(const Elem & elem,
151  const std::vector<Real> & vertex_distance_func);
152 
153  std::vector<Elem const *> _inside_elem;
154  std::vector<Elem const *> _outside_elem;
155 
160 
161  Parallel::Communicator _comm_self; // defaults to MPI_COMM_SELF
162 
167 
168  std::vector<Point> _intersection_pts;
169 };
170 
171 
172 } // namespace libMesh
173 
174 #endif // LIBMESH_HAVE_TRIANGLE && LIBMESH_HAVE_TETGEN
175 #endif // LIBMESH_ELEM_CUTTER_H
UniquePtr< ReplicatedMesh > _outside_mesh_3D
Definition: elem_cutter.h:159
UniquePtr< ReplicatedMesh > _inside_mesh_3D
Definition: elem_cutter.h:158
UniquePtr< TriangleInterface > _triangle_outside
Definition: elem_cutter.h:164
Encapsulates the MPI_Comm object.
Definition: parallel.h:657
UniquePtr< ReplicatedMesh > _inside_mesh_2D
Definition: elem_cutter.h:156
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.
Definition: elem_cutter.C:156
std::vector< Point > _intersection_pts
Definition: elem_cutter.h:168
void cut_1D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
cutting algorithm in 1D.
Definition: elem_cutter.C:211
ElemCutter()
Constructor.
Definition: elem_cutter.C:41
void operator()(const Elem &elem_in, const std::vector< Real > &vertex_distance_func)
This function implements cutting an element by a signed distance function.
Definition: elem_cutter.C:111
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
bool is_outside(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
Definition: elem_cutter.C:74
const std::vector< Elem const * > & inside_elements() const
Definition: elem_cutter.h:115
bool is_cut(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
Definition: elem_cutter.C:89
The libMesh namespace provides an interface to certain functionality in the library.
UniquePtr< ReplicatedMesh > _outside_mesh_2D
Definition: elem_cutter.h:157
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
void cut_2D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
cutting algorithm in 2D.
Definition: elem_cutter.C:219
This class implements cutting a single element into a collection of subelements.
Definition: elem_cutter.h:59
UniquePtr< TetGenMeshInterface > _tetgen_outside
Definition: elem_cutter.h:166
std::vector< Elem const * > _inside_elem
Definition: elem_cutter.h:153
void cut_3D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
cutting algorithm in 3D.
Definition: elem_cutter.C:308
UniquePtr< TetGenMeshInterface > _tetgen_inside
Definition: elem_cutter.h:165
std::vector< Elem const * > _outside_elem
Definition: elem_cutter.h:154
~ElemCutter()
Destructor.
Definition: elem_cutter.C:54
UniquePtr< TriangleInterface > _triangle_inside
Definition: elem_cutter.h:163
bool is_inside(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
Definition: elem_cutter.C:59
Parallel::Communicator _comm_self
Definition: elem_cutter.h:161
const std::vector< Elem const * > & outside_elements() const
Definition: elem_cutter.h:123