libMesh
Loading...
Searching...
No Matches
simplex_refiner.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19#ifndef LIBMESH_SIMPLEX_REFINER_H
20#define LIBMESH_SIMPLEX_REFINER_H
21
22#include "libmesh/libmesh_config.h"
23
24// Local Includes
25#include "libmesh/elem.h"
26#include "libmesh/function_base.h"
27
28#include <map>
29#include <memory>
30#include <tuple>
31#include <unordered_map>
32#include <utility>
33#include <vector>
34
35namespace libMesh
36{
37
38// Forward Declarations
39class UnstructuredMesh;
40class Node;
41
50{
51public:
58 explicit
60
67 bool refine_elements ();
68
74 virtual void set_desired_volume_function (FunctionBase<Real> * desired);
75
81
94
95protected:
96
103 std::size_t refine_via_edges();
104
108 bool should_refine_elem(Elem & elem);
109
124 std::size_t refine_via_edges(Elem & elem,
125 dof_id_type coarse_id);
126
127private:
128
133
138
142 std::unique_ptr<FunctionBase<Real>> _desired_volume_func;
143
148 std::map<std::pair<Node *, Node *>, Node *> new_nodes;
149
154 std::vector<std::unique_ptr<Elem>> new_elements;
155
160 std::unordered_map
162 std::vector<std::pair<dof_id_type, dof_id_type>>>
164
165 // All the "refine first and second to get third" that was
166 // done to this edge, including the processor to assign the new node
167 // to.
168 typedef
169 std::vector<std::tuple<dof_id_type, dof_id_type,
172
176 void fill_refinement_datum(std::pair<Node *, Node *> vertices,
177 refinement_datum & vec);
178
185 std::unordered_map<dof_id_type, std::unordered_map<Point, Elem *>> added_elements;
186
191 std::unordered_map<Elem *, dof_id_type> coarse_parent;
192
196 std::unordered_map<processor_id_type, std::unique_ptr<Elem>> proxy_elements;
197};
198
199
200} // namespace libMesh
201
202#endif // ifndef LIBMESH_SIMPLEX_REFINER_H
This is the base class from which all geometric element types are derived.
Definition elem.h:96
Base class for functors that can be evaluated at a point and (optionally) time.
A Node is like a Point, but with more information.
Definition node.h:55
A C++ class to refine a simplicial mesh via splitting edges that exceed a given metric.
std::size_t refine_via_edges()
Finds elements which exceed the requested metric and refines them via inserting new midedge nodes and...
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.
virtual void set_desired_volume_function(FunctionBase< Real > *desired)
Set a function giving desired element volume as a function of position.
bool refine_elements()
Finds elements which exceed the requested metric and refines them via subdivision into new simplices ...
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 o...
bool should_refine_elem(Elem &elem)
Checks if an element exceeds the requested metric.
std::map< std::pair< Node *, Node * >, Node * > new_nodes
Keep track of new nodes on edges.
Real _desired_volume
The desired volume for the elements in the resulting mesh.
std::vector< std::tuple< dof_id_type, dof_id_type, dof_id_type, processor_id_type > > refinement_datum
virtual FunctionBase< Real > * get_desired_volume_function()
Get the function giving desired element volume as a function of position, or nullptr if no such funct...
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 correc...
std::unordered_map< processor_id_type, std::unique_ptr< Elem > > proxy_elements
Keep track of what processor an element's neighbors came from.
std::unique_ptr< FunctionBase< Real > > _desired_volume_func
Location-dependent volume requirements.
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.
void fill_refinement_datum(std::pair< Node *, Node * > vertices, refinement_datum &vec)
Helper for responding to edge queries.
Real & desired_volume()
Sets and/or gets the desired element volume.
UnstructuredMesh & _mesh
Reference to the mesh which is to be refined.
The UnstructuredMesh class is derived from the MeshBase class.
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
Definition id_types.h:104