@@ -59,7 +59,7 @@ namespace t8_mesh_handle
5959 */
6060template <typename mesh_class, template <typename > class ... TCompetence>
6161class element : public TCompetence <element<mesh_class, TCompetence...>>... {
62- protected :
62+ private :
6363 using SelfType
6464 = element<mesh_class, TCompetence...>; /* *< Type of the current class with all template parameters specified. */
6565 friend mesh_class; /* *< Define mesh_class as friend to be able to access e.g. the constructor. */
@@ -84,7 +84,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
8484 m_element = t8_forest_get_leaf_element_in_tree (m_mesh->m_forest , m_tree_id, m_element_id);
8585 }
8686
87- if constexpr (neighbor_cache_exists ) {
87+ if constexpr (has_face_neighbor_cache () ) {
8888 // Resize neighbor caches for clean access to the caches.
8989 const int num_faces = this ->get_num_faces ();
9090 this ->m_num_neighbors .resize (num_faces);
@@ -104,10 +104,6 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
104104 {
105105 return requires (T<SelfType>& competence) { competence.volume_cache_filled (); };
106106 }
107- /* * This variable is true if any of the given competences \a TCompetence implements
108- a function volume_cache_filled. */
109- static constexpr bool volume_cache_exists = (false || ... || volume_cache_defined<TCompetence> ());
110-
111107 /* * Helper function to check if class T implements the function vertex_cache_filled.
112108 * \tparam T The competence to be checked.
113109 * \return true if T implements the function, false if not.
@@ -118,10 +114,6 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
118114 {
119115 return requires (T<SelfType>& competence) { competence.vertex_cache_filled (); };
120116 }
121- /* * This variable is true if any of the given competences \a TCompetence implements
122- a function vertex_cache_filled. */
123- static constexpr bool vertex_cache_exists = (false || ... || vertex_cache_defined<TCompetence> ());
124-
125117 /* * Helper function to check if class T implements the function centroid_cache_filled.
126118 * \tparam T The competence to be checked.
127119 * \return true if T implements the function, false if not.
@@ -132,10 +124,6 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
132124 {
133125 return requires (T<SelfType>& competence) { competence.centroid_cache_filled (); };
134126 }
135- /* * This variable is true if any of the given competences \a TCompetence implements
136- a function centroid_cache_filled. */
137- static constexpr bool centroid_cache_exists = (false || ... || centroid_cache_defined<TCompetence> ());
138-
139127 /* * Helper function to check if class T implements the function neighbor_cache_filled.
140128 * \tparam T The competence to be checked.
141129 * \return true if T implements the function, false if not.
@@ -146,9 +134,6 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
146134 {
147135 return requires (T<SelfType>& competence) { competence.neighbor_cache_filled (0 ); };
148136 }
149- /* * This variable is true if any of the given competences \a TCompetence implements
150- a function neighbor_cache_filled. */
151- static constexpr bool neighbor_cache_exists = (false || ... || neighbor_cache_defined<TCompetence> ());
152137
153138 public:
154139 // --- Public functions to check if caches exist. ---
@@ -159,7 +144,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
159144 static constexpr bool
160145 has_volume_cache ()
161146 {
162- return volume_cache_exists ;
147+ return ( false || ... || volume_cache_defined<TCompetence> ()) ;
163148 }
164149 /* *
165150 * Function that checks if a cache for the vertex coordinates exists.
@@ -168,7 +153,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
168153 static constexpr bool
169154 has_vertex_cache ()
170155 {
171- return vertex_cache_exists ;
156+ return ( false || ... || vertex_cache_defined<TCompetence> ()) ;
172157 }
173158
174159 /* *
@@ -178,7 +163,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
178163 static constexpr bool
179164 has_centroid_cache ()
180165 {
181- return centroid_cache_exists ;
166+ return ( false || ... || centroid_cache_defined<TCompetence> ()) ;
182167 }
183168
184169 /* *
@@ -188,7 +173,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
188173 static constexpr bool
189174 has_face_neighbor_cache ()
190175 {
191- return neighbor_cache_exists ;
176+ return ( false || ... || neighbor_cache_defined<TCompetence> ()) ;
192177 }
193178
194179 // --- Functionality of the element. In each function, it is checked if a cached version exists (and is used then). ---
@@ -235,7 +220,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
235220 double
236221 get_volume () const
237222 {
238- if constexpr (volume_cache_exists ) {
223+ if constexpr (has_volume_cache () ) {
239224 if (this ->volume_cache_filled ()) {
240225 return this ->m_volume .value ();
241226 }
@@ -255,7 +240,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
255240 get_vertex_coordinates () const
256241 {
257242 // Check if we have a cached version and if the cache has already been filled.
258- if constexpr (vertex_cache_exists ) {
243+ if constexpr (has_vertex_cache () ) {
259244 if (this ->vertex_cache_filled ()) {
260245 return this ->m_vertex_coordinates ;
261246 }
@@ -269,7 +254,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
269254 t8_forest_element_coordinate (m_mesh->m_forest , m_tree_id, element, icorner, vertex_coordinates[icorner].data ());
270255 }
271256 // Fill the cache in the cached version.
272- if constexpr (vertex_cache_exists ) {
257+ if constexpr (has_vertex_cache () ) {
273258 this ->m_vertex_coordinates = std::move (vertex_coordinates);
274259 return this ->m_vertex_coordinates ;
275260 }
@@ -285,15 +270,15 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
285270 get_centroid () const
286271 {
287272 // Check if we have a cached version and if the cache has already been filled.
288- if constexpr (centroid_cache_exists ) {
273+ if constexpr (has_centroid_cache () ) {
289274 if (this ->centroid_cache_filled ()) {
290275 return this ->m_centroid .value ();
291276 }
292277 }
293278 t8_3D_point coordinates;
294279 t8_forest_element_centroid (m_mesh->m_forest , m_tree_id, get_element (), coordinates.data ());
295280 // Fill the cache in the cached version.
296- if constexpr (centroid_cache_exists ) {
281+ if constexpr (has_centroid_cache () ) {
297282 this ->m_centroid = coordinates;
298283 }
299284 return coordinates;
@@ -304,13 +289,12 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
304289 * \param [in] face The index of the face across which the face neighbors are searched.
305290 * \param [out] dual_faces On output the face id's of the neighboring elements' faces.
306291 * \return Vector of length num_neighbors with pointers to the elements neighboring at the given face.
307- * \note For ghost elements, the functionality to calculate face neighbors is currently not provided.
308292 */
309293 std::vector<const SelfType*>
310294 get_face_neighbors (int face, std::optional<std::reference_wrapper<std::vector<int >>> dual_faces = std::nullopt ) const
311295 {
312296 SC_CHECK_ABORT (!m_is_ghost_element, " get_face_neighbors is not implemented for ghost elements.\n " );
313- if constexpr (neighbor_cache_exists ) {
297+ if constexpr (has_face_neighbor_cache () ) {
314298 if (this ->neighbor_cache_filled (face)) {
315299 if (dual_faces) {
316300 dual_faces->get () = this ->m_dual_faces [face];
@@ -334,7 +318,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
334318 for (int ineighs = 0 ; ineighs < num_neighbors; ineighs++) {
335319 neighbors_handle.push_back (&((*m_mesh)[neighids[ineighs]]));
336320 }
337- if constexpr (neighbor_cache_exists ) {
321+ if constexpr (has_face_neighbor_cache () ) {
338322 // Also store num_neighbors in cache to indicate that the cache is filled if a face does not have any neighbor.
339323 this ->m_num_neighbors [face] = num_neighbors;
340324 this ->m_dual_faces [face].assign (dual_faces_internal, dual_faces_internal + num_neighbors);
@@ -347,7 +331,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
347331 T8_FREE (dual_faces_internal);
348332 T8_FREE (neighids);
349333 }
350- if constexpr (neighbor_cache_exists ) {
334+ if constexpr (has_face_neighbor_cache () ) {
351335 return this ->m_neighbors [face];
352336 }
353337 return neighbors_handle;
@@ -358,7 +342,7 @@ class element: public TCompetence<element<mesh_class, TCompetence...>>... {
358342 */
359343 void
360344 fill_face_neighbor_cache () const
361- requires (neighbor_cache_exists )
345+ requires (has_face_neighbor_cache () )
362346 {
363347 for (int iface = 0 ; iface < get_num_faces (); iface++) {
364348 get_face_neighbors (iface);
0 commit comments