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" // deprecated
31 #include "libmesh/parallel.h"
32 
33 // C++ includes
34 #include <vector>
35 #include <memory>
36 
37 namespace libMesh
38 {
39 
40 // Forward declarations
41 class Elem;
42 class ReplicatedMesh;
43 class TriangleInterface;
44 class TetGenMeshInterface;
45 
46 // This is for backwards compatibility, but if your code relies on
47 // forward declarations in our headers then fix it.
48 class SerialMesh;
49 
61 {
62 public:
63 
68  ElemCutter();
69 
73  ~ElemCutter();
74 
80  bool is_inside (const Elem & elem,
81  const std::vector<Real> & vertex_distance_func) const;
82 
88  bool is_outside (const Elem & elem,
89  const std::vector<Real> & vertex_distance_func) const;
90 
96  bool is_cut (const Elem & elem,
97  const std::vector<Real> & vertex_distance_func) const;
98 
108  void operator()(const Elem & elem_in,
109  const std::vector<Real> & vertex_distance_func);
110 
116  const std::vector<Elem const *> & inside_elements () const
117  { return _inside_elem; }
118 
124  const std::vector<Elem const *> & outside_elements() const
125  { return _outside_elem; }
126 
127 protected:
128 
133  void find_intersection_points(const Elem & elem,
134  const std::vector<Real> & vertex_distance_func);
135 
139  void cut_1D(const Elem & elem,
140  const std::vector<Real> & vertex_distance_func);
141 
145  void cut_2D(const Elem & elem,
146  const std::vector<Real> & vertex_distance_func);
147 
151  void cut_3D(const Elem & elem,
152  const std::vector<Real> & vertex_distance_func);
153 
154  std::vector<Elem const *> _inside_elem;
155  std::vector<Elem const *> _outside_elem;
156 
157  Parallel::Communicator _comm_self; // defaults to MPI_COMM_SELF
158 
159  std::unique_ptr<ReplicatedMesh> _inside_mesh_2D;
160  std::unique_ptr<TriangleInterface> _triangle_inside;
161 
162  std::unique_ptr<ReplicatedMesh> _outside_mesh_2D;
163  std::unique_ptr<TriangleInterface> _triangle_outside;
164 
165  std::unique_ptr<ReplicatedMesh> _inside_mesh_3D;
166  std::unique_ptr<TetGenMeshInterface> _tetgen_inside;
167 
168  std::unique_ptr<ReplicatedMesh> _outside_mesh_3D;
169  std::unique_ptr<TetGenMeshInterface> _tetgen_outside;
170 
171  std::vector<Point> _intersection_pts;
172 };
173 
174 
175 } // namespace libMesh
176 
177 #endif // LIBMESH_HAVE_TRIANGLE && LIBMESH_HAVE_TETGEN
178 #endif // LIBMESH_ELEM_CUTTER_H
std::unique_ptr< ReplicatedMesh > _inside_mesh_3D
Definition: elem_cutter.h:165
std::unique_ptr< ReplicatedMesh > _inside_mesh_2D
Definition: elem_cutter.h:159
void find_intersection_points(const Elem &elem, const std::vector< Real > &vertex_distance_func)
Definition: elem_cutter.C:154
std::vector< Point > _intersection_pts
Definition: elem_cutter.h:171
std::unique_ptr< TriangleInterface > _triangle_outside
Definition: elem_cutter.h:163
void cut_1D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
Definition: elem_cutter.C:209
void operator()(const Elem &elem_in, const std::vector< Real > &vertex_distance_func)
Definition: elem_cutter.C:109
The base class for all geometric element types.
Definition: elem.h:100
bool is_cut(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
Definition: elem_cutter.C:88
void cut_2D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
Definition: elem_cutter.C:217
Subdivides a single element using a mesh generator.
Definition: elem_cutter.h:60
std::vector< Elem const * > _inside_elem
Definition: elem_cutter.h:154
std::unique_ptr< ReplicatedMesh > _outside_mesh_3D
Definition: elem_cutter.h:168
std::unique_ptr< TriangleInterface > _triangle_inside
Definition: elem_cutter.h:160
const std::vector< Elem const * > & outside_elements() const
Definition: elem_cutter.h:124
void cut_3D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
Definition: elem_cutter.C:297
std::unique_ptr< TetGenMeshInterface > _tetgen_inside
Definition: elem_cutter.h:166
std::unique_ptr< TetGenMeshInterface > _tetgen_outside
Definition: elem_cutter.h:169
bool is_outside(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
Definition: elem_cutter.C:73
bool is_inside(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
Definition: elem_cutter.C:58
std::vector< Elem const * > _outside_elem
Definition: elem_cutter.h:155
const std::vector< Elem const * > & inside_elements() const
Definition: elem_cutter.h:116
std::unique_ptr< ReplicatedMesh > _outside_mesh_2D
Definition: elem_cutter.h:162
Parallel::Communicator _comm_self
Definition: elem_cutter.h:157