libMesh
|
A C++ class to refine a simplicial mesh via splitting edges that exceed a given metric. More...
#include <simplex_refiner.h>
Public Member Functions | |
SimplexRefiner (UnstructuredMesh &mesh) | |
The constructor. More... | |
bool | refine_elements () |
Finds elements which exceed the requested metric and refines them via subdivision into new simplices as necessary. More... | |
virtual void | set_desired_volume_function (FunctionBase< Real > *desired) |
Set a function giving desired element volume as a function of position. More... | |
virtual FunctionBase< Real > * | get_desired_volume_function () |
Get the function giving desired element volume as a function of position, or nullptr if no such function has been set. More... | |
Real & | desired_volume () |
Sets and/or gets the desired element volume. More... | |
Protected Member Functions | |
std::size_t | refine_via_edges () |
Finds elements which exceed the requested metric and refines them via inserting new midedge nodes and bisecting as necessary. More... | |
bool | should_refine_elem (Elem &elem) |
Checks if an element exceeds the requested metric. More... | |
std::size_t | refine_via_edges (Elem &elem, dof_id_type coarse_id) |
Checks if an element exceeds the requested metric or if it has an edge which was split by a neighboring metric and refines it (bisecting it, removing it from the mesh to be replaced by the two subelements, and recursing into those) if necessary. More... | |
Private Types | |
typedef std::vector< std::tuple< dof_id_type, dof_id_type, dof_id_type, processor_id_type > > | refinement_datum |
Private Member Functions | |
void | fill_refinement_datum (std::pair< Node *, Node *> vertices, refinement_datum &vec) |
Helper for responding to edge queries. More... | |
Private Attributes | |
UnstructuredMesh & | _mesh |
Reference to the mesh which is to be refined. More... | |
Real | _desired_volume |
The desired volume for the elements in the resulting mesh. More... | |
std::unique_ptr< FunctionBase< Real > > | _desired_volume_func |
Location-dependent volume requirements. More... | |
std::map< std::pair< Node *, Node * >, Node * > | new_nodes |
Keep track of new nodes on edges. More... | |
std::vector< std::unique_ptr< Elem > > | new_elements |
Keep track of elements to add so we don't invalidate iterators during an iteration over elements. More... | |
std::unordered_map< processor_id_type, std::vector< std::pair< dof_id_type, dof_id_type > > > | edge_queries |
Keep track of coarse remote edges for which we should query about additional point splits. More... | |
std::unordered_map< dof_id_type, std::unordered_map< Point, Elem * > > | added_elements |
Keep track of elements added within each original element, so we can answer queries about them from other processors. More... | |
std::unordered_map< Elem *, dof_id_type > | coarse_parent |
Keep track of added elements' original coarse ids, so we get subsequent splits assigned to the correct coarse id. More... | |
std::unordered_map< processor_id_type, std::unique_ptr< Elem > > | proxy_elements |
Keep track of what processor an element's neighbors came from. More... | |
A C++ class to refine a simplicial mesh via splitting edges that exceed a given metric.
Definition at line 49 of file simplex_refiner.h.
|
private |
Definition at line 171 of file simplex_refiner.h.
|
explicit |
The constructor.
A reference to the mesh containing the elements which are to be split by edge subdivision must be provided.
At the time of refining this mesh should be conforming.
Definition at line 45 of file simplex_refiner.C.
|
inline |
Sets and/or gets the desired element volume.
Set to zero to disable volume constraint.
If a desired_volume_function
is set, then desired_volume()
should be used to set a minimum desired volume; this will reduce "false negatives" by suggesting how finely to sample desired_volume_function
inside large elements, where ideally the desired_volume_function
will be satisfied in the element interior and not just at the element vertices.
Definition at line 93 of file simplex_refiner.h.
References _desired_volume.
Referenced by main(), should_refine_elem(), and SimplexRefinementTest::testRefinement().
|
private |
Helper for responding to edge queries.
Definition at line 567 of file simplex_refiner.C.
References new_nodes.
Referenced by refine_via_edges().
|
virtual |
Get the function giving desired element volume as a function of position, or nullptr
if no such function has been set.
Definition at line 561 of file simplex_refiner.C.
References _desired_volume_func.
Referenced by should_refine_elem().
bool libMesh::SimplexRefiner::refine_elements | ( | ) |
Finds elements which exceed the requested metric and refines them via subdivision into new simplices as necessary.
true
iff the mesh actually changed. Definition at line 52 of file simplex_refiner.C.
References _mesh, libMesh::MeshBase::is_prepared(), libMesh::MeshBase::prepare_for_use(), and refine_via_edges().
Referenced by main(), and SimplexRefinementTest::testRefinement().
|
protected |
Finds elements which exceed the requested metric and refines them via inserting new midedge nodes and bisecting as necessary.
Definition at line 312 of file simplex_refiner.C.
References _mesh, libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), added_elements, libMesh::Elem::build(), coarse_parent, libMesh::ParallelObject::comm(), edge_queries, fill_refinement_datum(), libMesh::DofObject::id(), libMesh::MeshBase::is_replicated(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_equal_points(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::make_range(), TIMPI::Communicator::max(), libMesh::Elem::neighbor_ptr(), new_elements, new_nodes, libMesh::MeshBase::node_ptr(), libMesh::NODEELEM, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), proxy_elements, libMesh::remote_elem, libMesh::MeshBase::renumber_elem(), libMesh::MeshBase::renumber_node(), libMesh::DofObject::set_unique_id(), and libMesh::Elem::vertex_average().
Referenced by refine_elements(), and refine_via_edges().
|
protected |
Checks if an element exceeds the requested metric or if it has an edge which was split by a neighboring metric and refines it (bisecting it, removing it from the mesh to be replaced by the two subelements, and recursing into those) if necessary.
The coarse_id
specifies which coarse element this one is (or which this one was originally refined from), to make global communication easier after local refinement is done.
Definition at line 111 of file simplex_refiner.C.
References _desired_volume_func, _mesh, libMesh::MeshBase::add_point(), libMesh::BoundaryInfo::add_side(), added_elements, libMesh::BoundaryInfo::boundary_ids(), coarse_parent, libMesh::MeshBase::delete_elem(), edge_queries, libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::get_extra_integer(), libMesh::DofObject::id(), libMesh::DofObject::invalid_id, libMesh::MeshBase::is_serial(), libMesh::Elem::level(), libMesh::make_range(), libMesh::DofObject::n_extra_integers(), libMesh::Elem::n_sides(), libMesh::Elem::neighbor_ptr(), new_elements, new_nodes, libMesh::Elem::node_ptr(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), proxy_elements, libMesh::Real, refine_via_edges(), libMesh::remote_elem, libMesh::BoundaryInfo::remove(), should_refine_elem(), libMesh::TOLERANCE, libMesh::TRI3, libMesh::Elem::type(), libMesh::Elem::vertex_average(), libMesh::MeshTools::volume(), and libMesh::Elem::volume().
|
virtual |
Set a function giving desired element volume as a function of position.
Set this to nullptr to disable position-dependent volume constraint (falling back on desired_volume()).
Definition at line 551 of file simplex_refiner.C.
References libMesh::FunctionBase< Output >::clone().
|
protected |
Checks if an element exceeds the requested metric.
Definition at line 65 of file simplex_refiner.C.
References desired_volume(), get_desired_volume_function(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::Elem::n_vertices(), libMesh::Elem::point(), libMesh::Real, libMesh::TOLERANCE, libMesh::MeshTools::volume(), and libMesh::Elem::volume().
Referenced by refine_via_edges().
|
private |
The desired volume for the elements in the resulting mesh.
Definition at line 137 of file simplex_refiner.h.
Referenced by desired_volume().
|
private |
Location-dependent volume requirements.
Definition at line 142 of file simplex_refiner.h.
Referenced by get_desired_volume_function(), and refine_via_edges().
|
private |
Reference to the mesh which is to be refined.
Definition at line 132 of file simplex_refiner.h.
Referenced by refine_elements(), and refine_via_edges().
|
private |
Keep track of elements added within each original element, so we can answer queries about them from other processors.
If the element originally with id i is split, its replacements e1 and e2 will be in added_elements[i][ei.vertex_average()]
Definition at line 185 of file simplex_refiner.h.
Referenced by refine_via_edges().
|
private |
Keep track of added elements' original coarse ids, so we get subsequent splits assigned to the correct coarse id.
Definition at line 191 of file simplex_refiner.h.
Referenced by refine_via_edges().
|
private |
Keep track of coarse remote edges for which we should query about additional point splits.
Definition at line 163 of file simplex_refiner.h.
Referenced by refine_via_edges().
|
private |
Keep track of elements to add so we don't invalidate iterators during an iteration over elements.
Definition at line 154 of file simplex_refiner.h.
Referenced by refine_via_edges().
Keep track of new nodes on edges.
A new node x in between node y and node z (with y<z) will be reflected by new_nodes[(y,z)]=x
Definition at line 148 of file simplex_refiner.h.
Referenced by fill_refinement_datum(), and refine_via_edges().
|
private |
Keep track of what processor an element's neighbors came from.
Definition at line 196 of file simplex_refiner.h.
Referenced by refine_via_edges().