20 #if defined(LIBMESH_HAVE_TRIANGLE) && defined(LIBMESH_HAVE_TETGEN) 32 unsigned int cut_cntr;
39 _inside_mesh_2D(libmesh_make_unique<
ReplicatedMesh>(_comm_self,2)),
41 _outside_mesh_2D(libmesh_make_unique<
ReplicatedMesh>(_comm_self,2)),
43 _inside_mesh_3D(libmesh_make_unique<
ReplicatedMesh>(_comm_self,3)),
45 _outside_mesh_3D(libmesh_make_unique<
ReplicatedMesh>(_comm_self,3)),
59 const std::vector<Real> & vertex_distance_func)
const 61 libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());
63 for (
const auto & val : vertex_distance_func)
74 const std::vector<Real> & vertex_distance_func)
const 76 libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());
78 for (
const auto & val : vertex_distance_func)
89 const std::vector<Real> & vertex_distance_func)
const 91 libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());
94 vmin = vertex_distance_func.front(),
97 for (
const auto & val : vertex_distance_func)
104 return (vmin*vmax < 0.);
110 const std::vector<Real> & vertex_distance_func)
113 libmesh_assert_equal_to (vertex_distance_func.size(), elem.
n_vertices());
121 if (this->
is_outside(elem, vertex_distance_func))
129 else if (this->
is_inside(elem, vertex_distance_func))
136 libmesh_assert (this->
is_cut (elem, vertex_distance_func));
145 case 1: this->
cut_1D(elem, vertex_distance_func);
break;
146 case 2: this->
cut_2D(elem, vertex_distance_func);
break;
147 case 3: this->
cut_3D(elem, vertex_distance_func);
break;
148 default: libmesh_error_msg(
"Invalid element dimension: " << elem.
dim());
155 const std::vector<Real> & vertex_distance_func)
159 for (
unsigned int e=0; e<elem.
n_edges(); e++)
170 libmesh_assert_less (el0, vertex_distance_func.size());
171 libmesh_assert_less (el1, vertex_distance_func.size());
174 d0 = vertex_distance_func[el0],
175 d1 = vertex_distance_func[el1];
180 libmesh_assert_not_equal_to (d0, d1);
184 const Real d_star = d0 / (d0 - d1);
189 const Real endpoint_tol = 0.01;
191 if ( (d_star > endpoint_tol) &&
192 (d_star < (1.-endpoint_tol)) )
194 const Point x_star = (edge->point(0)*(1-d_star) +
195 edge->point(1)*d_star);
197 std::cout <<
"adding cut point (d_star, x_star) = " 198 << d_star <<
" , " << x_star << std::endl;
210 const std::vector<Real> &)
212 libmesh_not_implemented();
218 const std::vector<Real> & vertex_distance_func)
220 #ifndef LIBMESH_HAVE_TRIANGLE 223 libMesh::err <<
"ERROR: current libMesh ElemCutter 2D implementation requires\n" 224 <<
" the \"triangle\" library!\n" 226 libmesh_not_implemented();
228 #else // OK, LIBMESH_HAVE_TRIANGLE 230 std::cout <<
"Inside cut face element!\n";
238 for (
unsigned int v=0; v<elem.
n_vertices(); v++)
240 if (vertex_distance_func[v] >= 0.)
243 if (vertex_distance_func[v] <= 0.)
298 const std::vector<Real> & vertex_distance_func)
300 #ifndef LIBMESH_HAVE_TETGEN 303 libMesh::err <<
"ERROR: current libMesh ElemCutter 3D implementation requires\n" 304 <<
" the \"tetgen\" library!\n" 306 libmesh_not_implemented();
308 #else // OK, LIBMESH_HAVE_TETGEN 310 std::cout <<
"Inside cut cell element!\n";
318 for (
unsigned int v=0; v<elem.
n_vertices(); v++)
320 if (vertex_distance_func[v] >= 0.)
323 if (vertex_distance_func[v] <= 0.)
355 std::ostringstream
name;
368 if (elem->
volume() > std::numeric_limits<Real>::epsilon())
372 if (elem->
volume() > std::numeric_limits<Real>::epsilon())
382 #endif // LIBMESH_HAVE_TRIANGLE && LIBMESH_HAVE_TETGEN std::string name(const ElemQuality q)
std::unique_ptr< ReplicatedMesh > _inside_mesh_3D
Mesh data structure replicated on all processors.
std::unique_ptr< ReplicatedMesh > _inside_mesh_2D
void find_intersection_points(const Elem &elem, const std::vector< Real > &vertex_distance_func)
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)
void operator()(const Elem &elem_in, const std::vector< Real > &vertex_distance_func)
The base class for all geometric element types.
long double max(long double a, double b)
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)
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)
OStreamProxy err(std::cerr)
std::unique_ptr< TetGenMeshInterface > _tetgen_inside
virtual unsigned int n_edges() const =0
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
virtual Real volume() const
std::unique_ptr< ReplicatedMesh > _outside_mesh_2D
virtual std::unique_ptr< Elem > build_edge_ptr(const unsigned int i)=0
long double min(long double a, double b)
A geometric point in (x,y,z) space.
const Point & point(const unsigned int i) const