34 #include <unordered_map>
56 template <
typename geometry_type,
typename... _args>
60 std::unique_ptr<t8_geometry> geom_ptr = std::make_unique<geometry_type> (std::forward<_args> (args)...);
61 return add_geometry<geometry_type> (std::move (geom_ptr));
80 const size_t hash = std::hash<std::string> {}(name);
92 auto found = registered_geometries.find (hash);
93 if (found != registered_geometries.end ()) {
94 return found->second.get ();
106 return registered_geometries.size ();
118 T8_ASSERT (registered_geometries.size () == 1);
119 return active_geometry;
141 update_tree (cmesh, gtreeid);
142 return active_geometry;
157 update_tree (cmesh, gtreeid);
158 active_geometry->
t8_geom_evaluate (cmesh, gtreeid, ref_coords, num_coords, out_coords);
171 const size_t num_coords,
double *out_coords)
173 update_tree (cmesh, gtreeid);
186 update_tree (cmesh, gtreeid);
199 update_tree (cmesh, gtreeid);
210 template <
typename geometry_type>
211 inline geometry_type *
212 add_geometry (std::unique_ptr<t8_geometry> geom)
214 t8_debugf (
"Registering geometry with name %s\n", geom->t8_geom_get_name ().c_str ());
215 const size_t hash = geom->t8_geom_get_hash ();
216 if (registered_geometries.find (hash) == registered_geometries.end ()) {
217 registered_geometries.emplace (hash, std::move (geom));
219 if (registered_geometries.size () == 1) {
220 active_geometry = registered_geometries.at (hash).get ();
222 return static_cast<geometry_type *
> (registered_geometries.at (hash).get ());
234 std::unordered_map<size_t, std::unique_ptr<t8_geometry>> registered_geometries;
This structure holds the connectivity data of the coarse mesh.
Definition: t8_cmesh_types.h:88
Definition: t8_geometry_handler.hxx:37
t8_geometry * get_unique_geometry()
If a geometry handler only has one registered geometry, get a pointer to this geometry.
Definition: t8_geometry_handler.hxx:116
t8_geometry * get_geometry(const std::string &name)
Find a geometry by its name.
Definition: t8_geometry_handler.hxx:78
void evaluate_tree_geometry_jacobian(t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords)
Evaluate the Jacobian of the geometry of the provided tree at the given reference coordinates.
Definition: t8_geometry_handler.hxx:170
void evaluate_tree_geometry(t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords)
Evaluate the geometry of the provided tree at the given reference coordinates.
Definition: t8_geometry_handler.hxx:154
t8_geometry * get_tree_geometry(t8_cmesh_t cmesh, t8_gloidx_t gtreeid)
Get the geometry of the provided tree.
Definition: t8_geometry_handler.hxx:139
geometry_type * register_geometry(_args &&...args)
Register a geometry with the geometry handler.
Definition: t8_geometry_handler.hxx:58
t8_geometry * get_geometry(const size_t hash)
Find a geometry by its hash.
Definition: t8_geometry_handler.hxx:90
void deactivate_tree()
Deactivate the current active tree.
Definition: t8_geometry_handler.hxx:127
size_t get_num_geometries() const
Get the number of registered geometries.
Definition: t8_geometry_handler.hxx:104
~t8_geometry_handler()
Destructor.
Definition: t8_geometry_handler.hxx:47
t8_geometry_handler()
Constructor.
Definition: t8_geometry_handler.hxx:42
bool tree_negative_volume(const t8_cmesh_t cmesh, const t8_gloidx_t gtreeid)
Check if the volume of a tree is negative.
Definition: t8_geometry_handler.hxx:197
t8_geometry_type_t get_tree_geometry_type(t8_cmesh_t cmesh, t8_gloidx_t gtreeid)
Get the geometry type of the provided tree.
Definition: t8_geometry_handler.hxx:184
The base class for all geometries.
Definition: t8_geometry_base.hxx:48
virtual bool t8_geom_tree_negative_volume() const
Check if the currently active tree has a negative volume.
Definition: t8_geometry_base.hxx:138
virtual void t8_geom_evaluate(t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *out_coords) const =0
Maps points in the reference space .
virtual void t8_geom_evaluate_jacobian(t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords, double *jacobian) const =0
Compute the jacobian of the t8_geom_evaluate map at a point in the reference space .
virtual t8_geometry_type_t t8_geom_get_type() const =0
Get the type of this geometry.
This is the administrative header file for t8code.
int64_t t8_gloidx_t
A type for global indexing that holds really big numbers.
Definition: t8.h:100
void t8_debugf(const char *fmt,...)
Log a message, no matter what rank, with priority SC_LP_DEBUG.
Definition: t8.c:123
#define T8_ASSERT(c)
Widely used assertion.
Definition: t8.h:71
Typedef for the t8_geometry class in order to be usable as a pointer from .c files.
enum t8_geometry_type t8_geometry_type_t
This enumeration contains all possible geometries.
Implements the base pure virtual struct t8_geometry which provides a general template for all geometr...