19 #include "libmesh/libmesh_config.h"    20 #if defined(LIBMESH_HAVE_TRIANGLE) && defined(LIBMESH_HAVE_TETGEN)    23 #include "libmesh/elem_cutter.h"    24 #include "libmesh/elem.h"    25 #include "libmesh/replicated_mesh.h"    26 #include "libmesh/mesh_triangle_interface.h"    27 #include "libmesh/mesh_tetgen_interface.h"    34 unsigned int cut_cntr;
    60                             const std::vector<Real> & vertex_distance_func)
 const    62   libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());
    64   for (
const auto & val : vertex_distance_func)
    75                              const std::vector<Real> & vertex_distance_func)
 const    77   libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());
    79   for (
const auto & val : vertex_distance_func)
    90                          const std::vector<Real> & vertex_distance_func)
 const    92   libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());
    95     vmin = vertex_distance_func.front(),
    98   for (
const auto & val : vertex_distance_func)
   100       vmin = std::min (vmin, val);
   101       vmax = std::max (vmax, val);
   105   return (vmin*vmax < 0.);
   111                             const std::vector<Real> & vertex_distance_func)
   114   libmesh_assert_equal_to (vertex_distance_func.size(), elem.
n_vertices());
   122     if (this->
is_outside(elem, vertex_distance_func))
   130     else if (this->
is_inside(elem, vertex_distance_func))
   146     case 1: this->
cut_1D(elem, vertex_distance_func); 
break;
   147     case 2: this->
cut_2D(elem, vertex_distance_func); 
break;
   148     case 3: this->
cut_3D(elem, vertex_distance_func); 
break;
   149     default: libmesh_error_msg(
"Invalid element dimension: " << elem.
dim());
   156                                           const std::vector<Real> & vertex_distance_func)
   171       libmesh_assert_less (el0, vertex_distance_func.size());
   172       libmesh_assert_less (el1, vertex_distance_func.size());
   175         d0 = vertex_distance_func[el0],
   176         d1 = vertex_distance_func[el1];
   181           libmesh_assert_not_equal_to (d0, d1);
   185           const Real d_star = d0 / (d0 - d1);
   190           const Real endpoint_tol = 0.01;
   192           if ( (d_star > endpoint_tol) &&
   193                (d_star < (1.-endpoint_tol)) )
   195               const Point x_star = (edge->point(0)*(1-d_star) +
   196                                     edge->point(1)*d_star);
   213                          const std::vector<Real> &)
   215   libmesh_not_implemented();
   221                          const std::vector<Real> & vertex_distance_func)
   223 #ifndef LIBMESH_HAVE_TRIANGLE   226   libMesh::err << 
"ERROR: current libMesh ElemCutter 2D implementation requires\n"   227                << 
"       the \"triangle\" library!\n"   229   libmesh_not_implemented();
   231 #else // OK, LIBMESH_HAVE_TRIANGLE   243       if (vertex_distance_func[v] >= 0.)
   246       if (vertex_distance_func[v] <= 0.)
   301                          const std::vector<Real> & vertex_distance_func)
   303 #ifndef LIBMESH_HAVE_TETGEN   306   libMesh::err << 
"ERROR: current libMesh ElemCutter 3D implementation requires\n"   307                << 
"       the \"tetgen\" library!\n"   309   libmesh_not_implemented();
   311 #else // OK, LIBMESH_HAVE_TETGEN   323       if (vertex_distance_func[v] >= 0.)
   326       if (vertex_distance_func[v] <= 0.)
   358   std::ostringstream 
name;
   371     if (el->volume() > std::numeric_limits<Real>::epsilon())
   375     if (el->volume() > std::numeric_limits<Real>::epsilon())
   385 #endif // LIBMESH_HAVE_TRIANGLE && LIBMESH_HAVE_TETGEN std::string name(const ElemQuality q)
This function returns a string containing some name for q. 
std::unique_ptr< ReplicatedMesh > _inside_mesh_3D
Class TetGenMeshInterface provides an interface for tetrahedralization of meshes using the TetGen lib...
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
std::unique_ptr< ReplicatedMesh > _inside_mesh_2D
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. 
std::vector< Point > _intersection_pts
std::unique_ptr< TriangleInterface > _triangle_outside
unsigned int get_node_index(const Node *node_ptr) const
void cut_1D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
cutting algorithm in 1D. 
void operator()(const Elem &elem_in, const std::vector< Real > &vertex_distance_func)
This function implements cutting an element by a signed distance function. 
This is the base class from which all geometric element types are derived. 
The libMesh namespace provides an interface to certain functionality in the library. 
bool is_cut(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
void cut_2D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
cutting algorithm in 2D. 
IntRange< unsigned short > edge_index_range() const
std::vector< Elem const * > _inside_elem
std::unique_ptr< ReplicatedMesh > _outside_mesh_3D
std::unique_ptr< TriangleInterface > _triangle_inside
void cut_3D(const Elem &elem, const std::vector< Real > &vertex_distance_func)
cutting algorithm in 3D. 
std::unique_ptr< TetGenMeshInterface > _tetgen_inside
std::unique_ptr< TetGenMeshInterface > _tetgen_outside
bool is_outside(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
bool is_inside(const Elem &elem, const std::vector< Real > &vertex_distance_func) const
std::vector< Elem const * > _outside_elem
virtual unsigned int n_vertices() const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual unsigned short dim() const =0
virtual bool is_vertex(const unsigned int i) const =0
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
std::unique_ptr< ReplicatedMesh > _outside_mesh_2D
virtual std::unique_ptr< Elem > build_edge_ptr(const unsigned int i)=0
A C++ interface between LibMesh and the Triangle library written by J.R. 
A Point defines a location in LIBMESH_DIM dimensional Real space. 
const Point & point(const unsigned int i) const