Go to the documentation of this file.
23 #include "libmesh/mesh_tools.h"
24 #include "libmesh/mesh_subdivision_support.h"
25 #include "libmesh/boundary_info.h"
32 std::vector<const Node *> & nodes)
38 nodes.resize(valence + 6);
50 unsigned int j, i = 1;
57 nb = static_cast<const Tri3Subdivision *>(nb->
neighbor_ptr(j));
78 nb = static_cast<const Tri3Subdivision *>(nb->
neighbor_ptr(j));
82 nb = static_cast<const Tri3Subdivision *>(nb->
neighbor_ptr(j));
92 std::vector<Elem *> new_elements;
94 const bool mesh_has_boundary_data =
97 std::vector<Elem *> new_boundary_elements;
98 std::vector<short int> new_boundary_sides;
99 std::vector<boundary_id_type> new_boundary_ids;
102 std::vector<boundary_id_type> ids;
106 libmesh_assert_equal_to(elem->type(),
TRI3);
110 tri->subdomain_id() = elem->subdomain_id();
111 tri->set_node(0) = elem->node_ptr(0);
112 tri->set_node(1) = elem->node_ptr(1);
113 tri->set_node(2) = elem->node_ptr(2);
115 if (mesh_has_boundary_data)
117 for (
auto side : elem->side_index_range())
121 for (
const auto &
id : ids)
124 new_boundary_ids.push_back(
id);
125 new_boundary_elements.push_back(tri);
126 new_boundary_sides.push_back(side);
134 new_elements.push_back(tri);
139 if (mesh_has_boundary_data)
142 libmesh_assert_greater(new_boundary_elements.size(), 0);
146 libmesh_assert_equal_to(new_boundary_sides.size(), new_boundary_elements.size());
147 libmesh_assert_equal_to(new_boundary_sides.size(), new_boundary_ids.size());
152 new_boundary_sides[s],
153 new_boundary_ids[s]);
180 std::unordered_map<dof_id_type, std::vector<const Elem *>> nodes_to_elem_map;
186 std::vector<const Node *> neighbors;
188 const unsigned int valence =
189 cast_int<unsigned int>(neighbors.size());
190 libmesh_assert_greater(valence, 1);
191 node->set_valence(valence);
211 for (
auto i : elem->side_index_range())
213 if (elem->neighbor_ptr(i) ==
nullptr)
215 sd_elem->set_ghost(
true);
217 if (elem->neighbor_ptr(
next[i]))
222 if (elem->neighbor_ptr(
prev[i]))
235 static const Real tol = 1e-5;
238 std::vector<Tri3Subdivision *> ghost_elems;
239 std::vector<Node *> ghost_nodes;
241 for (
unsigned int eid = 0; eid <
n_elem; ++eid)
254 libmesh_assert_not_equal_to(elem->
neighbor_ptr(i), elem);
261 for (
unsigned int l=0;l<4;l++)
272 Node * node =
nullptr;
273 for (
auto & ghost_node : ghost_nodes)
274 if ((*ghost_node - point).
norm() < tol * (elem->
point(k) - point).
norm())
284 ghost_nodes.push_back(node);
291 ghost_elems.push_back(newelem);
331 libmesh_assert_not_equal_to(elem->
neighbor_ptr(i), elem);
342 Node * node =
nullptr;
343 for (
auto & ghost_node : ghost_nodes)
344 if ((*ghost_node - point).
norm() < tol * (elem->
point(i) - point).
norm())
354 ghost_nodes.push_back(node);
358 ghost_elems.push_back(newelem);
377 std::vector<Tri3Subdivision *> missing_ghost_elems;
378 for (
auto & elem : ghost_elems)
382 for (
auto i : elem->side_index_range())
384 if (elem->neighbor_ptr(i) ==
nullptr &&
385 elem->neighbor_ptr(
prev[i]) !=
nullptr)
391 unsigned int n_nb = 0;
392 while (nb1 !=
nullptr && nb1->
id() != elem->id())
401 libmesh_assert_not_equal_to(nb2->id(), elem->id());
406 if (elem->node_ptr(
next[i])->id() == nb2->node_ptr(
prev[j])->id())
416 Point point = nb2->point(j) + nb2->point(
prev[j]) - nb2->point(
next[j]);
421 Node * node =
nullptr;
422 for (
auto & ghost_node : ghost_nodes)
423 if ((*ghost_node - point).
norm() < tol * (nb2->point(j) - point).
norm())
433 ghost_nodes.push_back(node);
438 newelem->
set_node(0) = nb2->node_ptr(j);
444 nb2->set_neighbor(
prev[j], newelem);
457 newelem->
set_node(1) = elem->node_ptr(i);
464 elem->set_neighbor(i, newelem);
465 nb2->set_neighbor(
prev[j], newelem);
467 missing_ghost_elems.push_back(newelem);
474 for (
auto & elem : missing_ghost_elems)
std::vector< boundary_id_type > boundary_ids(const Node *node) const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
virtual dof_id_type n_elem() const =0
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
The libMesh namespace provides an interface to certain functionality in the library.
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
void prepare_subdivision_properties()
Prepares the element for use by reordering the nodes such that the irregular node (valence !...
virtual const Elem * elem_ptr(const dof_id_type i) const =0
void remove(const Node *node)
Removes the boundary conditions associated with node node, if any exist.
const Point & point(const unsigned int i) const
virtual SimpleRange< element_iterator > element_ptr_range()=0
This is the MeshBase class.
virtual SimpleRange< node_iterator > node_ptr_range()=0
bool is_subdivision_updated() const
unsigned int local_node_number(unsigned int node_id) const
A Point defines a location in LIBMESH_DIM dimensional Real space.
Node * get_ordered_node(unsigned int node_id) const
virtual Elem * insert_elem(Elem *e)=0
Insert elem e to the element array, preserving its id and replacing/deleting any existing element wit...
A Node is like a Point, but with more information.
std::size_t n_boundary_ids() const
virtual Node *& set_node(const unsigned int i)
unsigned int get_ordered_valence(unsigned int node_id) const
void set_ghost(bool ghosted)
Sets the boolean flag identifying ghost elements.
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
IntRange< unsigned short > side_index_range() const
This is the base class from which all geometric element types are derived.
MetaPhysicL::DualNumber< T, D > norm(const MetaPhysicL::DualNumber< T, D > &in)
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
const Elem * neighbor_ptr(unsigned int i) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly ecreated (or read) mesh for use.
The Tri3Subdivision element is a three-noded subdivision surface shell element used in mechanics calc...
const Node * node_ptr(const unsigned int i) const
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure.
virtual ElemType type() const =0