14 #include "libmesh/type_vector.h" 15 #include "libmesh/point.h" 16 #include "libmesh/elem.h" 17 #include "libmesh/fe_base.h" 18 #include "libmesh/quadrature_gauss.h" 28 "Removes elements lying \"near\" another mesh. The proximity is examined by the distance " 30 "the element's centroid to the faces of elements of the \"proximity_mesh\"");
32 "Mesh providing the deletion criterion");
36 "The distance from the centroid of elements in the 'input' mesh to elements in the " 37 "'proximity_mesh' under which they are marked for deletion");
42 "Order of the face quadrature used to find the nearest face in the " 43 "'proximity_mesh'. Default is CONSTANT");
50 _proximity_mesh(getMesh(
"proximity_mesh")),
51 _distance(getParam<
Real>(
"distance"))
55 std::unique_ptr<MeshBase>
60 _pl->enable_out_of_mesh_mode();
65 std::vector<Point> all_side_qps;
66 const auto & order = getParam<MooseEnum>(
"side_order");
71 const auto dim = elem->dim();
72 for (
const auto side_i :
make_range(elem->n_sides()))
75 if (elem->neighbor_ptr(side_i))
77 const std::unique_ptr<const Elem> face = elem->build_side_ptr(side_i);
78 std::unique_ptr<libMesh::FEBase> fe(
81 fe->attach_quadrature_rule(&qface);
82 const auto & qpoints = fe->get_xyz();
83 fe->reinit(elem, side_i);
84 all_side_qps.insert(all_side_qps.end(), qpoints.begin(), qpoints.end());
87 mooseAssert(!all_side_qps.empty(),
"Should have found side Qps");
88 _kd_tree = std::make_unique<KDTree>(all_side_qps, 1);
101 const auto delete_due_to_point = [
this](
const Point & pt) ->
bool 108 std::vector<Real> distance_sqr(2);
109 std::vector<std::size_t> return_indices(2);
110 _kd_tree->neighborSearch(pt, 1, return_indices, distance_sqr);
118 const auto centroid = elem->vertex_average();
119 if (delete_due_to_point(centroid))
123 for (
const auto & node : elem->node_ref_range())
124 if (delete_due_to_point(node))
std::unique_ptr< FEGenericBase< Real > > build(const unsigned int dim, const FEType &fet)
static MooseEnum getQuadratureOrderEnum()
Return the potential selections for the order of the quadrature, with an 'auto' default.
std::shared_ptr< KDTree > _kd_tree
KD Tree to find the nearest side Qp in the proximity mesh.
This class deletes elements from the mesh data structure after it has been generated or read but befo...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
const Real _distance
Distance for deletion criterion.
static InputParameters validParams()
Real distance(const Point &p)
Order stringToEnum< Order >(const std::string &s)
auto max(const L &left, const R &right)
virtual bool shouldDelete(const Elem *elem) override
Method that returns a Boolean indicating whether an element should be removed from the mesh...
static InputParameters validParams()
virtual std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
DeleteElementsNearMeshGenerator(const InputParameters ¶meters)
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
std::unique_ptr< MeshBase > & _proximity_mesh
Mesh used to define the proximity deletion criterion.
IntRange< T > make_range(T beg, T end)
registerMooseObject("MooseApp", DeleteElementsNearMeshGenerator)
Deletes elements close to another mesh.
std::unique_ptr< libMesh::PointLocatorBase > _pl
Point locator to weed out elements inside the proximity mesh.