From 62faded40ad0e3f0ec8dabb405cf6f2fe59b2ae1 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Thu, 5 Sep 2024 13:21:05 +0200 Subject: [PATCH 01/11] add first multilevel design concept --- example/CMakeLists.txt | 2 + example/multilevel/t8_example_multilevel.cxx | 64 ++++++++ example/multilevel/t8_multilevel_concept.hxx | 156 +++++++++++++++++++ 3 files changed, 222 insertions(+) create mode 100644 example/multilevel/t8_example_multilevel.cxx create mode 100644 example/multilevel/t8_multilevel_concept.hxx diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index ad32fd28a7..e9f30cf89d 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -73,3 +73,5 @@ add_t8_example( NAME t8_example_gauss_blob SOURCES remove/t8_exampl add_t8_example( NAME t8_example_empty_trees SOURCES remove/t8_example_empty_trees.cxx ) add_t8_example( NAME t8_version SOURCES version/t8_version.cxx ) + +add_t8_example( NAME t8_example_multilevel SOURCES multilevel/t8_example_multilevel.cxx multilevel/t8_multilevel_concept.hxx) diff --git a/example/multilevel/t8_example_multilevel.cxx b/example/multilevel/t8_example_multilevel.cxx new file mode 100644 index 0000000000..4487559ac0 --- /dev/null +++ b/example/multilevel/t8_example_multilevel.cxx @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +template +using scheme_v = std::variant; + +using scheme_container = std::vector< + scheme_v, multilevel_scheme > >; + +int +main () +{ + typedef enum { triangle_eclass, quad_eclass, triangle_m_eclass, quad_m_eclass } eclass; + + scheme_container schemes { triangle_scheme (), quad_scheme (), multilevel_scheme (), + multilevel_scheme () }; + + triangle tri; + tri.level = 1; + tri.orientation = 0; + element_t *tri_elem = (element_t *) (&tri); + + std::visit ([tri_elem] (auto &&scheme) { + std::cout << "Triangle level: " << scheme.get_level (tri_elem) << std::endl; + std::cout << "Triangle num children: " << scheme.get_num_children (tri_elem) << std::endl; + std::cout << "Triangle num vertices: " << scheme.get_num_vertices () << std::endl; + }, schemes[triangle_eclass]); + + quad q; + q.level = 1; + element_t *q_elem = (element_t *) (&q); + + std::visit ([q_elem] (auto &&scheme) { + std::cout << "Quad level: " << scheme.get_level (q_elem) << std::endl; + std::cout << "Quad num children: " << scheme.get_num_children (q_elem) << std::endl; + std::cout << "Quad num vertices: " << scheme.get_num_vertices () << std::endl; + }, schemes[quad_eclass]); + + multilevel_element tri_m; + tri_m.elem = tri; + tri_m.multilevel_level = 1; + element_t *tri_m_elem = (element_t *) (&tri_m); + + multilevel_element q_m; + q_m.elem = q; + q_m.multilevel_level = 2; + element_t *q_m_elem = (element_t *) (&q_m); + + std::visit ([tri_m_elem] (auto &&scheme) { + std::cout << "Multilevel triangle level: " << scheme.get_level (tri_m_elem) << std::endl; + std::cout << "Multilevel triangle num children: " << scheme.get_num_children (tri_m_elem) << std::endl; + std::cout << "Multilevel triangle num vertices: " << scheme.get_num_vertices () << std::endl; + }, schemes[triangle_m_eclass]); + + std::visit ([q_m_elem] (auto &&scheme) { + std::cout << "Multilevel quad level: " << scheme.get_level (q_m_elem) << std::endl; + std::cout << "Multilevel quad num children: " << scheme.get_num_children (q_m_elem) << std::endl; + std::cout << "Multilevel quad num vertices: " << scheme.get_num_vertices () << std::endl; + }, schemes[quad_m_eclass]); + + return 0; +} diff --git a/example/multilevel/t8_multilevel_concept.hxx b/example/multilevel/t8_multilevel_concept.hxx new file mode 100644 index 0000000000..4ad0275880 --- /dev/null +++ b/example/multilevel/t8_multilevel_concept.hxx @@ -0,0 +1,156 @@ +struct triangle +{ + int level; + int orientation; +}; + +struct quad +{ + int level; +}; + +// Multilevel element, which adds the actual hierarchical level of the element +// The level inside the element will determine its size +template +struct multilevel_element +{ + eclass elem; + int multilevel_level; +}; + +// Opaque pointer to cast the element type into +typedef struct element element_t; + +// Using CRTP to avoid virtual function calls +template +class scheme_base { + public: + ~scheme_base () + { + } + + int + get_level (element_t *elem) + { + // cast derived class into base class to avoid virtual functions + return static_cast (*this).get_level (elem); + }; + + int + get_num_children (element_t *elem) + { + // cast derived class into base class to avoid virtual functions + return static_cast (*this).get_num_children (elem); + }; + + int + get_num_vertices () + { + // cast derived class into base class to avoid virtual functions + return static_cast (*this).get_num_vertices (); + }; + + private: + // This way the derived class and only the derived class can use this constructor. + // This way you get an error when doing: `class triangle_scheme: public scheme_base ` + scheme_base () {}; + friend derived_scheme_t; +}; + +// inherits from base which is a template for this class +class triangle_scheme: public scheme_base { + public: + triangle_scheme () {}; + + int + get_level (element_t *elem) + { + elem_type *tri = (elem_type *) elem; + return tri->level; + }; + + int + get_num_children (element_t *elem) + { + return 4; + }; + + int + get_num_vertices () + { + return 3; + }; + + protected: + // When the multilevel class inherits from this it needs to know the element type of this scheme + using elem_type = triangle; + + private: +}; + +// inherits from base which is a template for this class +class quad_scheme: public scheme_base { + public: + quad_scheme () {}; + + int + get_level (element_t *elem) + { + elem_type *q = (elem_type *) elem; + return q->level; + }; + + int + get_num_children (element_t *elem) + { + return 4; + }; + + int + get_num_vertices () + { + return 4; + }; + + protected: + // When the multilevel class inherits from this it needs to know the element type of this scheme + using elem_type = quad; + + private: +}; + +template +class multilevel_scheme: public scheme_base>, private scheme_impl_t { + public: + using scheme_impl_t::scheme_impl_t; + using elem_type = typename scheme_impl_t::elem_type; + ~multilevel_scheme () {}; + + int + get_level (element_t *elem) + { + multilevel_element *m_elem = (multilevel_element *) elem; + return m_elem->multilevel_level; + }; + + int + get_num_children (element_t *elem) + { + multilevel_element *m_elem = (multilevel_element *) elem; + const int elem_level = scheme_impl_t::get_level ((element_t *) &(m_elem->elem)); + if (elem_level == get_level (elem)) { + return scheme_impl_t::get_num_children ((element_t *) &(m_elem->elem)) + 1; + } + else { + return 0; + } + }; + + int + get_num_vertices () + { + return scheme_impl_t::get_num_vertices (); + }; + + private: +}; From b3c97fb61bf6647e2638bbcf9e1444f5bebd16d7 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Fri, 13 Sep 2024 20:38:47 +0200 Subject: [PATCH 02/11] beautified usage --- example/CMakeLists.txt | 2 +- example/multilevel/t8_example_multilevel.cxx | 55 +++--- example/multilevel/t8_multilevel_concept.hxx | 156 ------------------ .../multilevel/t8_multilevel_concept_base.hxx | 46 ++++++ .../t8_multilevel_concept_default.hxx | 79 +++++++++ .../t8_multilevel_concept_multilevel.hxx | 50 ++++++ .../t8_multilevel_concept_scheme.hxx | 80 +++++++++ 7 files changed, 278 insertions(+), 190 deletions(-) delete mode 100644 example/multilevel/t8_multilevel_concept.hxx create mode 100644 example/multilevel/t8_multilevel_concept_base.hxx create mode 100644 example/multilevel/t8_multilevel_concept_default.hxx create mode 100644 example/multilevel/t8_multilevel_concept_multilevel.hxx create mode 100644 example/multilevel/t8_multilevel_concept_scheme.hxx diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index e9f30cf89d..e89a6b6ba9 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -74,4 +74,4 @@ add_t8_example( NAME t8_example_empty_trees SOURCES remove/t8_exampl add_t8_example( NAME t8_version SOURCES version/t8_version.cxx ) -add_t8_example( NAME t8_example_multilevel SOURCES multilevel/t8_example_multilevel.cxx multilevel/t8_multilevel_concept.hxx) +add_t8_example( NAME t8_example_multilevel SOURCES multilevel/t8_example_multilevel.cxx multilevel/t8_multilevel_concept_base.hxx multilevel/t8_multilevel_concept_default.hxx multilevel/t8_multilevel_concept_multilevel.hxx) diff --git a/example/multilevel/t8_example_multilevel.cxx b/example/multilevel/t8_example_multilevel.cxx index 4487559ac0..1c0894a0a7 100644 --- a/example/multilevel/t8_example_multilevel.cxx +++ b/example/multilevel/t8_example_multilevel.cxx @@ -1,42 +1,32 @@ -#include -#include -#include -#include - -template -using scheme_v = std::variant; +#include +#include +#include +#include -using scheme_container = std::vector< - scheme_v, multilevel_scheme > >; +#include int main () { - typedef enum { triangle_eclass, quad_eclass, triangle_m_eclass, quad_m_eclass } eclass; - - scheme_container schemes { triangle_scheme (), quad_scheme (), multilevel_scheme (), - multilevel_scheme () }; + Scheme default_scheme = new_default_scheme (); + Scheme multilevel_scheme = new_default_scheme (true); triangle tri; tri.level = 1; tri.orientation = 0; element_t *tri_elem = (element_t *) (&tri); - std::visit ([tri_elem] (auto &&scheme) { - std::cout << "Triangle level: " << scheme.get_level (tri_elem) << std::endl; - std::cout << "Triangle num children: " << scheme.get_num_children (tri_elem) << std::endl; - std::cout << "Triangle num vertices: " << scheme.get_num_vertices () << std::endl; - }, schemes[triangle_eclass]); + std::cout << "Triangle level: " << default_scheme.get_level (triangle_eclass, tri_elem) << std::endl; + std::cout << "Triangle num children: " << default_scheme.get_num_children (triangle_eclass, tri_elem) << std::endl; + std::cout << "Triangle num vertices: " << default_scheme.get_num_vertices (triangle_eclass) << std::endl; quad q; q.level = 1; element_t *q_elem = (element_t *) (&q); - std::visit ([q_elem] (auto &&scheme) { - std::cout << "Quad level: " << scheme.get_level (q_elem) << std::endl; - std::cout << "Quad num children: " << scheme.get_num_children (q_elem) << std::endl; - std::cout << "Quad num vertices: " << scheme.get_num_vertices () << std::endl; - }, schemes[quad_eclass]); + std::cout << "Quad level: " << default_scheme.get_level (quad_eclass, q_elem) << std::endl; + std::cout << "Quad num children: " << default_scheme.get_num_children (quad_eclass, q_elem) << std::endl; + std::cout << "Quad num vertices: " << default_scheme.get_num_vertices (quad_eclass) << std::endl; multilevel_element tri_m; tri_m.elem = tri; @@ -48,17 +38,16 @@ main () q_m.multilevel_level = 2; element_t *q_m_elem = (element_t *) (&q_m); - std::visit ([tri_m_elem] (auto &&scheme) { - std::cout << "Multilevel triangle level: " << scheme.get_level (tri_m_elem) << std::endl; - std::cout << "Multilevel triangle num children: " << scheme.get_num_children (tri_m_elem) << std::endl; - std::cout << "Multilevel triangle num vertices: " << scheme.get_num_vertices () << std::endl; - }, schemes[triangle_m_eclass]); + std::cout << "Multilevel triangle level: " << multilevel_scheme.get_level (triangle_eclass, tri_m_elem) << std::endl; + std::cout << "Multilevel triangle num children: " << multilevel_scheme.get_num_children (triangle_eclass, tri_m_elem) + << std::endl; + std::cout << "Multilevel triangle num vertices: " << multilevel_scheme.get_num_vertices (triangle_eclass) + << std::endl; - std::visit ([q_m_elem] (auto &&scheme) { - std::cout << "Multilevel quad level: " << scheme.get_level (q_m_elem) << std::endl; - std::cout << "Multilevel quad num children: " << scheme.get_num_children (q_m_elem) << std::endl; - std::cout << "Multilevel quad num vertices: " << scheme.get_num_vertices () << std::endl; - }, schemes[quad_m_eclass]); + std::cout << "Multilevel quad level: " << multilevel_scheme.get_level (quad_eclass, q_m_elem) << std::endl; + std::cout << "Multilevel quad num children: " << multilevel_scheme.get_num_children (quad_eclass, q_m_elem) + << std::endl; + std::cout << "Multilevel quad num vertices: " << multilevel_scheme.get_num_vertices (quad_eclass) << std::endl; return 0; } diff --git a/example/multilevel/t8_multilevel_concept.hxx b/example/multilevel/t8_multilevel_concept.hxx deleted file mode 100644 index 4ad0275880..0000000000 --- a/example/multilevel/t8_multilevel_concept.hxx +++ /dev/null @@ -1,156 +0,0 @@ -struct triangle -{ - int level; - int orientation; -}; - -struct quad -{ - int level; -}; - -// Multilevel element, which adds the actual hierarchical level of the element -// The level inside the element will determine its size -template -struct multilevel_element -{ - eclass elem; - int multilevel_level; -}; - -// Opaque pointer to cast the element type into -typedef struct element element_t; - -// Using CRTP to avoid virtual function calls -template -class scheme_base { - public: - ~scheme_base () - { - } - - int - get_level (element_t *elem) - { - // cast derived class into base class to avoid virtual functions - return static_cast (*this).get_level (elem); - }; - - int - get_num_children (element_t *elem) - { - // cast derived class into base class to avoid virtual functions - return static_cast (*this).get_num_children (elem); - }; - - int - get_num_vertices () - { - // cast derived class into base class to avoid virtual functions - return static_cast (*this).get_num_vertices (); - }; - - private: - // This way the derived class and only the derived class can use this constructor. - // This way you get an error when doing: `class triangle_scheme: public scheme_base ` - scheme_base () {}; - friend derived_scheme_t; -}; - -// inherits from base which is a template for this class -class triangle_scheme: public scheme_base { - public: - triangle_scheme () {}; - - int - get_level (element_t *elem) - { - elem_type *tri = (elem_type *) elem; - return tri->level; - }; - - int - get_num_children (element_t *elem) - { - return 4; - }; - - int - get_num_vertices () - { - return 3; - }; - - protected: - // When the multilevel class inherits from this it needs to know the element type of this scheme - using elem_type = triangle; - - private: -}; - -// inherits from base which is a template for this class -class quad_scheme: public scheme_base { - public: - quad_scheme () {}; - - int - get_level (element_t *elem) - { - elem_type *q = (elem_type *) elem; - return q->level; - }; - - int - get_num_children (element_t *elem) - { - return 4; - }; - - int - get_num_vertices () - { - return 4; - }; - - protected: - // When the multilevel class inherits from this it needs to know the element type of this scheme - using elem_type = quad; - - private: -}; - -template -class multilevel_scheme: public scheme_base>, private scheme_impl_t { - public: - using scheme_impl_t::scheme_impl_t; - using elem_type = typename scheme_impl_t::elem_type; - ~multilevel_scheme () {}; - - int - get_level (element_t *elem) - { - multilevel_element *m_elem = (multilevel_element *) elem; - return m_elem->multilevel_level; - }; - - int - get_num_children (element_t *elem) - { - multilevel_element *m_elem = (multilevel_element *) elem; - const int elem_level = scheme_impl_t::get_level ((element_t *) &(m_elem->elem)); - if (elem_level == get_level (elem)) { - return scheme_impl_t::get_num_children ((element_t *) &(m_elem->elem)) + 1; - } - else { - return 0; - } - }; - - int - get_num_vertices () - { - return scheme_impl_t::get_num_vertices (); - }; - - private: -}; diff --git a/example/multilevel/t8_multilevel_concept_base.hxx b/example/multilevel/t8_multilevel_concept_base.hxx new file mode 100644 index 0000000000..3f4bcc1466 --- /dev/null +++ b/example/multilevel/t8_multilevel_concept_base.hxx @@ -0,0 +1,46 @@ +#pragma once + +#include +#include +#include + +typedef enum { triangle_eclass, quad_eclass, eclass_count } eclass; + +// Opaque pointer to cast the element type into +typedef struct element element_t; + +// Using CRTP to avoid virtual function calls +template +class Scheme_base { + public: + ~Scheme_base () + { + } + + inline int + get_level (element_t *elem) + { + // cast derived class into base class to avoid virtual functions + return static_cast (*this).get_level (elem); + }; + + inline int + get_num_children (element_t *elem) + { + // cast derived class into base class to avoid virtual functions + return static_cast (*this).get_num_children (elem); + }; + + inline int + get_num_vertices () + { + // cast derived class into base class to avoid virtual functions + return static_cast (*this).get_num_vertices (); + }; + + private: + // This way the derived class and only the derived class can use this constructor. + // This way you get an error when doing: `class triangle_scheme: public scheme_base ` + Scheme_base () {}; + friend Derived_scheme_t; +}; diff --git a/example/multilevel/t8_multilevel_concept_default.hxx b/example/multilevel/t8_multilevel_concept_default.hxx new file mode 100644 index 0000000000..931b25cf19 --- /dev/null +++ b/example/multilevel/t8_multilevel_concept_default.hxx @@ -0,0 +1,79 @@ +#pragma once + +#include +#include +#include +#include + +struct triangle +{ + int level; + int orientation; +}; + +struct quad +{ + int level; +}; + +// inherits from base which is a template for this class +class Triangle_scheme: public Scheme_base { + public: + Triangle_scheme () {}; + + inline int + get_level (element_t *elem) const + { + elem_type *tri = (elem_type *) elem; + return tri->level; + }; + + inline int + get_num_children (element_t *elem) const + { + return 4; + }; + + inline int + get_num_vertices () const + { + return 3; + }; + + protected: + // When the multilevel class inherits from this it needs to know the element type of this scheme + using elem_type = triangle; + + private: +}; + +// inherits from base which is a template for this class +class Quad_scheme: public Scheme_base { + public: + Quad_scheme () {}; + + inline int + get_level (element_t *elem) const + { + elem_type *q = (elem_type *) elem; + return q->level; + }; + + int + get_num_children (element_t *elem) const + { + return 4; + }; + + int + get_num_vertices () const + { + return 4; + }; + + protected: + // When the multilevel class inherits from this it needs to know the element type of this scheme + using elem_type = quad; + + private: +}; diff --git a/example/multilevel/t8_multilevel_concept_multilevel.hxx b/example/multilevel/t8_multilevel_concept_multilevel.hxx new file mode 100644 index 0000000000..c7f0a45934 --- /dev/null +++ b/example/multilevel/t8_multilevel_concept_multilevel.hxx @@ -0,0 +1,50 @@ +#pragma once +#include +#include +#include +#include + +// Multilevel element, which adds the actual hierarchical level of the element +// The level inside the element will determine its size +template +struct multilevel_element +{ + eclass elem; + int multilevel_level; +}; + +template +class Multilevel_element_scheme: public Scheme_base>, private Scheme_impl_t { + public: + using Scheme_impl_t::Scheme_impl_t; + using elem_type = typename Scheme_impl_t::elem_type; + ~Multilevel_element_scheme () {}; + + int + get_level (element_t *elem) const + { + multilevel_element *m_elem = (multilevel_element *) elem; + return m_elem->multilevel_level; + }; + + int + get_num_children (element_t *elem) const + { + multilevel_element *m_elem = (multilevel_element *) elem; + const int elem_level = Scheme_impl_t::get_level ((element_t *) &(m_elem->elem)); + if (elem_level == get_level (elem)) { + return Scheme_impl_t::get_num_children ((element_t *) &(m_elem->elem)) + 1; + } + else { + return 0; + } + }; + + int + get_num_vertices () const + { + return Scheme_impl_t::get_num_vertices (); + }; + + private: +}; diff --git a/example/multilevel/t8_multilevel_concept_scheme.hxx b/example/multilevel/t8_multilevel_concept_scheme.hxx new file mode 100644 index 0000000000..abce766ad9 --- /dev/null +++ b/example/multilevel/t8_multilevel_concept_scheme.hxx @@ -0,0 +1,80 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +class Scheme { + friend class Scheme_builder; + + public: + Scheme () {}; + ~Scheme () {}; + + using Scheme_v = std::variant, + Multilevel_element_scheme>; + using Scheme_container = std::array; + + int + get_level (eclass eclass, element_t *elem) const + { + return std::visit ([elem] (auto &&scheme) { return scheme.get_level (elem); }, eclass_schemes[eclass]); + } + + int + get_num_children (eclass eclass, element_t *elem) const + { + return std::visit ([elem] (auto &&scheme) { return scheme.get_num_children (elem); }, eclass_schemes[eclass]); + } + + int + get_num_vertices (eclass eclass) const + { + return std::visit ([] (auto &&scheme) { return scheme.get_num_vertices (); }, eclass_schemes[eclass]); + } + + private: + Scheme_container eclass_schemes; +}; + +class Scheme_builder { + public: + Scheme_builder (bool convert_to_multilevel = false): multilevel (convert_to_multilevel) {}; + ~Scheme_builder () {}; + + using Scheme_v = Scheme::Scheme_v; + + template + void + add_eclass_scheme (eclass eclass, _args &&...args) + { + if (!multilevel) { + scheme.eclass_schemes[eclass] = Eclass_scheme (std::forward<_args> (args)...); + } + else { + scheme.eclass_schemes[eclass] = Multilevel_element_scheme (std::forward<_args> (args)...); + } + } + + Scheme + build_scheme () + { + return scheme; + } + + private: + Scheme scheme; + bool multilevel; +}; + +Scheme +new_default_scheme (bool multilevel = false) +{ + Scheme_builder builder (multilevel); + builder.add_eclass_scheme (triangle_eclass); + builder.add_eclass_scheme (quad_eclass); + return builder.build_scheme (); +} From b51469beceb6e636dd3987a32cfab69d3442e2e5 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 25 Sep 2024 11:17:22 +0200 Subject: [PATCH 03/11] crtp improvements --- example/multilevel/t8_multilevel_concept_base.hxx | 9 +++++---- example/multilevel/t8_multilevel_concept_crtp.hxx | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 example/multilevel/t8_multilevel_concept_crtp.hxx diff --git a/example/multilevel/t8_multilevel_concept_base.hxx b/example/multilevel/t8_multilevel_concept_base.hxx index 3f4bcc1466..594792050a 100644 --- a/example/multilevel/t8_multilevel_concept_base.hxx +++ b/example/multilevel/t8_multilevel_concept_base.hxx @@ -3,6 +3,7 @@ #include #include #include +#include typedef enum { triangle_eclass, quad_eclass, eclass_count } eclass; @@ -11,7 +12,7 @@ typedef struct element element_t; // Using CRTP to avoid virtual function calls template -class Scheme_base { +class Scheme_base: public crtp { public: ~Scheme_base () { @@ -21,21 +22,21 @@ class Scheme_base { get_level (element_t *elem) { // cast derived class into base class to avoid virtual functions - return static_cast (*this).get_level (elem); + return this->underlying ().get_level (elem); }; inline int get_num_children (element_t *elem) { // cast derived class into base class to avoid virtual functions - return static_cast (*this).get_num_children (elem); + return this->underlying ().get_num_children (elem); }; inline int get_num_vertices () { // cast derived class into base class to avoid virtual functions - return static_cast (*this).get_num_vertices (); + return this->underlying ().get_num_vertices (); }; private: diff --git a/example/multilevel/t8_multilevel_concept_crtp.hxx b/example/multilevel/t8_multilevel_concept_crtp.hxx new file mode 100644 index 0000000000..5bc088ddb2 --- /dev/null +++ b/example/multilevel/t8_multilevel_concept_crtp.hxx @@ -0,0 +1,15 @@ +#pragma once + +template +class crtp { + Derived_t& + underlying () + { + return static_cast (*this); + } + Derived_t const& + underlying () const + { + return static_cast (*this); + } +}; From 02807bacd79a5df67afffdc45ddd3190d49a7ecf Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Thu, 26 Sep 2024 09:39:47 +0200 Subject: [PATCH 04/11] add a small crtp benchmark --- example/CMakeLists.txt | 1 + example/multilevel/benchmark.cxx | 72 ++++++++++++++++++ example/multilevel/benchmark_crtp.hxx | 93 ++++++++++++++++++++++++ example/multilevel/benchmark_virtual.hxx | 89 +++++++++++++++++++++++ 4 files changed, 255 insertions(+) create mode 100644 example/multilevel/benchmark.cxx create mode 100644 example/multilevel/benchmark_crtp.hxx create mode 100644 example/multilevel/benchmark_virtual.hxx diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index e89a6b6ba9..a2315758a4 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -75,3 +75,4 @@ add_t8_example( NAME t8_example_empty_trees SOURCES remove/t8_exampl add_t8_example( NAME t8_version SOURCES version/t8_version.cxx ) add_t8_example( NAME t8_example_multilevel SOURCES multilevel/t8_example_multilevel.cxx multilevel/t8_multilevel_concept_base.hxx multilevel/t8_multilevel_concept_default.hxx multilevel/t8_multilevel_concept_multilevel.hxx) +add_t8_example( NAME t8_test SOURCES multilevel/benchmark.cxx multilevel/benchmark_crtp.hxx multilevel/benchmark_virtual.hxx) diff --git a/example/multilevel/benchmark.cxx b/example/multilevel/benchmark.cxx new file mode 100644 index 0000000000..f4234e6f07 --- /dev/null +++ b/example/multilevel/benchmark.cxx @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include + +using namespace std::chrono; + +int +main () +{ + crtp::scheme crtp_scheme = crtp::scheme (); + crtp::quad crtp_quad; + crtp::triangle crtp_tri; + crtp_quad.level = 34; + crtp_tri.level = 10; + crtp::element_t *crtp_quad_elem = (crtp::element_t *) (&crtp_quad); + crtp::element_t *crtp_tri_elem = (crtp::element_t *) (&crtp_tri); + + crtp::triangle_scheme crtp_tri_scheme = crtp::triangle_scheme (); + crtp::quad_scheme crtp_quad_scheme = crtp::quad_scheme (); + + virtuals::scheme virtual_scheme = virtuals::scheme (); + virtuals::quad virtual_quad; + virtuals::triangle virtual_tri; + virtual_quad.level = 34; + virtual_tri.level = 10; + virtuals::element_t *virtual_quad_elem = (virtuals::element_t *) (&virtual_quad); + virtuals::element_t *virtual_tri_elem = (virtuals::element_t *) (&virtual_tri); + + { + auto start = high_resolution_clock::now (); + int result = 0; + for (int i = 0; i < 1000000000; i++) { + result += crtp_scheme.get_level (0, crtp_tri_elem); + result += crtp_scheme.get_level (1, crtp_quad_elem); + } + auto stop = high_resolution_clock::now (); + auto duration = duration_cast (stop - start); + std::cout << "CRTP with handler: " << std::setprecision (15) << duration.count () << " milliseconds" << std::endl; + std::cout << "Result: " << result << std::endl; + } + + { + auto start = high_resolution_clock::now (); + int result = 0; + for (int i = 0; i < 1000000000; i++) { + result += crtp_tri_scheme.get_level (crtp_tri_elem); + result += crtp_quad_scheme.get_level (crtp_quad_elem); + } + auto stop = high_resolution_clock::now (); + auto duration = duration_cast (stop - start); + std::cout << "CRTP without handler: " << std::setprecision (15) << duration.count () << " milliseconds" + << std::endl; + std::cout << "Result: " << result << std::endl; + } + + { + auto start = high_resolution_clock::now (); + virtuals::base *tri_scheme_ptr = virtual_scheme.get_scheme (0); + virtuals::base *quad_scheme_ptr = virtual_scheme.get_scheme (1); + int result = 0; + for (int i = 0; i < 1000000000; i++) { + result += tri_scheme_ptr->get_level (virtual_tri_elem); + result += quad_scheme_ptr->get_level (virtual_quad_elem); + } + auto stop = high_resolution_clock::now (); + auto duration = duration_cast (stop - start); + std::cout << "Virtual: " << std::setprecision (15) << duration.count () << " milliseconds" << std::endl; + std::cout << "Result: " << result << std::endl; + } +}; diff --git a/example/multilevel/benchmark_crtp.hxx b/example/multilevel/benchmark_crtp.hxx new file mode 100644 index 0000000000..b510fa9883 --- /dev/null +++ b/example/multilevel/benchmark_crtp.hxx @@ -0,0 +1,93 @@ +#pragma once + +#include +#include +#include +#include + +namespace crtp +{ +typedef struct element element_t; + +struct triangle +{ + int level; +}; + +struct quad +{ + int level; +}; + +template +class base { + public: + ~base () + { + } + + inline int + get_level (element_t *elem) const + { + return static_cast (*this).get_level (elem); + }; + + private: + base () {}; + friend derived_t; +}; + +class triangle_scheme: public base { + public: + triangle_scheme () {}; + + inline int + get_level (element_t *elem) const + { + triangle &tri = *(triangle *) elem; + if (std::time (NULL) == 0) { + std::cout << "Do not optimize this\n"; + } + return tri.level % 3; + }; + + protected: +}; + +class quad_scheme: public base { + public: + quad_scheme () {}; + + int + get_level (element_t *elem) const + { + quad &q = *(quad *) elem; + if (std::time (NULL) == 0) { + std::cout << "Do not optimize this\n"; + } + return q.level % 3; + }; + + protected: +}; + +class scheme { + public: + scheme () + { + schemes[0] = triangle_scheme (); + schemes[1] = quad_scheme (); + }; + ~scheme () {}; + + inline int + get_level (int eclass, element_t *elem) + { + return std::visit ([&] (auto &&scheme) { return scheme.get_level (elem); }, schemes[eclass]); + }; + + private: + std::array, 2> schemes; +}; + +} // namespace crtp diff --git a/example/multilevel/benchmark_virtual.hxx b/example/multilevel/benchmark_virtual.hxx new file mode 100644 index 0000000000..3113305613 --- /dev/null +++ b/example/multilevel/benchmark_virtual.hxx @@ -0,0 +1,89 @@ +#pragma once + +#include +#include +#include + +namespace virtuals +{ +typedef struct element element_t; + +struct triangle +{ + int level; +}; + +struct quad +{ + int level; +}; + +class base { + public: + virtual ~base () {}; + + virtual inline int + get_level (element_t *elem) const + = 0; +}; + +class triangle_scheme: public base { + public: + triangle_scheme () {}; + ~triangle_scheme () {}; + + inline int + get_level (element_t *elem) const override + { + triangle &tri = *(triangle *) elem; + if (std::time (NULL) == 0) { + std::cout << "Do not optimize this\n"; + } + return tri.level % 3; + }; + + protected: +}; + +class quad_scheme: public base { + public: + quad_scheme () {}; + ~quad_scheme () {}; + + inline int + get_level (element_t *elem) const override + { + quad &q = *(quad *) elem; + if (std::time (NULL) == 0) { + std::cout << "Do not optimize this\n"; + } + return q.level % 3; + }; + + protected: +}; + +class scheme { + public: + scheme () + { + schemes[0] = new triangle_scheme (); + schemes[1] = new quad_scheme (); + }; + ~scheme () + { + delete schemes[0]; + delete schemes[1]; + }; + + inline base * + get_scheme (int eclass) const + { + return schemes[eclass]; + } + + private: + std::array schemes; +}; + +} // namespace virtuals From 6a5e9f79812b74e59da3d81c019259217f8de511 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Sun, 20 Oct 2024 14:51:28 +0200 Subject: [PATCH 05/11] add new crtp scheme structure --- src/t8_schemes/t8_crtp.hxx | 43 ++ src/t8_schemes/t8_scheme.hxx | 994 +++++++++++++++++++++++++++ src/t8_schemes/t8_scheme_builder.hxx | 55 ++ 3 files changed, 1092 insertions(+) create mode 100644 src/t8_schemes/t8_crtp.hxx create mode 100644 src/t8_schemes/t8_scheme.hxx create mode 100644 src/t8_schemes/t8_scheme_builder.hxx diff --git a/src/t8_schemes/t8_crtp.hxx b/src/t8_schemes/t8_crtp.hxx new file mode 100644 index 0000000000..0d6119a993 --- /dev/null +++ b/src/t8_schemes/t8_crtp.hxx @@ -0,0 +1,43 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2024 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** \file t8_crtp.hxx + * This file implements a helper class for CRTP implementations. + */ + +#pragma once + +/* CRTP helper class, adds static "upcasting" methods for const and non const objects. */ +template +class crtp { + public: + TUnderlying& + underlying () + { + return static_cast (*this); + } + TUnderlying const& + underlying () const + { + return static_cast (*this); + } +}; diff --git a/src/t8_schemes/t8_scheme.hxx b/src/t8_schemes/t8_scheme.hxx new file mode 100644 index 0000000000..8400db5e5a --- /dev/null +++ b/src/t8_schemes/t8_scheme.hxx @@ -0,0 +1,994 @@ +/* + This file is part of t8code. + t8code is a C library to manage a collection (a forest) of multiple + connected adaptive space-trees of general element classes in parallel. + + Copyright (C) 2024 the developers + + t8code is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + t8code is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with t8code; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#pragma once + +#include +#include +#include + +/** This class holds one or more element schemes. + * It also relays the function calls to the specific schemes. */ +class t8_scheme { + friend class t8_scheme_builder; + + public: + t8_scheme () {}; + ~t8_scheme () {}; + + /* clang-format off */ + using scheme_var = std::variant< + /* Default schemes */ + t8_default_vertex, + t8_default_line, + t8_default_quad, + t8_default_tri, + t8_default_hex, + t8_default_tet, + t8_default_prism, + t8_default_pyramid + >; + /* clang-format on */ + using scheme_container = std::array; + + private: + Scheme_container eclass_schemes; + + public: + /** Return the size of any element of a given class. + * \param [in] tree_class The eclass of the current tree. + * \return The size of an element of class \a tree_class. + * We provide a default implementation of this routine that should suffice + * for most use cases. + */ + inline size_t + get_element_size (t8_eclass_t tree_class) const + { + return std::visit ([&] (auto &&scheme) { return scheme.get_element_size (elem); }, eclass_schemes[tree_class]); + }; + + /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. + * Returns false otherwise. + * \param [in] tree_class The eclass of the current tree. + * \return non-zero if there is one element in the tree that does not refine into 2^dim children. + */ + inline int + refines_irregular (t8_eclass_t tree_class) const + { + return std::visit ([&] (auto &&scheme) { return scheme.refines_irregular (); }, eclass_schemes[tree_class]); + }; + + /** Return the maximum allowed level for any element of a given class. + * \param [in] tree_class The eclass of the current tree. + * \return The maximum allowed level for elements of class \a tree_class. + */ + inline int + get_maxlevel (t8_eclass_t tree_class) const + { + return std::visit ([&] (auto &&scheme) { return scheme.get_maxlevel (); }, eclass_schemes[tree_class]); + }; + + /** Return the level of a particular element. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element whose level should be returned. + * \return The level of \a elem. + */ + inline int + element_get_level (t8_eclass_t tree_class, const t8_element_t *elem) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_level (elem); }, eclass_schemes[tree_class]); + }; + + /** Copy all entries of \a source to \a dest. \a dest must be an existing + * element. No memory is allocated by this function. + * \param [in] tree_class The eclass of the current tree. + * \param [in] source The element whose entries will be copied to \a dest. + * \param [in,out] dest This element's entries will be overwritten with the + * entries of \a source. + * \note \a source and \a dest may point to the same element. + */ + inline void + element_copy (t8_eclass_t tree_class, const t8_element_t *source, t8_element_t *dest) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_copy (source, dest); }, eclass_schemes[tree_class]); + }; + + /** Compare two elements. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem1 The first element. + * \param [in] elem2 The second element. + * \return negative if elem1 < elem2, zero if elem1 equals elem2 + * and positive if elem1 > elem2. + * If elem2 is a copy of elem1 then the elements are equal. + */ + inline int + element_compare (t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_compare (elem1, elem2); }, + eclass_schemes[tree_class]); + }; + + /** Check if two elements are equal. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem1 The first element. + * \param [in] elem2 The second element. + * \return 1 if the elements are equal, 0 if they are not equal + */ + inline int + element_is_equal (t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_is_equal (elem1, elem2); }, + eclass_schemes[tree_class]); + }; + + /** Compute the parent of a given element \a elem and store it in \a parent. + * \a parent needs to be an existing element. No memory is allocated by this function. + * \a elem and \a parent can point to the same element, then the entries of + * \a elem are overwritten by the ones of its parent. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element whose parent will be computed. + * \param [in,out] parent This element's entries will be overwritten by those + * of \a elem's parent. + * The storage for this element must exist + * and match the element class of the parent. + * For a pyramid, for example, it may be either a + * tetrahedron or a pyramid depending on \a elem's childid. + */ + inline void + element_get_parent (t8_eclass_t tree_class, const t8_element_t *elem, t8_element_t *parent) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_parent (elem, parent); }, + eclass_schemes[tree_class]); + }; + + /** Compute the number of siblings of an element. That is the number of + * Children of its parent. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element. + * \return The number of siblings of \a element. + * Note that this number is >= 1, since we count the element itself as a sibling. + */ + inline int + element_get_num_siblings (t8_eclass_t tree_class, const t8_element_t *elem) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_num_siblings (elem); }, + eclass_schemes[tree_class]); + }; + + /** Compute a specific sibling of a given element \a elem and store it in \a sibling. + * \a sibling needs to be an existing element. No memory is allocated by this function. + * \a elem and \a sibling can point to the same element, then the entries of + * \a elem are overwritten by the ones of its sibid-th sibling. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element whose sibling will be computed. + * \param [in] sibid The id of the sibling computed. + * \param [in,out] sibling This element's entries will be overwritten by those + * of \a elem's sibid-th sibling. + * The storage for this element must exist + * and match the element class of the sibling. + */ + inline void + element_get_sibling (t8_eclass_t tree_class, const t8_element_t *elem, int sibid, t8_element_t *sibling) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_sibling (elem, sibid, sibling); }, + eclass_schemes[tree_class]); + }; + + /** Compute the number of corners of a given element. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element. + * \return The number of corners of \a elem. + */ + inline int + element_get_num_corners (t8_eclass_t tree_class, const t8_element_t *elem) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_num_corners (elem); }, + eclass_schemes[tree_class]); + }; + + /** Compute the number of faces of a given element. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element. + * \return The number of faces of \a elem. + */ + inline int + element_get_num_faces (t8_eclass_t tree_class, const t8_element_t *elem) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_num_faces (elem); }, eclass_schemes[tree_class]); + }; + + /** Compute the maximum number of faces of a given element and all of its + * descendants. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element. + * \return The maximum number of faces of \a elem and its descendants. + */ + inline int + element_get_max_num_faces (t8_eclass_t tree_class, const t8_element_t *elem) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_max_num_faces (elem); }, + eclass_schemes[tree_class]); + }; + + /** Return the number of children of an element when it is refined. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element whose number of children is returned. + * \return The number of children of \a elem if it is to be refined. + */ + inline int + element_get_num_children (t8_eclass_t tree_class, const t8_element_t *elem) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_num_children (elem); }, + eclass_schemes[tree_class]); + }; + + /** Return the number of children of an element's face when the element is refined. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element whose face is considered. + * \param [in] face A face of \a elem. + * \return The number of children of \a face if \a elem is to be refined. + */ + inline int + element_get_num_face_children (t8_eclass_t tree_class, const t8_element_t *elem, int face) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_num_face_children (elem, face); }, + eclass_schemes[tree_class]); + }; + + /** Return the corner number of an element's face corner. + * Example quad: 2 x --- x 3 + * | | + * | | face 1 + * 0 x --- x 1 + * Thus for face = 1 the output is: corner=0 : 1, corner=1: 3 + * + * \param [in] tree_class The eclass of the current tree. + * \param [in] element The element. + * \param [in] face A face index for \a element. + * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. + * \return The corner number of the \a corner-th vertex of \a face. + */ + inline int + element_get_face_corner (t8_eclass_t tree_class, const t8_element_t *element, int face, int corner) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_face_corner (element, face, corner); }, + eclass_schemes[tree_class]); + }; + + /** Return the face numbers of the faces sharing an element's corner. + * Example quad: 2 x --- x 3 + * | | + * | | face 1 + * 0 x --- x 1 + * face 2 + * Thus for corner = 1 the output is: face=0 : 2, face=1: 1 + * \param [in] tree_class The eclass of the current tree. + * \param [in] element The element. + * \param [in] corner A corner index for the face. + * \param [in] face A face index for \a corner. + * \return The face number of the \a face-th face at \a corner. + */ + inline int + element_get_corner_face (t8_eclass_t tree_class, const t8_element_t *element, int corner, int face) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_corner_face (element, corner, face); }, + eclass_schemes[tree_class]); + }; + + /** Construct the child element of a given number. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem This must be a valid element, bigger than maxlevel. + * \param [in] childid The number of the child to construct. + * \param [in,out] child The storage for this element must exist. + * On output, a valid element. + * It is valid to call this function with elem = child. + */ + inline void + element_get_child (t8_eclass_t tree_class, const t8_element_t *elem, int childid, t8_element_t *child) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_child (elem, childid, child); }, + eclass_schemes[tree_class]); + }; + + /** Construct all children of a given element. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem This must be a valid element, bigger than maxlevel. + * \param [in] length The length of the output array \a c must match + * the number of children. + * \param [in,out] c The storage for these \a length elements must exist. + * On output, all children are valid. + * It is valid to call this function with elem = c[0]. + * \see t8_element_num_children + */ + inline void + element_get_children (t8_eclass_t tree_class, const t8_element_t *elem, int length, t8_element_t *c[]) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_children (elem, length, c); }, + eclass_schemes[tree_class]); + }; + + /** Compute the child id of an element. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem This must be a valid element. + * \return The child id of elem. + */ + inline int + element_get_child_id (t8_eclass_t tree_class, const t8_element_t *elem) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_child_id (elem); }, eclass_schemes[tree_class]); + }; + + /** Compute the ancestor id of an element, that is the child id + * at a given level. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem This must be a valid element. + * \param [in] level A refinement level. Must satisfy \a level < elem.level + * \return The child_id of \a elem in regard to its \a level ancestor. + */ + inline int + element_get_ancestor_id (t8_eclass_t tree_class, const t8_element_t *elem, int level) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_ancestor_id (elem, level); }, + eclass_schemes[tree_class]); + }; + + /** Query whether a given set of elements is a family or not. + * \param [in] tree_class The eclass of the current tree. + * \param [in] fam An array of as many elements as an element of class + * \a tree_class has siblings. + * \return Zero if \a fam is not a family, nonzero if it is. + * \note level 0 elements do not form a family. + */ + inline int + elements_are_family (t8_eclass_t tree_class, t8_element_t *const *fam) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_is_family (fam); }, eclass_schemes[tree_class]); + }; + + /** Compute the nearest common ancestor of two elements. That is, + * the element with highest level that still has both given elements as + * descendants. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem1 The first of the two input elements. + * \param [in] elem2 The second of the two input elements. + * \param [in,out] nca The storage for this element must exist + * and match the element class of the child. + * On output the unique nearest common ancestor of + * \a elem1 and \a elem2. + */ + inline void + element_get_nca (t8_eclass_t tree_class, const t8_element_t *elem1, const t8_element_t *elem2, + t8_element_t *nca) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_nca (elem1, elem2, nca); }, + eclass_schemes[tree_class]); + }; + + /** Compute the shape of the face of an element. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element. + * \param [in] face A face of \a elem. + * \return The element shape of the face. + * I.e. T8_ECLASS_LINE for quads, T8_ECLASS_TRIANGLE for tets + * and depending on the face number either T8_ECLASS_QUAD or + * T8_ECLASS_TRIANGLE for prisms. + */ + inline t8_element_shape_t + element_get_face_shape (t8_eclass_t tree_class, const t8_element_t *elem, int face) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_face_shape (elem, face); }, + eclass_schemes[tree_class]); + }; + + /** Given an element and a face of the element, compute all children of + * the element that touch the face. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element. + * \param [in] face A face of \a elem. + * \param [in,out] children Allocated elements, in which the children of \a elem + * that share a face with \a face are stored. + * They will be stored in order of their linear id. + * \param [in] num_children The number of elements in \a children. Must match + * the number of children that touch \a face. + * \ref t8_element_num_face_children + * \param [in,out] child_indices If not NULL, an array of num_children integers must be given, + * on output its i-th entry is the child_id of the i-th face_child. + * It is valid to call this function with elem = children[0]. + */ + inline void + element_get_children_at_face (t8_eclass_t tree_class, const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const + { + return std::visit ( + [&] (auto &&scheme) { + return scheme.element_get_children_at_face (elem, face, children, num_children, child_indices); + }, + eclass_schemes[tree_class]); + }; + + /** Given a face of an element and a child number of a child of that face, return the face number + * of the child of the element that matches the child face. + * \verbatim + x ---- x x x x ---- x + | | | | | | | <-- f + | | | x | x--x + | | | | | + x ---- x x x ---- x + elem face face_child Returns the face number f + \endverbatim + + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element. + * \param [in] face Then number of the face. + * \param [in] face_child A number 0 <= \a face_child < num_face_children, + * specifying a child of \a elem that shares a face with \a face. + * These children are counted in linear order. This coincides with + * the order of children from a call to \ref t8_element_children_at_face. + * \return The face number of the face of a child of \a elem + * that coincides with \a face_child. + */ + inline int + element_face_get_child_face (t8_eclass_t tree_class, const t8_element_t *elem, int face, int face_child) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_face_get_child_face (elem, face, face_child); }, + eclass_schemes[tree_class]); + }; + + /** Given a face of an element return the face number + * of the parent of the element that matches the element's face. Or return -1 if + * no face of the parent matches the face. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element. + * \param [in] face Then number of the face. + * \return If \a face of \a elem is also a face of \a elem's parent, + * the face number of this face. Otherwise -1. + * \note For the root element this function always returns \a face. + */ + inline int + element_face_get_parent_face (t8_eclass_t tree_class, const t8_element_t *elem, int face) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_face_get_parent_face (elem, face); }, + eclass_schemes[tree_class]); + }; + + /** Given an element and a face of this element. If the face lies on the + * tree boundary, return the face number of the tree face. + * If not the return value is arbitrary. + * You can call \ref t8_element_is_root_boundary to query whether the face is + * at the tree boundary. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem The element. + * \param [in] face The index of a face of \a elem. + * \return The index of the tree face that \a face is a subface of, if + * \a face is on a tree boundary. + * Any arbitrary integer if \a is not at a tree boundary. + * \warning The return value may look like a valid face of the tree even if + * the element does not lie on the root boundary. + */ + inline int + element_get_tree_face (t8_eclass_t tree_class, const t8_element_t *elem, int face) const + { + return std::visit ([&] (auto &&scheme) { return scheme.element_get_tree_face (elem, face); }, + eclass_schemes[tree_class]); + }; + + /** Suppose we have two trees that share a common face f. + * Given an element e that is a subface of f in one of the trees + * and given the orientation of the tree connection, construct the face + * element of the respective tree neighbor that logically coincides with e + * but lies in the coordinate system of the neighbor tree. + * \param [in] tree_class The eclass of the current tree. + * \param [in] elem1 The face element. + * \param [in,out] elem2 On return the face element \a elem1 with respect + * to the coordinate system of the other tree. + * \param [in] orientation The orientation of the tree-tree connection. + * \see t8_cmesh_set_join + * \param [in] sign Depending on the topological orientation of the two tree faces, + * either 0 (both faces have opposite orientation) + * or 1 (both faces have the same top. orientattion). + * \ref t8_eclass_face_orientation + * \param [in] is_smaller_face Flag to declare whether \a elem1 belongs to + * the smaller face. A face f of tree T is smaller than + * f' of T' if either the eclass of T is smaller or if + * the classes are equal and f + +class Scheme_builder { + public: + Scheme_builder () {}; + ~Scheme_builder () {}; + + using Scheme_v = Scheme::Scheme_v; + + template + void + add_eclass_scheme (eclass tree_class, _args &&...args) + { + scheme.eclass_schemes[tree_class] = Multilevel_element_scheme (std::forward<_args> (args)...); + } + + const Scheme + build_scheme () const + { + return scheme; + } + + private: + Scheme scheme; + bool multilevel; +}; From 2fb3e131e3c1c0f3481245778c8456456fe63859 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Sun, 20 Oct 2024 14:52:19 +0200 Subject: [PATCH 06/11] saving first changes --- .../t8_fortran_interface.c | 4 +- benchmarks/t8_time_fractal.cxx | 17 +- benchmarks/t8_time_prism_adapt.cxx | 7 +- benchmarks/time_forest_partition.cxx | 4 +- benchmarks/time_new_refine.c | 4 +- .../gmsh/t8_load_and_refine_square_w_hole.cxx | 6 +- .../forest/netcdf/t8_write_forest_netcdf.cxx | 8 +- example/advect/t8_advection.cxx | 38 +- example/cmesh/t8_cmesh_hypercube_pad.cxx | 2 +- example/common/t8_example_common.cxx | 7 +- example/common/t8_example_common.h | 7 +- example/forest/t8_face_neighbor.cxx | 4 +- example/forest/t8_test_face_iterate.cxx | 4 +- example/forest/t8_test_ghost.cxx | 6 +- .../forest/t8_test_ghost_large_level_diff.cxx | 2 +- example/geometry/t8_example_geometries.cxx | 2 +- example/remove/t8_example_empty_trees.cxx | 2 +- example/remove/t8_example_gauss_blob.cxx | 4 +- example/remove/t8_example_spheres.cxx | 4 +- src/t8_cmesh.h | 6 +- src/t8_cmesh/t8_cmesh.cxx | 8 +- src/t8_cmesh/t8_cmesh_partition.cxx | 2 +- src/t8_cmesh/t8_cmesh_types.h | 18 +- src/t8_data/t8_containers.cxx | 14 +- src/t8_data/t8_containers.h | 19 +- src/t8_element.cxx | 10 +- src/t8_element.h | 24 +- src/t8_element.hxx | 499 +++++++++++------- src/t8_element_c_interface.cxx | 394 ++++++++------ src/t8_element_c_interface.h | 154 +++--- src/t8_forest/t8_forest.cxx | 139 ++--- src/t8_forest/t8_forest_adapt.cxx | 19 +- src/t8_forest/t8_forest_balance.cxx | 8 +- src/t8_forest/t8_forest_general.h | 34 +- src/t8_forest/t8_forest_ghost.cxx | 10 +- src/t8_forest/t8_forest_iterate.cxx | 86 +-- src/t8_forest/t8_forest_netcdf.cxx | 4 +- src/t8_forest/t8_forest_partition.cxx | 8 +- src/t8_forest/t8_forest_private.h | 13 +- src/t8_forest/t8_forest_types.h | 14 +- .../t8_geometry_linear.cxx | 2 +- src/t8_schemes/t8_default/t8_default.cxx | 17 +- src/t8_schemes/t8_default/t8_default.hxx | 13 +- .../t8_default/t8_default_c_interface.h | 4 +- .../t8_default_common/t8_default_common.cxx | 32 +- .../t8_default_common/t8_default_common.hxx | 72 +-- .../t8_default_hex/t8_default_hex.cxx | 223 ++++---- .../t8_default_hex/t8_default_hex.hxx | 267 +++++----- .../t8_default_line/t8_default_line.cxx | 232 ++++---- .../t8_default_line/t8_default_line.hxx | 265 +++++----- .../t8_default_prism/t8_default_prism.cxx | 230 ++++---- .../t8_default_prism/t8_default_prism.hxx | 268 +++++----- .../t8_default_pyramid/t8_default_pyramid.cxx | 237 +++++---- .../t8_default_pyramid/t8_default_pyramid.hxx | 273 +++++----- .../t8_default_quad/t8_default_quad.cxx | 258 ++++----- .../t8_default_quad/t8_default_quad.hxx | 218 +++----- .../t8_default_tet/t8_default_tet.cxx | 213 ++++---- .../t8_default_tet/t8_default_tet.hxx | 263 ++++----- .../t8_default_tri/t8_default_tri.cxx | 229 ++++---- .../t8_default_tri/t8_default_tri.hxx | 219 +++----- .../t8_default_vertex/t8_default_vertex.cxx | 160 +++--- .../t8_default_vertex/t8_default_vertex.hxx | 265 +++++----- src/t8_vtk/t8_vtk_write_ASCII.cxx | 52 +- src/t8_vtk/t8_vtk_writer_helper.cxx | 6 +- test/t8_IO/t8_gtest_vtk_writer.cxx | 2 +- test/t8_forest/t8_gtest_balance.cxx | 6 +- test/t8_forest/t8_gtest_element_is_leaf.cxx | 7 +- test/t8_forest/t8_gtest_element_volume.cxx | 2 +- test/t8_forest/t8_gtest_find_owner.cxx | 10 +- test/t8_forest/t8_gtest_forest_commit.cxx | 8 +- .../t8_forest/t8_gtest_forest_face_normal.cxx | 6 +- test/t8_forest/t8_gtest_ghost_and_owner.cxx | 8 +- test/t8_forest/t8_gtest_ghost_delete.cxx | 8 +- test/t8_forest/t8_gtest_ghost_exchange.cxx | 10 +- test/t8_forest/t8_gtest_half_neighbors.cxx | 6 +- test/t8_forest/t8_gtest_partition_data.cxx | 6 +- test/t8_forest/t8_gtest_search.cxx | 6 +- test/t8_forest/t8_gtest_transform.cxx | 4 +- test/t8_forest/t8_gtest_user_data.cxx | 4 +- .../t8_gtest_empty_global_tree.cxx | 2 +- .../t8_gtest_empty_local_tree.cxx | 2 +- .../t8_gtest_iterate_replace.cxx | 7 +- .../t8_gtest_permute_hole.cxx | 4 +- .../t8_gtest_recursive.cxx | 14 +- test/t8_geometry/t8_gtest_point_inside.cxx | 4 +- test/t8_gtest_custom_assertion.hxx | 2 +- test/t8_schemes/t8_gtest_ancestor.cxx | 8 +- test/t8_schemes/t8_gtest_boundary_extrude.cxx | 2 +- test/t8_schemes/t8_gtest_default.cxx | 2 +- test/t8_schemes/t8_gtest_descendant.cxx | 15 +- test/t8_schemes/t8_gtest_dfs_base.hxx | 4 +- .../t8_gtest_element_count_leaves.cxx | 6 +- .../t8_gtest_element_ref_coords.cxx | 7 +- test/t8_schemes/t8_gtest_face_descendant.cxx | 2 +- test/t8_schemes/t8_gtest_face_neigh.cxx | 15 +- test/t8_schemes/t8_gtest_init_linear_id.cxx | 12 +- test/t8_schemes/t8_gtest_nca.cxx | 8 +- test/t8_schemes/t8_gtest_root.cxx | 6 +- test/t8_schemes/t8_gtest_successor.cxx | 10 +- .../features/t8_features_curved_meshes.cxx | 8 +- tutorials/general/t8_step2_uniform_forest.cxx | 2 +- tutorials/general/t8_step3.h | 2 +- tutorials/general/t8_step3_adapt_forest.cxx | 2 +- tutorials/general/t8_step5_element_data.cxx | 4 +- .../t8_step5_element_data_c_interface.c | 4 +- tutorials/general/t8_step6_stencil.cxx | 16 +- tutorials/general/t8_step7_interpolation.cxx | 9 +- 107 files changed, 2951 insertions(+), 2954 deletions(-) diff --git a/api/t8_fortran_interface/t8_fortran_interface.c b/api/t8_fortran_interface/t8_fortran_interface.c index 92d0ab5a8e..e594dd1afa 100644 --- a/api/t8_fortran_interface/t8_fortran_interface.c +++ b/api/t8_fortran_interface/t8_fortran_interface.c @@ -117,7 +117,7 @@ t8_cmesh_new_periodic_tri_wrap (sc_MPI_Comm *Ccomm) t8_forest_t t8_forest_new_uniform_default (t8_cmesh_t cmesh, int level, int do_face_ghost, sc_MPI_Comm *comm) { - t8_scheme_cxx_t *default_scheme = t8_scheme_new_default_cxx (); + t8_scheme_c *default_scheme = t8_scheme_new_default_cxx (); T8_ASSERT (comm != NULL); return t8_forest_new_uniform (cmesh, default_scheme, level, do_face_ghost, *comm); @@ -125,7 +125,7 @@ t8_forest_new_uniform_default (t8_cmesh_t cmesh, int level, int do_face_ghost, s int t8_fortran_adapt_by_coordinates_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, + t8_locidx_t lelement_id, t8_scheme_c *ts, const int is_family, int num_elements, t8_element_t *elements[]) { t8_fortran_adapt_coordinate_callback callback diff --git a/benchmarks/t8_time_fractal.cxx b/benchmarks/t8_time_fractal.cxx index c29d4402bb..d0cffdee69 100644 --- a/benchmarks/t8_time_fractal.cxx +++ b/benchmarks/t8_time_fractal.cxx @@ -46,7 +46,7 @@ */ static int t8_adapt_menger_quad (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const int *adapt_data = (const int *) t8_forest_get_user_data (forest); const int level_max = adapt_data[0]; @@ -77,7 +77,7 @@ t8_adapt_menger_quad (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t w */ static int t8_adapt_sierpinski_tri (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const int *adapt_data = (const int *) t8_forest_get_user_data (forest); const int level_max = adapt_data[0]; @@ -101,7 +101,7 @@ t8_adapt_sierpinski_tri (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_ */ static int t8_adapt_menger_hex (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const int *adapt_data = (const int *) t8_forest_get_user_data (forest); const int level_max = adapt_data[0]; @@ -149,7 +149,7 @@ t8_adapt_menger_hex (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t wh */ static int t8_adapt_sierpinski_tet (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const int *adapt_data = (const int *) t8_forest_get_user_data (forest); const int level_max = adapt_data[0]; @@ -173,8 +173,7 @@ t8_adapt_sierpinski_tet (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_ */ static int t8_adapt_sierpinski_prism (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, - t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const int *adapt_data = (const int *) t8_forest_get_user_data (forest); const int level_max = adapt_data[0]; @@ -198,8 +197,8 @@ t8_adapt_sierpinski_prism (t8_forest_t forest, t8_forest_t forest_from, t8_locid */ static int t8_adapt_sierpinski_pyramid (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]) + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { const int *adapt_data = (const int *) t8_forest_get_user_data (forest); const int level_max = adapt_data[0]; @@ -220,7 +219,7 @@ t8_adapt_sierpinski_pyramid (t8_forest_t forest, t8_forest_t forest_from, t8_loc /* Coarse every family in the mesh. */ static int t8_adapt_coarse (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { if (is_family) { return -1; diff --git a/benchmarks/t8_time_prism_adapt.cxx b/benchmarks/t8_time_prism_adapt.cxx index 70221c3341..d31459c76b 100644 --- a/benchmarks/t8_time_prism_adapt.cxx +++ b/benchmarks/t8_time_prism_adapt.cxx @@ -36,8 +36,8 @@ static int t8_basic_adapt_refine_type (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]) + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { int level; int type; @@ -59,8 +59,7 @@ t8_basic_adapt_refine_type (t8_forest_t forest, t8_forest_t forest_from, t8_loci static int t8_basic_adapt_refine_tet (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, - t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { int level; int type; diff --git a/benchmarks/time_forest_partition.cxx b/benchmarks/time_forest_partition.cxx index a8a11a0b0d..bfa523b501 100644 --- a/benchmarks/time_forest_partition.cxx +++ b/benchmarks/time_forest_partition.cxx @@ -75,7 +75,7 @@ t8_vec3_xmay (double *x, double alpha, double *y) /* TODO: deprecated. was replaced by t8_common_midpoint. */ static void t8_anchor_element (t8_forest_t forest, t8_locidx_t which_tree, - t8_eclass_scheme_c *ts, t8_element_t *element, + t8_scheme *ts, t8_element_t *element, double elem_anchor_f[3]) { double *tree_vertices; @@ -102,7 +102,7 @@ t8_anchor_element (t8_forest_t forest, t8_locidx_t which_tree, * c_min, c_max. We refine the cells in the band c_min*E, c_max*E */ static int t8_band_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { int level, base_level, max_level; double elem_midpoint[3]; diff --git a/benchmarks/time_new_refine.c b/benchmarks/time_new_refine.c index 2995258b9a..8bb1bdb245 100644 --- a/benchmarks/time_new_refine.c +++ b/benchmarks/time_new_refine.c @@ -36,7 +36,7 @@ /* This function refines every element */ static int t8_basic_adapt_refine (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { int level; level = t8_element_level (ts, elements[0]); @@ -52,7 +52,7 @@ t8_basic_adapt_refine (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t /* This function coarsens each element */ static int t8_basic_adapt_coarsen (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, int num_elements, t8_element_t *elements[]) + t8_scheme_c *ts, const int is_family, int num_elements, t8_element_t *elements[]) { if (is_family) { return -1; diff --git a/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx b/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx index 751845f4b8..69c89c5258 100644 --- a/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx +++ b/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx @@ -55,8 +55,8 @@ t8_vec3_xmay (double *x, double alpha, double *y) /* Compute the coordinates of the midpoint * and a measure for the length of a triangle or square */ static void -t8_midpoint (t8_forest_t forest, t8_locidx_t which_tree, t8_eclass_scheme_c *ts, t8_element_t *element, - double elem_mid_point[3], double *h) +t8_midpoint (t8_forest_t forest, t8_locidx_t which_tree, t8_scheme *ts, t8_element_t *element, double elem_mid_point[3], + double *h) { double *corner[3]; int i, j; @@ -114,7 +114,7 @@ t8_midpoint (t8_forest_t forest, t8_locidx_t which_tree, t8_eclass_scheme_c *ts, static int t8_load_refine_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { int level; double elem_midpoint[3]; diff --git a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx index b96e060891..6699ec2e39 100644 --- a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx +++ b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx @@ -71,8 +71,8 @@ struct t8_example_netcdf_adapt_data */ int t8_example_netcdf_adapt_fn (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]) + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { double element_centroid[3]; double distance; @@ -177,7 +177,7 @@ t8_example_compare_performance_netcdf_var_properties (sc_MPI_Comm comm, int fore { t8_cmesh_t cmesh; t8_forest_t forest; - t8_scheme_cxx_t *default_scheme; + t8_scheme *default_scheme; t8_gloidx_t num_elements; t8_nc_int64_t *var_rank; double *random_values; @@ -324,7 +324,7 @@ t8_example_netcdf_write_forest (sc_MPI_Comm comm, int forest_refinement_level, i { t8_cmesh_t cmesh; t8_forest_t forest; - t8_scheme_cxx_t *default_scheme; + t8_scheme *default_scheme; t8_gloidx_t num_elements; t8_nc_int32_t *var_rank; double *random_values; diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index e72603eb68..5948cd3c15 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -180,7 +180,7 @@ t8_advect_element_set_phi_adapt (const t8_advect_problem_t *problem, t8_locidx_t * and coarsen if it is larger than a given threshold. */ static int t8_advect_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t ltree_id, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { t8_advect_problem_t *problem; t8_advect_element_data_t *elem_data; @@ -414,7 +414,7 @@ t8_advect_flux_upwind_hanging (const t8_advect_problem_t *problem, t8_locidx_t i const t8_element_t *element_hang, int face, int adapted_or_partitioned) { int i, num_face_children, child_face; - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_eclass eclass; t8_element_t **face_children; t8_advect_element_data_t *neigh_data; @@ -429,21 +429,21 @@ t8_advect_flux_upwind_hanging (const t8_advect_problem_t *problem, t8_locidx_t i el_hang = (t8_advect_element_data_t *) t8_sc_array_index_locidx (problem->element_data, iel_hang); /* Get the eclass and the scheme for the element */ eclass = t8_forest_get_tree_class (problem->forest, ltreeid); - ts = t8_forest_get_eclass_scheme (problem->forest, eclass); + ts = t8_forest_get_scheme (problem->forest); /* Compute the children of the element at the face */ - num_face_children = ts->t8_element_num_face_children (element_hang, face); + num_face_children = ts->element_get_num_face_children (eclass, element_hang, face); T8_ASSERT (num_face_children == el_hang->num_neighbors[face]); face_children = T8_ALLOC (t8_element_t *, num_face_children); - ts->t8_element_new (num_face_children, face_children); - ts->t8_element_children_at_face (element_hang, face, face_children, num_face_children, NULL); + ts->element_new (eclass, num_face_children, face_children); + ts->element_get_children_at_face (eclass, element_hang, face, face_children, num_face_children, NULL); /* Store the phi value of el_hang. We use it as the phi value of the * children to compute the flux */ phi_plus = t8_advect_element_get_phi (problem, iel_hang); for (i = 0; i < num_face_children; i++) { - child_face = ts->t8_element_face_child_face (element_hang, face, i); + child_face = ts->element_face_get_child_face (eclass, element_hang, face, i); /* Get a pointer to the neighbor's element data */ neigh_id = el_hang->neighs[face][i]; neigh_data = (t8_advect_element_data_t *) t8_sc_array_index_locidx (problem->element_data, neigh_id); @@ -472,7 +472,7 @@ t8_advect_flux_upwind_hanging (const t8_advect_problem_t *problem, t8_locidx_t i el_hang->flux_valid[face] = 1; /* clean-up */ - ts->t8_element_destroy (num_face_children, face_children); + ts->element_destroy (eclass, num_face_children, face_children); T8_FREE (face_children); a = 2; @@ -516,7 +516,7 @@ t8_advect_advance_element (t8_advect_problem_t *problem, t8_locidx_t lelement) /* Compute element midpoint and vol and store at element_data field. */ static void t8_advect_compute_element_data (t8_advect_problem_t *problem, t8_advect_element_data_t *elem_data, - const t8_element_t *element, t8_locidx_t ltreeid, t8_eclass_scheme_c *ts) + const t8_element_t *element, t8_locidx_t ltreeid, t8_scheme *ts) { /* Compute the midpoint coordinates of element */ t8_forest_element_centroid (problem->forest, ltreeid, element, elem_data->midpoint); @@ -534,8 +534,8 @@ t8_advect_compute_element_data (t8_advect_problem_t *problem, t8_advect_element_ * Similar formula for refining? */ static void -t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, t8_eclass_scheme_c *ts, - int refine, int num_outgoing, t8_locidx_t first_outgoing, int num_incoming, +t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, t8_scheme *ts, + t8_eclass_t tree_class, int refine, int num_outgoing, t8_locidx_t first_outgoing, int num_incoming, t8_locidx_t first_incoming) { t8_advect_problem_t *problem; @@ -567,7 +567,7 @@ t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t w /* Get a pointer to the new element */ const t8_element_t *element = t8_forest_get_element_in_tree (problem->forest_adapt, which_tree, first_incoming); /* Debug check number of faces */ - T8_ASSERT (elem_data_in->num_faces == ts->t8_element_num_faces (element)); + T8_ASSERT (elem_data_in->num_faces == ts->element_get_num_faces (tree_class, element)); #endif /* Set the neighbor entries to uninitialized */ for (iface = 0; iface < elem_data_in->num_faces; iface++) { @@ -584,7 +584,7 @@ t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t w /* Ensure that the number of incoming elements matches the * number of children of the outgoing element. */ const t8_element_t *element_outgoing = t8_forest_get_element_in_tree (forest_old, which_tree, first_outgoing); - const int num_children = ts->t8_element_num_children (element_outgoing); + const int num_children = ts->element_get_num_children (tree_class, element_outgoing); T8_ASSERT (num_incoming == num_children); #endif /* The old element is refined, we copy the phi values and compute the new midpoints */ @@ -596,7 +596,7 @@ t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t w t8_advect_compute_element_data (problem, elem_data_in + i, element, which_tree, ts); t8_advect_element_set_phi_adapt (problem, first_incoming_data + i, phi_old); /* Set the neighbor entries to uninitialized */ - const int num_new_faces = ts->t8_element_num_faces (element); + const int num_new_faces = ts->element_get_num_faces (tree_class, element); elem_data_in[i].num_faces = num_new_faces; for (iface = 0; iface < num_new_faces; iface++) { elem_data_in[i].num_neighbors[iface] = 0; @@ -617,7 +617,7 @@ t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t w /* Ensure that the number of outgoing elements matches the * number of siblings of the first outgoing element. */ const t8_element_t *element_outgoing = t8_forest_get_element_in_tree (forest_old, which_tree, first_outgoing); - const int num_siblings = ts->t8_element_num_siblings (element_outgoing); + const int num_siblings = ts->element_get_num_siblings (tree_class, element_outgoing); T8_ASSERT (num_outgoing == num_siblings); #endif /* The old elements form a family which is coarsened. We compute the average @@ -635,7 +635,7 @@ t8_advect_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t w t8_advect_element_set_phi_adapt (problem, first_incoming_data, phi); /* Set the neighbor entries to uninitialized */ elem_data_in->num_faces = elem_data_out[0].num_faces; - T8_ASSERT (elem_data_in->num_faces == ts->t8_element_num_faces (element)); + T8_ASSERT (elem_data_in->num_faces == ts->element_get_num_faces (tree_class, element)); for (iface = 0; iface < elem_data_in->num_faces; iface++) { elem_data_in->num_neighbors[iface] = 0; elem_data_in->flux_valid[iface] = -1; @@ -902,7 +902,7 @@ t8_advect_problem_init (t8_cmesh_t cmesh, t8_flow_function_3d_fn u, t8_example_l int dummy_op, int volume_refine) { t8_advect_problem_t *problem; - t8_scheme_cxx_t *default_scheme; + t8_scheme *default_scheme; int i; T8_ASSERT (1 <= dim && dim <= 3); @@ -987,7 +987,7 @@ t8_advect_problem_init_elements (t8_advect_problem_t *problem) t8_element_t **neighbors; int iface, ineigh; t8_advect_element_data_t *elem_data; - t8_eclass_scheme_c *ts, *neigh_scheme; + t8_scheme *ts, *neigh_scheme; double speed, max_speed = 0, min_diam = -1, delta_t, min_delta_t; double u[3]; double diam; @@ -1196,7 +1196,7 @@ t8_advect_solve (t8_cmesh_t cmesh, t8_flow_function_3d_fn u, t8_example_level_se int adapted_or_partitioned = 0; int dual_face; t8_element_t **neighs; - t8_eclass_scheme_c *neigh_scheme; + t8_scheme *neigh_scheme; double total_time, solve_time = 0; double ghost_exchange_time, ghost_waittime, neighbor_time, flux_time; double vtk_time = 0; diff --git a/example/cmesh/t8_cmesh_hypercube_pad.cxx b/example/cmesh/t8_cmesh_hypercube_pad.cxx index 8e9ca6021b..3b023caba5 100644 --- a/example/cmesh/t8_cmesh_hypercube_pad.cxx +++ b/example/cmesh/t8_cmesh_hypercube_pad.cxx @@ -54,7 +54,7 @@ main (int argc, char **argv) t8_global_productionf (" [step1] Created coarse mesh.\n"); t8_global_productionf (" [step1] Local number of trees:\t%i\n", local_num_trees); t8_global_productionf (" [step1] Global number of trees:\t%li\n", global_num_trees); - t8_scheme_cxx *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default_cxx (); t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, 0, 0, sc_MPI_COMM_WORLD); t8_forest_vtk_write_file (forest, prefix, 1, 1, 1, 1, 0, 0, NULL); t8_forest_unref (&forest); diff --git a/example/common/t8_example_common.cxx b/example/common/t8_example_common.cxx index e474aa2e75..bbfb249874 100644 --- a/example/common/t8_example_common.cxx +++ b/example/common/t8_example_common.cxx @@ -39,7 +39,7 @@ T8_EXTERN_C_BEGIN (); */ int t8_common_adapt_balance (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { int level; int maxlevel, child_id; @@ -62,7 +62,7 @@ t8_common_adapt_balance (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_ } int -t8_common_within_levelset (t8_forest_t forest, t8_locidx_t ltreeid, t8_element_t *element, t8_eclass_scheme_c *ts, +t8_common_within_levelset (t8_forest_t forest, t8_locidx_t ltreeid, t8_element_t *element, t8_scheme *ts, t8_example_level_set_fn levelset, double band_width, double t, void *udata) { double elem_midpoint[3], elem_diam; @@ -116,8 +116,7 @@ t8_common_within_levelset (t8_forest_t forest, t8_locidx_t ltreeid, t8_element_t /* TODO: Currently the band_width control is not working yet. */ int t8_common_adapt_level_set (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, - t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { t8_example_level_set_struct_t *data; int within_band; diff --git a/example/common/t8_example_common.h b/example/common/t8_example_common.h index 503dad0475..2789622891 100644 --- a/example/common/t8_example_common.h +++ b/example/common/t8_example_common.h @@ -77,7 +77,7 @@ T8_EXTERN_C_BEGIN (); * the zero level-set passes through \a element. */ int -t8_common_within_levelset (t8_forest_t forest, t8_locidx_t ltreeid, t8_element_t *element, t8_eclass_scheme_c *ts, +t8_common_within_levelset (t8_forest_t forest, t8_locidx_t ltreeid, t8_element_t *element, t8_scheme_c *ts, t8_example_level_set_fn levelset, double band_width, double t, void *udata); /** Adapt a forest such that always the second child of the first @@ -86,7 +86,7 @@ t8_common_within_levelset (t8_forest_t forest, t8_locidx_t ltreeid, t8_element_t */ int t8_common_adapt_balance (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]); + t8_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]); /** Adapt a forest along a given level-set function. * The user data of forest must be a pointer to a \a t8_example_level_set_struct_t. @@ -97,8 +97,7 @@ t8_common_adapt_balance (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_ * if band_with = 0, then all elements that are touched by the zero LS are refined. */ int t8_common_adapt_level_set (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, - t8_element_t *elements[]); + t8_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]); /** Real valued functions defined in t8_example_common_functions.h */ diff --git a/example/forest/t8_face_neighbor.cxx b/example/forest/t8_face_neighbor.cxx index e95fe3d497..9d13516fdc 100644 --- a/example/forest/t8_face_neighbor.cxx +++ b/example/forest/t8_face_neighbor.cxx @@ -38,8 +38,8 @@ t8_ghost_neighbor_test (t8_eclass_t eclass, sc_MPI_Comm comm, int hybrid) t8_cmesh_t cmesh; t8_forest_t forest; t8_element_t *elem, *neigh; - t8_scheme_cxx_t *scheme; - t8_eclass_scheme_c *neigh_scheme; + t8_scheme *scheme; + t8_scheme *neigh_scheme; t8_default_scheme_common_c *common_scheme; int level = 1; t8_locidx_t element_id = 0, treeid; diff --git a/example/forest/t8_test_face_iterate.cxx b/example/forest/t8_test_face_iterate.cxx index b469afbc0f..0d5461d87f 100644 --- a/example/forest/t8_test_face_iterate.cxx +++ b/example/forest/t8_test_face_iterate.cxx @@ -60,7 +60,7 @@ t8_test_fiterate_callback (t8_forest_t forest, t8_locidx_t ltreeid, const t8_ele /* Only refine the first tree on a process. */ static int t8_basic_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { int mpirank, mpiret; T8_ASSERT (!is_family || num_elements == ts->t8_element_num_children (elements[0])); @@ -77,7 +77,7 @@ t8_test_fiterate (t8_forest_t forest) { t8_locidx_t itree, num_trees; t8_eclass_t eclass; - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_element_t *nca; t8_element_array_t *leaf_elements; t8_test_fiterate_udata_t udata; diff --git a/example/forest/t8_test_ghost.cxx b/example/forest/t8_test_ghost.cxx index 63468d9faa..75750dd500 100644 --- a/example/forest/t8_test_ghost.cxx +++ b/example/forest/t8_test_ghost.cxx @@ -45,7 +45,7 @@ typedef enum { */ int t8_refine_p8est (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { int id; T8_ASSERT (!is_family || num_elements == ts->t8_element_num_children (elements[0])); @@ -57,8 +57,8 @@ t8_refine_p8est (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_ /* Refine every third element. */ static int t8_adapt_every_third_element (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]) + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { int level; T8_ASSERT (!is_family || num_elements == ts->t8_element_num_children (elements[0])); diff --git a/example/forest/t8_test_ghost_large_level_diff.cxx b/example/forest/t8_test_ghost_large_level_diff.cxx index 02481ff90a..541433e823 100644 --- a/example/forest/t8_test_ghost_large_level_diff.cxx +++ b/example/forest/t8_test_ghost_large_level_diff.cxx @@ -68,7 +68,7 @@ */ static int t8_ghost_fractal_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { int level; int type, child_id; diff --git a/example/geometry/t8_example_geometries.cxx b/example/geometry/t8_example_geometries.cxx index 0139974b6e..744582ba31 100644 --- a/example/geometry/t8_example_geometries.cxx +++ b/example/geometry/t8_example_geometries.cxx @@ -519,7 +519,7 @@ struct t8_geometry_cube_zdistorted: public t8_geometry * domain boundary up to a given maximum refinement level. */ static int t8_geom_adapt_boundary (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t ltree_id, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { t8_cmesh_t cmesh = t8_forest_get_cmesh (forest_from); /* Get the number of faces of the element. */ diff --git a/example/remove/t8_example_empty_trees.cxx b/example/remove/t8_example_empty_trees.cxx index af9523dc2f..7447d27b49 100644 --- a/example/remove/t8_example_empty_trees.cxx +++ b/example/remove/t8_example_empty_trees.cxx @@ -35,7 +35,7 @@ T8_EXTERN_C_BEGIN (); * global trees which is given by the user_data. */ static int t8_adapt_remove (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const t8_gloidx_t *tree_id = (const t8_gloidx_t *) t8_forest_get_user_data (forest); const t8_gloidx_t global_tree_id = t8_forest_global_tree_id (forest_from, which_tree); diff --git a/example/remove/t8_example_gauss_blob.cxx b/example/remove/t8_example_gauss_blob.cxx index a20e80b72b..dce89ce3d6 100644 --- a/example/remove/t8_example_gauss_blob.cxx +++ b/example/remove/t8_example_gauss_blob.cxx @@ -97,7 +97,7 @@ t8_output_data_to_vtu (t8_forest_t forest, double *data, const char *prefix) /* Refine, if element is within a given radius. */ static int t8_adapt_refine (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const struct t8_adapt_data *adapt_data = (const struct t8_adapt_data *) t8_forest_get_user_data (forest); T8_ASSERT (adapt_data != NULL); @@ -115,7 +115,7 @@ t8_adapt_refine (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_ /* Remove, element if it is within our outside a given radius. */ static int t8_adapt_remove (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const struct t8_adapt_data *adapt_data = (const struct t8_adapt_data *) t8_forest_get_user_data (forest); T8_ASSERT (adapt_data != NULL); diff --git a/example/remove/t8_example_spheres.cxx b/example/remove/t8_example_spheres.cxx index 8bf69883ce..aedbc302d2 100644 --- a/example/remove/t8_example_spheres.cxx +++ b/example/remove/t8_example_spheres.cxx @@ -40,7 +40,7 @@ struct t8_adapt_data /* Refine, if element is within a given radius. */ static int t8_adapt_callback_refine (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const struct t8_adapt_data *adapt_data = (const struct t8_adapt_data *) t8_forest_get_user_data (forest); T8_ASSERT (adapt_data != NULL); @@ -60,7 +60,7 @@ t8_adapt_callback_refine (t8_forest_t forest, t8_forest_t forest_from, t8_locidx /* Remove, element if it is within a given radius. */ static int t8_adapt_callback_remove (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const struct t8_adapt_data *adapt_data = (const struct t8_adapt_data *) t8_forest_get_user_data (forest); T8_ASSERT (adapt_data != NULL); diff --git a/src/t8_cmesh.h b/src/t8_cmesh.h index 3c0a6b68b0..d58a995a36 100644 --- a/src/t8_cmesh.h +++ b/src/t8_cmesh.h @@ -222,14 +222,14 @@ t8_cmesh_set_partition_offsets (t8_cmesh_t cmesh, t8_shmem_array_t tree_offsets) * referencing \b ts before calling this function. */ void -t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, int element_level, t8_scheme_cxx_t *ts); +t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, int element_level, t8_scheme_c *ts); /** Refine the cmesh to a given level. * Thus split each tree into x^level subtrees * TODO: implement */ /* If level = 0 then no refinement is performed */ void -t8_cmesh_set_refine (t8_cmesh_t cmesh, int level, t8_scheme_cxx_t *scheme); +t8_cmesh_set_refine (t8_cmesh_t cmesh, int level, t8_scheme_c *scheme); /** Set the dimension of a cmesh. If any tree is inserted to the cmesh * via \a t8_cmesh_set_tree_class, then the dimension is set automatically @@ -742,7 +742,7 @@ t8_cmesh_get_partition_table (t8_cmesh_t cmesh); * \a cmesh must be committed before calling this function. * */ void -t8_cmesh_uniform_bounds (t8_cmesh_t cmesh, int level, const t8_scheme_cxx_t *ts, t8_gloidx_t *first_local_tree, +t8_cmesh_uniform_bounds (t8_cmesh_t cmesh, int level, const t8_scheme_c *ts, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared); diff --git a/src/t8_cmesh/t8_cmesh.cxx b/src/t8_cmesh/t8_cmesh.cxx index f4684d19a3..874c2fcc9d 100644 --- a/src/t8_cmesh/t8_cmesh.cxx +++ b/src/t8_cmesh/t8_cmesh.cxx @@ -273,7 +273,7 @@ t8_cmesh_set_partition_offsets (t8_cmesh_t cmesh, t8_shmem_array_t tree_offsets) } void -t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, const int element_level, t8_scheme_cxx_t *ts) +t8_cmesh_set_partition_uniform (t8_cmesh_t cmesh, const int element_level, t8_scheme *ts) { T8_ASSERT (t8_cmesh_is_initialized (cmesh)); T8_ASSERT (element_level >= -1); @@ -1268,7 +1268,7 @@ t8_cmesh_reset (t8_cmesh_t *pcmesh) /* unref the partition scheme (if set) */ if (cmesh->set_partition_scheme != NULL) { - t8_scheme_cxx_unref (&cmesh->set_partition_scheme); + t8_schemexx_unref (&cmesh->set_partition_scheme); } T8_FREE (cmesh); @@ -1420,7 +1420,7 @@ t8_cmesh_debug_print_trees (const t8_cmesh_t cmesh, sc_MPI_Comm comm) } void -t8_cmesh_uniform_bounds (t8_cmesh_t cmesh, const int level, const t8_scheme_cxx_t *ts, t8_gloidx_t *first_local_tree, +t8_cmesh_uniform_bounds (t8_cmesh_t cmesh, const int level, const t8_scheme *ts, t8_gloidx_t *first_local_tree, t8_gloidx_t *child_in_tree_begin, t8_gloidx_t *last_local_tree, t8_gloidx_t *child_in_tree_end, int8_t *first_tree_shared) { @@ -1449,7 +1449,7 @@ t8_cmesh_uniform_bounds (t8_cmesh_t cmesh, const int level, const t8_scheme_cxx_ t8_gloidx_t prev_last_tree = -1; #endif int tree_class; - t8_eclass_scheme_c *tree_scheme; + t8_scheme *tree_scheme; /* Compute the number of children on level in each tree */ global_num_children = 0; diff --git a/src/t8_cmesh/t8_cmesh_partition.cxx b/src/t8_cmesh/t8_cmesh_partition.cxx index b9de8fbc54..3a95266746 100644 --- a/src/t8_cmesh/t8_cmesh_partition.cxx +++ b/src/t8_cmesh/t8_cmesh_partition.cxx @@ -1545,7 +1545,7 @@ t8_cmesh_partition (t8_cmesh_t cmesh, sc_MPI_Comm comm) t8_cmesh_t cmesh_from; t8_gloidx_t last_tree; const t8_gloidx_t *tree_offsets; - t8_scheme_cxx_t *ts; + t8_scheme *ts; T8_ASSERT (t8_cmesh_is_committed (cmesh->set_from)); T8_ASSERT (t8_cmesh_is_initialized (cmesh)); diff --git a/src/t8_cmesh/t8_cmesh_types.h b/src/t8_cmesh/t8_cmesh_types.h index 854d80c471..60685c6387 100644 --- a/src/t8_cmesh/t8_cmesh_types.h +++ b/src/t8_cmesh/t8_cmesh_types.h @@ -96,21 +96,21 @@ typedef struct t8_cmesh see \ref t8_cmesh_set_partition. */ - t8_scheme_cxx_t *set_partition_scheme; /**< If the cmesh is to be partitioned according to a uniform level, + t8_scheme_c *set_partition_scheme; /**< If the cmesh is to be partitioned according to a uniform level, the scheme that describes the refinement pattern. See \ref t8_cmesh_set_partition. */ - int8_t set_partition_level; /**< Non-negative if the cmesh should be partitioned from an already existing cmesh + int8_t set_partition_level; /**< Non-negative if the cmesh should be partitioned from an already existing cmesh with an assumed \a level uniform mesh underneath. */ - struct t8_cmesh *set_from; /**< If this cmesh shall be derived from an + struct t8_cmesh *set_from; /**< If this cmesh shall be derived from an existing cmesh by copy or more elaborate modification, we store a pointer to this other cmesh here. */ - int mpirank; /**< Number of this MPI process. */ - int mpisize; /**< Number of MPI processes. */ - t8_refcount_t rc; /**< The reference count of the cmesh. */ - t8_gloidx_t num_trees; /**< The global number of trees */ - t8_locidx_t num_local_trees; /**< If partitioned the number of trees on this process. + int mpirank; /**< Number of this MPI process. */ + int mpisize; /**< Number of MPI processes. */ + t8_refcount_t rc; /**< The reference count of the cmesh. */ + t8_gloidx_t num_trees; /**< The global number of trees */ + t8_locidx_t num_local_trees; /**< If partitioned the number of trees on this process. Otherwise the global number of trees. */ - t8_locidx_t num_ghosts; /**< If partitioned the number of neighbor trees + t8_locidx_t num_ghosts; /**< If partitioned the number of neighbor trees owned by different processes. */ /* TODO: wouldnt a local num_trees_per_eclass be better? * only as an additional info. we need the global count. i.e. for forest_maxlevel computation. diff --git a/src/t8_data/t8_containers.cxx b/src/t8_data/t8_containers.cxx index 70d7495cad..064a344262 100644 --- a/src/t8_data/t8_containers.cxx +++ b/src/t8_data/t8_containers.cxx @@ -53,7 +53,7 @@ t8_element_array_is_valid (const t8_element_array_t *element_array) #endif t8_element_array_t * -t8_element_array_new (t8_eclass_scheme_c *scheme) +t8_element_array_new (t8_scheme *scheme) { t8_element_array_t *new_array; @@ -67,7 +67,7 @@ t8_element_array_new (t8_eclass_scheme_c *scheme) } t8_element_array_t * -t8_element_array_new_count (t8_eclass_scheme_c *scheme, size_t num_elements) +t8_element_array_new_count (t8_scheme *scheme, size_t num_elements) { t8_element_array_t *new_array; @@ -81,7 +81,7 @@ t8_element_array_new_count (t8_eclass_scheme_c *scheme, size_t num_elements) } void -t8_element_array_init (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme) +t8_element_array_init (t8_element_array_t *element_array, t8_scheme *scheme) { size_t elem_size; @@ -96,7 +96,7 @@ t8_element_array_init (t8_element_array_t *element_array, t8_eclass_scheme_c *sc } void -t8_element_array_init_size (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, size_t num_elements) +t8_element_array_init_size (t8_element_array_t *element_array, t8_scheme *scheme, size_t num_elements) { t8_element_t *first_element; T8_ASSERT (element_array != NULL); @@ -126,7 +126,7 @@ t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, } void -t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_eclass_scheme_c *scheme, size_t elem_count) +t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_scheme *scheme, size_t elem_count) { /* Initialize the element array */ sc_array_init_data (&view->array, (void *) base, scheme->t8_element_size (), elem_count); @@ -136,7 +136,7 @@ t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_ecl } void -t8_element_array_init_copy (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, t8_element_t *data, +t8_element_array_init_copy (t8_element_array_t *element_array, t8_scheme *scheme, t8_element_t *data, size_t num_elements) { sc_array_t *array; @@ -256,7 +256,7 @@ t8_element_array_index_int_mutable (t8_element_array_t *element_array, int index return (t8_element_t *) t8_element_array_index_int (element_array, index); } -const t8_eclass_scheme_c * +const t8_scheme * t8_element_array_get_scheme (const t8_element_array_t *element_array) { T8_ASSERT (t8_element_array_is_valid (element_array)); diff --git a/src/t8_data/t8_containers.h b/src/t8_data/t8_containers.h index 28f6547bce..5d9b4fa0b9 100644 --- a/src/t8_data/t8_containers.h +++ b/src/t8_data/t8_containers.h @@ -40,8 +40,8 @@ */ typedef struct { - t8_eclass_scheme_c *scheme; /**< An eclass scheme of which elements should be stored */ - sc_array_t array; /**< The array in which the elements are stored */ + t8_scheme_c *scheme; /**< An eclass scheme of which elements should be stored */ + sc_array_t array; /**< The array in which the elements are stored */ } t8_element_array_t; T8_EXTERN_C_BEGIN (); @@ -51,7 +51,7 @@ T8_EXTERN_C_BEGIN (); * \return Return an allocated array of zero length. */ t8_element_array_t * -t8_element_array_new (t8_eclass_scheme_c *scheme); +t8_element_array_new (t8_scheme_c *scheme); /** Creates a new array structure with a given length (number of elements) * and calls \ref t8_element_new for those elements. @@ -62,14 +62,14 @@ t8_element_array_new (t8_eclass_scheme_c *scheme); * t8_element_new was called. */ t8_element_array_t * -t8_element_array_new_count (t8_eclass_scheme_c *scheme, size_t num_elements); +t8_element_array_new_count (t8_scheme_c *scheme, size_t num_elements); /** Initializes an already allocated (or static) array structure. * \param [in,out] element_array Array structure to be initialized. * \param [in] scheme The eclass scheme of which elements should be stored. */ void -t8_element_array_init (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme); +t8_element_array_init (t8_element_array_t *element_array, t8_scheme_c *scheme); /** Initializes an already allocated (or static) array structure * and allocates a given number of elements and initializes them with \ref t8_element_init. @@ -78,7 +78,7 @@ t8_element_array_init (t8_element_array_t *element_array, t8_eclass_scheme_c *sc * \param [in] num_elements Number of initial array elements. */ void -t8_element_array_init_size (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, size_t num_elements); +t8_element_array_init_size (t8_element_array_t *element_array, t8_scheme_c *scheme, size_t num_elements); /** Initializes an already allocated (or static) view from existing t8_element_array. * The array view returned does not require t8_element_array_reset (doesn't hurt though). @@ -105,8 +105,7 @@ t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, * It is not necessary to call t8_element_array_reset later. */ void -t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_eclass_scheme_c *scheme, - size_t elem_count); +t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_scheme_c *scheme, size_t elem_count); /** Initializes an already allocated (or static) array structure * and copy an existing array of t8_element_t into it. @@ -119,7 +118,7 @@ t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_ecl * \param [in] num_elements Number of elements in \a data to be copied. */ void -t8_element_array_init_copy (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, t8_element_t *data, +t8_element_array_init_copy (t8_element_array_t *element_array, t8_scheme_c *scheme, t8_element_t *data, size_t num_elements); /** Change the number of elements stored in an element array. @@ -197,7 +196,7 @@ t8_element_array_index_int_mutable (t8_element_array_t *element_array, int index * \param [in] element_array Array of elements. * \return The eclass scheme stored at \a element_array. */ -const t8_eclass_scheme_c * +const t8_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array); /** Return the number of elements stored in a t8_element_array_t. diff --git a/src/t8_element.cxx b/src/t8_element.cxx index 8ebe3fe0e1..5cb5d66841 100644 --- a/src/t8_element.cxx +++ b/src/t8_element.cxx @@ -52,7 +52,7 @@ const double t8_element_centroid_ref_coords[T8_ECLASS_COUNT][3] = { /* clang-format on */ void -t8_scheme_cxx_ref (t8_scheme_cxx_t *scheme) +t8_schemexx_ref (t8_scheme *scheme) { T8_ASSERT (scheme != NULL); @@ -60,22 +60,22 @@ t8_scheme_cxx_ref (t8_scheme_cxx_t *scheme) } void -t8_scheme_cxx_unref (t8_scheme_cxx_t **pscheme) +t8_schemexx_unref (t8_scheme **pscheme) { - t8_scheme_cxx_t *scheme; + t8_scheme *scheme; T8_ASSERT (pscheme != NULL); scheme = *pscheme; T8_ASSERT (scheme != NULL); if (sc_refcount_unref (&scheme->rc)) { - t8_scheme_cxx_destroy (scheme); + t8_schemexx_destroy (scheme); *pscheme = NULL; } } void -t8_scheme_cxx_destroy (t8_scheme_cxx_t *s) +t8_schemexx_destroy (t8_scheme *s) { int t; diff --git a/src/t8_element.h b/src/t8_element.h index ce43592a47..76f5272fcd 100644 --- a/src/t8_element.h +++ b/src/t8_element.h @@ -41,20 +41,10 @@ T8_EXTERN_C_BEGIN (); */ typedef struct t8_element t8_element_t; -/** This typedef holds virtual functions for a particular element class. */ -typedef struct t8_eclass_scheme t8_eclass_scheme_c; - -typedef struct t8_scheme_cxx t8_scheme_cxx_t; - -/** The scheme holds implementations for one or more element classes. */ -struct t8_scheme_cxx -{ - /** Reference counter for this scheme. */ - sc_refcount_t rc; - - /** This array holds one virtual table per element class. */ - t8_eclass_scheme_c *eclass_schemes[T8_ECLASS_COUNT]; -}; +/** The scheme holds implementations for one or more element classes. + * Opaque pointer for C interface. + */ +typedef struct t8_scheme t8_scheme_c; /** This array holds the reference coordinates of each vertex of each element. * It can e.g. be used with the \ref t8_element_reference_coords function. @@ -73,7 +63,7 @@ extern const double t8_element_centroid_ref_coords[T8_ECLASS_COUNT][3]; * exist with positive reference count. */ void -t8_scheme_cxx_ref (t8_scheme_cxx_t *scheme); +t8_scheme_cxx_ref (t8_scheme_c *scheme); /** Decrease the reference counter of a scheme. * If the counter reaches zero, this scheme is destroyed. @@ -85,11 +75,11 @@ t8_scheme_cxx_ref (t8_scheme_cxx_t *scheme); * the scheme is not modified in other ways. */ void -t8_scheme_cxx_unref (t8_scheme_cxx_t **pscheme); +t8_scheme_cxx_unref (t8_scheme_c **pscheme); /* TODO: document, see t8_element.hxx */ extern void -t8_scheme_cxx_destroy (t8_scheme_cxx_t *s); +t8_scheme_cxx_destroy (t8_scheme_c *s); T8_EXTERN_C_END (); diff --git a/src/t8_element.hxx b/src/t8_element.hxx index 53effbff9f..631be78334 100644 --- a/src/t8_element.hxx +++ b/src/t8_element.hxx @@ -3,7 +3,7 @@ t8code is a C library to manage a collection (a forest) of multiple connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2015 the developers + Copyright (C) 2024 the developers t8code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,8 +23,8 @@ /** \file t8_element.hxx * This file defines basic operations on an element in a refinement tree. * - * All operations work for all element classes by providing a virtual function table. - * For each element class, one implementation of the type and virtual table is required. + * All operations work for all element classes by providing a inline function table. + * For each element class, one implementation of the type and inline table is required. */ #pragma once @@ -32,12 +32,17 @@ #include #include #include +#include T8_EXTERN_C_BEGIN (); -/** This struct holds virtual functions for a particular element class. */ -struct t8_eclass_scheme -{ +/** This class holds functions for a particular element class. */ +template +class t8_eclass_scheme: public crtp { + private: + t8_scheme () {}; /**< private destructor which can only be used by derived schemes. */ + friend TUnderlyingEclassScheme; + protected: size_t element_size; /**< The size in bytes of an element of class \a eclass */ void *ts_context; /**< Anonymous implementation context. */ @@ -48,45 +53,53 @@ struct t8_eclass_scheme /** The destructor. It does nothing but has to be defined since * we may want to delete an eclass_scheme that is actually inherited - * (for example t8_default_scheme_quad) and providing an implementation + * (for example t8_default_scheme_quad_c) and providing an implementation * for the destructor ensures that the * destructor of the child class will be executed. */ - virtual ~t8_eclass_scheme () + ~t8_scheme () { + this->underlying ().~TUnderlyingEclassScheme (); } - /** The virtual table for a particular implementation of an element class. */ - /** Return the size of any element of a given class. * \return The size of an element of class \b ts. * We provide a default implementation of this routine that should suffice * for most use cases. */ - virtual size_t - t8_element_size (void) const; + inline size_t + get_element_size (void) const + { + return this->underlying ().get_element_size (elem); + }; /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * \return non-zero if there is one element in the tree that does not refine into 2^dim children. */ - virtual int - t8_element_refines_irregular (void) const - = 0; + inline int + refines_irregular (void) const + { + return this->underlying ().refines_irregular (); + }; /** Return the maximum allowed level for any element of a given class. * \return The maximum allowed level for elements of class \b ts. */ - virtual int - t8_element_maxlevel (void) const - = 0; + inline int + get_maxlevel (void) const + { + return this->underlying ().get_maxlevel (); + }; /** Return the level of a particular element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - virtual int - t8_element_level (const t8_element_t *elem) const - = 0; + inline int + element_get_level (const t8_element_t *elem) const + { + return this->underlying ().element_get_level (elem); + }; /** Copy all entries of \b source to \b dest. \b dest must be an existing * element. No memory is allocated by this function. @@ -95,9 +108,11 @@ struct t8_eclass_scheme * entries of \b source. * \note \a source and \a dest may point to the same element. */ - virtual void - t8_element_copy (const t8_element_t *source, t8_element_t *dest) const - = 0; + inline void + element_copy (const t8_element_t *source, t8_element_t *dest) const + { + this->underlying ().element_copy (source, dest); + }; /** Compare two elements. * \param [in] elem1 The first element. @@ -106,9 +121,11 @@ struct t8_eclass_scheme * and positive if elem1 > elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - virtual int - t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const - = 0; + inline int + element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const + { + return this->underlying ().element_compare (elem1, elem2); + }; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -116,9 +133,11 @@ struct t8_eclass_scheme * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - virtual int - t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const - = 0; + inline int + element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const + { + return this->underlying ().element_is_equal (elem1, elem2); + }; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -132,9 +151,11 @@ struct t8_eclass_scheme * For a pyramid, for example, it may be either a * tetrahedron or a pyramid depending on \b elem's childid. */ - virtual void - t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const - = 0; + inline void + element_get_parent (const t8_element_t *elem, t8_element_t *parent) const + { + this->underlying ().element_get_parent (elem, parent); + }; /** Compute the number of siblings of an element. That is the number of * Children of its parent. @@ -142,9 +163,11 @@ struct t8_eclass_scheme * \return The number of siblings of \a element. * Note that this number is >= 1, since we count the element itself as a sibling. */ - virtual int - t8_element_num_siblings (const t8_element_t *elem) const - = 0; + inline int + element_get_num_siblings (const t8_element_t *elem) const + { + return this->underlying ().element_get_num_siblings (elem); + }; /** Compute a specific sibling of a given element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -157,51 +180,63 @@ struct t8_eclass_scheme * The storage for this element must exist * and match the element class of the sibling. */ - virtual void - t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const - = 0; + inline void + element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const + { + this->underlying ().element_get_sibling (elem, sibid, sibling); + }; /** Compute the number of corners of a given element. * \param [in] elem The element. * \return The number of corners of \a elem. */ - virtual int - t8_element_num_corners (const t8_element_t *elem) const - = 0; + inline int + element_get_num_corners (const t8_element_t *elem) const + { + return this->underlying ().element_get_num_corners (elem); + }; /** Compute the number of faces of a given element. * \param [in] elem The element. * \return The number of faces of \a elem. */ - virtual int - t8_element_num_faces (const t8_element_t *elem) const - = 0; + inline int + element_get_num_faces (const t8_element_t *elem) const + { + return this->underlying ().element_get_num_faces (elem); + }; /** Compute the maximum number of faces of a given element and all of its * descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - virtual int - t8_element_max_num_faces (const t8_element_t *elem) const - = 0; + inline int + element_get_max_num_faces (const t8_element_t *elem) const + { + return this->underlying ().element_get_max_num_faces (elem); + }; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - virtual int - t8_element_num_children (const t8_element_t *elem) const - = 0; + inline int + element_get_num_children (const t8_element_t *elem) const + { + return this->underlying ().element_get_num_children (elem); + }; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - virtual int - t8_element_num_face_children (const t8_element_t *elem, int face) const - = 0; + inline int + element_get_num_face_children (const t8_element_t *elem, int face) const + { + return this->underlying ().element_get_num_face_children (elem, face); + }; /** Return the corner number of an element's face corner. * Example quad: 2 x --- x 3 @@ -215,9 +250,11 @@ struct t8_eclass_scheme * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - virtual int - t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const - = 0; + inline int + element_get_face_corner (const t8_element_t *element, int face, int corner) const + { + return this->underlying ().element_get_face_corner (element, face, corner); + }; /** Return the face numbers of the faces sharing an element's corner. * Example quad: 2 x --- x 3 @@ -231,9 +268,11 @@ struct t8_eclass_scheme * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - virtual int - t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const - = 0; + inline int + element_get_corner_face (const t8_element_t *element, int corner, int face) const + { + return this->underlying ().element_get_corner_face (element, corner, face); + }; /** Construct the child element of a given number. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -242,9 +281,11 @@ struct t8_eclass_scheme * On output, a valid element. * It is valid to call this function with elem = child. */ - virtual void - t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const - = 0; + inline void + element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const + { + this->underlying ().element_get_child (elem, childid, child); + }; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -255,17 +296,21 @@ struct t8_eclass_scheme * It is valid to call this function with elem = c[0]. * \see t8_element_num_children */ - virtual void - t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const - = 0; + inline void + element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const + { + this->underlying ().element_get_children (elem, length, c); + }; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - virtual int - t8_element_child_id (const t8_element_t *elem) const - = 0; + inline int + element_get_child_id (const t8_element_t *elem) const + { + return this->underlying ().element_get_child_id (elem); + }; /** Compute the ancestor id of an element, that is the child id * at a given level. @@ -273,9 +318,11 @@ struct t8_eclass_scheme * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - virtual int - t8_element_ancestor_id (const t8_element_t *elem, int level) const - = 0; + inline int + element_get_ancestor_id (const t8_element_t *elem, int level) const + { + return this->underlying ().element_get_ancestor_id (elem, level); + }; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class @@ -283,9 +330,11 @@ struct t8_eclass_scheme * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - virtual int - t8_element_is_family (t8_element_t *const *fam) const - = 0; + inline int + element_is_family (t8_element_t *const *fam) const + { + return this->underlying ().element_is_family (fam); + }; /** Compute the nearest common ancestor of two elements. That is, * the element with highest level that still has both given elements as @@ -297,9 +346,11 @@ struct t8_eclass_scheme * On output the unique nearest common ancestor of * \b elem1 and \b elem2. */ - virtual void - t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const - = 0; + inline void + element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const + { + this->underlying ().element_get_nca (elem1, elem2, nca); + }; /** Compute the shape of the face of an element. * \param [in] elem The element. @@ -309,9 +360,11 @@ struct t8_eclass_scheme * and depending on the face number either T8_ECLASS_QUAD or * T8_ECLASS_TRIANGLE for prisms. */ - virtual t8_element_shape_t - t8_element_face_shape (const t8_element_t *elem, int face) const - = 0; + inline t8_element_shape_t + element_get_face_shape (const t8_element_t *elem, int face) const + { + return this->underlying ().element_get_face_shape (elem, face); + }; /** Given an element and a face of the element, compute all children of * the element that touch the face. @@ -327,10 +380,12 @@ struct t8_eclass_scheme * on output its i-th entry is the child_id of the i-th face_child. * It is valid to call this function with elem = children[0]. */ - virtual void - t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const - = 0; + inline void + element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const + { + this->underlying ().element_get_children_at_face (elem, face, children, num_children, child_indices); + }; /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -352,9 +407,11 @@ struct t8_eclass_scheme * \return The face number of the face of a child of \a elem * that coincides with \a face_child. */ - virtual int - t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const - = 0; + inline int + element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const + { + return this->underlying ().element_face_get_child_face (elem, face, face_child); + }; /** Given a face of an element return the face number * of the parent of the element that matches the element's face. Or return -1 if @@ -366,9 +423,11 @@ struct t8_eclass_scheme * the face number of this face. Otherwise -1. * \note For the root element this function always returns \a face. */ - virtual int - t8_element_face_parent_face (const t8_element_t *elem, int face) const - = 0; + inline int + element_face_get_parent_face (const t8_element_t *elem, int face) const + { + return this->underlying ().element_face_get_parent_face (elem, face); + }; /** Given an element and a face of this element. If the face lies on the * tree boundary, return the face number of the tree face. @@ -383,9 +442,11 @@ struct t8_eclass_scheme * \warning The return value may look like a valid face of the tree even if * the element does not lie on the root boundary. */ - virtual int - t8_element_tree_face (const t8_element_t *elem, int face) const - = 0; + inline int + element_get_tree_face (const t8_element_t *elem, int face) const + { + return this->underlying ().element_get_tree_face (elem, face); + }; /** Suppose we have two trees that share a common face f. * Given an element e that is a subface of f in one of the trees @@ -408,28 +469,33 @@ struct t8_eclass_scheme * defined in relation to the smaller face. * \note \a elem1 and \a elem2 may point to the same element. */ - virtual void - t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, - int is_smaller_face) const - = 0; + inline void + element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, + int is_smaller_face) const + { + this->underlying ().element_transform_face (elem1, elem2, orientation, sign, is_smaller_face); + }; /** Given a boundary face inside a root tree's face construct * the element inside the root tree that has the given face as a * face. * \param [in] face A face element. - * \param [in] face_scheme The scheme for the face element. + * \param [in] face_eclass The eclass of the face element. * \param [in,out] elem An allocated element. The entries will be filled with * the data of the element that has \a face as a face and * lies within the root tree. * \param [in] root_face The index of the face of the root tree in which \a face * lies. + * \param [in] scheme The scheme for the face eclass. * \return The face number of the face of \a elem that coincides * with \a face. */ - virtual int - t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const - = 0; + inline int + element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, t8_element_t *elem, int root_face, + t8_scheme *scheme) const + { + return this->underlying ().element_extrude_face (face, face_eclass, elem, root_face, scheme); + }; /** Construct the boundary element at a specific face. * \param [in] elem The input element. @@ -438,14 +504,17 @@ struct t8_eclass_scheme * \param [in,out] boundary An allocated element of dimension of \a element * minus 1. The entries will be filled with the entries * of the face of \a element. - * \param [in] boundary_scheme The scheme for the eclass of the boundary face. + * \param [in] boundary_face_eclass The eclass of the boundary face. + * \param [in] scheme The scheme for the boundary face. * If \a elem is of class T8_ECLASS_VERTEX, then \a boundary must be NULL * and will not be modified. */ - virtual void - t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const - = 0; + inline void + element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_eclass_t boundary_face_eclass, t8_scheme *scheme) const + { + this->underlying ().element_construct_boundary_face (elem, face, boundary, boundary_face_eclass, scheme); + }; /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -455,9 +524,12 @@ struct t8_eclass_scheme * that shares a face with \a face. * \param [in] level The level, at which the first descendant is constructed */ - virtual void - t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const - = 0; + inline void + element_construct_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, + int level) const + { + this->underlying ().element_construct_first_descendant_face (elem, face, first_desc, level); + }; /** Construct the last descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -467,9 +539,11 @@ struct t8_eclass_scheme * that shares a face with \a face. * \param [in] level The level, at which the last descendant is constructed */ - virtual void - t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const - = 0; + inline void + element_construct_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const + { + this->underlying ().element_construct_last_descendant_face (elem, face, last_desc, level); + }; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. @@ -477,9 +551,11 @@ struct t8_eclass_scheme * \return True if \a face is a subface of the element's root element. * \note You can compute the corresponding face number of the tree via \ref t8_element_tree_face. */ - virtual int - t8_element_is_root_boundary (const t8_element_t *elem, int face) const - = 0; + inline int + element_is_root_boundary (const t8_element_t *elem, int face) const + { + return this->underlying ().element_is_root_boundary (elem, face); + }; /** Construct the face neighbor of a given element if this face neighbor * is inside the root tree. Return 0 otherwise. @@ -496,18 +572,24 @@ struct t8_eclass_scheme * False if not. In this case \a neigh's data can be arbitrary * on output. */ - virtual int - t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const - = 0; + inline int + element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const + { + return this->underlying ().element_construct_face_neighbor_inside (elem, neigh, face, neigh_face); + }; + /** Return the shape of an allocated element according its type. * For example, a child of an element can be an element of a different shape * and has to be handled differently - according to its shape. * \param [in] elem The element to be considered * \return The shape of the element as an eclass */ - virtual t8_element_shape_t - t8_element_shape (const t8_element_t *elem) const - = 0; + inline t8_element_shape_t + element_get_shape (const t8_element_t *elem) const + { + return this->underlying ().element_get_shape (elem); + }; /** Initialize the entries of an allocated element according to a * given linear id in a uniform refinement. @@ -516,9 +598,11 @@ struct t8_eclass_scheme * \param [in] id The linear id. * id must fulfil 0 <= id < 'number of leaves in the uniform refinement' */ - virtual void - t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const - = 0; + inline void + element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const + { + this->underlying ().element_set_linear_id (elem, level, id); + }; /** Compute the linear id of a given element in a hypothetical uniform * refinement of a given level. @@ -526,9 +610,11 @@ struct t8_eclass_scheme * \param [in] level The level of the uniform refinement to consider. * \return The linear id of the element. */ - virtual t8_linearidx_t - t8_element_get_linear_id (const t8_element_t *elem, int level) const - = 0; + inline t8_linearidx_t + element_get_linear_id (const t8_element_t *elem, int level) const + { + return this->underlying ().element_get_linear_id (elem, level); + }; /** Compute the first descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -536,9 +622,11 @@ struct t8_eclass_scheme * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const - = 0; + inline void + element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const + { + this->underlying ().element_construct_first_descendant (elem, desc, level); + }; /** Compute the last descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -546,17 +634,21 @@ struct t8_eclass_scheme * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const - = 0; + inline void + element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const + { + this->underlying ().element_construct_last_descendant (elem, desc, level); + }; /** Construct the successor in a uniform refinement of a given element. * \param [in] elem1 The element whose successor should be constructed. * \param [in,out] elem2 The element whose entries will be set. */ - virtual void - t8_element_successor (const t8_element_t *t, t8_element_t *s) const - = 0; + inline void + element_construct_successor (const t8_element_t *t, t8_element_t *s) const + { + this->underlying ().element_construct_successor (t, s); + }; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). @@ -567,9 +659,11 @@ struct t8_eclass_scheme * \warning coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere * all coords might be used. */ - virtual void - t8_element_vertex_reference_coords (const t8_element_t *t, const int vertex, double coords[]) const - = 0; + inline void + element_get_vertex_reference_coords (const t8_element_t *t, const int vertex, double coords[]) const + { + this->underlying ().element_get_vertex_reference_coords (t, vertex, coords); + }; /** Convert points in the reference space of an element to points in the * reference space of the tree. @@ -581,10 +675,12 @@ struct t8_eclass_scheme * \param [out] out_coords The coordinates of the points in the * reference space of the tree. */ - virtual void - t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const - = 0; + inline void + element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, + double *out_coords) const + { + this->underlying ().element_get_reference_coords (elem, ref_coords, num_coords, out_coords); + }; /** Count how many leaf descendants of a given uniform level an element would produce. * \param [in] t The element to be checked. @@ -597,9 +693,11 @@ struct t8_eclass_scheme * then the return value is max(0, 2^{\a level - level(\a t)}). * Thus, if \a t's level is 0, and \a level = 3, the return value is 2^3 = 8. */ - virtual t8_gloidx_t - t8_element_count_leaves (const t8_element_t *t, int level) const - = 0; + inline t8_gloidx_t + element_count_leaves (const t8_element_t *t, int level) const + { + return this->underlying ().element_count_leaves (t, level); + }; /** Count how many leaf descendants of a given uniform level the root element will produce. * \param [in] level A refinement level. @@ -609,9 +707,11 @@ struct t8_eclass_scheme * This is a convenience function, and can be implemented via * \ref t8_element_count_leaves. */ - virtual t8_gloidx_t - t8_element_count_leaves_from_root (int level) const - = 0; + inline t8_gloidx_t + element_count_leaves_from_root (int level) const + { + return this->underlying ().element_count_leaves_from_root (level); + }; #ifdef T8_ENABLE_DEBUG /** Query whether a given element can be considered as 'valid' and it is @@ -630,9 +730,11 @@ struct t8_eclass_scheme * \note We recommend to use the assertion T8_ASSERT (t8_element_is_valid (elem)) * in the implementation of each of the functions in this file. */ - virtual int - t8_element_is_valid (const t8_element_t *elem) const - = 0; + inline int + element_is_valid (const t8_element_t *elem) const + { + return this->underlying ().element_is_valid (elem); + }; /** * Print a given element. For a example for a triangle print the coordinates @@ -641,9 +743,11 @@ struct t8_eclass_scheme * * \param [in] elem The element to print */ - virtual void - t8_element_debug_print (const t8_element_t *elem) const - = 0; + inline void + element_debug_print (const t8_element_t *elem) const + { + this->underlying ().element_debug_print (elem); + }; /** * \brief Fill a string with readable information about the element @@ -651,9 +755,11 @@ struct t8_eclass_scheme * \param[in] elem The element to translate into human-readable information * \param[in, out] debug_string The string to fill. */ - virtual void - t8_element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const - = 0; + inline void + element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const + { + this->underlying ().element_to_string (elem, debug_string, string_size); + }; #endif /** Allocate memory for \b length many elements of a given class and initialize them, @@ -677,9 +783,11 @@ struct t8_eclass_scheme * \see t8_element_init * \see t8_element_is_valid */ - virtual void - t8_element_new (int length, t8_element_t **elem) const - = 0; + inline void + element_new (int length, t8_element_t **elem) const + { + this->underlying ().element_new (length, elem); + }; /** Initialize an array of allocated elements. * \param [in] length The number of elements to be initialized. @@ -695,9 +803,11 @@ struct t8_eclass_scheme * \see t8_element_new * \see t8_element_is_valid */ - virtual void - t8_element_init (int length, t8_element_t *elem) const - = 0; + inline void + element_init (int length, t8_element_t *elem) const + { + this->underlying ().element_init (length, elem); + }; /** Deinitialize an array of allocated elements. * \param [in] length The number of elements to be deinitialized. @@ -707,9 +817,11 @@ struct t8_eclass_scheme * \note Call this function if you called t8_element_init on the element pointers. * \see t8_element_init */ - virtual void - t8_element_deinit (int length, t8_element_t *elem) const - = 0; + inline void + element_deinit (int length, t8_element_t *elem) const + { + this->underlying ().element_deinit (length, elem); + }; /** Deallocate an array of elements. * \param [in] length The number of elements in the array. @@ -719,16 +831,20 @@ struct t8_eclass_scheme * \b elem itself will not be freed by this function. * \see t8_element_new */ - virtual void - t8_element_destroy (int length, t8_element_t **elem) const - = 0; + inline void + element_destroy (int length, t8_element_t **elem) const + { + this->underlying ().element_destroy (length, elem); + }; /** create the root element * \param [in,out] elem The element that is filled with the root */ - virtual void - t8_element_root (t8_element_t *elem) const - = 0; + inline void + element_root (t8_element_t *elem) const + { + this->underlying ().element_root (elem); + }; /** Pack multiple elements into contiguous memory, so they can be sent via MPI. * \param [in] elements Array of elements that are to be packed @@ -738,19 +854,23 @@ struct t8_eclass_scheme * \param [in, out] position the position of the first byte that is not already packed * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, - int *position, sc_MPI_Comm comm) const - = 0; + inline void + element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, + int *position, sc_MPI_Comm comm) const + { + this->underlying ().element_MPI_Pack (elements, count, send_buffer, buffer_size, position, comm); + }; /** Determine an upper bound for the size of the packed message of \b count elements * \param [in] count Number of elements to pack * \param [in] comm MPI Communicator * \param [out] pack_size upper bound on the message size */ - virtual void - t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const - = 0; + inline void + element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const + { + this->underlying ().element_MPI_Pack_size (count, comm, pack_size); + }; /** Unpack multiple elements from contiguous memory that was received via MPI. * \param [in] recvbuf Buffer from which to unpack the elements @@ -760,15 +880,12 @@ struct t8_eclass_scheme * \param [in] count Number of elements to unpack * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, - const unsigned int count, sc_MPI_Comm comm) const - = 0; + inline void + element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const unsigned int count, sc_MPI_Comm comm) const + { + this->underlying ().element_MPI_Unpack (recvbuf, buffer_size, position, elements, count, comm); + }; }; -/** Destroy an implementation of a particular element class. - * param [in] scheme Defines the implementation of the element class. */ -void -t8_scheme_cxx_destroy (t8_scheme_cxx_t *s); - T8_EXTERN_C_END (); diff --git a/src/t8_element_c_interface.cxx b/src/t8_element_c_interface.cxx index 88d57e5f65..189455fdef 100644 --- a/src/t8_element_c_interface.cxx +++ b/src/t8_element_c_interface.cxx @@ -21,7 +21,7 @@ */ /* In this file we implement a C interface for the member functions of the - * t8_eclass_scheme_c class. + * t8_scheme class. * With this interface you can use these member functions from a C file * without the need of compiling it with C++. */ @@ -29,438 +29,486 @@ #include #include #include +#include +#include size_t -t8_element_size (const t8_eclass_scheme_c *ts) +t8_element_get_element_size (const t8_forest_t forest, const t8_eclass_t tree_class) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_size (); + return forest->scheme->get_element_size (tree_class); } int -t8_element_refines_irregular (const t8_eclass_scheme_c *ts) +t8_element_refines_irregular (const t8_forest_t forest, const t8_eclass_t tree_class) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_refines_irregular (); + return forest->scheme->refines_irregular (tree_class); } int -t8_element_maxlevel (const t8_eclass_scheme_c *ts) +t8_element_get_maxlevel (const t8_forest_t forest, const t8_eclass_t tree_class) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_maxlevel (); + return forest->scheme->get_maxlevel (tree_class); } int -t8_element_level (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +t8_element_get_level (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_level (elem); + return forest->scheme->element_get_level (tree_class, elem); } void -t8_element_copy (const t8_eclass_scheme_c *ts, const t8_element_t *source, t8_element_t *dest) +t8_element_copy (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *source, t8_element_t *dest) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_copy (source, dest); + return forest->scheme->element_copy (tree_class, source, dest); } int -t8_element_compare (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2) +t8_element_compare (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + const t8_element_t *elem2) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_compare (elem1, elem2); + return forest->scheme->element_compare (tree_class, elem1, elem2); } int -t8_element_equal (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2) +t8_element_is_equal (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + const t8_element_t *elem2) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_equal (elem1, elem2); + return forest->scheme->element_is_equal (tree_class, elem1, elem2); } void -t8_element_parent (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *parent) +t8_element_get_parent (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + t8_element_t *parent) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_parent (elem, parent); + return forest->scheme->element_get_parent (tree_class, elem, parent); } int -t8_element_num_siblings (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +t8_element_get_num_siblings (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_num_siblings (elem); + return forest->scheme->element_get_num_siblings (tree_class, elem); } void -t8_element_sibling (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int sibid, t8_element_t *sibling) +t8_element_get_sibling (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int sibid, + t8_element_t *sibling) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_sibling (elem, sibid, sibling); + return forest->scheme->element_get_sibling (tree_class, elem, sibid, sibling); } int -t8_element_num_corners (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +t8_element_get_num_corners (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_num_corners (elem); + return forest->scheme->element_get_num_corners (tree_class, elem); } int -t8_element_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +t8_element_get_num_faces (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_num_faces (elem); + return forest->scheme->element_get_num_faces (tree_class, elem); } int -t8_element_max_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +t8_element_get_max_num_faces (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_max_num_faces (elem); + return forest->scheme->element_get_max_num_faces (tree_class, elem); } int -t8_element_num_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +t8_element_get_num_children (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_num_children (elem); + return forest->scheme->element_get_num_children (tree_class, elem); } int -t8_element_num_face_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face) +t8_element_get_num_face_children (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_num_face_children (elem, face); + return forest->scheme->element_get_num_face_children (tree_class, elem, face); } int -t8_element_get_face_corner (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int corner) +t8_element_get_face_corner (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face, + int corner) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_get_face_corner (elem, face, corner); + return forest->scheme->element_get_face_corner (tree_class, elem, face, corner); } int -t8_element_get_corner_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int corner, int face) +t8_element_get_corner_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int corner, int face) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_get_corner_face (elem, corner, face); + return forest->scheme->element_get_corner_face (tree_class, elem, corner, face); } void -t8_element_child (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int childid, t8_element_t *child) +t8_element_get_child (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int childid, + t8_element_t *child) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_child (elem, childid, child); + return forest->scheme->element_get_child (tree_class, elem, childid, child); } void -t8_element_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int length, t8_element_t *c[]) +t8_element_get_children (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int length, + t8_element_t *c[]) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_children (elem, length, c); + return forest->scheme->element_get_children (tree_class, elem, length, c); } int -t8_element_child_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +t8_element_get_child_id (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_child_id (elem); + return forest->scheme->element_get_child_id (tree_class, elem); } int -t8_element_ancestor_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int level) +t8_element_get_ancestor_id (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int level) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_ancestor_id (elem, level); + return forest->scheme->element_get_ancestor_id (tree_class, elem, level); } int -t8_element_is_family (const t8_eclass_scheme_c *ts, t8_element_t *const *fam) +t8_elements_are_family (const t8_forest_t forest, const t8_eclass_t tree_class, t8_element_t *const *fam) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_is_family (fam); + return forest->scheme->elements_are_family (tree_class, fam); } void -t8_element_nca (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) +t8_element_get_nca (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + const t8_element_t *elem2, t8_element_t *nca) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_nca (elem1, elem2, nca); + return forest->scheme->element_get_nca (tree_class, elem1, elem2, nca); } t8_element_shape_t -t8_element_face_shape (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face) +t8_element_get_face_shape (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_face_shape (elem, face); + return forest->scheme->element_get_face_shape (tree_class, elem, face); } void -t8_element_children_at_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) +t8_element_get_children_at_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face, t8_element_t *children[], int num_children, int *child_indices) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_children_at_face (elem, face, children, num_children, child_indices); + return forest->scheme->element_get_children_at_face (tree_class, elem, face, children, num_children, child_indices); } int -t8_element_face_child_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int face_child) +t8_element_face_get_child_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face, int face_child) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_face_child_face (elem, face, face_child); + return forest->scheme->element_face_get_child_face (tree_class, elem, face, face_child); } int -t8_element_face_parent_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face) +t8_element_face_get_parent_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_face_parent_face (elem, face); + return forest->scheme->element_face_get_parent_face (tree_class, elem, face); } int -t8_element_tree_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face) +t8_element_get_tree_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_tree_face (elem, face); + return forest->scheme->element_get_tree_face (tree_class, elem, face); } void -t8_element_transform_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, t8_element_t *elem2, - int orientation, int sign, int is_smaller_face) +t8_element_transform_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + t8_element_t *elem2, int orientation, int sign, int is_smaller_face) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_transform_face (elem1, elem2, orientation, sign, is_smaller_face); + return forest->scheme->element_transform_face (tree_class, elem1, elem2, orientation, sign, is_smaller_face); } int -t8_element_extrude_face (const t8_eclass_scheme_c *ts, const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, - t8_element_t *elem, int root_face) +t8_element_extrude_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *face, + const t8_eclass_t face_eclass, t8_element_t *elem, int root_face) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_extrude_face (face, face_scheme, elem, root_face); + return forest->scheme->element_extrude_face (tree_class, face, face_scheme, elem, root_face); } void -t8_element_boundary_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) +t8_element_construct_boundary_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face, t8_element_t *boundary, const t8_eclass_t boundary_face_eclass) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_boundary_face (elem, face, boundary, boundary_scheme); + return forest->scheme->element_construct_boundary_face (tree_class, elem, face, boundary, boundary_scheme); } void -t8_element_first_descendant_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) +t8_element_construct_first_descendant_face (const t8_forest_t forest, const t8_eclass_t tree_class, + const t8_element_t *elem, int face, t8_element_t *first_desc, int level) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_first_descendant_face (elem, face, first_desc, level); + return forest->scheme->element_construct_first_descendant_face (tree_class, elem, face, first_desc, level); } void -t8_element_last_descendant_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, - t8_element_t *last_desc, int level) +t8_element_construct_last_descendant_face (const t8_forest_t forest, const t8_eclass_t tree_class, + const t8_element_t *elem, int face, t8_element_t *last_desc, int level) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_last_descendant_face (elem, face, last_desc, level); + return forest->scheme->element_construct_last_descendant_face (tree_class, elem, face, last_desc, level); } -void -t8_element_set_linear_id (const t8_eclass_scheme_c *ts, t8_element_t *elem, int level, t8_linearidx_t id) +int +t8_element_is_root_boundary (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_set_linear_id (elem, level, id); + return forest->scheme->element_is_root_boundary (tree_class, elem, face); } int -t8_element_is_root_boundary (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face) +t8_element_construct_face_neighbor_inside (const t8_forest_t forest, const t8_eclass_t tree_class, + const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_is_root_boundary (elem, face); + return forest->scheme->element_construct_face_neighbor_inside (tree_class, elem, neigh, face, neigh_face); } -int -t8_element_face_neighbor_inside (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *neigh, int face, - int *neigh_face) +t8_element_shape_t +t8_element_get_shape (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_face_neighbor_inside (elem, neigh, face, neigh_face); + return forest->scheme->element_get_shape (tree_class, elem); } -t8_element_shape_t -t8_element_shape (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +void +t8_element_set_linear_id (const t8_forest_t forest, const t8_eclass_t tree_class, t8_element_t *elem, int level, + t8_linearidx_t id) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_shape (elem); + return forest->scheme->element_set_linear_id (tree_class, elem, level, id); } t8_linearidx_t -t8_element_get_linear_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int level) +t8_element_get_linear_id (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int level) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_get_linear_id (elem, level); + return forest->scheme->element_get_linear_id (tree_class, elem, level); } void -t8_element_first_descendant (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *desc, int level) +t8_element_construct_first_descendant (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + t8_element_t *desc, int level) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_first_descendant (elem, desc, level); + return forest->scheme->element_construct_first_descendant (tree_class, elem, desc, level); } void -t8_element_last_descendant (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *desc, int level) +t8_element_construct_last_descendant (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + t8_element_t *desc, int level) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_last_descendant (elem, desc, level); + return forest->scheme->element_construct_last_descendant (tree_class, elem, desc, level); } void -t8_element_successor (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, t8_element_t *elem2) +t8_element_construct_successor (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + t8_element_t *elem2) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_successor (elem1, elem2); + return forest->scheme->element_construct_successor (tree_class, elem1, elem2); } void -t8_element_vertex_reference_coords (const t8_eclass_scheme_c *ts, const t8_element_t *t, const int vertex, - double coords[]) +t8_element_get_vertex_reference_coords (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *t, + const int vertex, double coords[]) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_vertex_reference_coords (t, vertex, coords); + return forest->scheme->element_get_vertex_reference_coords (tree_class, t, vertex, coords); +} + +void +t8_element_get_reference_coords (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *t, + const double *ref_coords, const size_t num_coords, double coords[]) +{ + T8_ASSERT (t8_forest_is_committed (forest)); + + return forest->scheme->element_get_reference_coords (tree_class, t, vertex, coords); } t8_gloidx_t -t8_element_count_leaves (const t8_eclass_scheme_c *ts, const t8_element_t *t, int level) +t8_element_count_leaves (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *t, int level) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_count_leaves (t, level); + return forest->scheme->element_count_leaves (tree_class, t, level); } t8_gloidx_t -t8_element_count_leaves_from_root (const t8_eclass_scheme_c *ts, int level) +t8_element_count_leaves_from_root (const t8_forest_t forest, const t8_eclass_t tree_class, int level) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_count_leaves_from_root (level); + return forest->scheme->element_count_leaves_from_root (tree_class, level); } #ifdef T8_ENABLE_DEBUG int -t8_element_is_valid (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +t8_element_is_valid (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_is_valid (elem); + return forest->scheme->element_is_valid (tree_class, elem); } void -t8_element_debug_print (const t8_eclass_scheme_c *ts, const t8_element_t *elem) +t8_element_debug_print (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_debug_print (elem); + return forest->scheme->element_debug_print (tree_class, elem); } void -t8_element_to_string (const t8_eclass_scheme_c *ts, const t8_element_t *elem, char *debug_string, const int string_size) +t8_element_to_string (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + char *debug_string, const int string_size) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); + T8_ASSERT (debug_string != NULL); - ts->t8_element_to_string (elem, debug_string, string_size); + return forest->scheme->element_to_string (tree_class, elem, debug_string, string_size); } #endif void -t8_element_new (const t8_eclass_scheme_c *ts, int length, t8_element_t **elems) +t8_element_new (const t8_forest_t forest, const t8_eclass_t tree_class, int length, t8_element_t **elems) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_new (length, elems); + return forest->scheme->element_new (tree_class, length, elems); } void -t8_element_destroy (const t8_eclass_scheme_c *ts, int length, t8_element_t **elems) +t8_element_init (const t8_forest_t forest, const t8_eclass_t tree_class, int length, t8_element_t *elems) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_destroy (length, elems); + return forest->scheme->element_init (tree_class, length, elems); } void -t8_element_root (const t8_eclass_scheme_c *ts, t8_element_t *elem) +t8_element_deinit (const t8_forest_t forest, const t8_eclass_t tree_class, int length, t8_element_t *elems) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - ts->t8_element_root (elem); + return forest->scheme->element_deinit (tree_class, length, elems); +} +void +t8_element_destroy (const t8_forest_t forest, const t8_eclass_t tree_class, int length, t8_element_t **elems) +{ + T8_ASSERT (t8_forest_is_committed (forest)); + + return forest->scheme->element_destroy (tree_class, length, elems); } void -t8_element_MPI_Pack (const t8_eclass_scheme_c *ts, t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, sc_MPI_Comm comm) +t8_element_get_root (const t8_forest_t forest, const t8_eclass_t tree_class, t8_element_t *elem) { - T8_ASSERT (ts != NULL); + T8_ASSERT (t8_forest_is_committed (forest)); - return ts->t8_element_MPI_Pack (elements, count, send_buffer, buffer_size, position, comm); + return forest->scheme->get_root_element (tree_class, elem); } void -t8_element_MPI_Pack_size (const t8_eclass_scheme_c *ts, const unsigned int count, sc_MPI_Comm comm, int *pack_size) +t8_element_MPI_Pack (const t8_forest_t forest, const t8_eclass_t tree_class, t8_element_t **const elements, + const unsigned int count, void *send_buffer, const int buffer_size, int *position, + sc_MPI_Comm comm) { - T8_ASSERT (ts != NULL); - return ts->t8_element_MPI_Pack_size (count, comm, pack_size); + T8_ASSERT (t8_forest_is_committed (forest)); + + return forest->scheme->element_MPI_Pack (tree_class, elements, count, send_buffer, buffer_size, position, comm); } void -t8_element_MPI_Unpack (const t8_eclass_scheme_c *ts, void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) +t8_element_MPI_Pack_size (const t8_forest_t forest, const t8_eclass_t tree_class, const unsigned int count, + sc_MPI_Comm comm, int *pack_size) { - T8_ASSERT (ts != NULL); - return ts->t8_element_MPI_Unpack (recvbuf, buffer_size, position, elements, count, comm); + T8_ASSERT (t8_forest_is_committed (forest)); + + return forest->scheme->element_MPI_Pack_size (tree_class, count, comm, pack_size); +} + +void +t8_element_MPI_Unpack (const t8_forest_t forest, const t8_eclass_t tree_class, void *recvbuf, const int buffer_size, + int *position, t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) +{ + T8_ASSERT (t8_forest_is_committed (forest)); + + return forest->scheme->element_MPI_Unpack (tree_class, recvbuf, buffer_size, position, elements, count, comm); } diff --git a/src/t8_element_c_interface.h b/src/t8_element_c_interface.h index f1fb8cea52..a4730e152e 100644 --- a/src/t8_element_c_interface.h +++ b/src/t8_element_c_interface.h @@ -22,7 +22,7 @@ /** \file t8_element_c_interface.h * This file defines the c interface to (some of) the member functions of the - * t8_eclass_scheme_c class. + * t8_scheme_c class. * * We recommend to use the C++ functions directly and only use this * interface when you really need to use C. @@ -41,23 +41,23 @@ T8_EXTERN_C_BEGIN (); * for most use cases. */ size_t -t8_element_size (const t8_eclass_scheme_c *ts); +t8_element_size (const t8_forest_t forest, const t8_eclass_t tree_class); /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. */ int -t8_element_refines_irregular (const t8_eclass_scheme_c *ts); +t8_element_refines_irregular (const t8_forest_t forest, const t8_eclass_t tree_class); /** Return the maximum allowed level for any element of a given class. * \param [in] ts Implementation of a class scheme. * \return The maximum allowed level for elements of class \b ts. */ int -t8_element_maxlevel (const t8_eclass_scheme_c *ts); +t8_element_maxlevel (const t8_forest_t forest, const t8_eclass_t tree_class); int -t8_element_level (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_level (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** Copy all entries of \b source to \b dest. \b dest must be an existing * element. No memory is allocated by this function. @@ -68,7 +68,8 @@ t8_element_level (const t8_eclass_scheme_c *ts, const t8_element_t *elem); * \note \a source and \a dest may point to the same element. */ void -t8_element_copy (const t8_eclass_scheme_c *ts, const t8_element_t *source, t8_element_t *dest); +t8_element_copy (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *source, + t8_element_t *dest); /** Compare two elements with respect to the scheme. * \param [in] ts Implementation of a class scheme. @@ -79,7 +80,8 @@ t8_element_copy (const t8_eclass_scheme_c *ts, const t8_element_t *source, t8_el * If elem2 is a copy of elem1 then the elements are equal. */ int -t8_element_compare (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2); +t8_element_compare (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + const t8_element_t *elem2); /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -88,7 +90,8 @@ t8_element_compare (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, con * \return 1 if the elements are equal, 0 if they are not equal */ int -t8_element_equal (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2); +t8_element_equal (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + const t8_element_t *elem2); /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -102,7 +105,8 @@ t8_element_equal (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const * and match the element class of the parent. */ void -t8_element_parent (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *parent); +t8_element_parent (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + t8_element_t *parent); /** Compute the number of siblings of an element. That is the number of * Children of its parent. @@ -112,7 +116,7 @@ t8_element_parent (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_el * Note that this number is >= 1, since we count the element itself as a sibling. */ int -t8_element_num_siblings (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_num_siblings (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** Compute a specific sibling of a given element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -127,7 +131,8 @@ t8_element_num_siblings (const t8_eclass_scheme_c *ts, const t8_element_t *elem) * and match the element class of the sibling. */ void -t8_element_sibling (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int sibid, t8_element_t *sibling); +t8_element_sibling (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int sibid, + t8_element_t *sibling); /** Compute the number of corners of an element. * \param [in] ts Implementation of a class scheme. @@ -135,7 +140,7 @@ t8_element_sibling (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int * \return The number of corners of \a element. */ int -t8_element_num_corners (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_num_corners (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** Compute the number of faces of an element. * \param [in] ts Implementation of a class scheme. @@ -143,7 +148,7 @@ t8_element_num_corners (const t8_eclass_scheme_c *ts, const t8_element_t *elem); * \return The number of faces of \a element. */ int -t8_element_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_num_faces (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** Compute the maximum number of faces of a given element and all of its * descendants. @@ -152,7 +157,7 @@ t8_element_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem); * \return The number of faces of \a element. */ int -t8_element_max_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_max_num_faces (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** Compute the number of children of an element when it is refined. * \param [in] ts Implementation of a class scheme. @@ -160,7 +165,7 @@ t8_element_max_num_faces (const t8_eclass_scheme_c *ts, const t8_element_t *elem * \return The number of children of \a element. */ int -t8_element_num_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_num_children (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** Compute the number of children of an element's face when the element is refined. * \param [in] ts Implementation of a class scheme. @@ -169,7 +174,8 @@ t8_element_num_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem) * \return The number of children of \a face if \a elem is to be refined. */ int -t8_element_num_face_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +t8_element_num_face_children (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face); /** Return the corner number of an element's face corner. * Example quad: 2 x --- x 3 @@ -191,7 +197,8 @@ t8_element_num_face_children (const t8_eclass_scheme_c *ts, const t8_element_t * * 'outside' of the element. */ int -t8_element_get_face_corner (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int corner); +t8_element_get_face_corner (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face, + int corner); /** Compute the face numbers of the faces sharing an element's corner. * Example quad: 2 x --- x 3 @@ -207,7 +214,8 @@ t8_element_get_face_corner (const t8_eclass_scheme_c *ts, const t8_element_t *el * \return The face number of the \a face-th face at \a corner. */ int -t8_element_get_corner_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int corner, int face); +t8_element_get_corner_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int corner, int face); /** Construct the child element of a given number. * \param [in] ts Implementation of a class scheme. @@ -218,7 +226,8 @@ t8_element_get_corner_face (const t8_eclass_scheme_c *ts, const t8_element_t *el * It is valid to call this function with elem = child. */ void -t8_element_child (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int childid, t8_element_t *child); +t8_element_child (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int childid, + t8_element_t *child); /** Construct all children of a given element. * \param [in] ts Implementation of a class scheme. @@ -232,7 +241,8 @@ t8_element_child (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int ch * \see t8_element_num_children */ void -t8_element_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int length, t8_element_t *c[]); +t8_element_children (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int length, + t8_element_t *c[]); /** Compute the child id of an element. * \param [in] ts Implementation of a class scheme. @@ -240,7 +250,7 @@ t8_element_children (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int * \return The child id of elem. */ int -t8_element_child_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_child_id (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** Compute the ancestor id of an element, that is the child id * at a given level. @@ -250,7 +260,7 @@ t8_element_child_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem); * \return The child_id of \a elem in regard to its \a level ancestor. */ int -t8_element_ancestor_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int level); +t8_element_ancestor_id (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int level); /** Query whether a given set of elements is a family or not. * \param [in] ts Implementation of a class scheme. @@ -259,7 +269,7 @@ t8_element_ancestor_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem, * \return Zero if \b fam is not a family, nonzero if it is. */ int -t8_element_is_family (const t8_eclass_scheme_c *ts, t8_element_t *const *fam); +t8_element_is_family (const t8_forest_t forest, const t8_eclass_t tree_class, t8_element_t *const *fam); /** Compute the nearest common ancestor of two elements. That is, * the element with highest level that still has both given elements as @@ -273,7 +283,8 @@ t8_element_is_family (const t8_eclass_scheme_c *ts, t8_element_t *const *fam); * \b elem1 and \b elem2. */ void -t8_element_nca (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca); +t8_element_nca (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + const t8_element_t *elem2, t8_element_t *nca); /** Compute the shape of the face of an element. * \param [in] ts Implementation of a class scheme. @@ -285,7 +296,7 @@ t8_element_nca (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, const t * T8_ECLASS_TRIANGLE for prisms. */ t8_element_shape_t -t8_element_face_shape (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +t8_element_face_shape (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face); /** Given an element and a face of the element, compute all children of * the element that touch the face. @@ -303,8 +314,8 @@ t8_element_face_shape (const t8_eclass_scheme_c *ts, const t8_element_t *elem, i * It is valid to call this function with elem = children[0]. */ void -t8_element_children_at_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices); +t8_element_children_at_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face, + t8_element_t *children[], int num_children, int *child_indices); /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -328,7 +339,8 @@ t8_element_children_at_face (const t8_eclass_scheme_c *ts, const t8_element_t *e * that coincides with \a face_child. */ int -t8_element_face_child_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, int face_child); +t8_element_face_child_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face, + int face_child); /** Given a face of an element return the face number * of the parent of the element that matches the element's face. Or return -1 if @@ -342,7 +354,8 @@ t8_element_face_child_face (const t8_eclass_scheme_c *ts, const t8_element_t *el * \note For the root element this function always returns \a face. */ int -t8_element_face_parent_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +t8_element_face_parent_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face); /** Given an element and a face of this element. If the face lies on the * tree boundary, return the face number of the tree face. @@ -355,7 +368,7 @@ t8_element_face_parent_face (const t8_eclass_scheme_c *ts, const t8_element_t *e * Any arbitrary integer if \a is not at a tree boundary. */ int -t8_element_tree_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +t8_element_tree_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face); /** Suppose we have two trees that share a common face f. * Given an element e that is a subface of f in one of the trees @@ -380,15 +393,15 @@ t8_element_tree_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, in * \note \a elem1 and \a elem2 may point to the same element. */ void -t8_element_transform_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, t8_element_t *elem2, - int orientation, int sign, int is_smaller_face); +t8_element_transform_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + t8_element_t *elem2, int orientation, int sign, int is_smaller_face); /** Given a boundary face inside a root tree's face construct * the element inside the root tree that has the given face as a * face. * \param [in] ts Implementation of a class scheme. * \param [in] face A face element. - * \param [in] face_scheme The scheme for the face element. + * \param [in] face_eclass The eclass for the face element. * \param [in,out] elem An allocated element. The entries will be filled with * the data of the element that has \a face as a face and * lies within the root tree. @@ -398,8 +411,8 @@ t8_element_transform_face (const t8_eclass_scheme_c *ts, const t8_element_t *ele * with \a face. */ int -t8_element_extrude_face (const t8_eclass_scheme_c *ts, const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, - t8_element_t *elem, int root_face); +t8_element_extrude_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *face, + const t8_eclass_t face_eclass, t8_element_t *elem, int root_face); /** Construct the boundary element at a specific face. * \param [in] ts Implementation of a class scheme. @@ -409,13 +422,13 @@ t8_element_extrude_face (const t8_eclass_scheme_c *ts, const t8_element_t *face, * \param [in,out] boundary An allocated element of dimension of \a element * minus 1. The entries will be filled with the entries * of the face of \a element. - * \param [in] boundary_scheme The scheme for the eclass of the boundary face. + * \param [in] boundary_face_eclass The eclass of the boundary face. * If \a elem is of class T8_ECLASS_VERTEX, then \a boundary must be NULL * and will not be modified. */ void -t8_element_boundary_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme); +t8_element_boundary_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int face, + t8_element_t *boundary, const t8_eclass_t boundary_face_eclass); /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] ts Implementation of a class scheme. @@ -427,8 +440,8 @@ t8_element_boundary_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem * \param [in] level The level, at which the first descendant is constructed */ void -t8_element_first_descendant_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, - t8_element_t *first_desc, int level); +t8_element_first_descendant_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face, t8_element_t *first_desc, int level); /** Construct the last descendant of an element at a given level that touches a given face. * \param [in] ts Implementation of a class scheme. @@ -440,8 +453,8 @@ t8_element_first_descendant_face (const t8_eclass_scheme_c *ts, const t8_element * \param [in] level The level, at which the last descendant is constructed */ void -t8_element_last_descendant_face (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face, - t8_element_t *last_desc, int level); +t8_element_last_descendant_face (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face, t8_element_t *last_desc, int level); /** Compute whether a given element shares a given face with its root tree. * \param [in] ts Implementation of a class scheme. @@ -450,7 +463,8 @@ t8_element_last_descendant_face (const t8_eclass_scheme_c *ts, const t8_element_ * \return True if \a face is a subface of the element's root element. */ int -t8_element_is_root_boundary (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int face); +t8_element_is_root_boundary (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + int face); /** Construct the face neighbor of a given element if this face neighbor * is inside the root tree. Return 0 otherwise. @@ -469,8 +483,8 @@ t8_element_is_root_boundary (const t8_eclass_scheme_c *ts, const t8_element_t *e * on output. */ int -t8_element_face_neighbor_inside (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *neigh, int face, - int *neigh_face); +t8_element_face_neighbor_inside (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + t8_element_t *neigh, int face, int *neigh_face); /** Return the shape of an allocated element according its type. * For example, a child of an element can be an element of a different shape @@ -480,7 +494,7 @@ t8_element_face_neighbor_inside (const t8_eclass_scheme_c *ts, const t8_element_ * \return The shape of the element as an eclass */ t8_element_shape_t -t8_element_shape (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_shape (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** Initialize the entries of an allocated element according to a * given linear id in a uniform refinement. @@ -491,7 +505,8 @@ t8_element_shape (const t8_eclass_scheme_c *ts, const t8_element_t *elem); * id must fulfil 0 <= id < 'number of leaves in the uniform refinement' */ void -t8_element_set_linear_id (const t8_eclass_scheme_c *ts, t8_element_t *elem, int level, t8_linearidx_t id); +t8_element_set_linear_id (const t8_forest_t forest, const t8_eclass_t tree_class, t8_element_t *elem, int level, + t8_linearidx_t id); /** Compute the linear id of a given element in a hypothetical uniform * refinement of a given level. @@ -501,7 +516,7 @@ t8_element_set_linear_id (const t8_eclass_scheme_c *ts, t8_element_t *elem, int * \return The linear id of the element. */ t8_linearidx_t -t8_element_get_linear_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem, int level); +t8_element_get_linear_id (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, int level); /** Compute the first descendant of a given element. * \param [in] ts Implementation of a class scheme. @@ -510,7 +525,8 @@ t8_element_get_linear_id (const t8_eclass_scheme_c *ts, const t8_element_t *elem * of the maximum possible level. */ void -t8_element_first_descendant (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *desc, int level); +t8_element_first_descendant (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + t8_element_t *desc, int level); /** Compute the last descendant of a given element. * \param [in] ts Implementation of a class scheme. @@ -519,7 +535,8 @@ t8_element_first_descendant (const t8_eclass_scheme_c *ts, const t8_element_t *e * of the maximum possible level. */ void -t8_element_last_descendant (const t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_element_t *desc, int level); +t8_element_last_descendant (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + t8_element_t *desc, int level); /** Construct the successor in a uniform refinement of a given element. * \param [in] ts Implementation of a class scheme. @@ -528,7 +545,8 @@ t8_element_last_descendant (const t8_eclass_scheme_c *ts, const t8_element_t *el * \param [in] level The level of the uniform refinement to consider. */ void -t8_element_successor (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, t8_element_t *elem2); +t8_element_successor (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem1, + t8_element_t *elem2); /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). @@ -540,8 +558,8 @@ t8_element_successor (const t8_eclass_scheme_c *ts, const t8_element_t *elem1, t * all coords might be used. */ void -t8_element_vertex_reference_coords (const t8_eclass_scheme_c *ts, const t8_element_t *t, const int vertex, - double coords[]); +t8_element_vertex_reference_coords (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *t, + const int vertex, double coords[]); /** Count how many leaf descendants of a given uniform level an element would produce. * \param [in] ts Implementation of a class scheme. @@ -556,7 +574,7 @@ t8_element_vertex_reference_coords (const t8_eclass_scheme_c *ts, const t8_eleme * Thus, if \a t's level is 0, and \a level = 3, the return value is 2^3 = 8. */ t8_gloidx_t -t8_element_count_leaves (const t8_eclass_scheme_c *ts, const t8_element_t *t, int level); +t8_element_count_leaves (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *t, int level); /** Count how many leaf descendants of a given uniform level the root element will produce. * \param [in] ts Implementation of a class scheme. @@ -568,7 +586,7 @@ t8_element_count_leaves (const t8_eclass_scheme_c *ts, const t8_element_t *t, in * \ref t8_element_count_leaves. */ t8_gloidx_t -t8_element_count_leaves_from_root (const t8_eclass_scheme_c *ts, int level); +t8_element_count_leaves_from_root (const t8_forest_t forest, const t8_eclass_t tree_class, int level); #ifdef T8_ENABLE_DEBUG /** Query whether a given element can be considered as 'valid' and it is @@ -589,7 +607,7 @@ t8_element_count_leaves_from_root (const t8_eclass_scheme_c *ts, int level); * in the implementation of each of the functions in this file. */ int -t8_element_is_valid (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_is_valid (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** * Print a given element. For a example for a triangle print the coordinates @@ -600,7 +618,7 @@ t8_element_is_valid (const t8_eclass_scheme_c *ts, const t8_element_t *elem); * \param [in] elem The element to print */ void -t8_element_debug_print (const t8_eclass_scheme_c *ts, const t8_element_t *elem); +t8_element_debug_print (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem); /** * \brief Fill a string with readable information about the element @@ -609,8 +627,8 @@ t8_element_debug_print (const t8_eclass_scheme_c *ts, const t8_element_t *elem); * \param[in, out] debug_string The string to fill. */ void -t8_element_to_string (const t8_eclass_scheme_c *ts, const t8_element_t *elem, char *debug_string, - const int string_size); +t8_element_to_string (const t8_forest_t forest, const t8_eclass_t tree_class, const t8_element_t *elem, + char *debug_string, const int string_size); #endif /** Allocate memory for an array of elements of a given class and initialize them. @@ -630,7 +648,7 @@ t8_element_to_string (const t8_eclass_scheme_c *ts, const t8_element_t *elem, ch * \see t8_element_is_valid */ void -t8_element_new (const t8_eclass_scheme_c *ts, int length, t8_element_t **elems); +t8_element_new (const t8_forest_t forest, const t8_eclass_t tree_class, int length, t8_element_t **elems); /** Deallocate an array of elements. * \param [in] ts Implementation of a class scheme. @@ -639,14 +657,14 @@ t8_element_new (const t8_eclass_scheme_c *ts, int length, t8_element_t **elems); * will be freed. \b elem itself will not be freed by this function. */ void -t8_element_destroy (const t8_eclass_scheme_c *ts, int length, t8_element_t **elems); +t8_element_destroy (const t8_forest_t forest, const t8_eclass_t tree_class, int length, t8_element_t **elems); /** Fills an element with the root element. * \param [in] ts Implementation of a class scheme. * \param [in,out] elem The element to be filled with root. */ void -t8_element_root (const t8_eclass_scheme_c *ts, t8_element_t *elem); +t8_element_get_root (const t8_forest_t forest, const t8_eclass_t tree_class, t8_element_t *elem); /** Pack multiple elements into contiguous memory, so they can be sent via MPI. * \param [in] ts Implementation of a class scheme. @@ -658,8 +676,9 @@ t8_element_root (const t8_eclass_scheme_c *ts, t8_element_t *elem); * \param [in] comm MPI Communicator */ void -t8_element_MPI_Pack (const t8_eclass_scheme_c *ts, t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, sc_MPI_Comm comm); +t8_element_MPI_Pack (const t8_forest_t forest, const t8_eclass_t tree_class, t8_element_t **const elements, + const unsigned int count, void *send_buffer, const int buffer_size, int *position, + sc_MPI_Comm comm); /** Determine an upper bound for the size of the packed message of \b count elements * \param [in] ts Implementation of a class scheme. @@ -668,7 +687,8 @@ t8_element_MPI_Pack (const t8_eclass_scheme_c *ts, t8_element_t **const elements * \param [out] pack_size upper bound on the message size */ void -t8_element_MPI_Pack_size (const t8_eclass_scheme_c *ts, const unsigned int count, sc_MPI_Comm comm, int *pack_size); +t8_element_MPI_Pack_size (const t8_forest_t forest, const t8_eclass_t tree_class, const unsigned int count, + sc_MPI_Comm comm, int *pack_size); /** Unpack multiple elements from contiguous memory that was received via MPI. * \param [in] ts Implementation of a class scheme. @@ -680,8 +700,8 @@ t8_element_MPI_Pack_size (const t8_eclass_scheme_c *ts, const unsigned int count * \param [in] comm MPI Communicator */ void -t8_element_MPI_Unpack (const t8_eclass_scheme_c *ts, void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm); +t8_element_MPI_Unpack (const t8_forest_t forest, const t8_eclass_t tree_class, void *recvbuf, const int buffer_size, + int *position, t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm); T8_EXTERN_C_END (); diff --git a/src/t8_forest/t8_forest.cxx b/src/t8_forest/t8_forest.cxx index 41fb758b67..f6bd92e44f 100644 --- a/src/t8_forest/t8_forest.cxx +++ b/src/t8_forest/t8_forest.cxx @@ -49,7 +49,7 @@ T8_EXTERN_C_BEGIN (); int t8_forest_is_incomplete_family (const t8_forest_t forest, const t8_locidx_t ltree_id, const t8_locidx_t el_considered, - t8_eclass_scheme_c *tscheme, t8_element_t **elements, const int elements_size) + t8_scheme *tscheme, t8_element_t **elements, const int elements_size) { T8_ASSERT (forest != NULL); T8_ASSERT (ltree_id >= 0); @@ -177,7 +177,7 @@ t8_forest_compute_maxlevel (t8_forest_t forest) * class in the forest */ int eclass_it; int maxlevel; - t8_eclass_scheme_c *ts; + t8_scheme *ts; T8_ASSERT (t8_cmesh_is_committed (forest->cmesh)); forest->maxlevel = -1; @@ -209,7 +209,7 @@ t8_forest_get_maxlevel (const t8_forest_t forest) /* Ensure that the maxlevel does not increase the maximum level of any * class in the forest */ int eclass_it; - t8_eclass_scheme_c *ts; + t8_scheme *ts; for (eclass_it = 0; eclass_it < T8_ECLASS_COUNT; eclass_it++) { if (forest->cmesh->num_trees_per_eclass[eclass_it] > 0) { ts = t8_forest_get_eclass_scheme (forest, (t8_eclass_t) eclass_it); @@ -232,10 +232,10 @@ t8_forest_get_dimension (const t8_forest_t forest) /* Compute the minimum refinement level, such that a uniform forest on a cmesh * does not have empty processes */ int -t8_forest_min_nonempty_level (t8_cmesh_t cmesh, t8_scheme_cxx_t *scheme) +t8_forest_min_nonempty_level (t8_cmesh_t cmesh, t8_scheme *scheme) { int level, min_num_children, maxlevel; - t8_eclass_scheme_c *ts; + t8_scheme *ts; int eclass; t8_element_t *element; @@ -283,7 +283,7 @@ t8_forest_no_overlap (t8_forest_t forest) /* Iterate over all local trees */ for (t8_locidx_t itree = 0; itree < num_local_trees; itree++) { t8_tree_t tree = t8_forest_get_tree (forest, itree); - t8_eclass_scheme_c *ts = t8_forest_get_eclass_scheme (forest, tree->eclass); + t8_scheme *ts = t8_forest_get_eclass_scheme (forest, tree->eclass); const t8_locidx_t elems_in_tree = t8_forest_get_tree_num_elements (forest, itree); t8_element_t *element_nca; ts->t8_element_new (1, &element_nca); @@ -337,7 +337,7 @@ t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b) t8_locidx_t elems_in_tree_a, elems_in_tree_b; t8_locidx_t ielem; t8_locidx_t itree; - t8_eclass_scheme_c *ts_a, *ts_b; + t8_scheme *ts_a, *ts_b; T8_ASSERT (t8_forest_is_committed (forest_a)); T8_ASSERT (t8_forest_is_committed (forest_b)); @@ -387,7 +387,7 @@ t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8 double *coordinates) { double vertex_coords[3] = { 0.0 }; - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_eclass_t tree_class; t8_gloidx_t gtreeid; t8_cmesh_t cmesh; @@ -414,7 +414,7 @@ t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, { const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); const int tree_dim = t8_eclass_to_dimension[tree_class]; - const t8_eclass_scheme_c *scheme = t8_forest_get_eclass_scheme (forest, tree_class); + const t8_scheme *scheme = t8_forest_get_eclass_scheme (forest, tree_class); const t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, ltreeid); @@ -456,7 +456,7 @@ double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element) { t8_eclass_t tree_class; - t8_eclass_scheme_c *ts; + t8_scheme *ts; double centroid[3], coordinates[3]; double dist; @@ -492,7 +492,7 @@ t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_elemen void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; T8_ASSERT (t8_forest_is_committed (forest)); @@ -577,7 +577,7 @@ t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_elem { t8_eclass_t tree_class; t8_element_shape_t element_shape; - t8_eclass_scheme_c *ts; + t8_scheme *ts; T8_ASSERT (t8_forest_is_committed (forest)); @@ -597,7 +597,7 @@ t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_elem case T8_ECLASS_QUAD: { int face_a, face_b, corner_a, corner_b; double coordinates[3][3]; - t8_eclass_scheme_c *ts; + t8_scheme *ts; /* We use this formula for computing the surface area for a parallelogram * (we use parallelogram as approximation for the element). * @@ -745,7 +745,7 @@ t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_e t8_eclass_t tree_class; t8_element_shape_t face_shape; - t8_eclass_scheme_c *ts; + t8_scheme *ts; T8_ASSERT (t8_forest_is_committed (forest)); @@ -828,7 +828,7 @@ t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const { t8_eclass_t tree_class; t8_element_shape_t face_shape; - t8_eclass_scheme_c *ts; + t8_scheme *ts; T8_ASSERT (t8_forest_is_committed (forest)); /* get the eclass of the forest */ @@ -946,7 +946,7 @@ t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8 /* get the eclass of the forest */ const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); /* get the element's scheme and the face scheme */ - const t8_eclass_scheme_c *ts = t8_forest_get_eclass_scheme (forest, tree_class); + const t8_scheme *ts = t8_forest_get_eclass_scheme (forest, tree_class); const t8_element_shape_t face_shape = ts->t8_element_face_shape (element, face); switch (face_shape) { @@ -1123,7 +1123,7 @@ t8_forest_compute_desc (t8_forest_t forest) { t8_locidx_t itree_id, num_trees, num_elements; t8_tree_t itree; - t8_eclass_scheme_c *ts; + t8_scheme *ts; T8_ASSERT (forest != NULL); /* Iterate over all trees */ @@ -1171,7 +1171,7 @@ t8_forest_populate (t8_forest_t forest) t8_element_t *element, *element_succ; t8_element_array_t *telements; t8_eclass_t tree_class; - t8_eclass_scheme_c *eclass_scheme; + t8_scheme *eclass_scheme; t8_gloidx_t cmesh_first_tree, cmesh_last_tree; int is_empty; @@ -1273,7 +1273,7 @@ t8_forest_tree_shared (t8_forest_t forest, int first_or_last) t8_element_t *element; t8_element_t *tree_desc; t8_eclass_t eclass; - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_gloidx_t global_neighbour_tree_idx; int ret; int mpiret; @@ -1396,7 +1396,7 @@ t8_forest_copy_trees (t8_forest_t forest, t8_forest_t from, int copy_elements) t8_tree_t tree, fromtree; t8_gloidx_t num_tree_elements; t8_locidx_t jt, number_of_trees; - t8_eclass_scheme_c *eclass_scheme; + t8_scheme *eclass_scheme; T8_ASSERT (forest != NULL); T8_ASSERT (from != NULL); @@ -1450,7 +1450,7 @@ t8_forest_bin_search_lower (const t8_element_array_t *elements, const t8_lineari t8_linearidx_t query_id; t8_locidx_t low, high, guess; - const t8_eclass_scheme_c *ts = t8_element_array_get_scheme (elements); + const t8_scheme *ts = t8_element_array_get_scheme (elements); /* At first, we check whether any element has smaller id than the * given one. */ const t8_element_t *query = t8_element_array_index_int (elements, 0); @@ -1487,7 +1487,7 @@ t8_forest_bin_search_lower (const t8_element_array_t *elements, const t8_lineari t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, int face) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_tree_t tree; t8_ctree_t coarse_tree; t8_eclass_t eclass; @@ -1529,9 +1529,9 @@ t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, cons t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, - t8_eclass_scheme_c *neigh_scheme, int face, int *neigh_face) + t8_scheme *neigh_scheme, int face, int *neigh_face) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_tree_t tree; t8_eclass_t eclass; @@ -1545,7 +1545,7 @@ t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const } else { /* The neighbor does not lie inside the current tree. The content of neigh is undefined right now. */ - t8_eclass_scheme_c *boundary_scheme, *neighbor_scheme; + t8_scheme *boundary_scheme, *neighbor_scheme; t8_eclass_t neigh_eclass, boundary_class; t8_element_t *face_element; t8_cmesh_t cmesh; @@ -1642,10 +1642,10 @@ t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_gloidx_t t8_forest_element_half_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, - t8_element_t *neighs[], t8_eclass_scheme_c *neigh_scheme, int face, - int num_neighs, int dual_faces[]) + t8_element_t *neighs[], t8_scheme *neigh_scheme, int face, int num_neighs, + int dual_faces[]) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_tree_t tree; t8_eclass_t eclass; t8_element_t **children_at_face; @@ -1707,7 +1707,7 @@ t8_forest_element_half_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, } int -t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_eclass_scheme_c *ts, +t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_scheme *ts, const t8_element_t *leaf, int face) { int orientation = 0; @@ -1725,14 +1725,14 @@ t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, void t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, - t8_locidx_t **pelement_indices, t8_eclass_scheme_c **pneigh_scheme, - int forest_is_balanced, t8_gloidx_t *gneigh_tree, int *orientation) + t8_locidx_t **pelement_indices, t8_scheme **pneigh_scheme, int forest_is_balanced, + t8_gloidx_t *gneigh_tree, int *orientation) { t8_eclass_t neigh_class, eclass; t8_gloidx_t gneigh_treeid; t8_locidx_t lneigh_treeid = -1; t8_locidx_t lghost_treeid = -1, *element_indices, element_index; - t8_eclass_scheme_c *ts, *neigh_scheme; + t8_scheme *ts, *neigh_scheme; const t8_element_t *ancestor; t8_element_t **neighbor_leaves; t8_linearidx_t neigh_id; @@ -1965,8 +1965,7 @@ t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, cons void t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, - t8_locidx_t **pelement_indices, t8_eclass_scheme_c **pneigh_scheme, - int forest_is_balanced) + t8_locidx_t **pelement_indices, t8_scheme **pneigh_scheme, int forest_is_balanced) { t8_forest_leaf_face_neighbors_ext (forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, pelement_indices, pneigh_scheme, forest_is_balanced, NULL, NULL); @@ -1979,7 +1978,7 @@ t8_forest_print_all_leaf_neighbors (t8_forest_t forest) t8_element_t **neighbor_leaves; int iface, num_neighbors, ineigh; t8_eclass_t eclass; - t8_eclass_scheme_c *ts, *neigh_scheme; + t8_scheme *ts, *neigh_scheme; t8_locidx_t *element_indices; int *dual_faces; char buffer[BUFSIZ]; @@ -2056,7 +2055,7 @@ t8_forest_element_is_leaf (const t8_forest_t forest, const t8_element_t *element /* In order to find the element, we need to compute its linear id. * To do so, we need the scheme and the level of the element. */ - const t8_eclass_scheme_c *scheme = t8_element_array_get_scheme (elements); + const t8_scheme *scheme = t8_element_array_get_scheme (elements); const int element_level = scheme->t8_element_level (element); /* Compute the linear id. */ const t8_linearidx_t element_id = scheme->t8_element_get_linear_id (element, element_level); @@ -2082,7 +2081,7 @@ t8_forest_element_check_owner (t8_forest_t forest, t8_element_t *element, t8_glo int rank, int element_is_desc) { t8_element_t *first_desc; - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_linearidx_t rfirst_desc_id, rnext_desc_id = -1, first_desc_id; int is_first, is_last, check_next; int next_nonempty; @@ -2199,7 +2198,7 @@ t8_forest_element_find_owner_ext (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el int lower_bound, int upper_bound, int guess, int element_is_desc) { t8_element_t *first_desc; - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_gloidx_t current_first_tree; t8_linearidx_t current_id, element_desc_id; t8_linearidx_t *first_descs; @@ -2358,7 +2357,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el int proc, proc_next; t8_linearidx_t element_desc_lin_id; t8_element_t *element_first_desc; - t8_eclass_scheme_c *ts; + t8_scheme *ts; ssize_t proc_index; struct find_owner_data_t find_owner_data; @@ -2457,7 +2456,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el */ static void t8_forest_element_owners_at_face_recursion (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, - t8_eclass_t eclass, t8_eclass_scheme_c *ts, int face, sc_array_t *owners, + t8_eclass_t eclass, t8_scheme *ts, int face, sc_array_t *owners, int lower_bound, int upper_bound, t8_element_t *first_desc, t8_element_t *last_desc) { @@ -2558,7 +2557,7 @@ void t8_forest_element_owners_at_face (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_eclass_t eclass, int face, sc_array_t *owners) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; int lower_bound, upper_bound; ts = t8_forest_get_eclass_scheme (forest, eclass); @@ -2592,7 +2591,7 @@ void t8_forest_element_owners_bounds (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_eclass_t eclass, int *lower, int *upper) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_element_t *first_desc, *last_desc; if (*lower >= *upper) { @@ -2618,7 +2617,7 @@ void t8_forest_element_owners_at_face_bounds (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_eclass_t eclass, int face, int *lower, int *upper) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_element_t *first_face_desc, *last_face_desc; if (*lower >= *upper) { @@ -2643,7 +2642,7 @@ void t8_forest_element_owners_at_neigh_face (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, sc_array_t *owners) { - t8_eclass_scheme_c *neigh_scheme; + t8_scheme *neigh_scheme; t8_eclass_t neigh_class; t8_element_t *face_neighbor; int dual_face; @@ -2674,7 +2673,7 @@ void t8_forest_element_owners_at_neigh_face_bounds (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, int *lower, int *upper) { - t8_eclass_scheme_c *neigh_scheme; + t8_scheme *neigh_scheme; t8_eclass_t neigh_class; t8_element_t *face_neighbor; int dual_face; @@ -2703,8 +2702,7 @@ t8_forest_element_owners_at_neigh_face_bounds (t8_forest_t forest, t8_locidx_t l } int -t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, - t8_eclass_scheme_c *ts) +t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_scheme *ts) { t8_locidx_t ltreeid; t8_element_t *last_desc; @@ -2854,7 +2852,7 @@ t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm) } void -t8_forest_set_scheme (t8_forest_t forest, t8_scheme_cxx_t *scheme) +t8_forest_set_scheme (t8_forest_t forest, t8_scheme *scheme) { T8_ASSERT (forest != NULL); T8_ASSERT (forest->rc.refcount > 0); @@ -2864,7 +2862,7 @@ t8_forest_set_scheme (t8_forest_t forest, t8_scheme_cxx_t *scheme) T8_ASSERT (scheme != NULL); - forest->scheme_cxx = scheme; + forest->scheme = scheme; } void @@ -3074,8 +3072,8 @@ t8_forest_comm_global_num_elements (t8_forest_t forest) */ static int t8_forest_refine_everything (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]) + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { return 1; @@ -3098,7 +3096,7 @@ t8_forest_refines_irregular (t8_forest_t forest) int irregular_all_procs = 0; /* Result over all procs */ int int_eclass; int mpiret; - t8_eclass_scheme_c *tscheme; + t8_scheme *tscheme; /* Iterate over all eclasses */ for (int_eclass = (int) T8_ECLASS_ZERO; int_eclass < (int) T8_ECLASS_COUNT; int_eclass++) { /* If the forest has trees of the current eclass, check if elements of this eclass refine irregular. */ @@ -3127,7 +3125,7 @@ t8_forest_populate_irregular (t8_forest_t forest) t8_forest_t forest_tmp; t8_forest_t forest_tmp_partition; t8_cmesh_ref (forest->cmesh); - t8_scheme_cxx_ref (forest->scheme_cxx); + t8_schemexx_ref (forest->scheme_cxx); /* We start with a level 0 uniform refinement */ t8_forest_init (&forest_zero); t8_forest_set_level (forest_zero, 0); @@ -3233,7 +3231,7 @@ t8_forest_commit (t8_forest_t forest) /* increase reference count of cmesh and scheme from the input forest */ t8_cmesh_ref (forest->set_from->cmesh); - t8_scheme_cxx_ref (forest->set_from->scheme_cxx); + t8_schemexx_ref (forest->set_from->scheme_cxx); /* set the dimension, cmesh and scheme from the old forest */ forest->dimension = forest->set_from->dimension; forest->cmesh = forest->set_from->cmesh; @@ -3747,33 +3745,13 @@ t8_forest_get_first_local_element_id (t8_forest_t forest) return -1; } -t8_scheme_cxx_t * +t8_scheme * t8_forest_get_scheme (const t8_forest_t forest) { T8_ASSERT (t8_forest_is_committed (forest)); - T8_ASSERT (forest->scheme_cxx != NULL); - - return forest->scheme_cxx; -} - -t8_eclass_scheme_c * -t8_forest_get_eclass_scheme (const t8_forest_t forest, const t8_eclass_t eclass) -{ - T8_ASSERT (t8_forest_is_committed (forest)); - T8_ASSERT (forest->scheme_cxx != NULL); - T8_ASSERT (eclass != T8_ECLASS_COUNT); - - return forest->scheme_cxx->eclass_schemes[eclass]; -} - -t8_eclass_scheme_c * -t8_forest_get_eclass_scheme_before_commit (t8_forest_t forest, t8_eclass_t eclass) -{ - T8_ASSERT (t8_forest_is_initialized (forest)); - T8_ASSERT (forest->scheme_cxx != NULL); - T8_ASSERT (eclass != T8_ECLASS_COUNT); + T8_ASSERT (forest->scheme != NULL); - return forest->scheme_cxx->eclass_schemes[eclass]; + return forest->scheme; } t8_eclass_t @@ -4147,8 +4125,7 @@ t8_forest_write_vtk (t8_forest_t forest, const char *fileprefix) } t8_forest_t -t8_forest_new_uniform (t8_cmesh_t cmesh, t8_scheme_cxx_t *scheme, const int level, const int do_face_ghost, - sc_MPI_Comm comm) +t8_forest_new_uniform (t8_cmesh_t cmesh, t8_scheme *scheme, const int level, const int do_face_ghost, sc_MPI_Comm comm) { t8_forest_t forest; @@ -4207,7 +4184,7 @@ t8_forest_free_trees (t8_forest_t forest) if (t8_forest_get_tree_element_count (tree) >= 1) { /* destroy first and last descendant */ const t8_eclass_t eclass = t8_forest_get_tree_class (forest, jt); - const t8_eclass_scheme_c *scheme = forest->scheme_cxx->eclass_schemes[eclass]; + const t8_scheme *scheme = forest->scheme_cxx->eclass_schemes[eclass]; t8_element_destroy (scheme, 1, &tree->first_desc); t8_element_destroy (scheme, 1, &tree->last_desc); } @@ -4258,7 +4235,7 @@ t8_forest_reset (t8_forest_t *pforest) } /* we have taken ownership on calling t8_forest_set_* */ if (forest->scheme_cxx != NULL) { - t8_scheme_cxx_unref (&forest->scheme_cxx); + t8_schemexx_unref (&forest->scheme_cxx); } if (forest->cmesh != NULL) { t8_cmesh_unref (&forest->cmesh); diff --git a/src/t8_forest/t8_forest_adapt.cxx b/src/t8_forest/t8_forest_adapt.cxx index 5b8e2caf9f..e6598311df 100644 --- a/src/t8_forest/t8_forest_adapt.cxx +++ b/src/t8_forest/t8_forest_adapt.cxx @@ -44,7 +44,7 @@ T8_EXTERN_C_BEGIN (); * not valid. */ static int -t8_forest_is_family_callback (t8_eclass_scheme_c *ts, const int num_elements, t8_element_t **elements) +t8_forest_is_family_callback (t8_scheme *ts, const int num_elements, t8_element_t **elements) { for (int iter = 0; iter < num_elements; iter++) { @@ -101,8 +101,7 @@ t8_forest_is_family_callback (t8_eclass_scheme_c *ts, const int num_elements, t8 * recursively, return INT32_MIN. */ static t8_locidx_t -t8_forest_pos (t8_forest_t forest, t8_eclass_scheme_c *ts, t8_element_array_t *telements, - const t8_locidx_t telements_pos) +t8_forest_pos (t8_forest_t forest, t8_scheme *ts, t8_element_array_t *telements, const t8_locidx_t telements_pos) { const t8_locidx_t elements_in_array = t8_element_array_get_count (telements); T8_ASSERT (0 <= telements_pos && telements_pos < elements_in_array); @@ -212,9 +211,9 @@ t8_forest_pos (t8_forest_t forest, t8_eclass_scheme_c *ts, t8_element_array_t *t * \param [in] el_buffer Buffer space to store a family of elements. */ static void -t8_forest_adapt_coarsen_recursive (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, t8_element_array_t *telements, t8_locidx_t el_coarsen, - t8_locidx_t *el_inserted, t8_element_t **el_buffer) +t8_forest_adapt_coarsen_recursive (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t lelement_id, t8_scheme *ts, + t8_element_array_t *telements, t8_locidx_t el_coarsen, t8_locidx_t *el_inserted, + t8_element_t **el_buffer) { T8_ASSERT (el_coarsen >= 0); /* el_inserted is the index of the last element in telements plus one. @@ -313,9 +312,9 @@ t8_forest_adapt_coarsen_recursive (t8_forest_t forest, t8_locidx_t ltreeid, t8_l * \param [in] element_removed Flag set to 1 if element was removed. */ static void -t8_forest_adapt_refine_recursive (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, sc_list_t *elem_list, t8_element_array_t *telements, - t8_locidx_t *num_inserted, t8_element_t **el_buffer, int *element_removed) +t8_forest_adapt_refine_recursive (t8_forest_t forest, t8_locidx_t ltreeid, t8_locidx_t lelement_id, t8_scheme *ts, + sc_list_t *elem_list, t8_element_array_t *telements, t8_locidx_t *num_inserted, + t8_element_t **el_buffer, int *element_removed) { while (elem_list->elem_count > 0) { /* Until the list is empty we @@ -367,7 +366,7 @@ void t8_forest_adapt (t8_forest_t forest) { t8_forest_t forest_from; - t8_eclass_scheme_c *tscheme; + t8_scheme *tscheme; t8_element_array_t *telements; t8_element_array_t *telements_from; t8_element_t **elements; diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index 53f6061bd5..a9b98556f8 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -42,12 +42,12 @@ T8_EXTERN_C_BEGIN (); * if we refine recursively. */ static int t8_forest_balance_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t ltree_id, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { int *pdone, iface, num_faces, num_half_neighbors, ineigh; t8_gloidx_t neighbor_tree; t8_eclass_t neigh_class; - t8_eclass_scheme_c *neigh_scheme; + t8_scheme *neigh_scheme; const t8_element_t *element = elements[0]; t8_element_t **half_neighbors; @@ -104,7 +104,7 @@ t8_forest_compute_max_element_level (t8_forest_t forest) { t8_locidx_t ielement, elem_in_tree; t8_locidx_t itree, num_trees; - t8_eclass_scheme_c *scheme; + t8_scheme *scheme; int local_max_level = 0, elem_level; /* Iterate over all local trees and all local elements and comupte the maximum occurring level */ @@ -316,7 +316,7 @@ t8_forest_is_balanced (t8_forest_t forest) t8_forest_t forest_from; t8_locidx_t num_trees, num_elements; t8_locidx_t itree, ielem; - t8_eclass_scheme_c *ts; + t8_scheme *ts; void *data_temp; int dummy_int; diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index 650b520ace..550de10561 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -63,6 +63,7 @@ T8_EXTERN_C_BEGIN (); * \param [in] forest_old The forest that is adapted * \param [in] forest_new The forest that is newly constructed from \a forest_old * \param [in] which_tree The local tree containing \a first_outgoing and \a first_incoming + * \param [in] tree_class The eclass of the local tree containing \a first_outgoing and \a first_incoming * \param [in] ts The eclass scheme of the tree * \param [in] refine -1 if family in \a forest_old got coarsened, 0 if element * has not been touched, 1 if element got refined and -2 if @@ -84,7 +85,7 @@ T8_EXTERN_C_BEGIN (); * \see t8_forest_iterate_replace */ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, - t8_eclass_scheme_c *ts, const int refine, const int num_outgoing, + t8_eclass_t tree_class, t8_scheme_c *ts, const int refine, const int num_outgoing, const t8_locidx_t first_outgoing, const int num_incoming, const t8_locidx_t first_incoming); @@ -112,8 +113,8 @@ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, t8_forest_t forest_ /* TODO: Do we really need the forest argument? Since the forest is not committed yet it * seems dangerous to expose to the user. */ typedef int (*t8_forest_adapt_t) (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]); + t8_locidx_t lelement_id, t8_scheme_c *ts, const int is_family, const int num_elements, + t8_element_t *elements[]); /** Create a new forest with reference count one. * This forest needs to be specialized with the t8_forest_set_* calls. @@ -198,7 +199,7 @@ t8_forest_set_cmesh (t8_forest_t forest, t8_cmesh_t cmesh, sc_MPI_Comm comm); * This can be prevented by referencing \b scheme. */ void -t8_forest_set_scheme (t8_forest_t forest, t8_scheme_cxx_t *scheme); +t8_forest_set_scheme (t8_forest_t forest, t8_scheme_c *scheme); /** Set the initial refinement level to be used when \b forest is committed. * \param [in,out] forest The forest whose level will be set. @@ -529,7 +530,7 @@ t8_forest_element_is_leaf (const t8_forest_t forest, const t8_element_t *element * For more information about the encoding of face orientation refer to \ref t8_cmesh_get_face_neighbor. */ int -t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_eclass_scheme_c *ts, +t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_scheme_c *ts, const t8_element_t *leaf, int face); /** Compute the leaf face neighbors of a forest. @@ -568,14 +569,13 @@ t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, void t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, - t8_locidx_t **pelement_indices, t8_eclass_scheme_c **pneigh_scheme, - int forest_is_balanced); + t8_locidx_t **pelement_indices, t8_scheme_c **pneigh_scheme, int forest_is_balanced); void t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, - t8_locidx_t **pelement_indices, t8_eclass_scheme_c **pneigh_scheme, - int forest_is_balanced, t8_gloidx_t *gneigh_tree, int *orientation); + t8_locidx_t **pelement_indices, t8_scheme_c **pneigh_scheme, int forest_is_balanced, + t8_gloidx_t *gneigh_tree, int *orientation); /** Exchange ghost information of user defined element data. * \param[in] forest The forest. Must be committed. @@ -762,19 +762,9 @@ t8_forest_get_first_local_element_id (t8_forest_t forest); * \return The element scheme of the forest. * \see t8_forest_set_scheme */ -t8_scheme_cxx_t * +t8_scheme_c * t8_forest_get_scheme (const t8_forest_t forest); -/** Return the eclass scheme of a given element class associated to a forest. - * \param [in] forest. A committed forest. - * \param [in] eclass. An element class. - * \return The eclass scheme of \a eclass associated to forest. - * \see t8_forest_set_scheme - * \note The forest is not required to have trees of class \a eclass. - */ -t8_eclass_scheme_c * -t8_forest_get_eclass_scheme (t8_forest_t forest, t8_eclass_t eclass); - /** Return the eclass of the tree in which a face neighbor of a given element * lies. * \param [in] forest. A committed forest. @@ -805,7 +795,7 @@ t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, cons */ t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, - t8_eclass_scheme_c *neigh_scheme, int face, int *neigh_face); + t8_scheme_c *neigh_scheme, int face, int *neigh_face); /* TODO: implement */ void @@ -847,7 +837,7 @@ t8_forest_element_points_inside (t8_forest_t forest, t8_locidx_t ltreeid, const * \ref t8_forest_set_scheme, \ref t8_forest_set_level, and \ref t8_forest_commit. */ t8_forest_t -t8_forest_new_uniform (t8_cmesh_t cmesh, t8_scheme_cxx_t *scheme, const int level, const int do_face_ghost, +t8_forest_new_uniform (t8_cmesh_t cmesh, t8_scheme_c *scheme, const int level, const int do_face_ghost, sc_MPI_Comm comm); /** Build a adapted forest from another forest. diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index de868e1922..f606acd850 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -370,7 +370,7 @@ static void t8_ghost_init_remote_tree (t8_forest_t forest, t8_gloidx_t gtreeid, int remote_rank, t8_eclass_t eclass, t8_ghost_remote_tree_t *remote_tree) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_locidx_t local_treeid; T8_ASSERT (remote_tree != NULL); @@ -397,7 +397,7 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran t8_ghost_remote_t remote_entry_lookup, *remote_entry; t8_ghost_remote_tree_t *remote_tree; t8_element_t *elem_copy; - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_eclass_t eclass; sc_array_t *remote_array; size_t index, element_count; @@ -492,7 +492,7 @@ typedef struct Each entry is an array of 2 * (max_num_faces + 1) integers, | face_0 low | face_0 high | ... | face_n low | face_n high | owner low | owner high | */ sc_array_t face_owners; /* Temporary storage for all owners at a leaf's face */ - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_gloidx_t gtreeid; int level_nca; /* The refinement level of the root element in the search. At position element_level - level_nca in bounds_per_level are the bounds @@ -687,7 +687,7 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int gh t8_tree_t tree; t8_eclass_t tree_class, neigh_class, last_class; t8_gloidx_t neighbor_tree; - t8_eclass_scheme_c *ts, *neigh_scheme = NULL, *prev_neigh_scheme = NULL; + t8_scheme *ts, *neigh_scheme = NULL, *prev_neigh_scheme = NULL; int iface, num_faces; int num_face_children, max_num_face_children = 0; @@ -1020,7 +1020,7 @@ t8_forest_ghost_parse_received_message (t8_forest_t forest, t8_forest_ghost_t gh size_t num_elements, old_elem_count, ghosts_offset; t8_ghost_gtree_hash_t *tree_hash, **pfound_tree, *found_tree; t8_ghost_tree_t *ghost_tree; - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_element_t *element_insert; t8_ghost_process_hash_t *process_hash; #ifdef T8_ENABLE_DEBUG diff --git a/src/t8_forest/t8_forest_iterate.cxx b/src/t8_forest/t8_forest_iterate.cxx index e6abca40ea..bb3585d952 100644 --- a/src/t8_forest/t8_forest_iterate.cxx +++ b/src/t8_forest/t8_forest_iterate.cxx @@ -24,13 +24,14 @@ #include #include #include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); typedef struct { - const t8_eclass_scheme_c *ts; + const t8_scheme *ts; int level; int num_children; } t8_forest_child_type_query_t; @@ -56,7 +57,7 @@ t8_forest_split_array (const t8_element_t *element, t8_element_array_t *leaf_ele sc_array_t offset_view; t8_forest_child_type_query_t query_data; - const t8_eclass_scheme_c *ts = t8_element_array_get_scheme (leaf_elements); + const t8_scheme *ts = t8_element_array_get_scheme (leaf_elements); /* Store the number of children and the level of element */ query_data.num_children = ts->t8_element_num_children (element); query_data.level = ts->t8_element_level (element); @@ -78,7 +79,7 @@ t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_eleme t8_element_array_t *leaf_elements, void *user_data, t8_locidx_t tree_lindex_of_first_leaf, t8_forest_iterate_face_fn callback) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_eclass_t eclass; t8_element_t **face_children; int child_face, num_face_children, iface; @@ -170,10 +171,10 @@ t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_eleme * the query function is not called for this element. */ static void -t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_element_t *element, - const t8_eclass_scheme_c *ts, t8_element_array_t *leaf_elements, - const t8_locidx_t tree_lindex_of_first_leaf, t8_forest_search_fn search_fn, - t8_forest_query_fn query_fn, sc_array_t *queries, sc_array_t *active_queries) +t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_element_t *element, const t8_scheme *ts, + t8_element_array_t *leaf_elements, const t8_locidx_t tree_lindex_of_first_leaf, + t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries, + sc_array_t *active_queries) { /* Assertions to check for necessary requirements */ /* The forest must be committed */ @@ -293,7 +294,7 @@ t8_forest_search_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_search /* Get the element class, scheme and leaf elements of this tree */ const t8_eclass_t eclass = t8_forest_get_eclass (forest, ltreeid); - const t8_eclass_scheme_c *ts = t8_forest_get_eclass_scheme (forest, eclass); + const t8_scheme *ts = t8_forest_get_eclass_scheme (forest, eclass); t8_element_array_t *leaf_elements = t8_forest_tree_get_leaves (forest, ltreeid); /* assert for empty tree */ @@ -353,11 +354,11 @@ t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_fo /* Get the number of elements of this tree in old and new forest */ const t8_locidx_t elems_per_tree_new = t8_forest_get_tree_num_elements (forest_new, itree); const t8_locidx_t elems_per_tree_old = t8_forest_get_tree_num_elements (forest_old, itree); - /* Get the eclass and scheme of the tree */ + /* Get the eclass of the tree and scheme */ t8_eclass_t eclass = t8_forest_get_tree_class (forest_new, itree); T8_ASSERT (eclass == t8_forest_get_tree_class (forest_old, itree)); - t8_eclass_scheme_c *ts = t8_forest_get_eclass_scheme (forest_new, eclass); - T8_ASSERT (ts == t8_forest_get_eclass_scheme (forest_new, eclass)); + t8_scheme *ts = t8_forest_get_scheme (forest_new, eclass); + T8_ASSERT (ts == t8_forest_get_scheme (forest_new, eclass)); t8_locidx_t ielem_new = 0; t8_locidx_t ielem_old = 0; @@ -371,8 +372,8 @@ t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_fo const t8_element_t *elem_old = t8_forest_get_element_in_tree (forest_old, itree, ielem_old); /* Get the levels of these elements */ - const int level_new = ts->t8_element_level (elem_new); - const int level_old = ts->t8_element_level (elem_old); + const int level_new = ts->element_get_level (eclass, elem_new); + const int level_old = ts->element_get_level (eclass, elem_old); if (forest_new->incomplete_trees) { /* If el_removed is 1, the element in forest_new has been removed. @@ -381,22 +382,22 @@ t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_fo if (level_old < level_new) { /* elem_old got refined or removed */ t8_element_t *elem_parent; - ts->t8_element_new (1, &elem_parent); - ts->t8_element_parent (elem_new, elem_parent); - if (ts->t8_element_equal (elem_old, elem_parent)) { + ts->element_new (tree_class, 1, &elem_parent); + ts->element_get_parent (tree_class, elem_new, elem_parent); + if (ts->element_is_equal (tree_class, elem_old, elem_parent)) { /* elem_old got refined */ T8_ASSERT (level_new == level_old + 1); - const t8_locidx_t family_size = ts->t8_element_num_children (elem_old); + const t8_locidx_t family_size = ts->element_get_num_children (tree_class, elem_old); #if T8_DEBUG /* Check if family of new refined elements is complete */ T8_ASSERT (ielem_new + family_size <= elems_per_tree_new); for (t8_locidx_t ielem = 1; ielem < family_size; ielem++) { const t8_element_t *elem_new_debug = t8_forest_get_element_in_tree (forest_new, itree, ielem_new + ielem); ts->t8_element_parent (elem_new_debug, elem_parent); - SC_CHECK_ABORT (ts->t8_element_equal (elem_old, elem_parent), "Family is not complete."); + SC_CHECK_ABORT (ts->element_is_equal (tree_class, elem_old, elem_parent), "Family is not complete."); } #endif - ts->t8_element_destroy (1, &elem_parent); + ts->element_destroy (tree_class, 1, &elem_parent); const int refine = 1; replace_fn (forest_old, forest_new, itree, ts, refine, 1, ielem_old, family_size, ielem_new); /* Advance to the next element */ @@ -406,41 +407,42 @@ t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_fo else { /* elem_old got removed */ el_removed = 1; - ts->t8_element_destroy (1, &elem_parent); + ts->element_destroy (tree_class, 1, &elem_parent); } } else if (level_old > level_new) { /* elem_old got coarsened or removed */ t8_element_t *elem_parent; - ts->t8_element_new (1, &elem_parent); - ts->t8_element_parent (elem_old, elem_parent); - if (ts->t8_element_equal (elem_new, elem_parent)) { + ts->element_new (tree_class, 1, &elem_parent); + ts->element_get_parent (tree_class, elem_old, elem_parent); + if (ts->element_is_equal (tree_class, elem_new, elem_parent)) { /* elem_old got coarsened */ T8_ASSERT (level_new == level_old - 1); /* Get size of family of old forest */ int family_size = 1; for (t8_locidx_t ielem = 1; - ielem < ts->t8_element_num_children (elem_new) && ielem + ielem_old < elems_per_tree_old; ielem++) { + ielem < ts->element_get_num_children (tree_class, elem_new) && ielem + ielem_old < elems_per_tree_old; + ielem++) { elem_old = t8_forest_get_element_in_tree (forest_old, itree, ielem_old + ielem); - ts->t8_element_parent (elem_old, elem_parent); - if (ts->t8_element_equal (elem_new, elem_parent)) { + ts->element_get_parent (tree_class, elem_old, elem_parent); + if (ts->element_is_equal (tree_class, elem_new, elem_parent)) { family_size++; } } - T8_ASSERT (family_size <= ts->t8_element_num_children (elem_new)); + T8_ASSERT (family_size <= ts->element_get_num_children (tree_class, elem_new)); #if T8_DEBUG /* Check whether elem_old is the first element of the family */ - for (t8_locidx_t ielem = 1; ielem < ts->t8_element_num_children (elem_old) && ielem_old - ielem >= 0; - ielem++) { + for (t8_locidx_t ielem = 1; + ielem < ts->element_get_num_children (tree_class, elem_old) && ielem_old - ielem >= 0; ielem++) { const t8_element_t *elem_old_debug = t8_forest_get_element_in_tree (forest_old, itree, ielem_old - ielem); - ts->t8_element_parent (elem_old_debug, elem_parent); + ts->element_get_parent (tree_class, elem_old_debug, elem_parent); SC_CHECK_ABORT (!ts->t8_element_equal (elem_new, elem_parent), "elem_old is not the first of the family."); } #endif - ts->t8_element_destroy (1, &elem_parent); + ts->element_destroy (tree_class, 1, &elem_parent); const int refine = -1; - replace_fn (forest_old, forest_new, itree, ts, refine, family_size, ielem_old, 1, ielem_new); + replace_fn (forest_old, forest_new, itree, tree_class, ts, refine, family_size, ielem_old, 1, ielem_new); /* Advance to the next element */ ielem_new++; ielem_old += family_size; @@ -448,15 +450,15 @@ t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_fo else { /* elem_old got removed */ el_removed = 1; - ts->t8_element_destroy (1, &elem_parent); + ts->element_destroy (tree_class, 1, &elem_parent); } } else { /* elem_old was untouched or got removed */ - if (ts->t8_element_equal (elem_new, elem_old)) { + if (ts->element_is_equal (tree_class, elem_new, elem_old)) { /* elem_new = elem_old */ const int refine = 0; - replace_fn (forest_old, forest_new, itree, ts, refine, 1, ielem_old, 1, ielem_new); + replace_fn (forest_old, forest_new, itree, tree_class, ts, refine, 1, ielem_old, 1, ielem_new); /* Advance to the next element */ ielem_new++; ielem_old++; @@ -485,9 +487,9 @@ t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_fo if (level_old < level_new) { T8_ASSERT (level_new == level_old + 1); /* elem_old was refined */ - const t8_locidx_t family_size = ts->t8_element_num_children (elem_old); + const t8_locidx_t family_size = ts->element_get_num_children (tree_class, elem_old); const int refine = 1; - replace_fn (forest_old, forest_new, itree, ts, refine, 1, ielem_old, family_size, ielem_new); + replace_fn (forest_old, forest_new, itree, tree_class, ts, refine, 1, ielem_old, family_size, ielem_new); /* Advance to the next element */ ielem_new += family_size; ielem_old++; @@ -495,18 +497,18 @@ t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_fo else if (level_old > level_new) { T8_ASSERT (level_new == level_old - 1); /* elem_old was coarsened */ - const t8_locidx_t family_size = ts->t8_element_num_children (elem_new); + const t8_locidx_t family_size = ts->element_get_num_children (tree_class, elem_new); const int refine = -1; - replace_fn (forest_old, forest_new, itree, ts, refine, family_size, ielem_old, 1, ielem_new); + replace_fn (forest_old, forest_new, itree, tree_class, ts, refine, family_size, ielem_old, 1, ielem_new); /* Advance to the next element */ ielem_new++; ielem_old += family_size; } else { /* elem_new = elem_old */ - T8_ASSERT (ts->t8_element_equal (elem_new, elem_old)); + T8_ASSERT (ts->element_is_equal (tree_class, elem_new, elem_old)); const int refine = 0; - replace_fn (forest_old, forest_new, itree, ts, refine, 1, ielem_old, 1, ielem_new); + replace_fn (forest_old, forest_new, itree, tree_class, ts, refine, 1, ielem_old, 1, ielem_new); /* Advance to the next element */ ielem_new++; ielem_old++; @@ -518,7 +520,7 @@ t8_forest_iterate_replace (t8_forest_t forest_new, t8_forest_t forest_old, t8_fo for (; ielem_old < elems_per_tree_old; ielem_old++) { /* remaining elements in old tree got removed */ const int refine = -2; - replace_fn (forest_old, forest_new, itree, ts, refine, 1, ielem_old, 0, -1); + replace_fn (forest_old, forest_new, itree, tree_class, ts, refine, 1, ielem_old, 0, -1); } } else { diff --git a/src/t8_forest/t8_forest_netcdf.cxx b/src/t8_forest/t8_forest_netcdf.cxx index f9c82f8f95..c4ca0a57b7 100644 --- a/src/t8_forest/t8_forest_netcdf.cxx +++ b/src/t8_forest/t8_forest_netcdf.cxx @@ -416,7 +416,7 @@ t8_forest_write_netcdf_data (t8_forest_t forest, t8_forest_netcdf_context_t *con /* Iterate over all local elements in the local tree */ for (local_elem_id = 0; local_elem_id < num_local_tree_elem; local_elem_id++) { /* Get the eclass scheme */ - t8_eclass_scheme_c *scheme = t8_forest_get_eclass_scheme (forest, tree_class); + t8_scheme *scheme = t8_forest_get_eclass_scheme (forest, tree_class); /* Get the local element in the local tree */ const t8_element_t *element = t8_forest_get_element_in_tree (forest, ltree_id, local_elem_id); /* Determine the element shape */ @@ -741,7 +741,7 @@ t8_forest_write_netcdf_coordinate_data (t8_forest_t forest, t8_forest_netcdf_con for (local_elem_id = 0; local_elem_id < num_local_tree_elem; local_elem_id++) { /* Get the eclass scheme */ - t8_eclass_scheme_c *scheme = t8_forest_get_eclass_scheme (forest, tree_class); + t8_scheme *scheme = t8_forest_get_eclass_scheme (forest, tree_class); /* Get the local element in the local tree */ const t8_element_t *element = t8_forest_get_element_in_tree (forest, ltree_id, local_elem_id); /* Determine the element shape */ diff --git a/src/t8_forest/t8_forest_partition.cxx b/src/t8_forest/t8_forest_partition.cxx index eb77317fa4..68444d931a 100644 --- a/src/t8_forest/t8_forest_partition.cxx +++ b/src/t8_forest/t8_forest_partition.cxx @@ -122,7 +122,7 @@ t8_forest_partition_test_desc (t8_forest_t forest) t8_element_t *elem_desc; t8_linearidx_t first_desc_id; t8_locidx_t ielem; - t8_eclass_scheme_c *ts; + t8_scheme *ts; t8_tree_t tree; int level; @@ -223,7 +223,7 @@ t8_forest_partition_test_boundary_element (const t8_forest_t forest) T8_ASSERT (itree > -1); } const t8_tree_t tree = t8_forest_get_tree (forest, itree); - t8_eclass_scheme_c *ts = t8_forest_get_eclass_scheme (forest, tree->eclass); + t8_scheme *ts = t8_forest_get_eclass_scheme (forest, tree->eclass); t8_element_t *element_last_desc; ts->t8_element_new (1, &element_last_desc); /* last element of current rank */ @@ -255,7 +255,7 @@ t8_forest_partition_create_first_desc (t8_forest_t forest) sc_MPI_Comm comm; t8_linearidx_t local_first_desc; t8_element_t *first_desc = NULL; - t8_eclass_scheme_c *ts; + t8_scheme *ts; T8_ASSERT (t8_forest_is_committed (forest)); @@ -918,7 +918,7 @@ t8_forest_partition_recv_message (t8_forest_t forest, sc_MPI_Comm comm, int proc t8_forest_partition_tree_info_t *tree_info; t8_tree_t tree, last_tree; size_t element_size {}; - t8_eclass_scheme_c *eclass_scheme; + t8_scheme *eclass_scheme; if (proc != forest->mpirank) { T8_ASSERT (proc == status->MPI_SOURCE); diff --git a/src/t8_forest/t8_forest_private.h b/src/t8_forest/t8_forest_private.h index f43e244631..8c59119350 100644 --- a/src/t8_forest/t8_forest_private.h +++ b/src/t8_forest/t8_forest_private.h @@ -57,7 +57,7 @@ T8_EXTERN_C_BEGIN (); */ int t8_forest_is_incomplete_family (const t8_forest_t forest, const t8_locidx_t ltree_id, const t8_locidx_t el_considered, - t8_eclass_scheme_c *tscheme, t8_element_t **elements, const int elements_size); + t8_scheme_c *tscheme, t8_element_t **elements, const int elements_size); /* For each tree in a forest compute its first and last descendant */ void @@ -77,7 +77,7 @@ t8_forest_populate (t8_forest_t forest); * \see t8_forest_set_scheme * \note The forest is not required to have trees of class \a eclass. */ -t8_eclass_scheme_c * +t8_scheme_c * t8_forest_get_eclass_scheme_before_commit (t8_forest_t forest, t8_eclass_t eclass); /** Compute the maximum possible refinement level in a forest. @@ -98,7 +98,7 @@ t8_forest_compute_maxlevel (t8_forest_t forest); * \see t8_forest_new_uniform. */ int -t8_forest_min_nonempty_level (t8_cmesh_t cmesh, t8_scheme_cxx_t *scheme); +t8_forest_min_nonempty_level (t8_cmesh_t cmesh, t8_scheme_c *scheme); /** return nonzero if the first tree of a forest is shared with a smaller * process. @@ -396,8 +396,8 @@ t8_forest_element_owners_at_neigh_face_bounds (t8_forest_t forest, t8_locidx_t l */ t8_gloidx_t t8_forest_element_half_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, - t8_element_t *neighs[], t8_eclass_scheme_c *neigh_scheme, int face, - int num_neighs, int dual_faces[]); + t8_element_t *neighs[], t8_scheme_c *neigh_scheme, int face, int num_neighs, + int dual_faces[]); /** Iterate over all leaves of a forest and for each face compute the face neighbor * leaves with \ref t8_forest_leaf_face_neighbors and print their local element ids. @@ -421,8 +421,7 @@ t8_forest_print_all_leaf_neighbors (t8_forest_t forest); * \note \a forest must be committed before calling this function. */ int -t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, - t8_eclass_scheme_c *ts); +t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_scheme_c *ts); T8_EXTERN_C_END (); diff --git a/src/t8_forest/t8_forest_types.h b/src/t8_forest/t8_forest_types.h index 10f4c84b72..83f1ee7f1a 100644 --- a/src/t8_forest/t8_forest_types.h +++ b/src/t8_forest/t8_forest_types.h @@ -75,13 +75,13 @@ typedef struct t8_forest sc_MPI_Comm mpicomm; /**< MPI communicator to use. */ t8_cmesh_t cmesh; /**< Coarse mesh to use. */ - //t8_scheme_t *scheme; /**< Scheme for element types. */ - t8_scheme_cxx_t *scheme_cxx; /**< Scheme for element types. */ - int maxlevel; /**< The maximum allowed refinement level for elements in this forest. */ - int maxlevel_existing; /**< If >= 0, the maximum occurring refinemnent level of a forest element. */ - int do_dup; /**< Communicator shall be duped. */ - int dimension; /**< Dimension inferred from \b cmesh. */ - int incomplete_trees; /**< Flag to check whether the forest has (potential) incomplete trees. + //t8_scheme_c *scheme; /**< Scheme for element types. */ + t8_scheme_c *scheme; /**< Scheme for element types. */ + int maxlevel; /**< The maximum allowed refinement level for elements in this forest. */ + int maxlevel_existing; /**< If >= 0, the maximum occurring refinemnent level of a forest element. */ + int do_dup; /**< Communicator shall be duped. */ + int dimension; /**< Dimension inferred from \b cmesh. */ + int incomplete_trees; /**< Flag to check whether the forest has (potential) incomplete trees. A tree is incomplete if an element has been removed from it. Once an element got removed, the flag sets to 1 (true) and stays. For a committed forest this flag is either true on all ranks or diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear.cxx index b03e54a8f3..9e85990b1e 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_linear.cxx @@ -102,7 +102,7 @@ t8_geometry_linear::t8_geom_point_batch_inside_element (t8_forest_t forest, t8_l const double tolerance) const { const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); - t8_eclass_scheme_c *ts = t8_forest_get_eclass_scheme (forest, tree_class); + t8_scheme *ts = t8_forest_get_eclass_scheme (forest, tree_class); const t8_element_shape_t element_shape = ts->t8_element_shape (element); switch (element_shape) { case T8_ECLASS_VERTEX: { diff --git a/src/t8_schemes/t8_default/t8_default.cxx b/src/t8_schemes/t8_default/t8_default.cxx index 6c3f19b953..b11d6803a4 100644 --- a/src/t8_schemes/t8_default/t8_default.cxx +++ b/src/t8_schemes/t8_default/t8_default.cxx @@ -24,24 +24,15 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include - /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); -t8_scheme_cxx_t * +t8_scheme * t8_scheme_new_default_cxx (void) { - t8_scheme_cxx_t *s; + t8_scheme *s; - s = T8_ALLOC_ZERO (t8_scheme_cxx_t, 1); + s = T8_ALLOC_ZERO (t8_scheme, 1); t8_refcount_init (&s->rc); s->eclass_schemes[T8_ECLASS_VERTEX] = new t8_default_scheme_vertex_c (); @@ -76,7 +67,7 @@ t8_scheme_new_default_cxx (void) } int -t8_eclass_scheme_is_default (t8_eclass_scheme_c *ts) +t8_eclass_scheme_is_default (t8_scheme *ts) { switch (ts->eclass) { case T8_ECLASS_VERTEX: diff --git a/src/t8_schemes/t8_default/t8_default.hxx b/src/t8_schemes/t8_default/t8_default.hxx index 8c84f2bade..dc61f99f0d 100644 --- a/src/t8_schemes/t8_default/t8_default.hxx +++ b/src/t8_schemes/t8_default/t8_default.hxx @@ -29,11 +29,20 @@ #pragma once #include +#include +#include +#include +#include +#include +#include +#include +#include +#include T8_EXTERN_C_BEGIN (); /** Return the default element implementation of t8code. */ -t8_scheme_cxx_t * +t8_scheme_c * t8_scheme_new_default_cxx (void); /** Check whether a given eclass_scheme is one of the default schemes. @@ -42,6 +51,6 @@ t8_scheme_new_default_cxx (void); * false (zero) otherwise. */ int -t8_eclass_scheme_is_default (t8_eclass_scheme_c *ts); +t8_eclass_scheme_is_default (t8_scheme_c *ts); T8_EXTERN_C_END (); diff --git a/src/t8_schemes/t8_default/t8_default_c_interface.h b/src/t8_schemes/t8_default/t8_default_c_interface.h index baab722cf1..36a6d0cee6 100644 --- a/src/t8_schemes/t8_default/t8_default_c_interface.h +++ b/src/t8_schemes/t8_default/t8_default_c_interface.h @@ -32,7 +32,7 @@ T8_EXTERN_C_BEGIN (); /** Return the default element implementation of t8code. */ -t8_scheme_cxx_t * +t8_scheme_c * t8_scheme_new_default_cxx (void); /** Check whether a given eclass_scheme is one of the default schemes. @@ -41,7 +41,7 @@ t8_scheme_new_default_cxx (void); * false (zero) otherwise. */ int -t8_eclass_scheme_is_default (t8_eclass_scheme_c *ts); +t8_eclass_scheme_is_default (t8_scheme_c *ts); T8_EXTERN_C_END (); diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.cxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.cxx index b83349f5ff..c3e8962a55 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.cxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.cxx @@ -3,7 +3,7 @@ t8code is a C library to manage a collection (a forest) of multiple connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2015 the developers + Copyright (C) 2024 the developers t8code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ T8_EXTERN_C_BEGIN (); * \param [in] length Non-negative number of elements to allocate. * \param [in,out] elem Array of correct size whose members are filled. */ -static void +inline static void t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, t8_element_t **elem); /** This class independent function assumes an sc_mempool_t as context. @@ -43,7 +43,7 @@ t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, t8_element_t **e * \param [in] length Non-negative number of elements to destroy. * \param [in,out] elem Array whose members are returned to the mempool. */ -static void +inline static void t8_default_mempool_free (sc_mempool_t *ts_context, int length, t8_element_t **elem); /* Destructor */ @@ -56,7 +56,7 @@ t8_default_scheme_common_c::~t8_default_scheme_common_c () /** Compute the number of corners of a given element. */ int -t8_default_scheme_common_c::t8_element_num_corners (const t8_element_t *elem) const +t8_default_scheme_common_c::element_get_num_corners (const t8_element_t *elem) const { /* use the lookup table of the eclasses. * Pyramids should implement their own version of this function. */ @@ -64,18 +64,18 @@ t8_default_scheme_common_c::t8_element_num_corners (const t8_element_t *elem) co } void -t8_default_scheme_common_c::t8_element_new (int length, t8_element_t **elem) const +t8_default_scheme_common_c::element_new (int length, t8_element_t **elem) const { t8_default_mempool_alloc ((sc_mempool_t *) this->ts_context, length, elem); } void -t8_default_scheme_common_c::t8_element_destroy (int length, t8_element_t **elem) const +t8_default_scheme_common_c::element_destroy (int length, t8_element_t **elem) const { t8_default_mempool_free ((sc_mempool_t *) this->ts_context, length, elem); } -static void +inline static void t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, t8_element_t **elem) { int i; @@ -89,7 +89,7 @@ t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, t8_element_t **e } } -static void +inline static void t8_default_mempool_free (sc_mempool_t *ts_context, int length, t8_element_t **elem) { int i; @@ -104,7 +104,7 @@ t8_default_mempool_free (sc_mempool_t *ts_context, int length, t8_element_t **el } t8_element_shape_t -t8_default_scheme_common_c::t8_element_shape (const t8_element_t *elem) const +t8_default_scheme_common_c::element_get_shape (const t8_element_t *elem) const { return eclass; } @@ -118,10 +118,10 @@ count_leaves_from_level (int element_level, int refinement_level, int dimension) } t8_gloidx_t -t8_default_scheme_common_c::t8_element_count_leaves (const t8_element_t *t, int level) const +t8_default_scheme_common_c::element_count_leaves (const t8_element_t *t, int level) const { - int element_level = t8_element_level (t); + int element_level = element_get_level (t); t8_element_shape_t element_shape; int dim = t8_eclass_to_dimension[eclass]; element_shape = t8_element_shape (t); @@ -136,7 +136,7 @@ t8_default_scheme_common_c::t8_element_count_leaves (const t8_element_t *t, int * The number of children is 2^dim for each element, except for pyramids. * TODO: For pyramids we will have to implement a standalone version in the pyramid scheme. */ int -t8_default_scheme_common_c::t8_element_num_siblings (const t8_element_t *elem) const +t8_default_scheme_common_c::element_get_num_siblings (const t8_element_t *elem) const { const int dim = t8_eclass_to_dimension[eclass]; T8_ASSERT (eclass != T8_ECLASS_PYRAMID); @@ -144,7 +144,7 @@ t8_default_scheme_common_c::t8_element_num_siblings (const t8_element_t *elem) c } t8_gloidx_t -t8_default_scheme_common_c::t8_element_count_leaves_from_root (int level) const +t8_default_scheme_common_c::count_leaves_from_root (int level) const { if (eclass == T8_ECLASS_PYRAMID) { return 2 * sc_intpow64u (8, level) - sc_intpow64u (6, level); @@ -155,16 +155,16 @@ t8_default_scheme_common_c::t8_element_count_leaves_from_root (int level) const #if T8_ENABLE_DEBUG void -t8_default_scheme_common_c::t8_element_debug_print (const t8_element_t *elem) const +t8_default_scheme_common_c::element_debug_print (const t8_element_t *elem) const { char debug_string[BUFSIZ]; - t8_element_to_string (elem, debug_string, BUFSIZ); + element_to_string (elem, debug_string, BUFSIZ); t8_debugf ("%s\n", debug_string); } #endif void -t8_default_scheme_common_c::t8_element_deinit (int length, t8_element_t *elem) const +t8_default_scheme_common_c::element_deinit (int length, t8_element_t *elem) const { } diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx index e40861ca88..bb6b664f55 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx @@ -3,7 +3,7 @@ t8code is a C library to manage a collection (a forest) of multiple connected adaptive space-trees of general element classes in parallel. - Copyright (C) 2015 the developers + Copyright (C) 2024 the developers t8code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,34 +27,32 @@ #pragma once #include +#include /* Macro to check whether a pointer (VAR) to a base class, comes from an * implementation of a child class (TYPE). */ #define T8_COMMON_IS_TYPE(VAR, TYPE) ((dynamic_cast (VAR)) != NULL) -class t8_default_scheme_common_c: public t8_eclass_scheme_c { +class t8_default_scheme_common_c { public: /** Destructor for all default schemes */ - virtual ~t8_default_scheme_common_c (); - - virtual void - t8_element_deinit (int length, t8_element_t *elem) const override; + ~t8_default_scheme_common_c (); /** Compute the number of corners of a given element. */ int - t8_element_num_corners (const t8_element_t *elem) const override; + element_get_num_corners (const t8_element_t *elem) const; /** Allocate space for a bunch of elements. */ void - t8_element_new (int length, t8_element_t **elem) const override; + element_new (int length, t8_element_t **elem) const; /** Deallocate space for a bunch of elements. */ void - t8_element_destroy (int length, t8_element_t **elem) const override; + element_destroy (int length, t8_element_t **elem) const; /** Return the shape of an element */ t8_element_shape_t - t8_element_shape (const t8_element_t *elem) const override; + element_get_shape (const t8_element_t *elem) const; /** Count how many leaf descendants of a given uniform level an element would produce. * \param [in] t The element to be checked. @@ -65,7 +63,7 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { * children. */ t8_gloidx_t - t8_element_count_leaves (const t8_element_t *t, int level) const override; + element_count_leaves (const t8_element_t *t, int level) const; /** Compute the number of siblings of an element. That is the number of * Children of its parent. @@ -74,7 +72,7 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { * Note that this number is >= 1, since we count the element itself as a sibling. */ int - t8_element_num_siblings (const t8_element_t *elem) const override; + element_get_num_siblings (const t8_element_t *elem) const; /** Count how many leaf descendants of a given uniform level the root element will produce. * \param [in] level A refinement level. @@ -82,52 +80,10 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c { * is the root (level 0) element. */ t8_gloidx_t - t8_element_count_leaves_from_root (int level) const override; - - /** Compute the integer coordinates of a given element vertex. - * The default scheme implements the Morton type SFCs. In these SFCs the - * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and - * L the maximum refinement level. - * All element vertices have integer coordinates in this cube. - * \param [in] elem The element. - * \param [in] vertex The id of the vertex whose coordinates shall be computed. - * \param [out] coords An array of at least as many integers as the element's dimension - * whose entries will be filled with the coordinates of \a vertex. - */ - virtual void - t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const - = 0; - - /** Convert points in the reference space of an element to points in the - * reference space of the tree. - * - * \param [in] elem The element. - * \param [in] coords_input The coordinates \f$ [0,1]^\mathrm{dim} \f$ of the point - * in the reference space of the element. - * \param [in] num_coords Number of \f$ dim\f$-sized coordinates to evaluate. - * \param [out] out_coords The coordinates of the points in the - * reference space of the tree. - */ - void - t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const override - = 0; - - /** Get the integer coordinates of the anchor node of an element. - * The default scheme implements the Morton type SFCs. In these SFCs the - * elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and - * L the maximum refinement level. - * All element vertices have integer coordinates in this cube and the anchor - * node is the first of all vertices (index 0). It also has the lowest x,y and z - * coordinates. - * \param [in] elem The element. - * \param [out] anchor The integer coordinates of the anchor node in the cube [0,1]^(dL) - */ - virtual void - t8_element_anchor (const t8_element_t *elem, int anchor[3]) const - = 0; + count_leaves_from_root (int level) const; + #if T8_ENABLE_DEBUG - virtual void - t8_element_debug_print (const t8_element_t *elem) const; + void + element_debug_print (const t8_element_t *elem) const; #endif }; diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx index 5465eda575..73bd3076f4 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx @@ -34,88 +34,88 @@ T8_EXTERN_C_BEGIN (); int -t8_default_scheme_hex_c::t8_element_maxlevel (void) const +t8_default_scheme_hex_c::get_maxlevel (void) const { return HEX_REFINE_MAXLEVEL; } int -t8_default_scheme_hex_c::t8_element_level (const t8_element_t *elem) const +t8_default_scheme_hex_c::element_get_level (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return (int) ((const p8est_quadrant_t *) elem)->level; } void -t8_default_scheme_hex_c::t8_element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_hex_c::element_copy (const t8_element_t *source, t8_element_t *dest) const { - T8_ASSERT (t8_element_is_valid (source)); - T8_ASSERT (t8_element_is_valid (dest)); + T8_ASSERT (element_is_valid (source)); + T8_ASSERT (element_is_valid (dest)); *(p8est_quadrant_t *) dest = *(const p8est_quadrant_t *) source; } int -t8_default_scheme_hex_c::t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_hex_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); return p8est_quadrant_compare ((const p8est_quadrant_t *) elem1, (const p8est_quadrant_t *) elem2); } int -t8_default_scheme_hex_c::t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_hex_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return p8est_quadrant_is_equal ((const p8est_quadrant_t *) elem1, (const p8est_quadrant_t *) elem2); } void -t8_default_scheme_hex_c::t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_hex_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (parent)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (parent)); p8est_quadrant_parent ((const p8est_quadrant_t *) elem, (p8est_quadrant_t *) parent); } void -t8_default_scheme_hex_c::t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const +t8_default_scheme_hex_c::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (sibling)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (sibling)); p8est_quadrant_sibling ((const p8est_quadrant_t *) elem, (p8est_quadrant_t *) sibling, sibid); } int -t8_default_scheme_hex_c::t8_element_num_faces (const t8_element_t *elem) const +t8_default_scheme_hex_c::element_get_num_faces (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return P8EST_FACES; } int -t8_default_scheme_hex_c::t8_element_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_hex_c::element_get_max_num_faces (const t8_element_t *elem) const { return P8EST_FACES; } int -t8_default_scheme_hex_c::t8_element_num_children (const t8_element_t *elem) const +t8_default_scheme_hex_c::element_get_num_children (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return P8EST_CHILDREN; } int -t8_default_scheme_hex_c::t8_element_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_hex_c::element_get_num_face_children (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return 4; } int -t8_default_scheme_hex_c::t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_hex_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const { - T8_ASSERT (t8_element_is_valid (element)); + T8_ASSERT (element_is_valid (element)); T8_ASSERT (0 <= face && face < P8EST_FACES); T8_ASSERT (0 <= corner && corner < 4); @@ -123,14 +123,14 @@ t8_default_scheme_hex_c::t8_element_get_face_corner (const t8_element_t *element } void -t8_default_scheme_hex_c::t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_hex_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; const p4est_qcoord_t shift = P8EST_QUADRANT_LEN (q->level + 1); p8est_quadrant_t *r = (p8est_quadrant_t *) child; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (child)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (child)); T8_ASSERT (p8est_quadrant_is_extended (q)); T8_ASSERT (q->level < HEX_REFINE_MAXLEVEL); T8_ASSERT (0 <= childid && childid < P8EST_CHILDREN); @@ -145,14 +145,14 @@ t8_default_scheme_hex_c::t8_element_child (const t8_element_t *elem, int childid } void -t8_default_scheme_hex_c::t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_hex_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); #ifdef T8_ENABLE_DEBUG { int i; for (i = 0; i < P8EST_CHILDREN; i++) { - T8_ASSERT (t8_element_is_valid (c[i])); + T8_ASSERT (element_is_valid (c[i])); } } #endif @@ -162,26 +162,26 @@ t8_default_scheme_hex_c::t8_element_children (const t8_element_t *elem, int leng } int -t8_default_scheme_hex_c::t8_element_child_id (const t8_element_t *elem) const +t8_default_scheme_hex_c::element_get_child_id (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return p8est_quadrant_child_id ((const p8est_quadrant_t *) elem); } int -t8_default_scheme_hex_c::t8_element_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_hex_c::element_get_ancestor_id (const t8_element_t *elem, int level) const { return p8est_quadrant_ancestor_id ((p8est_quadrant_t *) elem, level); } int -t8_default_scheme_hex_c::t8_element_is_family (t8_element_t *const *fam) const +t8_default_scheme_hex_c::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG { int i; for (i = 0; i < P8EST_CHILDREN; i++) { - T8_ASSERT (t8_element_is_valid (fam[i])); + T8_ASSERT (element_is_valid (fam[i])); } } #endif @@ -189,38 +189,38 @@ t8_default_scheme_hex_c::t8_element_is_family (t8_element_t *const *fam) const } void -t8_default_scheme_hex_c::t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const +t8_default_scheme_hex_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); p8est_nearest_common_ancestor ((const p8est_quadrant_t *) elem1, (const p8est_quadrant_t *) elem2, (p8est_quadrant_t *) nca); } t8_element_shape_t -t8_default_scheme_hex_c::t8_element_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_hex_c::element_get_face_shape (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_ECLASS_QUAD; } void -t8_default_scheme_hex_c::t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_hex_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { int child_ids_local[4], i, *child_ids; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); #ifdef T8_ENABLE_DEBUG { int j; for (j = 0; j < P4EST_CHILDREN; j++) { - T8_ASSERT (t8_element_is_valid (children[j])); + T8_ASSERT (element_is_valid (children[j])); } } #endif T8_ASSERT (0 <= face && face < P8EST_FACES); - T8_ASSERT (num_children == t8_element_num_face_children (elem, face)); + T8_ASSERT (num_children == element_get_num_face_children (elem, face)); if (child_indices != NULL) { child_ids = child_indices; @@ -251,25 +251,25 @@ t8_default_scheme_hex_c::t8_element_children_at_face (const t8_element_t *elem, * the usage allows for elem == children[0]. */ for (i = 3; i >= 0; i--) { - t8_element_child (elem, child_ids[i], children[i]); + element_get_child (elem, child_ids[i], children[i]); } } int -t8_default_scheme_hex_c::t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_hex_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); /* For octants the face enumeration of children is the same as for the parent. */ return face; } int -t8_default_scheme_hex_c::t8_element_face_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_hex_c::element_face_get_parent_face (const t8_element_t *elem, int face) const { int child_id; const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); if (q->level == 0) { return face; } @@ -284,25 +284,25 @@ t8_default_scheme_hex_c::t8_element_face_parent_face (const t8_element_t *elem, } int -t8_default_scheme_hex_c::t8_element_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_hex_c::element_get_tree_face (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < P8EST_FACES); /* For hexahedra the face and the tree face number are the same. */ return face; } int -t8_default_scheme_hex_c::t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_hex_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, + t8_element_t *elem, int root_face) const { const p4est_quadrant_t *b = (const p4est_quadrant_t *) face; p8est_quadrant_t *q = (p8est_quadrant_t *) elem; T8_ASSERT (T8_COMMON_IS_TYPE (face_scheme, const t8_default_scheme_quad_c *)); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (face_scheme->eclass == T8_ECLASS_QUAD); - T8_ASSERT (face_scheme->t8_element_is_valid (face)); + T8_ASSERT (face_scheme->element_is_valid (face)); T8_ASSERT (0 <= root_face && root_face < P8EST_FACES); q->level = b->level; /* @@ -358,8 +358,8 @@ t8_default_scheme_hex_c::t8_element_extrude_face (const t8_element_t *face, cons /** Construct the first descendant of an element that touches a given face. */ void -t8_default_scheme_hex_c::t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, - int level) const +t8_default_scheme_hex_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p8est_quadrant_t *desc = (p8est_quadrant_t *) first_desc; @@ -376,8 +376,8 @@ t8_default_scheme_hex_c::t8_element_first_descendant_face (const t8_element_t *e /** Construct the last descendant of an element that touches a given face. */ void -t8_default_scheme_hex_c::t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, - int level) const +t8_default_scheme_hex_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p8est_quadrant_t *desc = (p8est_quadrant_t *) last_desc; @@ -393,16 +393,16 @@ t8_default_scheme_hex_c::t8_element_last_descendant_face (const t8_element_t *el } void -t8_default_scheme_hex_c::t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const +t8_default_scheme_hex_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *boundary_scheme) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p4est_quadrant_t *b = (p4est_quadrant_t *) boundary; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (T8_COMMON_IS_TYPE (boundary_scheme, const t8_default_scheme_quad_c *)); T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_QUAD); - T8_ASSERT (boundary_scheme->t8_element_is_valid (boundary)); + T8_ASSERT (boundary_scheme->element_is_valid (boundary)); T8_ASSERT (0 <= face && face < P8EST_FACES); /* The level of the boundary element is the same as the quadrant's level */ @@ -431,12 +431,12 @@ t8_default_scheme_hex_c::t8_element_boundary_face (const t8_element_t *elem, int } int -t8_default_scheme_hex_c::t8_element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_hex_c::element_is_root_boundary (const t8_element_t *elem, int face) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p4est_qcoord_t coord; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < P8EST_FACES); /* if face is 0 or 1 q->x @@ -450,14 +450,14 @@ t8_default_scheme_hex_c::t8_element_is_root_boundary (const t8_element_t *elem, } int -t8_default_scheme_hex_c::t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, - int *neigh_face) const +t8_default_scheme_hex_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, + int face, int *neigh_face) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p8est_quadrant_t *n = (p8est_quadrant_t *) neigh; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (neigh)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (neigh)); T8_ASSERT (0 <= face && face < P8EST_FACES); /* Compute the face neighbor */ p8est_quadrant_face_neighbor (q, face, n); @@ -476,9 +476,9 @@ t8_default_scheme_hex_c::t8_element_face_neighbor_inside (const t8_element_t *el } void -t8_default_scheme_hex_c::t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_hex_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= HEX_LINEAR_MAXLEVEL); T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << P8EST_DIM * level); @@ -486,47 +486,49 @@ t8_default_scheme_hex_c::t8_element_set_linear_id (t8_element_t *elem, int level } t8_linearidx_t -t8_default_scheme_hex_c::t8_element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_hex_c::element_get_linear_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= HEX_LINEAR_MAXLEVEL); return p8est_quadrant_linear_id ((p8est_quadrant_t *) elem, level); } void -t8_default_scheme_hex_c::t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_hex_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= HEX_REFINE_MAXLEVEL); p8est_quadrant_first_descendant ((p8est_quadrant_t *) elem, (p8est_quadrant_t *) desc, level); } void -t8_default_scheme_hex_c::t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_hex_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= HEX_REFINE_MAXLEVEL); p8est_quadrant_last_descendant ((p8est_quadrant_t *) elem, (p8est_quadrant_t *) desc, level); } void -t8_default_scheme_hex_c::t8_element_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_hex_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); - T8_ASSERT (0 <= t8_element_level (elem1) && t8_element_level (elem1) <= HEX_REFINE_MAXLEVEL); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); + T8_ASSERT (0 <= element_get_level (elem1) && element_get_level (elem1) <= HEX_REFINE_MAXLEVEL); p8est_quadrant_successor ((p8est_quadrant_t *) elem1, (p8est_quadrant_t *) elem2); } void -t8_default_scheme_hex_c::t8_element_anchor (const t8_element_t *elem, int coord[3]) const +t8_default_scheme_hex_c::element_get_anchor (const t8_element_t *elem, int coord[3]) const { p8est_quadrant_t *q; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); q = (p8est_quadrant_t *) elem; coord[0] = q->x; coord[1] = q->y; @@ -534,7 +536,7 @@ t8_default_scheme_hex_c::t8_element_anchor (const t8_element_t *elem, int coord[ } void -t8_default_scheme_hex_c::t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_hex_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) elem; @@ -549,14 +551,14 @@ t8_default_scheme_hex_c::t8_element_vertex_integer_coords (const t8_element_t *e } void -t8_default_scheme_hex_c::t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_hex_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= vertex && vertex < 8); int coords_int[3]; - t8_element_vertex_integer_coords (elem, vertex, coords_int); + element_get_vertex_integer_coords (elem, vertex, coords_int); /* We divide the integer coordinates by the root length of the hex * to obtain the reference coordinates. */ @@ -566,32 +568,32 @@ t8_default_scheme_hex_c::t8_element_vertex_reference_coords (const t8_element_t } void -t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_hex_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dhex_compute_reference_coords ((const t8_dhex_t *) elem, ref_coords, num_coords, out_coords); } int -t8_default_scheme_hex_c::t8_element_refines_irregular () const +t8_default_scheme_hex_c::refines_irregular () const { /* Hex always refine regularly */ return 0; } void -t8_default_scheme_hex_c::t8_element_new (int length, t8_element_t **elem) const +t8_default_scheme_hex_c::element_new (int length, t8_element_t **elem) const { /* allocate memory for a hex */ - t8_default_scheme_common_c::t8_element_new (length, elem); + t8_default_scheme_common_c::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG { int i; for (i = 0; i < length; i++) { - t8_element_root (elem[i]); + get_root (elem[i]); T8_QUAD_SET_TDIM ((p8est_quadrant_t *) elem[i], 3); } } @@ -599,7 +601,7 @@ t8_default_scheme_hex_c::t8_element_new (int length, t8_element_t **elem) const } void -t8_default_scheme_hex_c::t8_element_init (int length, t8_element_t *elem) const +t8_default_scheme_hex_c::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG p8est_quadrant_t *quads = (p8est_quadrant_t *) elem; @@ -613,7 +615,7 @@ t8_default_scheme_hex_c::t8_element_init (int length, t8_element_t *elem) const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_hex_c::t8_element_is_valid (const t8_element_t *elem) const +t8_default_scheme_hex_c::element_is_valid (const t8_element_t *elem) const { /* TODO: additional checks? do we set pad8 or similar? */ @@ -622,10 +624,9 @@ t8_default_scheme_hex_c::t8_element_is_valid (const t8_element_t *elem) const } void -t8_default_scheme_hex_c::t8_element_to_string (const t8_element_t *elem, char *debug_string, - const int string_size) const +t8_default_scheme_hex_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); p8est_quadrant_t *hex = (p8est_quadrant_t *) elem; snprintf (debug_string, string_size, "x: %i, y: %i, z: %i, level: %i", hex->x, hex->y, hex->z, hex->level); @@ -649,7 +650,7 @@ t8_default_scheme_hex_c::~t8_default_scheme_hex_c () * and hence this empty function. */ } void -t8_default_scheme_hex_c::t8_element_root (t8_element_t *elem) const +t8_default_scheme_hex_c::get_root (t8_element_t *elem) const { p8est_quadrant_t *hex = (p8est_quadrant_t *) elem; p8est_quadrant_set_morton (hex, 0, 0); @@ -658,9 +659,8 @@ t8_default_scheme_hex_c::t8_element_root (t8_element_t *elem) const /* each hex is packed as x,y,z coordinates and the level */ void -t8_default_scheme_hex_c::t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_hex_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { int mpiret; p8est_quadrant_t **quads = (p8est_quadrant_t **) elements; @@ -678,7 +678,7 @@ t8_default_scheme_hex_c::t8_element_MPI_Pack (t8_element_t **const elements, con /* each hex is packed as x,y,z coordinates and the level */ void -t8_default_scheme_hex_c::t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_hex_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -699,9 +699,8 @@ t8_default_scheme_hex_c::t8_element_MPI_Pack_size (const unsigned int count, sc_ /* each hex is packed as x,y,z coordinates and the level */ void -t8_default_scheme_hex_c::t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_hex_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const { int mpiret; p8est_quadrant_t **quads = (p8est_quadrant_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx index ccb37a63ba..f3289f9eb4 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx @@ -31,17 +31,14 @@ #include #include -/** The structure holding a hexahedral element in the default scheme. +/** The class holding a hexahedral element in the default scheme. * We make this definition public for interoperability of element classes. * We might want to put this into a private, scheme-specific header file. */ typedef p8est_quadrant_t t8_phex_t; -struct t8_default_scheme_hex_c: public t8_default_scheme_common_c -{ +class t8_default_scheme_hex_c: public t8_eclass_scheme, public t8_default_scheme_common_c { public: - /** The virtual table for a particular implementation of an element class. */ - /** Constructor. */ t8_default_scheme_hex_c (); @@ -54,51 +51,51 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * On output all these pointers will point to an allocated * and initialized element. * \note Not every element that is created in t8code will be created by a call - * to this function. However, if an element is not created using \ref t8_element_new, - * then it is guaranteed that \ref t8_element_init is called on it. - * \note In debugging mode, an element that was created with \ref t8_element_new - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. - * \see t8_element_init - * \see t8_element_is_valid - */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + * to this function. However, if an element is not created using \ref element_new, + * then it is guaranteed that \ref element_init is called on it. + * \note In debugging mode, an element that was created with \ref element_new + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. + * \see element_init + * \see element_is_valid + */ + void + element_new (int length, t8_element_t **elem) const; /** Initialize an array of allocated hexaedra. * \param [in] length The number of hex to be initialized. * \param [in,out] elems On input an array of \b length many allocated * elements. * \param [in] called_new True if the elements in \a elem were created by a call - * to \ref t8_element_new. False if no element in \a elem + * to \ref element_new. False if no element in \a elem * was created in this way. The case that only some elements - * were created by \ref t8_element_new should never occur. - * \note In debugging mode, an element that was passed to \ref t8_element_init - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. + * were created by \ref element_new should never occur. + * \note In debugging mode, an element that was passed to \ref element_init + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. * Thus, if \a called_new is true this function should usually do nothing. - * \see t8_element_new - * \see t8_element_is_valid + * \see element_new + * \see element_is_valid */ - virtual void - t8_element_init (int length, t8_element_t *elem) const; + void + element_init (int length, t8_element_t *elem) const; /** Return the refinement level of an element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - virtual int - t8_element_level (const t8_element_t *elem) const; + int + element_get_level (const t8_element_t *elem) const; /** Return the maximum allowed level for this element class. * \return The maximum allowed level for elements of this class. */ - virtual int - t8_element_maxlevel (void) const; + int + get_maxlevel (void) const; /** Copy all entries of \b source to \b dest. \b dest must be an existing * element. No memory is allocated by this function. @@ -107,8 +104,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * entries of \b source. * \note \a source and \a dest may point to the same element. */ - virtual void - t8_element_copy (const t8_element_t *source, t8_element_t *dest) const; + void + element_copy (const t8_element_t *source, t8_element_t *dest) const; /** Compare two elements. * \param [in] elem1 The first element. @@ -117,8 +114,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * and positive if elem1 > elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - virtual int - t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -126,8 +123,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - virtual int - t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -141,8 +138,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * For a pyramid, for example, it may be either a * tetrahedron or a pyramid depending on \b elem's childid. */ - virtual void - t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const; + void + element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; /** Compute a specific sibling of a given hex element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -155,46 +152,46 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * The storage for this element must exist * and match the element class of the sibling. */ - virtual void - t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; + void + element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; /** Compute the number of faces of a given element. * \param [in] elem The element. * \return The number of faces of \a elem. */ - virtual int - t8_element_num_faces (const t8_element_t *elem) const; + int + element_get_num_faces (const t8_element_t *elem) const; /** Compute the maximum number of faces of a given element and all of its * descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - virtual int - t8_element_max_num_faces (const t8_element_t *elem) const; + int + element_get_max_num_faces (const t8_element_t *elem) const; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - virtual int - t8_element_num_children (const t8_element_t *elem) const; + int + element_get_num_children (const t8_element_t *elem) const; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - virtual int - t8_element_num_face_children (const t8_element_t *elem, int face) const; + int + element_get_num_face_children (const t8_element_t *elem, int face) const; /** Return the corner number of an element's face corner. * \param [in] element The element. * \param [in] face A face index for \a element. * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - virtual int - t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const; + int + element_get_face_corner (const t8_element_t *element, int face, int corner) const; /** Return the face numbers of the faces sharing an element's corner. * \param [in] element The element. @@ -202,8 +199,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - virtual int - t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const + int + element_get_corner_face (const t8_element_t *element, int corner, int face) const { SC_ABORT ("This function is not implemented yet.\n"); return 0; /* suppresses compiler warning */ @@ -217,8 +214,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * On output, a valid element. * It is valid to call this function with elem = child. */ - virtual void - t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const; + void + element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -228,17 +225,17 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * and match the element class in the children's ordering. * On output, all children are valid. * It is valid to call this function with elem = c[0]. - * \see t8_element_num_children + * \see element_get_num_children */ - virtual void - t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; + void + element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - virtual int - t8_element_child_id (const t8_element_t *elem) const; + int + element_get_child_id (const t8_element_t *elem) const; /** Compute the ancestor id of an element, that is the child id * at a given level. @@ -246,8 +243,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - virtual int - t8_element_ancestor_id (const t8_element_t *elem, int level) const; + int + element_get_ancestor_id (const t8_element_t *elem, int level) const; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class @@ -255,8 +252,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - virtual int - t8_element_is_family (t8_element_t *const *fam) const; + int + elements_are_family (t8_element_t *const *fam) const; /** Compute the nearest common ancestor of two elements. That is, * the element with highest level that still has both given elements as @@ -268,16 +265,16 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * On output the unique nearest common ancestor of * \b elem1 and \b elem2. */ - virtual void - t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; + void + element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; /** Compute the shape of the face of an element. * \param [in] elem The element. * \param [in] face A face of \a elem. * \return The element shape of the face. */ - virtual t8_element_shape_t - t8_element_face_shape (const t8_element_t *elem, int face) const; + t8_element_shape_t + element_get_face_shape (const t8_element_t *elem, int face) const; /** Given an element and a face of the element, compute all children of * the element that touch the face. @@ -288,14 +285,14 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * They will be stored in order of their linear id. * \param [in] num_children The number of elements in \a children. Must match * the number of children that touch \a face. - * \ref t8_element_num_face_children + * \ref element_get_num_face_children * \param [in,out] child_indices If not NULL, an array of num_children integers must be given, * on output its i-th entry is the child_id of the i-th face_child. * It is valid to call this function with elem = children[0]. */ - virtual void - t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const; + void + element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const; /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -313,12 +310,12 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [in] face_child A number 0 <= \a face_child < num_face_children, * specifying a child of \a elem that shares a face with \a face. * These children are counted in linear order. This coincides with - * the order of children from a call to \ref t8_element_children_at_face. + * the order of children from a call to \ref element_get_children_at_face. * \return The face number of the face of a child of \a elem * that coincides with \a face_child. */ - virtual int - t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const; + int + element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const; /** Given a face of an element return the face number * of the parent of the element that matches the element's face. Or return -1 if @@ -330,8 +327,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * the face number of this face. Otherwise -1. * \note For the root element this function always returns \a face. */ - virtual int - t8_element_face_parent_face (const t8_element_t *elem, int face) const; + int + element_face_get_parent_face (const t8_element_t *elem, int face) const; /** Given an element and a face of this element. If the face lies on the * tree boundary, return the face number of the tree face. @@ -342,8 +339,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \a face is on a tree boundary. * Any arbitrary integer if \a is not at a tree boundary. */ - virtual int - t8_element_tree_face (const t8_element_t *elem, int face) const; + int + element_get_tree_face (const t8_element_t *elem, int face) const; /** Suppose we have two trees that share a common face f. * Given an element e that is a subface of f in one of the trees @@ -366,9 +363,9 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * defined in relation to the smaller face. * \note \a elem1 and \a elem2 may point to the same element. */ - virtual void - t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, - int is_smaller_face) const + void + element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, + int is_smaller_face) const { SC_ABORT ("This function is not implemented yet.\n"); return; /* suppresses compiler warning */ @@ -387,9 +384,9 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \return The face number of the face of \a elem that coincides * with \a face. */ - virtual int - t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const; + int + element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, + int root_face) const; /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -399,8 +396,9 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the first descendant is constructed */ - virtual void - t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const; + void + element_construct_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, + int level) const; /** Construct the last descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -410,8 +408,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the last descendant is constructed */ - virtual void - t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const; + void + element_construct_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const; /** Construct the boundary element at a specific face. * \param [in] elem The input element. @@ -422,17 +420,17 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * of the face of \a element. * \param [in] boundary_scheme The scheme for the eclass of the boundary face. */ - virtual void - t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const; + void + element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme_c *boundary_scheme) const; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. * \param [in] face A face of \a elem. * \return True if \a face is a subface of the element's root element. */ - virtual int - t8_element_is_root_boundary (const t8_element_t *elem, int face) const; + int + element_is_root_boundary (const t8_element_t *elem, int face) const; /** Construct the face neighbor of a given element if this face neighbor * is inside the root tree. Return 0 otherwise. @@ -449,8 +447,9 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * False if not. In this case \a neigh's data can be arbitrary * on output. */ - virtual int - t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const; + int + element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const; /** Initialize the entries of an allocated element according to a * given linear id in a uniform refinement. @@ -459,8 +458,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [in] id The linear id. * id must fulfil 0 <= id < 'number of leaves in the uniform refinement' */ - virtual void - t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; + void + element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; /** Compute the linear id of a given element in a hypothetical uniform * refinement of a given level. @@ -468,8 +467,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [in] level The level of the uniform refinement to consider. * \return The linear id of the element. */ - virtual t8_linearidx_t - t8_element_get_linear_id (const t8_element_t *elem, int level) const; + t8_linearidx_t + element_get_linear_id (const t8_element_t *elem, int level) const; /** Compute the first descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -477,8 +476,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Compute the last descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -486,16 +485,16 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Construct the successor in a uniform refinement of a given element. * \param [in] elem1 The element whose successor should be constructed. * \param [in,out] elem2 The element whose entries will be set. * \param [in] level The level of the uniform refinement to consider. */ - virtual void - t8_element_successor (const t8_element_t *elem, t8_element_t *succ) const; + void + element_construct_successor (const t8_element_t *elem, t8_element_t *succ) const; /** Get the integer coordinates of the anchor node of an element. * The default scheme implements the Morton type SFCs. In these SFCs the @@ -507,8 +506,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [in] elem The element. * \param [out] anchor The integer coordinates of the anchor node in the cube [0,1]^(dL) */ - virtual void - t8_element_anchor (const t8_element_t *elem, int anchor[3]) const; + void + element_get_anchor (const t8_element_t *elem, int anchor[3]) const; /** Compute the integer coordinates of a given element vertex. * The default scheme implements the Morton type SFCs. In these SFCs the @@ -520,8 +519,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void - t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; + void + element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). @@ -532,8 +531,8 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \warning coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere * all coords might be used. */ - virtual void - t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; + void + element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; /** Convert points in the reference space of an element to points in the * reference space of the tree. @@ -545,34 +544,34 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [out] out_coords The coordinates of the points in the * reference space of the tree. */ - virtual void - t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + void + element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, + double *out_coords) const; /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because hexs refine regularly */ - virtual int - t8_element_refines_irregular (void) const; + int + refines_irregular (void) const; #ifdef T8_ENABLE_DEBUG /** Query whether a given element can be considered as 'valid' and it is * safe to perform any of the above algorithms on it. * \param [in] elem The element to be checked. * \return True if \a elem is safe to use. False otherwise. - * \note An element that is constructed with \ref t8_element_new + * \note An element that is constructed with \ref element_new * must pass this test. - * \note An element for which \ref t8_element_init was called must pass + * \note An element for which \ref element_init was called must pass * this test. * \note This function is used for debugging to catch certain errors. * These can for example occur when an element points to a region * of memory which should not be interpreted as an element. - * \note We recommend to use the assertion T8_ASSERT (t8_element_is_valid (elem)) + * \note We recommend to use the assertion T8_ASSERT (element_is_valid (elem)) * in the implementation of each of the functions in this file. */ - virtual int - t8_element_is_valid (const t8_element_t *t) const; + int + element_is_valid (const t8_element_t *t) const; /** * Print a given element. For a example for a triangle print the coordinates @@ -581,15 +580,15 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * * \param [in] elem The element to print */ - virtual void - t8_element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; + void + element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; #endif /** Fills an element with the root element. * \param [in,out] elem The element to be filled with root. */ void - t8_element_root (t8_element_t *elem) const; + get_root (t8_element_t *elem) const; /** Pack multiple elements into contiguous memory, so they can be sent via MPI. * \param [in] elements Array of elements that are to be packed @@ -599,17 +598,17 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [in, out] position the position of the first byte that is not already packed * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, - int *position, sc_MPI_Comm comm) const; + void + element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, + int *position, sc_MPI_Comm comm) const; /** Determine an upper bound for the size of the packed message of \b count elements * \param [in] count Number of elements to pack * \param [in] comm MPI Communicator * \param [out] pack_size upper bound on the message size */ - virtual void - t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; + void + element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; /** Unpack multiple elements from contiguous memory that was received via MPI. * \param [in] recvbuf Buffer from which to unpack the elements @@ -619,7 +618,7 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c * \param [in] count Number of elements to unpack * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, - const int unsigned count, sc_MPI_Comm comm) const; + void + element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const int unsigned count, sc_MPI_Comm comm) const; }; diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx index 392ccc735a..b5e490036e 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx @@ -31,86 +31,87 @@ typedef t8_dline_t t8_default_line_t; T8_EXTERN_C_BEGIN (); int -t8_default_scheme_line_c::t8_element_maxlevel (void) const +t8_default_scheme_line_c::get_maxlevel (void) const { return T8_DLINE_MAXLEVEL; } int -t8_default_scheme_line_c::t8_element_level (const t8_element_t *elem) const +t8_default_scheme_line_c::element_get_level (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dline_get_level ((const t8_dline_t *) elem); } void -t8_default_scheme_line_c::t8_element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_line_c::element_copy (const t8_element_t *source, t8_element_t *dest) const { - T8_ASSERT (t8_element_is_valid (source)); - T8_ASSERT (t8_element_is_valid (dest)); + T8_ASSERT (element_is_valid (source)); + T8_ASSERT (element_is_valid (dest)); t8_dline_copy ((const t8_dline_t *) source, (t8_dline_t *) dest); } int -t8_default_scheme_line_c::t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_line_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); return t8_dline_compare ((const t8_dline_t *) elem1, (const t8_dline_t *) elem2); } int -t8_default_scheme_line_c::t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_line_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dline_equal ((const t8_dline_t *) elem1, (const t8_dline_t *) elem2); } void -t8_default_scheme_line_c::t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_line_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { const t8_default_line_t *l = (const t8_default_line_t *) elem; t8_default_line_t *p = (t8_default_line_t *) parent; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (parent)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (parent)); t8_dline_parent (l, p); } void -t8_default_scheme_line_c::t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_line_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const t8_default_line_t *l = (const t8_default_line_t *) elem; t8_default_line_t *c = (t8_default_line_t *) child; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (child)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (child)); t8_dline_child (l, childid, c); } void -t8_default_scheme_line_c::t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const +t8_default_scheme_line_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, + t8_element_t *nca) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); - T8_ASSERT (t8_element_is_valid (nca)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); + T8_ASSERT (element_is_valid (nca)); t8_dline_nearest_common_ancestor ((const t8_dline_t *) elem1, (const t8_dline_t *) elem2, (t8_dline_t *) nca); } t8_element_shape_t -t8_default_scheme_line_c::t8_element_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_line_c::element_get_face_shape (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_ECLASS_VERTEX; } void -t8_default_scheme_line_c::t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_line_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); T8_ASSERT (num_children == 1); - T8_ASSERT (t8_element_is_valid (children[0])); + T8_ASSERT (element_is_valid (children[0])); /* We have exactly one child at a face and this is child 0 if face = 0 * and child 1 if face = 1 */ @@ -121,9 +122,9 @@ t8_default_scheme_line_c::t8_element_children_at_face (const t8_element_t *elem, } int -t8_default_scheme_line_c::t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_line_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); T8_ASSERT (face_child == 0); @@ -132,29 +133,29 @@ t8_default_scheme_line_c::t8_element_face_child_face (const t8_element_t *elem, } int -t8_default_scheme_line_c::t8_element_face_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_line_c::element_face_get_parent_face (const t8_element_t *elem, int face) const { /* The number of faces does not change from parent to child */ - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); return t8_dline_face_parent_face ((const t8_dline_t *) elem, face); } int -t8_default_scheme_line_c::t8_element_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_line_c::element_get_tree_face (const t8_element_t *elem, int face) const { /* The number of faces does not change from tree to element */ - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); return face; } void -t8_default_scheme_line_c::t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, - int sign, int is_smaller_face) const +t8_default_scheme_line_c::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, + int sign, int is_smaller_face) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); T8_ASSERT (orientation == 0 || orientation == 1); /* We can ignore is_smaller_face, since for lines the orientation is independent @@ -166,39 +167,39 @@ t8_default_scheme_line_c::t8_element_transform_face (const t8_element_t *elem1, * the element inside the root tree that has the given face as a * face. */ int -t8_default_scheme_line_c::t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_line_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, + t8_element_t *elem, int root_face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (T8_COMMON_IS_TYPE (face_scheme, const t8_default_scheme_vertex_c *)); - T8_ASSERT (face_scheme->t8_element_is_valid (face)); + T8_ASSERT (face_scheme->element_is_valid (face)); return t8_dline_extrude_face ((const t8_dvertex_t *) face, root_face, (t8_dline_t *) elem); } /** Construct the boundary element at a specific face. */ void -t8_default_scheme_line_c::t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const +t8_default_scheme_line_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *boundary_scheme) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (T8_COMMON_IS_TYPE (boundary_scheme, const t8_default_scheme_vertex_c *)); T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_VERTEX); - T8_ASSERT (boundary_scheme->t8_element_is_valid (boundary)); + T8_ASSERT (boundary_scheme->element_is_valid (boundary)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); /* Since each vertex is the same, we just construct a vertex of the same level * as elem. */ - t8_dvertex_init_linear_id ((t8_dvertex_t *) boundary, t8_element_level (elem), 0); + t8_dvertex_init_linear_id ((t8_dvertex_t *) boundary, element_get_level (elem), 0); } /** Construct the first descendant of an element that touches a given face. */ void -t8_default_scheme_line_c::t8_element_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_line_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (first_desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (first_desc)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL); @@ -214,33 +215,33 @@ t8_default_scheme_line_c::t8_element_first_descendant_face (const t8_element_t * } void -t8_default_scheme_line_c::t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, - int level) const +t8_default_scheme_line_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (last_desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (last_desc)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL); /* The last descendant is the same as the first descendant. */ - t8_element_first_descendant_face (elem, face, last_desc, level); + element_construct_first_descendant_face (elem, face, last_desc, level); } int -t8_default_scheme_line_c::t8_element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_line_c::element_is_root_boundary (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); return t8_dline_is_root_boundary ((const t8_dline_t *) elem, face); } int -t8_default_scheme_line_c::t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, - int *neigh_face) const +t8_default_scheme_line_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, + int face, int *neigh_face) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (neigh)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (neigh)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); t8_dline_face_neighbour ((const t8_dline_t *) elem, (t8_dline_t *) neigh, face, neigh_face); @@ -248,9 +249,9 @@ t8_default_scheme_line_c::t8_element_face_neighbor_inside (const t8_element_t *e } void -t8_default_scheme_line_c::t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_line_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL); T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << level); @@ -258,134 +259,136 @@ t8_default_scheme_line_c::t8_element_set_linear_id (t8_element_t *elem, int leve } void -t8_default_scheme_line_c::t8_element_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_line_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); - T8_ASSERT (1 <= t8_element_level (elem1) && t8_element_level (elem1) <= T8_DLINE_MAXLEVEL); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); + T8_ASSERT (1 <= element_get_level (elem1) && element_get_level (elem1) <= T8_DLINE_MAXLEVEL); - t8_dline_successor ((const t8_default_line_t *) elem1, (t8_default_line_t *) elem2, t8_element_level (elem1)); + t8_dline_successor ((const t8_default_line_t *) elem1, (t8_default_line_t *) elem2, element_get_level (elem1)); } void -t8_default_scheme_line_c::t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_line_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL); t8_dline_first_descendant ((const t8_dline_t *) elem, (t8_dline_t *) desc, level); } void -t8_default_scheme_line_c::t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_line_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL); t8_dline_last_descendant ((const t8_dline_t *) elem, (t8_dline_t *) desc, level); } void -t8_default_scheme_line_c::t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_line_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dline_vertex_integer_coords ((const t8_dline_t *) elem, vertex, coords); } void -t8_default_scheme_line_c::t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_line_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dline_vertex_ref_coords ((const t8_dline_t *) elem, vertex, coords); } void -t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_line_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (ref_coords != NULL); t8_dline_compute_reference_coords ((const t8_dline_t *) elem, ref_coords, num_coords, 0, out_coords); } t8_linearidx_t -t8_default_scheme_line_c::t8_element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_line_c::element_get_linear_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL); return t8_dline_linear_id ((const t8_dline_t *) elem, level); } int -t8_default_scheme_line_c::t8_element_num_faces (const t8_element_t *elem) const +t8_default_scheme_line_c::element_get_num_faces (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DLINE_FACES; } int -t8_default_scheme_line_c::t8_element_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_line_c::element_get_max_num_faces (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DLINE_FACES; } int -t8_default_scheme_line_c::t8_element_num_children (const t8_element_t *elem) const +t8_default_scheme_line_c::element_get_num_children (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DLINE_CHILDREN; } int -t8_default_scheme_line_c::t8_element_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_line_c::element_get_num_face_children (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); return T8_DLINE_FACE_CHILDREN; } int -t8_default_scheme_line_c::t8_element_child_id (const t8_element_t *elem) const +t8_default_scheme_line_c::element_get_child_id (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dline_child_id ((const t8_dline_t *) elem); } void -t8_default_scheme_line_c::t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_line_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (length == T8_DLINE_CHILDREN); t8_dline_childrenpv ((const t8_dline_t *) elem, (t8_dline_t **) c); } int -t8_default_scheme_line_c::t8_element_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_line_c::element_get_ancestor_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dline_ancestor_id ((const t8_dline_t *) elem, level); } int -t8_default_scheme_line_c::t8_element_is_family (t8_element_t *const *fam) const +t8_default_scheme_line_c::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG int i; for (i = 0; i < T8_DLINE_CHILDREN; i++) { - T8_ASSERT (t8_element_is_valid (fam[i])); + T8_ASSERT (element_is_valid (fam[i])); } #endif return t8_dline_is_familypv ((const t8_dline_t **) fam); } int -t8_default_scheme_line_c::t8_element_refines_irregular () const +t8_default_scheme_line_c::refines_irregular () const { /*lines always refine regularly */ return 0; @@ -393,16 +396,15 @@ t8_default_scheme_line_c::t8_element_refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_line_c::t8_element_is_valid (const t8_element_t *elem) const +t8_default_scheme_line_c::element_is_valid (const t8_element_t *elem) const { return t8_dline_is_valid ((const t8_dline_t *) elem); } void -t8_default_scheme_line_c::t8_element_to_string (const t8_element_t *elem, char *debug_string, - const int string_size) const +t8_default_scheme_line_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); t8_dline_t *line = (t8_dline_t *) elem; snprintf (debug_string, string_size, "x: %i, level: %i", line->x, line->level); @@ -410,24 +412,24 @@ t8_default_scheme_line_c::t8_element_to_string (const t8_element_t *elem, char * #endif void -t8_default_scheme_line_c::t8_element_new (int length, t8_element_t **elem) const +t8_default_scheme_line_c::element_new (int length, t8_element_t **elem) const { /* allocate memory for a line */ - t8_default_scheme_common_c::t8_element_new (length, elem); + t8_default_scheme_common_c::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG { int i; for (i = 0; i < length; i++) { - t8_element_root (elem[i]); + get_root (elem[i]); } } #endif } void -t8_default_scheme_line_c::t8_element_init (int length, t8_element_t *elem) const +t8_default_scheme_line_c::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dline_t *lines = (t8_dline_t *) elem; @@ -456,9 +458,8 @@ t8_default_scheme_line_c::~t8_default_scheme_line_c () /* each line is packed as an x coordinate and the level */ void -t8_default_scheme_line_c::t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_line_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { t8_default_line_t **lines = (t8_default_line_t **) elements; int mpiret; @@ -472,7 +473,7 @@ t8_default_scheme_line_c::t8_element_MPI_Pack (t8_element_t **const elements, co /* each line is packed as an x coordinate and the level */ void -t8_default_scheme_line_c::t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_line_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -491,9 +492,8 @@ t8_default_scheme_line_c::t8_element_MPI_Pack_size (const unsigned int count, sc /* each line is packed as an x coordinate and the level */ void -t8_default_scheme_line_c::t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_line_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const { int mpiret; t8_default_line_t **lines = (t8_default_line_t **) elements; @@ -506,7 +506,7 @@ t8_default_scheme_line_c::t8_element_MPI_Unpack (void *recvbuf, const int buffer } void -t8_default_scheme_line_c::t8_element_root (t8_element_t *elem) const +t8_default_scheme_line_c::get_root (t8_element_t *elem) const { t8_dline_t *line = (t8_dline_t *) elem; line->level = 0; diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx index 9ad91f60a1..8e5c509d60 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx @@ -36,11 +36,8 @@ * It is written as a self-contained library in the t8_dline_* files. */ -struct t8_default_scheme_line_c: public t8_default_scheme_common_c -{ +class t8_default_scheme_line_c: public t8_eclass_scheme, public t8_default_scheme_common_c { public: - /** The virtual table for a particular implementation of an element class. */ - /** Constructor. */ t8_default_scheme_line_c (); @@ -53,51 +50,51 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * On output all these pointers will point to an allocated * and initialized element. * \note Not every element that is created in t8code will be created by a call - * to this function. However, if an element is not created using \ref t8_element_new, - * then it is guaranteed that \ref t8_element_init is called on it. - * \note In debugging mode, an element that was created with \ref t8_element_new - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. - * \see t8_element_init - * \see t8_element_is_valid - */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + * to this function. However, if an element is not created using \ref element_new, + * then it is guaranteed that \ref element_init is called on it. + * \note In debugging mode, an element that was created with \ref element_new + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. + * \see element_init + * \see element_is_valid + */ + void + element_new (int length, t8_element_t **elem) const; /** Initialize an array of allocated line elements. * \param [in] length The number of line elements to be initialized. * \param [in,out] elems On input an array of \b length many allocated * elements. * \param [in] called_new True if the elements in \a elem were created by a call - * to \ref t8_element_new. False if no element in \a elem + * to \ref element_new. False if no element in \a elem * was created in this way. The case that only some elements - * were created by \ref t8_element_new should never occur. - * \note In debugging mode, an element that was passed to \ref t8_element_init - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. + * were created by \ref element_new should never occur. + * \note In debugging mode, an element that was passed to \ref element_init + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. * Thus, if \a called_new is true this function should usually do nothing. - * \see t8_element_new - * \see t8_element_is_valid + * \see element_new + * \see element_is_valid */ - virtual void - t8_element_init (int length, t8_element_t *elem) const; + void + element_init (int length, t8_element_t *elem) const; /** Return the refinement level of an element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - virtual int - t8_element_level (const t8_element_t *elem) const; + int + element_get_level (const t8_element_t *elem) const; /** Return the maximum allowed level for this element class. * \return The maximum allowed level for elements of this class. */ - virtual int - t8_element_maxlevel (void) const; + int + get_maxlevel (void) const; /** Copy all entries of \b source to \b dest. \b dest must be an existing * element. No memory is allocated by this function. @@ -106,8 +103,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * entries of \b source. * \note \a source and \a dest may point to the same element. */ - virtual void - t8_element_copy (const t8_element_t *source, t8_element_t *dest) const; + void + element_copy (const t8_element_t *source, t8_element_t *dest) const; /** Compare two elements. * \param [in] elem1 The first element. @@ -116,8 +113,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * and positive if elem1 > elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - virtual int - t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -125,8 +122,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - virtual int - t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -140,8 +137,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * For a pyramid, for example, it may be either a * tetrahedron or a pyramid depending on \b elem's childid. */ - virtual void - t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const; + void + element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; /** Compute a specific sibling of a given line element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -154,8 +151,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * The storage for this element must exist * and match the element class of the sibling. */ - virtual void - t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const + void + element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { SC_ABORT ("This function is not implemented yet.\n"); return; /* suppresses compiler warning */ @@ -165,39 +162,39 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in] elem The element. * \return The number of faces of \a elem. */ - virtual int - t8_element_num_faces (const t8_element_t *elem) const; + int + element_get_num_faces (const t8_element_t *elem) const; /** Compute the maximum number of faces of a given element and all of its * descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - virtual int - t8_element_max_num_faces (const t8_element_t *elem) const; + int + element_get_max_num_faces (const t8_element_t *elem) const; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - virtual int - t8_element_num_children (const t8_element_t *elem) const; + int + element_get_num_children (const t8_element_t *elem) const; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - virtual int - t8_element_num_face_children (const t8_element_t *elem, int face) const; + int + element_get_num_face_children (const t8_element_t *elem, int face) const; /** Return the corner number of an element's face corner. * \param [in] element The element. * \param [in] face A face index for \a element. * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - virtual int - t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const + int + element_get_face_corner (const t8_element_t *element, int face, int corner) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -209,8 +206,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - virtual int - t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const + int + element_get_corner_face (const t8_element_t *element, int corner, int face) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -224,8 +221,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * On output, a valid element. * It is valid to call this function with elem = child. */ - virtual void - t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const; + void + element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -235,17 +232,17 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * and match the element class in the children's ordering. * On output, all children are valid. * It is valid to call this function with elem = c[0]. - * \see t8_element_num_children + * \see element_get_num_children */ - virtual void - t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; + void + element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - virtual int - t8_element_child_id (const t8_element_t *elem) const; + int + element_get_child_id (const t8_element_t *elem) const; /** Compute the ancestor id of an element, that is the child id * at a given level. @@ -253,8 +250,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - virtual int - t8_element_ancestor_id (const t8_element_t *elem, int level) const; + int + element_get_ancestor_id (const t8_element_t *elem, int level) const; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class @@ -262,8 +259,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - virtual int - t8_element_is_family (t8_element_t *const *fam) const; + int + elements_are_family (t8_element_t *const *fam) const; /** Compute the nearest common ancestor of two elements. That is, * the element with highest level that still has both given elements as @@ -275,16 +272,16 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * On output the unique nearest common ancestor of * \b elem1 and \b elem2. */ - virtual void - t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; + void + element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; /** Compute the shape of the face of an element. * \param [in] elem The element. * \param [in] face A face of \a elem. * \return The element shape of the face. */ - virtual t8_element_shape_t - t8_element_face_shape (const t8_element_t *elem, int face) const; + t8_element_shape_t + element_get_face_shape (const t8_element_t *elem, int face) const; /** Given an element and a face of the element, compute all children of * the element that touch the face. @@ -295,14 +292,14 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * They will be stored in order of their linear id. * \param [in] num_children The number of elements in \a children. Must match * the number of children that touch \a face. - * \ref t8_element_num_face_children + * \ref element_get_num_face_children * \param [in,out] child_indices If not NULL, an array of num_children integers must be given, * on output its i-th entry is the child_id of the i-th face_child. * It is valid to call this function with elem = children[0]. */ - virtual void - t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const; + void + element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const; /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -320,12 +317,12 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in] face_child A number 0 <= \a face_child < num_face_children, * specifying a child of \a elem that shares a face with \a face. * These children are counted in linear order. This coincides with - * the order of children from a call to \ref t8_element_children_at_face. + * the order of children from a call to \ref element_get_children_at_face. * \return The face number of the face of a child of \a elem * that coincides with \a face_child. */ - virtual int - t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const; + int + element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const; /** Given a face of an element return the face number * of the parent of the element that matches the element's face. Or return -1 if @@ -337,8 +334,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * the face number of this face. Otherwise -1. * \note For the root element this function always returns \a face. */ - virtual int - t8_element_face_parent_face (const t8_element_t *elem, int face) const; + int + element_face_get_parent_face (const t8_element_t *elem, int face) const; /** Given an element and a face of this element. If the face lies on the * tree boundary, return the face number of the tree face. @@ -349,8 +346,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \a face is on a tree boundary. * Any arbitrary integer if \a is not at a tree boundary. */ - virtual int - t8_element_tree_face (const t8_element_t *elem, int face) const; + int + element_get_tree_face (const t8_element_t *elem, int face) const; /** Suppose we have two trees that share a common face f. * Given an element e that is a subface of f in one of the trees @@ -373,9 +370,9 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * defined in relation to the smaller face. * \note \a elem1 and \a elem2 may point to the same element. */ - virtual void - t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, - int is_smaller_face) const; + void + element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, + int is_smaller_face) const; /** Given a boundary face inside a root tree's face construct * the element inside the root tree that has the given face as a @@ -390,9 +387,9 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \return The face number of the face of \a elem that coincides * with \a face. */ - virtual int - t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const; + int + element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, + int root_face) const; /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -402,8 +399,9 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the first descendant is constructed */ - virtual void - t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const; + void + element_construct_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, + int level) const; /** Construct the last descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -413,8 +411,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the last descendant is constructed */ - virtual void - t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const; + void + element_construct_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const; /** Construct the boundary element at a specific face. * \param [in] elem The input element. @@ -425,17 +423,17 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * of the face of \a element. * \param [in] boundary_scheme The scheme for the eclass of the boundary face. */ - virtual void - t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const; + void + element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme_c *boundary_scheme) const; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. * \param [in] face A face of \a elem. * \return True if \a face is a subface of the element's root element. */ - virtual int - t8_element_is_root_boundary (const t8_element_t *elem, int face) const; + int + element_is_root_boundary (const t8_element_t *elem, int face) const; /** Construct the face neighbor of a given element if this face neighbor * is inside the root tree. Return 0 otherwise. @@ -452,8 +450,9 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * False if not. In this case \a neigh's data can be arbitrary * on output. */ - virtual int - t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const; + int + element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const; /** Initialize the entries of an allocated element according to a * given linear id in a uniform refinement. @@ -462,8 +461,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in] id The linear id. * id must fulfil 0 <= id < 'number of leaves in the uniform refinement' */ - virtual void - t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; + void + element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; /** Compute the linear id of a given element in a hypothetical uniform * refinement of a given level. @@ -471,8 +470,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in] level The level of the uniform refinement to consider. * \return The linear id of the element. */ - virtual t8_linearidx_t - t8_element_get_linear_id (const t8_element_t *elem, int level) const; + t8_linearidx_t + element_get_linear_id (const t8_element_t *elem, int level) const; /** Compute the first descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -480,8 +479,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Compute the last descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -489,16 +488,16 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Construct the successor in a uniform refinement of a given element. * \param [in] elem1 The element whose successor should be constructed. * \param [in,out] elem2 The element whose entries will be set. * \param [in] level The level of the uniform refinement to consider. */ - virtual void - t8_element_successor (const t8_element_t *elem, t8_element_t *succ) const; + void + element_construct_successor (const t8_element_t *elem, t8_element_t *succ) const; /** Get the integer coordinates of the anchor node of an element. * The default scheme implements the Morton type SFCs. In these SFCs the @@ -510,8 +509,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in] elem The element. * \param [out] anchor The integer coordinates of the anchor node in the cube [0,1]^(dL) */ - virtual void - t8_element_anchor (const t8_element_t *elem, int anchor[3]) const + void + element_get_anchor (const t8_element_t *elem, int anchor[3]) const { SC_ABORT ("This function is not implemented yet.\n"); return; /* suppresses compiler warning */ @@ -527,8 +526,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void - t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; + void + element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). @@ -539,8 +538,8 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \warning coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere * all coords might be used. */ - virtual void - t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; + void + element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; /** Convert points in the reference space of an element to points in the * reference space of the tree. @@ -552,34 +551,34 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [out] out_coords The coordinates of the points in the * reference space of the tree. */ - virtual void - t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + void + element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, + double *out_coords) const; /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because lines refine regularly */ - virtual int - t8_element_refines_irregular (void) const; + int + refines_irregular (void) const; #ifdef T8_ENABLE_DEBUG /** Query whether a given element can be considered as 'valid' and it is * safe to perform any of the above algorithms on it. * \param [in] elem The element to be checked. * \return True if \a elem is safe to use. False otherwise. - * \note An element that is constructed with \ref t8_element_new + * \note An element that is constructed with \ref element_new * must pass this test. - * \note An element for which \ref t8_element_init was called must pass + * \note An element for which \ref element_init was called must pass * this test. * \note This function is used for debugging to catch certain errors. * These can for example occur when an element points to a region * of memory which should not be interpreted as an element. - * \note We recommend to use the assertion T8_ASSERT (t8_element_is_valid (elem)) + * \note We recommend to use the assertion T8_ASSERT (element_is_valid (elem)) * in the implementation of each of the functions in this file. */ - virtual int - t8_element_is_valid (const t8_element_t *t) const; + int + element_is_valid (const t8_element_t *t) const; /** * Print a given element. For a example for a triangle print the coordinates @@ -588,14 +587,14 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * * \param [in] elem The element to print */ - virtual void - t8_element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; + void + element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; #endif /** Fills an element with the root element. * \param [in,out] elem The element to be filled with root. */ void - t8_element_root (t8_element_t *elem) const; + get_root (t8_element_t *elem) const; /** Pack multiple elements into contiguous memory, so they can be sent via MPI. * \param [in] elements Array of elements that are to be packed @@ -605,17 +604,17 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in, out] position the position of the first byte that is not already packed * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, - int *position, sc_MPI_Comm comm) const; + void + element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, + int *position, sc_MPI_Comm comm) const; /** Determine an upper bound for the size of the packed message of \b count elements * \param [in] count Number of elements to pack * \param [in] comm MPI Communicator * \param [out] pack_size upper bound on the message size */ - virtual void - t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; + void + element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; /** Unpack multiple elements from contiguous memory that was received via MPI. * \param [in] recvbuf Buffer from which to unpack the elements @@ -625,7 +624,7 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c * \param [in] count Number of elements to unpack * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, - const unsigned int count, sc_MPI_Comm comm) const; + void + element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const unsigned int count, sc_MPI_Comm comm) const; }; diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx index da2b18338d..7830ec2d98 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx @@ -30,24 +30,24 @@ typedef t8_dprism_t t8_default_prism_t; T8_EXTERN_C_BEGIN (); void -t8_default_scheme_prism_c::t8_element_new (int length, t8_element_t **elem) const +t8_default_scheme_prism_c::element_new (int length, t8_element_t **elem) const { /* allocate memory for a tet */ - t8_default_scheme_common_c::t8_element_new (length, elem); + t8_default_scheme_common_c::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG { int i; for (i = 0; i < length; i++) { - t8_element_root (elem[i]); + get_root (elem[i]); } } #endif } void -t8_default_scheme_prism_c::t8_element_init (int length, t8_element_t *elem) const +t8_default_scheme_prism_c::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dprism_t *prism = (t8_dprism_t *) elem; @@ -60,75 +60,75 @@ t8_default_scheme_prism_c::t8_element_init (int length, t8_element_t *elem) cons } int -t8_default_scheme_prism_c::t8_element_maxlevel (void) const +t8_default_scheme_prism_c::get_maxlevel (void) const { return T8_DPRISM_MAXLEVEL; } int -t8_default_scheme_prism_c::t8_element_level (const t8_element_t *elem) const +t8_default_scheme_prism_c::element_get_level (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dprism_get_level ((const t8_dprism_t *) elem); } t8_element_shape_t -t8_default_scheme_prism_c::t8_element_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_prism_c::element_get_face_shape (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); return t8_dprism_face_shape ((const t8_dprism_t *) elem, face); } void -t8_default_scheme_prism_c::t8_element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_prism_c::element_copy (const t8_element_t *source, t8_element_t *dest) const { - T8_ASSERT (t8_element_is_valid (source)); + T8_ASSERT (element_is_valid (source)); t8_dprism_copy ((const t8_dprism_t *) source, (t8_dprism_t *) dest); - T8_ASSERT (t8_element_is_valid (dest)); + T8_ASSERT (element_is_valid (dest)); } int -t8_default_scheme_prism_c::t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_prism_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); return t8_dprism_compare ((const t8_dprism_t *) elem1, (const t8_dprism_t *) elem2); } int -t8_default_scheme_prism_c::t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_prism_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dprism_equal ((const t8_dprism_t *) elem1, (const t8_dprism_t *) elem2); } void -t8_default_scheme_prism_c::t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_prism_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dprism_parent ((const t8_dprism_t *) elem, (t8_dprism_t *) parent); - T8_ASSERT (t8_element_is_valid (parent)); + T8_ASSERT (element_is_valid (parent)); } int -t8_default_scheme_prism_c::t8_element_num_children (const t8_element_t *elem) const +t8_default_scheme_prism_c::element_get_num_children (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DPRISM_CHILDREN; } int -t8_default_scheme_prism_c::t8_element_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_prism_c::element_get_num_face_children (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dprism_num_face_children ((const t8_dprism_t *) elem, face); } int -t8_default_scheme_prism_c::t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_prism_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const { - T8_ASSERT (t8_element_is_valid (element)); + T8_ASSERT (element_is_valid (element)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); T8_ASSERT (0 <= corner && corner < T8_DPRISM_CORNERS); @@ -136,102 +136,102 @@ t8_default_scheme_prism_c::t8_element_get_face_corner (const t8_element_t *eleme } int -t8_default_scheme_prism_c::t8_element_num_faces (const t8_element_t *elem) const +t8_default_scheme_prism_c::element_get_num_faces (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DPRISM_FACES; } int -t8_default_scheme_prism_c::t8_element_child_id (const t8_element_t *elem) const +t8_default_scheme_prism_c::element_get_child_id (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dprism_child_id ((const t8_dprism_t *) elem); } void -t8_default_scheme_prism_c::t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_prism_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dprism_child ((const t8_dprism_t *) elem, childid, (t8_dprism_t *) child); - T8_ASSERT (t8_element_is_valid (child)); + T8_ASSERT (element_is_valid (child)); } int -t8_default_scheme_prism_c::t8_element_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_prism_c::element_get_max_num_faces (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DPRISM_FACES; } void -t8_default_scheme_prism_c::t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_prism_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (length == T8_DPRISM_CHILDREN); t8_dprism_childrenpv ((const t8_dprism_t *) elem, length, (t8_dprism_t **) c); #if T8_ENABLE_DEBUG for (int i = 0; i < length; i++) { - T8_ASSERT (t8_element_is_valid (c[i])); + T8_ASSERT (element_is_valid (c[i])); } #endif } int -t8_default_scheme_prism_c::t8_element_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_prism_c::element_get_ancestor_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dprism_ancestor_id ((t8_dprism_t *) elem, level); } void -t8_default_scheme_prism_c::t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_prism_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); T8_ASSERT (num_children == t8_dprism_num_face_children ((const t8_dprism_t *) elem, face)); t8_dprism_children_at_face ((const t8_dprism_t *) elem, face, (t8_dprism_t **) children, num_children, child_indices); #if T8_ENABLE_DEBUG for (int i = 0; i < num_children; i++) { - T8_ASSERT (t8_element_is_valid (children[i])); + T8_ASSERT (element_is_valid (children[i])); } #endif } int -t8_default_scheme_prism_c::t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_prism_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); T8_ASSERT (face_child < t8_dprism_num_face_children ((const t8_dprism_t *) elem, face)); return t8_dprism_face_child_face ((const t8_dprism_t *) elem, face, face_child); } int -t8_default_scheme_prism_c::t8_element_face_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_prism_c::element_face_get_parent_face (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); return t8_dprism_face_parent_face ((const t8_dprism_t *) elem, face); } int -t8_default_scheme_prism_c::t8_element_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_prism_c::element_get_tree_face (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); return t8_dprism_tree_face ((const t8_dprism_t *) elem, face); } int -t8_default_scheme_prism_c::t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_prism_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, + t8_element_t *elem, int root_face) const { - T8_ASSERT (face_scheme->t8_element_is_valid (face)); + T8_ASSERT (face_scheme->element_is_valid (face)); T8_ASSERT (0 <= root_face && root_face < T8_DPRISM_FACES); t8_dprism_extrude_face (face, elem, root_face); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); /* For the quad-faces of prisms it holds that only the corner-children touch the faces of the parent and * their face-numbers coincide. * for the triangular-faces (bottom and top) the faces always have the same number and we can return the @@ -240,23 +240,23 @@ t8_default_scheme_prism_c::t8_element_extrude_face (const t8_element_t *face, co } int -t8_default_scheme_prism_c::t8_element_is_family (t8_element_t *const *fam) const +t8_default_scheme_prism_c::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG int i; for (i = 0; i < T8_DPRISM_CHILDREN; i++) { - T8_ASSERT (t8_element_is_valid (fam[i])); + T8_ASSERT (element_is_valid (fam[i])); } #endif return t8_dprism_is_familypv ((t8_dprism_t **) fam); } void -t8_default_scheme_prism_c::t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, - t8_element_t *nca) const +t8_default_scheme_prism_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, + t8_element_t *nca) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); const t8_default_prism_t *p1 = (const t8_default_prism_t *) elem1; const t8_default_prism_t *p2 = (const t8_default_prism_t *) elem2; t8_default_prism_t *c = (t8_default_prism_t *) nca; @@ -266,13 +266,13 @@ t8_default_scheme_prism_c::t8_element_nca (const t8_element_t *elem1, const t8_e } void -t8_default_scheme_prism_c::t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const +t8_default_scheme_prism_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *boundary_scheme) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); t8_dprism_boundary_face ((const t8_dprism_t *) elem, face, boundary); - T8_ASSERT (boundary_scheme->t8_element_is_valid (boundary)); + T8_ASSERT (boundary_scheme->element_is_valid (boundary)); } const int t8_dprism_face_corner[5][4] = { @@ -284,26 +284,26 @@ const int t8_dprism_face_corner[5][4] = { }; void -t8_default_scheme_prism_c::t8_element_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_prism_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); corner = t8_dprism_face_corner[face][0]; t8_dprism_corner_descendant ((const t8_dprism_t *) elem, (t8_dprism_t *) first_desc, corner, level); - T8_ASSERT (t8_element_is_valid (first_desc)); + T8_ASSERT (element_is_valid (first_desc)); } void -t8_default_scheme_prism_c::t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, - int level) const +t8_default_scheme_prism_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); if (face < 3) { corner = t8_dprism_face_corner[face][3]; } @@ -311,27 +311,27 @@ t8_default_scheme_prism_c::t8_element_last_descendant_face (const t8_element_t * corner = t8_dprism_face_corner[face][2]; } t8_dprism_corner_descendant ((const t8_dprism_t *) elem, (t8_dprism_t *) last_desc, corner, level); - T8_ASSERT (t8_element_is_valid (last_desc)); + T8_ASSERT (element_is_valid (last_desc)); } int -t8_default_scheme_prism_c::t8_element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_prism_c::element_is_root_boundary (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dprism_is_root_boundary ((const t8_dprism_t *) elem, face); } int -t8_default_scheme_prism_c::t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, - int *neigh_face) const +t8_default_scheme_prism_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, + int face, int *neigh_face) const { const t8_dprism_t *p = (const t8_dprism_t *) elem; t8_dprism_t *n = (t8_dprism_t *) neigh; T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); T8_ASSERT (neigh_face != NULL); - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (neigh)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (neigh)); *neigh_face = t8_dprism_face_neighbour (p, face, n); /* return true if neigh is inside the root */ @@ -339,86 +339,88 @@ t8_default_scheme_prism_c::t8_element_face_neighbor_inside (const t8_element_t * } void -t8_default_scheme_prism_c::t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_prism_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL); T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << 3 * level); t8_dprism_init_linear_id ((t8_default_prism_t *) elem, level, id); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); } void -t8_default_scheme_prism_c::t8_element_successor (const t8_element_t *elem, t8_element_t *s) const +t8_default_scheme_prism_c::element_construct_successor (const t8_element_t *elem, t8_element_t *s) const { - T8_ASSERT (1 <= t8_element_level (elem) && t8_element_level (elem) <= T8_DPRISM_MAXLEVEL); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (1 <= element_get_level (elem) && element_get_level (elem) <= T8_DPRISM_MAXLEVEL); + T8_ASSERT (element_is_valid (elem)); - t8_dprism_successor ((const t8_default_prism_t *) elem, (t8_default_prism_t *) s, t8_element_level (elem)); - T8_ASSERT (t8_element_is_valid (s)); + t8_dprism_successor ((const t8_default_prism_t *) elem, (t8_default_prism_t *) s, element_get_level (elem)); + T8_ASSERT (element_is_valid (s)); } void -t8_default_scheme_prism_c::t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_prism_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dprism_first_descendant ((const t8_default_prism_t *) elem, (t8_default_prism_t *) desc, level); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (desc)); } void -t8_default_scheme_prism_c::t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_prism_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dprism_last_descendant ((const t8_default_prism_t *) elem, (t8_default_prism_t *) desc, level); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (desc)); } void -t8_default_scheme_prism_c::t8_element_anchor (const t8_element_t *elem, int anchor[3]) const +t8_default_scheme_prism_c::element_get_anchor (const t8_element_t *elem, int anchor[3]) const { t8_dprism_t *prism = (t8_dprism_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); anchor[0] = prism->tri.x / T8_DTRI_ROOT_LEN * T8_DPRISM_ROOT_LEN; anchor[1] = prism->tri.y / T8_DTRI_ROOT_LEN * T8_DPRISM_ROOT_LEN; anchor[2] = prism->line.x / T8_DLINE_ROOT_LEN * T8_DPRISM_ROOT_LEN; } void -t8_default_scheme_prism_c::t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_prism_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dprism_vertex_integer_coords ((const t8_dprism_t *) elem, vertex, coords); } void -t8_default_scheme_prism_c::t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_prism_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dprism_vertex_ref_coords ((const t8_dprism_t *) elem, vertex, coords); } void -t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_prism_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dprism_compute_reference_coords ((const t8_dprism_t *) elem, ref_coords, num_coords, out_coords); } t8_linearidx_t -t8_default_scheme_prism_c::t8_element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_prism_c::element_get_linear_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dprism_linear_id ((const t8_dprism_t *) elem, level); } int -t8_default_scheme_prism_c::t8_element_refines_irregular (void) const +t8_default_scheme_prism_c::refines_irregular (void) const { /*prisms refine regularly */ return 0; @@ -427,17 +429,16 @@ t8_default_scheme_prism_c::t8_element_refines_irregular (void) const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_prism_c::t8_element_is_valid (const t8_element_t *elem) const +t8_default_scheme_prism_c::element_is_valid (const t8_element_t *elem) const { T8_ASSERT (elem != NULL); return t8_dprism_is_valid ((const t8_dprism_t *) elem); } void -t8_default_scheme_prism_c::t8_element_to_string (const t8_element_t *elem, char *debug_string, - const int string_size) const +t8_default_scheme_prism_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); t8_dprism_t *prism = (t8_dprism_t *) elem; snprintf (debug_string, string_size, "x: %i, y: %i, z: %i, type: %i, level: %i", prism->tri.x, prism->tri.y, @@ -463,7 +464,7 @@ t8_default_scheme_prism_c::~t8_default_scheme_prism_c () * and hence this empty function. */ } void -t8_default_scheme_prism_c::t8_element_root (t8_element_t *elem) const +t8_default_scheme_prism_c::get_root (t8_element_t *elem) const { t8_dprism_t *prism = (t8_dprism_t *) elem; prism->line.level = 0; @@ -475,9 +476,8 @@ t8_default_scheme_prism_c::t8_element_root (t8_element_t *elem) const } /* each prism is packed as x (line.x), y (tri.x), z(tri.y) coordinates, type and the level */ void -t8_default_scheme_prism_c::t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_prism_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { int mpiret; t8_default_prism_t **prisms = (t8_default_prism_t **) elements; @@ -499,7 +499,7 @@ t8_default_scheme_prism_c::t8_element_MPI_Pack (t8_element_t **const elements, c /* each prism is packed as x (line.x), y (tri.x), z(tri.y) coordinates, type and the level */ void -t8_default_scheme_prism_c::t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_prism_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -520,9 +520,9 @@ t8_default_scheme_prism_c::t8_element_MPI_Pack_size (const unsigned int count, s /* each prism is packed as x (line.x), y (tri.x), z(tri.y) coordinates, type and the level */ void -t8_default_scheme_prism_c::t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_prism_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, + sc_MPI_Comm comm) const { int mpiret; t8_default_prism_t **prisms = (t8_default_prism_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx index cbf207a796..a347c8c097 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx @@ -37,11 +37,11 @@ * It is written as a self-contained library in the t8_dprism_* files. */ -struct t8_default_scheme_prism_c: public t8_default_scheme_common_c -{ +class t8_default_scheme_prism_c: + : + public t8_eclass_scheme, + public t8_default_scheme_common_c { public: - /** The virtual table for a particular implementation of an element class. */ - /** Constructor. */ t8_default_scheme_prism_c (void); @@ -54,51 +54,51 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * On output all these pointers will point to an allocated * and initialized element. * \note Not every element that is created in t8code will be created by a call - * to this function. However, if an element is not created using \ref t8_element_new, - * then it is guaranteed that \ref t8_element_init is called on it. - * \note In debugging mode, an element that was created with \ref t8_element_new - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. - * \see t8_element_init - * \see t8_element_is_valid - */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + * to this function. However, if an element is not created using \ref element_new, + * then it is guaranteed that \ref element_init is called on it. + * \note In debugging mode, an element that was created with \ref element_new + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. + * \see element_init + * \see element_is_valid + */ + void + element_new (int length, t8_element_t **elem) const; /** Initialize an array of allocated prism elements. * \param [in] length The number of prism elements to be initialized. * \param [in,out] elems On input an array of \b length many allocated * elements. * \param [in] called_new True if the elements in \a elem were created by a call - * to \ref t8_element_new. False if no element in \a elem + * to \ref element_new. False if no element in \a elem * was created in this way. The case that only some elements - * were created by \ref t8_element_new should never occur. - * \note In debugging mode, an element that was passed to \ref t8_element_init - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. + * were created by \ref element_new should never occur. + * \note In debugging mode, an element that was passed to \ref element_init + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. * Thus, if \a called_new is true this function should usually do nothing. - * \see t8_element_new - * \see t8_element_is_valid + * \see element_new + * \see element_is_valid */ - virtual void - t8_element_init (int length, t8_element_t *elem) const; + void + element_init (int length, t8_element_t *elem) const; /** Return the refinement level of an element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - virtual int - t8_element_level (const t8_element_t *elem) const; + int + element_get_level (const t8_element_t *elem) const; /** Return the maximum allowed level for this element class. * \return The maximum allowed level for elements of this class. */ - virtual int - t8_element_maxlevel (void) const; + int + get_maxlevel (void) const; /** Copy all entries of \b source to \b dest. \b dest must be an existing * element. No memory is allocated by this function. @@ -107,8 +107,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * entries of \b source. * \note \a source and \a dest may point to the same element. */ - virtual void - t8_element_copy (const t8_element_t *source, t8_element_t *dest) const; + void + element_copy (const t8_element_t *source, t8_element_t *dest) const; /** Compare two elements. * \param [in] elem1 The first element. @@ -116,8 +116,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \return negative if elem1 < elem2, zero if elem1 equals elem2 * and positive if elem1 > elem2. If elem2 is a copy of elem1 then the elements are equal. */ - virtual int - t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -125,8 +125,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - virtual int - t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -137,8 +137,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * of \b elem's parent. The storage for this element must exist and match the element class of * the parent. For a pyramid, for example, it may be either a tetrahedron or a pyramid depending on \b elem's childid. */ - virtual void - t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const; + void + element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; /** Compute a specific sibling of a given prism element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -149,8 +149,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in,out] sibling This element's entries will be overwritten by those of \b elem's sibid-th sibling. * The storage for this element must exist and match the element class of the sibling. */ - virtual void - t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const + void + element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { SC_ABORT ("This function is not implemented yet.\n"); return; /* suppresses compiler warning */ @@ -160,39 +160,39 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in] elem The element. * \return The number of faces of \a elem. */ - virtual int - t8_element_num_faces (const t8_element_t *elem) const; + int + element_get_num_faces (const t8_element_t *elem) const; /** Compute the maximum number of faces of a given element and all of its * descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - virtual int - t8_element_max_num_faces (const t8_element_t *elem) const; + int + element_get_max_num_faces (const t8_element_t *elem) const; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - virtual int - t8_element_num_children (const t8_element_t *elem) const; + int + element_get_num_children (const t8_element_t *elem) const; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - virtual int - t8_element_num_face_children (const t8_element_t *elem, int face) const; + int + element_get_num_face_children (const t8_element_t *elem, int face) const; /** Return the corner number of an element's face corner. * \param [in] element The element. * \param [in] face A face index for \a element. * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - virtual int - t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const; + int + element_get_face_corner (const t8_element_t *element, int face, int corner) const; /** Return the face numbers of the faces sharing an element's corner. * \param [in] element The element. @@ -200,8 +200,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - virtual int - t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const + int + element_get_corner_face (const t8_element_t *element, int corner, int face) const { SC_ABORT ("This function is not implemented yet.\n"); return 0; /* suppresses compiler warning */ @@ -213,8 +213,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in,out] child The storage for this element must exist and match the element class of the child. * On output, a valid element. It is valid to call this function with elem = child. */ - virtual void - t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const; + void + element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -224,25 +224,25 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * and match the element class in the children's ordering. * On output, all children are valid. * It is valid to call this function with elem = c[0]. - * \see t8_element_num_children + * \see element_get_num_children */ - virtual void - t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; + void + element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - virtual int - t8_element_child_id (const t8_element_t *elem) const; + int + element_get_child_id (const t8_element_t *elem) const; /** Compute the ancestor id of an element, that is the child id at a given level. * \param [in] elem This must be a valid element. * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - virtual int - t8_element_ancestor_id (const t8_element_t *elem, int level) const; + int + element_get_ancestor_id (const t8_element_t *elem, int level) const; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class @@ -250,8 +250,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - virtual int - t8_element_is_family (t8_element_t *const *fam) const; + int + elements_are_family (t8_element_t *const *fam) const; /** Compute the nearest common ancestor of two elements. That is, the element with highest level that still has * both given elements as descendants. @@ -260,16 +260,16 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in,out] nca The storage for this element must exist and match the element class of the child. * On output the unique nearest common ancestor of \b elem1 and \b elem2. */ - virtual void - t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; + void + element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; /** Compute the shape of the face of an element. * \param [in] elem The element. * \param [in] face A face of \a elem. * \return The element shape of the face. */ - virtual t8_element_shape_t - t8_element_face_shape (const t8_element_t *elem, int face) const; + t8_element_shape_t + element_get_face_shape (const t8_element_t *elem, int face) const; /** Given an element and a face of the element, compute all children of the element that touch the face. * \param [in] elem The element. @@ -277,14 +277,14 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in,out] children Allocated elements, in which the children of \a elem that share a face with \a face * are stored. They will be stored in order of their linear id. * \param [in] num_children The number of elements in \a children. Must match the number of children that touch \a face. - * \ref t8_element_num_face_children + * \ref element_get_num_face_children * \param [in,out] child_indices If not NULL, an array of num_children integers must be given, on output its i-th * entry is the child_id of the i-th face_child. * It is valid to call this function with elem = children[0]. */ - virtual void - t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const; + void + element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const; /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -301,11 +301,11 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in] face Then number of the face. * \param [in] face_child A number 0 <= \a face_child < num_face_children, specifying a child of \a elem that shares * a face with \a face. These children are counted in linear order. This coincides with the - * order of children from a call to \ref t8_element_children_at_face. + * order of children from a call to \ref element_get_children_at_face. * \return The face number of the face of a child of \a elem that coincides with \a face_child. */ - virtual int - t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const; + int + element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const; /** Given a face of an element return the face number of the parent of the element that matches the element's face. * Or return -1 if no face of the parent matches the face. @@ -315,8 +315,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * the face number of this face. Otherwise -1. * \note For the root element this function always returns \a face. */ - virtual int - t8_element_face_parent_face (const t8_element_t *elem, int face) const; + int + element_face_get_parent_face (const t8_element_t *elem, int face) const; /** Given an element and a face of this element. If the face lies on the * tree boundary, return the face number of the tree face. @@ -326,8 +326,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \return The index of the tree face that \a face is a subface of, if \a face is on a tree boundary. * Any arbitrary integer if \a is not at a tree boundary. */ - virtual int - t8_element_tree_face (const t8_element_t *elem, int face) const; + int + element_get_tree_face (const t8_element_t *elem, int face) const; /** Suppose we have two trees that share a common face f. * Given an element e that is a subface of f in one of the trees @@ -350,9 +350,9 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * defined in relation to the smaller face. * \note \a elem1 and \a elem2 may point to the same element. */ - virtual void - t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, - int is_smaller_face) const + void + element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, + int is_smaller_face) const { SC_ABORT ("This function is not implemented yet.\n"); return; /* suppresses compiler warning */ @@ -371,9 +371,9 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \return The face number of the face of \a elem that coincides * with \a face. */ - virtual int - t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const; + int + element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, + int root_face) const; /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -383,8 +383,9 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the first descendant is constructed */ - virtual void - t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const; + void + element_construct_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, + int level) const; /** Construct the last descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -394,8 +395,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the last descendant is constructed */ - virtual void - t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const; + void + element_construct_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const; /** Construct the boundary element at a specific face. * \param [in] elem The input element. @@ -406,17 +407,17 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * of the face of \a element. * \param [in] boundary_scheme The scheme for the eclass of the boundary face. */ - virtual void - t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const; + void + element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme_c *boundary_scheme) const; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. * \param [in] face A face of \a elem. * \return True if \a face is a subface of the element's root element. */ - virtual int - t8_element_is_root_boundary (const t8_element_t *elem, int face) const; + int + element_is_root_boundary (const t8_element_t *elem, int face) const; /** Construct the face neighbor of a given element if this face neighbor * is inside the root tree. Return 0 otherwise. @@ -433,8 +434,9 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * False if not. In this case \a neigh's data can be arbitrary * on output. */ - virtual int - t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const; + int + element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const; /** Initialize the entries of an allocated element according to a * given linear id in a uniform refinement. @@ -442,8 +444,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in] level The level of the uniform refinement to consider. * \param [in] id The linear id. id must fulfil 0 <= id < 'number of leaves in the uniform refinement' */ - virtual void - t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; + void + element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; /** Compute the linear id of a given element in a hypothetical uniform * refinement of a given level. @@ -451,32 +453,32 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in] level The level of the uniform refinement to consider. * \return The linear id of the element. */ - virtual t8_linearidx_t - t8_element_get_linear_id (const t8_element_t *elem, int level) const; + t8_linearidx_t + element_get_linear_id (const t8_element_t *elem, int level) const; /** Compute the first descendant of a given element. * \param [in] elem The element whose descendant is computed. * \param [out] desc The first element in a uniform refinement of \a elem of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Compute the last descendant of a given element. * \param [in] elem The element whose descendant is computed. * \param [out] desc The last element in a uniform refinement of \a elem of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Construct the successor in a uniform refinement of a given element. * \param [in] elem1 The element whose successor should be constructed. * \param [in,out] elem2 The element whose entries will be set. * \param [in] level The level of the uniform refinement to consider. */ - virtual void - t8_element_successor (const t8_element_t *elem, t8_element_t *succ) const; + void + element_construct_successor (const t8_element_t *elem, t8_element_t *succ) const; /** Get the integer coordinates of the anchor node of an element. The default scheme implements the Morton type SFCs. * In these SFCs the elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and L the maximum @@ -485,8 +487,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in] elem The element. * \param [out] anchor The integer coordinates of the anchor node in the cube [0,1]^(dL) */ - virtual void - t8_element_anchor (const t8_element_t *elem, int anchor[3]) const; + void + element_get_anchor (const t8_element_t *elem, int anchor[3]) const; /** Compute the integer coordinates of a given element vertex. The default scheme implements the Morton type SFCs. * In these SFCs the elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and L the maximum @@ -496,8 +498,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [out] coords An array of at least as many integers as the element's dimension whose entries will be * filled with the coordinates of \a vertex. */ - virtual void - t8_element_vertex_integer_coords (const t8_element_t *t, int vertex, int coords[]) const; + void + element_get_vertex_integer_coords (const t8_element_t *t, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). @@ -508,8 +510,8 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \warning coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere * all coords might be used. */ - virtual void - t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; + void + element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; /** Convert points in the reference space of an element to points in the * reference space of the tree. @@ -521,34 +523,34 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [out] out_coords The coordinates of the points in the * reference space of the tree. */ - virtual void - t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + void + element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, + double *out_coords) const; /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * \return 0, because prisms refine regularly */ - virtual int - t8_element_refines_irregular (void) const; + int + refines_irregular (void) const; #ifdef T8_ENABLE_DEBUG /** Query whether a given element can be considered as 'valid' and it is * safe to perform any of the above algorithms on it. * \param [in] elem The element to be checked. * \return True if \a elem is safe to use. False otherwise. - * \note An element that is constructed with \ref t8_element_new + * \note An element that is constructed with \ref element_new * must pass this test. - * \note An element for which \ref t8_element_init was called must pass + * \note An element for which \ref element_init was called must pass * this test. * \note This function is used for debugging to catch certain errors. * These can for example occur when an element points to a region * of memory which should not be interpreted as an element. - * \note We recommend to use the assertion T8_ASSERT (t8_element_is_valid (elem)) + * \note We recommend to use the assertion T8_ASSERT (element_is_valid (elem)) * in the implementation of each of the functions in this file. */ - virtual int - t8_element_is_valid (const t8_element_t *t) const; + int + element_is_valid (const t8_element_t *t) const; /** * Print a given element. For a example for a triangle print the coordinates @@ -557,15 +559,15 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * * \param [in] elem The element to print */ - virtual void - t8_element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; + void + element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; #endif /** Fills an element with the root element. * \param [in,out] elem The element to be filled with root. */ void - t8_element_root (t8_element_t *elem) const; + get_root (t8_element_t *elem) const; /** Pack multiple elements into contiguous memory, so they can be sent via MPI. * \param [in] elements Array of elements that are to be packed @@ -575,17 +577,17 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in, out] position the position of the first byte that is not already packed * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, - int *position, sc_MPI_Comm comm) const; + void + element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, + int *position, sc_MPI_Comm comm) const; /** Determine an upper bound for the size of the packed message of \b count elements * \param [in] count Number of elements to pack * \param [in] comm MPI Communicator * \param [out] pack_size upper bound on the message size */ - virtual void - t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; + void + element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; /** Unpack multiple elements from contiguous memory that was received via MPI. * \param [in] recvbuf Buffer from which to unpack the elements @@ -595,7 +597,7 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c * \param [in] count Number of elements to unpack * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, - const unsigned int count, sc_MPI_Comm comm) const; + void + element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const unsigned int count, sc_MPI_Comm comm) const; }; diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx index 7a7ee358bf..4173666a41 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx @@ -32,24 +32,24 @@ typedef t8_dpyramid_t t8_default_pyramid_t; T8_EXTERN_C_BEGIN (); void -t8_default_scheme_pyramid_c::t8_element_new (int length, t8_element_t **elem) const +t8_default_scheme_pyramid_c::element_new (int length, t8_element_t **elem) const { /* allocate memory for a tet */ - t8_default_scheme_common_c::t8_element_new (length, elem); + t8_default_scheme_common_c::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG { int i; for (i = 0; i < length; i++) { - t8_element_root (elem[i]); + get_root (elem[i]); } } #endif } void -t8_default_scheme_pyramid_c::t8_element_init (int length, t8_element_t *elem) const +t8_default_scheme_pyramid_c::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dpyramid_t *pyramid = (t8_dpyramid_t *) elem; @@ -63,331 +63,334 @@ t8_default_scheme_pyramid_c::t8_element_init (int length, t8_element_t *elem) co } int -t8_default_scheme_pyramid_c::t8_element_maxlevel (void) const +t8_default_scheme_pyramid_c::get_maxlevel (void) const { return T8_DPYRAMID_MAXLEVEL; } int -t8_default_scheme_pyramid_c::t8_element_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_pyramid_c::element_get_max_num_faces (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_max_num_faces ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::t8_element_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_pyramid_c::element_get_ancestor_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DPYRAMID_MAXLEVEL); return t8_dpyramid_ancestor_id ((const t8_dpyramid_t *) elem, level); } int -t8_default_scheme_pyramid_c::t8_element_num_children (const t8_element_t *elem) const +t8_default_scheme_pyramid_c::element_get_num_children (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_num_children ((const t8_dpyramid_t *) elem); } int t8_default_scheme_pyramid_c::t8_element_num_corners (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_num_corners ((const t8_dpyramid_t *) elem); } int t8_default_scheme_pyramid_c::t8_element_num_siblings (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_num_siblings ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::t8_element_num_faces (const t8_element_t *elem) const +t8_default_scheme_pyramid_c::element_get_num_faces (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_num_faces ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_pyramid_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); return t8_dpyramid_compare ((const t8_dpyramid_t *) elem1, (const t8_dpyramid_t *) elem2); } int -t8_default_scheme_pyramid_c::t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_pyramid_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dpyramid_equal ((const t8_dpyramid_t *) elem1, (const t8_dpyramid_t *) elem2); } void -t8_default_scheme_pyramid_c::t8_element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_pyramid_c::element_copy (const t8_element_t *source, t8_element_t *dest) const { - T8_ASSERT (t8_element_is_valid (source)); + T8_ASSERT (element_is_valid (source)); t8_dpyramid_copy ((const t8_dpyramid_t *) source, (t8_dpyramid_t *) dest); - T8_ASSERT (t8_element_is_valid (dest)); + T8_ASSERT (element_is_valid (dest)); } void -t8_default_scheme_pyramid_c::t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_pyramid_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= childid && childid < t8_dpyramid_num_children ((const t8_dpyramid_t *) elem)); t8_dpyramid_child ((t8_dpyramid_t *) elem, childid, (t8_dpyramid_t *) child); - T8_ASSERT (t8_element_is_valid (child)); + T8_ASSERT (element_is_valid (child)); } void -t8_default_scheme_pyramid_c::t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_pyramid_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_children ((const t8_dpyramid_t *) elem, (t8_dpyramid_t **) c); #if T8_ENABLE_DEBUG for (int i = 0; i < length; i++) { - T8_ASSERT (t8_element_is_valid (c[i])); + T8_ASSERT (element_is_valid (c[i])); } #endif } void -t8_default_scheme_pyramid_c::t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_pyramid_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_children_at_face ((const t8_dpyramid_t *) elem, face, (t8_dpyramid_t **) children, num_children, child_indices); #if T8_ENABLE_DEBUG for (int i = 0; i < num_children; i++) { - T8_ASSERT (t8_element_is_valid (children[i])); + T8_ASSERT (element_is_valid (children[i])); } #endif } int -t8_default_scheme_pyramid_c::t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_pyramid_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_face_child_face ((const t8_dpyramid_t *) elem, face, face_child); } t8_element_shape_t -t8_default_scheme_pyramid_c::t8_element_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid_c::element_get_face_shape (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_face_shape ((const t8_dpyramid_t *) elem, face); } int -t8_default_scheme_pyramid_c::t8_element_child_id (const t8_element_t *p) const +t8_default_scheme_pyramid_c::element_get_child_id (const t8_element_t *p) const { - T8_ASSERT (t8_element_is_valid (p)); + T8_ASSERT (element_is_valid (p)); return t8_dpyramid_child_id ((const t8_dpyramid_t *) p); } int -t8_default_scheme_pyramid_c::t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, - int *neigh_face) const +t8_default_scheme_pyramid_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, + int face, int *neigh_face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_face_neighbor_inside ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) neigh, face, neigh_face); } int -t8_default_scheme_pyramid_c::t8_element_face_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid_c::element_face_get_parent_face (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_face_parent_face ((const t8_dpyramid_t *) elem, face); } void -t8_default_scheme_pyramid_c::t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_pyramid_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_first_descendant ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) desc, level); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (desc)); } void -t8_default_scheme_pyramid_c::t8_element_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_pyramid_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_first_descendant_face ((const t8_dpyramid_t *) elem, face, (t8_dpyramid_t *) first_desc, level); - T8_ASSERT (t8_element_is_valid (first_desc)); + T8_ASSERT (element_is_valid (first_desc)); } int -t8_default_scheme_pyramid_c::t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_pyramid_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const { - T8_ASSERT (t8_element_is_valid (element)); + T8_ASSERT (element_is_valid (element)); return t8_dpyramid_get_face_corner ((const t8_dpyramid_t *) element, face, corner); } int -t8_default_scheme_pyramid_c::t8_element_level (const t8_element_t *elem) const +t8_default_scheme_pyramid_c::element_get_level (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_get_level ((const t8_dpyramid_t *) elem); } void -t8_default_scheme_pyramid_c::t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_pyramid_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { t8_dpyramid_init_linear_id ((t8_dpyramid_t *) elem, level, id); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); } int -t8_default_scheme_pyramid_c::t8_element_is_family (t8_element_t *const *fam) const +t8_default_scheme_pyramid_c::elements_are_family (t8_element_t *const *fam) const { #if T8_ENABLE_DEBUG int num_siblings = t8_element_num_siblings (fam[0]); for (int i = 0; i < num_siblings; i++) { - T8_ASSERT (t8_element_is_valid (fam[i])); + T8_ASSERT (element_is_valid (fam[i])); } #endif return t8_dpyramid_is_family ((t8_dpyramid_t **) fam); } int -t8_default_scheme_pyramid_c::t8_element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid_c::element_is_root_boundary (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_is_root_boundary ((const t8_dpyramid_t *) elem, face); } void -t8_default_scheme_pyramid_c::t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const +t8_default_scheme_pyramid_c::element_construct_boundary_face (const t8_element_t *elem, int face, + t8_element_t *boundary, + const t8_scheme *boundary_scheme) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_boundary_face ((const t8_dpyramid_t *) elem, face, boundary); - T8_ASSERT (boundary_scheme->t8_element_is_valid (boundary)); + T8_ASSERT (boundary_scheme->element_is_valid (boundary)); } int -t8_default_scheme_pyramid_c::t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_pyramid_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, + t8_element_t *elem, int root_face) const { - T8_ASSERT (face_scheme->t8_element_is_valid (face)); + T8_ASSERT (face_scheme->element_is_valid (face)); return t8_dpyramid_extrude_face (face, (t8_dpyramid_t *) elem, root_face); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); } t8_element_shape_t t8_default_scheme_pyramid_c::t8_element_shape (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_shape ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::t8_element_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid_c::element_get_tree_face (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_tree_face ((const t8_dpyramid_t *) elem, face); } int -t8_default_scheme_pyramid_c::t8_element_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid_c::element_get_num_face_children (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DPYRAMID_FACE_CHILDREN; } t8_linearidx_t -t8_default_scheme_pyramid_c::t8_element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_pyramid_c::element_get_linear_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_linear_id ((const t8_dpyramid_t *) elem, level); } void -t8_default_scheme_pyramid_c::t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_pyramid_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_last_descendant ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) desc, level); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (desc)); } void -t8_default_scheme_pyramid_c::t8_element_last_descendant_face (const t8_element_t *elem, int face, - t8_element_t *last_desc, int level) const +t8_default_scheme_pyramid_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_last_descendant_face ((const t8_dpyramid_t *) elem, face, (t8_dpyramid_t *) last_desc, level); - T8_ASSERT (t8_element_is_valid (last_desc)); + T8_ASSERT (element_is_valid (last_desc)); } void -t8_default_scheme_pyramid_c::t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_pyramid_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_parent ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) parent); - T8_ASSERT (t8_element_is_valid (parent)); + T8_ASSERT (element_is_valid (parent)); } void -t8_default_scheme_pyramid_c::t8_element_successor (const t8_element_t *elem, t8_element_t *s) const +t8_default_scheme_pyramid_c::element_construct_successor (const t8_element_t *elem, t8_element_t *s) const { - T8_ASSERT (t8_element_is_valid (elem)); - t8_dpyramid_successor ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) s, t8_element_level (elem)); - T8_ASSERT (t8_element_is_valid (s)); + T8_ASSERT (element_is_valid (elem)); + t8_dpyramid_successor ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) s, element_get_level (elem)); + T8_ASSERT (element_is_valid (s)); } void -t8_default_scheme_pyramid_c::t8_element_anchor (const t8_element_t *elem, int anchor[3]) const +t8_default_scheme_pyramid_c::element_get_anchor (const t8_element_t *elem, int anchor[3]) const { t8_dpyramid_t *pyra = (t8_dpyramid_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); anchor[0] = pyra->pyramid.x; anchor[1] = pyra->pyramid.y; anchor[2] = pyra->pyramid.z; } void -t8_default_scheme_pyramid_c::t8_element_vertex_integer_coords (const t8_element_t *t, int vertex, int coords[]) const +t8_default_scheme_pyramid_c::element_get_vertex_integer_coords (const t8_element_t *t, int vertex, int coords[]) const { - T8_ASSERT (t8_element_is_valid (t)); + T8_ASSERT (element_is_valid (t)); t8_dpyramid_compute_integer_coords ((const t8_dpyramid_t *) t, vertex, coords); } void -t8_default_scheme_pyramid_c::t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, - t8_element_t *nca) const +t8_default_scheme_pyramid_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, + t8_element_t *nca) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); t8_dpyramid_nearest_common_ancestor ((const t8_dpyramid_t *) elem1, (const t8_dpyramid_t *) elem2, (t8_dpyramid_t *) nca); - T8_ASSERT (t8_element_is_valid (nca)); + T8_ASSERT (element_is_valid (nca)); } void -t8_default_scheme_pyramid_c::t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_pyramid_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_vertex_reference_coords ((const t8_dpyramid_t *) elem, vertex, coords); } void -t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_pyramid_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dpyramid_compute_reference_coords ((const t8_dpyramid_t *) elem, ref_coords, num_coords, out_coords); } int -t8_default_scheme_pyramid_c::t8_element_refines_irregular () const +t8_default_scheme_pyramid_c::refines_irregular () const { /*Pyramids do not refine regularly */ return 1; @@ -395,17 +398,17 @@ t8_default_scheme_pyramid_c::t8_element_refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_pyramid_c::t8_element_is_valid (const t8_element_t *elem) const +t8_default_scheme_pyramid_c::element_is_valid (const t8_element_t *elem) const { T8_ASSERT (elem != NULL); return t8_dpyramid_is_valid ((const t8_dpyramid_t *) elem); } void -t8_default_scheme_pyramid_c::t8_element_to_string (const t8_element_t *elem, char *debug_string, - const int string_size) const +t8_default_scheme_pyramid_c::element_to_string (const t8_element_t *elem, char *debug_string, + const int string_size) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); t8_dpyramid_t *pyra = (t8_dpyramid_t *) elem; snprintf (debug_string, string_size, "x: %i, y: %i, z: %i, type: %i, level: %i, switch_shape_at_level: %i", @@ -431,7 +434,7 @@ t8_default_scheme_pyramid_c::~t8_default_scheme_pyramid_c () * and hence this empty function. */ } void -t8_default_scheme_pyramid_c::t8_element_root (t8_element_t *elem) const +t8_default_scheme_pyramid_c::get_root (t8_element_t *elem) const { t8_dpyramid_t *pyramid = (t8_dpyramid_t *) elem; pyramid->pyramid.level = 0; @@ -443,9 +446,9 @@ t8_default_scheme_pyramid_c::t8_element_root (t8_element_t *elem) const } /* each pyramid is packed as a tet and the switch_shape_at_level marker */ void -t8_default_scheme_pyramid_c::t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_pyramid_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, + void *send_buffer, const int buffer_size, int *position, + sc_MPI_Comm comm) const { t8_default_pyramid_t **pyramids = (t8_default_pyramid_t **) elements; for (unsigned int ielem = 0; ielem < count; ielem++) { @@ -459,7 +462,7 @@ t8_default_scheme_pyramid_c::t8_element_MPI_Pack (t8_element_t **const elements, /* each pyramid is packed as a tet and the switch_shape_at_level marker */ void -t8_default_scheme_pyramid_c::t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_pyramid_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -476,9 +479,9 @@ t8_default_scheme_pyramid_c::t8_element_MPI_Pack_size (const unsigned int count, /* each pyramid is packed as a tet and the switch_shape_at_level marker */ void -t8_default_scheme_pyramid_c::t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_pyramid_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, + sc_MPI_Comm comm) const { int mpiret; t8_default_pyramid_t **pyramids = (t8_default_pyramid_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx index 287056c9c8..4a4e6578a3 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx @@ -35,11 +35,10 @@ * t8_dpyramid_* files. */ -struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c -{ +class t8_default_scheme_pyramid_c: + public t8_eclass_scheme, + public t8_default_scheme_common_c { public: - /** The virtual table for a particular implementation of an element class. */ - /** Constructor. */ t8_default_scheme_pyramid_c (void); @@ -51,57 +50,57 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * On output all these pointers will point to an allocated * and initialized element. * \note Not every element that is created in t8code will be created by a call - * to this function. However, if an element is not created using \ref t8_element_new, - * then it is guaranteed that \ref t8_element_init is called on it. - * \note In debugging mode, an element that was created with \ref t8_element_new - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. - * \see t8_element_init - * \see t8_element_is_valid - */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + * to this function. However, if an element is not created using \ref element_new, + * then it is guaranteed that \ref element_init is called on it. + * \note In debugging mode, an element that was created with \ref element_new + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. + * \see element_init + * \see element_is_valid + */ + void + element_new (int length, t8_element_t **elem) const; /** Initialize an array of allocated elements. * \param [in] length The number of pyramid elements to be allocated. * \param [in,out] elems On input an array of \b length many allocated elements. - * \param [in] called_new True if the elements in \a elem were created by a call to \ref t8_element_new. + * \param [in] called_new True if the elements in \a elem were created by a call to \ref element_new. * False if no element in \a elem was created in this way. The case that only some elements - * were created by \ref t8_element_new should never occur. - * \note In debugging mode, an element that was passed to \ref t8_element_init - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. + * were created by \ref element_new should never occur. + * \note In debugging mode, an element that was passed to \ref element_init + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. * Thus, if \a called_new is true this function should usually do nothing. - * \see t8_element_new - * \see t8_element_is_valid + * \see element_new + * \see element_is_valid */ - virtual void - t8_element_init (int length, t8_element_t *elem) const; + void + element_init (int length, t8_element_t *elem) const; /** Return the refinement level of an element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - virtual int - t8_element_level (const t8_element_t *elem) const; + int + element_get_level (const t8_element_t *elem) const; /** Return the maximum allowed level for this element class. * \return The maximum allowed level for elements of this class. */ - virtual int - t8_element_maxlevel (void) const; + int + get_maxlevel (void) const; /** Copy all entries of \b source to \b dest. \b dest must be an existing element. No memory is allocated by this function. * \param [in] source The element whose entries will be copied to \b dest. * \param [in,out] dest This element's entries will be overwritten with the entries of \b source. * \note \a source and \a dest may point to the same element. */ - virtual void - t8_element_copy (const t8_element_t *source, t8_element_t *dest) const; + void + element_copy (const t8_element_t *source, t8_element_t *dest) const; /** Compare two elements. * \param [in] elem1 The first element. @@ -109,8 +108,8 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \return negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - virtual int - t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -118,8 +117,8 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - virtual int - t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -130,15 +129,15 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * this element must exist and match the element class of the parent. For a pyramid, for * example, it may be either a tetrahedron or a pyramid depending on \b elem's childid. */ - virtual void - t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const; + void + element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; /** Compute the number of siblings of an element. That is the number of Children of its parent. * \param [in] elem The element. * \return The number of siblings of \a element. * Note that this number is >= 1, since we count the element itself as a sibling. */ - virtual int + int t8_element_num_siblings (const t8_element_t *elem) const; /** Compute a specific sibling of a given pyramid element \b elem and store it in \b sibling. @@ -150,8 +149,8 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \param [in,out] sibling This element's entries will be overwritten by those of \b elem's sibid-th sibling. * The storage for this element must exist and match the element class of the sibling. */ - virtual void - t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const + void + element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { SC_ABORT ("This function is not implemented yet.\n"); return; /* suppresses compiler warning */ @@ -161,44 +160,44 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \param [in] elem The element. * \return The number of faces of \a elem. */ - virtual int - t8_element_num_faces (const t8_element_t *elem) const; + int + element_get_num_faces (const t8_element_t *elem) const; /** Compute the maximum number of faces of a given element and all of its descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - virtual int - t8_element_max_num_faces (const t8_element_t *elem) const; + int + element_get_max_num_faces (const t8_element_t *elem) const; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - virtual int - t8_element_num_children (const t8_element_t *elem) const; + int + element_get_num_children (const t8_element_t *elem) const; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - virtual int - t8_element_num_face_children (const t8_element_t *elem, int face) const; + int + element_get_num_face_children (const t8_element_t *elem, int face) const; /** Return the corner number of an element's face corner. * \param [in] element The element. * \param [in] face A face index for \a element. * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - virtual int - t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const; + int + element_get_face_corner (const t8_element_t *element, int face, int corner) const; /** Compute the number of corners of a given element. * \param [in] elem The element. * \return The number of corners of \a elem. */ - virtual int + int t8_element_num_corners (const t8_element_t *elem) const; /** Return the face numbers of the faces sharing an element's corner. @@ -207,8 +206,8 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - virtual int - t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const + int + element_get_corner_face (const t8_element_t *element, int corner, int face) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -221,8 +220,8 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * On output, a valid element. * It is valid to call this function with elem = child. */ - virtual void - t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const; + void + element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -230,33 +229,33 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \param [in,out] c The storage for these \a length elements must exist and match the element class in the * children's ordering. On output, all children are valid. * It is valid to call this function with elem = c[0]. - * \see t8_element_num_children + * \see element_get_num_children */ - virtual void - t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; + void + element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - virtual int - t8_element_child_id (const t8_element_t *elem) const; + int + element_get_child_id (const t8_element_t *elem) const; /** Compute the ancestor id of an element, that is the child id at a given level. * \param [in] elem This must be a valid element. * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - virtual int - t8_element_ancestor_id (const t8_element_t *elem, int level) const; + int + element_get_ancestor_id (const t8_element_t *elem, int level) const; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class \b ts has siblings. * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - virtual int - t8_element_is_family (t8_element_t *const *fam) const; + int + elements_are_family (t8_element_t *const *fam) const; /** Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both * given elements as descendants. @@ -265,15 +264,15 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \param [in,out] nca The storage for this element must exist and match the element class of the child. * On output the unique nearest common ancestor of \b elem1 and \b elem2. */ - virtual void - t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; + void + element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; /** Return the shape of an allocated element according its type. For example, a child of an element can be an * element of a different shape and has to be handled differently - according to its shape. * \param [in] elem The element to be considered * \return The shape of the element as an eclass */ - virtual t8_element_shape_t + t8_element_shape_t t8_element_shape (const t8_element_t *elem) const; /** Compute the shape of the face of an element. @@ -281,8 +280,8 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \param [in] face A face of \a elem. * \return The element shape of the face. */ - virtual t8_element_shape_t - t8_element_face_shape (const t8_element_t *elem, int face) const; + t8_element_shape_t + element_get_face_shape (const t8_element_t *elem, int face) const; /** Given an element and a face of the element, compute all children of the element that touch the face. * \param [in] elem The element. @@ -290,14 +289,14 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \param [in,out] children Allocated elements, in which the children of \a elem that share a face with \a face are * stored. They will be stored in order of their linear id. * \param [in] num_children The number of elements in \a children. Must match the number of children that touch \a - * face. \ref t8_element_num_face_children + * face. \ref element_get_num_face_children * \param [in,out] child_indices If not NULL, an array of num_children integers must be given, on output its i-th * entry is the child_id of the i-th face_child. * It is valid to call this function with elem = children[0]. */ - virtual void - t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const; + void + element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const; /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -314,11 +313,11 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \param [in] face Then number of the face. * \param [in] face_child A number 0 <= \a face_child < num_face_children, specifying a child of \a elem that * shares a face with \a face. These children are counted in linear order. This coincides - * with the order of children from a call to \ref t8_element_children_at_face. + * with the order of children from a call to \ref element_get_children_at_face. * \return The face number of the face of a child of \a elem that coincides with \a face_child. */ - virtual int - t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const; + int + element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const; /** Given a face of an element return the face number of the parent of the element that matches the element's face. * Or return -1 if no face of the parent matches the face @@ -328,8 +327,8 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * the face number of this face. Otherwise -1. * \note For the root element this function always returns \a face. */ - virtual int - t8_element_face_parent_face (const t8_element_t *elem, int face) const; + int + element_face_get_parent_face (const t8_element_t *elem, int face) const; /** Given an element and a face of this element. If the face lies on the * tree boundary, return the face number of the tree face. @@ -339,8 +338,8 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * \return The index of the tree face that \a face is a subface of, if \a face is on a tree boundary. * Any arbitrary integer if \a is not at a tree boundary. */ - virtual int - t8_element_tree_face (const t8_element_t *elem, int face) const; + int + element_get_tree_face (const t8_element_t *elem, int face) const; /** Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the * trees and given the orientation of the tree connection, construct the face element of the respective tree neighbor @@ -356,9 +355,9 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c * and flevel; } static void -t8_element_copy_surround (const p4est_quadrant_t *q, p4est_quadrant_t *r) +element_copy_surround (const p4est_quadrant_t *q, p4est_quadrant_t *r) { T8_QUAD_SET_TDIM (r, T8_QUAD_GET_TDIM (q)); if (T8_QUAD_GET_TDIM (q) == 3) { @@ -61,89 +61,89 @@ t8_element_copy_surround (const p4est_quadrant_t *q, p4est_quadrant_t *r) } void -t8_default_scheme_quad_c::t8_element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_quad_c::element_copy (const t8_element_t *source, t8_element_t *dest) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) source; p4est_quadrant_t *r = (p4est_quadrant_t *) dest; - T8_ASSERT (t8_element_is_valid (source)); - T8_ASSERT (t8_element_is_valid (dest)); + T8_ASSERT (element_is_valid (source)); + T8_ASSERT (element_is_valid (dest)); if (r == q) { /* Do nothing if they are already the same quadrant. */ return; } *r = *q; - t8_element_copy_surround (q, r); + element_copy_surround (q, r); } int -t8_default_scheme_quad_c::t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_quad_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); return p4est_quadrant_compare ((const p4est_quadrant_t *) elem1, (const p4est_quadrant_t *) elem2); } int -t8_default_scheme_quad_c::t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_quad_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return p4est_quadrant_is_equal ((const p4est_quadrant_t *) elem1, (const p4est_quadrant_t *) elem2); } void -t8_default_scheme_quad_c::t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_quad_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *r = (p4est_quadrant_t *) parent; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (parent)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (parent)); p4est_quadrant_parent (q, r); - t8_element_copy_surround (q, r); + element_copy_surround (q, r); } void -t8_default_scheme_quad_c::t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const +t8_default_scheme_quad_c::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *r = (p4est_quadrant_t *) sibling; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (sibling)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (sibling)); p4est_quadrant_sibling (q, r, sibid); - t8_element_copy_surround (q, r); + element_copy_surround (q, r); } int -t8_default_scheme_quad_c::t8_element_num_faces (const t8_element_t *elem) const +t8_default_scheme_quad_c::element_get_num_faces (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return P4EST_FACES; } int -t8_default_scheme_quad_c::t8_element_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_quad_c::element_get_max_num_faces (const t8_element_t *elem) const { return P4EST_FACES; } int -t8_default_scheme_quad_c::t8_element_num_children (const t8_element_t *elem) const +t8_default_scheme_quad_c::element_get_num_children (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return P4EST_CHILDREN; } int -t8_default_scheme_quad_c::t8_element_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_quad_c::element_get_num_face_children (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return 2; } int -t8_default_scheme_quad_c::t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_quad_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const { /* * 2 f_2 3 @@ -161,23 +161,23 @@ t8_default_scheme_quad_c::t8_element_get_face_corner (const t8_element_t *elemen } int -t8_default_scheme_quad_c::t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const +t8_default_scheme_quad_c::element_get_corner_face (const t8_element_t *element, int corner, int face) const { - T8_ASSERT (t8_element_is_valid (element)); + T8_ASSERT (element_is_valid (element)); T8_ASSERT (0 <= corner && corner < P4EST_CHILDREN); T8_ASSERT (0 <= face && face < 2); return p4est_corner_faces[corner][face]; } void -t8_default_scheme_quad_c::t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_quad_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; const p4est_qcoord_t shift = P4EST_QUADRANT_LEN (q->level + 1); p4est_quadrant_t *r = (p4est_quadrant_t *) child; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (child)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (child)); T8_ASSERT (p4est_quadrant_is_extended (q)); T8_ASSERT (q->level < P4EST_QMAXLEVEL); T8_ASSERT (childid >= 0 && childid < P4EST_CHILDREN); @@ -189,21 +189,21 @@ t8_default_scheme_quad_c::t8_element_child (const t8_element_t *elem, int childi if (q != r) { T8_ASSERT (p4est_quadrant_is_parent (q, r)); } - t8_element_copy_surround (q, r); + element_copy_surround (q, r); } void -t8_default_scheme_quad_c::t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_quad_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; int i; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); #ifdef T8_ENABLE_DEBUG { int j; for (j = 0; j < P4EST_CHILDREN; j++) { - T8_ASSERT (t8_element_is_valid (c[j])); + T8_ASSERT (element_is_valid (c[j])); } } #endif @@ -211,39 +211,39 @@ t8_default_scheme_quad_c::t8_element_children (const t8_element_t *elem, int len p4est_quadrant_childrenpv (q, (p4est_quadrant_t **) c); for (i = 0; i < P4EST_CHILDREN; ++i) { - t8_element_copy_surround (q, (p4est_quadrant_t *) c[i]); + element_copy_surround (q, (p4est_quadrant_t *) c[i]); } } int -t8_default_scheme_quad_c::t8_element_child_id (const t8_element_t *elem) const +t8_default_scheme_quad_c::element_get_child_id (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return p4est_quadrant_child_id ((const p4est_quadrant_t *) elem); } int -t8_default_scheme_quad_c::t8_element_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_quad_c::element_get_ancestor_id (const t8_element_t *elem, int level) const { return p4est_quadrant_ancestor_id ((p4est_quadrant_t *) elem, level); } int -t8_default_scheme_quad_c::t8_element_is_family (t8_element_t *const *fam) const +t8_default_scheme_quad_c::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG int i; for (i = 0; i < P4EST_CHILDREN; i++) { - T8_ASSERT (t8_element_is_valid (fam[i])); + T8_ASSERT (element_is_valid (fam[i])); } #endif return p4est_quadrant_is_familypv ((p4est_quadrant_t **) fam); } void -t8_default_scheme_quad_c::t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_quad_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= P4EST_QMAXLEVEL); T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << P4EST_DIM * level); @@ -252,68 +252,71 @@ t8_default_scheme_quad_c::t8_element_set_linear_id (t8_element_t *elem, int leve } t8_linearidx_t -t8_default_scheme_quad_c::t8_element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_quad_c::element_get_linear_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= P4EST_QMAXLEVEL); return p4est_quadrant_linear_id ((p4est_quadrant_t *) elem, level); } void -t8_default_scheme_quad_c::t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_quad_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= P4EST_QMAXLEVEL); p4est_quadrant_first_descendant ((p4est_quadrant_t *) elem, (p4est_quadrant_t *) desc, level); T8_QUAD_SET_TDIM ((p4est_quadrant_t *) desc, 2); } void -t8_default_scheme_quad_c::t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_quad_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= P4EST_QMAXLEVEL); p4est_quadrant_last_descendant ((p4est_quadrant_t *) elem, (p4est_quadrant_t *) desc, level); T8_QUAD_SET_TDIM ((p4est_quadrant_t *) desc, 2); } void -t8_default_scheme_quad_c::t8_element_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_quad_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); - T8_ASSERT (0 <= t8_element_level (elem1) && t8_element_level (elem1) <= P4EST_QMAXLEVEL); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); + T8_ASSERT (0 <= element_get_level (elem1) && element_get_level (elem1) <= P4EST_QMAXLEVEL); p4est_quadrant_successor ((p4est_quadrant_t *) elem1, (p4est_quadrant_t *) elem2); - t8_element_copy_surround ((const p4est_quadrant_t *) elem1, (p4est_quadrant_t *) elem2); + element_copy_surround ((const p4est_quadrant_t *) elem1, (p4est_quadrant_t *) elem2); } void -t8_default_scheme_quad_c::t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const +t8_default_scheme_quad_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, + t8_element_t *nca) const { const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem1; const p4est_quadrant_t *q2 = (const p4est_quadrant_t *) elem2; p4est_quadrant_t *r = (p4est_quadrant_t *) nca; - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); p4est_nearest_common_ancestor (q1, q2, r); - t8_element_copy_surround (q1, r); + element_copy_surround (q1, r); } t8_element_shape_t -t8_default_scheme_quad_c::t8_element_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_quad_c::element_get_face_shape (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_ECLASS_LINE; } void -t8_default_scheme_quad_c::t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_quad_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { int first_child, second_child; @@ -321,13 +324,13 @@ t8_default_scheme_quad_c::t8_element_children_at_face (const t8_element_t *elem, { int i; for (i = 0; i < num_children; i++) { - T8_ASSERT (t8_element_is_valid (children[i])); + T8_ASSERT (element_is_valid (children[i])); } } #endif - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < P4EST_FACES); - T8_ASSERT (num_children == t8_element_num_face_children (elem, face)); + T8_ASSERT (num_children == element_get_num_face_children (elem, face)); /* * Compute the child id of the first and second child at the face. @@ -370,8 +373,8 @@ t8_default_scheme_quad_c::t8_element_children_at_face (const t8_element_t *elem, /* We have to revert the order and compute second child first, since * the usage allows for elem == children[0]. */ - this->t8_element_child (elem, second_child, children[1]); - this->t8_element_child (elem, first_child, children[0]); + this->element_get_child (elem, second_child, children[1]); + this->element_get_child (elem, first_child, children[0]); if (child_indices != NULL) { child_indices[0] = first_child; child_indices[1] = second_child; @@ -379,20 +382,20 @@ t8_default_scheme_quad_c::t8_element_children_at_face (const t8_element_t *elem, } int -t8_default_scheme_quad_c::t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_quad_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); /* For quadrants the face enumeration of children is the same as for the parent. */ return face; } int -t8_default_scheme_quad_c::t8_element_face_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_quad_c::element_face_get_parent_face (const t8_element_t *elem, int face) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; int child_id; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); if (q->level == 0) { return face; } @@ -406,8 +409,8 @@ t8_default_scheme_quad_c::t8_element_face_parent_face (const t8_element_t *elem, } void -t8_default_scheme_quad_c::t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, - int sign, int is_smaller_face) const +t8_default_scheme_quad_c::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, + int sign, int is_smaller_face) const { const p4est_quadrant_t *qin = (const p4est_quadrant_t *) elem1; const p4est_quadrant_t *q; @@ -415,8 +418,8 @@ t8_default_scheme_quad_c::t8_element_transform_face (const t8_element_t *elem1, p4est_qcoord_t h = P4EST_QUADRANT_LEN (qin->level); p4est_qcoord_t x = qin->x; /* temp storage for x coordinate in case elem1 = elem 2 */ - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); T8_ASSERT (0 <= orientation && orientation < P4EST_FACES); if (sign) { @@ -425,7 +428,7 @@ t8_default_scheme_quad_c::t8_element_transform_face (const t8_element_t *elem1, /* We use p as storage, since elem1 and elem2 are allowed to * point to the same quad */ q = (const p4est_quadrant_t *) p; - t8_element_copy_surround (qin, (p4est_quadrant_t *) q); + element_copy_surround (qin, (p4est_quadrant_t *) q); ((p4est_quadrant_t *) q)->x = qin->y; ((p4est_quadrant_t *) q)->y = x; x = q->x; /* temp storage in case elem1 = elem 2 */ @@ -484,16 +487,16 @@ t8_default_scheme_quad_c::t8_element_transform_face (const t8_element_t *elem1, } int -t8_default_scheme_quad_c::t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_quad_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, + t8_element_t *elem, int root_face) const { const t8_dline_t *l = (const t8_dline_t *) face; p4est_quadrant_t *q = (p4est_quadrant_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (T8_COMMON_IS_TYPE (face_scheme, const t8_default_scheme_line_c *)); T8_ASSERT (face_scheme->eclass == T8_ECLASS_LINE); - T8_ASSERT (face_scheme->t8_element_is_valid (elem)); + T8_ASSERT (face_scheme->element_is_valid (elem)); T8_ASSERT (0 <= root_face && root_face < P4EST_FACES); /* * The faces of the root quadrant are enumerated like this: @@ -537,9 +540,9 @@ t8_default_scheme_quad_c::t8_element_extrude_face (const t8_element_t *face, con } int -t8_default_scheme_quad_c::t8_element_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_quad_c::element_get_tree_face (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < P4EST_FACES); /* For quadrants the face and the tree face number are the same. */ return face; @@ -547,8 +550,8 @@ t8_default_scheme_quad_c::t8_element_tree_face (const t8_element_t *elem, int fa /** Construct the first descendant of an element that touches a given face. */ void -t8_default_scheme_quad_c::t8_element_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_quad_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *desc = (p4est_quadrant_t *) first_desc; @@ -565,8 +568,8 @@ t8_default_scheme_quad_c::t8_element_first_descendant_face (const t8_element_t * /** Construct the last descendant of an element that touches a given face. */ void -t8_default_scheme_quad_c::t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, - int level) const +t8_default_scheme_quad_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *desc = (p4est_quadrant_t *) last_desc; @@ -582,16 +585,16 @@ t8_default_scheme_quad_c::t8_element_last_descendant_face (const t8_element_t *e } void -t8_default_scheme_quad_c::t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const +t8_default_scheme_quad_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *boundary_scheme) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; t8_dline_t *l = (t8_dline_t *) boundary; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (T8_COMMON_IS_TYPE (boundary_scheme, const t8_default_scheme_line_c *)); T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_LINE); - T8_ASSERT (boundary_scheme->t8_element_is_valid (boundary)); + T8_ASSERT (boundary_scheme->element_is_valid (boundary)); T8_ASSERT (0 <= face && face < P4EST_FACES); /* The level of the boundary element is the same as the quadrant's level */ l->level = q->level; @@ -611,12 +614,12 @@ t8_default_scheme_quad_c::t8_element_boundary_face (const t8_element_t *elem, in } int -t8_default_scheme_quad_c::t8_element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_quad_c::element_is_root_boundary (const t8_element_t *elem, int face) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_qcoord_t coord; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < P4EST_FACES); /* if face is 0 or 1 q->x @@ -629,14 +632,14 @@ t8_default_scheme_quad_c::t8_element_is_root_boundary (const t8_element_t *elem, } int -t8_default_scheme_quad_c::t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, - int *neigh_face) const +t8_default_scheme_quad_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, + int face, int *neigh_face) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *n = (p4est_quadrant_t *) neigh; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (neigh)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (neigh)); T8_ASSERT (0 <= face && face < P4EST_FACES); /* Construct the face neighbor */ p4est_quadrant_face_neighbor (q, face, n); @@ -652,11 +655,11 @@ t8_default_scheme_quad_c::t8_element_face_neighbor_inside (const t8_element_t *e } void -t8_default_scheme_quad_c::t8_element_anchor (const t8_element_t *elem, int coord[3]) const +t8_default_scheme_quad_c::element_get_anchor (const t8_element_t *elem, int coord[3]) const { p4est_quadrant_t *q; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); q = (p4est_quadrant_t *) elem; coord[0] = q->x; coord[1] = q->y; @@ -665,11 +668,11 @@ t8_default_scheme_quad_c::t8_element_anchor (const t8_element_t *elem, int coord } void -t8_default_scheme_quad_c::t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_quad_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= vertex && vertex < 4); /* Get the length of the quadrant */ const int len = P4EST_QUADRANT_LEN (q1->level); @@ -680,14 +683,14 @@ t8_default_scheme_quad_c::t8_element_vertex_integer_coords (const t8_element_t * } void -t8_default_scheme_quad_c::t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_quad_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= vertex && vertex < 4); int coords_int[2]; - t8_element_vertex_integer_coords (elem, vertex, coords_int); + element_get_vertex_integer_coords (elem, vertex, coords_int); /* We divide the integer coordinates by the root length of the quad * to obtain the reference coordinates. */ @@ -696,31 +699,31 @@ t8_default_scheme_quad_c::t8_element_vertex_reference_coords (const t8_element_t } void -t8_default_scheme_quad_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_quad_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dquad_compute_reference_coords ((const t8_dquad_t *) elem, ref_coords, num_coords, out_coords); } void -t8_default_scheme_quad_c::t8_element_new (int length, t8_element_t **elem) const +t8_default_scheme_quad_c::element_new (int length, t8_element_t **elem) const { /* allocate memory for a quad */ - t8_default_scheme_common_c::t8_element_new (length, elem); + t8_default_scheme_common_c::element_new (length, elem); /* in debug mode, set sensible default values. */ { int i; for (i = 0; i < length; i++) { - t8_element_root (elem[i]); + get_root (elem[i]); T8_QUAD_SET_TDIM ((p4est_quadrant_t *) elem[i], 2); } } } void -t8_default_scheme_quad_c::t8_element_init (int length, t8_element_t *elem) const +t8_default_scheme_quad_c::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG p4est_quadrant_t *quads = (p4est_quadrant_t *) elem; @@ -737,7 +740,7 @@ t8_default_scheme_quad_c::t8_element_init (int length, t8_element_t *elem) const * Returns false otherwise. */ int -t8_default_scheme_quad_c::t8_element_refines_irregular () const +t8_default_scheme_quad_c::refines_irregular () const { /*Quad refine regularly */ return 0; @@ -745,7 +748,7 @@ t8_default_scheme_quad_c::t8_element_refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_quad_c::t8_element_is_valid (const t8_element_t *elem) const +t8_default_scheme_quad_c::element_is_valid (const t8_element_t *elem) const { /* TODO: additional checks? do we set pad8 or similar? */ @@ -753,10 +756,9 @@ t8_default_scheme_quad_c::t8_element_is_valid (const t8_element_t *elem) const } void -t8_default_scheme_quad_c::t8_element_to_string (const t8_element_t *elem, char *debug_string, - const int string_size) const +t8_default_scheme_quad_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); p4est_quadrant_t *quad = (p4est_quadrant_t *) elem; snprintf (debug_string, string_size, "x: %i, y: %i, level: %i", quad->x, quad->y, quad->level); @@ -780,7 +782,7 @@ t8_default_scheme_quad_c::~t8_default_scheme_quad_c () * and hence this empty function. */ } void -t8_default_scheme_quad_c::t8_element_root (t8_element_t *elem) const +t8_default_scheme_quad_c::get_root (t8_element_t *elem) const { t8_pquad_t *quad = (t8_pquad_t *) elem; p4est_quadrant_set_morton (quad, 0, 0); @@ -788,9 +790,8 @@ t8_default_scheme_quad_c::t8_element_root (t8_element_t *elem) const } /* each quad is packed as x,y coordinates and the level */ void -t8_default_scheme_quad_c::t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_quad_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { int mpiret; p4est_quadrant_t **quads = (p4est_quadrant_t **) elements; @@ -806,7 +807,7 @@ t8_default_scheme_quad_c::t8_element_MPI_Pack (t8_element_t **const elements, co /* each quad is packed as x,y coordinates and the level */ void -t8_default_scheme_quad_c::t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_quad_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -827,9 +828,8 @@ t8_default_scheme_quad_c::t8_element_MPI_Pack_size (const unsigned int count, sc /* each quad is packed as x,y coordinates and the level */ void -t8_default_scheme_quad_c::t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_quad_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const { int mpiret; p4est_quadrant_t **quads = (p4est_quadrant_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx index f1f81e1520..bcd7f2f08a 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx @@ -76,11 +76,9 @@ typedef p4est_quadrant_t t8_pquad_t; (quad)->p.user_long = (long) (coord); \ } while (0) -struct t8_default_scheme_quad_c: public t8_default_scheme_common_c +class t8_default_scheme_quad_c::public t8_eclass_scheme, public t8_default_scheme_common_c { public: - /** The virtual table for a particular implementation of an element class. */ - /** Constructor. */ t8_default_scheme_quad_c (); @@ -93,51 +91,47 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * On output all these pointers will point to an allocated * and initialized element. * \note Not every element that is created in t8code will be created by a call - * to this function. However, if an element is not created using \ref t8_element_new, - * then it is guaranteed that \ref t8_element_init is called on it. - * \note In debugging mode, an element that was created with \ref t8_element_new - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. - * \see t8_element_init - * \see t8_element_is_valid - */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + * to this function. However, if an element is not created using \ref element_new, + * then it is guaranteed that \ref element_init is called on it. + * \note In debugging mode, an element that was created with \ref element_new + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. + * \see element_init + * \see element_is_valid + */ + void element_new (int length, t8_element_t **elem) const; /** Initialize an array of allocated quad elements. * \param [in] length The number of quad elements to be initialized. * \param [in,out] elems On input an array of \b length many allocated * elements. * \param [in] called_new True if the elements in \a elem were created by a call - * to \ref t8_element_new. False if no element in \a elem + * to \ref element_new. False if no element in \a elem * was created in this way. The case that only some elements - * were created by \ref t8_element_new should never occur. - * \note In debugging mode, an element that was passed to \ref t8_element_init - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. + * were created by \ref element_new should never occur. + * \note In debugging mode, an element that was passed to \ref element_init + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. * Thus, if \a called_new is true this function should usually do nothing. - * \see t8_element_new - * \see t8_element_is_valid + * \see element_new + * \see element_is_valid */ - virtual void - t8_element_init (int length, t8_element_t *elem) const; + void element_init (int length, t8_element_t *elem) const; /** Return the refinement level of an element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - virtual int - t8_element_level (const t8_element_t *elem) const; + int element_get_level (const t8_element_t *elem) const; /** Return the maximum allowed level for this element class. * \return The maximum allowed level for elements of this class. */ - virtual int - t8_element_maxlevel (void) const; + int get_maxlevel (void) const; /** Copy all entries of \b source to \b dest. \b dest must be an existing * element. No memory is allocated by this function. @@ -146,8 +140,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * entries of \b source. * \note \a source and \a dest may point to the same element. */ - virtual void - t8_element_copy (const t8_element_t *source, t8_element_t *dest) const; + void element_copy (const t8_element_t *source, t8_element_t *dest) const; /** Compare two elements. * \param [in] elem1 The first element. @@ -156,8 +149,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * and positive if elem1 > elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - virtual int - t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -165,8 +157,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - virtual int - t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; + int element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -180,8 +171,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * For a pyramid, for example, it may be either a * tetrahedron or a pyramid depending on \b elem's childid. */ - virtual void - t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const; + void element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; /** Compute a specific sibling of a given quad element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -194,46 +184,40 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * The storage for this element must exist * and match the element class of the sibling. */ - virtual void - t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; + void element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; /** Compute the number of faces of a given element. * \param [in] elem The element. * \return The number of faces of \a elem. */ - virtual int - t8_element_num_faces (const t8_element_t *elem) const; + int element_get_num_faces (const t8_element_t *elem) const; /** Compute the maximum number of faces of a given element and all of its * descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - virtual int - t8_element_max_num_faces (const t8_element_t *elem) const; + int element_get_max_num_faces (const t8_element_t *elem) const; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - virtual int - t8_element_num_children (const t8_element_t *elem) const; + int element_get_num_children (const t8_element_t *elem) const; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - virtual int - t8_element_num_face_children (const t8_element_t *elem, int face) const; + int element_get_num_face_children (const t8_element_t *elem, int face) const; /** Return the corner number of an element's face corner. * \param [in] element The element. * \param [in] face A face index for \a element. * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - virtual int - t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const; + int element_get_face_corner (const t8_element_t *element, int face, int corner) const; /** Return the face numbers of the faces sharing an element's corner. * \param [in] element The element. @@ -241,8 +225,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - virtual int - t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const; + int element_get_corner_face (const t8_element_t *element, int corner, int face) const; /** Construct the child element of a given number. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -252,8 +235,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * On output, a valid element. * It is valid to call this function with elem = child. */ - virtual void - t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const; + void element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -263,17 +245,15 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * and match the element class in the children's ordering. * On output, all children are valid. * It is valid to call this function with elem = c[0]. - * \see t8_element_num_children + * \see element_get_num_children */ - virtual void - t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; + void element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - virtual int - t8_element_child_id (const t8_element_t *elem) const; + int element_get_child_id (const t8_element_t *elem) const; /** Compute the ancestor id of an element, that is the child id * at a given level. @@ -281,8 +261,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - virtual int - t8_element_ancestor_id (const t8_element_t *elem, int level) const; + int element_get_ancestor_id (const t8_element_t *elem, int level) const; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class @@ -290,8 +269,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - virtual int - t8_element_is_family (t8_element_t *const *fam) const; + int elements_are_family (t8_element_t *const *fam) const; /** Compute the nearest common ancestor of two elements. That is, * the element with highest level that still has both given elements as @@ -303,16 +281,14 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * On output the unique nearest common ancestor of * \b elem1 and \b elem2. */ - virtual void - t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; + void element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; /** Compute the shape of the face of an element. * \param [in] elem The element. * \param [in] face A face of \a elem. * \return The element shape of the face. */ - virtual t8_element_shape_t - t8_element_face_shape (const t8_element_t *elem, int face) const; + t8_element_shape_t element_get_face_shape (const t8_element_t *elem, int face) const; /** Given an element and a face of the element, compute all children of * the element that touch the face. @@ -323,14 +299,13 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * They will be stored in order of their linear id. * \param [in] num_children The number of elements in \a children. Must match * the number of children that touch \a face. - * \ref t8_element_num_face_children + * \ref element_get_num_face_children * \param [in,out] child_indices If not NULL, an array of num_children integers must be given, * on output its i-th entry is the child_id of the i-th face_child. * It is valid to call this function with elem = children[0]. */ - virtual void - t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const; + void element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const; /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -348,12 +323,11 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [in] face_child A number 0 <= \a face_child < num_face_children, * specifying a child of \a elem that shares a face with \a face. * These children are counted in linear order. This coincides with - * the order of children from a call to \ref t8_element_children_at_face. + * the order of children from a call to \ref element_get_children_at_face. * \return The face number of the face of a child of \a elem * that coincides with \a face_child. */ - virtual int - t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const; + int element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const; /** Given a face of an element return the face number * of the parent of the element that matches the element's face. Or return -1 if @@ -365,8 +339,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * the face number of this face. Otherwise -1. * \note For the root element this function always returns \a face. */ - virtual int - t8_element_face_parent_face (const t8_element_t *elem, int face) const; + int element_face_get_parent_face (const t8_element_t *elem, int face) const; /** Given an element and a face of this element. If the face lies on the * tree boundary, return the face number of the tree face. @@ -377,8 +350,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \a face is on a tree boundary. * Any arbitrary integer if \a is not at a tree boundary. */ - virtual int - t8_element_tree_face (const t8_element_t *elem, int face) const; + int element_get_tree_face (const t8_element_t *elem, int face) const; /** Suppose we have two trees that share a common face f. * Given an element e that is a subface of f in one of the trees @@ -401,9 +373,8 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * defined in relation to the smaller face. * \note \a elem1 and \a elem2 may point to the same element. */ - virtual void - t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, - int is_smaller_face) const; + void element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, + int is_smaller_face) const; /** Given a boundary face inside a root tree's face construct * the element inside the root tree that has the given face as a @@ -418,9 +389,8 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \return The face number of the face of \a elem that coincides * with \a face. */ - virtual int - t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const; + int element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, int root_face) + const; /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -430,8 +400,8 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the first descendant is constructed */ - virtual void - t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const; + void element_construct_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) + const; /** Construct the last descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -441,8 +411,8 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the last descendant is constructed */ - virtual void - t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const; + void element_construct_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) + const; /** Construct the boundary element at a specific face. * \param [in] elem The input element. @@ -453,17 +423,15 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * of the face of \a element. * \param [in] boundary_scheme The scheme for the eclass of the boundary face. */ - virtual void - t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const; + void element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme_c *boundary_scheme) const; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. * \param [in] face A face of \a elem. * \return True if \a face is a subface of the element's root element. */ - virtual int - t8_element_is_root_boundary (const t8_element_t *elem, int face) const; + int element_is_root_boundary (const t8_element_t *elem, int face) const; /** Construct the face neighbor of a given element if this face neighbor * is inside the root tree. Return 0 otherwise. @@ -480,8 +448,8 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * False if not. In this case \a neigh's data can be arbitrary * on output. */ - virtual int - t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const; + int element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) + const; /** Initialize the entries of an allocated element according to a * given linear id in a uniform refinement. @@ -490,8 +458,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [in] id The linear id. * id must fulfil 0 <= id < 'number of leaves in the uniform refinement' */ - virtual void - t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; + void element_set_linear_id (t8_element_t * elem, int level, t8_linearidx_t id) const; /** Compute the linear id of a given element in a hypothetical uniform * refinement of a given level. @@ -499,8 +466,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [in] level The level of the uniform refinement to consider. * \return The linear id of the element. */ - virtual t8_linearidx_t - t8_element_get_linear_id (const t8_element_t *elem, int level) const; + t8_linearidx_t element_get_linear_id (const t8_element_t *elem, int level) const; /** Compute the first descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -508,8 +474,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Compute the last descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -517,16 +482,14 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Construct the successor in a uniform refinement of a given element. * \param [in] elem1 The element whose successor should be constructed. * \param [in,out] elem2 The element whose entries will be set. * \param [in] level The level of the uniform refinement to consider. */ - virtual void - t8_element_successor (const t8_element_t *elem, t8_element_t *succ) const; + void element_construct_successor (const t8_element_t *elem, t8_element_t *succ) const; /** Get the integer coordinates of the anchor node of an element. * The default scheme implements the Morton type SFCs. In these SFCs the @@ -538,8 +501,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [in] elem The element. * \param [out] anchor The integer coordinates of the anchor node in the cube [0,1]^(dL) */ - virtual void - t8_element_anchor (const t8_element_t *elem, int anchor[3]) const; + void element_get_anchor (const t8_element_t *elem, int anchor[3]) const; /** Compute the integer coordinates of a given element vertex. * The default scheme implements the Morton type SFCs. In these SFCs the @@ -551,8 +513,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void - t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; + void element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). @@ -563,8 +524,7 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \warning coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere * all coords might be used. */ - virtual void - t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; + void element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; /** Convert points in the reference space of an element to points in the * reference space of the tree. @@ -576,34 +536,31 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [out] out_coords The coordinates of the points in the * reference space of the tree. */ - virtual void - t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + void element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, + double *out_coords) const; /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because quads refine regularly */ - virtual int - t8_element_refines_irregular (void) const; + int refines_irregular (void) const; #ifdef T8_ENABLE_DEBUG /** Query whether a given element can be considered as 'valid' and it is * safe to perform any of the above algorithms on it. * \param [in] elem The element to be checked. * \return True if \a elem is safe to use. False otherwise. - * \note An element that is constructed with \ref t8_element_new + * \note An element that is constructed with \ref element_new * must pass this test. - * \note An element for which \ref t8_element_init was called must pass + * \note An element for which \ref element_init was called must pass * this test. * \note This function is used for debugging to catch certain errors. * These can for example occur when an element points to a region * of memory which should not be interpreted as an element. - * \note We recommend to use the assertion T8_ASSERT (t8_element_is_valid (elem)) + * \note We recommend to use the assertion T8_ASSERT (element_is_valid (elem)) * in the implementation of each of the functions in this file. */ - virtual int - t8_element_is_valid (const t8_element_t *t) const; + int element_is_valid (const t8_element_t *t) const; /** * Print a given element. For a example for a triangle print the coordinates @@ -612,15 +569,13 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * * \param [in] elem The element to print */ - virtual void - t8_element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; + void element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; #endif /** Fills an element with the root element. * \param [in,out] elem The element to be filled with root. */ - void - t8_element_root (t8_element_t *elem) const; + void get_root (t8_element_t * elem) const; /** Pack multiple elements into contiguous memory, so they can be sent via MPI. * \param [in] elements Array of elements that are to be packed @@ -630,17 +585,15 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [in, out] position the position of the first byte that is not already packed * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, - int *position, sc_MPI_Comm comm) const; + void element_MPI_Pack (t8_element_t * *const elements, const unsigned int count, void *send_buffer, int buffer_size, + int *position, sc_MPI_Comm comm) const; /** Determine an upper bound for the size of the packed message of \b count elements * \param [in] count Number of elements to pack * \param [in] comm MPI Communicator * \param [out] pack_size upper bound on the message size */ - virtual void - t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; + void element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; /** Unpack multiple elements from contiguous memory that was received via MPI. * \param [in] recvbuf Buffer from which to unpack the elements @@ -650,7 +603,6 @@ struct t8_default_scheme_quad_c: public t8_default_scheme_common_c * \param [in] count Number of elements to unpack * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, - const unsigned int count, sc_MPI_Comm comm) const; + void element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const unsigned int count, sc_MPI_Comm comm) const; }; diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx index bc571d361a..64e8d3b590 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx @@ -32,89 +32,89 @@ T8_EXTERN_C_BEGIN (); typedef t8_dtet_t t8_default_tet_t; int -t8_default_scheme_tet_c::t8_element_maxlevel (void) const +t8_default_scheme_tet_c::get_maxlevel (void) const { return T8_DTET_MAXLEVEL; } int -t8_default_scheme_tet_c::t8_element_level (const t8_element_t *elem) const +t8_default_scheme_tet_c::element_get_level (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dtet_get_level ((t8_dtet_t *) elem); } void -t8_default_scheme_tet_c::t8_element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_tet_c::element_copy (const t8_element_t *source, t8_element_t *dest) const { - T8_ASSERT (t8_element_is_valid (source)); - T8_ASSERT (t8_element_is_valid (dest)); + T8_ASSERT (element_is_valid (source)); + T8_ASSERT (element_is_valid (dest)); t8_dtet_copy ((const t8_dtet_t *) source, (t8_dtet_t *) dest); } int -t8_default_scheme_tet_c::t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_tet_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dtet_compare ((const t8_dtet_t *) elem1, (const t8_dtet_t *) elem2); } int -t8_default_scheme_tet_c::t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_tet_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dtet_equal ((const t8_dtet_t *) elem1, (const t8_dtet_t *) elem2); } void -t8_default_scheme_tet_c::t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_tet_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { const t8_default_tet_t *t = (const t8_default_tet_t *) elem; t8_default_tet_t *p = (t8_default_tet_t *) parent; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (parent)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (parent)); t8_dtet_parent (t, p); } void -t8_default_scheme_tet_c::t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const +t8_default_scheme_tet_c::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { const t8_default_tet_t *t = (const t8_default_tet_t *) elem; t8_default_tet_t *s = (t8_default_tet_t *) sibling; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (sibling)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (sibling)); t8_dtet_sibling (t, sibid, s); } int -t8_default_scheme_tet_c::t8_element_num_faces (const t8_element_t *elem) const +t8_default_scheme_tet_c::element_get_num_faces (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DTET_FACES; } int -t8_default_scheme_tet_c::t8_element_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_tet_c::element_get_max_num_faces (const t8_element_t *elem) const { return T8_DTET_FACES; } int -t8_default_scheme_tet_c::t8_element_num_children (const t8_element_t *elem) const +t8_default_scheme_tet_c::element_get_num_children (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DTET_CHILDREN; } int -t8_default_scheme_tet_c::t8_element_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_tet_c::element_get_num_face_children (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_DTET_FACE_CHILDREN; } int -t8_default_scheme_tet_c::t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_tet_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const { T8_ASSERT (0 <= face && face < T8_DTET_FACES); T8_ASSERT (0 <= corner && corner < 3); @@ -122,82 +122,82 @@ t8_default_scheme_tet_c::t8_element_get_face_corner (const t8_element_t *element } void -t8_default_scheme_tet_c::t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_tet_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const t8_default_tet_t *t = (const t8_default_tet_t *) elem; t8_default_tet_t *c = (t8_default_tet_t *) child; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (child)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (child)); t8_dtet_child (t, childid, c); } void -t8_default_scheme_tet_c::t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_tet_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { T8_ASSERT (length == T8_DTET_CHILDREN); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); #ifdef T8_ENABLE_DEBUG int i; for (i = 0; i < T8_DTET_CHILDREN; i++) { - T8_ASSERT (t8_element_is_valid (c[i])); + T8_ASSERT (element_is_valid (c[i])); } #endif t8_dtet_childrenpv ((const t8_dtet_t *) elem, (t8_dtet_t **) c); } int -t8_default_scheme_tet_c::t8_element_child_id (const t8_element_t *elem) const +t8_default_scheme_tet_c::element_get_child_id (const t8_element_t *elem) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dtet_child_id ((const t8_dtet_t *) elem); } int -t8_default_scheme_tet_c::t8_element_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_tet_c::element_get_ancestor_id (const t8_element_t *elem, int level) const { return t8_dtet_ancestor_id ((t8_dtet_t *) elem, level); } int -t8_default_scheme_tet_c::t8_element_is_family (t8_element_t *const *fam) const +t8_default_scheme_tet_c::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG int i; for (i = 0; i < T8_DTET_CHILDREN; i++) { - T8_ASSERT (t8_element_is_valid (fam[i])); + T8_ASSERT (element_is_valid (fam[i])); } #endif return t8_dtet_is_familypv ((const t8_dtet_t **) fam); } void -t8_default_scheme_tet_c::t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const +t8_default_scheme_tet_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const { const t8_default_tet_t *t1 = (const t8_default_tet_t *) elem1; const t8_default_tet_t *t2 = (const t8_default_tet_t *) elem2; t8_default_tet_t *c = (t8_default_tet_t *) nca; - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); t8_dtet_nearest_common_ancestor (t1, t2, c); } t8_element_shape_t -t8_default_scheme_tet_c::t8_element_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_tet_c::element_get_face_shape (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return T8_ECLASS_TRIANGLE; } void -t8_default_scheme_tet_c::t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_tet_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { const t8_dtet_t *t = (const t8_dtet_t *) elem; t8_dtet_t **c = (t8_dtet_t **) children; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DTET_FACES); T8_ASSERT (num_children == T8_DTET_FACE_CHILDREN); @@ -206,7 +206,7 @@ t8_default_scheme_tet_c::t8_element_children_at_face (const t8_element_t *elem, { int i; for (i = 0; i < num_children; i++) { - T8_ASSERT (t8_element_is_valid (children[i])); + T8_ASSERT (element_is_valid (children[i])); } } #endif @@ -215,16 +215,16 @@ t8_default_scheme_tet_c::t8_element_children_at_face (const t8_element_t *elem, } int -t8_default_scheme_tet_c::t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_tet_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DTET_FACES); T8_ASSERT (0 <= face && face < T8_DTET_FACE_CHILDREN); return t8_dtet_face_child_face ((const t8_dtet_t *) elem, face, face_child); } int -t8_default_scheme_tet_c::t8_element_face_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_tet_c::element_face_get_parent_face (const t8_element_t *elem, int face) const { T8_ASSERT (0 <= face && face < T8_DTET_FACES); @@ -232,9 +232,9 @@ t8_default_scheme_tet_c::t8_element_face_parent_face (const t8_element_t *elem, } int -t8_default_scheme_tet_c::t8_element_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_tet_c::element_get_tree_face (const t8_element_t *elem, int face) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DTET_FACES); return t8_dtet_tree_face ((t8_dtet_t *) elem, face); } @@ -245,15 +245,15 @@ t8_default_scheme_tet_c::t8_element_tree_face (const t8_element_t *elem, int fac * both in t8_dtri_bits.c. This would be needed by an implementation, at least * for tets. */ int -t8_default_scheme_tet_c::t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_tet_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, + t8_element_t *elem, int root_face) const { const t8_dtri_t *b = (const t8_dtri_t *) face; t8_dtet_t *t = (t8_dtet_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (face_scheme->eclass == T8_ECLASS_TRIANGLE); - T8_ASSERT (face_scheme->t8_element_is_valid (face)); + T8_ASSERT (face_scheme->element_is_valid (face)); T8_ASSERT (0 <= root_face && root_face < T8_DTET_FACES); t->level = b->level; switch (root_face) { @@ -289,8 +289,8 @@ t8_default_scheme_tet_c::t8_element_extrude_face (const t8_element_t *face, cons } void -t8_default_scheme_tet_c::t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, - int level) const +t8_default_scheme_tet_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DTET_FACES); @@ -303,8 +303,8 @@ t8_default_scheme_tet_c::t8_element_first_descendant_face (const t8_element_t *e } void -t8_default_scheme_tet_c::t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, - int level) const +t8_default_scheme_tet_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DTET_FACES); @@ -321,16 +321,16 @@ t8_default_scheme_tet_c::t8_element_last_descendant_face (const t8_element_t *el * the compile logic does not allow for t8_dtri_t and t8_dtet_t to exist * both in t8_dtet_bits.c. */ void -t8_default_scheme_tet_c::t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const +t8_default_scheme_tet_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *boundary_scheme) const { const t8_default_tet_t *t = (const t8_default_tet_t *) elem; t8_dtri_t *b = (t8_dtri_t *) boundary; int face_cat; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_TRIANGLE); - T8_ASSERT (boundary_scheme->t8_element_is_valid (boundary)); + T8_ASSERT (boundary_scheme->element_is_valid (boundary)); T8_ASSERT (0 <= face && face < T8_DTET_FACES); /* The level of the boundary element is the same as the quadrant's level */ b->level = t->level; @@ -368,23 +368,23 @@ t8_default_scheme_tet_c::t8_element_boundary_face (const t8_element_t *elem, int } int -t8_default_scheme_tet_c::t8_element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_tet_c::element_is_root_boundary (const t8_element_t *elem, int face) const { const t8_dtet_t *t = (const t8_dtet_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dtet_is_root_boundary (t, face); } int -t8_default_scheme_tet_c::t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, - int *neigh_face) const +t8_default_scheme_tet_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, + int face, int *neigh_face) const { const t8_dtet_t *t = (const t8_dtet_t *) elem; t8_dtet_t *n = (t8_dtet_t *) neigh; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (neigh)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (neigh)); T8_ASSERT (0 <= face && face < T8_DTET_FACES); T8_ASSERT (neigh_face != NULL); *neigh_face = t8_dtet_face_neighbour (t, face, n); @@ -393,57 +393,59 @@ t8_default_scheme_tet_c::t8_element_face_neighbor_inside (const t8_element_t *el } void -t8_default_scheme_tet_c::t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_tet_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { T8_ASSERT (0 <= level && level <= T8_DTET_MAXLEVEL); T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << 3 * level); - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dtet_init_linear_id ((t8_default_tet_t *) elem, id, level); } t8_linearidx_t -t8_default_scheme_tet_c::t8_element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_tet_c::element_get_linear_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DTET_MAXLEVEL); return t8_dtet_linear_id ((t8_default_tet_t *) elem, level); } void -t8_default_scheme_tet_c::t8_element_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_tet_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); - T8_ASSERT (0 <= t8_element_level (elem1) && t8_element_level (elem1) <= T8_DTET_MAXLEVEL); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); + T8_ASSERT (0 <= element_get_level (elem1) && element_get_level (elem1) <= T8_DTET_MAXLEVEL); - t8_dtet_successor ((const t8_default_tet_t *) elem1, (t8_default_tet_t *) elem2, t8_element_level (elem1)); + t8_dtet_successor ((const t8_default_tet_t *) elem1, (t8_default_tet_t *) elem2, element_get_level (elem1)); } void -t8_default_scheme_tet_c::t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_tet_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= T8_DTET_MAXLEVEL); t8_dtet_first_descendant ((t8_dtet_t *) elem, (t8_dtet_t *) desc, level); } void -t8_default_scheme_tet_c::t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_tet_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= T8_DTET_MAXLEVEL); t8_dtet_last_descendant ((t8_dtet_t *) elem, (t8_dtet_t *) desc, level); } void -t8_default_scheme_tet_c::t8_element_anchor (const t8_element_t *elem, int anchor[3]) const +t8_default_scheme_tet_c::element_get_anchor (const t8_element_t *elem, int anchor[3]) const { t8_dtet_t *tet = (t8_dtet_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); anchor[0] = tet->x; anchor[1] = tet->y; @@ -451,25 +453,25 @@ t8_default_scheme_tet_c::t8_element_anchor (const t8_element_t *elem, int anchor } void -t8_default_scheme_tet_c::t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_tet_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dtet_compute_integer_coords ((const t8_default_tet_t *) elem, vertex, coords); } void -t8_default_scheme_tet_c::t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_tet_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dtet_compute_vertex_ref_coords ((const t8_default_tet_t *) elem, vertex, coords); } void -t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_tet_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dtet_compute_reference_coords ((const t8_dtet_t *) elem, ref_coords, num_coords, out_coords); } @@ -477,7 +479,7 @@ t8_default_scheme_tet_c::t8_element_reference_coords (const t8_element_t *elem, * Returns false otherwise. */ int -t8_default_scheme_tet_c::t8_element_refines_irregular () const +t8_default_scheme_tet_c::refines_irregular () const { /*Tets refine regularly */ return 0; @@ -485,17 +487,16 @@ t8_default_scheme_tet_c::t8_element_refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_tet_c::t8_element_is_valid (const t8_element_t *t) const +t8_default_scheme_tet_c::element_is_valid (const t8_element_t *t) const { return t8_dtet_is_valid ((const t8_dtet_t *) t); } void -t8_default_scheme_tet_c::t8_element_to_string (const t8_element_t *elem, char *debug_string, - const int string_size) const +t8_default_scheme_tet_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); t8_dtet_t *tet = (t8_dtet_t *) elem; snprintf (debug_string, BUFSIZ, "x: %i, y: %i, z: %i, type: %i, level: %i", tet->x, tet->y, tet->z, tet->type, @@ -504,24 +505,24 @@ t8_default_scheme_tet_c::t8_element_to_string (const t8_element_t *elem, char *d #endif void -t8_default_scheme_tet_c::t8_element_new (int length, t8_element_t **elem) const +t8_default_scheme_tet_c::element_new (int length, t8_element_t **elem) const { /* allocate memory for a tet */ - t8_default_scheme_common_c::t8_element_new (length, elem); + t8_default_scheme_common_c::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG { int i; for (i = 0; i < length; i++) { - t8_element_root (elem[i]); + get_root (elem[i]); } } #endif } void -t8_default_scheme_tet_c::t8_element_init (int length, t8_element_t *elem) const +t8_default_scheme_tet_c::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dtet_t *tets = (t8_dtet_t *) elem; @@ -549,7 +550,7 @@ t8_default_scheme_tet_c::~t8_default_scheme_tet_c () * and hence this empty function. */ } void -t8_default_scheme_tet_c::t8_element_root (t8_element_t *elem) const +t8_default_scheme_tet_c::get_root (t8_element_t *elem) const { t8_dtet_t *tet = (t8_dtet_t *) elem; tet->level = 0; @@ -560,25 +561,23 @@ t8_default_scheme_tet_c::t8_element_root (t8_element_t *elem) const } /* use macro tri functionality */ void -t8_default_scheme_tet_c::t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_tet_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { t8_dtet_element_pack ((t8_dtet_t **) elements, count, send_buffer, buffer_size, position, comm); } /* use macro tri functionality */ void -t8_default_scheme_tet_c::t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_tet_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { t8_dtet_element_pack_size (count, comm, pack_size); } /* use macro tri functionality */ void -t8_default_scheme_tet_c::t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_tet_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const { t8_dtet_element_unpack (recvbuf, buffer_size, position, (t8_dtet_t **) elements, count, comm); } diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx index acc92d61ac..6d2b3e174b 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx @@ -33,8 +33,7 @@ #include #include -struct t8_default_scheme_tet_c: public t8_default_scheme_common_c -{ +class t8_default_scheme_tet_c: public t8_eclass_scheme, public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_tet_c (); @@ -46,50 +45,50 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \param [in,out] elems On input an array of \b length many unallocated element pointers. On output all these * pointers will point to an allocated and initialized element. * \note Not every element that is created in t8code will be created by a call - * to this function. However, if an element is not created using \ref t8_element_new, - * then it is guaranteed that \ref t8_element_init is called on it. - * \note In debugging mode, an element that was created with \ref t8_element_new - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. - * \see t8_element_init - * \see t8_element_is_valid - */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + * to this function. However, if an element is not created using \ref element_new, + * then it is guaranteed that \ref element_init is called on it. + * \note In debugging mode, an element that was created with \ref element_new + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. + * \see element_init + * \see element_is_valid + */ + void + element_new (int length, t8_element_t **elem) const; /** Initialize an array of allocated tet elements. * \param [in] length The number of tet elements to be initialized. * \param [in,out] elems On input an array of \b length many allocated elements. * \param [in] called_new True if the elements in \a elem were created by a call - * to \ref t8_element_new. False if no element in \a elem + * to \ref element_new. False if no element in \a elem * was created in this way. The case that only some elements - * were created by \ref t8_element_new should never occur. - * \note In debugging mode, an element that was passed to \ref t8_element_init - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. + * were created by \ref element_new should never occur. + * \note In debugging mode, an element that was passed to \ref element_init + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. * Thus, if \a called_new is true this function should usually do nothing. - * \see t8_element_new - * \see t8_element_is_valid + * \see element_new + * \see element_is_valid */ - virtual void - t8_element_init (int length, t8_element_t *elem) const; + void + element_init (int length, t8_element_t *elem) const; /** Return the refinement level of an element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - virtual int - t8_element_level (const t8_element_t *elem) const; + int + element_get_level (const t8_element_t *elem) const; /** Return the maximum allowed level for this element class. * \return The maximum allowed level for elements of this class. */ - virtual int - t8_element_maxlevel (void) const; + int + get_maxlevel (void) const; /** Copy all entries of \b source to \b dest. \b dest must be an existing element. * No memory is allocated by this function. @@ -97,8 +96,8 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \param [in,out] dest This element's entries will be overwritten with the entries of \b source. * \note \a source and \a dest may point to the same element. */ - virtual void - t8_element_copy (const t8_element_t *source, t8_element_t *dest) const; + void + element_copy (const t8_element_t *source, t8_element_t *dest) const; /** Compare two elements. * \param [in] elem1 The first element. @@ -106,8 +105,8 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \return negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - virtual int - t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -115,8 +114,8 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - virtual int - t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -127,8 +126,8 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * The storage for this element must exist and match the element class of the parent. * For a pyramid, for example, it may be either a tetrahedron or a pyramid depending on \b elem's childid. */ - virtual void - t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const; + void + element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; /** Compute a specific sibling of a given tet element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -139,45 +138,45 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \param [in,out] sibling This element's entries will be overwritten by those of \b elem's sibid-th sibling. * The storage for this element must exist and match the element class of the sibling. */ - virtual void - t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; + void + element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; /** Compute the number of faces of a given element. * \param [in] elem The element. * \return The number of faces of \a elem. */ - virtual int - t8_element_num_faces (const t8_element_t *elem) const; + int + element_get_num_faces (const t8_element_t *elem) const; /** Compute the maximum number of faces of a given element and all of its descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - virtual int - t8_element_max_num_faces (const t8_element_t *elem) const; + int + element_get_max_num_faces (const t8_element_t *elem) const; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - virtual int - t8_element_num_children (const t8_element_t *elem) const; + int + element_get_num_children (const t8_element_t *elem) const; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - virtual int - t8_element_num_face_children (const t8_element_t *elem, int face) const; + int + element_get_num_face_children (const t8_element_t *elem, int face) const; /** Return the corner number of an element's face corner. * \param [in] element The element. * \param [in] face A face index for \a element. * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - virtual int - t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const; + int + element_get_face_corner (const t8_element_t *element, int face, int corner) const; /** Return the face numbers of the faces sharing an element's corner. * \param [in] element The element. @@ -185,8 +184,8 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - virtual int - t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const + int + element_get_corner_face (const t8_element_t *element, int corner, int face) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -199,8 +198,8 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * On output, a valid element. * It is valid to call this function with elem = child. */ - virtual void - t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const; + void + element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -208,33 +207,33 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \param [in,out] c The storage for these \a length elements must exist and match the element class in the * children's ordering. On output, all children are valid. * It is valid to call this function with elem = c[0]. - * \see t8_element_num_children + * \see element_get_num_children */ - virtual void - t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; + void + element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - virtual int - t8_element_child_id (const t8_element_t *elem) const; + int + element_get_child_id (const t8_element_t *elem) const; /** Compute the ancestor id of an element, that is the child id at a given level. * \param [in] elem This must be a valid element. * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - virtual int - t8_element_ancestor_id (const t8_element_t *elem, int level) const; + int + element_get_ancestor_id (const t8_element_t *elem, int level) const; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class \b ts has siblings. * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - virtual int - t8_element_is_family (t8_element_t *const *fam) const; + int + elements_are_family (t8_element_t *const *fam) const; /** Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both * given elements as descendants. @@ -243,16 +242,16 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \param [in,out] nca The storage for this element must exist and match the element class of the child. * On output the unique nearest common ancestor of \b elem1 and \b elem2. */ - virtual void - t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; + void + element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; /** Compute the shape of the face of an element. * \param [in] elem The element. * \param [in] face A face of \a elem. * \return The element shape of the face. */ - virtual t8_element_shape_t - t8_element_face_shape (const t8_element_t *elem, int face) const; + t8_element_shape_t + element_get_face_shape (const t8_element_t *elem, int face) const; /** Given an element and a face of the element, compute all children of the element that touch the face. * \param [in] elem The element. @@ -260,14 +259,14 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \param [in,out] children Allocated elements, in which the children of \a elem that share a face with \a face are * stored. They will be stored in order of their linear id. * \param [in] num_children The number of elements in \a children. Must match the number of children that touch - * \a face. \ref t8_element_num_face_children + * \a face. \ref element_get_num_face_children * \param [in,out] child_indices If not NULL, an array of num_children integers must be given, on output its i-th * entry is the child_id of the i-th face_child. It is valid to call this function * with elem = children[0]. */ - virtual void - t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const; + void + element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const; /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -284,11 +283,11 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \param [in] face Then number of the face. * \param [in] face_child A number 0 <= \a face_child < num_face_children, specifying a child of \a elem that shares * a face with \a face. These children are counted in linear order. This coincides with the - * order of children from a call to \ref t8_element_children_at_face. + * order of children from a call to \ref element_get_children_at_face. * \return The face number of the face of a child of \a elem that coincides with \a face_child. */ - virtual int - t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const; + int + element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const; /** Given a face of an element return the face number of the parent of the element that matches the element's face. * Or return -1 if no face of the parent matches the face. @@ -298,8 +297,8 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * Otherwise -1. * \note For the root element this function always returns \a face. */ - virtual int - t8_element_face_parent_face (const t8_element_t *elem, int face) const; + int + element_face_get_parent_face (const t8_element_t *elem, int face) const; /** Given an element and a face of this element. If the face lies on the tree boundary, return the face number of * the tree face. If not the return value is arbitrary. @@ -308,8 +307,8 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * \return The index of the tree face that \a face is a subface of, if \a face is on a tree boundary. Any arbitrary * integer if \a is not at a tree boundary. */ - virtual int - t8_element_tree_face (const t8_element_t *elem, int face) const; + int + element_get_tree_face (const t8_element_t *elem, int face) const; /** Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the * trees and given the orientation of the tree connection, construct the face element of the respective tree neighbor @@ -325,9 +324,9 @@ struct t8_default_scheme_tet_c: public t8_default_scheme_common_c * and feclass == T8_ECLASS_LINE); - T8_ASSERT (face_scheme->t8_element_is_valid (face)); + T8_ASSERT (face_scheme->element_is_valid (face)); T8_ASSERT (0 <= root_face && root_face < T8_DTRI_FACES); /* * The faces of the root triangle are enumerated like this @@ -318,8 +318,8 @@ t8_default_scheme_tri_c::t8_element_extrude_face (const t8_element_t *face, cons } void -t8_default_scheme_tri_c::t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, - int level) const +t8_default_scheme_tri_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DTRI_FACES); @@ -332,8 +332,8 @@ t8_default_scheme_tri_c::t8_element_first_descendant_face (const t8_element_t *e } void -t8_default_scheme_tri_c::t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, - int level) const +t8_default_scheme_tri_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DTRI_FACES); @@ -346,16 +346,16 @@ t8_default_scheme_tri_c::t8_element_last_descendant_face (const t8_element_t *el /* Construct the boundary element at a specific face. */ void -t8_default_scheme_tri_c::t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const +t8_default_scheme_tri_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *boundary_scheme) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; t8_dline_t *l = (t8_dline_t *) boundary; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (T8_COMMON_IS_TYPE (boundary_scheme, const t8_default_scheme_line_c *)); T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_LINE); - T8_ASSERT (boundary_scheme->t8_element_is_valid (boundary)); + T8_ASSERT (boundary_scheme->element_is_valid (boundary)); T8_ASSERT (0 <= face && face < T8_DTRI_FACES); /* The level of the boundary element is the same as the quadrant's level */ l->level = t->level; @@ -384,23 +384,23 @@ t8_default_scheme_tri_c::t8_element_boundary_face (const t8_element_t *elem, int } int -t8_default_scheme_tri_c::t8_element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_tri_c::element_is_root_boundary (const t8_element_t *elem, int face) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); return t8_dtri_is_root_boundary (t, face); } int -t8_default_scheme_tri_c::t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, - int *neigh_face) const +t8_default_scheme_tri_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, + int face, int *neigh_face) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; t8_dtri_t *n = (t8_dtri_t *) neigh; - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (neigh)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (neigh)); T8_ASSERT (0 <= face && face < T8_DTRI_FACES); T8_ASSERT (neigh_face != NULL); @@ -410,9 +410,9 @@ t8_default_scheme_tri_c::t8_element_face_neighbor_inside (const t8_element_t *el } void -t8_default_scheme_tri_c::t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_tri_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DTRI_MAXLEVEL); T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << (2 * level)); @@ -420,78 +420,80 @@ t8_default_scheme_tri_c::t8_element_set_linear_id (t8_element_t *elem, int level } t8_linearidx_t -t8_default_scheme_tri_c::t8_element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_tri_c::element_get_linear_id (const t8_element_t *elem, int level) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DTRI_MAXLEVEL); return t8_dtri_linear_id ((t8_dtri_t *) elem, level); } void -t8_default_scheme_tri_c::t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_tri_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= T8_DTRI_MAXLEVEL); t8_dtri_first_descendant ((t8_dtri_t *) elem, (t8_dtri_t *) desc, level); } void -t8_default_scheme_tri_c::t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const +t8_default_scheme_tri_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { - T8_ASSERT (t8_element_is_valid (elem)); - T8_ASSERT (t8_element_is_valid (desc)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (element_is_valid (desc)); T8_ASSERT (0 <= level && level <= T8_DTRI_MAXLEVEL); t8_dtri_last_descendant ((t8_dtri_t *) elem, (t8_dtri_t *) desc, level); } void -t8_default_scheme_tri_c::t8_element_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_tri_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { - T8_ASSERT (t8_element_is_valid (elem1)); - T8_ASSERT (t8_element_is_valid (elem2)); - T8_ASSERT (0 <= t8_element_level (elem1) && t8_element_level (elem1) <= T8_DTRI_MAXLEVEL); + T8_ASSERT (element_is_valid (elem1)); + T8_ASSERT (element_is_valid (elem2)); + T8_ASSERT (0 <= element_get_level (elem1) && element_get_level (elem1) <= T8_DTRI_MAXLEVEL); - t8_dtri_successor ((const t8_dtri_t *) elem1, (t8_dtri_t *) elem2, t8_element_level (elem1)); + t8_dtri_successor ((const t8_dtri_t *) elem1, (t8_dtri_t *) elem2, element_get_level (elem1)); } void -t8_default_scheme_tri_c::t8_element_anchor (const t8_element_t *elem, int anchor[3]) const +t8_default_scheme_tri_c::element_get_anchor (const t8_element_t *elem, int anchor[3]) const { t8_dtri_t *tri = (t8_dtri_t *) elem; - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); anchor[0] = tri->x; anchor[1] = tri->y; anchor[2] = 0; } void -t8_default_scheme_tri_c::t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_tri_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dtri_compute_integer_coords ((const t8_dtri_t *) elem, vertex, coords); } void -t8_default_scheme_tri_c::t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_tri_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dtri_compute_vertex_ref_coords ((const t8_dtri_t *) elem, vertex, coords); } void -t8_default_scheme_tri_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_tri_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); t8_dtri_compute_reference_coords ((const t8_dtri_t *) elem, ref_coords, num_coords, 0, out_coords); } int -t8_default_scheme_tri_c::t8_element_refines_irregular () const +t8_default_scheme_tri_c::refines_irregular () const { /*tris refine regularly */ return 0; @@ -499,16 +501,15 @@ t8_default_scheme_tri_c::t8_element_refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_tri_c::t8_element_is_valid (const t8_element_t *t) const +t8_default_scheme_tri_c::element_is_valid (const t8_element_t *t) const { return t8_dtri_is_valid ((const t8_dtri_t *) t); } void -t8_default_scheme_tri_c::t8_element_to_string (const t8_element_t *elem, char *debug_string, - const int string_size) const +t8_default_scheme_tri_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { - T8_ASSERT (t8_element_is_valid (elem)); + T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); t8_dtri_t *tri = (t8_dtri_t *) elem; snprintf (debug_string, string_size, "x: %i, y: %i, type: %i, level: %i", tri->x, tri->y, tri->type, tri->level); @@ -516,24 +517,24 @@ t8_default_scheme_tri_c::t8_element_to_string (const t8_element_t *elem, char *d #endif void -t8_default_scheme_tri_c::t8_element_new (int length, t8_element_t **elem) const +t8_default_scheme_tri_c::element_new (int length, t8_element_t **elem) const { /* allocate memory for a tet */ - t8_default_scheme_common_c::t8_element_new (length, elem); + t8_default_scheme_common_c::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG { int i; for (i = 0; i < length; i++) { - t8_element_root (elem[i]); + get_root (elem[i]); } } #endif } void -t8_default_scheme_tri_c::t8_element_init (int length, t8_element_t *elem) const +t8_default_scheme_tri_c::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dtri_t *tris = (t8_dtri_t *) elem; @@ -561,7 +562,7 @@ t8_default_scheme_tri_c::~t8_default_scheme_tri_c () * and hence this empty function. */ } void -t8_default_scheme_tri_c::t8_element_root (t8_element_t *elem) const +t8_default_scheme_tri_c::get_root (t8_element_t *elem) const { t8_dtri_t *tri = (t8_dtri_t *) elem; tri->level = 0; @@ -571,25 +572,23 @@ t8_default_scheme_tri_c::t8_element_root (t8_element_t *elem) const } /* use macro tri functionality */ void -t8_default_scheme_tri_c::t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_tri_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { t8_dtri_element_pack ((t8_dtri_t **) elements, count, send_buffer, buffer_size, position, comm); } /* use macro tri functionality */ void -t8_default_scheme_tri_c::t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_tri_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { t8_dtri_element_pack_size (count, comm, pack_size); } /* use macro tri functionality */ void -t8_default_scheme_tri_c::t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_tri_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const { t8_dtri_element_unpack (recvbuf, buffer_size, position, (t8_dtri_t **) elements, count, comm); } diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx index dcb0b313ef..de9916ed42 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx @@ -32,11 +32,9 @@ #include #include -struct t8_default_scheme_tri_c: public t8_default_scheme_common_c +class t8_default_scheme_tri_c::public t8_eclass_scheme, public t8_default_scheme_common_c { public: - /** The virtual table for a particular implementation of an element class. */ - /** Constructor. */ t8_default_scheme_tri_c (); @@ -49,51 +47,47 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * On output all these pointers will point to an allocated * and initialized element. * \note Not every element that is created in t8code will be created by a call - * to this function. However, if an element is not created using \ref t8_element_new, - * then it is guaranteed that \ref t8_element_init is called on it. - * \note In debugging mode, an element that was created with \ref t8_element_new - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. - * \see t8_element_init - * \see t8_element_is_valid - */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + * to this function. However, if an element is not created using \ref element_new, + * then it is guaranteed that \ref element_init is called on it. + * \note In debugging mode, an element that was created with \ref element_new + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. + * \see element_init + * \see element_is_valid + */ + void element_new (int length, t8_element_t **elem) const; /** Initialize an array of allocated tri elements. * \param [in] length The number of tri elements to be initialized. * \param [in,out] elems On input an array of \b length many allocated * elements. * \param [in] called_new True if the elements in \a elem were created by a call - * to \ref t8_element_new. False if no element in \a elem + * to \ref element_new. False if no element in \a elem * was created in this way. The case that only some elements - * were created by \ref t8_element_new should never occur. - * \note In debugging mode, an element that was passed to \ref t8_element_init - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. + * were created by \ref element_new should never occur. + * \note In debugging mode, an element that was passed to \ref element_init + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. * Thus, if \a called_new is true this function should usually do nothing. - * \see t8_element_new - * \see t8_element_is_valid + * \see element_new + * \see element_is_valid */ - virtual void - t8_element_init (int length, t8_element_t *elem) const; + void element_init (int length, t8_element_t *elem) const; /** Return the refinement level of an element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - virtual int - t8_element_level (const t8_element_t *elem) const; + int element_get_level (const t8_element_t *elem) const; /** Return the maximum allowed level for this element class. * \return The maximum allowed level for elements of this class. */ - virtual int - t8_element_maxlevel (void) const; + int get_maxlevel (void) const; /** Copy all entries of \b source to \b dest. \b dest must be an existing element. No memory is allocated by this * function. @@ -101,8 +95,7 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \param [in,out] dest This element's entries will be overwritten with the entries of \b source. * \note \a source and \a dest may point to the same element. */ - virtual void - t8_element_copy (const t8_element_t *source, t8_element_t *dest) const; + void element_copy (const t8_element_t *source, t8_element_t *dest) const; /** Compare two elements. * \param [in] elem1 The first element. @@ -110,8 +103,7 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \return negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - virtual int - t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -119,8 +111,7 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - virtual int - t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; + int element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -131,8 +122,7 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * this element must exist and match the element class of the parent. For a pyramid, for * example, it may be either a tetrahedron or a pyramid depending on \b elem's childid. */ - virtual void - t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const; + void element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; /** Compute a specific sibling of a given tri element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -143,37 +133,32 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \param [in,out] sibling This element's entries will be overwritten by those of \b elem's sibid-th sibling. * The storage for this element must existand match the element class of the sibling. */ - virtual void - t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; + void element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; /** Compute the number of faces of a given element. * \param [in] elem The element. * \return The number of faces of \a elem. */ - virtual int - t8_element_num_faces (const t8_element_t *elem) const; + int element_get_num_faces (const t8_element_t *elem) const; /** Compute the maximum number of faces of a given element and all of its descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - virtual int - t8_element_max_num_faces (const t8_element_t *elem) const; + int element_get_max_num_faces (const t8_element_t *elem) const; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - virtual int - t8_element_num_children (const t8_element_t *elem) const; + int element_get_num_children (const t8_element_t *elem) const; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - virtual int - t8_element_num_face_children (const t8_element_t *elem, int face) const; + int element_get_num_face_children (const t8_element_t *elem, int face) const; /** Return the corner number of an element's face corner. * \param [in] element The element. @@ -181,8 +166,7 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - virtual int - t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const; + int element_get_face_corner (const t8_element_t *element, int face, int corner) const; /** Return the face numbers of the faces sharing an element's corner. * \param [in] element The element. @@ -190,8 +174,7 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - virtual int - t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const; + int element_get_corner_face (const t8_element_t *element, int corner, int face) const; /** Construct the child element of a given number. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -200,8 +183,7 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * On output, a valid element. * It is valid to call this function with elem = child. */ - virtual void - t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const; + void element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -209,33 +191,29 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \param [in,out] c The storage for these \a length elements must exist and match the element class in the * children's ordering. On output, all children are valid. * It is valid to call this function with elem = c[0]. - * \see t8_element_num_children + * \see element_get_num_children */ - virtual void - t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; + void element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - virtual int - t8_element_child_id (const t8_element_t *elem) const; + int element_get_child_id (const t8_element_t *elem) const; /** Compute the ancestor id of an element, that is the child id at a given level. * \param [in] elem This must be a valid element. * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - virtual int - t8_element_ancestor_id (const t8_element_t *elem, int level) const; + int element_get_ancestor_id (const t8_element_t *elem, int level) const; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class \b ts has siblings. * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - virtual int - t8_element_is_family (t8_element_t *const *fam) const; + int elements_are_family (t8_element_t *const *fam) const; /** Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both * given elements as descendants. @@ -244,16 +222,14 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \param [in,out] nca The storage for this element must exist and match the element class of the child. On output * the unique nearest common ancestor of \b elem1 and \b elem2. */ - virtual void - t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; + void element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; /** Compute the shape of the face of an element. * \param [in] elem The element. * \param [in] face A face of \a elem. * \return The element shape of the face. */ - virtual t8_element_shape_t - t8_element_face_shape (const t8_element_t *elem, int face) const; + t8_element_shape_t element_get_face_shape (const t8_element_t *elem, int face) const; /** Given an element and a face of the element, compute all children of the element that touch the face. * \param [in] elem The element. @@ -261,14 +237,13 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \param [in,out] children Allocated elements, in which the children of \a elem that share a face with \a face are * stored. They will be stored in order of their linear id. * \param [in] num_children The number of elements in \a children. Must match the number of children that touch - * \a face. \ref t8_element_num_face_children + * \a face. \ref element_get_num_face_children * \param [in,out] child_indices If not NULL, an array of num_children integers must be given, * on output its i-th entry is the child_id of the i-th face_child. * It is valid to call this function with elem = children[0]. */ - virtual void - t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const; + void element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const; /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -285,11 +260,10 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \param [in] face Then number of the face. * \param [in] face_child A number 0 <= \a face_child < num_face_children, specifying a child of \a elem that shares * a face with \a face. These children are counted in linear order. This coincides with the - * order of children from a call to \ref t8_element_children_at_face. + * order of children from a call to \ref element_get_children_at_face. * \return The face number of the face of a child of \a elem that coincides with \a face_child. */ - virtual int - t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const; + int element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const; /** Given a face of an element return the face number of the parent of the element that matches the element's face. * Or return -1 if no face of the parent matches the face. @@ -298,8 +272,7 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \return If \a face of \a elem is also a face of \a elem's parent, the face number of this face. Otherwise -1. * \note For the root element this function always returns \a face. */ - virtual int - t8_element_face_parent_face (const t8_element_t *elem, int face) const; + int element_face_get_parent_face (const t8_element_t *elem, int face) const; /** Given an element and a face of this element. If the face lies on the tree boundary, return the face number of * the tree face. If not the return value is arbitrary. @@ -308,8 +281,7 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * \return The index of the tree face that \a face is a subface of, if \a face is on a tree boundary. Any arbitrary * integer if \a is not at a tree boundary. */ - virtual int - t8_element_tree_face (const t8_element_t *elem, int face) const; + int element_get_tree_face (const t8_element_t *elem, int face) const; /** Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the * trees and given the orientation of the tree connection, construct the face element of the respective tree @@ -325,9 +297,8 @@ struct t8_default_scheme_tri_c: public t8_default_scheme_common_c * flevel); @@ -286,31 +288,31 @@ t8_default_scheme_vertex_c::t8_element_to_string (const t8_element_t *elem, char #endif int -t8_default_scheme_vertex_c::t8_element_refines_irregular () const +t8_default_scheme_vertex_c::refines_irregular () const { /*vertices refine regularly */ return 0; } void -t8_default_scheme_vertex_c::t8_element_new (int length, t8_element_t **elem) const +t8_default_scheme_vertex_c::element_new (int length, t8_element_t **elem) const { /* allocate memory for a vertex */ - t8_default_scheme_common_c::t8_element_new (length, elem); + t8_default_scheme_common_c::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG { int i; for (i = 0; i < length; i++) { - t8_element_root (elem[i]); + get_root (elem[i]); } } #endif } void -t8_default_scheme_vertex_c::t8_element_init (int length, t8_element_t *elem) const +t8_default_scheme_vertex_c::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dvertex_t *vertexs = (t8_dvertex_t *) elem; @@ -338,16 +340,16 @@ t8_default_scheme_vertex_c::~t8_default_scheme_vertex_c () * and hence this empty function. */ } void -t8_default_scheme_vertex_c::t8_element_root (t8_element_t *elem) const +t8_default_scheme_vertex_c::get_root (t8_element_t *elem) const { t8_dvertex_t *vertex = (t8_dvertex_t *) elem; vertex->level = 0; } /* vertices are packed as the level */ void -t8_default_scheme_vertex_c::t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_vertex_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, + void *send_buffer, const int buffer_size, int *position, + sc_MPI_Comm comm) const { int mpiret; t8_dvertex_t **vertices = (t8_dvertex_t **) elements; @@ -359,7 +361,7 @@ t8_default_scheme_vertex_c::t8_element_MPI_Pack (t8_element_t **const elements, /* vertices are packed as the level */ void -t8_default_scheme_vertex_c::t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_vertex_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -374,9 +376,9 @@ t8_default_scheme_vertex_c::t8_element_MPI_Pack_size (const unsigned int count, /* vertices are packed as the level */ void -t8_default_scheme_vertex_c::t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_vertex_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, + sc_MPI_Comm comm) const { int mpiret; t8_dvertex_t **vertices = (t8_dvertex_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx index 2569bd8010..64b95deb9e 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx @@ -33,8 +33,9 @@ #include #include -struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c -{ +class t8_default_scheme_vertex_c: + public t8_eclass_scheme, + public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_vertex_c (); @@ -47,51 +48,51 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * On output all these pointers will point to an allocated * and initialized element. * \note Not every element that is created in t8code will be created by a call - * to this function. However, if an element is not created using \ref t8_element_new, - * then it is guaranteed that \ref t8_element_init is called on it. - * \note In debugging mode, an element that was created with \ref t8_element_new - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. - * \see t8_element_init - * \see t8_element_is_valid - */ - virtual void - t8_element_new (int length, t8_element_t **elem) const; + * to this function. However, if an element is not created using \ref element_new, + * then it is guaranteed that \ref element_init is called on it. + * \note In debugging mode, an element that was created with \ref element_new + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. + * \see element_init + * \see element_is_valid + */ + void + element_new (int length, t8_element_t **elem) const; /** Initialize an array of allocated vertex elements. * \param [in] length The number of vertex elements to be initialized. * \param [in,out] elems On input an array of \b length many allocated * elements. * \param [in] called_new True if the elements in \a elem were created by a call - * to \ref t8_element_new. False if no element in \a elem + * to \ref element_new. False if no element in \a elem * was created in this way. The case that only some elements - * were created by \ref t8_element_new should never occur. - * \note In debugging mode, an element that was passed to \ref t8_element_init - * must pass \ref t8_element_is_valid. - * \note If an element was created by \ref t8_element_new then \ref t8_element_init - * may not be called for it. Thus, \ref t8_element_new should initialize an element - * in the same way as a call to \ref t8_element_init would. + * were created by \ref element_new should never occur. + * \note In debugging mode, an element that was passed to \ref element_init + * must pass \ref element_is_valid. + * \note If an element was created by \ref element_new then \ref element_init + * may not be called for it. Thus, \ref element_new should initialize an element + * in the same way as a call to \ref element_init would. * Thus, if \a called_new is true this function should usually do nothing. - * \see t8_element_new - * \see t8_element_is_valid + * \see element_new + * \see element_is_valid */ - virtual void - t8_element_init (int length, t8_element_t *elem) const; + void + element_init (int length, t8_element_t *elem) const; /** Return the refinement level of an element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - virtual int - t8_element_level (const t8_element_t *elem) const; + int + element_get_level (const t8_element_t *elem) const; /** Return the maximum allowed level for this element class. * \return The maximum allowed level for elements of this class. */ - virtual int - t8_element_maxlevel (void) const; + int + get_maxlevel (void) const; /** Copy all entries of \b source to \b dest. \b dest must be an existing * element. No memory is allocated by this function. @@ -100,8 +101,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * entries of \b source. * \note \a source and \a dest may point to the same element. */ - virtual void - t8_element_copy (const t8_element_t *source, t8_element_t *dest) const; + void + element_copy (const t8_element_t *source, t8_element_t *dest) const; /** Compare two elements. * \param [in] elem1 The first element. @@ -110,8 +111,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * and positive if elem1 > elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - virtual int - t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -119,8 +120,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - virtual int - t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -134,8 +135,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * For a pyramid, for example, it may be either a * tetrahedron or a pyramid depending on \b elem's childid. */ - virtual void - t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const; + void + element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; /** Compute a specific sibling of a given vertex element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -148,46 +149,46 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * The storage for this element must exist * and match the element class of the sibling. */ - virtual void - t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; + void + element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; /** Compute the number of faces of a given element. * \param [in] elem The element. * \return The number of faces of \a elem. */ - virtual int - t8_element_num_faces (const t8_element_t *elem) const; + int + element_get_num_faces (const t8_element_t *elem) const; /** Compute the maximum number of faces of a given element and all of its * descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - virtual int - t8_element_max_num_faces (const t8_element_t *elem) const; + int + element_get_max_num_faces (const t8_element_t *elem) const; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - virtual int - t8_element_num_children (const t8_element_t *elem) const; + int + element_get_num_children (const t8_element_t *elem) const; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - virtual int - t8_element_num_face_children (const t8_element_t *elem, int face) const; + int + element_get_num_face_children (const t8_element_t *elem, int face) const; /** Return the corner number of an element's face corner. * \param [in] element The element. * \param [in] face A face index for \a element. * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - virtual int - t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const + int + element_get_face_corner (const t8_element_t *element, int face, int corner) const { SC_ABORT_NOT_REACHED (); /* it is impossible to have a face of a vertex */ return 0; /* prevents compiler warning */ @@ -199,8 +200,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - virtual int - t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const + int + element_get_corner_face (const t8_element_t *element, int corner, int face) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -214,8 +215,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * On output, a valid element. * It is valid to call this function with elem = child. */ - virtual void - t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const; + void + element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -225,17 +226,17 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * and match the element class in the children's ordering. * On output, all children are valid. * It is valid to call this function with elem = c[0]. - * \see t8_element_num_children + * \see element_get_num_children */ - virtual void - t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; + void + element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - virtual int - t8_element_child_id (const t8_element_t *elem) const; + int + element_get_child_id (const t8_element_t *elem) const; /** Compute the ancestor id of an element, that is the child id * at a given level. @@ -243,8 +244,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - virtual int - t8_element_ancestor_id (const t8_element_t *elem, int level) const; + int + element_get_ancestor_id (const t8_element_t *elem, int level) const; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class @@ -252,8 +253,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - virtual int - t8_element_is_family (t8_element_t *const *fam) const; + int + elements_are_family (t8_element_t *const *fam) const; /** Compute the nearest common ancestor of two elements. That is, * the element with highest level that still has both given elements as @@ -265,16 +266,16 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * On output the unique nearest common ancestor of * \b elem1 and \b elem2. */ - virtual void - t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; + void + element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; /** Compute the shape of the face of an element. * \param [in] elem The element. * \param [in] face A face of \a elem. * \return The element shape of the face. */ - virtual t8_element_shape_t - t8_element_face_shape (const t8_element_t *elem, int face) const + t8_element_shape_t + element_get_face_shape (const t8_element_t *elem, int face) const { SC_ABORT ("Not implemented.\n"); return T8_ECLASS_ZERO; /* prevents compiler warning */ @@ -289,14 +290,14 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * They will be stored in order of their linear id. * \param [in] num_children The number of elements in \a children. Must match * the number of children that touch \a face. - * \ref t8_element_num_face_children + * \ref element_get_num_face_children * \param [in,out] child_indices If not NULL, an array of num_children integers must be given, * on output its i-th entry is the child_id of the i-th face_child. * It is valid to call this function with elem = children[0]. */ - virtual void - t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const + void + element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const { SC_ABORT ("Not implemented.\n"); return; /* prevents compiler warning */ @@ -318,12 +319,12 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in] face_child A number 0 <= \a face_child < num_face_children, * specifying a child of \a elem that shares a face with \a face. * These children are counted in linear order. This coincides with - * the order of children from a call to \ref t8_element_children_at_face. + * the order of children from a call to \ref element_get_children_at_face. * \return The face number of the face of a child of \a elem * that coincides with \a face_child. */ - virtual int - t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const + int + element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -339,8 +340,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * the face number of this face. Otherwise -1. * \note For the root element this function always returns \a face. */ - virtual int - t8_element_face_parent_face (const t8_element_t *elem, int face) const + int + element_face_get_parent_face (const t8_element_t *elem, int face) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -355,8 +356,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \a face is on a tree boundary. * Any arbitrary integer if \a is not at a tree boundary. */ - virtual int - t8_element_tree_face (const t8_element_t *elem, int face) const + int + element_get_tree_face (const t8_element_t *elem, int face) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -383,9 +384,9 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * defined in relation to the smaller face. * \note \a elem1 and \a elem2 may point to the same element. */ - virtual void - t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, - int is_smaller_face) const; + void + element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, + int is_smaller_face) const; /** Given a boundary face inside a root tree's face construct * the element inside the root tree that has the given face as a @@ -400,9 +401,9 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \return The face number of the face of \a elem that coincides * with \a face. */ - virtual int - t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const + int + element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, + int root_face) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -416,8 +417,9 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the first descendant is constructed */ - virtual void - t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const + void + element_construct_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, + int level) const { SC_ABORT ("Not implemented.\n"); return; /* prevents compiler warning */ @@ -431,8 +433,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * that shares a face with \a face. * \param [in] level The level, at which the last descendant is constructed */ - virtual void - t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const + void + element_construct_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const { SC_ABORT ("Not implemented.\n"); return; /* prevents compiler warning */ @@ -447,9 +449,9 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * of the face of \a element. * \param [in] boundary_scheme The scheme for the eclass of the boundary face. */ - virtual void - t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_eclass_scheme_c *boundary_scheme) const + void + element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme_c *boundary_scheme) const { SC_ABORT ("Not implemented.\n"); return; /* prevents compiler warning */ @@ -460,8 +462,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in] face A face of \a elem. * \return True if \a face is a subface of the element's root element. */ - virtual int - t8_element_is_root_boundary (const t8_element_t *elem, int face) const; + int + element_is_root_boundary (const t8_element_t *elem, int face) const; /** Construct the face neighbor of a given element if this face neighbor * is inside the root tree. Return 0 otherwise. @@ -478,8 +480,9 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * False if not. In this case \a neigh's data can be arbitrary * on output. */ - virtual int - t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const + int + element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -492,8 +495,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in] id The linear id. * id must fulfil 0 <= id < 'number of leaves in the uniform refinement' */ - virtual void - t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; + void + element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; /** Compute the linear id of a given element in a hypothetical uniform * refinement of a given level. @@ -501,8 +504,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in] level The level of the uniform refinement to consider. * \return The linear id of the element. */ - virtual t8_linearidx_t - t8_element_get_linear_id (const t8_element_t *elem, int level) const; + t8_linearidx_t + element_get_linear_id (const t8_element_t *elem, int level) const; /** Compute the first descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -510,8 +513,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Compute the last descendant of a given element. * \param [in] elem The element whose descendant is computed. @@ -519,16 +522,16 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * of the given level. * \param [in] level The level, at which the descendant is computed. */ - virtual void - t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Construct the successor in a uniform refinement of a given element. * \param [in] elem1 The element whose successor should be constructed. * \param [in,out] elem2 The element whose entries will be set. * \param [in] level The level of the uniform refinement to consider. */ - virtual void - t8_element_successor (const t8_element_t *elem, t8_element_t *succ) const + void + element_construct_successor (const t8_element_t *elem, t8_element_t *succ) const { SC_ABORT ("Not implemented.\n"); return; /* prevents compiler warning */ @@ -544,8 +547,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in] elem The element. * \param [out] anchor The integer coordinates of the anchor node in the cube [0,1]^(dL) */ - virtual void - t8_element_anchor (const t8_element_t *elem, int anchor[3]) const; + void + element_get_anchor (const t8_element_t *elem, int anchor[3]) const; /** Compute the integer coordinates of a given element vertex. * The default scheme implements the Morton type SFCs. In these SFCs the @@ -557,8 +560,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [out] coords An array of at least as many integers as the element's dimension * whose entries will be filled with the coordinates of \a vertex. */ - virtual void - t8_element_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; + void + element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). @@ -569,8 +572,8 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \warning coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere * all coords might be used. */ - virtual void - t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; + void + element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; /** Convert points in the reference space of an element to points in the * reference space of the tree. @@ -582,34 +585,34 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [out] out_coords The coordinates of the points in the * reference space of the tree. */ - virtual void - t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + void + element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, + double *out_coords) const; /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because vertices refine regularly */ - virtual int - t8_element_refines_irregular (void) const; + int + refines_irregular (void) const; #ifdef T8_ENABLE_DEBUG /** Query whether a given element can be considered as 'valid' and it is * safe to perform any of the above algorithms on it. * \param [in] elem The element to be checked. * \return True if \a elem is safe to use. False otherwise. - * \note An element that is constructed with \ref t8_element_new + * \note An element that is constructed with \ref element_new * must pass this test. - * \note An element for which \ref t8_element_init was called must pass + * \note An element for which \ref element_init was called must pass * this test. * \note This function is used for debugging to catch certain errors. * These can for example occur when an element points to a region * of memory which should not be interpreted as an element. - * \note We recommend to use the assertion T8_ASSERT (t8_element_is_valid (elem)) + * \note We recommend to use the assertion T8_ASSERT (element_is_valid (elem)) * in the implementation of each of the functions in this file. */ - virtual int - t8_element_is_valid (const t8_element_t *t) const; + int + element_is_valid (const t8_element_t *t) const; /** * Print a given element. For a example for a triangle print the coordinates @@ -618,15 +621,15 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * * \param [in] elem The element to print */ - virtual void - t8_element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; + void + element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; #endif /** Fills an element with the root element. * \param [in,out] elem The element to be filled with root. */ void - t8_element_root (t8_element_t *elem) const; + get_root (t8_element_t *elem) const; /** Pack multiple elements into contiguous memory, so they can be sent via MPI. * \param [in] elements Array of elements that are to be packed @@ -636,17 +639,17 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in, out] position the position of the first byte that is not already packed * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, - int *position, sc_MPI_Comm comm) const; + void + element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, + int *position, sc_MPI_Comm comm) const; /** Determine an upper bound for the size of the packed message of \b count elements * \param [in] count Number of elements to pack * \param [in] comm MPI Communicator * \param [out] pack_size upper bound on the message size */ - virtual void - t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; + void + element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; /** Unpack multiple elements from contiguous memory that was received via MPI. * \param [in] recvbuf Buffer from which to unpack the elements @@ -656,7 +659,7 @@ struct t8_default_scheme_vertex_c: public t8_default_scheme_common_c * \param [in] count Number of elements to unpack * \param [in] comm MPI Communicator */ - virtual void - t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, - const unsigned int count, sc_MPI_Comm comm) const; + void + element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const unsigned int count, sc_MPI_Comm comm) const; }; diff --git a/src/t8_vtk/t8_vtk_write_ASCII.cxx b/src/t8_vtk/t8_vtk_write_ASCII.cxx index f2b7f45a24..6bbdd1eb4e 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.cxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.cxx @@ -76,7 +76,7 @@ typedef enum { T8_VTK_KERNEL_INIT, T8_VTK_KERNEL_EXECUTE, T8_VTK_KERNEL_CLEANUP */ typedef int (*t8_forest_vtk_cell_data_kernel) (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, const t8_locidx_t element_index, const t8_element_t *element, - t8_eclass_scheme_c *ts, const int is_ghost, FILE *vtufile, int *columns, + t8_scheme *ts, const int is_ghost, FILE *vtufile, int *columns, void **data, T8_VTK_KERNEL_MODUS modus); static t8_locidx_t @@ -88,7 +88,7 @@ t8_forest_num_points (t8_forest_t forest, const int count_ghosts) /* Get the tree that stores the elements */ t8_tree_t tree = (t8_tree_t) t8_sc_array_index_locidx (forest->trees, itree); /* Get the scheme of the current tree */ - t8_eclass_scheme *tscheme = t8_forest_get_eclass_scheme (forest, tree->eclass); + t8_scheme *tscheme = t8_forest_get_eclass_scheme (forest, tree->eclass); const size_t num_elements = t8_element_array_get_count (&tree->elements); for (t8_locidx_t ielem = 0; ielem < (t8_locidx_t) num_elements; ielem++) { const t8_element_t *elem = t8_element_array_index_locidx (&tree->elements, ielem); @@ -104,7 +104,7 @@ t8_forest_num_points (t8_forest_t forest, const int count_ghosts) t8_eclass_t ghost_class = t8_forest_ghost_get_tree_class (forest, itree); t8_element_array_t *ghost_elem = t8_forest_ghost_get_tree_elements (forest, itree); const size_t num_elements = t8_forest_ghost_tree_num_elements (forest, itree); - t8_eclass_scheme *tscheme = t8_forest_get_eclass_scheme (forest, ghost_class); + t8_scheme *tscheme = t8_forest_get_eclass_scheme (forest, ghost_class); for (t8_locidx_t ielem = 0; ielem < (t8_locidx_t) num_elements; ielem++) { const t8_element_t *elem = t8_element_array_index_locidx (ghost_elem, ielem); num_points += tscheme->t8_element_num_corners (elem); @@ -116,9 +116,9 @@ t8_forest_num_points (t8_forest_t forest, const int count_ghosts) static int t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, - t8_eclass_scheme_c *ts, const int is_ghost, FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, + const int is_ghost, FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { double element_coordinates[3]; int num_el_vertices, ivertex; @@ -162,9 +162,9 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree static int t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, - t8_eclass_scheme_c *ts, const int is_ghost, FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, + const int is_ghost, FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { int ivertex, num_vertices; int freturn; @@ -197,7 +197,7 @@ t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, const t8_locidx_t l static int t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_eclass_scheme_c *ts, + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, const int is_ghost, FILE *vtufile, int *columns, void **data, T8_VTK_KERNEL_MODUS modus) { @@ -230,7 +230,7 @@ t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, const t8_locidx_t ltree_i static int t8_forest_vtk_cells_type_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_eclass_scheme_c *ts, + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, const int is_ghost, FILE *vtufile, int *columns, void **data, T8_VTK_KERNEL_MODUS modus) { @@ -248,7 +248,7 @@ t8_forest_vtk_cells_type_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, static int t8_forest_vtk_cells_level_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_eclass_scheme_c *ts, + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, const int is_ghost, FILE *vtufile, int *columns, void **data, T8_VTK_KERNEL_MODUS modus) { @@ -261,7 +261,7 @@ t8_forest_vtk_cells_level_kernel (t8_forest_t forest, const t8_locidx_t ltree_id static int t8_forest_vtk_cells_rank_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_eclass_scheme_c *ts, + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, const int is_ghost, FILE *vtufile, int *columns, void **data, T8_VTK_KERNEL_MODUS modus) { @@ -274,7 +274,7 @@ t8_forest_vtk_cells_rank_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, static int t8_forest_vtk_cells_treeid_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_eclass_scheme_c *ts, + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, const int is_ghost, FILE *vtufile, int *columns, void **data, T8_VTK_KERNEL_MODUS modus) { @@ -296,9 +296,9 @@ t8_forest_vtk_cells_treeid_kernel (t8_forest_t forest, const t8_locidx_t ltree_i static int t8_forest_vtk_cells_elementid_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, - t8_eclass_scheme_c *ts, const int is_ghost, FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, + const int is_ghost, FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { if (modus == T8_VTK_KERNEL_EXECUTE) { if (!is_ghost) { @@ -315,7 +315,7 @@ t8_forest_vtk_cells_elementid_kernel (t8_forest_t forest, const t8_locidx_t ltre static int t8_forest_vtk_cells_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_eclass_scheme_c *ts, + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, const int is_ghost, FILE *vtufile, int *columns, void **data, T8_VTK_KERNEL_MODUS modus) { @@ -339,7 +339,7 @@ t8_forest_vtk_cells_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltree_i static int t8_forest_vtk_cells_vector_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_eclass_scheme_c *ts, + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, const int is_ghost, FILE *vtufile, int *columns, void **data, T8_VTK_KERNEL_MODUS modus) { @@ -370,9 +370,9 @@ t8_forest_vtk_cells_vector_kernel (t8_forest_t forest, const t8_locidx_t ltree_i /* The point data version of the scalar kernel */ static int t8_forest_vtk_vertices_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, - t8_eclass_scheme_c *ts, const int is_ghost, FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, + const int is_ghost, FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { double element_value = 0; int num_vertex, ivertex; @@ -400,9 +400,9 @@ t8_forest_vtk_vertices_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltre /* The point data version of the vector kernel */ static int t8_forest_vtk_vertices_vector_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, - t8_eclass_scheme_c *ts, const int is_ghost, FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, + const int is_ghost, FILE *vtufile, int *columns, void **data, + T8_VTK_KERNEL_MODUS modus) { double *element_values, null_vec[3] = { 0, 0, 0 }; int dim, idim; @@ -446,7 +446,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da t8_locidx_t element_index, elems_in_tree; t8_locidx_t num_local_trees, num_ghost_trees; t8_element_t *element; - t8_eclass_scheme_c *ts; + t8_scheme *ts; void *data = NULL; /* Write the connectivity information. diff --git a/src/t8_vtk/t8_vtk_writer_helper.cxx b/src/t8_vtk/t8_vtk_writer_helper.cxx index 976c403c88..01226780c0 100644 --- a/src/t8_vtk/t8_vtk_writer_helper.cxx +++ b/src/t8_vtk/t8_vtk_writer_helper.cxx @@ -40,7 +40,7 @@ t8_forest_vtk_get_element_nodes (t8_forest_t forest, t8_locidx_t ltreeid, const const int curved_flag, double *out_coords) { const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); - const t8_eclass_scheme_c *scheme = t8_forest_get_eclass_scheme (forest, tree_class); + const t8_scheme *scheme = t8_forest_get_eclass_scheme (forest, tree_class); const t8_element_shape_t element_shape = scheme->t8_element_shape (element); const double *ref_coords = t8_forest_vtk_point_to_element_ref_coords[element_shape][vertex]; const int num_node = t8_get_number_of_vtk_nodes (element_shape, curved_flag); @@ -161,7 +161,7 @@ t8_element_shape_t grid_element_shape (const t8_forest_t grid, const t8_locidx_t itree, const t8_element_t *element) { const t8_eclass_t eclass = t8_forest_get_eclass (grid, itree); - t8_eclass_scheme *scheme = t8_forest_get_eclass_scheme (grid, eclass); + t8_scheme *scheme = t8_forest_get_eclass_scheme (grid, eclass); return scheme->t8_element_shape (element); } @@ -197,7 +197,7 @@ int grid_element_level (const t8_forest_t grid, const t8_locidx_t itree, const t8_element_t *element) { const t8_eclass_t eclass = t8_forest_get_eclass (grid, itree); - t8_eclass_scheme *scheme = t8_forest_get_eclass_scheme (grid, eclass); + t8_scheme *scheme = t8_forest_get_eclass_scheme (grid, eclass); return scheme->t8_element_level (element); } template <> diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 81fb56630f..9cd7356d39 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -49,7 +49,7 @@ t8_forest_t make_grid () { t8_cmesh_t cmesh = make_grid (); - t8_scheme_cxx *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default_cxx (); return t8_forest_new_uniform (cmesh, scheme, 2, 0, sc_MPI_COMM_WORLD); } diff --git a/test/t8_forest/t8_gtest_balance.cxx b/test/t8_forest/t8_gtest_balance.cxx index 3d4e3062ba..4ad034cc9c 100644 --- a/test/t8_forest/t8_gtest_balance.cxx +++ b/test/t8_forest/t8_gtest_balance.cxx @@ -65,7 +65,7 @@ TEST_P (gtest_balance, confirm_is_balanced_check_for_uniform_forests) if (ieclass == t8_eclass_t::T8_ECLASS_PYRAMID && ido_periodic == 1) GTEST_SKIP_ ("The pyramid cube mesh cannot be periodic."); - t8_scheme_cxx_t *default_scheme = t8_scheme_new_default_cxx (); + t8_scheme *default_scheme = t8_scheme_new_default_cxx (); t8_cmesh_t cmesh = t8_cmesh_new_hypercube (ieclass, sc_MPI_COMM_WORLD, 0, 0, ido_periodic); t8_forest_t forest = t8_forest_new_uniform (cmesh, default_scheme, ilevel, 0, sc_MPI_COMM_WORLD); @@ -82,7 +82,7 @@ struct gtest_balance_adapt_data static int t8_gtest_balance_refine_certain_trees (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { gtest_balance_adapt_data *adapt_data = static_cast (t8_forest_get_user_data (forest)); @@ -161,7 +161,7 @@ t8_gtest_check_custom_balanced_forest (t8_forest_t balanced_forest, const t8_gloidx_t gtree_id = t8_forest_global_tree_id (balanced_forest, tree_id); - const t8_eclass_scheme_c *ts + const t8_scheme *ts = t8_forest_get_eclass_scheme (balanced_forest, t8_forest_get_tree_class (balanced_forest, tree_id)); for (t8_locidx_t elem_id = 0; elem_id < num_tree_local_elems; ++elem_id) { diff --git a/test/t8_forest/t8_gtest_element_is_leaf.cxx b/test/t8_forest/t8_gtest_element_is_leaf.cxx index 51d32755ae..bb95f7fec8 100644 --- a/test/t8_forest/t8_gtest_element_is_leaf.cxx +++ b/test/t8_forest/t8_gtest_element_is_leaf.cxx @@ -42,8 +42,7 @@ * imbalanced forest. */ static int t8_test_adapt_first_child (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, - t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { T8_ASSERT (!is_family || (is_family && num_elements == ts->t8_element_num_children (elements[0]))); @@ -98,7 +97,7 @@ class element_is_leaf: public testing::TestWithParamt8_element_new (1, ¬_leaf); diff --git a/test/t8_forest/t8_gtest_element_volume.cxx b/test/t8_forest/t8_gtest_element_volume.cxx index a44c990fe1..8873cb5b06 100644 --- a/test/t8_forest/t8_gtest_element_volume.cxx +++ b/test/t8_forest/t8_gtest_element_volume.cxx @@ -54,7 +54,7 @@ class t8_forest_volume: public testing::TestWithParam { } t8_eclass_t eclass; t8_cmesh_t cmesh; - t8_scheme_cxx_t *default_scheme; + t8_scheme *default_scheme; }; #if 0 @@ -82,7 +82,7 @@ TEST_P (forest_find_owner, find_owner) t8_eclass_to_string[eclass]); /* allocate the element */ - t8_eclass_scheme_c ts = scheme->eclass_schemes[eclass]; + t8_scheme ts = scheme->eclass_schemes[eclass]; ts->t8_element_new (1, &element); /* Compute the number of elements per tree */ ts->t8_element_root (element); @@ -95,7 +95,7 @@ TEST_P (forest_find_owner, find_owner) /* build the cmesh */ cmesh = t8_test_create_cmesh (itype, eclass, sc_MPI_COMM_WORLD); /* We reuse the scheme for all forests and thus ref it */ - t8_scheme_cxx_ref (default_scheme); + t8_schemexx_ref (default_scheme); /* build the forest */ t8_forest_t forest = t8_forest_new_uniform (cmesh, default_scheme, level, 0, @@ -130,7 +130,7 @@ TEST_P (forest_find_owner, find_owner) } /* clean-up */ ts->t8_element_destroy (1, &element); - t8_scheme_cxx_unref (&default_scheme); + t8_schemexx_unref (&default_scheme); } #endif @@ -145,7 +145,7 @@ TEST_P (forest_find_owner, find_multiple_owners) sc_array_init (&owners, sizeof (int)); /* Build a uniform forest */ t8_forest_t forest = t8_forest_new_uniform (cmesh, default_scheme, level, 0, sc_MPI_COMM_WORLD); - t8_eclass_scheme_c *ts = t8_forest_get_eclass_scheme (forest, eclass); + t8_scheme *ts = t8_forest_get_eclass_scheme (forest, eclass); /* Construct the root element */ ts->t8_element_new (1, &root_element); ts->t8_element_set_linear_id (root_element, 0, 0); diff --git a/test/t8_forest/t8_gtest_forest_commit.cxx b/test/t8_forest/t8_gtest_forest_commit.cxx index 3ab727f497..51c9bf55ab 100644 --- a/test/t8_forest/t8_gtest_forest_commit.cxx +++ b/test/t8_forest/t8_gtest_forest_commit.cxx @@ -63,7 +63,7 @@ class forest_commit: public testing::TestWithParam { * imbalanced forest. */ static int t8_test_adapt_balance (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { T8_ASSERT (!is_family || (is_family && num_elements == ts->t8_element_num_children (elements[0]))); @@ -137,7 +137,7 @@ TEST_P (forest_commit, test_forest_commit) const int level_step = 2; - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default_cxx (); /* Compute the first level, such that no process is empty */ int min_level = t8_forest_min_nonempty_level (cmesh, scheme); @@ -158,11 +158,11 @@ TEST_P (forest_commit, test_forest_commit) forest_abp_3part = t8_test_forest_commit_abp_3step (forest, maxlevel); ASSERT_TRUE (t8_forest_is_equal (forest_abp_3part, forest_ada_bal_part)) << "The forests are not equal"; - t8_scheme_cxx_ref (scheme); + t8_schemexx_ref (scheme); t8_forest_unref (&forest_ada_bal_part); t8_forest_unref (&forest_abp_3part); } - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); t8_debugf ("Done testing forest commit."); } diff --git a/test/t8_forest/t8_gtest_forest_face_normal.cxx b/test/t8_forest/t8_gtest_forest_face_normal.cxx index 659aa53ea9..8033e011cc 100644 --- a/test/t8_forest/t8_gtest_forest_face_normal.cxx +++ b/test/t8_forest/t8_gtest_forest_face_normal.cxx @@ -52,7 +52,7 @@ class class_forest_face_normal: public testing::TestWithParamt8_element_num_faces (element); @@ -82,7 +82,7 @@ TEST_P (class_forest_face_normal, back_and_forth) t8_element_t **neighbors; int num_neighbors; const int forest_is_balanced = 1; - t8_eclass_scheme_c *neigh_scheme; + t8_scheme *neigh_scheme; int *dual_faces; t8_locidx_t *neigh_ids; diff --git a/test/t8_forest/t8_gtest_ghost_and_owner.cxx b/test/t8_forest/t8_gtest_ghost_and_owner.cxx index aabe9822b0..6907bf8cab 100644 --- a/test/t8_forest/t8_gtest_ghost_and_owner.cxx +++ b/test/t8_forest/t8_gtest_ghost_and_owner.cxx @@ -54,15 +54,15 @@ class forest_ghost_owner: public testing::TestWithParam { TearDown () override { t8_cmesh_destroy (&cmesh); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } t8_cmesh_t cmesh; - t8_scheme_cxx_t *scheme; + t8_scheme *scheme; }; static int t8_test_gao_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { /* refine every second element up to the maximum level */ int level = ts->t8_element_level (elements[0]); @@ -128,7 +128,7 @@ TEST_P (forest_ghost_owner, test_ghost_owner) t8_debugf ("Testing ghost exchange with start level %i\n", min_level); for (int level = min_level; level < min_level + 3; level++) { /* ref the scheme since we reuse it */ - t8_scheme_cxx_ref (scheme); + t8_schemexx_ref (scheme); /* ref the cmesh since we reuse it */ t8_cmesh_ref (cmesh); /* Create a uniformly refined forest */ diff --git a/test/t8_forest/t8_gtest_ghost_delete.cxx b/test/t8_forest/t8_gtest_ghost_delete.cxx index 17f90d5cb3..191384c0b2 100644 --- a/test/t8_forest/t8_gtest_ghost_delete.cxx +++ b/test/t8_forest/t8_gtest_ghost_delete.cxx @@ -42,7 +42,7 @@ */ static int test_adapt_holes (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { double coordinates[3]; t8_forest_element_coordinate (forest_from, which_tree, elements[0], 0, coordinates); @@ -95,10 +95,10 @@ class DISABLED_forest_ghost_exchange_holes: public testing::Test { } sc_MPI_Barrier (sc_MPI_COMM_WORLD); t8_cmesh_unref (&cmesh); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } sc_MPI_Comm comm; - t8_scheme_cxx_t *scheme; + t8_scheme *scheme; t8_cmesh_t cmesh; }; @@ -110,7 +110,7 @@ TEST_F (DISABLED_forest_ghost_exchange_holes, errorTest) const int level = 1; const int execute_ghost = 1; t8_cmesh_ref (cmesh); - t8_scheme_cxx_ref (scheme); + t8_schemexx_ref (scheme); t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, level, 1, comm); forest = t8_forest_new_adapt (forest, test_adapt_holes, 0, execute_ghost, NULL); forest = t8_forest_new_adapt (forest, test_adapt_holes, 0, execute_ghost, NULL); diff --git a/test/t8_forest/t8_gtest_ghost_exchange.cxx b/test/t8_forest/t8_gtest_ghost_exchange.cxx index 9a9da8c2ed..279e9240b0 100644 --- a/test/t8_forest/t8_gtest_ghost_exchange.cxx +++ b/test/t8_forest/t8_gtest_ghost_exchange.cxx @@ -60,15 +60,15 @@ class forest_ghost_exchange: public testing::TestWithParam TearDown () override { t8_cmesh_destroy (&cmesh); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } - t8_scheme_cxx_t *scheme; + t8_scheme *scheme; t8_cmesh_t cmesh; }; static int t8_test_exchange_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { /* refine every second element up to the maximum level */ int level = ts->t8_element_level (elements[0]); @@ -88,7 +88,7 @@ t8_test_exchange_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t static void t8_test_ghost_exchange_data_id (t8_forest_t forest) { - t8_eclass_scheme_c *ts; + t8_scheme *ts; size_t array_pos = 0; sc_array_t element_data; @@ -177,7 +177,7 @@ TEST_P (forest_ghost_exchange, test_ghost_exchange) min_level = SC_MAX (min_level - 1, 0); for (int level = min_level; level < min_level + 3; level++) { /* ref the scheme since we reuse it */ - t8_scheme_cxx_ref (scheme); + t8_schemexx_ref (scheme); /* ref the cmesh since we reuse it */ t8_cmesh_ref (cmesh); /* Create a uniformly refined forest */ diff --git a/test/t8_forest/t8_gtest_half_neighbors.cxx b/test/t8_forest/t8_gtest_half_neighbors.cxx index 0b6088435c..4ffbde3d5d 100644 --- a/test/t8_forest/t8_gtest_half_neighbors.cxx +++ b/test/t8_forest/t8_gtest_half_neighbors.cxx @@ -50,7 +50,7 @@ class forest_half_neighbors: public testing::TestWithParamt8_element_num_faces (element); face++) { /* Get the eclass of the face neighbor and get the scheme */ const t8_eclass_t neigh_class = t8_forest_element_neighbor_eclass (forest, itree, element, face); - t8_eclass_scheme_c *neigh_scheme = t8_forest_get_eclass_scheme (forest, neigh_class); + t8_scheme *neigh_scheme = t8_forest_get_eclass_scheme (forest, neigh_class); const int num_face_neighs = ts->t8_element_num_face_children (element, face); t8_element_t **half_neighbors = T8_ALLOC (t8_element_t *, num_face_neighs); ts->t8_element_new (num_face_neighs, half_neighbors); diff --git a/test/t8_forest/t8_gtest_partition_data.cxx b/test/t8_forest/t8_gtest_partition_data.cxx index 9b850c4f01..4e19fa2ffb 100644 --- a/test/t8_forest/t8_gtest_partition_data.cxx +++ b/test/t8_forest/t8_gtest_partition_data.cxx @@ -198,8 +198,8 @@ TestPartitionData (const t8_forest_t initial_forest, const t8_forest_t partition */ static int t8_test_partition_data_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c* ts, const int is_family, - const int num_elements, t8_element_t* elements[]) + t8_locidx_t lelement_id, t8_scheme* ts, const int is_family, const int num_elements, + t8_element_t* elements[]) { const int level = ts->t8_element_level (elements[0]); const t8_gloidx_t gtree_id = t8_forest_global_tree_id (forest_from, which_tree); @@ -225,7 +225,7 @@ TEST (partition_data, test_partition_data) { /* Build a forest */ t8_cmesh_t cmesh = t8_cmesh_new_hypercube (T8_ECLASS_TRIANGLE, sc_MPI_COMM_WORLD, 0, 0, 0); - t8_scheme_cxx_t* scheme = t8_scheme_new_default_cxx (); + t8_scheme* scheme = t8_scheme_new_default_cxx (); t8_forest_t base_forest = t8_forest_new_uniform (cmesh, scheme, 1, 0, sc_MPI_COMM_WORLD); /* Adapt the forest examplary. */ diff --git a/test/t8_forest/t8_gtest_search.cxx b/test/t8_forest/t8_gtest_search.cxx index a4a9bb2712..17c63001a8 100644 --- a/test/t8_forest/t8_gtest_search.cxx +++ b/test/t8_forest/t8_gtest_search.cxx @@ -52,7 +52,7 @@ class forest_search: public testing::TestWithParam> { int level; t8_cmesh_t cmesh; t8_forest_t forest; - t8_scheme_cxx_t *default_scheme; + t8_scheme *default_scheme; }; /* A search function that matches all elements. @@ -70,7 +70,7 @@ t8_test_search_all_fn (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_e t8_locidx_t test_ltreeid; t8_element_t *test_element; t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); - t8_eclass_scheme_c *ts; + t8_scheme *ts; ts = t8_forest_get_eclass_scheme (forest, tree_class); tree_offset = t8_forest_get_tree_element_offset (forest, ltreeid); @@ -103,7 +103,7 @@ t8_test_search_query_all_fn (t8_forest_t forest, t8_locidx_t ltreeid, const t8_e /* Test whether tree_leaf_index is actually the index of the element */ t8_locidx_t test_ltreeid; t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); - t8_eclass_scheme_c *ts; + t8_scheme *ts; ts = t8_forest_get_eclass_scheme (forest, tree_class); t8_locidx_t tree_offset = t8_forest_get_tree_element_offset (forest, ltreeid); diff --git a/test/t8_forest/t8_gtest_transform.cxx b/test/t8_forest/t8_gtest_transform.cxx index fcd62185c7..4926ebcecf 100644 --- a/test/t8_forest/t8_gtest_transform.cxx +++ b/test/t8_forest/t8_gtest_transform.cxx @@ -65,13 +65,13 @@ class forest_transform: public testing::TestWithParam } t8_eclass_t eclass; t8_cmesh_t cmesh; - t8_scheme_cxx_t *default_scheme; + t8_scheme *default_scheme; t8_forest_t forest; int level; }; static void -t8_test_transform_element (t8_eclass_scheme_c *ts, const t8_element_t *elem, t8_eclass_t eclass) +t8_test_transform_element (t8_scheme *ts, const t8_element_t *elem, t8_eclass_t eclass) { t8_element_t *transform; diff --git a/test/t8_forest/t8_gtest_user_data.cxx b/test/t8_forest/t8_gtest_user_data.cxx index 9eb99014db..23513b4c13 100644 --- a/test/t8_forest/t8_gtest_user_data.cxx +++ b/test/t8_forest/t8_gtest_user_data.cxx @@ -38,7 +38,7 @@ TEST (user_data, test_user_data) { /* Build a forest */ t8_cmesh_t cmesh = t8_cmesh_new_hypercube (T8_ECLASS_TRIANGLE, sc_MPI_COMM_WORLD, 0, 0, 0); - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default_cxx (); t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, 1, 0, sc_MPI_COMM_WORLD); /* Define user data */ double data = 42.42; @@ -96,7 +96,7 @@ TEST (user_data, test_user_function) { /* Build a forest */ t8_cmesh_t cmesh = t8_cmesh_new_hypercube (T8_ECLASS_TRIANGLE, sc_MPI_COMM_WORLD, 0, 0, 0); - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default_cxx (); t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, 1, 0, sc_MPI_COMM_WORLD); double (*funpointer) (int); diff --git a/test/t8_forest_incomplete/t8_gtest_empty_global_tree.cxx b/test/t8_forest_incomplete/t8_gtest_empty_global_tree.cxx index fe756f831f..67073496f1 100644 --- a/test/t8_forest_incomplete/t8_gtest_empty_global_tree.cxx +++ b/test/t8_forest_incomplete/t8_gtest_empty_global_tree.cxx @@ -62,7 +62,7 @@ class DISABLED_global_tree: public testing::TestWithParamremove[forest_from->mpirank] == 0) { diff --git a/test/t8_forest_incomplete/t8_gtest_iterate_replace.cxx b/test/t8_forest_incomplete/t8_gtest_iterate_replace.cxx index 3fb176b8da..0279c3e9b0 100644 --- a/test/t8_forest_incomplete/t8_gtest_iterate_replace.cxx +++ b/test/t8_forest_incomplete/t8_gtest_iterate_replace.cxx @@ -71,9 +71,8 @@ struct t8_return_data * If true, we check the parameter \a num_outgoing, \a first_outgoing * \a num_incoming and \a first_incoming for correctness. */ void -t8_forest_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, t8_eclass_scheme_c *ts, - int refine, int num_outgoing, t8_locidx_t first_outgoing, int num_incoming, - t8_locidx_t first_incoming) +t8_forest_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, t8_scheme *ts, int refine, + int num_outgoing, t8_locidx_t first_outgoing, int num_incoming, t8_locidx_t first_incoming) { /* Note, the new forest contains the callback returns of the old forest */ struct t8_return_data *adapt_data = (struct t8_return_data *) t8_forest_get_user_data (forest_new); @@ -145,7 +144,7 @@ t8_forest_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t w */ int t8_adapt_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { struct t8_return_data *return_data = (struct t8_return_data *) t8_forest_get_user_data (forest); T8_ASSERT (return_data != NULL); diff --git a/test/t8_forest_incomplete/t8_gtest_permute_hole.cxx b/test/t8_forest_incomplete/t8_gtest_permute_hole.cxx index 1c6ed01b59..6f0ac431a3 100644 --- a/test/t8_forest_incomplete/t8_gtest_permute_hole.cxx +++ b/test/t8_forest_incomplete/t8_gtest_permute_hole.cxx @@ -102,7 +102,7 @@ struct t8_elements * the current permutation \a remove is 0. */ static int t8_adapt_remove (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { struct t8_elements *data = (struct t8_elements *) t8_forest_get_user_data (forest); if (data->remove[lelement_id] == 0) { @@ -114,7 +114,7 @@ t8_adapt_remove (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_ /** Coarse every (incomplete) family */ static int t8_adapt_coarse (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { if (is_family) { return -1; diff --git a/test/t8_forest_incomplete/t8_gtest_recursive.cxx b/test/t8_forest_incomplete/t8_gtest_recursive.cxx index e2c3ed327e..db3cb5100d 100644 --- a/test/t8_forest_incomplete/t8_gtest_recursive.cxx +++ b/test/t8_forest_incomplete/t8_gtest_recursive.cxx @@ -49,7 +49,7 @@ class recursive_tree: public testing::TestWithParam { cmesh = t8_cmesh_new_bigmesh (eclass, MPI_size, sc_MPI_COMM_WORLD); scheme = t8_scheme_new_default_cxx (); - t8_scheme_cxx_ref (scheme); + t8_schemexx_ref (scheme); t8_cmesh_ref (cmesh); /* The forest to be adapted. */ @@ -65,7 +65,7 @@ class recursive_tree: public testing::TestWithParam { } int MPI_size; t8_eclass_t eclass; - t8_scheme_cxx_t *scheme; + t8_scheme *scheme; t8_cmesh_t cmesh; t8_forest_t forest; t8_forest_t forest_base; @@ -74,8 +74,8 @@ class recursive_tree: public testing::TestWithParam { /** Remove every element except last and first of a family. */ static int t8_adapt_remove_but_last_first (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]) + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { const int num_children = ts->t8_element_num_children (elements[0]); const int child_id = ts->t8_element_child_id (elements[0]); @@ -88,7 +88,7 @@ t8_adapt_remove_but_last_first (t8_forest_t forest, t8_forest_t forest_from, t8_ /** Refine the first element of a family. */ static int t8_adapt_refine_first (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { const int level = ts->t8_element_level (elements[0]); const int level_max = ts->t8_element_maxlevel (); @@ -102,7 +102,7 @@ t8_adapt_refine_first (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t /** Refine every element. */ static int t8_adapt_refine_all (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { return 1; } @@ -110,7 +110,7 @@ t8_adapt_refine_all (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t wh /** Coarse every family. */ static int t8_adapt_coarse_all (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { if (is_family) { return -1; diff --git a/test/t8_geometry/t8_gtest_point_inside.cxx b/test/t8_geometry/t8_gtest_point_inside.cxx index da28c40a05..103eb4db86 100644 --- a/test/t8_geometry/t8_gtest_point_inside.cxx +++ b/test/t8_geometry/t8_gtest_point_inside.cxx @@ -170,7 +170,7 @@ TEST_P (geometry_point_inside, test_point_inside) t8_debugf ("Testing eclass %s, uniform level %i with approx. %i points per element.\n", t8_eclass_to_string[eclass], level, num_points_to_generate); - t8_scheme_cxx_t *default_scheme = t8_scheme_new_default_cxx (); + t8_scheme *default_scheme = t8_scheme_new_default_cxx (); /* We translate the coordinates of the cmesh to create a non-standard case. * In particular, we want the 1D and 2D elements to move outside of axis @@ -203,7 +203,7 @@ TEST_P (geometry_point_inside, test_point_inside) const t8_locidx_t num_elements = t8_forest_get_tree_num_elements (forest, itree); /* Get the associated eclass scheme */ const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, itree); - const t8_eclass_scheme_c *eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); + const t8_scheme *eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); for (t8_locidx_t ielement = 0; ielement < num_elements; ++ielement) { /* Get a pointer to the element */ const t8_element_t *element = t8_forest_get_element_in_tree (forest, itree, ielement); diff --git a/test/t8_gtest_custom_assertion.hxx b/test/t8_gtest_custom_assertion.hxx index e5cb271576..a0638d09ea 100644 --- a/test/t8_gtest_custom_assertion.hxx +++ b/test/t8_gtest_custom_assertion.hxx @@ -43,7 +43,7 @@ * \return testing::AssertionResult */ testing::AssertionResult -element_equality (const char *ts_expr, const char *elem_1_expr, const char *elem_2_expr, const t8_eclass_scheme_c *ts, +element_equality (const char *ts_expr, const char *elem_1_expr, const char *elem_2_expr, const t8_scheme_c *ts, const t8_element_t *elem_1, const t8_element_t *elem_2) { if (ts->t8_element_equal (elem_1, elem_2)) { diff --git a/test/t8_schemes/t8_gtest_ancestor.cxx b/test/t8_schemes/t8_gtest_ancestor.cxx index 05ca3df634..33ca059b8e 100644 --- a/test/t8_schemes/t8_gtest_ancestor.cxx +++ b/test/t8_schemes/t8_gtest_ancestor.cxx @@ -51,7 +51,7 @@ class ancestor: public testing::TestWithParam { ts->t8_element_destroy (1, &correct_ancestor); ts->t8_element_destroy (1, &desc_a); ts->t8_element_destroy (1, &check); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } /* correct_nca -> the nearest common ancestor that we check for * desc_a -> a descendant of correct_nca @@ -59,15 +59,15 @@ class ancestor: public testing::TestWithParam { * check -> the computed nca of desc_a and desc_b, should be equal to correct_nca */ t8_element_t *correct_ancestor, *desc_a, *check; - t8_scheme_cxx *scheme; - t8_eclass_scheme_c *ts; + t8_scheme *scheme; + t8_scheme *ts; t8_eclass_t eclass; }; /*Test root and parent*/ static void t8_recursive_ancestor (t8_element_t *element, t8_element_t *child, t8_element_t *parent, t8_element_t *test_ancestor, - t8_eclass_scheme_c *ts, const int maxlvl) + t8_scheme *ts, const int maxlvl) { int num_children, i; int level = ts->t8_element_level (parent); diff --git a/test/t8_schemes/t8_gtest_boundary_extrude.cxx b/test/t8_schemes/t8_gtest_boundary_extrude.cxx index 7f64b3db32..e743f25ffa 100644 --- a/test/t8_schemes/t8_gtest_boundary_extrude.cxx +++ b/test/t8_schemes/t8_gtest_boundary_extrude.cxx @@ -42,7 +42,7 @@ class class_test_boundary_extrude: public TestDFS { /* Get face scheme */ const int tree_face = ts->t8_element_tree_face (element, iface); const t8_eclass_t face_eclass = (t8_eclass_t) t8_eclass_face_types[eclass][tree_face]; - const t8_eclass_scheme_c *face_ts = scheme->eclass_schemes[face_eclass]; + const t8_scheme *face_ts = scheme->eclass_schemes[face_eclass]; t8_element_t *boundary; face_ts->t8_element_new (1, &boundary); diff --git a/test/t8_schemes/t8_gtest_default.cxx b/test/t8_schemes/t8_gtest_default.cxx index aab7410d43..84573ac09e 100644 --- a/test/t8_schemes/t8_gtest_default.cxx +++ b/test/t8_schemes/t8_gtest_default.cxx @@ -78,7 +78,7 @@ class gtest_default_scheme: public testing::TestWithParam { { delete (eclass_scheme); } - t8_eclass_scheme_c *eclass_scheme; + t8_scheme *eclass_scheme; }; TEST_P (gtest_default_scheme, is_default) diff --git a/test/t8_schemes/t8_gtest_descendant.cxx b/test/t8_schemes/t8_gtest_descendant.cxx index 2461ec138a..a4fb77735f 100644 --- a/test/t8_schemes/t8_gtest_descendant.cxx +++ b/test/t8_schemes/t8_gtest_descendant.cxx @@ -48,7 +48,7 @@ class class_schemes_descendant: public testing::TestWithParam { ts->t8_element_destroy (1, &elem); ts->t8_element_destroy (1, &desc); ts->t8_element_destroy (1, &test); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } #ifdef T8_ENABLE_DEBUG const int maxlvl = 3; @@ -56,8 +56,8 @@ class class_schemes_descendant: public testing::TestWithParam { const int maxlvl = 4; #endif - t8_scheme_cxx *scheme; - t8_eclass_scheme_c *ts; + t8_scheme *scheme; + t8_scheme *ts; t8_eclass_t eclass; t8_element_t *elem; t8_element_t *desc; @@ -68,7 +68,7 @@ class class_schemes_descendant: public testing::TestWithParam { * computed correctly. Only the descendant of elem->level + 1 is tested. */ static void -t8_recursive_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_eclass_scheme_c *ts, int maxlvl) +t8_recursive_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_scheme *ts, int maxlvl) { const int num_children = ts->t8_element_num_children (elem); const int level = ts->t8_element_level (elem); @@ -95,7 +95,7 @@ t8_recursive_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *t * of levels. */ static void -t8_deep_first_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_eclass_scheme_c *ts, int level) +t8_deep_first_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_scheme *ts, int level) { const int elem_level = ts->t8_element_level (elem); ts->t8_element_copy (elem, test); @@ -112,7 +112,7 @@ t8_deep_first_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t * * of levels. */ static void -t8_deep_last_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_eclass_scheme_c *ts, int level) +t8_deep_last_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_scheme *ts, int level) { ts->t8_element_copy (elem, test); @@ -131,8 +131,7 @@ t8_deep_last_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *t * The level between the element and the descendant is larger or equal to one. */ static void -t8_large_step_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_eclass_scheme_c *ts, - int maxlvl) +t8_large_step_descendant (t8_element_t *elem, t8_element_t *desc, t8_element_t *test, t8_scheme *ts, int maxlvl) { for (int ilevel = ts->t8_element_level (elem); ilevel < maxlvl; ilevel++) { diff --git a/test/t8_schemes/t8_gtest_dfs_base.hxx b/test/t8_schemes/t8_gtest_dfs_base.hxx index 4b369197f3..95aaef49f4 100644 --- a/test/t8_schemes/t8_gtest_dfs_base.hxx +++ b/test/t8_schemes/t8_gtest_dfs_base.hxx @@ -83,9 +83,9 @@ class TestDFS: public testing::TestWithParam { dfs_test_teardown (); } - t8_scheme_cxx *scheme; + t8_scheme *scheme; t8_eclass_t eclass; - t8_eclass_scheme_c *ts; + t8_scheme_c *ts; t8_element_t *element; }; diff --git a/test/t8_schemes/t8_gtest_element_count_leaves.cxx b/test/t8_schemes/t8_gtest_element_count_leaves.cxx index 4c11780f2f..a434b26ada 100644 --- a/test/t8_schemes/t8_gtest_element_count_leaves.cxx +++ b/test/t8_schemes/t8_gtest_element_count_leaves.cxx @@ -46,11 +46,11 @@ class class_element_leaves: public testing::TestWithParam { void TearDown () override { - t8_scheme_cxx_unref (&ts); + t8_schemexx_unref (&ts); } t8_eclass eclass; - t8_eclass_scheme_c *class_scheme; - t8_scheme_cxx_t *ts = t8_scheme_new_default_cxx (); + t8_scheme *class_scheme; + t8_scheme *ts = t8_scheme_new_default_cxx (); }; TEST_P (class_element_leaves, test_element_count_leaves_root) diff --git a/test/t8_schemes/t8_gtest_element_ref_coords.cxx b/test/t8_schemes/t8_gtest_element_ref_coords.cxx index fa7e6ed0b9..6d81ec4af3 100644 --- a/test/t8_schemes/t8_gtest_element_ref_coords.cxx +++ b/test/t8_schemes/t8_gtest_element_ref_coords.cxx @@ -71,7 +71,7 @@ t8_write_message_by_dim (const char *message, const T *array, const int dim) * \param [out] coordinates The coordinates of the centroid. */ void -t8_element_centroid_by_vertex_coords (const t8_forest_t forest, const t8_eclass_scheme_c *ts, const t8_locidx_t ltreeid, +t8_element_centroid_by_vertex_coords (const t8_forest_t forest, const t8_scheme *ts, const t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates) { double vertex_ref_coords[3], vertex_out_coords[3]; @@ -182,8 +182,7 @@ t8_compare_arrays (const double *array1, const double *array2, const int dim, co * \param [in] ts The element class scheme. */ void -t8_test_coords (const t8_forest_t forest, const t8_locidx_t ltree_id, const t8_element_t *element, - const t8_eclass_scheme_c *ts) +t8_test_coords (const t8_forest_t forest, const t8_locidx_t ltree_id, const t8_element_t *element, const t8_scheme *ts) { double tree_ref_coords_by_vertex [3]; /** reference coordinates of the element vertices computed by \ref t8_element_vertex_reference_coords */ @@ -250,7 +249,7 @@ TEST_P (class_ref_coords, t8_check_elem_ref_coords) /* Check the reference coordinates of each element in each tree */ for (itree = 0; itree < t8_forest_get_num_local_trees (forest); itree++) { const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, itree); - const t8_eclass_scheme_c *ts = t8_forest_get_eclass_scheme (forest, tree_class); + const t8_scheme *ts = t8_forest_get_eclass_scheme (forest, tree_class); for (ielement = 0; ielement < t8_forest_get_tree_num_elements (forest, itree); ielement++) { const t8_element_t *element = t8_forest_get_element_in_tree (forest, itree, ielement); t8_test_coords (forest, itree, element, ts); diff --git a/test/t8_schemes/t8_gtest_face_descendant.cxx b/test/t8_schemes/t8_gtest_face_descendant.cxx index 6d12e21b5b..c0c06ca190 100644 --- a/test/t8_schemes/t8_gtest_face_descendant.cxx +++ b/test/t8_schemes/t8_gtest_face_descendant.cxx @@ -29,7 +29,7 @@ /* compute the first/last descendant by iteratively taking the first/last child at each level*/ static void -t8_test_manual_first_last_face_descendant (const t8_eclass_scheme_c *ts, const t8_element_t *element, const int iface, +t8_test_manual_first_last_face_descendant (const t8_scheme *ts, const t8_element_t *element, const int iface, const int desc_level, const int last, t8_element_t *face_desc) { const int num_children_at_face = ts->t8_element_num_face_children (element, iface); diff --git a/test/t8_schemes/t8_gtest_face_neigh.cxx b/test/t8_schemes/t8_gtest_face_neigh.cxx index 6e3838ec57..57af14048b 100644 --- a/test/t8_schemes/t8_gtest_face_neigh.cxx +++ b/test/t8_schemes/t8_gtest_face_neigh.cxx @@ -51,13 +51,13 @@ class face_neigh: public testing::TestWithParam { ts->t8_element_destroy (1, &element); ts->t8_element_destroy (1, &child); ts->t8_element_destroy (1, &neigh); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } t8_element_t *element; t8_element_t *child; t8_element_t *neigh; - t8_scheme_cxx *scheme; - t8_eclass_scheme_c *ts; + t8_scheme *scheme; + t8_scheme *ts; t8_eclass_t eclass; #ifdef T8_ENABLE_LESS_TESTS @@ -70,7 +70,7 @@ class face_neigh: public testing::TestWithParam { void t8_test_face_neighbor_inside (int num_faces, t8_element_t *element, t8_element_t *child, t8_element_t *neigh, - t8_eclass_scheme_c *ts) + t8_scheme *ts) { int face_num; int check; @@ -87,8 +87,7 @@ t8_test_face_neighbor_inside (int num_faces, t8_element_t *element, t8_element_t } int -t8_test_get_middle_child (t8_eclass_t eclass, int ilevel, t8_element_t *element, t8_element_t *child, - t8_eclass_scheme_c *ts) +t8_test_get_middle_child (t8_eclass_t eclass, int ilevel, t8_element_t *element, t8_element_t *child, t8_scheme *ts) { /* Get the child number of the child in the middle of the element, depending of the shape of the element. */ switch (eclass) { @@ -172,8 +171,8 @@ TEST_P (face_neigh, check_not_inside_root) } void -t8_recursive_check_diff (t8_element_t *element, t8_element_t *child, t8_element_t *neigh, t8_eclass_scheme_c *ts, - int maxlvl, int level) +t8_recursive_check_diff (t8_element_t *element, t8_element_t *child, t8_element_t *neigh, t8_scheme *ts, int maxlvl, + int level) { T8_ASSERT (level <= maxlvl && maxlvl <= ts->t8_element_maxlevel () - 1); diff --git a/test/t8_schemes/t8_gtest_init_linear_id.cxx b/test/t8_schemes/t8_gtest_init_linear_id.cxx index 7e2e6c419b..8a9e0a0077 100644 --- a/test/t8_schemes/t8_gtest_init_linear_id.cxx +++ b/test/t8_schemes/t8_gtest_init_linear_id.cxx @@ -47,20 +47,20 @@ class linear_id: public testing::TestWithParam { ts->t8_element_destroy (1, &element); ts->t8_element_destroy (1, &child); ts->t8_element_destroy (1, &test); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } t8_element_t *element; t8_element_t *child; t8_element_t *test; - t8_scheme_cxx *scheme; - t8_eclass_scheme_c *ts; + t8_scheme *scheme; + t8_scheme *ts; t8_eclass_t eclass; sc_MPI_Comm comm = sc_MPI_COMM_WORLD; }; static int t8_test_init_linear_id_refine_everything (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { return 1; @@ -80,7 +80,7 @@ TEST_P (linear_id, uniform_forest) cmesh = t8_cmesh_new_from_class (ts->eclass, comm); t8_cmesh_ref (cmesh); forest = t8_forest_new_uniform (cmesh, scheme, 0, 0, comm); - t8_scheme_cxx_ref (scheme); + t8_schemexx_ref (scheme); for (int level = 0; level < maxlvl; level++) { /*Get the number of local trees*/ const t8_locidx_t num_local_trees = t8_forest_get_num_local_trees (forest); @@ -90,7 +90,7 @@ TEST_P (linear_id, uniform_forest) const t8_locidx_t num_elements_in_tree = t8_forest_get_tree_num_elements (forest, tree_id); /*Manually compute the id of the first element*/ const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, tree_id); - t8_eclass_scheme_c *tc_scheme = t8_forest_get_eclass_scheme (forest, tree_class); + t8_scheme *tc_scheme = t8_forest_get_eclass_scheme (forest, tree_class); const t8_locidx_t shift = tc_scheme->t8_element_count_leaves_from_root (level) - num_elements_in_tree; /*Iterate over elements */ for (t8_locidx_t id_iter = 0; id_iter < num_elements_in_tree; id_iter++) { diff --git a/test/t8_schemes/t8_gtest_nca.cxx b/test/t8_schemes/t8_gtest_nca.cxx index e78a07ece0..a8cbb8a0d2 100644 --- a/test/t8_schemes/t8_gtest_nca.cxx +++ b/test/t8_schemes/t8_gtest_nca.cxx @@ -52,7 +52,7 @@ class nca: public testing::TestWithParam { ts->t8_element_destroy (1, &desc_a); ts->t8_element_destroy (1, &desc_b); ts->t8_element_destroy (1, &check); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } /* correct_nca -> the nearest common ancestor that we check for * desc_a -> a descendant of correct_nca @@ -60,8 +60,8 @@ class nca: public testing::TestWithParam { * check -> the computed nca of desc_a and desc_b, should be equal to correct_nca */ t8_element_t *correct_nca, *desc_a, *desc_b, *check; - t8_scheme_cxx *scheme; - t8_eclass_scheme_c *ts; + t8_scheme *scheme; + t8_scheme *ts; t8_eclass_t eclass; }; @@ -156,7 +156,7 @@ TEST_P (nca, nca_check_deep) */ static void t8_recursive_nca_check (t8_element_t *check_nca, t8_element_t *desc_a, t8_element_t *desc_b, t8_element_t *check, - t8_element_t *parent_a, t8_element_t *parent_b, const int max_lvl, t8_eclass_scheme_c *ts) + t8_element_t *parent_a, t8_element_t *parent_b, const int max_lvl, t8_scheme *ts) { T8_ASSERT (max_lvl <= ts->t8_element_maxlevel () - 1); /* compute the level of the parents */ diff --git a/test/t8_schemes/t8_gtest_root.cxx b/test/t8_schemes/t8_gtest_root.cxx index 63d546c6b4..baa7d5b9e4 100644 --- a/test/t8_schemes/t8_gtest_root.cxx +++ b/test/t8_schemes/t8_gtest_root.cxx @@ -44,11 +44,11 @@ class root: public testing::TestWithParam { TearDown () override { ts->t8_element_destroy (1, &element); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } t8_element_t *element; - t8_scheme_cxx *scheme; - t8_eclass_scheme_c *ts; + t8_scheme *scheme; + t8_scheme *ts; t8_eclass_t eclass; }; diff --git a/test/t8_schemes/t8_gtest_successor.cxx b/test/t8_schemes/t8_gtest_successor.cxx index 2b7a465a48..c3d5690c25 100644 --- a/test/t8_schemes/t8_gtest_successor.cxx +++ b/test/t8_schemes/t8_gtest_successor.cxx @@ -53,11 +53,11 @@ class class_successor: public testing::TestWithParam { ts->t8_element_destroy (1, &child); ts->t8_element_destroy (1, &last); - t8_scheme_cxx_unref (&scheme); + t8_schemexx_unref (&scheme); } t8_eclass_t eclass; - t8_eclass_scheme_c *ts; - t8_scheme_cxx *scheme; + t8_scheme *ts; + t8_scheme *scheme; t8_element_t *element; t8_element_t *successor; t8_element_t *child; @@ -70,7 +70,7 @@ class class_successor: public testing::TestWithParam { */ static void t8_recursive_successor (t8_element_t *element, t8_element_t *successor, t8_element_t *child, t8_element_t *last, - t8_eclass_scheme_c *ts, const int maxlvl) + t8_scheme *ts, const int maxlvl) { const int level = ts->t8_element_level (element); ASSERT_TRUE (ts->t8_element_level (element) <= maxlvl && maxlvl <= ts->t8_element_maxlevel () - 1); @@ -113,7 +113,7 @@ t8_recursive_successor (t8_element_t *element, t8_element_t *successor, t8_eleme * maximum level are computed. The successor runs through all these children. */ static void -t8_deep_successor (t8_element_t *element, t8_element_t *successor, t8_element_t *child, t8_eclass_scheme_c *ts) +t8_deep_successor (t8_element_t *element, t8_element_t *successor, t8_element_t *child, t8_scheme *ts) { int maxlvl = ts->t8_element_maxlevel (); int num_children = ts->t8_element_num_children (element); diff --git a/tutorials/features/t8_features_curved_meshes.cxx b/tutorials/features/t8_features_curved_meshes.cxx index 1e9bb47078..f234607963 100644 --- a/tutorials/features/t8_features_curved_meshes.cxx +++ b/tutorials/features/t8_features_curved_meshes.cxx @@ -85,8 +85,8 @@ struct t8_naca_geometry_adapt_data */ int t8_naca_geometry_adapt_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]) + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { /* We retrieve the adapt data */ const struct t8_naca_geometry_adapt_data *adapt_data @@ -228,8 +228,8 @@ struct t8_naca_plane_adapt_data */ int t8_naca_plane_adapt_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_eclass_scheme_c *ts, const int is_family, - const int num_elements, t8_element_t *elements[]) + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { double elem_midpoint[3]; int elem_level; diff --git a/tutorials/general/t8_step2_uniform_forest.cxx b/tutorials/general/t8_step2_uniform_forest.cxx index 40bc03e2ed..956a48fc53 100644 --- a/tutorials/general/t8_step2_uniform_forest.cxx +++ b/tutorials/general/t8_step2_uniform_forest.cxx @@ -81,7 +81,7 @@ static t8_forest_t t8_step2_build_uniform_forest (sc_MPI_Comm comm, t8_cmesh_t cmesh, int level) { t8_forest_t forest; - t8_scheme_cxx_t *scheme; + t8_scheme *scheme; /* Create the refinement scheme. */ scheme = t8_scheme_new_default_cxx (); diff --git a/tutorials/general/t8_step3.h b/tutorials/general/t8_step3.h index 9bd4be4760..9d41db3be3 100644 --- a/tutorials/general/t8_step3.h +++ b/tutorials/general/t8_step3.h @@ -74,7 +74,7 @@ t8_step3_adapt_forest (t8_forest_t forest); */ int t8_step3_adapt_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]); + t8_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]); T8_EXTERN_C_END (); diff --git a/tutorials/general/t8_step3_adapt_forest.cxx b/tutorials/general/t8_step3_adapt_forest.cxx index 58b11f3482..c1ccc3afb3 100644 --- a/tutorials/general/t8_step3_adapt_forest.cxx +++ b/tutorials/general/t8_step3_adapt_forest.cxx @@ -86,7 +86,7 @@ T8_EXTERN_C_BEGIN (); */ int t8_step3_adapt_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { /* Our adaptation criterion is to look at the midpoint coordinates of the current element and if * they are inside a sphere around a given midpoint we refine, if they are outside, we coarsen. */ diff --git a/tutorials/general/t8_step5_element_data.cxx b/tutorials/general/t8_step5_element_data.cxx index 25f3cda356..7689ae14ac 100644 --- a/tutorials/general/t8_step5_element_data.cxx +++ b/tutorials/general/t8_step5_element_data.cxx @@ -65,7 +65,7 @@ static t8_forest_t t8_step5_build_forest (sc_MPI_Comm comm, int level) { t8_cmesh_t cmesh = t8_cmesh_new_hypercube_hybrid (comm, 0, 0); - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default_cxx (); struct t8_step3_adapt_data adapt_data = { { 0.5, 0.5, 1 }, /* Midpoints of the sphere. */ 0.2, /* Refine if inside this radius. */ @@ -130,7 +130,7 @@ t8_step5_create_element_data (t8_forest_t forest) t8_locidx_t current_index; t8_locidx_t ielement, num_elements_in_tree; t8_eclass_t tree_class; - t8_eclass_scheme_c *eclass_scheme; + t8_scheme *eclass_scheme; const t8_element_t *element; /* Get the number of trees that have elements of this process. */ diff --git a/tutorials/general/t8_step5_element_data_c_interface.c b/tutorials/general/t8_step5_element_data_c_interface.c index a32596f4ce..0180cd373c 100644 --- a/tutorials/general/t8_step5_element_data_c_interface.c +++ b/tutorials/general/t8_step5_element_data_c_interface.c @@ -68,7 +68,7 @@ static t8_forest_t t8_step5_build_forest (sc_MPI_Comm comm, int level) { t8_cmesh_t cmesh = t8_cmesh_new_hypercube_hybrid (comm, 0, 0); - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); + t8_scheme_c *scheme = t8_scheme_new_default_cxx (); struct t8_step3_adapt_data adapt_data = { { 0.5, 0.5, 1 }, /* Midpoints of the sphere. */ 0.2, /* Refine if inside this radius. */ @@ -133,7 +133,7 @@ t8_step5_create_element_data (t8_forest_t forest) t8_locidx_t current_index; t8_locidx_t ielement, num_elements_in_tree; t8_eclass_t tree_class; - t8_eclass_scheme_c *eclass_scheme; + t8_scheme_c *eclass_scheme; const t8_element_t *element; /* Get the number of trees that have elements of this process. */ diff --git a/tutorials/general/t8_step6_stencil.cxx b/tutorials/general/t8_step6_stencil.cxx index e3cff9ab86..37b83a97f5 100644 --- a/tutorials/general/t8_step6_stencil.cxx +++ b/tutorials/general/t8_step6_stencil.cxx @@ -83,7 +83,7 @@ t8_step6_build_forest (sc_MPI_Comm comm, int dim, int level) { t8_cmesh_t cmesh = t8_cmesh_new_periodic (comm, dim); - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default_cxx (); struct t8_step3_adapt_data adapt_data = { { 0.0, 0.0, 0.0 }, /* Midpoints of the sphere. */ 0.5, /* Refine if inside this radius. */ @@ -129,7 +129,7 @@ t8_step6_create_element_data (t8_forest_t forest) /* Loop over all local trees in the forest. */ for (t8_locidx_t itree = 0, current_index = 0; itree < num_local_trees; ++itree) { t8_eclass_t tree_class = t8_forest_get_tree_class (forest, itree); - t8_eclass_scheme_c *eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); + t8_scheme *eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); /* Get the number of elements of this tree. */ t8_locidx_t num_elements_in_tree = t8_forest_get_tree_num_elements (forest, itree); @@ -188,7 +188,7 @@ t8_step6_compute_stencil (t8_forest_t forest, struct data_per_element *element_d * each element is calculated and stored into the element data array. */ for (t8_locidx_t itree = 0, current_index = 0; itree < num_local_trees; ++itree) { t8_eclass_t tree_class = t8_forest_get_tree_class (forest, itree); - t8_eclass_scheme_c *eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); + t8_scheme *eclass_scheme = t8_forest_get_eclass_scheme (forest, tree_class); t8_locidx_t num_elements_in_tree = t8_forest_get_tree_num_elements (forest, itree); @@ -204,11 +204,11 @@ t8_step6_compute_stencil (t8_forest_t forest, struct data_per_element *element_d /* Loop over all faces of an element. */ int num_faces = eclass_scheme->t8_element_num_faces (element); for (int iface = 0; iface < num_faces; iface++) { - int num_neighbors; /**< Number of neighbors for each face */ - int *dual_faces; /**< The face indices of the neighbor elements */ - t8_locidx_t *neighids; /**< Indices of the neighbor elements */ - t8_element_t **neighbors; /*< Neighboring elements. */ - t8_eclass_scheme_c *neigh_scheme; /*< Neighboring elements scheme. */ + int num_neighbors; /**< Number of neighbors for each face */ + int *dual_faces; /**< The face indices of the neighbor elements */ + t8_locidx_t *neighids; /**< Indices of the neighbor elements */ + t8_element_t **neighbors; /*< Neighboring elements. */ + t8_scheme *neigh_scheme; /*< Neighboring elements scheme. */ /* Collect all neighbors at the current face. */ t8_forest_leaf_face_neighbors (forest, itree, element, &neighbors, iface, &dual_faces, &num_neighbors, diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index 34a2265479..3a83deac5d 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -112,7 +112,7 @@ t8_element_get_value (const t8_step7_adapt_data *adapt_data, t8_locidx_t ielemen */ int t8_step7_adapt_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_eclass_scheme_c *ts, const int is_family, const int num_elements, t8_element_t *elements[]) + t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) { /* Our adaptation criterion is to look at the midpoint coordinates of the current element and if * they are inside a sphere around a given midpoint we refine, if they are outside, we coarsen. */ @@ -199,9 +199,8 @@ t8_adapt_forest (t8_forest_t forest_from, t8_forest_adapt_t adapt_fn, int do_par * \param [in] first_incoming index of the new element */ void -t8_forest_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, t8_eclass_scheme_c *ts, - int refine, int num_outgoing, t8_locidx_t first_outgoing, int num_incoming, - t8_locidx_t first_incoming) +t8_forest_replace (t8_forest_t forest_old, t8_forest_t forest_new, t8_locidx_t which_tree, t8_scheme *ts, int refine, + int num_outgoing, t8_locidx_t first_outgoing, int num_incoming, t8_locidx_t first_incoming) { struct t8_step7_adapt_data *adapt_data_new = (struct t8_step7_adapt_data *) t8_forest_get_user_data (forest_new); const struct t8_step7_adapt_data *adapt_data_old @@ -286,7 +285,7 @@ t8_interpolation () t8_step7_adapt_data *data; double centroid[3]; const double midpoint[3] = { 0.5, 0.5, 1 }; - t8_scheme_cxx_t *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default_cxx (); /* Construct a cmesh */ t8_cmesh_t cmesh = t8_cmesh_new_from_class (T8_ECLASS_HEX, sc_MPI_COMM_WORLD); From 3ad3f6399df44a9f9c91fcd504507823c824e820 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Thu, 24 Oct 2024 10:11:32 +0200 Subject: [PATCH 07/11] remove outdated face neighbor example --- example/CMakeLists.txt | 1 - example/forest/Makefile.am | 2 - example/forest/t8_face_neighbor.cxx | 138 ---------------------------- 3 files changed, 141 deletions(-) delete mode 100644 example/forest/t8_face_neighbor.cxx diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index a2315758a4..838b9b5836 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -47,7 +47,6 @@ add_t8_example( NAME t8_cmesh_geometry_examples SOURCES cmesh/t8_cmesh_g add_t8_example( NAME t8_cmesh_create_partitioned SOURCES cmesh/t8_cmesh_create_partitioned.cxx ) add_t8_example( NAME t8_cmesh_hypercube_pad SOURCES cmesh/t8_cmesh_hypercube_pad.cxx ) -add_t8_example( NAME t8_face_neighbor SOURCES forest/t8_face_neighbor.cxx ) add_t8_example( NAME t8_test_ghost SOURCES forest/t8_test_ghost.cxx ) add_t8_example( NAME t8_test_face_iterate SOURCES forest/t8_test_face_iterate.cxx ) add_t8_example( NAME t8_test_ghost_large_level_diff SOURCES forest/t8_test_ghost_large_level_diff.cxx ) diff --git a/example/forest/Makefile.am b/example/forest/Makefile.am index 4412877d8c..36c5f88ee8 100644 --- a/example/forest/Makefile.am +++ b/example/forest/Makefile.am @@ -3,12 +3,10 @@ # Included from toplevel directory bin_PROGRAMS += \ - example/forest/t8_face_neighbor \ example/forest/t8_test_ghost \ example/forest/t8_test_face_iterate \ example/forest/t8_test_ghost_large_level_diff -example_forest_t8_face_neighbor_SOURCES = example/forest/t8_face_neighbor.cxx example_forest_t8_test_ghost_SOURCES = example/forest/t8_test_ghost.cxx example_forest_t8_test_face_iterate_SOURCES = example/forest/t8_test_face_iterate.cxx example_forest_t8_test_ghost_large_level_diff_SOURCES = example/forest/t8_test_ghost_large_level_diff.cxx diff --git a/example/forest/t8_face_neighbor.cxx b/example/forest/t8_face_neighbor.cxx deleted file mode 100644 index 9d13516fdc..0000000000 --- a/example/forest/t8_face_neighbor.cxx +++ /dev/null @@ -1,138 +0,0 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element types in parallel. - - Copyright (C) 2015 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* Construct a coarse mesh of two trees that are connected to each other. - * Build a forest on top of it and perform some element_neighbor routines. - * If hybrid is true, eclass is ignored and a hybrid quad/triangle mesh is created. */ -void -t8_ghost_neighbor_test (t8_eclass_t eclass, sc_MPI_Comm comm, int hybrid) -{ - t8_cmesh_t cmesh; - t8_forest_t forest; - t8_element_t *elem, *neigh; - t8_scheme *scheme; - t8_scheme *neigh_scheme; - t8_default_scheme_common_c *common_scheme; - int level = 1; - t8_locidx_t element_id = 0, treeid; - t8_eclass_t elem_eclass, neighbor_class; - int i; - t8_gloidx_t ret; - int anchor_node[3]; - int face_neigh; - - if (hybrid) { - eclass = T8_ECLASS_QUAD; - } - T8_ASSERT (eclass != T8_ECLASS_VERTEX); - - t8_cmesh_init (&cmesh); - /* We construct a coarse mesh of 2 trees that are connected to each other. */ - t8_cmesh_set_tree_class (cmesh, 0, eclass); - t8_cmesh_set_tree_class (cmesh, 1, hybrid ? T8_ECLASS_TRIANGLE : eclass); - t8_cmesh_set_join (cmesh, 0, 1, 1, 1, 1); - t8_cmesh_commit (cmesh, comm); - - /* Construct a forest */ - t8_forest_init (&forest); - t8_forest_set_cmesh (forest, cmesh, comm); - t8_forest_set_level (forest, level); - /* construct the scheme and get the eclass scheme */ - scheme = t8_scheme_new_default_cxx (); - - t8_forest_set_scheme (forest, scheme); - t8_forest_commit (forest); - - /* Get the data of element number element_id */ - elem = t8_forest_get_element (forest, element_id, &treeid); - /* Get the scheme corresponding to the element. */ - elem_eclass = t8_forest_get_tree_class (forest, treeid); - T8_ASSERT (elem != NULL); - - /* Iterate over all faces and create the face neighbor */ - - for (i = 0; i < t8_eclass_num_faces[elem_eclass]; i++) { - /* Get the eclass of the face neighbor's tree */ - neighbor_class = t8_forest_element_neighbor_eclass (forest, treeid, elem, i); - /* Get the corresponding scheme and allocate the face neighbor */ - neigh_scheme = t8_forest_get_eclass_scheme (forest, neighbor_class); - /* We expect this scheme to be the default scheme. Since we want to use - * the anchor node information which is only implemented in that scheme, - * it is crucial that we do not use any other scheme. */ - common_scheme = static_cast (neigh_scheme); - T8_ASSERT (common_scheme != NULL); - neigh_scheme->t8_element_new (1, &neigh); - - ret = t8_forest_element_face_neighbor (forest, 0, elem, neigh, neigh_scheme, i, &face_neigh); - if (ret != -1) { - /* Anchor is only implemented in the common scheme. */ - common_scheme->t8_element_anchor (neigh, anchor_node); - t8_debugf ("neighbor of %i across face %i (in tree %li): (%i,%i,%i,%i)\n", element_id, i, ret, - neigh_scheme->t8_element_level (neigh), anchor_node[0], anchor_node[1], - t8_eclass_to_dimension[elem_eclass] > 2 ? anchor_node[2] : -1); - } - /* free the neighbors memory */ - neigh_scheme->t8_element_destroy (1, &neigh); - } - t8_forest_unref (&forest); -} - -int -main (int argc, char **argv) -{ - int mpiret; - - mpiret = sc_MPI_Init (&argc, &argv); - SC_CHECK_MPI (mpiret); - - sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL); - t8_init (SC_LP_DEFAULT); - - t8_global_productionf ("Testing neighbors for triangle\n"); - t8_ghost_neighbor_test (T8_ECLASS_TRIANGLE, sc_MPI_COMM_WORLD, 0); - t8_global_productionf ("Testing neighbors for quad\n"); - t8_ghost_neighbor_test (T8_ECLASS_QUAD, sc_MPI_COMM_WORLD, 0); - t8_global_productionf ("Testing neighbors for tet\n"); - t8_ghost_neighbor_test (T8_ECLASS_TET, sc_MPI_COMM_WORLD, 0); - t8_global_productionf ("Testing neighbors for hex\n"); - t8_ghost_neighbor_test (T8_ECLASS_HEX, sc_MPI_COMM_WORLD, 0); - t8_global_productionf ("Testing neighbors for pyramid\n"); - t8_ghost_neighbor_test (T8_ECLASS_PYRAMID, sc_MPI_COMM_WORLD, 0); - t8_global_productionf ("Testing neighbors for hybrid_mesh\n"); - t8_ghost_neighbor_test (T8_ECLASS_HEX, sc_MPI_COMM_WORLD, 1); - - sc_finalize (); - - mpiret = sc_MPI_Finalize (); - SC_CHECK_MPI (mpiret); - - return 0; -} From 85698b8f7a80d9de92a5695fa685cd7fc2000ab6 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Mon, 28 Oct 2024 11:49:27 +0100 Subject: [PATCH 08/11] capturing progress --- example/advect/t8_advection.cxx | 18 +- example/forest/t8_test_face_iterate.cxx | 12 +- .../multilevel/t8_multilevel_concept_base.hxx | 2 +- src/t8_data/t8_containers.cxx | 64 ++-- src/t8_data/t8_containers.h | 46 ++- src/t8_element.hxx | 6 +- src/t8_forest/t8_forest.cxx | 282 ++++++++---------- src/t8_forest/t8_forest_adapt.cxx | 38 +-- src/t8_forest/t8_forest_balance.cxx | 37 ++- src/t8_forest/t8_forest_general.h | 21 +- src/t8_forest/t8_forest_ghost.cxx | 78 ++--- src/t8_forest/t8_forest_iterate.cxx | 47 +-- src/t8_forest/t8_forest_netcdf.cxx | 10 +- src/t8_forest/t8_forest_partition.cxx | 58 ++-- src/t8_forest/t8_forest_private.h | 11 +- src/t8_vtk/t8_vtk_write_ASCII.cxx | 118 ++++---- 16 files changed, 432 insertions(+), 416 deletions(-) diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index 5948cd3c15..51c4e3b084 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -179,8 +179,9 @@ t8_advect_element_set_phi_adapt (const t8_advect_problem_t *problem, t8_locidx_t /* Adapt the forest. We refine if the level-set function is close to zero * and coarsen if it is larger than a given threshold. */ static int -t8_advect_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t ltree_id, t8_locidx_t lelement_id, - t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) +t8_advect_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t ltree_id, t8_eclass_t tree_class, + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { t8_advect_problem_t *problem; t8_advect_element_data_t *elem_data; @@ -195,7 +196,7 @@ t8_advect_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t ltree_ /* Get a pointer to the problem from the user data pointer of forest */ problem = (t8_advect_problem_t *) t8_forest_get_user_data (forest); /* Get the element's level */ - level = ts->t8_element_level (elements[0]); + level = ts->element_get_level (tree_class, elements[0]); if (level == problem->maxlevel && !is_family) { /* It is not possible to refine this level */ return 0; @@ -516,7 +517,7 @@ t8_advect_advance_element (t8_advect_problem_t *problem, t8_locidx_t lelement) /* Compute element midpoint and vol and store at element_data field. */ static void t8_advect_compute_element_data (t8_advect_problem_t *problem, t8_advect_element_data_t *elem_data, - const t8_element_t *element, t8_locidx_t ltreeid, t8_scheme *ts) + const t8_element_t *element, t8_locidx_t ltreeid) { /* Compute the midpoint coordinates of element */ t8_forest_element_centroid (problem->forest, ltreeid, element, elem_data->midpoint); @@ -997,13 +998,14 @@ t8_advect_problem_init_elements (t8_advect_problem_t *problem) /* maximum possible delta_t value */ min_delta_t = problem->T - problem->t; for (itree = 0, idata = 0; itree < num_trees; itree++) { - ts = t8_forest_get_eclass_scheme (problem->forest, t8_forest_get_tree_class (problem->forest, itree)); + const t8_eclass_t tree_class = t8_forest_get_tree_class (problem->forest, itree); + ts = t8_forest_get_scheme (problem->forest); num_elems_in_tree = t8_forest_get_tree_num_elements (problem->forest, itree); for (ielement = 0; ielement < num_elems_in_tree; ielement++, idata++) { const t8_element_t *element = t8_forest_get_element_in_tree (problem->forest, itree, ielement); elem_data = (t8_advect_element_data_t *) t8_sc_array_index_locidx (problem->element_data, idata); /* Initialize the element's midpoint and volume */ - t8_advect_compute_element_data (problem, elem_data, element, itree, ts); + t8_advect_compute_element_data (problem, elem_data, element, itree); /* Compute the minimum diameter */ diam = t8_forest_element_diam (problem->forest, itree, element); T8_ASSERT (diam > 0); @@ -1026,9 +1028,9 @@ t8_advect_problem_init_elements (t8_advect_problem_t *problem) /* Set the initial condition */ t8_advect_element_set_phi (problem, idata, problem->phi_0 (elem_data->midpoint, 0, problem->udata_for_phi)); /* Set the level */ - elem_data->level = ts->t8_element_level (element); + elem_data->level = ts->element_get_level (tree_class, element); /* Set the faces */ - elem_data->num_faces = ts->t8_element_num_faces (element); + elem_data->num_faces = ts->element_get_num_faces (tree_class, element); for (iface = 0; iface < elem_data->num_faces; iface++) { /* Compute the indices of the face neighbors */ diff --git a/example/forest/t8_test_face_iterate.cxx b/example/forest/t8_test_face_iterate.cxx index 0d5461d87f..8da5435750 100644 --- a/example/forest/t8_test_face_iterate.cxx +++ b/example/forest/t8_test_face_iterate.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,20 +86,20 @@ t8_test_fiterate (t8_forest_t forest) num_trees = t8_forest_get_num_local_trees (forest); for (itree = 0; itree < num_trees; itree++) { eclass = t8_forest_get_tree_class (forest, itree); - ts = t8_forest_get_eclass_scheme (forest, eclass); + ts = t8_forest_get_scheme (forest); const t8_element_t *first_el = t8_forest_get_element_in_tree (forest, itree, 0); const t8_element_t *last_el = t8_forest_get_element_in_tree (forest, itree, t8_forest_get_tree_num_elements (forest, itree) - 1); - ts->t8_element_new (1, &nca); - ts->t8_element_nca (first_el, last_el, nca); + ts->element_new (eclass, 1, &nca); + ts->element_get_nca (eclass, first_el, last_el, nca); leaf_elements = t8_forest_tree_get_leaves (forest, itree); - for (iface = 0; iface < ts->t8_element_num_faces (nca); iface++) { + for (iface = 0; iface < ts->element_get_num_faces (eclass, nca); iface++) { udata.count = 0; t8_forest_iterate_faces (forest, itree, nca, iface, leaf_elements, &udata, 0, t8_test_fiterate_callback); t8_debugf ("Leaf elements at face %i:\t%i\n", iface, udata.count); } - ts->t8_element_destroy (1, &nca); + ts->element_destroy (eclass, 1, &nca); } } diff --git a/example/multilevel/t8_multilevel_concept_base.hxx b/example/multilevel/t8_multilevel_concept_base.hxx index 594792050a..d8252b98d4 100644 --- a/example/multilevel/t8_multilevel_concept_base.hxx +++ b/example/multilevel/t8_multilevel_concept_base.hxx @@ -12,7 +12,7 @@ typedef struct element element_t; // Using CRTP to avoid virtual function calls template -class Scheme_base: public crtp { +class Scheme_base: public t8_crtp { public: ~Scheme_base () { diff --git a/src/t8_data/t8_containers.cxx b/src/t8_data/t8_containers.cxx index 064a344262..c72974cfc6 100644 --- a/src/t8_data/t8_containers.cxx +++ b/src/t8_data/t8_containers.cxx @@ -27,6 +27,7 @@ #include #include #include +#include T8_EXTERN_C_BEGIN (); @@ -46,64 +47,68 @@ t8_element_array_is_valid (const t8_element_array_t *element_array) /* Check that the element size of the scheme matches the size of data elements * stored in the array. */ - is_valid = is_valid && element_array->scheme->t8_element_size () == element_array->array.elem_size; + is_valid + = is_valid && element_array->scheme->get_element_size (element_array->tree_class) == element_array->array.elem_size; return is_valid; } #endif t8_element_array_t * -t8_element_array_new (t8_scheme *scheme) +t8_element_array_new (const t8_scheme_c *scheme, const t8_eclass_t tree_class) { t8_element_array_t *new_array; /* allocate memory */ new_array = T8_ALLOC (t8_element_array_t, 1); /* initialize array */ - t8_element_array_init (new_array, scheme); + t8_element_array_init (new_array, scheme, tree_class); T8_ASSERT (t8_element_array_is_valid (new_array)); return new_array; } t8_element_array_t * -t8_element_array_new_count (t8_scheme *scheme, size_t num_elements) +t8_element_array_new_count (t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t num_elements) { t8_element_array_t *new_array; /* allocate memory */ new_array = T8_ALLOC (t8_element_array_t, 1); /* initialize array */ - t8_element_array_init_size (new_array, scheme, num_elements); + t8_element_array_init_size (new_array, scheme, tree_class, num_elements); T8_ASSERT (t8_element_array_is_valid (new_array)); return new_array; } void -t8_element_array_init (t8_element_array_t *element_array, t8_scheme *scheme) +t8_element_array_init (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class) { size_t elem_size; T8_ASSERT (element_array != NULL); - /* set the scheme */ + /* set the scheme and eclass */ element_array->scheme = scheme; + element_array->tree_class = tree_class; /* get the size of an element and initialize the array member */ - elem_size = scheme->t8_element_size (); + elem_size = scheme->get_element_size (tree_class); sc_array_init (&element_array->array, elem_size); T8_ASSERT (t8_element_array_is_valid (element_array)); } void -t8_element_array_init_size (t8_element_array_t *element_array, t8_scheme *scheme, size_t num_elements) +t8_element_array_init_size (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, + const size_t num_elements) { t8_element_t *first_element; T8_ASSERT (element_array != NULL); element_array->scheme = scheme; + element_array->tree_class = tree_class; /* allocate the elements */ - sc_array_init_size (&element_array->array, scheme->t8_element_size (), num_elements); + sc_array_init_size (&element_array->array, scheme->get_element_size (tree_class), num_elements); if (num_elements > 0) { /* Call t8_element_init for the elements */ @@ -114,7 +119,8 @@ t8_element_array_init_size (t8_element_array_t *element_array, t8_scheme *scheme } void -t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, size_t offset, size_t length) +t8_element_array_init_view (t8_element_array_t *view, const t8_element_array_t *array, const size_t offset, + const size_t length) { T8_ASSERT (t8_element_array_is_valid (array)); @@ -126,7 +132,8 @@ t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, } void -t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_scheme *scheme, size_t elem_count) +t8_element_array_init_data (t8_element_array_t *view, const t8_element_t *base, const t8_scheme_c *scheme, + const size_t elem_count) { /* Initialize the element array */ sc_array_init_data (&view->array, (void *) base, scheme->t8_element_size (), elem_count); @@ -136,13 +143,13 @@ t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_sch } void -t8_element_array_init_copy (t8_element_array_t *element_array, t8_scheme *scheme, t8_element_t *data, - size_t num_elements) +t8_element_array_init_copy (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, + const t8_element_t *data, const size_t num_elements) { sc_array_t *array; T8_ASSERT (element_array != NULL); - t8_element_array_init (element_array, scheme); + t8_element_array_init (element_array, scheme, tree_class); array = &element_array->array; #ifdef T8_ENABLE_DEBUG @@ -152,23 +159,23 @@ t8_element_array_init_copy (t8_element_array_t *element_array, t8_scheme *scheme const t8_element_t *element; size_t size; - size = scheme->t8_element_size (); + size = scheme->get_element_size (tree_class); for (ielem = 0; ielem < num_elements; ielem++) { /* data is of incomplete type, we thus have to manually set the address * of the ielem-th t8_element */ element = (const t8_element_t *) (((char *) data) + ielem * size); - T8_ASSERT (scheme->t8_element_is_valid (element)); + T8_ASSERT (scheme->element_is_valid (tree_class, element)); } } #endif /* Allocate enough memory for the new elements */ - sc_array_init_size (array, scheme->t8_element_size (), num_elements); + sc_array_init_size (array, scheme->get_element_size (tree_class), num_elements); /* Copy the elements in data */ memcpy (array->array, data, num_elements * array->elem_size); } void -t8_element_array_resize (t8_element_array_t *element_array, size_t new_count) +t8_element_array_resize (t8_element_array_t *element_array, const size_t new_count) { size_t old_count; T8_ASSERT (t8_element_array_is_valid (element_array)); @@ -218,7 +225,7 @@ t8_element_array_push (t8_element_array_t *element_array) } t8_element_t * -t8_element_array_push_count (t8_element_array_t *element_array, size_t count) +t8_element_array_push_count (t8_element_array_t *element_array, const size_t count) { t8_element_t *new_elements; T8_ASSERT (t8_element_array_is_valid (element_array)); @@ -230,14 +237,14 @@ t8_element_array_push_count (t8_element_array_t *element_array, size_t count) } const t8_element_t * -t8_element_array_index_locidx (const t8_element_array_t *element_array, t8_locidx_t index) +t8_element_array_index_locidx (const t8_element_array_t *element_array, const t8_locidx_t index) { T8_ASSERT (t8_element_array_is_valid (element_array)); return (const t8_element_t *) t8_sc_array_index_locidx (&element_array->array, index); } const t8_element_t * -t8_element_array_index_int (const t8_element_array_t *element_array, int index) +t8_element_array_index_int (const t8_element_array_t *element_array, const int index) { T8_ASSERT (t8_element_array_is_valid (element_array)); return (const t8_element_t *) sc_array_index_int ((sc_array_t *) &element_array->array, @@ -245,24 +252,31 @@ t8_element_array_index_int (const t8_element_array_t *element_array, int index) } t8_element_t * -t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, t8_locidx_t index) +t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, const t8_locidx_t index) { return (t8_element_t *) t8_element_array_index_locidx (element_array, index); } t8_element_t * -t8_element_array_index_int_mutable (t8_element_array_t *element_array, int index) +t8_element_array_index_int_mutable (t8_element_array_t *element_array, const int index) { return (t8_element_t *) t8_element_array_index_int (element_array, index); } -const t8_scheme * +const t8_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array) { T8_ASSERT (t8_element_array_is_valid (element_array)); return element_array->scheme; } +t8_eclass_t +t8_element_array_get_tree_class (const t8_element_array_t *element_array) +{ + T8_ASSERT (t8_element_array_is_valid (element_array)); + return element_array->tree_class; +} + size_t t8_element_array_get_count (const t8_element_array_t *element_array) { diff --git a/src/t8_data/t8_containers.h b/src/t8_data/t8_containers.h index 5d9b4fa0b9..0799a0a55d 100644 --- a/src/t8_data/t8_containers.h +++ b/src/t8_data/t8_containers.h @@ -40,45 +40,51 @@ */ typedef struct { - t8_scheme_c *scheme; /**< An eclass scheme of which elements should be stored */ - sc_array_t array; /**< The array in which the elements are stored */ + t8_scheme_c *scheme; /**< A scheme of which elements should be stored */ + t8_eclass_t tree_class; /**< The tree class of the elements stored in the array */ + sc_array_t array; /**< The array in which the elements are stored */ } t8_element_array_t; T8_EXTERN_C_BEGIN (); /** Creates a new array structure with 0 elements. * \param [in] scheme The eclass scheme of which elements should be stored. + * \param [in] tree_class The tree class of the elements stored in the array. * \return Return an allocated array of zero length. */ t8_element_array_t * -t8_element_array_new (t8_scheme_c *scheme); +t8_element_array_new (const t8_scheme_c *scheme, const t8_eclass_t tree_class); /** Creates a new array structure with a given length (number of elements) * and calls \ref t8_element_new for those elements. * \param [in] scheme The eclass scheme of which elements should be stored. + * \param [in] tree_class The tree class of the elements stored in the array. * \param [in] num_elements Initial number of array elements. * \return Return an allocated array * with allocated and initialized elements for which \ref * t8_element_new was called. */ t8_element_array_t * -t8_element_array_new_count (t8_scheme_c *scheme, size_t num_elements); +t8_element_array_new_count (const t8_scheme_c *scheme, const t8_eclass_t tree_class, const size_t num_elements); /** Initializes an already allocated (or static) array structure. * \param [in,out] element_array Array structure to be initialized. * \param [in] scheme The eclass scheme of which elements should be stored. + * \param [in] tree_class The tree class of the elements stored in the array. */ void -t8_element_array_init (t8_element_array_t *element_array, t8_scheme_c *scheme); +t8_element_array_init (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class); /** Initializes an already allocated (or static) array structure * and allocates a given number of elements and initializes them with \ref t8_element_init. * \param [in,out] element_array Array structure to be initialized. * \param [in] scheme The eclass scheme of which elements should be stored. + * \param [in] tree_class The tree class of the elements stored in the array. * \param [in] num_elements Number of initial array elements. */ void -t8_element_array_init_size (t8_element_array_t *element_array, t8_scheme_c *scheme, size_t num_elements); +t8_element_array_init_size (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, + const size_t num_elements); /** Initializes an already allocated (or static) view from existing t8_element_array. * The array view returned does not require t8_element_array_reset (doesn't hurt though). @@ -91,7 +97,8 @@ t8_element_array_init_size (t8_element_array_t *element_array, t8_scheme_c *sche * It is not necessary to call sc_array_reset later. */ void -t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, size_t offset, size_t length); +t8_element_array_init_view (t8_element_array_t *view, const t8_element_array_t *array, const size_t offset, + const size_t length); /** Initializes an already allocated (or static) view from given plain C data * (array of t8_element_t). @@ -105,12 +112,14 @@ t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, * It is not necessary to call t8_element_array_reset later. */ void -t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_scheme_c *scheme, size_t elem_count); +t8_element_array_init_data (t8_element_array_t *view, const t8_element_t *base, const t8_scheme_c *scheme, + const size_t elem_count); /** Initializes an already allocated (or static) array structure * and copy an existing array of t8_element_t into it. * \param [in,out] element_array Array structure to be initialized. * \param [in] scheme The eclass scheme of which elements should be stored. + * \param [in] tree_class The tree class of the elements stored in the array. * \param [in] data An array of t8_element_t which will be copied into * \a element_array. The elements in \a data must belong to * \a scheme and must be properly initialized with either @@ -118,8 +127,8 @@ t8_element_array_init_data (t8_element_array_t *view, t8_element_t *base, t8_sch * \param [in] num_elements Number of elements in \a data to be copied. */ void -t8_element_array_init_copy (t8_element_array_t *element_array, t8_scheme_c *scheme, t8_element_t *data, - size_t num_elements); +t8_element_array_init_copy (t8_element_array_t *element_array, const t8_scheme_c *scheme, const t8_eclass_t tree_class, + const t8_element_t *data, const size_t num_elements); /** Change the number of elements stored in an element array. * \param [in,out] element_array The element array to be modified. @@ -129,7 +138,7 @@ t8_element_array_init_copy (t8_element_array_t *element_array, t8_scheme_c *sche * then \ref t8_element_init is called for the new elements. */ void -t8_element_array_resize (t8_element_array_t *element_array, size_t new_count); +t8_element_array_resize (t8_element_array_t *element_array, const size_t new_count); /** Copy the contents of an array into another. * Both arrays must have the same eclass_scheme. @@ -163,7 +172,7 @@ t8_element_array_push_count (t8_element_array_t *element_array, size_t count); * \a element_array. */ const t8_element_t * -t8_element_array_index_locidx (const t8_element_array_t *element_array, t8_locidx_t index); +t8_element_array_index_locidx (const t8_element_array_t *element_array, const t8_locidx_t index); /** Return a given element in an array. Const version. * \param [in] element_array Array of elements. @@ -172,7 +181,7 @@ t8_element_array_index_locidx (const t8_element_array_t *element_array, t8_locid * \a element_array. */ const t8_element_t * -t8_element_array_index_int (const t8_element_array_t *element_array, int index); +t8_element_array_index_int (const t8_element_array_t *element_array, const int index); /** Return a given element in an array. Mutable version. * \param [in] element_array Array of elements. @@ -181,7 +190,7 @@ t8_element_array_index_int (const t8_element_array_t *element_array, int index); * \a element_array. */ t8_element_t * -t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, t8_locidx_t index); +t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, const t8_locidx_t index); /** Return a given element in an array. Mutable version. * \param [in] element_array Array of elements. @@ -190,7 +199,7 @@ t8_element_array_index_locidx_mutable (t8_element_array_t *element_array, t8_loc * \a element_array. */ t8_element_t * -t8_element_array_index_int_mutable (t8_element_array_t *element_array, int index); +t8_element_array_index_int_mutable (t8_element_array_t *element_array, const int index); /** Return the eclass scheme associated to a t8_element_array. * \param [in] element_array Array of elements. @@ -199,6 +208,13 @@ t8_element_array_index_int_mutable (t8_element_array_t *element_array, int index const t8_scheme_c * t8_element_array_get_scheme (const t8_element_array_t *element_array); +/** Return the tree class of the t8_element_array . + * \param [in] element_array Array of elements. + * \return The tree class stored at \a element_array. + */ +t8_eclass_t +t8_element_array_get_tree_class (const t8_element_array_t *element_array); + /** Return the number of elements stored in a t8_element_array_t. * \param [in] element_array Array structure. * \return The number of elements stored in \a element_array. diff --git a/src/t8_element.hxx b/src/t8_element.hxx index 631be78334..3aa2e4359d 100644 --- a/src/t8_element.hxx +++ b/src/t8_element.hxx @@ -34,11 +34,9 @@ #include #include -T8_EXTERN_C_BEGIN (); - /** This class holds functions for a particular element class. */ template -class t8_eclass_scheme: public crtp { +class t8_eclass_scheme: public t8_crtp { private: t8_scheme () {}; /**< private destructor which can only be used by derived schemes. */ friend TUnderlyingEclassScheme; @@ -887,5 +885,3 @@ class t8_eclass_scheme: public crtp { this->underlying ().element_MPI_Unpack (recvbuf, buffer_size, position, elements, count, comm); }; }; - -T8_EXTERN_C_END (); diff --git a/src/t8_forest/t8_forest.cxx b/src/t8_forest/t8_forest.cxx index f6bd92e44f..8e1b8494c7 100644 --- a/src/t8_forest/t8_forest.cxx +++ b/src/t8_forest/t8_forest.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -49,17 +50,20 @@ T8_EXTERN_C_BEGIN (); int t8_forest_is_incomplete_family (const t8_forest_t forest, const t8_locidx_t ltree_id, const t8_locidx_t el_considered, - t8_scheme *tscheme, t8_element_t **elements, const int elements_size) + t8_element_t **elements, const int elements_size) { T8_ASSERT (forest != NULL); T8_ASSERT (ltree_id >= 0); T8_ASSERT (ltree_id < t8_forest_get_num_local_trees (forest)); - T8_ASSERT (tscheme != NULL); T8_ASSERT (elements != NULL); T8_ASSERT (elements_size > 0); + const t8_scheme *tscheme = t8_forest_get_scheme (forest); + T8_ASSERT (tscheme != NULL); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltree_id); + /* If current considered element has level 0 there is no coarsening possible */ - if (0 == tscheme->t8_element_level (elements[0])) { + if (0 == tscheme->element_get_level (tree_class, elements[0])) { return 0; } @@ -71,17 +75,17 @@ t8_forest_is_incomplete_family (const t8_forest_t forest, const t8_locidx_t ltre /* Buffer for elements */ t8_element_t *element_parent_current; t8_element_t *element_compare; - tscheme->t8_element_new (1, &element_parent_current); - tscheme->t8_element_new (1, &element_compare); + tscheme->element_new (tree_class, 1, &element_parent_current); + tscheme->element_new (tree_class, 1, &element_compare); /* We first assume that we have an (in)complete family with the size of array elements. * In the following we try to disprove this. */ int family_size = elements_size; /* Get level, child ID and parent of first element of possible family */ - const int level_current = tscheme->t8_element_level (elements[0]); - const int child_id_current = tscheme->t8_element_child_id (elements[0]); - tscheme->t8_element_parent (elements[0], element_parent_current); + const int level_current = tscheme->element_get_level (tree_class, elements[0]); + const int child_id_current = tscheme->element_get_child_id (tree_class, elements[0]); + tscheme->element_get_parent (tree_class, elements[0], element_parent_current); /* Elements of the current family could already be passed, so that * the element/family currently under consideration can no longer be coarsened. @@ -90,18 +94,18 @@ t8_forest_is_incomplete_family (const t8_forest_t forest, const t8_locidx_t ltre * */ if (child_id_current > 0 && el_considered > 0) { const t8_element_t *element_temp = t8_forest_get_tree_element (tree, el_considered - 1); - int level_temp = tscheme->t8_element_level (element_temp); + int level_temp = tscheme->element_get_level (tree_class, element_temp); /* Only elements with higher or equal level then level of current considered * element, can get potentially be overlapped. */ if (level_temp >= level_current) { /* Compare ancestors */ - tscheme->t8_element_nca (element_parent_current, element_temp, element_compare); - const int level_compare = tscheme->t8_element_level (element_compare); + tscheme->element_get_nca (tree_class, element_parent_current, element_temp, element_compare); + const int level_compare = tscheme->element_get_level (tree_class, element_compare); /* Level_current-1 is level of element_parent_current */ T8_ASSERT (level_compare <= level_current - 1); if (level_compare == level_current - 1) { - tscheme->t8_element_destroy (1, &element_parent_current); - tscheme->t8_element_destroy (1, &element_compare); + tscheme->element_destroy (tree_class, 1, &element_parent_current); + tscheme->element_destroy (tree_class, 1, &element_compare); return 0; } } @@ -109,16 +113,16 @@ t8_forest_is_incomplete_family (const t8_forest_t forest, const t8_locidx_t ltre /* Reduce family_size to the number of family members that directly follow each other. */ for (int family_iter = 1; family_iter < family_size; family_iter++) { - const int level = tscheme->t8_element_level (elements[family_iter]); + const int level = tscheme->element_get_level (tree_class, elements[family_iter]); /* By comparing the levels in advance we may be able to avoid * the more complex test with the parent element.*/ if (level != level_current) { family_size = family_iter; break; } - tscheme->t8_element_parent (elements[family_iter], element_compare); + tscheme->element_get_parent (tree_class, elements[family_iter], element_compare); /* If the levels are equal, check if the parents are too. */ - if (!tscheme->t8_element_equal (element_parent_current, element_compare)) { + if (!tscheme->element_is_equal (tree_class, element_parent_current, element_compare)) { family_size = family_iter; break; } @@ -131,28 +135,28 @@ t8_forest_is_incomplete_family (const t8_forest_t forest, const t8_locidx_t ltre * family_size in this family) that would be overlapped after coarsening. */ if (family_size < elements_size) { /* Get level of element after last element of current possible family */ - const int level = tscheme->t8_element_level (elements[family_size]); + const int level = tscheme->element_get_level (tree_class, elements[family_size]); /* Only elements with higher level then level of current element, can get * potentially be overlapped. */ if (level > level_current) { /* Compare ancestors */ - tscheme->t8_element_nca (element_parent_current, elements[family_size], element_compare); - const int level_compare = tscheme->t8_element_level (element_compare); + tscheme->element_get_nca (tree_class, element_parent_current, elements[family_size], element_compare); + const int level_compare = tscheme->element_get_level (tree_class, element_compare); T8_ASSERT (level_compare <= level_current - 1); if (level_compare == level_current - 1) { - tscheme->t8_element_destroy (1, &element_parent_current); - tscheme->t8_element_destroy (1, &element_compare); + tscheme->element_destroy (tree_class, 1, &element_parent_current); + tscheme->element_destroy (tree_class, 1, &element_compare); return 0; } } } /* clean up */ - tscheme->t8_element_destroy (1, &element_parent_current); - tscheme->t8_element_destroy (1, &element_compare); + tscheme->element_destroy (tree_class, 1, &element_parent_current); + tscheme->element_destroy (tree_class, 1, &element_compare); #if T8_ENABLE_MPI - const int num_siblings = tscheme->t8_element_num_siblings (elements[0]); + const int num_siblings = tscheme->element_get_num_siblings (tree_class, elements[0]); T8_ASSERT (family_size <= num_siblings); /* If the first/last element at a process boundary is not the first/last * element of a possible family, we are not guaranteed to consider all @@ -184,8 +188,8 @@ t8_forest_compute_maxlevel (t8_forest_t forest) for (eclass_it = T8_ECLASS_VERTEX; eclass_it < T8_ECLASS_COUNT; eclass_it++) { if (forest->cmesh->num_trees_per_eclass[eclass_it] > 0) { /* If there are trees of this class, compute the maxlevel of the class */ - ts = t8_forest_get_eclass_scheme_before_commit (forest, (t8_eclass_t) eclass_it); - maxlevel = ts->t8_element_maxlevel (); + ts = t8_forest_get_scheme_before_commit (forest); + maxlevel = ts->get_maxlevel ((t8_eclass_t) eclass_it); /* Compute the minimum of this level and the stored maxlevel */ if (forest->maxlevel == -1) { forest->maxlevel = maxlevel; @@ -209,11 +213,10 @@ t8_forest_get_maxlevel (const t8_forest_t forest) /* Ensure that the maxlevel does not increase the maximum level of any * class in the forest */ int eclass_it; - t8_scheme *ts; + const t8_scheme *ts = t8_forest_get_scheme (forest); for (eclass_it = 0; eclass_it < T8_ECLASS_COUNT; eclass_it++) { if (forest->cmesh->num_trees_per_eclass[eclass_it] > 0) { - ts = t8_forest_get_eclass_scheme (forest, (t8_eclass_t) eclass_it); - T8_ASSERT (forest->maxlevel <= ts->t8_element_maxlevel ()); + T8_ASSERT (forest->maxlevel <= ts->get_maxlevel ((t8_eclass_t) eclass_it)); } } #endif @@ -337,7 +340,7 @@ t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b) t8_locidx_t elems_in_tree_a, elems_in_tree_b; t8_locidx_t ielem; t8_locidx_t itree; - t8_scheme *ts_a, *ts_b; + *ts_a, *ts_b; T8_ASSERT (t8_forest_is_committed (forest_a)); T8_ASSERT (t8_forest_is_committed (forest_b)); @@ -349,12 +352,19 @@ t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b) return 0; } + /* Check the schemes for equality */ + const t8_scheme *ts_a = t8_forest_get_scheme (forest_a); + const t8_scheme *ts_b = t8_forest_get_scheme (forest_b); + if (ts_a != ts_b) { + return 0; + } + /* Check element arrays for equality */ for (itree = 0; itree < num_local_trees_a; itree++) { - /* Check the schemes for equality */ - ts_a = t8_forest_get_eclass_scheme (forest_a, t8_forest_get_tree_class (forest_a, itree)); - ts_b = t8_forest_get_eclass_scheme (forest_b, t8_forest_get_tree_class (forest_b, itree)); - if (ts_a != ts_b) { + /* Check the tree classes for equality */ + const t8_eclass_t tree_class_a = t8_forest_get_tree_class (forest_a, itree); + const t8_eclass_t tree_class_b = t8_forest_get_tree_class (forest_b, itree); + if (tree_class_a != tree_class_b) { return 0; } /* Check the elements for equality */ @@ -368,7 +378,7 @@ t8_forest_is_equal (t8_forest_t forest_a, t8_forest_t forest_b) const t8_element_t *elem_a = t8_forest_get_element_in_tree (forest_a, itree, ielem); const t8_element_t *elem_b = t8_forest_get_element_in_tree (forest_b, itree, ielem); /* check for equality */ - if (!ts_a->t8_element_equal (elem_a, elem_b)) { + if (!ts_a->element_is_equal (tree_class_a, elem_a, elem_b)) { /* The elements are not equal */ return 0; } @@ -387,22 +397,18 @@ t8_forest_element_coordinate (t8_forest_t forest, t8_locidx_t ltree_id, const t8 double *coordinates) { double vertex_coords[3] = { 0.0 }; - t8_scheme *ts; - t8_eclass_t tree_class; - t8_gloidx_t gtreeid; - t8_cmesh_t cmesh; T8_ASSERT (forest != NULL); - T8_ASSERT (forest->scheme_cxx != NULL); + T8_ASSERT (forest->scheme != NULL); /* Get the tree's class and scheme */ - tree_class = t8_forest_get_tree_class (forest, ltree_id); - ts = t8_forest_get_eclass_scheme (forest, tree_class); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltree_id); + const t8_scheme *ts = t8_forest_get_scheme (forest, tree_class); /* Compute the vertex coordinates inside [0,1]^dim reference cube. */ - ts->t8_element_vertex_reference_coords (element, corner_number, vertex_coords); + ts->element_get_vertex_reference_coords (tree_class, element, corner_number, vertex_coords); /* Compute the global tree id */ - gtreeid = t8_forest_global_tree_id (forest, ltree_id); + const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, ltree_id); /* Get the cmesh */ - cmesh = t8_forest_get_cmesh (forest); + const t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); /* Evaluate the geometry */ t8_geometry_evaluate (cmesh, gtreeid, vertex_coords, 1, coordinates); } @@ -414,7 +420,7 @@ t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, { const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); const int tree_dim = t8_eclass_to_dimension[tree_class]; - const t8_scheme *scheme = t8_forest_get_eclass_scheme (forest, tree_class); + const t8_scheme *scheme = t8_forest_get_scheme (forest); const t8_cmesh_t cmesh = t8_forest_get_cmesh (forest); const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, ltreeid); @@ -433,10 +439,10 @@ t8_forest_element_from_ref_coords_ext (t8_forest_t forest, t8_locidx_t ltreeid, = 0.5 + ((ref_coords[i_coord * tree_dim + dim] - 0.5) * stretch_factors[dim]); } } - scheme->t8_element_reference_coords (element, stretched_ref_coords, num_coords, tree_ref_coords); + scheme->element_get_reference_coords (tree_class, element, stretched_ref_coords, num_coords, tree_ref_coords); } else { - scheme->t8_element_reference_coords (element, ref_coords, num_coords, tree_ref_coords); + scheme->element_get_reference_coords (tree_class, element, ref_coords, num_coords, tree_ref_coords); } t8_geometry_evaluate (cmesh, gtreeid, tree_ref_coords, num_coords, coords_out); @@ -455,22 +461,19 @@ t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, cons double t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element) { - t8_eclass_t tree_class; - t8_scheme *ts; + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); + const t8_scheme *ts = t8_forest_get_scheme (forest); double centroid[3], coordinates[3]; double dist; int i, num_corners; - /* Get the element's eclass and scheme */ - tree_class = t8_forest_get_tree_class (forest, ltreeid); - ts = t8_forest_get_eclass_scheme (forest, tree_class); /* validity check */ - T8_ASSERT (ts->t8_element_is_valid (element)); + T8_ASSERT (ts->element_is_valid (tree_class, element)); /* We approximate the diameter as twice the average of the distances * from the vertices to the centroid. */ - num_corners = ts->t8_element_num_corners (element); + num_corners = ts->element_get_num_corners (tree_class, element); /* Compute the centroid */ t8_forest_element_centroid (forest, ltreeid, element, centroid); @@ -492,18 +495,16 @@ t8_forest_element_diam (t8_forest_t forest, t8_locidx_t ltreeid, const t8_elemen void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates) { - t8_scheme *ts; - T8_ASSERT (t8_forest_is_committed (forest)); + const t8_scheme *ts t8_forest_get_eclass_scheme (forest); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); /* Get the tree's eclass and scheme. */ - const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); - ts = t8_forest_get_eclass_scheme (forest, tree_class); - T8_ASSERT (ts->t8_element_is_valid (element)); + T8_ASSERT (ts->element_is_valid (tree_class, element)); /* Get the element class and calculate the centroid using its element * reference coordinates */ - const t8_element_shape_t element_shape = t8_element_shape (ts, element); + const t8_element_shape_t element_shape = ts->element_get_shape (tree_class, element); t8_forest_element_from_ref_coords (forest, ltreeid, element, t8_element_centroid_ref_coords[element_shape], 1, coordinates); } @@ -575,17 +576,10 @@ t8_forest_element_tet_volume (const double coordinates[4][3]) double t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element) { - t8_eclass_t tree_class; - t8_element_shape_t element_shape; - t8_scheme *ts; - T8_ASSERT (t8_forest_is_committed (forest)); - - /* get the eclass of the forest */ - tree_class = t8_forest_get_tree_class (forest, ltreeid); - ts = t8_forest_get_eclass_scheme (forest, tree_class); - /* Get the geometrical shape of the element */ - element_shape = ts->t8_element_shape (element); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); + const t8_scheme *ts = t8_forest_get_scheme (forest); + const t8_element_shape_t element_shape = ts->element_get_shape (tree_class, element); switch (element_shape) { case T8_ECLASS_VERTEX: @@ -597,7 +591,6 @@ t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_elem case T8_ECLASS_QUAD: { int face_a, face_b, corner_a, corner_b; double coordinates[3][3]; - t8_scheme *ts; /* We use this formula for computing the surface area for a parallelogram * (we use parallelogram as approximation for the element). * @@ -611,12 +604,11 @@ t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_elem * 0 v_2 */ /* Compute the faces meeting at vertex 0 */ - ts = t8_forest_get_eclass_scheme (forest, T8_ECLASS_QUAD); - face_a = ts->t8_element_get_corner_face (element, 0, 0); - face_b = ts->t8_element_get_corner_face (element, 0, 1); + face_a = ts->element_get_corner_face (T8_ECLASS_QUAD, element, 0, 0); + face_b = ts->element_get_corner_face (T8_ECLASS_QUAD, element, 0, 1); /* Compute the other corners of these faces */ - corner_a = ts->t8_element_get_face_corner (element, face_a, 1); - corner_b = ts->t8_element_get_face_corner (element, face_b, 1); + corner_a = ts->element_get_face_corner (T8_ECLASS_QUAD, element, face_a, 1); + corner_b = ts->element_get_face_corner (T8_ECLASS_QUAD, element, face_b, 1); T8_ASSERT (corner_a != 0 && corner_b != 0); T8_ASSERT (corner_a != corner_b); /* Compute the coordinates of vertex 0, a and b */ @@ -742,18 +734,10 @@ t8_forest_element_volume (t8_forest_t forest, t8_locidx_t ltreeid, const t8_elem double t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face) { - - t8_eclass_t tree_class; - t8_element_shape_t face_shape; - t8_scheme *ts; - T8_ASSERT (t8_forest_is_committed (forest)); - - /* get the eclass of the forest */ - tree_class = t8_forest_get_tree_class (forest, ltreeid); - /* get the element's scheme and the face scheme */ - ts = t8_forest_get_eclass_scheme (forest, tree_class); - face_shape = ts->t8_element_face_shape (element, face); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); + const t8_scheme *ts = t8_forest_get_scheme (forest); + const t8_element_shape_t face_shape = ts->t8_element_face_shape (tree_class, element, face); switch (face_shape) { case T8_ECLASS_VERTEX: @@ -764,8 +748,8 @@ t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_e int corner_a, corner_b; /* Compute the two endnotes of the face line */ - corner_a = ts->t8_element_get_face_corner (element, face, 0); - corner_b = ts->t8_element_get_face_corner (element, face, 1); + corner_a = ts->element_get_face_corner (tree_class, element, face, 0); + corner_b = ts->element_get_face_corner (tree_class, element, face, 1); /* Compute the length of this line */ return t8_forest_element_line_length (forest, ltreeid, element, corner_a, corner_b); @@ -776,7 +760,7 @@ t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_e /* Compute the coordinates of the triangle's vertices */ for (i = 0; i < 3; i++) { - face_corner = ts->t8_element_get_face_corner (element, face, i); + face_corner = ts->element_get_face_corner (tree_class, element, face, i); t8_forest_element_coordinate (forest, ltreeid, element, face_corner, coordinates[i]); } @@ -799,7 +783,7 @@ t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_e /* Compute the coordinates of the first triangle's vertices */ for (i = 0; i < 3; i++) { - face_corner = ts->t8_element_get_face_corner (element, face, i); + face_corner = ts->element_get_face_corner (tree_class, element, face, i); t8_forest_element_coordinate (forest, ltreeid, element, face_corner, coordinates[i]); } /* Compute the first triangle's area */ @@ -809,7 +793,7 @@ t8_forest_element_face_area (t8_forest_t forest, t8_locidx_t ltreeid, const t8_e /* Since the function element_triangle_are has modified coordinates, * we recompute all corner coordinates for the second triangle. */ for (i = 0; i < 3; i++) { - face_corner = ts->t8_element_get_face_corner (element, face, i + 1); + face_corner = ts->element_get_face_corner (tree_class, element, face, i + 1); t8_forest_element_coordinate (forest, ltreeid, element, face_corner, coordinates[i]); } @@ -826,23 +810,16 @@ void t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, double centroid[3]) { - t8_eclass_t tree_class; - t8_element_shape_t face_shape; - t8_scheme *ts; - T8_ASSERT (t8_forest_is_committed (forest)); - /* get the eclass of the forest */ - tree_class = t8_forest_get_tree_class (forest, ltreeid); - /* get the element's scheme and the face shape */ - ts = t8_forest_get_eclass_scheme (forest, tree_class); - face_shape = ts->t8_element_face_shape (element, face); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); + const t8_scheme *ts = t8_forest_get_scheme (forest); + const t8_element_shape_t face_shape = ts->t8_element_face_shape (tree_class, element, face); switch (face_shape) { case T8_ECLASS_VERTEX: { /* Element is a line, the face midpoint is the vertex itself */ - int corner; /* Get the index of the corner that is the face */ - corner = ts->t8_element_get_face_corner (element, face, 0); + const int corner = ts->element_get_face_corner (tree_class, element, face, 0); /* Compute the coordinates of this corner */ t8_forest_element_coordinate (forest, ltreeid, element, corner, centroid); return; @@ -852,8 +829,8 @@ t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const double vertex_a[3]; /* Compute the corner indices of the face */ - corner_a = ts->t8_element_get_face_corner (element, face, 0); - corner_b = ts->t8_element_get_face_corner (element, face, 1); + corner_a = ts->element_get_face_corner (tree_class, element, face, 0); + corner_b = ts->element_get_face_corner (tree_class, element, face, 1); /* Compute the vertex coordinates of these corners */ t8_forest_element_coordinate (forest, ltreeid, element, corner_a, vertex_a); t8_forest_element_coordinate (forest, ltreeid, element, corner_b, centroid); @@ -873,7 +850,7 @@ t8_forest_element_face_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const /* We compute the average of all corner coordinates */ num_corners = face_shape == T8_ECLASS_TRIANGLE ? 3 : 4; for (i = 0; i < num_corners; i++) { - corner = ts->t8_element_get_face_corner (element, face, i); + corner = ts->element_get_face_corner (tree_class, element, face, i); t8_forest_element_coordinate (forest, ltreeid, element, corner, coordinates[i]); } @@ -1171,7 +1148,7 @@ t8_forest_populate (t8_forest_t forest) t8_element_t *element, *element_succ; t8_element_array_t *telements; t8_eclass_t tree_class; - t8_scheme *eclass_scheme; + t8_scheme *scheme; t8_gloidx_t cmesh_first_tree, cmesh_last_tree; int is_empty; @@ -1212,24 +1189,24 @@ t8_forest_populate (t8_forest_t forest) tree = (t8_tree_t) t8_sc_array_index_locidx (forest->trees, jt - forest->first_local_tree); tree_class = tree->eclass = t8_cmesh_get_tree_class (forest->cmesh, jt - first_ctree); tree->elements_offset = count_elements; - eclass_scheme = forest->scheme_cxx->eclass_schemes[tree_class]; - T8_ASSERT (eclass_scheme != NULL); + scheme = forest->scheme; + T8_ASSERT (scheme != NULL); telements = &tree->elements; /* calculate first and last element on this tree */ start = (jt == forest->first_local_tree) ? child_in_tree_begin : 0; end = (jt == forest->last_local_tree) ? child_in_tree_end - : eclass_scheme->t8_element_count_leaves_from_root (forest->set_level); + : scheme->count_leaves_from_root (tree_class, forest->set_level); num_tree_elements = end - start; T8_ASSERT (num_tree_elements > 0); /* Allocate elements for this processor. */ - t8_element_array_init_size (telements, eclass_scheme, num_tree_elements); + t8_element_array_init_size (telements, scheme, tree_class, num_tree_elements); element = t8_element_array_index_locidx_mutable (telements, 0); - eclass_scheme->t8_element_set_linear_id (element, forest->set_level, start); + scheme->element_set_linear_id (tree_class, element, forest->set_level, start); count_elements++; for (et = start + 1; et < end; et++, count_elements++) { element_succ = t8_element_array_index_locidx_mutable (telements, et - start); - T8_ASSERT (eclass_scheme->t8_element_level (element) == forest->set_level); - eclass_scheme->t8_element_successor (element, element_succ); + T8_ASSERT (scheme->element_get_level (tree_class, element) == forest->set_level); + scheme->element_construct_successor (element, element_succ); /* TODO: process elements here */ element = element_succ; } @@ -1410,9 +1387,8 @@ t8_forest_copy_trees (t8_forest_t forest, t8_forest_t from, int copy_elements) tree = (t8_tree_t) t8_sc_array_index_locidx (forest->trees, jt); fromtree = (t8_tree_t) t8_sc_array_index_locidx (from->trees, jt); tree->eclass = fromtree->eclass; - eclass_scheme = forest->scheme_cxx->eclass_schemes[tree->eclass]; num_tree_elements = t8_element_array_get_count (&fromtree->elements); - t8_element_array_init_size (&tree->elements, eclass_scheme, num_tree_elements); + t8_element_array_init_size (&tree->elements, forest->scheme, tree->eclass, num_tree_elements); /* TODO: replace with t8_elem_copy (not existing yet), in order to * eventually copy additional pointer data stored in the elements? * -> i.m.o. we should not allow such pointer data at the elements */ @@ -1529,24 +1505,19 @@ t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, cons t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, - t8_scheme *neigh_scheme, int face, int *neigh_face) + t8_eclass_t neigh_class, int face, int *neigh_face) { - t8_scheme *ts; - t8_tree_t tree; - t8_eclass_t eclass; - /* Get a pointer to the tree to read its element class */ - tree = t8_forest_get_tree (forest, ltreeid); - eclass = tree->eclass; - ts = t8_forest_get_eclass_scheme (forest, eclass); - if (neigh_scheme == ts && ts->t8_element_face_neighbor_inside (elem, neigh, face, neigh_face)) { + const t8_tree_t tree = t8_forest_get_tree (forest, ltreeid); + const t8_eclass_t eclass = tree->eclass; + t8_scheme *ts = t8_forest_get_scheme (forest); + if (neigh_eclass == eclass && ts->element_construct_face_neighbor_inside (eclass, elem, neigh, face, neigh_face)) { /* The neighbor was constructed and is inside the current tree. */ return ltreeid + t8_forest_get_first_local_tree_id (forest); } else { /* The neighbor does not lie inside the current tree. The content of neigh is undefined right now. */ - t8_scheme *boundary_scheme, *neighbor_scheme; - t8_eclass_t neigh_eclass, boundary_class; + t8_eclass_t neigh_eclass; t8_element_t *face_element; t8_cmesh_t cmesh; t8_locidx_t lctree_id, lcneigh_id; @@ -1561,20 +1532,19 @@ t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const cmesh = forest->cmesh; /* Get the scheme associated to the element class of the boundary element. */ /* Compute the face of elem_tree at which the face connection is. */ - tree_face = ts->t8_element_tree_face (elem, face); + tree_face = ts->element_get_tree_face (eclass, elem, face); /* compute coarse tree id */ lctree_id = t8_forest_ltreeid_to_cmesh_ltreeid (forest, ltreeid); if (t8_cmesh_tree_face_is_boundary (cmesh, lctree_id, tree_face)) { /* This face is a domain boundary. We do not need to continue */ return -1; } - /* Get the eclass scheme for the boundary */ - boundary_class = (t8_eclass_t) t8_eclass_face_types[eclass][tree_face]; - boundary_scheme = t8_forest_get_eclass_scheme (forest, boundary_class); + /* Get the eclass for the boundary */ + const t8_eclass_t boundary_class = (t8_eclass_t) t8_eclass_face_types[eclass][tree_face]; /* Allocate the face element */ - boundary_scheme->t8_element_new (1, &face_element); + ts->element_new (boundary_class, 1, &face_element); /* Compute the face element. */ - ts->t8_element_boundary_face (elem, face, face_element, boundary_scheme); + ts->element_construct_boundary_face (eclass, elem, face, face_element, boundary_class); /* Get the coarse tree that contains elem. * Also get the face neighbor information of the coarse tree. */ (void) t8_cmesh_trees_get_tree_ext (cmesh->trees, lctree_id, &face_neighbor, &ttf); @@ -1629,12 +1599,11 @@ t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const } /* We now transform the face element to the other tree. */ sign = t8_eclass_face_orientation[eclass][tree_face] == t8_eclass_face_orientation[neigh_eclass][tree_neigh_face]; - boundary_scheme->t8_element_transform_face (face_element, face_element, ttf[tree_face] / F, sign, is_smaller); + ts->element_transform_face (boundary_class, face_element, face_element, ttf[tree_face] / F, sign, is_smaller); /* And now we extrude the face to the new neighbor element */ - neighbor_scheme = forest->scheme_cxx->eclass_schemes[neigh_eclass]; - *neigh_face = neighbor_scheme->t8_element_extrude_face (face_element, boundary_scheme, neigh, tree_neigh_face); + *neigh_face = ts->element_extrude_face (neigh_eclass, face_element, boundary_class, neigh, tree_neigh_face); /* Free the face_element */ - boundary_scheme->t8_element_destroy (1, &face_element); + ts->element_destroy (boundary_class, 1, &face_element); return global_neigh_id; } @@ -1642,12 +1611,10 @@ t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_gloidx_t t8_forest_element_half_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, - t8_element_t *neighs[], t8_scheme *neigh_scheme, int face, int num_neighs, + t8_element_t *neighs[], t8_eclass_t neigh_class, int face, int num_neighs, int dual_faces[]) { - t8_scheme *ts; t8_tree_t tree; - t8_eclass_t eclass; t8_element_t **children_at_face; t8_gloidx_t neighbor_tree = -1; #ifdef T8_ENABLE_DEBUG @@ -1659,17 +1626,17 @@ t8_forest_element_half_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, /* Get the current tree and its element class */ tree = t8_forest_get_tree (forest, ltreeid); - eclass = tree->eclass; - /* The eclass scheme for the current tree */ - ts = t8_forest_get_eclass_scheme (forest, eclass); - SC_CHECK_ABORT (ts->t8_element_level (elem) < t8_forest_get_maxlevel (forest), + const t8_eclass_t eclass = tree->eclass; + /* The scheme for the current tree */ + const t8_scheme *ts = t8_forest_get_scheme (forest); + SC_CHECK_ABORT (ts->element_get_level (eclass, elem) < t8_forest_get_maxlevel (forest), "Trying to refine an element beyond its maximum allowed level."); /* The number of children of elem at face */ - T8_ASSERT (num_neighs == ts->t8_element_num_face_children (elem, face)); + T8_ASSERT (num_neighs == ts->element_get_num_face_children (eclass, elem, face)); num_children_at_face = num_neighs; /* Allocate memory for the children of elem that share a face with face. */ children_at_face = T8_ALLOC (t8_element_t *, num_children_at_face); - ts->t8_element_new (num_children_at_face, children_at_face); + ts->element_new (eclass, num_children_at_face, children_at_face); /* Construct the children of elem at face * @@ -1680,16 +1647,16 @@ t8_forest_element_half_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, * c-----d x--d * */ - ts->t8_element_children_at_face (elem, face, children_at_face, num_children_at_face, NULL); + ts->element_get_children_at_face (eclass, elem, face, children_at_face, num_children_at_face, NULL); /* For each face_child build its neighbor */ for (child_it = 0; child_it < num_children_at_face; child_it++) { /* The face number of the face of the child that coincides with face * is not necessarily the same as the face number of elem. (which is the integer face) * We thus have to compute the face number of the child first. */ - child_face = ts->t8_element_face_child_face (elem, face, child_it); + child_face = ts->element_face_get_child_face (eclass, elem, face, child_it); neighbor_tree = t8_forest_element_face_neighbor (forest, ltreeid, children_at_face[child_it], neighs[child_it], - neigh_scheme, child_face, &neigh_face); + neigh_class, child_face, &neigh_face); if (dual_faces != NULL) { /* Store the dual face */ dual_faces[child_it] = neigh_face; @@ -1701,7 +1668,7 @@ t8_forest_element_half_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, #endif } /* Clean-up the memory */ - ts->t8_element_destroy (num_children_at_face, children_at_face); + ts->element_destroy (eclass, num_children_at_face, children_at_face); T8_FREE (children_at_face); return neighbor_tree; } @@ -3101,8 +3068,8 @@ t8_forest_refines_irregular (t8_forest_t forest) for (int_eclass = (int) T8_ECLASS_ZERO; int_eclass < (int) T8_ECLASS_COUNT; int_eclass++) { /* If the forest has trees of the current eclass, check if elements of this eclass refine irregular. */ if (forest->cmesh->num_local_trees_per_eclass[int_eclass] > 0) { - tscheme = t8_forest_get_eclass_scheme_before_commit (forest, (t8_eclass_t) int_eclass); - irregular = irregular || t8_element_refines_irregular (tscheme); + tscheme = t8_forest_get_scheme_before_commit (forest); + irregular = irregular || t8_element_refines_irregular (tscheme, (t8_eclass_t) int_eclass); } } /* Combine the process-local results via a logic or and distribute the result over all procs (in the communicator).*/ @@ -3754,6 +3721,15 @@ t8_forest_get_scheme (const t8_forest_t forest) return forest->scheme; } +t8_scheme * +t8_forest_get_scheme_before_commit (const t8_forest_t forest) +{ + T8_ASSERT (t8_forest_is_initialized (forest)); + T8_ASSERT (forest->scheme != NULL); + + return forest->scheme; +} + t8_eclass_t t8_forest_get_eclass (const t8_forest_t forest, const t8_locidx_t ltreeid) { diff --git a/src/t8_forest/t8_forest_adapt.cxx b/src/t8_forest/t8_forest_adapt.cxx index e6598311df..43bca33f4f 100644 --- a/src/t8_forest/t8_forest_adapt.cxx +++ b/src/t8_forest/t8_forest_adapt.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -437,7 +438,7 @@ t8_forest_adapt (t8_forest_t forest) if (num_el_from > 0) { const t8_element_t *first_element_from = t8_element_array_index_locidx (telements_from, 0); /* Get the element scheme for this tree */ - tscheme = t8_forest_get_eclass_scheme (forest_from, tree->eclass); + tscheme = t8_forest_get_scheme (forest_from, tree->eclass); /* Index of the element we currently consider for refinement/coarsening. */ el_considered = 0; /* Index into the newly inserted elements */ @@ -445,9 +446,9 @@ t8_forest_adapt (t8_forest_t forest) /* el_coarsen is the index of the first element in the new element * array which could be coarsened recursively. */ el_coarsen = 0; - num_children = tscheme->t8_element_num_children (first_element_from); + num_children = tscheme->element_get_num_children (tree->eclass, first_element_from); curr_size_elements = num_children; - curr_size_elements_from = tscheme->t8_element_num_siblings (first_element_from); + curr_size_elements_from = tscheme->element_get_num_siblings (tree->eclass, first_element_from); /* Buffer for a family of new elements */ elements = T8_ALLOC (t8_element_t *, num_children); /* Buffer for a family of old elements */ @@ -460,7 +461,8 @@ t8_forest_adapt (t8_forest_t forest) * At the end is_family will be true, if these elements form a family. */ - num_siblings = tscheme->t8_element_num_siblings (t8_element_array_index_locidx (telements_from, el_considered)); + num_siblings = tscheme->element_get_num_siblings ( + tree->eclass, t8_element_array_index_locidx (telements_from, el_considered)); if (num_siblings > curr_size_elements_from) { /* Enlarge the elements_from buffer if required */ @@ -481,7 +483,7 @@ t8_forest_adapt (t8_forest_t forest) * be part of a family (Since we can only have a family if child ids * are 0, 1, 2, ... zz, ... num_siblings-1). * This check is however not sufficient - therefore, we call is_family later. */ - if (!forest_from->incomplete_trees && tscheme->t8_element_child_id (elements_from[zz]) != zz) { + if (!forest_from->incomplete_trees && tscheme->element_get_child_id (tree->eclass, elements_from[zz]) != zz) { break; } } @@ -491,14 +493,14 @@ t8_forest_adapt (t8_forest_t forest) is_family = 0; num_elements_to_adapt_callback = 1; if (forest_from->incomplete_trees) { - is_family = t8_forest_is_incomplete_family (forest_from, ltree_id, el_considered, tscheme, elements_from, zz); + is_family = t8_forest_is_incomplete_family (forest_from, ltree_id, el_considered, elements_from, zz); if (is_family > 0) { /* We will pass a (in)complete family to the adapt callback */ num_elements_to_adapt_callback = is_family; is_family = 1; } } - else if (zz == num_siblings && tscheme->t8_element_is_family (elements_from)) { + else if (zz == num_siblings && tscheme->elements_are_family (tree->eclass, elements_from)) { /* We will pass a full family to the adapt callback */ is_family = 1; num_elements_to_adapt_callback = num_siblings; @@ -512,7 +514,7 @@ t8_forest_adapt (t8_forest_t forest) } else { T8_ASSERT (forest_from->incomplete_trees == 0); - T8_ASSERT (!is_family || tscheme->t8_element_is_family (elements_from)); + T8_ASSERT (!is_family || tscheme->elements_are_family (tree->eclass, elements_from)); } #endif /* Pass the element, or the family to the adapt callback. @@ -525,21 +527,21 @@ t8_forest_adapt (t8_forest_t forest) num_elements_to_adapt_callback, elements_from); T8_ASSERT (is_family || refine != -1); - if (refine > 0 && tscheme->t8_element_level (elements_from[0]) >= forest->maxlevel) { + if (refine > 0 && tscheme->element_get_level (tree->eclass, elements_from[0]) >= forest->maxlevel) { /* Only refine an element if it does not exceed the maximum level */ refine = 0; } if (refine == 1) { /* The first element is to be refined */ - num_children = tscheme->t8_element_num_children (elements_from[0]); + num_children = tscheme->element_get_num_children (tree->eclass, elements_from[0]); if (num_children > curr_size_elements) { elements = T8_REALLOC (elements, t8_element_t *, num_children); curr_size_elements = num_children; } if (forest->set_adapt_recursive) { /* Create the children of this element */ - tscheme->t8_element_new (num_children, elements); - tscheme->t8_element_children (elements_from[0], num_children, elements); + tscheme->element_new (tree->eclass, num_children, elements); + tscheme->element_get_children (tree->eclass, elements_from[0], num_children, elements); for (ci = num_children - 1; ci >= 0; ci--) { /* Prepend the children to the refine_list. * These should now be the only elements in the list. @@ -557,7 +559,7 @@ t8_forest_adapt (t8_forest_t forest) /* TODO: In a future version elements_from[zz] should be const and we should call t8_element_array_index_locidx (the const version). */ elements[zz] = t8_element_array_index_locidx_mutable (telements, el_inserted + zz); } - tscheme->t8_element_children (elements_from[0], num_children, elements); + tscheme->element_get_children (tree->eclass, elements_from[0], num_children, elements); el_inserted += (t8_locidx_t) num_children; } el_considered++; @@ -568,8 +570,8 @@ t8_forest_adapt (t8_forest_t forest) elements[0] = t8_element_array_push (telements); /* Compute the parent of the current family. * This parent is now inserted in telements. */ - T8_ASSERT (tscheme->t8_element_level (elements_from[0]) > 0); - tscheme->t8_element_parent (elements_from[0], elements[0]); + T8_ASSERT (tscheme->element_get_level (tree->eclass, elements_from[0]) > 0); + tscheme->element_get_parent (tree->eclass, elements_from[0], elements[0]); /* num_siblings is now equivalent to the number of children of elements[0], * as num_siblings is always associated with elements_from*/ num_children = num_siblings; @@ -583,7 +585,7 @@ t8_forest_adapt (t8_forest_t forest) * We check whether the just generated parent is the last in its * family (and not the only one). * If so, we check this family for recursive coarsening. */ - const int child_id = tscheme->t8_element_child_id (elements[0]); + const int child_id = tscheme->element_get_child_id (tree->eclass, elements[0]); if (child_id > 0 && child_id == num_children - 1) { t8_forest_adapt_coarsen_recursive (forest, ltree_id, el_considered, tscheme, telements, el_coarsen, &el_inserted, elements); @@ -596,13 +598,13 @@ t8_forest_adapt (t8_forest_t forest) * one to be refined. * We copy the element to the new element array. */ elements[0] = t8_element_array_push (telements); - tscheme->t8_element_copy (elements_from[0], elements[0]); + tscheme->element_copy (tree->eclass, elements_from[0], elements[0]); el_inserted++; if (forest->set_adapt_recursive) { /* Adaptation is recursive. * If adaptation is recursive and this was the last element in its family * (and not the only one), we need to check for recursive coarsening. */ - const int child_id = tscheme->t8_element_child_id (elements[0]); + const int child_id = tscheme->element_get_child_id (tree->eclass, elements[0]); if (child_id > 0 && child_id == num_children - 1) { t8_forest_adapt_coarsen_recursive (forest, ltree_id, el_considered, tscheme, telements, el_coarsen, &el_inserted, elements); diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index a9b98556f8..da5e5bcf75 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include /* We want to export the whole implementation to be callable from "C" */ @@ -41,8 +42,9 @@ T8_EXTERN_C_BEGIN (); * we pass forest_from as a parameter. But doing so is not valid anymore * if we refine recursively. */ static int -t8_forest_balance_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t ltree_id, t8_locidx_t lelement_id, - t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) +t8_forest_balance_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t ltree_id, t8_eclass_t tree_class, + t8_locidx_t lelement_id, t8_scheme *ts, const int is_family, const int num_elements, + t8_element_t *elements[]) { int *pdone, iface, num_faces, num_half_neighbors, ineigh; t8_gloidx_t neighbor_tree; @@ -58,39 +60,40 @@ t8_forest_balance_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_ * If we enter from the check function is_balanced, then it may not be set. */ - if (forest_from->maxlevel_existing <= 0 || ts->t8_element_level (element) <= forest_from->maxlevel_existing - 2) { + if (forest_from->maxlevel_existing <= 0 + || ts->element_get_level (tree_class, element) <= forest_from->maxlevel_existing - 2) { pdone = (int *) forest->t8code_data; - num_faces = ts->t8_element_num_faces (element); + num_faces = ts->element_get_num_faces (tree_class, element); for (iface = 0; iface < num_faces; iface++) { /* Get the element class and scheme of the face neighbor */ neigh_class = t8_forest_element_neighbor_eclass (forest_from, ltree_id, element, iface); - neigh_scheme = t8_forest_get_eclass_scheme (forest_from, neigh_class); /* Allocate memory for the number of half face neighbors */ - num_half_neighbors = ts->t8_element_num_face_children (element, iface); + num_half_neighbors = ts->element_get_num_face_children (tree_class, element, iface); half_neighbors = T8_ALLOC (t8_element_t *, num_half_neighbors); - neigh_scheme->t8_element_new (num_half_neighbors, half_neighbors); + ts->element_new (neigh_class, num_half_neighbors, half_neighbors); /* Compute the half face neighbors of element at this face */ - neighbor_tree = t8_forest_element_half_face_neighbors (forest_from, ltree_id, element, half_neighbors, - neigh_scheme, iface, num_half_neighbors, NULL); + neighbor_tree = t8_forest_element_half_face_neighbors ( + forest_from, ltree_id, element, half_neighbors, neigh_scheme, iface, num_half_neighbors, NULL); // TODO: CRTP if (neighbor_tree >= 0) { /* The face neighbors do exist, check for each one, whether it has * local or ghost leaf descendants in the forest. * If so, the element will be refined. */ for (ineigh = 0; ineigh < num_half_neighbors; ineigh++) { - if (t8_forest_element_has_leaf_desc (forest_from, neighbor_tree, half_neighbors[ineigh], neigh_scheme)) { + if (t8_forest_element_has_leaf_desc (forest_from, neighbor_tree, half_neighbors[ineigh], + neigh_scheme)) { //TODO: CRTP /* This element should be refined */ *pdone = 0; /* clean-up */ - neigh_scheme->t8_element_destroy (num_half_neighbors, half_neighbors); + ts->element_destroy (neigh_class, num_half_neighbors, half_neighbors); T8_FREE (half_neighbors); return 1; } } } /* clean-up */ - neigh_scheme->t8_element_destroy (num_half_neighbors, half_neighbors); + ts->element_destroy (neigh_class, num_half_neighbors, half_neighbors); T8_FREE (half_neighbors); } } @@ -111,11 +114,12 @@ t8_forest_compute_max_element_level (t8_forest_t forest) num_trees = t8_forest_get_num_local_trees (forest); for (itree = 0; itree < num_trees; itree++) { elem_in_tree = t8_forest_get_tree_num_elements (forest, itree); - scheme = t8_forest_get_eclass_scheme (forest, t8_forest_get_tree_class (forest, itree)); + scheme = t8_forest_get_scheme (forest); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, itree); for (ielement = 0; ielement < elem_in_tree; ielement++) { /* Get the element and compute its level */ const t8_element_t *elem = t8_forest_get_element_in_tree (forest, itree, ielement); - elem_level = scheme->t8_element_level (elem); + elem_level = scheme->element_get_level (tree_class, elem); local_max_level = SC_MAX (local_max_level, elem_level); } } @@ -335,13 +339,14 @@ t8_forest_is_balanced (t8_forest_t forest) /* Iterate over all trees */ for (itree = 0; itree < num_trees; itree++) { num_elements = t8_forest_get_tree_num_elements (forest, itree); - ts = t8_forest_get_eclass_scheme (forest, t8_forest_get_tree_class (forest, itree)); + ts = t8_forest_get_scheme (forest); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, itree); /* Iterate over all elements of this tree */ for (ielem = 0; ielem < num_elements; ielem++) { const t8_element_t *element = t8_forest_get_element_in_tree (forest, itree, ielem); /* Test if this element would need to be refined in the balance step. * If so, the forest is not balanced locally. */ - if (t8_forest_balance_adapt (forest, forest, itree, ielem, ts, 0, 1, (t8_element_t **) (&element))) { + if (t8_forest_balance_adapt (forest, forest, itree, tree_class, ielem, ts, 0, 1, (t8_element_t **) (&element))) { forest->set_from = forest_from; forest->t8code_data = data_temp; return 0; diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index 550de10561..a668508ed3 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -64,7 +64,7 @@ T8_EXTERN_C_BEGIN (); * \param [in] forest_new The forest that is newly constructed from \a forest_old * \param [in] which_tree The local tree containing \a first_outgoing and \a first_incoming * \param [in] tree_class The eclass of the local tree containing \a first_outgoing and \a first_incoming - * \param [in] ts The eclass scheme of the tree + * \param [in] ts The scheme of the forest * \param [in] refine -1 if family in \a forest_old got coarsened, 0 if element * has not been touched, 1 if element got refined and -2 if * element got removed. See return of t8_forest_adapt_t. @@ -96,13 +96,14 @@ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, t8_forest_t forest_ * Otherwise \a is_family must equal zero and we consider the first entry * of the element array for refinement. * Entries of the element array beyond the first \a num_elements are undefined. - * \param [in] forest the forest to which the new elements belong - * \param [in] forest_from the forest that is adapted. - * \param [in] which_tree the local tree containing \a elements - * \param [in] lelement_id the local element id in \a forest_old in the tree of the current element - * \param [in] ts the eclass scheme of the tree - * \param [in] is_family if 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. - * \param [in] num_elements the number of entries in \a elements that are defined + * \param [in] forest The forest to which the new elements belong. + * \param [in] forest_from The forest that is adapted. + * \param [in] which_tree The local tree containing \a elements. + * \param [in] tree_class The eclass of \a which_tree. + * \param [in] lelement_id The local element id in \a forest_old in the tree of the current element. + * \param [in] ts The scheme of the forest. + * \param [in] is_family If 1, the first \a num_elements entries in \a elements form a family. If 0, they do not. + * \param [in] num_elements The number of entries in \a elements that are defined * \param [in] elements Pointers to a family or, if \a is_family is zero, * pointer to one element. * \return 1 if the first entry in \a elements should be refined, @@ -113,8 +114,8 @@ typedef void (*t8_forest_replace_t) (t8_forest_t forest_old, t8_forest_t forest_ /* TODO: Do we really need the forest argument? Since the forest is not committed yet it * seems dangerous to expose to the user. */ typedef int (*t8_forest_adapt_t) (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, - t8_locidx_t lelement_id, t8_scheme_c *ts, const int is_family, const int num_elements, - t8_element_t *elements[]); + t8_eclass_t tree_class, t8_locidx_t lelement_id, t8_scheme_c *ts, const int is_family, + const int num_elements, t8_element_t *elements[]); /** Create a new forest with reference count one. * This forest needs to be specialized with the t8_forest_set_* calls. diff --git a/src/t8_forest/t8_forest_ghost.cxx b/src/t8_forest/t8_forest_ghost.cxx index f606acd850..995cdc659c 100644 --- a/src/t8_forest/t8_forest_ghost.cxx +++ b/src/t8_forest/t8_forest_ghost.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -367,7 +368,7 @@ t8_forest_ghost_get_element (t8_forest_t forest, t8_locidx_t lghost_tree, t8_loc /* Initialize a t8_ghost_remote_tree_t */ static void -t8_ghost_init_remote_tree (t8_forest_t forest, t8_gloidx_t gtreeid, int remote_rank, t8_eclass_t eclass, +t8_ghost_init_remote_tree (t8_forest_t forest, t8_gloidx_t gtreeid, int remote_rank, t8_eclass_t tree_class, t8_ghost_remote_tree_t *remote_tree) { t8_scheme *ts; @@ -375,14 +376,14 @@ t8_ghost_init_remote_tree (t8_forest_t forest, t8_gloidx_t gtreeid, int remote_r T8_ASSERT (remote_tree != NULL); - ts = t8_forest_get_eclass_scheme (forest, eclass); + ts = t8_forest_get_scheme (forest); local_treeid = gtreeid - t8_forest_get_first_local_tree_id (forest); /* Set the entries of the new remote tree */ remote_tree->global_id = gtreeid; remote_tree->mpirank = remote_rank; remote_tree->eclass = t8_forest_get_eclass (forest, local_treeid); /* Initialize the array to store the element */ - t8_element_array_init (&remote_tree->elements, ts); + t8_element_array_init (&remote_tree->elements, ts, tree_class); /* Initialize the array to store the element indices. */ sc_array_init (&remote_tree->element_indices, sizeof (t8_locidx_t)); } @@ -398,7 +399,7 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran t8_ghost_remote_tree_t *remote_tree; t8_element_t *elem_copy; t8_scheme *ts; - t8_eclass_t eclass; + t8_eclass_t tree_class; sc_array_t *remote_array; size_t index, element_count; t8_gloidx_t gtreeid; @@ -406,8 +407,8 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran int level, copy_level = 0; /* Get the tree's element class and the scheme */ - eclass = t8_forest_get_tree_class (forest, ltreeid); - ts = t8_forest_get_eclass_scheme (forest, eclass); + tree_class = t8_forest_get_tree_class (forest, ltreeid); + ts = t8_forest_get_scheme (forest); gtreeid = t8_forest_get_first_local_tree_id (forest) + ltreeid; /* Check whether the remote_rank is already present in the remote ghosts @@ -426,7 +427,7 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran /* Get a pointer to the new entry */ remote_tree = (t8_ghost_remote_tree_t *) sc_array_index (&remote_entry->remote_trees, 0); /* initialize the remote_tree */ - t8_ghost_init_remote_tree (forest, gtreeid, remote_rank, eclass, remote_tree); + t8_ghost_init_remote_tree (forest, gtreeid, remote_rank, tree_class, remote_tree); /* Since the rank is a new remote rank, we also add it to the remote ranks array */ remote_process_entry = (int *) sc_array_push (ghost->remote_processes); *remote_process_entry = remote_rank; @@ -445,7 +446,7 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran /* The tree does not exist in the array. We thus need to add it and * initialize it. */ remote_tree = (t8_ghost_remote_tree_t *) sc_array_push (&remote_entry->remote_trees); - t8_ghost_init_remote_tree (forest, gtreeid, remote_rank, eclass, remote_tree); + t8_ghost_init_remote_tree (forest, gtreeid, remote_rank, tree_class, remote_tree); } } /* remote_tree now points to a valid entry for the tree. @@ -458,26 +459,27 @@ t8_ghost_add_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int remote_ran int elem_count = t8_element_array_get_count (&remote_tree->elements); for (ielem = 0; ielem < elem_count - 1; ielem++) { const t8_element_t *test_el = t8_element_array_index_int (&remote_tree->elements, ielem); - SC_CHECK_ABORTF (!ts->t8_element_equal (test_el, elem), "Local element %i already in remote ghosts at pos %i\n", - element_index, ielem); + SC_CHECK_ABORTF (!ts->element_is_equal (tree_class, test_el, elem), + "Local element %i already in remote ghosts at pos %i\n", element_index, ielem); } } #endif elem_copy = NULL; - level = ts->t8_element_level (elem); + level = ts->element_get_level (tree_class, elem); element_count = t8_element_array_get_count (&remote_tree->elements); if (element_count > 0) { elem_copy = t8_element_array_index_locidx_mutable (&remote_tree->elements, element_count - 1); - copy_level = ts->t8_element_level (elem_copy); + copy_level = ts->element_get_level (tree_class, elem_copy); } /* Check if the element was not contained in the array. * If so, we add a copy of elem to the array. * Otherwise, we do nothing. */ if (elem_copy == NULL || level != copy_level - || ts->t8_element_get_linear_id (elem_copy, copy_level) != ts->t8_element_get_linear_id (elem, level)) { + || ts->element_get_linear_id (tree_class, elem_copy, copy_level) + != ts->element_get_linear_id (tree_class, elem, level)) { /* Add the element */ elem_copy = t8_element_array_push (&remote_tree->elements); - ts->t8_element_copy (elem, elem_copy); + ts->element_copy (tree_class, elem, elem_copy); /* Add the index of the element */ *(t8_locidx_t *) sc_array_push (&remote_tree->element_indices) = element_index; remote_entry->num_elements++; @@ -521,7 +523,7 @@ t8_forest_ghost_search_boundary (t8_forest_t forest, t8_locidx_t ltreeid, const /* The search has entered a new tree, store its eclass and element scheme */ data->gtreeid = t8_forest_global_tree_id (forest, ltreeid); data->eclass = t8_forest_get_eclass (forest, ltreeid); - data->ts = t8_forest_get_eclass_scheme (forest, data->eclass); + data->ts = t8_forest_get_scheme (forest); data->level_nca = data->ts->t8_element_level (element); data->max_num_faces = data->ts->t8_element_max_num_faces (element); max_num_faces = data->max_num_faces; @@ -537,7 +539,7 @@ t8_forest_ghost_search_boundary (t8_forest_t forest, t8_locidx_t ltreeid, const } /* The level of the current element */ - level = data->ts->t8_element_level (element); + level = data->ts->element_get_level (data->eclass, element); /* Get a pointer to the owner at face bounds of this element, if there doesnt exist * an entry for this in the bounds_per_level array yet, we allocate it */ T8_ASSERT (level >= data->level_nca); @@ -563,7 +565,7 @@ t8_forest_ghost_search_boundary (t8_forest_t forest, t8_locidx_t ltreeid, const new_bounds[2 * data->max_num_faces] = el_lower; new_bounds[2 * data->max_num_faces + 1] = el_upper; element_is_owned = (el_lower == el_upper); - num_faces = data->ts->t8_element_num_faces (element); + num_faces = data->ts->element_get_num_faces (data->eclass, element); faces_totally_owned = 1; /* TODO: we may not carry on with the face computations if the element is not @@ -572,7 +574,7 @@ t8_forest_ghost_search_boundary (t8_forest_t forest, t8_locidx_t ltreeid, const */ for (iface = 0; iface < num_faces; iface++) { /* Compute the face number of the parent to reuse the bounds */ - parent_face = data->ts->t8_element_face_parent_face (element, iface); + parent_face = data->ts->element_face_get_parent_face (data->eclass, element, iface); if (parent_face >= 0) { /* This face was also a face of the parent, we reuse the computed bounds */ lower = bounds[parent_face * 2]; @@ -685,9 +687,9 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int gh t8_locidx_t num_local_trees, num_tree_elems; t8_locidx_t itree, ielem; t8_tree_t tree; - t8_eclass_t tree_class, neigh_class, last_class; + t8_eclass_t neigh_class, last_class; t8_gloidx_t neighbor_tree; - t8_scheme *ts, *neigh_scheme = NULL, *prev_neigh_scheme = NULL; + t8_scheme *prev_neigh_scheme = NULL; int iface, num_faces; int num_face_children, max_num_face_children = 0; @@ -707,16 +709,16 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int gh /* Get a pointer to the tree, the class of the tree, the * scheme associated to the class and the number of elements in this tree. */ tree = t8_forest_get_tree (forest, itree); - tree_class = t8_forest_get_tree_class (forest, itree); - ts = t8_forest_get_eclass_scheme (forest, tree_class); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, itree); + const t8_scheme *ts = t8_forest_get_scheme (forest); /* Loop over the elements of this tree */ num_tree_elems = t8_forest_get_tree_element_count (tree); for (ielem = 0; ielem < num_tree_elems; ielem++) { /* Get the element of the tree */ const t8_element_t *elem = t8_forest_get_tree_element (tree, ielem); - num_faces = ts->t8_element_num_faces (elem); - if (ts->t8_element_level (elem) == ts->t8_element_maxlevel ()) { + num_faces = ts->element_get_num_faces (tree_class, elem); + if (ts->element_get_level (tree_class, elem) == ts->get_maxlevel (tree_class)) { /* flag to decide whether this element is at the maximum level */ is_atom = 1; } @@ -731,37 +733,35 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int gh /* Get the element class of the neighbor tree */ neigh_class = t8_forest_element_neighbor_eclass (forest, itree, elem, iface); - neigh_scheme = t8_forest_get_eclass_scheme (forest, neigh_class); if (ghost_method == 0) { /* Use half neighbors */ /* Get the number of face children of the element at this face */ - num_face_children = ts->t8_element_num_face_children (elem, iface); + num_face_children = ts->element_get_num_face_children (tree_class, elem, iface); /* regrow the half_neighbors array if necessary. * We also need to reallocate it, if the element class of the neighbor * changes */ if (max_num_face_children < num_face_children || last_class != neigh_class) { if (max_num_face_children > 0) { /* Clean-up memory */ - prev_neigh_scheme->t8_element_destroy (max_num_face_children, half_neighbors); + ts->element_destroy (last_class, max_num_face_children, half_neighbors); T8_FREE (half_neighbors); } half_neighbors = T8_ALLOC (t8_element_t *, num_face_children); /* Allocate memory for the half size face neighbors */ - neigh_scheme->t8_element_new (num_face_children, half_neighbors); + ts->element_new (neigh_class, num_face_children, half_neighbors); max_num_face_children = num_face_children; last_class = neigh_class; - prev_neigh_scheme = neigh_scheme; } if (!is_atom) { /* Construct each half size neighbor */ - neighbor_tree = t8_forest_element_half_face_neighbors (forest, itree, elem, half_neighbors, neigh_scheme, + neighbor_tree = t8_forest_element_half_face_neighbors (forest, itree, elem, half_neighbors, neigh_class, iface, num_face_children, NULL); } else { int dummy_neigh_face; /* This element has maximum level, we only construct its neighbor */ - neighbor_tree = t8_forest_element_face_neighbor (forest, itree, elem, half_neighbors[0], neigh_scheme, - iface, &dummy_neigh_face); + neighbor_tree = t8_forest_element_face_neighbor (forest, itree, elem, half_neighbors[0], neigh_class, iface, + &dummy_neigh_face); } if (neighbor_tree >= 0) { /* If there exist face neighbor elements (we are not at a domain boundary */ @@ -805,7 +805,7 @@ t8_forest_ghost_fill_remote (t8_forest_t forest, t8_forest_ghost_t ghost, int gh /* Clean-up memory */ if (ghost_method == 0) { if (half_neighbors != NULL) { - neigh_scheme->t8_element_destroy (max_num_face_children, half_neighbors); + ts->t8_element_destroy (neigh_class, max_num_face_children, half_neighbors); T8_FREE (half_neighbors); } } @@ -1063,8 +1063,8 @@ t8_forest_ghost_parse_received_message (t8_forest_t forest, t8_forest_ghost_t gh tree_hash = (t8_ghost_gtree_hash_t *) sc_mempool_alloc (ghost->glo_tree_mempool); tree_hash->global_id = global_id; - /* Get the element scheme for this tree */ - ts = t8_forest_get_eclass_scheme (forest, eclass); + /* Get the scheme for this tree */ + ts = t8_forest_get_scheme (forest); if (sc_hash_insert_unique (ghost->global_tree_to_ghost_tree, tree_hash, (void ***) &pfound_tree)) { /* The tree was not stored already, tree_hash is now an entry in the hash table. */ /* If the tree was not contained, it is the newest tree in the array and @@ -1076,7 +1076,7 @@ t8_forest_ghost_parse_received_message (t8_forest_t forest, t8_forest_ghost_t gh ghost_tree->global_id = global_id; ghost_tree->eclass = eclass; /* Initialize the element array */ - t8_element_array_init_size (&ghost_tree->elements, ts, num_elements); + t8_element_array_init_size (&ghost_tree->elements, ts, eclass, num_elements); /* pointer to where the elements are to be inserted */ element_insert = t8_element_array_get_data_mutable (&ghost_tree->elements); /* Compute the element offset of this new tree by adding the offset @@ -1094,7 +1094,7 @@ t8_forest_ghost_parse_received_message (t8_forest_t forest, t8_forest_ghost_t gh ghost_tree = (t8_ghost_tree_t *) sc_array_index (ghost->ghost_trees, found_tree->index); T8_ASSERT (ghost_tree->eclass == eclass); T8_ASSERT (ghost_tree->global_id == global_id); - T8_ASSERT (ghost_tree->elements.scheme == ts); + T8_ASSERT (ghost_tree->elements.tree_class == eclass); old_elem_count = t8_element_array_get_count (&ghost_tree->elements); @@ -1111,9 +1111,9 @@ t8_forest_ghost_parse_received_message (t8_forest_t forest, t8_forest_ghost_t gh first_element_index = old_elem_count; } /* Insert the new elements */ - memcpy (element_insert, recv_buffer + bytes_read, num_elements * ts->t8_element_size ()); + memcpy (element_insert, recv_buffer + bytes_read, num_elements * ts->get_element_size (eclass)); - bytes_read += num_elements * ts->t8_element_size (); + bytes_read += num_elements * ts->get_element_size (eclass); bytes_read += T8_ADD_PADDING (bytes_read); *current_element_offset += num_elements; } diff --git a/src/t8_forest/t8_forest_iterate.cxx b/src/t8_forest/t8_forest_iterate.cxx index bb3585d952..a2e3b5613c 100644 --- a/src/t8_forest/t8_forest_iterate.cxx +++ b/src/t8_forest/t8_forest_iterate.cxx @@ -96,14 +96,14 @@ t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_eleme return; } eclass = t8_forest_get_tree_class (forest, ltreeid); - ts = t8_forest_get_eclass_scheme (forest, eclass); + ts = t8_forest_get_scheme (forest); if (elem_count == 1) { /* There is only one leaf left, we check whether it is the same as element * and if so call the callback function */ const t8_element_t *leaf = t8_element_array_index_locidx (leaf_elements, 0); T8_ASSERT (t8_forest_element_is_leaf (forest, leaf, ltreeid)); - if (ts->t8_element_equal (element, leaf)) { + if (ts->element_is_equal (eclass, element, leaf)) { /* The element is the leaf, we are at the last stage of the recursion * and can call the callback. */ (void) callback (forest, ltreeid, leaf, face, user_data, tree_lindex_of_first_leaf); @@ -114,7 +114,7 @@ t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_eleme /* Check whether element has greater level than the first leaf */ const t8_element_t *leaf = t8_element_array_index_locidx (leaf_elements, 0); T8_ASSERT (t8_forest_element_is_leaf (forest, leaf, ltreeid)); - T8_ASSERT (ts->t8_element_level (element) < ts->t8_element_level (leaf)); + T8_ASSERT (ts->element_get_level (eclass, element) < ts->element_get_level (eclass, leaf)); #endif /* Call the callback function element, we pass -index - 1 as index to indicate @@ -123,15 +123,15 @@ t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_eleme /* Enter the recursion */ /* We compute all face children of E, compute their leaf arrays and call iterate_faces */ /* allocate the memory to store the face children */ - num_face_children = ts->t8_element_num_face_children (element, face); + num_face_children = ts->element_get_num_face_children (eclass, element, face); face_children = T8_ALLOC (t8_element_t *, num_face_children); ts->t8_element_new (num_face_children, face_children); /* Memory for the child indices of the face children */ child_indices = T8_ALLOC (int, num_face_children); /* Memory for the indices that split the leaf_elements array */ - split_offsets = T8_ALLOC (size_t, ts->t8_element_num_children (element) + 1); + split_offsets = T8_ALLOC (size_t, ts->element_get_num_children (eclass, element) + 1); /* Compute the face children */ - ts->t8_element_children_at_face (element, face, face_children, num_face_children, child_indices); + ts->element_get_children_at_face (eclass, element, face, face_children, num_face_children, child_indices); /* Split the leaves array in portions belonging to the children of element */ t8_forest_split_array (element, leaf_elements, split_offsets); for (iface = 0; iface < num_face_children; iface++) { @@ -143,14 +143,14 @@ t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_eleme * we construct an array of these leaves */ t8_element_array_init_view (&face_child_leaves, leaf_elements, indexa, indexb - indexa); /* Compute the corresponding face number of this face child */ - child_face = ts->t8_element_face_child_face (element, face, iface); + child_face = ts->element_face_get_child_face (eclass, element, face, iface); /* Enter the recursion */ t8_forest_iterate_faces (forest, ltreeid, face_children[iface], child_face, &face_child_leaves, user_data, indexa + tree_lindex_of_first_leaf, callback); } } /* clean-up */ - ts->t8_element_destroy (num_face_children, face_children); + ts->element_destroy (eclass, num_face_children, face_children); T8_FREE (face_children); T8_FREE (child_indices); T8_FREE (split_offsets); @@ -171,10 +171,10 @@ t8_forest_iterate_faces (t8_forest_t forest, t8_locidx_t ltreeid, const t8_eleme * the query function is not called for this element. */ static void -t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_element_t *element, const t8_scheme *ts, - t8_element_array_t *leaf_elements, const t8_locidx_t tree_lindex_of_first_leaf, - t8_forest_search_fn search_fn, t8_forest_query_fn query_fn, sc_array_t *queries, - sc_array_t *active_queries) +t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_element_t *element, + const t8_eclass_t tree_class, t8_element_array_t *leaf_elements, + const t8_locidx_t tree_lindex_of_first_leaf, t8_forest_search_fn search_fn, + t8_forest_query_fn query_fn, sc_array_t *queries, sc_array_t *active_queries) { /* Assertions to check for necessary requirements */ /* The forest must be committed */ @@ -184,6 +184,7 @@ t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_el /* If we have queries, we also must have a query function */ T8_ASSERT ((queries == NULL) == (query_fn == NULL)); + const t8_scheme *scheme = t8_forest_get_scheme (forest); const size_t elem_count = t8_element_array_get_count (leaf_elements); if (elem_count == 0) { /* There are no leaves left, so we have nothing to do */ @@ -200,11 +201,11 @@ t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_el /* There is only one leaf left, we check whether it is the same as element and if so call the callback function */ const t8_element_t *leaf = t8_element_array_index_locidx (leaf_elements, 0); - SC_CHECK_ABORT (ts->t8_element_level (element) <= ts->t8_element_level (leaf), + SC_CHECK_ABORT (scheme->element_get_level (tree_class, element) <= scheme->element_get_level (tree_class, leaf), "Search: element level greater than leaf level\n"); - if (ts->t8_element_level (element) == ts->t8_element_level (leaf)) { + if (scheme->element_get_level (tree_class, element) == scheme->element_get_level (tree_class, leaf)) { T8_ASSERT (t8_forest_element_is_leaf (forest, leaf, ltreeid)); - T8_ASSERT (ts->t8_element_equal (element, leaf)); + T8_ASSERT (scheme->element_is_equal (tree_class, element, leaf)); /* The element is the leaf */ is_leaf = 1; } @@ -254,13 +255,13 @@ t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_el /* Enter the recursion (the element is definitely not a leaf at this point) */ /* We compute all children of E, compute their leaf arrays and call search_recursion */ /* allocate the memory to store the children */ - const int num_children = ts->t8_element_num_children (element); + const int num_children = scheme->element_get_num_children (tree_class, element); t8_element_t **children = T8_ALLOC (t8_element_t *, num_children); - ts->t8_element_new (num_children, children); + scheme->element_new (tree_class, num_children, children); /* Memory for the indices that split the leaf_elements array */ size_t *split_offsets = T8_ALLOC (size_t, num_children + 1); /* Compute the children */ - ts->t8_element_children (element, num_children, children); + scheme->element_get_children (tree_class, element, num_children, children); /* Split the leaves array in portions belonging to the children of element */ t8_forest_split_array (element, leaf_elements, split_offsets); for (int ichild = 0; ichild < num_children; ichild++) { @@ -278,7 +279,7 @@ t8_forest_search_recursion (t8_forest_t forest, const t8_locidx_t ltreeid, t8_el } } /* clean-up */ - ts->t8_element_destroy (num_children, children); + scheme->element_destroy (tree_class, num_children, children); T8_FREE (children); T8_FREE (split_offsets); if (num_active > 0) { @@ -294,7 +295,7 @@ t8_forest_search_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_search /* Get the element class, scheme and leaf elements of this tree */ const t8_eclass_t eclass = t8_forest_get_eclass (forest, ltreeid); - const t8_scheme *ts = t8_forest_get_eclass_scheme (forest, eclass); + const t8_scheme *ts = t8_forest_get_scheme (forest); t8_element_array_t *leaf_elements = t8_forest_tree_get_leaves (forest, ltreeid); /* assert for empty tree */ @@ -305,13 +306,13 @@ t8_forest_search_tree (t8_forest_t forest, t8_locidx_t ltreeid, t8_forest_search = t8_element_array_index_locidx (leaf_elements, t8_element_array_get_count (leaf_elements) - 1); /* Compute their nearest common ancestor */ t8_element_t *nca; - ts->t8_element_new (1, &nca); - ts->t8_element_nca (first_el, last_el, nca); + ts->element_new (eclass, 1, &nca); + ts->element_get_nca (eclass, first_el, last_el, nca); /* Start the top-down search */ t8_forest_search_recursion (forest, ltreeid, nca, ts, leaf_elements, 0, search_fn, query_fn, queries, active_queries); - ts->t8_element_destroy (1, &nca); + ts->element_destroy (eclass, 1, &nca); } void diff --git a/src/t8_forest/t8_forest_netcdf.cxx b/src/t8_forest/t8_forest_netcdf.cxx index c4ca0a57b7..f0d09b698d 100644 --- a/src/t8_forest/t8_forest_netcdf.cxx +++ b/src/t8_forest/t8_forest_netcdf.cxx @@ -60,6 +60,7 @@ These functions write a file in the NetCDF-format which represents the given 2D- #include #include #include +#include T8_EXTERN_C_BEGIN (); @@ -388,6 +389,7 @@ t8_forest_write_netcdf_data (t8_forest_t forest, t8_forest_netcdf_context_t *con size_t start_ptr; size_t count_ptr; int retval; + const t8_scheme *scheme = t8_forest_get_scheme (forest); /* Get the first local element id in a forest (function is collective) */ first_local_elem_id = t8_forest_get_first_local_element_id (forest); @@ -415,12 +417,10 @@ t8_forest_write_netcdf_data (t8_forest_t forest, t8_forest_netcdf_context_t *con local_tree_offset = t8_forest_get_tree_element_offset (forest, ltree_id); /* Iterate over all local elements in the local tree */ for (local_elem_id = 0; local_elem_id < num_local_tree_elem; local_elem_id++) { - /* Get the eclass scheme */ - t8_scheme *scheme = t8_forest_get_eclass_scheme (forest, tree_class); /* Get the local element in the local tree */ const t8_element_t *element = t8_forest_get_element_in_tree (forest, ltree_id, local_elem_id); /* Determine the element shape */ - element_shape = scheme->t8_element_shape (element); + element_shape = scheme->element_get_shape (tree_class, element); /* Store the type of the element in its global index position */ Mesh_elem_types[(local_tree_offset + local_elem_id)] = t8_element_shape_vtk_type (element_shape); /* Store the elements tree_id in its global index position */ @@ -740,12 +740,10 @@ t8_forest_write_netcdf_coordinate_data (t8_forest_t forest, t8_forest_netcdf_con local_tree_offset = t8_forest_get_tree_element_offset (forest, ltree_id); for (local_elem_id = 0; local_elem_id < num_local_tree_elem; local_elem_id++) { - /* Get the eclass scheme */ - t8_scheme *scheme = t8_forest_get_eclass_scheme (forest, tree_class); /* Get the local element in the local tree */ const t8_element_t *element = t8_forest_get_element_in_tree (forest, ltree_id, local_elem_id); /* Determine the element shape */ - element_shape = scheme->t8_element_shape (element); + element_shape = scheme->element_get_shape (tree_class, element); /* Get the number of nodes for this elements shape */ number_nodes = t8_element_shape_num_vertices (element_shape); i = 0; diff --git a/src/t8_forest/t8_forest_partition.cxx b/src/t8_forest/t8_forest_partition.cxx index 68444d931a..cc054e0af8 100644 --- a/src/t8_forest/t8_forest_partition.cxx +++ b/src/t8_forest/t8_forest_partition.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include /* We want to export the whole implementation to be callable from "C" */ @@ -132,21 +133,22 @@ t8_forest_partition_test_desc (t8_forest_t forest) } tree = t8_forest_get_tree (forest, 0); - ts = t8_forest_get_eclass_scheme (forest, tree->eclass); + ts = t8_forest_get_scheme (forest); + const t8_eclass_t tree_class = tree->eclass; /* Get the first descendant id of this rank */ first_desc_id = *(t8_linearidx_t *) t8_shmem_array_index (forest->global_first_desc, forest->mpirank); - ts->t8_element_new (1, &elem_desc); + ts->element_new (tree_class, 1, &elem_desc); for (ielem = 0; ielem < t8_forest_get_tree_element_count (tree); ielem++) { /* Iterate over elems, for each one create the first descendant and check * its linear id versus the linear id of first_desc. */ const t8_element_t *element = t8_element_array_index_locidx (&tree->elements, ielem); - ts->t8_element_first_descendant (element, elem_desc, forest->maxlevel); - level = ts->t8_element_level (elem_desc); - T8_ASSERT (level == ts->t8_element_level (elem_desc)); + ts->element_construct_first_descendant (tree_class, element, elem_desc, forest->maxlevel); + level = ts->element_get_level (tree_class, elem_desc); + T8_ASSERT (level == ts->element_get_level (tree_class, elem_desc)); T8_ASSERT (level == forest->maxlevel); - T8_ASSERT (ts->t8_element_get_linear_id (elem_desc, level) >= first_desc_id); + T8_ASSERT (ts->element_get_linear_id (tree_class, elem_desc, level) >= first_desc_id); } - ts->t8_element_destroy (1, &elem_desc); + ts->element_destroy (tree_class, 1, &elem_desc); } #endif @@ -223,20 +225,21 @@ t8_forest_partition_test_boundary_element (const t8_forest_t forest) T8_ASSERT (itree > -1); } const t8_tree_t tree = t8_forest_get_tree (forest, itree); - t8_scheme *ts = t8_forest_get_eclass_scheme (forest, tree->eclass); + const t8_scheme *ts = t8_forest_get_scheme (forest); + const t8_eclass_t tree_class = tree->eclass; t8_element_t *element_last_desc; - ts->t8_element_new (1, &element_last_desc); + ts->element_new (tree_class, 1, &element_last_desc); /* last element of current rank */ const t8_element_t *element_last = t8_forest_get_element_in_tree (forest, itree, t8_forest_get_tree_element_count (tree) - 1); - T8_ASSERT (ts->t8_element_is_valid (element_last)); + T8_ASSERT (ts->element_is_valid (tree_class, element_last)); /* last and finest possiple element of current rank */ - ts->t8_element_last_descendant (element_last, element_last_desc, forest->maxlevel); - T8_ASSERT (ts->t8_element_is_valid (element_last_desc)); - const int level = ts->t8_element_level (element_last_desc); - T8_ASSERT (level == ts->t8_element_level (element_last_desc)); + ts->element_construct_last_descendant (tree_class, element_last, element_last_desc, forest->maxlevel); + T8_ASSERT (ts->element_is_valid (tree_class, element_last_desc)); + const int level = ts->element_get_level (tree_class, element_last_desc); + T8_ASSERT (level == ts->element_get_level (tree_class, element_last_desc)); T8_ASSERT (level == forest->maxlevel); - const t8_linearidx_t last_desc_id = ts->t8_element_get_linear_id (element_last_desc, level); + const t8_linearidx_t last_desc_id = ts->element_get_linear_id (tree_class, element_last_desc, level); /* Get the first descendant id of rank+1 */ const t8_linearidx_t first_desc_id = *(t8_linearidx_t *) t8_shmem_array_index (forest->global_first_desc, forest->mpirank + 1); @@ -245,7 +248,7 @@ t8_forest_partition_test_boundary_element (const t8_forest_t forest) /** TODO: This assertion might still be wrong, when our last element is the last element of the tree*/ T8_ASSERT (itree < num_local_trees - 1 || last_desc_id < first_desc_id); /* clean up */ - ts->t8_element_destroy (1, &element_last_desc); + ts->element_destroy (tree_class, 1, &element_last_desc); #endif } @@ -296,12 +299,13 @@ t8_forest_partition_create_first_desc (t8_forest_t forest) /* This process is not empty, the element was found, so we compute its first descendant. */ if (first_element != NULL) { /* Get the eclass_scheme of the element. */ - ts = t8_forest_get_eclass_scheme (forest, t8_forest_get_tree_class (forest, 0)); - ts->t8_element_new (1, &first_desc); - ts->t8_element_first_descendant (first_element, first_desc, forest->maxlevel); + ts = t8_forest_get_scheme (forest); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, 0); + ts->element_new (tree_class, 1, &first_desc); + ts->element_construct_first_descendant (tree_class, first_element, first_desc, forest->maxlevel); /* Compute the linear id of the descendant. */ - local_first_desc = ts->t8_element_get_linear_id (first_desc, forest->maxlevel); - ts->t8_element_destroy (1, &first_desc); + local_first_desc = ts->element_get_linear_id (tree_class, first_desc, forest->maxlevel); + ts->element_destroy (tree_class, 1, &first_desc); } } /* Collect all first global indices in the array */ @@ -918,7 +922,7 @@ t8_forest_partition_recv_message (t8_forest_t forest, sc_MPI_Comm comm, int proc t8_forest_partition_tree_info_t *tree_info; t8_tree_t tree, last_tree; size_t element_size {}; - t8_scheme *eclass_scheme; + const t8_scheme *scheme = t8_forest_get_scheme (forest->set_from); if (proc != forest->mpirank) { T8_ASSERT (proc == status->MPI_SOURCE); @@ -983,12 +987,11 @@ t8_forest_partition_recv_message (t8_forest_t forest, sc_MPI_Comm comm, int proc } /* Done calculating the element offset */ /* Get the size of an element of the tree */ - eclass_scheme = t8_forest_get_eclass_scheme (forest->set_from, tree->eclass); - element_size = eclass_scheme->t8_element_size (); + element_size = scheme->get_element_size (tree->eclass); /* initialize the elements array and copy the elements from the receive buffer */ T8_ASSERT (element_cursor + tree_info->num_elements * element_size <= (size_t) recv_bytes); - t8_element_array_init_copy (&tree->elements, eclass_scheme, (t8_element_t *) (recv_buffer + element_cursor), - tree_info->num_elements); + t8_element_array_init_copy (&tree->elements, scheme, tree->eclass, + (t8_element_t *) (recv_buffer + element_cursor), tree_info->num_elements); } else { T8_ASSERT (itree == 0); /* This situation only happens for the first tree */ @@ -1006,8 +1009,7 @@ t8_forest_partition_recv_message (t8_forest_t forest, sc_MPI_Comm comm, int proc if (tree_info->num_elements > 0) { t8_element_t *first_new_element = t8_element_array_index_locidx_mutable (&tree->elements, old_num_elements); /* Get the size of an element of the tree */ - eclass_scheme = t8_forest_get_eclass_scheme (forest->set_from, tree->eclass); - element_size = eclass_scheme->t8_element_size (); + element_size = scheme->get_element_size (tree->eclass); T8_ASSERT (element_size == t8_element_array_get_size (&tree->elements)); /* Copy the elements from the receive buffer to the elements array */ memcpy ((void *) first_new_element, recv_buffer + element_cursor, tree_info->num_elements * element_size); diff --git a/src/t8_forest/t8_forest_private.h b/src/t8_forest/t8_forest_private.h index 8c59119350..e9e473499e 100644 --- a/src/t8_forest/t8_forest_private.h +++ b/src/t8_forest/t8_forest_private.h @@ -43,7 +43,6 @@ T8_EXTERN_C_BEGIN (); * \param [in] ltree_id The index of considered local tree. * \param [in] el_considered The local id of the first element in * \a elements in the local tree of the forest. - * \param [in] tscheme The scheme for the local tree. * \param [in] elements Array of elements to consider. * \param [in] elements_size Number of elements in \a elements. * \return Size of family or zero, if \a elements does not contain a @@ -57,7 +56,7 @@ T8_EXTERN_C_BEGIN (); */ int t8_forest_is_incomplete_family (const t8_forest_t forest, const t8_locidx_t ltree_id, const t8_locidx_t el_considered, - t8_scheme_c *tscheme, t8_element_t **elements, const int elements_size); + t8_element_t **elements, const int elements_size); /* For each tree in a forest compute its first and last descendant */ void @@ -68,17 +67,15 @@ t8_forest_compute_desc (t8_forest_t forest); void t8_forest_populate (t8_forest_t forest); -/** Return the eclass scheme of a given element class associated to a forest. +/** Return the scheme associated to a forest. * This function does not check whether the given forest is committed, use with * caution and only if you are sure that the eclass_scheme was set. * \param [in] forest A nearly committed forest. - * \param [in] eclass An element class. - * \return The eclass scheme of \a eclass associated to forest. + * \return The scheme associated to forest. * \see t8_forest_set_scheme - * \note The forest is not required to have trees of class \a eclass. */ t8_scheme_c * -t8_forest_get_eclass_scheme_before_commit (t8_forest_t forest, t8_eclass_t eclass); +t8_forest_get_scheme_before_commit (t8_forest_t forest); /** Compute the maximum possible refinement level in a forest. * This is the minimum over all maximum refinement level of the present element diff --git a/src/t8_vtk/t8_vtk_write_ASCII.cxx b/src/t8_vtk/t8_vtk_write_ASCII.cxx index 6bbdd1eb4e..57486d0cb8 100644 --- a/src/t8_vtk/t8_vtk_write_ASCII.cxx +++ b/src/t8_vtk/t8_vtk_write_ASCII.cxx @@ -29,6 +29,7 @@ #include "t8_forest/t8_forest_types.h" #include "t8_cmesh/t8_cmesh_trees.h" #include "t8_cmesh/t8_cmesh_types.h" +#include /* TODO: Currently we only use ASCII mode and no data compression. * We also do not use sc_io to buffer our output stream. */ @@ -76,8 +77,8 @@ typedef enum { T8_VTK_KERNEL_INIT, T8_VTK_KERNEL_EXECUTE, T8_VTK_KERNEL_CLEANUP */ typedef int (*t8_forest_vtk_cell_data_kernel) (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, const t8_locidx_t element_index, const t8_element_t *element, - t8_scheme *ts, const int is_ghost, FILE *vtufile, int *columns, - void **data, T8_VTK_KERNEL_MODUS modus); + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, + int *columns, void **data, T8_VTK_KERNEL_MODUS modus); static t8_locidx_t t8_forest_num_points (t8_forest_t forest, const int count_ghosts) @@ -116,9 +117,9 @@ t8_forest_num_points (t8_forest_t forest, const int count_ghosts) static int t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { double element_coordinates[3]; int num_el_vertices, ivertex; @@ -133,8 +134,8 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree /* TODO: be careful with pyramid class here. * does this work too over tree->class or do we need something else? */ - - element_shape = ts->t8_element_shape (element); + const t8_scheme *scheme = t8_forest_get_scheme (forest); + element_shape = scheme->element_get_shape (tree_class, element); num_el_vertices = t8_eclass_num_vertices[element_shape]; for (ivertex = 0; ivertex < num_el_vertices; ivertex++) { const double *ref_coords = t8_forest_vtk_point_to_element_ref_coords[element_shape][ivertex]; @@ -162,9 +163,9 @@ t8_forest_vtk_cells_vertices_kernel (t8_forest_t forest, const t8_locidx_t ltree static int t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { int ivertex, num_vertices; int freturn; @@ -183,7 +184,8 @@ t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, const t8_locidx_t l T8_ASSERT (modus == T8_VTK_KERNEL_EXECUTE); count_vertices = (t8_locidx_t *) *data; - element_shape = ts->t8_element_shape (element); + const t8_scheme *scheme = t8_forest_get_scheme (forest); + element_shape = scheme->element_get_shape (tree_class, element); num_vertices = t8_eclass_num_vertices[element_shape]; for (ivertex = 0; ivertex < num_vertices; ++ivertex, (*count_vertices)++) { freturn = fprintf (vtufile, " %ld", (long) *count_vertices); @@ -197,9 +199,9 @@ t8_forest_vtk_cells_connectivity_kernel (t8_forest_t forest, const t8_locidx_t l static int t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { long long *offset; int freturn; @@ -217,7 +219,8 @@ t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, const t8_locidx_t ltree_i offset = (long long *) *data; - num_vertices = t8_eclass_num_vertices[ts->t8_element_shape (element)]; + const t8_scheme *scheme = t8_forest_get_scheme (forest); + num_vertices = t8_eclass_num_vertices[scheme->element_get_shape (tree_class, element)]; *offset += num_vertices; freturn = fprintf (vtufile, " %lld", *offset); if (freturn <= 0) { @@ -230,14 +233,15 @@ t8_forest_vtk_cells_offset_kernel (t8_forest_t forest, const t8_locidx_t ltree_i static int t8_forest_vtk_cells_type_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { int freturn; if (modus == T8_VTK_KERNEL_EXECUTE) { /* print the vtk type of the element */ - freturn = fprintf (vtufile, " %d", t8_eclass_vtk_type[ts->t8_element_shape (element)]); + const t8_scheme *scheme = t8_forest_get_scheme (forest); + freturn = fprintf (vtufile, " %d", t8_eclass_vtk_type[scheme->element_get_shape (tree_class, element)]); if (freturn <= 0) { return 0; } @@ -248,12 +252,13 @@ t8_forest_vtk_cells_type_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, static int t8_forest_vtk_cells_level_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { if (modus == T8_VTK_KERNEL_EXECUTE) { - fprintf (vtufile, "%i ", ts->t8_element_level (element)); + const t8_scheme *scheme = t8_forest_get_scheme (forest); + fprintf (vtufile, "%i ", scheme->element_get_level (tree_class, element)); *columns += 1; } return 1; @@ -261,9 +266,9 @@ t8_forest_vtk_cells_level_kernel (t8_forest_t forest, const t8_locidx_t ltree_id static int t8_forest_vtk_cells_rank_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { if (modus == T8_VTK_KERNEL_EXECUTE) { fprintf (vtufile, "%i ", forest->mpirank); @@ -274,9 +279,9 @@ t8_forest_vtk_cells_rank_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, static int t8_forest_vtk_cells_treeid_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { if (modus == T8_VTK_KERNEL_EXECUTE) { long long tree_id; @@ -296,9 +301,9 @@ t8_forest_vtk_cells_treeid_kernel (t8_forest_t forest, const t8_locidx_t ltree_i static int t8_forest_vtk_cells_elementid_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { if (modus == T8_VTK_KERNEL_EXECUTE) { if (!is_ghost) { @@ -315,9 +320,9 @@ t8_forest_vtk_cells_elementid_kernel (t8_forest_t forest, const t8_locidx_t ltre static int t8_forest_vtk_cells_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { double element_value = 0; t8_locidx_t scalar_index; @@ -339,9 +344,9 @@ t8_forest_vtk_cells_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltree_i static int t8_forest_vtk_cells_vector_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { double *element_values, null_vec[3] = { 0, 0, 0 }; int dim, idim; @@ -370,16 +375,17 @@ t8_forest_vtk_cells_vector_kernel (t8_forest_t forest, const t8_locidx_t ltree_i /* The point data version of the scalar kernel */ static int t8_forest_vtk_vertices_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { double element_value = 0; int num_vertex, ivertex; t8_locidx_t scalar_index; if (modus == T8_VTK_KERNEL_EXECUTE) { - num_vertex = ts->t8_element_num_corners (element); + const t8_scheme *scheme = t8_forest_get_scheme (forest); + num_vertex = scheme->element_get_num_corners (tree_class, element); for (ivertex = 0; ivertex < num_vertex; ivertex++) { /* For local elements access the data array, for ghosts, write 0 */ @@ -400,9 +406,9 @@ t8_forest_vtk_vertices_scalar_kernel (t8_forest_t forest, const t8_locidx_t ltre /* The point data version of the vector kernel */ static int t8_forest_vtk_vertices_vector_kernel (t8_forest_t forest, const t8_locidx_t ltree_id, const t8_tree_t tree, - const t8_locidx_t element_index, const t8_element_t *element, t8_scheme *ts, - const int is_ghost, FILE *vtufile, int *columns, void **data, - T8_VTK_KERNEL_MODUS modus) + const t8_locidx_t element_index, const t8_element_t *element, + const t8_eclass_t tree_class, const int is_ghost, FILE *vtufile, int *columns, + void **data, T8_VTK_KERNEL_MODUS modus) { double *element_values, null_vec[3] = { 0, 0, 0 }; int dim, idim; @@ -410,7 +416,8 @@ t8_forest_vtk_vertices_vector_kernel (t8_forest_t forest, const t8_locidx_t ltre t8_locidx_t tree_offset; if (modus == T8_VTK_KERNEL_EXECUTE) { - num_vertex = ts->t8_element_num_corners (element); + const t8_scheme *scheme = t8_forest_get_scheme (forest); + num_vertex = scheme->element_get_num_corners (tree_class, element); for (ivertex = 0; ivertex < num_vertex; ivertex++) { dim = 3; T8_ASSERT (forest->dimension <= 3); @@ -446,7 +453,6 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da t8_locidx_t element_index, elems_in_tree; t8_locidx_t num_local_trees, num_ghost_trees; t8_element_t *element; - t8_scheme *ts; void *data = NULL; /* Write the connectivity information. @@ -467,7 +473,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da /* Call the kernel in initialization modus to possibly initialize the * data pointer */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_INIT); + kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_COUNT, 0, NULL, NULL, &data, T8_VTK_KERNEL_INIT); /* We iterate over the trees and count each trees vertices, * we add this to the already counted vertices and write it to the file */ /* TODO: replace with an element iterator */ @@ -476,17 +482,17 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da /* Get the tree that stores the elements */ tree = t8_forest_get_tree (forest, itree); /* Get the eclass scheme of the tree */ - ts = t8_forest_get_eclass_scheme (forest, t8_forest_get_tree_class (forest, itree)); + const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, itree); elems_in_tree = (t8_locidx_t) t8_element_array_get_count (&tree->elements); for (element_index = 0; element_index < elems_in_tree; element_index++) { /* Get a pointer to the element */ element = t8_forest_get_element (forest, tree->elements_offset + element_index, NULL); T8_ASSERT (element != NULL); /* Execute the given callback on each element */ - if (!kernel (forest, itree, tree, element_index, element, ts, 0, vtufile, &countcols, &data, + if (!kernel (forest, itree, tree, element_index, element, tree_class, 0, vtufile, &countcols, &data, T8_VTK_KERNEL_EXECUTE)) { /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_COUNT, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); return 0; } /* After max_columns we break the line */ @@ -494,7 +500,7 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da freturn = fprintf (vtufile, "\n "); if (freturn <= 0) { /* call the kernel in clean-up modus */ - kernel (NULL, 0, NULL, 0, NULL, NULL, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); + kernel (NULL, 0, NULL, 0, NULL, T8_ECLASS_COUNT, 0, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); return 0; } } @@ -512,16 +518,16 @@ t8_forest_vtk_write_cell_data (t8_forest_t forest, FILE *vtufile, const char *da /* TODO: replace with an element iterator */ num_ghost_trees = t8_forest_ghost_num_trees (forest); for (ighost = 0; ighost < num_ghost_trees; ighost++) { - /* Get the eclass scheme of the ghost tree */ - ts = t8_forest_get_eclass_scheme (forest, t8_forest_ghost_get_tree_class (forest, ighost)); + /* Get the eclass of the ghost tree */ + const t8_eclass_t ghost_eclass = t8_forest_ghost_get_tree_class (forest, ighost); /* The number of ghosts in this tree */ num_ghosts_in_tree = t8_forest_ghost_tree_num_elements (forest, ighost); for (element_index = 0; element_index < num_ghosts_in_tree; element_index++) { /* Get a pointer to the element */ element = t8_forest_ghost_get_element (forest, ighost, element_index); /* Execute the given callback on each element */ - if (!kernel (forest, ighost + num_local_trees, NULL, element_index, element, ts, 1, vtufile, &countcols, &data, - T8_VTK_KERNEL_EXECUTE)) { + if (!kernel (forest, ighost + num_local_trees, NULL, element_index, element, ghost_eclass, 1, vtufile, + &countcols, &data, T8_VTK_KERNEL_EXECUTE)) { /* call the kernel in clean-up modus */ kernel (NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, &data, T8_VTK_KERNEL_CLEANUP); return 0; From b2bbdf47435005b05df7b204fcff1536ba06f527 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Wed, 30 Oct 2024 12:02:25 +0100 Subject: [PATCH 09/11] catching progress --- src/t8_element.hxx | 14 +- src/t8_element_c_interface.cxx | 2 +- src/t8_forest/t8_forest.cxx | 259 +++++++++--------- src/t8_forest/t8_forest_balance.cxx | 8 +- src/t8_forest/t8_forest_general.h | 10 +- src/t8_forest/t8_forest_private.h | 9 +- src/t8_schemes/t8_crtp.hxx | 2 +- .../t8_default_common/t8_default_common.cxx | 171 ------------ .../t8_default_common/t8_default_common.hxx | 126 ++++++++- .../t8_default_hex/t8_default_hex.cxx | 22 +- .../t8_default_hex/t8_default_hex.hxx | 21 +- .../t8_default_line/t8_default_line.cxx | 21 +- .../t8_default_line/t8_default_line.hxx | 21 +- .../t8_default_prism/t8_default_prism.cxx | 18 +- .../t8_default_prism/t8_default_prism.hxx | 20 +- .../t8_default_pyramid/t8_default_pyramid.cxx | 21 +- .../t8_default_pyramid/t8_default_pyramid.hxx | 46 ++-- .../t8_default_quad/t8_default_quad.cxx | 24 +- .../t8_default_quad/t8_default_quad.hxx | 182 +++++++----- .../t8_default_tet/t8_default_tet.cxx | 20 +- .../t8_default_tet/t8_default_tet.hxx | 42 ++- .../t8_default_tri/t8_default_tri.cxx | 22 +- .../t8_default_tri/t8_default_tri.hxx | 209 +++++++++----- .../t8_default_vertex/t8_default_vertex.cxx | 6 + .../t8_default_vertex/t8_default_vertex.hxx | 20 +- src/t8_schemes/t8_scheme.hxx | 20 +- 26 files changed, 740 insertions(+), 596 deletions(-) delete mode 100644 src/t8_schemes/t8_default/t8_default_common/t8_default_common.cxx diff --git a/src/t8_element.hxx b/src/t8_element.hxx index 3aa2e4359d..b8a23876b3 100644 --- a/src/t8_element.hxx +++ b/src/t8_element.hxx @@ -38,16 +38,20 @@ template class t8_eclass_scheme: public t8_crtp { private: - t8_scheme () {}; /**< private destructor which can only be used by derived schemes. */ + /** Private constructor which can only be used by derived schemes. + * \param [in] tree_class The tree class of this element scheme. + * \param [in] elem_size The size of the elements this scheme holds. + */ + t8_eclass_scheme (const t8_eclass_t tree_class, const size_t elem_size) + : element_size (elem_size), eclass (tree_class) {}; friend TUnderlyingEclassScheme; protected: - size_t element_size; /**< The size in bytes of an element of class \a eclass */ - void *ts_context; /**< Anonymous implementation context. */ + const size_t element_size; /**< The size in bytes of an element of class \a eclass */ + void *ts_context; /**< Anonymous implementation context. */ public: - t8_eclass_t eclass; - /**< The element class */ + const t8_eclass_t eclass; /**< The tree class */ /** The destructor. It does nothing but has to be defined since * we may want to delete an eclass_scheme that is actually inherited diff --git a/src/t8_element_c_interface.cxx b/src/t8_element_c_interface.cxx index 189455fdef..2f135d8f21 100644 --- a/src/t8_element_c_interface.cxx +++ b/src/t8_element_c_interface.cxx @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include size_t diff --git a/src/t8_forest/t8_forest.cxx b/src/t8_forest/t8_forest.cxx index 8e1b8494c7..1573b06f58 100644 --- a/src/t8_forest/t8_forest.cxx +++ b/src/t8_forest/t8_forest.cxx @@ -281,15 +281,16 @@ t8_forest_no_overlap (t8_forest_t forest) { #if T8_ENABLE_DEBUG T8_ASSERT (t8_forest_is_committed (forest)); + const t8_scheme *ts = t8_forest_get_scheme (forest); int has_overlap_local = 0; const t8_locidx_t num_local_trees = t8_forest_get_num_local_trees (forest); /* Iterate over all local trees */ for (t8_locidx_t itree = 0; itree < num_local_trees; itree++) { - t8_tree_t tree = t8_forest_get_tree (forest, itree); - t8_scheme *ts = t8_forest_get_eclass_scheme (forest, tree->eclass); + const t8_tree_t tree = t8_forest_get_tree (forest, itree); + const t8_eclass_t tree_class = tree->eclass; const t8_locidx_t elems_in_tree = t8_forest_get_tree_num_elements (forest, itree); t8_element_t *element_nca; - ts->t8_element_new (1, &element_nca); + ts->element_new (tree_class, 1, &element_nca); /* Iterate over all elements in current tree */ for (t8_locidx_t ielem = 0; ielem < elems_in_tree - 1; ielem++) { /* Compare each two consecutive elements. If one element is @@ -305,12 +306,12 @@ t8_forest_no_overlap (t8_forest_t forest) * */ const t8_element_t *element_a = t8_forest_get_element_in_tree (forest, itree, ielem); const t8_element_t *element_b = t8_forest_get_element_in_tree (forest, itree, ielem + 1); - T8_ASSERT (ts->t8_element_is_valid (element_a)); - T8_ASSERT (ts->t8_element_is_valid (element_b)); - ts->t8_element_nca (element_a, element_b, element_nca); - if (ts->t8_element_level (element_a) == ts->t8_element_level (element_nca) - || ts->t8_element_level (element_b) == ts->t8_element_level (element_nca)) { - ts->t8_element_destroy (1, &element_nca); + T8_ASSERT (ts->element_is_valid (tree_class, element_a)); + T8_ASSERT (ts->element_is_valid (tree_class, element_b)); + ts->element_get_nca (tree_class, element_a, element_b, element_nca); + if (ts->element_get_level (tree_class, element_a) == ts->element_get_level (tree_class, element_nca) + || ts->element_get_level (tree_class, element_b) == ts->element_get_level (tree_class, element_nca)) { + ts->element_destroy (tree_class, 1, &element_nca); has_overlap_local = 1; } } @@ -496,7 +497,7 @@ void t8_forest_element_centroid (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, double *coordinates) { T8_ASSERT (t8_forest_is_committed (forest)); - const t8_scheme *ts t8_forest_get_eclass_scheme (forest); + const t8_scheme *ts t8_forest_get_scheme (forest); const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); /* Get the tree's eclass and scheme. */ @@ -920,11 +921,9 @@ t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8 double normal[3]) { T8_ASSERT (t8_forest_is_committed (forest)); - /* get the eclass of the forest */ const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid); - /* get the element's scheme and the face scheme */ - const t8_scheme *ts = t8_forest_get_eclass_scheme (forest, tree_class); - const t8_element_shape_t face_shape = ts->t8_element_face_shape (element, face); + const t8_scheme *ts = t8_forest_get_scheme (forest); + const t8_element_shape_t face_shape = ts->t8_element_face_shape (tree_class, element, face); switch (face_shape) { case T8_ECLASS_VERTEX: @@ -978,8 +977,8 @@ t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8 * with corner vector V_a and V_b, and shift it by -V_a. */ /* Compute the two endnotes of the face line */ - corner_a = ts->t8_element_get_face_corner (element, face, 0); - corner_b = ts->t8_element_get_face_corner (element, face, 1); + corner_a = ts->element_get_face_corner (tree_class, element, face, 0); + corner_b = ts->element_get_face_corner (tree_class, element, face, 1); /* Compute the coordinates of the endnotes */ t8_forest_element_coordinate (forest, ltreeid, element, corner_a, vertex_a); t8_forest_element_coordinate (forest, ltreeid, element, corner_b, vertex_b); @@ -1051,7 +1050,7 @@ t8_forest_element_face_normal (t8_forest_t forest, t8_locidx_t ltreeid, const t8 for (i = 0; i < 3; i++) { /* Compute the i-th corner */ - corner = ts->t8_element_get_face_corner (element, face, i); + corner = ts->element_get_face_corner (tree_class, element, face, i); /* Compute the coordinates of this corner */ t8_forest_element_coordinate (forest, ltreeid, element, corner, corner_vertices[i]); } @@ -1250,7 +1249,6 @@ t8_forest_tree_shared (t8_forest_t forest, int first_or_last) t8_element_t *element; t8_element_t *tree_desc; t8_eclass_t eclass; - t8_scheme *ts; t8_gloidx_t global_neighbour_tree_idx; int ret; int mpiret; @@ -1320,27 +1318,27 @@ t8_forest_tree_shared (t8_forest_t forest, int first_or_last) } /* Get the eclass scheme of the first tree */ eclass = tree->eclass; - /* Get the eclass scheme of the first tree */ - ts = t8_forest_get_eclass_scheme (forest, eclass); + /* Get the scheme of the first tree */ + const t8_scheme *ts = t8_forest_get_scheme (forest); /* Calculate the first/last possible descendant of the first/last tree */ /* we do this by first creating a level 0 child of the tree, then * calculating its first/last descendant */ - ts->t8_element_new (1, &element); - ts->t8_element_root (element); - ts->t8_element_new (1, &desc); + ts->element_new (eclass, 1, &element); + ts->get_root (eclass, element); + ts->element_new (eclass, 1, &desc); if (first_or_last == 0) { - ts->t8_element_first_descendant (element, desc, forest->maxlevel); + ts->element_construct_first_descendant (eclass, element, desc, forest->maxlevel); } else { - ts->t8_element_last_descendant (element, desc, forest->maxlevel); + ts->element_construct_last_descendant (eclass, element, desc, forest->maxlevel); } /* We can now check whether the first/last possible descendant matches the * first/last local descendant */ tree_desc = first_or_last == 0 ? tree->first_desc : tree->last_desc; - ret = !ts->t8_element_equal (desc, tree_desc); + ret = !ts->element_is_equal (eclass, desc, tree_desc); /* clean-up */ - ts->t8_element_destroy (1, &element); - ts->t8_element_destroy (1, &desc); + ts->element_destroy (eclass, 1, &element); + ts->element_destroy (eclass, 1, &desc); /* If the descendants are the same then ret is zero and we return false. * We return true otherwise */ return ret; @@ -1463,8 +1461,6 @@ t8_forest_bin_search_lower (const t8_element_array_t *elements, const t8_lineari t8_eclass_t t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, int face) { - t8_scheme *ts; - t8_tree_t tree; t8_ctree_t coarse_tree; t8_eclass_t eclass; int tree_face; @@ -1472,10 +1468,10 @@ t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, cons t8_cmesh_t cmesh; /* Get a pointer to the tree to read its element class */ - tree = t8_forest_get_tree (forest, ltreeid); - eclass = tree->eclass; - ts = t8_forest_get_eclass_scheme (forest, eclass); - if (!ts->t8_element_is_root_boundary (elem, face)) { + const t8_tree_t tree = t8_forest_get_tree (forest, ltreeid); + const t8_eclass_t eclass = tree->eclass; + const t8_scheme *ts = t8_forest_get_scheme (forest); + if (!ts->t8_element_is_root_boundary (eclass, elem, face)) { /* The neighbor element is inside the current tree. */ return tree->eclass; } @@ -1483,7 +1479,7 @@ t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, cons /* The neighbor is in a neighbor tree */ /* If the face neighbor is not inside the tree, we have to find out the tree * face and the tree's face neighbor along that face. */ - tree_face = ts->t8_element_tree_face (elem, face); + tree_face = ts->element_get_tree_face (eclass, elem, face); cmesh = t8_forest_get_cmesh (forest); /* Get the coarse tree corresponding to tree */ @@ -1505,7 +1501,7 @@ t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, cons t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, - t8_eclass_t neigh_class, int face, int *neigh_face) + t8_eclass_t neigh_eclass, int face, int *neigh_face) { /* Get a pointer to the tree to read its element class */ const t8_tree_t tree = t8_forest_get_tree (forest, ltreeid); @@ -1692,14 +1688,14 @@ t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, void t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, - t8_locidx_t **pelement_indices, t8_scheme **pneigh_scheme, int forest_is_balanced, + t8_locidx_t **pelement_indices, t8_eclass_t *pneigh_eclass, int forest_is_balanced, t8_gloidx_t *gneigh_tree, int *orientation) { - t8_eclass_t neigh_class, eclass; + t8_eclass_t eclass; t8_gloidx_t gneigh_treeid; t8_locidx_t lneigh_treeid = -1; t8_locidx_t lghost_treeid = -1, *element_indices, element_index; - t8_scheme *ts, *neigh_scheme; + t8_scheme *ts = t8_forest_get_scheme (forest); const t8_element_t *ancestor; t8_element_t **neighbor_leaves; t8_linearidx_t neigh_id; @@ -1719,7 +1715,6 @@ t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, cons /* In a balanced forest, the leaf neighbor of a leaf is either the neighbor element itself, * its parent or its children at the face. */ eclass = t8_forest_get_tree_class (forest, ltreeid); - ts = t8_forest_get_eclass_scheme (forest, eclass); if (orientation) { *orientation = t8_forest_leaf_face_orientation (forest, ltreeid, ts, leaf, face); @@ -1727,22 +1722,21 @@ t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, cons /* At first we compute these children of the face neighbor elements of leaf. For this, we need the * neighbor tree's eclass, scheme, and tree id */ - neigh_class = t8_forest_element_neighbor_eclass (forest, ltreeid, leaf, face); - neigh_scheme = *pneigh_scheme = t8_forest_get_eclass_scheme (forest, neigh_class); + *pneigh_eclass = t8_forest_element_neighbor_eclass (forest, ltreeid, leaf, face); /* If we are at the maximum refinement level, we compute the neighbor instead */ - at_maxlevel = ts->t8_element_level (leaf) == t8_forest_get_maxlevel (forest); + at_maxlevel = ts->element_get_level (eclass, leaf) == t8_forest_get_maxlevel (forest); if (at_maxlevel) { num_children_at_face = 1; neighbor_leaves = *pneighbor_leaves = T8_ALLOC (t8_element_t *, 1); *dual_faces = T8_ALLOC (int, 1); - neigh_scheme->t8_element_new (num_children_at_face, neighbor_leaves); + ts->element_new (*pneigh_eclass, num_children_at_face, neighbor_leaves); /* Compute neighbor element and global treeid of the neighbor */ - gneigh_treeid - = t8_forest_element_face_neighbor (forest, ltreeid, leaf, neighbor_leaves[0], neigh_scheme, face, *dual_faces); + gneigh_treeid = t8_forest_element_face_neighbor (forest, ltreeid, leaf, neighbor_leaves[0], *pneigh_eclass, face, + *dual_faces); } else { /* Allocate neighbor element */ - num_children_at_face = ts->t8_element_num_face_children (leaf, face); + num_children_at_face = ts->element_get_num_face_children (eclass, leaf, face); neighbor_leaves = *pneighbor_leaves = T8_ALLOC (t8_element_t *, num_children_at_face); *dual_faces = T8_ALLOC (int, num_children_at_face); neigh_scheme->t8_element_new (num_children_at_face, neighbor_leaves); @@ -1932,10 +1926,10 @@ t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, cons void t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, - t8_locidx_t **pelement_indices, t8_scheme **pneigh_scheme, int forest_is_balanced) + t8_locidx_t **pelement_indices, t8_eclass_t *pneigh_eclass, int forest_is_balanced) { t8_forest_leaf_face_neighbors_ext (forest, ltreeid, leaf, pneighbor_leaves, face, dual_faces, num_neighbors, - pelement_indices, pneigh_scheme, forest_is_balanced, NULL, NULL); + pelement_indices, pneigh_eclass, forest_is_balanced, NULL, NULL); } void @@ -2324,7 +2318,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el int proc, proc_next; t8_linearidx_t element_desc_lin_id; t8_element_t *element_first_desc; - t8_scheme *ts; + const t8_scheme *ts = t8_forest_get_scheme (forest); ssize_t proc_index; struct find_owner_data_t find_owner_data; @@ -2358,13 +2352,11 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el t8_offset_all_owners_of_tree (forest->mpisize, gtreeid, t8_shmem_array_get_gloidx_array (forest->tree_offsets), owners_of_tree); } - /* Get the eclass_scheme and the element's first descendant's linear_id */ - ts = t8_forest_get_eclass_scheme (forest, eclass); /* Compute the first descendant of the element */ - ts->t8_element_new (1, &element_first_desc); - ts->t8_element_first_descendant (element, element_first_desc, forest->maxlevel); + ts->element_new (eclass, 1, &element_first_desc); + ts->element_construct_first_descendant (eclass, element, element_first_desc, forest->maxlevel); /* Compute the linear of the first descendant */ - element_desc_lin_id = ts->t8_element_get_linear_id (element_first_desc, forest->maxlevel); + element_desc_lin_id = ts->element_get_linear_id (eclass, element_first_desc, forest->maxlevel); /* The first owner of the tree may not have the tree as its first tree and * thus its first_descendant entry may not relate to this tree. @@ -2372,7 +2364,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el proc = *(int *) sc_array_index (owners_of_tree, 0); if (owners_of_tree->elem_count == 1) { /* There is only this proc as possible owner. */ - ts->t8_element_destroy (1, &element_first_desc); + ts->element_destroy (eclass, 1, &element_first_desc); if (all_owners_of_tree == NULL) { sc_array_destroy (owners_of_tree); } @@ -2384,7 +2376,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el proc_next = *(int *) sc_array_index (owners_of_tree, 1); if (*(t8_linearidx_t *) t8_shmem_array_index (forest->global_first_desc, (size_t) proc_next) > element_desc_lin_id) { - ts->t8_element_destroy (1, &element_first_desc); + ts->element_destroy (eclass, 1, &element_first_desc); if (all_owners_of_tree == NULL) { sc_array_destroy (owners_of_tree); } @@ -2408,7 +2400,7 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el /* Get the process and return it. */ proc = *(int *) sc_array_index_ssize_t (&owners_of_tree_wo_first, proc_index); /* clean-up */ - ts->t8_element_destroy (1, &element_first_desc); + ts->element_destroy (eclass, 1, &element_first_desc); if (all_owners_of_tree == NULL) { sc_array_destroy (owners_of_tree); } @@ -2423,28 +2415,28 @@ t8_forest_element_find_owner_old (t8_forest_t forest, t8_gloidx_t gtreeid, t8_el */ static void t8_forest_element_owners_at_face_recursion (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, - t8_eclass_t eclass, t8_scheme *ts, int face, sc_array_t *owners, - int lower_bound, int upper_bound, t8_element_t *first_desc, - t8_element_t *last_desc) + t8_eclass_t eclass, int face, sc_array_t *owners, int lower_bound, + int upper_bound, t8_element_t *first_desc, t8_element_t *last_desc) { t8_element_t *first_face_desc, *last_face_desc, **face_children; int first_owner, last_owner; int num_children, ichild; int child_face; int last_owner_entry; + const t8_scheme *ts = t8_forest_get_scheme (forest); T8_ASSERT (element != NULL); /* Create first and last descendants at face */ if (first_desc == NULL) { - ts->t8_element_new (1, &first_face_desc); - ts->t8_element_first_descendant_face (element, face, first_face_desc, forest->maxlevel); + ts->element_new (eclass, 1, &first_face_desc); + ts->element_construct_first_descendant_face (eclass, element, face, first_face_desc, forest->maxlevel); } else { first_face_desc = first_desc; } if (last_desc == NULL) { - ts->t8_element_new (1, &last_face_desc); - ts->t8_element_last_descendant_face (element, face, last_face_desc, forest->maxlevel); + ts->element_new (eclass, 1, &last_face_desc); + ts->element_construct_last_descendant_face (eclass, element, face, last_face_desc, forest->maxlevel); } else { last_face_desc = last_desc; @@ -2454,12 +2446,12 @@ t8_forest_element_owners_at_face_recursion (t8_forest_t forest, t8_gloidx_t gtre /* Check if the computed or given descendants are the correct descendant */ t8_element_t *test_desc; - ts->t8_element_new (1, &test_desc); - ts->t8_element_last_descendant_face (element, face, test_desc, forest->maxlevel); - T8_ASSERT (ts->t8_element_equal (test_desc, last_face_desc)); - ts->t8_element_first_descendant_face (element, face, test_desc, forest->maxlevel); - T8_ASSERT (ts->t8_element_equal (test_desc, first_face_desc)); - ts->t8_element_destroy (1, &test_desc); + ts->element_new (eclass, 1, &test_desc); + ts->element_construct_last_descendant_face (eclass, element, face, test_desc, forest->maxlevel); + T8_ASSERT (ts->element_is_equal (eclass, test_desc, last_face_desc)); + ts->element_construct_first_descendant_face (eclass, element, face, test_desc, forest->maxlevel); + T8_ASSERT (ts->element_is_equal (eclass, test_desc, first_face_desc)); + ts->element_destroy (eclass, 1, &test_desc); } #endif @@ -2491,31 +2483,31 @@ t8_forest_element_owners_at_face_recursion (t8_forest_t forest, t8_gloidx_t gtre T8_ASSERT (t8_forest_element_check_owner (forest, first_face_desc, gtreeid, eclass, first_owner, 1)); T8_ASSERT (t8_forest_element_check_owner (forest, last_face_desc, gtreeid, eclass, first_owner, 1)); /* free memory */ - ts->t8_element_destroy (1, &first_face_desc); - ts->t8_element_destroy (1, &last_face_desc); + ts->element_destroy (eclass, 1, &first_face_desc); + ts->element_destroy (eclass, 1, &last_face_desc); return; } else { - T8_ASSERT (ts->t8_element_level (element) < t8_forest_get_maxlevel (forest)); + T8_ASSERT (ts->element_get_level (eclass, element) < t8_forest_get_maxlevel (forest)); /* This element has different owners, we have to create its face children and continue with the recursion. */ - num_children = ts->t8_element_num_face_children (element, face); + num_children = ts->element_get_num_face_children (eclass, element, face); /* allocate memory */ face_children = T8_ALLOC (t8_element_t *, num_children); - ts->t8_element_new (num_children, face_children); + ts->element_new (eclass, num_children, face_children); /* construct the children of element that touch face */ - ts->t8_element_children_at_face (element, face, face_children, num_children, NULL); + ts->element_get_children_at_face (eclass, element, face, face_children, num_children, NULL); for (ichild = 0; ichild < num_children; ichild++) { /* the face number of the child may not be the same as face */ - child_face = ts->t8_element_face_child_face (element, face, ichild); + child_face = ts->element_face_get_child_face (eclass, element, face, ichild); /* find owners of this child */ /* For the first child, we reuse the first descendant */ first_desc = (ichild == 0 ? first_face_desc : NULL); /* For the last child, we reuse the last descendant */ last_desc = (ichild == num_children - 1 ? last_face_desc : NULL); - t8_forest_element_owners_at_face_recursion (forest, gtreeid, face_children[ichild], eclass, ts, child_face, - owners, lower_bound, upper_bound, first_desc, last_desc); + t8_forest_element_owners_at_face_recursion (forest, gtreeid, face_children[ichild], eclass, child_face, owners, + lower_bound, upper_bound, first_desc, last_desc); } - ts->t8_element_destroy (num_children, face_children); + ts->element_destroy (eclass, num_children, face_children); T8_FREE (face_children); } } @@ -2524,10 +2516,7 @@ void t8_forest_element_owners_at_face (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_eclass_t eclass, int face, sc_array_t *owners) { - t8_scheme *ts; int lower_bound, upper_bound; - - ts = t8_forest_get_eclass_scheme (forest, eclass); if (owners->elem_count > 0) { /* Compute lower and upper bound for the owners */ lower_bound = *(int *) sc_array_index (owners, 0); @@ -2550,15 +2539,15 @@ t8_forest_element_owners_at_face (t8_forest_t forest, t8_gloidx_t gtreeid, const return; } /* call the recursion */ - t8_forest_element_owners_at_face_recursion (forest, gtreeid, element, eclass, ts, face, owners, lower_bound, - upper_bound, NULL, NULL); + t8_forest_element_owners_at_face_recursion (forest, gtreeid, element, eclass, face, owners, lower_bound, upper_bound, + NULL, NULL); } void t8_forest_element_owners_bounds (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_eclass_t eclass, int *lower, int *upper) { - t8_scheme *ts; + const t8_scheme *ts = t8_forest_get_scheme (forest); t8_element_t *first_desc, *last_desc; if (*lower >= *upper) { @@ -2567,24 +2556,23 @@ t8_forest_element_owners_bounds (t8_forest_t forest, t8_gloidx_t gtreeid, const } /* Compute the first and last descendant of element */ - ts = t8_forest_get_eclass_scheme (forest, eclass); - ts->t8_element_new (1, &first_desc); - ts->t8_element_first_descendant (element, first_desc, forest->maxlevel); - ts->t8_element_new (1, &last_desc); - ts->t8_element_last_descendant (element, last_desc, forest->maxlevel); + ts->element_new (eclass, 1, &first_desc); + ts->element_construct_first_descendant (eclass, element, first_desc, forest->maxlevel); + ts->element_new (eclass, 1, &last_desc); + ts->element_construct_last_descendant (eclass, element, last_desc, forest->maxlevel); /* Compute their owners as bounds for all of element's owners */ *lower = t8_forest_element_find_owner_ext (forest, gtreeid, first_desc, eclass, *lower, *upper, *lower, 1); *upper = t8_forest_element_find_owner_ext (forest, gtreeid, last_desc, eclass, *lower, *upper, *upper, 1); - ts->t8_element_destroy (1, &first_desc); - ts->t8_element_destroy (1, &last_desc); + ts->element_destroy (eclass, 1, &first_desc); + ts->element_destroy (eclass, 1, &last_desc); } void t8_forest_element_owners_at_face_bounds (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_eclass_t eclass, int face, int *lower, int *upper) { - t8_scheme *ts; + const t8_scheme *ts = t8_forest_get_scheme (forest); t8_element_t *first_face_desc, *last_face_desc; if (*lower >= *upper) { @@ -2592,38 +2580,34 @@ t8_forest_element_owners_at_face_bounds (t8_forest_t forest, t8_gloidx_t gtreeid return; } - ts = t8_forest_get_eclass_scheme (forest, eclass); - ts->t8_element_new (1, &first_face_desc); - ts->t8_element_first_descendant_face (element, face, first_face_desc, forest->maxlevel); - ts->t8_element_new (1, &last_face_desc); - ts->t8_element_last_descendant_face (element, face, last_face_desc, forest->maxlevel); + ts->element_new (eclass, 1, &first_face_desc); + ts->element_construct_first_descendant_face (eclass, element, face, first_face_desc, forest->maxlevel); + ts->element_new (eclass, 1, &last_face_desc); + ts->element_construct_last_descendant_face (eclass, element, face, last_face_desc, forest->maxlevel); /* owner of first and last descendants */ *lower = t8_forest_element_find_owner_ext (forest, gtreeid, first_face_desc, eclass, *lower, *upper, *lower, 1); *upper = t8_forest_element_find_owner_ext (forest, gtreeid, last_face_desc, eclass, *lower, *upper, *upper, 1); - ts->t8_element_destroy (1, &first_face_desc); - ts->t8_element_destroy (1, &last_face_desc); + ts->element_destroy (eclass, 1, &first_face_desc); + ts->element_destroy (eclass, 1, &last_face_desc); } void t8_forest_element_owners_at_neigh_face (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, sc_array_t *owners) { - t8_scheme *neigh_scheme; - t8_eclass_t neigh_class; + const t8_scheme *scheme = t8_forest_get_scheme (forest); + const t8_eclass_t neigh_class = t8_forest_element_neighbor_eclass (forest, ltreeid, element, face); t8_element_t *face_neighbor; int dual_face; t8_gloidx_t neigh_tree; - /* Find out the eclass of the face neighbor tree and allocate memory for - * the neighbor element */ - neigh_class = t8_forest_element_neighbor_eclass (forest, ltreeid, element, face); + /* Aallocate memory for the neighbor element */ T8_ASSERT (T8_ECLASS_ZERO <= neigh_class && neigh_class < T8_ECLASS_COUNT); - neigh_scheme = t8_forest_get_eclass_scheme (forest, neigh_class); - neigh_scheme->t8_element_new (1, &face_neighbor); + scheme->element_new (neigh_class, 1, &face_neighbor); /* clang-format off */ neigh_tree = t8_forest_element_face_neighbor (forest, ltreeid, element, face_neighbor, - neigh_scheme, face, &dual_face); + neigh_class, face, &dual_face); /* clang-format on */ if (neigh_tree >= 0) { /* There is a face neighbor */ @@ -2633,15 +2617,15 @@ t8_forest_element_owners_at_neigh_face (t8_forest_t forest, t8_locidx_t ltreeid, /* There is no face neighbor, we indicate this by setting the array to 0 */ sc_array_resize (owners, 0); } - neigh_scheme->t8_element_destroy (1, &face_neighbor); + scheme->element_destroy (neigh_class, 1, &face_neighbor); } void t8_forest_element_owners_at_neigh_face_bounds (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *element, int face, int *lower, int *upper) { - t8_scheme *neigh_scheme; - t8_eclass_t neigh_class; + const t8_scheme *scheme = t8_forest_get_scheme (forest); + const t8_eclass_t neigh_class = t8_forest_element_neighbor_eclass (forest, ltreeid, element, face); t8_element_t *face_neighbor; int dual_face; t8_gloidx_t neigh_tree; @@ -2650,12 +2634,9 @@ t8_forest_element_owners_at_neigh_face_bounds (t8_forest_t forest, t8_locidx_t l /* There is no owner or it is unique */ return; } - /* Find out the eclass of the face neighbor tree and allocate memory for the neighbor element */ - neigh_class = t8_forest_element_neighbor_eclass (forest, ltreeid, element, face); - neigh_scheme = t8_forest_get_eclass_scheme (forest, neigh_class); - neigh_scheme->t8_element_new (1, &face_neighbor); - neigh_tree - = t8_forest_element_face_neighbor (forest, ltreeid, element, face_neighbor, neigh_scheme, face, &dual_face); + /* Allocate memory for the neighbor element */ + scheme->element_new (neigh_class, 1, &face_neighbor); + neigh_tree = t8_forest_element_face_neighbor (forest, ltreeid, element, face_neighbor, neigh_class, face, &dual_face); if (neigh_tree >= 0) { /* There is a face neighbor */ t8_forest_element_owners_at_face_bounds (forest, neigh_tree, face_neighbor, neigh_class, dual_face, lower, upper); @@ -2665,17 +2646,21 @@ t8_forest_element_owners_at_neigh_face_bounds (t8_forest_t forest, t8_locidx_t l *lower = 1; *upper = 0; } - neigh_scheme->t8_element_destroy (1, &face_neighbor); + scheme->element_destroy (neigh_class, 1, &face_neighbor); } int -t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_scheme *ts) +t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, + const t8_eclass_t tree_class) { t8_locidx_t ltreeid; t8_element_t *last_desc; t8_locidx_t ghost_treeid; t8_linearidx_t last_desc_id, elem_id; int index, level, level_found; + const t8_scheme *ts = t8_forest_get_scheme (forest); + const t8_locidx_t ltreeid = t8_forest_get_local_id (forest, gtreeid); + const t8_eclass_t tree_class = t8_forest_get_eclass (forest, ltreeid); T8_ASSERT (t8_forest_is_committed (forest)); @@ -2683,12 +2668,12 @@ t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const * We then check whether the forest has any element with id between * the id of element and the id of the last descendant */ /* TODO: element interface function t8_element_last_desc_id */ - ts->t8_element_new (1, &last_desc); + ts->element_new (tree_class, 1, &last_desc); /* TODO: set level in last_descendant */ - ts->t8_element_last_descendant (element, last_desc, forest->maxlevel); - last_desc_id = ts->t8_element_get_linear_id (last_desc, forest->maxlevel); + ts->element_construct_last_descendant (tree_class, element, last_desc, forest->maxlevel); + last_desc_id = ts->element_get_linear_id (tree_class, last_desc, forest->maxlevel); /* Get the level of the element */ - level = ts->t8_element_level (element); + level = ts->element_get_level (tree_class, element); /* Get the local id of the tree. If the tree is not a local tree, * then the number returned is negative */ ltreeid = t8_forest_get_local_id (forest, gtreeid); @@ -2702,14 +2687,14 @@ t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const /* There exists an element in the array with id <= last_desc_id, * If also elem_id < id, then we found a true decsendant of element */ const t8_element_t *elem_found = t8_element_array_index_locidx (elements, index); - elem_id = ts->t8_element_get_linear_id (elem_found, forest->maxlevel); - level_found = ts->t8_element_level (elem_found); - if (ts->t8_element_get_linear_id (element, forest->maxlevel) <= elem_id && level < level_found) { + elem_id = ts->element_get_linear_id (tree_class, elem_found, forest->maxlevel); + level_found = ts->element_get_level (tree_class, elem_found); + if (ts->element_get_linear_id (tree_class, element, forest->maxlevel) <= elem_id && level < level_found) { /* The element is a true descendant */ - T8_ASSERT (ts->t8_element_level (elem_found) > ts->t8_element_level (element)); + T8_ASSERT (ts->element_get_level (tree_class, elem_found) > ts->element_get_level (tree_class, element)); T8_ASSERT (t8_forest_element_is_leaf (forest, elem_found, ltreeid)); /* clean-up */ - ts->t8_element_destroy (1, &last_desc); + ts->element_destroy (tree_class, 1, &last_desc); return 1; } } @@ -2725,19 +2710,19 @@ t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const /* There exists an element in the array with id <= last_desc_id, * If also elem_id < id, then we found a true decsendant of element */ const t8_element_t *elem_found = t8_element_array_index_int (elements, index); - elem_id = ts->t8_element_get_linear_id (elem_found, forest->maxlevel); - level_found = ts->t8_element_level (elem_found); - if (ts->t8_element_get_linear_id (element, forest->maxlevel) <= elem_id && level < level_found) { + elem_id = ts->element_get_linear_id (tree_class, elem_found, forest->maxlevel); + level_found = ts->element_get_level (tree_class, elem_found); + if (ts->element_get_linear_id (tree_class, element, forest->maxlevel) <= elem_id && level < level_found) { /* The element is a true descendant */ - T8_ASSERT (ts->t8_element_level (elem_found) > ts->t8_element_level (element)); + T8_ASSERT (ts->element_get_level (tree_class, elem_found) > ts->element_get_level (tree_class, element)); /* clean-up */ - ts->t8_element_destroy (1, &last_desc); + ts->element_destroy (tree_class, 1, &last_desc); return 1; } } } } - ts->t8_element_destroy (1, &last_desc); + ts->element_destroy (tree_class, 1, &last_desc); return 0; } @@ -3069,7 +3054,7 @@ t8_forest_refines_irregular (t8_forest_t forest) /* If the forest has trees of the current eclass, check if elements of this eclass refine irregular. */ if (forest->cmesh->num_local_trees_per_eclass[int_eclass] > 0) { tscheme = t8_forest_get_scheme_before_commit (forest); - irregular = irregular || t8_element_refines_irregular (tscheme, (t8_eclass_t) int_eclass); + irregular = irregular || t8_element_refines_irregular (forest, (t8_eclass_t) int_eclass); } } /* Combine the process-local results via a logic or and distribute the result over all procs (in the communicator).*/ diff --git a/src/t8_forest/t8_forest_balance.cxx b/src/t8_forest/t8_forest_balance.cxx index da5e5bcf75..f9399cdca3 100644 --- a/src/t8_forest/t8_forest_balance.cxx +++ b/src/t8_forest/t8_forest_balance.cxx @@ -49,7 +49,6 @@ t8_forest_balance_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_ int *pdone, iface, num_faces, num_half_neighbors, ineigh; t8_gloidx_t neighbor_tree; t8_eclass_t neigh_class; - t8_scheme *neigh_scheme; const t8_element_t *element = elements[0]; t8_element_t **half_neighbors; @@ -74,15 +73,14 @@ t8_forest_balance_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_ half_neighbors = T8_ALLOC (t8_element_t *, num_half_neighbors); ts->element_new (neigh_class, num_half_neighbors, half_neighbors); /* Compute the half face neighbors of element at this face */ - neighbor_tree = t8_forest_element_half_face_neighbors ( - forest_from, ltree_id, element, half_neighbors, neigh_scheme, iface, num_half_neighbors, NULL); // TODO: CRTP + neighbor_tree = t8_forest_element_half_face_neighbors (forest_from, ltree_id, element, half_neighbors, + neigh_class, iface, num_half_neighbors, NULL); if (neighbor_tree >= 0) { /* The face neighbors do exist, check for each one, whether it has * local or ghost leaf descendants in the forest. * If so, the element will be refined. */ for (ineigh = 0; ineigh < num_half_neighbors; ineigh++) { - if (t8_forest_element_has_leaf_desc (forest_from, neighbor_tree, half_neighbors[ineigh], - neigh_scheme)) { //TODO: CRTP + if (t8_forest_element_has_leaf_desc (forest_from, neighbor_tree, half_neighbors[ineigh], neigh_class)) { /* This element should be refined */ *pdone = 0; /* clean-up */ diff --git a/src/t8_forest/t8_forest_general.h b/src/t8_forest/t8_forest_general.h index a668508ed3..beac8530c7 100644 --- a/src/t8_forest/t8_forest_general.h +++ b/src/t8_forest/t8_forest_general.h @@ -548,7 +548,7 @@ t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, * of the neighbor leaves are stored here. * 0, 1, ... num_local_el - 1 for local leaves and * num_local_el , ... , num_local_el + num_ghosts - 1 for ghosts. - * \param [out] pneigh_scheme On output the eclass scheme of the neighbor elements. + * \param [out] pneigh_eclass On output the eclass of the neighbor elements. * \param [in] forest_is_balanced True if we know that \a forest is balanced, false * otherwise. * \param [out] orientation If a pointer to an integer variable is given the face orientation is computed and stored there. @@ -570,12 +570,12 @@ t8_forest_leaf_face_orientation (t8_forest_t forest, const t8_locidx_t ltreeid, void t8_forest_leaf_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, - t8_locidx_t **pelement_indices, t8_scheme_c **pneigh_scheme, int forest_is_balanced); + t8_locidx_t **pelement_indices, t8_eclass_t *pneigh_eclass, int forest_is_balanced); void t8_forest_leaf_face_neighbors_ext (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *leaf, t8_element_t **pneighbor_leaves[], int face, int *dual_faces[], int *num_neighbors, - t8_locidx_t **pelement_indices, t8_scheme_c **pneigh_scheme, int forest_is_balanced, + t8_locidx_t **pelement_indices, t8_eclass_t *pneigh_eclass, int forest_is_balanced, t8_gloidx_t *gneigh_tree, int *orientation); /** Exchange ghost information of user defined element data. @@ -787,7 +787,7 @@ t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, cons * On output, this element's data is filled with the * data of the face neighbor. If the neighbor does not exist * the data could be modified arbitrarily. - * \param [in] neigh_scheme The eclass scheme of \a neigh. + * \param [in] neigh_eclass The eclass of \a neigh. * \param [in] face The number of the face along which the neighbor should be * constructed. * \param [out] neigh_face The number of the face viewed from perspective of \a neigh. @@ -796,7 +796,7 @@ t8_forest_element_neighbor_eclass (t8_forest_t forest, t8_locidx_t ltreeid, cons */ t8_gloidx_t t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, - t8_scheme_c *neigh_scheme, int face, int *neigh_face); + t8_eclass_t neigh_eclass, int face, int *neigh_face); /* TODO: implement */ void diff --git a/src/t8_forest/t8_forest_private.h b/src/t8_forest/t8_forest_private.h index e9e473499e..ca129087d3 100644 --- a/src/t8_forest/t8_forest_private.h +++ b/src/t8_forest/t8_forest_private.h @@ -383,7 +383,7 @@ t8_forest_element_owners_at_neigh_face_bounds (t8_forest_t forest, t8_locidx_t l * \param [in,out] neighs An array of allocated elements of the correct element class. * On output the face neighbors of \a elem across \a face of one * bigger refinement level are stored. - * \param [in] neigh_scheme The eclass scheme of the neighbors. + * \param [in] neigh_class The eclass of the neighbors. * \param [in] face The number of the face of \a elem. * \param [in] num_neighs The number of allocated element in \a neighs. Must match the * number of face neighbors of one bigger refinement level. @@ -393,7 +393,7 @@ t8_forest_element_owners_at_neigh_face_bounds (t8_forest_t forest, t8_locidx_t l */ t8_gloidx_t t8_forest_element_half_face_neighbors (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, - t8_element_t *neighs[], t8_scheme_c *neigh_scheme, int face, int num_neighs, + t8_element_t *neighs[], t8_eclass_t neigh_class, int face, int num_neighs, int dual_faces[]); /** Iterate over all leaves of a forest and for each face compute the face neighbor @@ -411,14 +411,15 @@ t8_forest_print_all_leaf_neighbors (t8_forest_t forest); * \param [in] forest The forest. * \param [in] gtreeid The global id of the tree the element is in * \param [in] element The element - * \param [in] ts The eclass scheme of \a element. + * \param [in] ts The eclass of \a element. * \return True if in the forest there exists a local leaf or ghost * leaf that is a descendant of \a element but not equal to \a element. * \note If no ghost layer was created for the forest, only local elements are tested. * \note \a forest must be committed before calling this function. */ int -t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, t8_scheme_c *ts); +t8_forest_element_has_leaf_desc (t8_forest_t forest, t8_gloidx_t gtreeid, const t8_element_t *element, + const t8_eclass_t tree_class); T8_EXTERN_C_END (); diff --git a/src/t8_schemes/t8_crtp.hxx b/src/t8_schemes/t8_crtp.hxx index 0d6119a993..c96d683947 100644 --- a/src/t8_schemes/t8_crtp.hxx +++ b/src/t8_schemes/t8_crtp.hxx @@ -28,7 +28,7 @@ /* CRTP helper class, adds static "upcasting" methods for const and non const objects. */ template -class crtp { +class t8_crtp { public: TUnderlying& underlying () diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.cxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.cxx deleted file mode 100644 index c3e8962a55..0000000000 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.cxx +++ /dev/null @@ -1,171 +0,0 @@ -/* - This file is part of t8code. - t8code is a C library to manage a collection (a forest) of multiple - connected adaptive space-trees of general element classes in parallel. - - Copyright (C) 2024 the developers - - t8code is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - t8code is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with t8code; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include - -/* We want to export the whole implementation to be callable from "C" */ -T8_EXTERN_C_BEGIN (); - -/** This class independent function assumes an sc_mempool_t as context. - * It is suitable as the elem_new callback in \ref t8_eclass_scheme_t. - * We assume that the mempool has been created with the correct element size. - * \param [in,out] ts_context An element is allocated in this sc_mempool_t. - * \param [in] length Non-negative number of elements to allocate. - * \param [in,out] elem Array of correct size whose members are filled. - */ -inline static void -t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, t8_element_t **elem); - -/** This class independent function assumes an sc_mempool_t as context. - * It is suitable as the elem_destroy callback in \ref t8_eclass_scheme_t. - * We assume that the mempool has been created with the correct element size. - * \param [in,out] ts_context An element is returned to this sc_mempool_t. - * \param [in] length Non-negative number of elements to destroy. - * \param [in,out] elem Array whose members are returned to the mempool. - */ -inline static void -t8_default_mempool_free (sc_mempool_t *ts_context, int length, t8_element_t **elem); - -/* Destructor */ -t8_default_scheme_common_c::~t8_default_scheme_common_c () -{ - T8_ASSERT (ts_context != NULL); - SC_ASSERT (((sc_mempool_t *) ts_context)->elem_count == 0); - sc_mempool_destroy ((sc_mempool_t *) ts_context); -} - -/** Compute the number of corners of a given element. */ -int -t8_default_scheme_common_c::element_get_num_corners (const t8_element_t *elem) const -{ - /* use the lookup table of the eclasses. - * Pyramids should implement their own version of this function. */ - return t8_eclass_num_vertices[eclass]; -} - -void -t8_default_scheme_common_c::element_new (int length, t8_element_t **elem) const -{ - t8_default_mempool_alloc ((sc_mempool_t *) this->ts_context, length, elem); -} - -void -t8_default_scheme_common_c::element_destroy (int length, t8_element_t **elem) const -{ - t8_default_mempool_free ((sc_mempool_t *) this->ts_context, length, elem); -} - -inline static void -t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, t8_element_t **elem) -{ - int i; - - T8_ASSERT (ts_context != NULL); - T8_ASSERT (0 <= length); - T8_ASSERT (elem != NULL); - - for (i = 0; i < length; ++i) { - elem[i] = (t8_element_t *) sc_mempool_alloc (ts_context); - } -} - -inline static void -t8_default_mempool_free (sc_mempool_t *ts_context, int length, t8_element_t **elem) -{ - int i; - - T8_ASSERT (ts_context != NULL); - T8_ASSERT (0 <= length); - T8_ASSERT (elem != NULL); - - for (i = 0; i < length; ++i) { - sc_mempool_free (ts_context, elem[i]); - } -} - -t8_element_shape_t -t8_default_scheme_common_c::element_get_shape (const t8_element_t *elem) const -{ - return eclass; -} - -/* Given an element's level and dimension, return the number of leaves it - * produces at a given uniform refinement level */ -static inline t8_gloidx_t -count_leaves_from_level (int element_level, int refinement_level, int dimension) -{ - return element_level > refinement_level ? 0 : sc_intpow64 (2, dimension * (refinement_level - element_level)); -} - -t8_gloidx_t -t8_default_scheme_common_c::element_count_leaves (const t8_element_t *t, int level) const -{ - - int element_level = element_get_level (t); - t8_element_shape_t element_shape; - int dim = t8_eclass_to_dimension[eclass]; - element_shape = t8_element_shape (t); - if (element_shape == T8_ECLASS_PYRAMID) { - int level_diff = level - element_level; - return element_level > level ? 0 : 2 * sc_intpow64 (8, level_diff) - sc_intpow64 (6, level_diff); - } - return count_leaves_from_level (element_level, level, dim); -} - -/* Count the number of siblings. - * The number of children is 2^dim for each element, except for pyramids. - * TODO: For pyramids we will have to implement a standalone version in the pyramid scheme. */ -int -t8_default_scheme_common_c::element_get_num_siblings (const t8_element_t *elem) const -{ - const int dim = t8_eclass_to_dimension[eclass]; - T8_ASSERT (eclass != T8_ECLASS_PYRAMID); - return sc_intpow (2, dim); -} - -t8_gloidx_t -t8_default_scheme_common_c::count_leaves_from_root (int level) const -{ - if (eclass == T8_ECLASS_PYRAMID) { - return 2 * sc_intpow64u (8, level) - sc_intpow64u (6, level); - } - int dim = t8_eclass_to_dimension[eclass]; - return count_leaves_from_level (0, level, dim); -} - -#if T8_ENABLE_DEBUG -void -t8_default_scheme_common_c::element_debug_print (const t8_element_t *elem) const -{ - char debug_string[BUFSIZ]; - element_to_string (elem, debug_string, BUFSIZ); - t8_debugf ("%s\n", debug_string); -} -#endif - -void -t8_default_scheme_common_c::element_deinit (int length, t8_element_t *elem) const -{ -} - -T8_EXTERN_C_END (); diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx index bb6b664f55..a52f767d2a 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx @@ -28,31 +28,109 @@ #include #include +#include /* Macro to check whether a pointer (VAR) to a base class, comes from an * implementation of a child class (TYPE). */ #define T8_COMMON_IS_TYPE(VAR, TYPE) ((dynamic_cast (VAR)) != NULL) -class t8_default_scheme_common_c { +/** This class independent function assumes an sc_mempool_t as context. + * It is suitable as the elem_new callback in \ref t8_eclass_scheme_t. + * We assume that the mempool has been created with the correct element size. + * \param [in,out] ts_context An element is allocated in this sc_mempool_t. + * \param [in] length Non-negative number of elements to allocate. + * \param [in,out] elem Array of correct size whose members are filled. + */ +inline static void +t8_default_mempool_alloc (sc_mempool_t *ts_context, int length, t8_element_t **elem) +{ + int i; + + T8_ASSERT (ts_context != NULL); + T8_ASSERT (0 <= length); + T8_ASSERT (elem != NULL); + + for (i = 0; i < length; ++i) { + elem[i] = (t8_element_t *) sc_mempool_alloc (ts_context); + } +} + +/** This class independent function assumes an sc_mempool_t as context. + * It is suitable as the elem_destroy callback in \ref t8_eclass_scheme_t. + * We assume that the mempool has been created with the correct element size. + * \param [in,out] ts_context An element is returned to this sc_mempool_t. + * \param [in] length Non-negative number of elements to destroy. + * \param [in,out] elem Array whose members are returned to the mempool. + */ +inline static void +t8_default_mempool_free (sc_mempool_t *ts_context, int length, t8_element_t **elem) +{ + int i; + + T8_ASSERT (ts_context != NULL); + T8_ASSERT (0 <= length); + T8_ASSERT (elem != NULL); + + for (i = 0; i < length; ++i) { + sc_mempool_free (ts_context, elem[i]); + } +} + +/* Given an element's level and dimension, return the number of leaves it + * produces at a given uniform refinement level */ +static inline t8_gloidx_t +count_leaves_from_level (int element_level, int refinement_level, int dimension) +{ + return element_level > refinement_level ? 0 : sc_intpow64 (2, dimension * (refinement_level - element_level)); +} + +template +class t8_default_scheme_common_c: t8_eclass_scheme { public: /** Destructor for all default schemes */ - ~t8_default_scheme_common_c (); + ~t8_default_scheme_common_c () + { + T8_ASSERT (ts_context != NULL); + SC_ASSERT (((sc_mempool_t *) ts_context)->elem_count == 0); + sc_mempool_destroy ((sc_mempool_t *) ts_context); + } /** Compute the number of corners of a given element. */ int - element_get_num_corners (const t8_element_t *elem) const; + element_get_num_corners (const t8_element_t *elem) const + { + /* use the lookup table of the eclasses. + * Pyramids should implement their own version of this function. */ + return t8_eclass_num_vertices[eclass]; + } /** Allocate space for a bunch of elements. */ void - element_new (int length, t8_element_t **elem) const; + element_new (int length, t8_element_t **elem) const + { + t8_default_mempool_alloc ((sc_mempool_t *) this->ts_context, length, elem); + } /** Deallocate space for a bunch of elements. */ void - element_destroy (int length, t8_element_t **elem) const; + element_destroy (int length, t8_element_t **elem) const + { + t8_default_mempool_free ((sc_mempool_t *) this->ts_context, length, elem); + } + + void + t8_element_deinit (int length, t8_element_t *elem) const + { + } /** Return the shape of an element */ t8_element_shape_t - element_get_shape (const t8_element_t *elem) const; + element_get_shape (const t8_element_t *elem) const + { + /* use the lookup table of the eclasses. + * Pyramids should implement their own version of this function. */ + return eclass; + } /** Count how many leaf descendants of a given uniform level an element would produce. * \param [in] t The element to be checked. @@ -63,7 +141,18 @@ class t8_default_scheme_common_c { * children. */ t8_gloidx_t - element_count_leaves (const t8_element_t *t, int level) const; + element_count_leaves (const t8_element_t *t, int level) const + { + int element_level = element_get_level (t); + t8_element_shape_t element_shape; + int dim = t8_eclass_to_dimension[eclass]; + element_shape = t8_element_shape (t); + if (element_shape == T8_ECLASS_PYRAMID) { + int level_diff = level - element_level; + return element_level > level ? 0 : 2 * sc_intpow64 (8, level_diff) - sc_intpow64 (6, level_diff); + } + return count_leaves_from_level (element_level, level, dim); + } /** Compute the number of siblings of an element. That is the number of * Children of its parent. @@ -72,7 +161,12 @@ class t8_default_scheme_common_c { * Note that this number is >= 1, since we count the element itself as a sibling. */ int - element_get_num_siblings (const t8_element_t *elem) const; + element_get_num_siblings (const t8_element_t *elem) const + { + const int dim = t8_eclass_to_dimension[eclass]; + T8_ASSERT (eclass != T8_ECLASS_PYRAMID); + return sc_intpow (2, dim); + } /** Count how many leaf descendants of a given uniform level the root element will produce. * \param [in] level A refinement level. @@ -80,10 +174,22 @@ class t8_default_scheme_common_c { * is the root (level 0) element. */ t8_gloidx_t - count_leaves_from_root (int level) const; + count_leaves_from_root (int level) const + { + if (eclass == T8_ECLASS_PYRAMID) { + return 2 * sc_intpow64u (8, level) - sc_intpow64u (6, level); + } + int dim = t8_eclass_to_dimension[eclass]; + return count_leaves_from_level (0, level, dim); + } #if T8_ENABLE_DEBUG void - element_debug_print (const t8_element_t *elem) const; + element_debug_print (const t8_element_t *elem) const + { + char debug_string[BUFSIZ]; + element_to_string (elem, debug_string, BUFSIZ); + t8_debugf ("%s\n", debug_string); + } #endif }; diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx index 73bd3076f4..aa915178d8 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #define HEX_LINEAR_MAXLEVEL P8EST_OLD_QMAXLEVEL #define HEX_REFINE_MAXLEVEL P8EST_OLD_QMAXLEVEL @@ -33,6 +34,12 @@ /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); +size_t +t8_default_scheme_hex_c::get_element_size (void) const +{ + return sizeof (t8_phex_t); +} + int t8_default_scheme_hex_c::get_maxlevel (void) const { @@ -293,16 +300,15 @@ t8_default_scheme_hex_c::element_get_tree_face (const t8_element_t *elem, int fa } int -t8_default_scheme_hex_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_hex_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { const p4est_quadrant_t *b = (const p4est_quadrant_t *) face; p8est_quadrant_t *q = (p8est_quadrant_t *) elem; - T8_ASSERT (T8_COMMON_IS_TYPE (face_scheme, const t8_default_scheme_quad_c *)); + T8_ASSERT (face_eclass == T8_ECLASS_QUAD); T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (face_scheme->eclass == T8_ECLASS_QUAD); - T8_ASSERT (face_scheme->element_is_valid (face)); + T8_ASSERT (scheme->element_is_valid (face_eclass, face)); T8_ASSERT (0 <= root_face && root_face < P8EST_FACES); q->level = b->level; /* @@ -394,15 +400,13 @@ t8_default_scheme_hex_c::element_construct_last_descendant_face (const t8_elemen void t8_default_scheme_hex_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *boundary_scheme) const + const t8_scheme *scheme) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p4est_quadrant_t *b = (p4est_quadrant_t *) boundary; T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (T8_COMMON_IS_TYPE (boundary_scheme, const t8_default_scheme_quad_c *)); - T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_QUAD); - T8_ASSERT (boundary_scheme->element_is_valid (boundary)); + T8_ASSERT (scheme->element_is_valid (T8_ECLASS_QUAD, boundary)); T8_ASSERT (0 <= face && face < P8EST_FACES); /* The level of the boundary element is the same as the quadrant's level */ diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx index f3289f9eb4..6c7a9e0ed5 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx @@ -37,13 +37,21 @@ */ typedef p8est_quadrant_t t8_phex_t; -class t8_default_scheme_hex_c: public t8_eclass_scheme, public t8_default_scheme_common_c { +class t8_default_scheme_hex_c: + public t8_eclass_scheme, + public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_hex_c (); ~t8_default_scheme_hex_c (); + /** Return the size of a hex element. + * \return The size of an element of class hex. + */ + size_t + get_element_size (void) const; + /** Allocate memory for an array of hexaedra and initialize them. * \param [in] length The number of hex to be allocated. * \param [in,out] elems On input an array of \b length many unallocated @@ -375,18 +383,19 @@ class t8_default_scheme_hex_c: public t8_eclass_scheme, * the element inside the root tree that has the given face as a * face. * \param [in] face A face element. - * \param [in] face_scheme The scheme for the face element. + * \param [in] face_eclass The eclass for the face element. * \param [in,out] elem An allocated element. The entries will be filled with * the data of the element that has \a face as a face and * lies within the root tree. * \param [in] root_face The index of the face of the root tree in which \a face * lies. + * \param [in] scheme The scheme collection with a scheme for the eclass of the face. * \return The face number of the face of \a elem that coincides * with \a face. */ int - element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const; + element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, t8_element_t *elem, int root_face, + const t8_scheme *scheme) const; /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -418,11 +427,11 @@ class t8_default_scheme_hex_c: public t8_eclass_scheme, * \param [in,out] boundary An allocated element of dimension of \a element * minus 1. The entries will be filled with the entries * of the face of \a element. - * \param [in] boundary_scheme The scheme for the eclass of the boundary face. + * \param [in] scheme The scheme containing an eclass scheme for the boundary face. */ void element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme_c *boundary_scheme) const; + const t8_scheme *scheme) const; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx index b5e490036e..1681cde65d 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx @@ -25,11 +25,18 @@ #include #include #include +#include typedef t8_dline_t t8_default_line_t; T8_EXTERN_C_BEGIN (); +size_t +t8_default_scheme_line_c::get_element_size (void) const +{ + return sizeof (t8_dline_t); +} + int t8_default_scheme_line_c::get_maxlevel (void) const { @@ -167,12 +174,12 @@ t8_default_scheme_line_c::element_transform_face (const t8_element_t *elem1, t8_ * the element inside the root tree that has the given face as a * face. */ int -t8_default_scheme_line_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_line_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (T8_COMMON_IS_TYPE (face_scheme, const t8_default_scheme_vertex_c *)); - T8_ASSERT (face_scheme->element_is_valid (face)); + T8_ASSERT (face_eclass == T8_ECLASS_VERTEX); + T8_ASSERT (scheme->element_is_valid (face_eclass, face)); return t8_dline_extrude_face ((const t8_dvertex_t *) face, root_face, (t8_dline_t *) elem); } @@ -180,12 +187,10 @@ t8_default_scheme_line_c::element_extrude_face (const t8_element_t *face, const /** Construct the boundary element at a specific face. */ void t8_default_scheme_line_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *boundary_scheme) const + const t8_scheme *scheme) const { T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (T8_COMMON_IS_TYPE (boundary_scheme, const t8_default_scheme_vertex_c *)); - T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_VERTEX); - T8_ASSERT (boundary_scheme->element_is_valid (boundary)); + T8_ASSERT (scheme->element_is_valid (T8_ECLASS_VERTEX, boundary)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); /* Since each vertex is the same, we just construct a vertex of the same level diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx index 8e5c509d60..dcbb33163b 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx @@ -36,13 +36,21 @@ * It is written as a self-contained library in the t8_dline_* files. */ -class t8_default_scheme_line_c: public t8_eclass_scheme, public t8_default_scheme_common_c { +class t8_default_scheme_line_c: + public t8_eclass_scheme, + public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_line_c (); ~t8_default_scheme_line_c (); + /** Return the size of a line element. + * \return The size of an element of class line. + */ + size_t + get_element_size (void) const; + /** Allocate memory for an array of lines and initialize them. * \param [in] length The number of line elements to be allocated. * \param [in,out] elems On input an array of \b length many unallocated @@ -378,18 +386,19 @@ class t8_default_scheme_line_c: public t8_eclass_scheme #include #include +#include typedef t8_dprism_t t8_default_prism_t; T8_EXTERN_C_BEGIN (); +size_t +t8_default_scheme_prism_c::get_element_size (void) const +{ + return sizeof (t8_dprism_t); +} + void t8_default_scheme_prism_c::element_new (int length, t8_element_t **elem) const { @@ -225,10 +232,10 @@ t8_default_scheme_prism_c::element_get_tree_face (const t8_element_t *elem, int } int -t8_default_scheme_prism_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_prism_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { - T8_ASSERT (face_scheme->element_is_valid (face)); + T8_ASSERT (scheme->element_is_valid (face_eclass, face)); T8_ASSERT (0 <= root_face && root_face < T8_DPRISM_FACES); t8_dprism_extrude_face (face, elem, root_face); T8_ASSERT (element_is_valid (elem)); @@ -267,12 +274,13 @@ t8_default_scheme_prism_c::element_get_nca (const t8_element_t *elem1, const t8_ void t8_default_scheme_prism_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *boundary_scheme) const + const t8_scheme *scheme) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); t8_dprism_boundary_face ((const t8_dprism_t *) elem, face, boundary); - T8_ASSERT (boundary_scheme->element_is_valid (boundary)); + T8_ASSERT ( + scheme->element_is_valid (static_cast (t8_eclass_face_types[T8_ECLASS_PRISM][face]), boundary)); } const int t8_dprism_face_corner[5][4] = { diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx index a347c8c097..723a97c457 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx @@ -38,15 +38,20 @@ */ class t8_default_scheme_prism_c: - : public t8_eclass_scheme, - public t8_default_scheme_common_c { + public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_prism_c (void); ~t8_default_scheme_prism_c (); + /** Return the size of a prism element. + * \return The size of an element of class prism. + */ + size_t + get_element_size (void) const; + /** Allocate memory for an array of prisms and initialize them. * \param [in] length The number of prism elements to be allocated. * \param [in,out] elems On input an array of \b length many unallocated @@ -362,18 +367,19 @@ class t8_default_scheme_prism_c: * the element inside the root tree that has the given face as a * face. * \param [in] face A face element. - * \param [in] face_scheme The scheme for the face element. + * \param [in] face_eclass The eclass for the face element. * \param [in,out] elem An allocated element. The entries will be filled with * the data of the element that has \a face as a face and * lies within the root tree. * \param [in] root_face The index of the face of the root tree in which \a face * lies. + * \param [in] scheme The scheme collection with a scheme for the eclass of the face. * \return The face number of the face of \a elem that coincides * with \a face. */ int - element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const; + element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, t8_element_t *elem, int root_face, + const t8_scheme *scheme) const; /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -405,11 +411,11 @@ class t8_default_scheme_prism_c: * \param [in,out] boundary An allocated element of dimension of \a element * minus 1. The entries will be filled with the entries * of the face of \a element. - * \param [in] boundary_scheme The scheme for the eclass of the boundary face. + * \param [in] scheme The scheme containing an eclass scheme for the boundary face. */ void element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme_c *boundary_scheme) const; + const t8_scheme *scheme) const; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx index 4173666a41..c1fb9216a2 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx @@ -26,11 +26,18 @@ #include #include #include +#include typedef t8_dpyramid_t t8_default_pyramid_t; T8_EXTERN_C_BEGIN (); +size_t +t8_default_scheme_pyramid_c::get_element_size (void) const +{ + return sizeof (t8_dpyramid_t); +} + void t8_default_scheme_pyramid_c::element_new (int length, t8_element_t **elem) const { @@ -264,19 +271,21 @@ t8_default_scheme_pyramid_c::element_is_root_boundary (const t8_element_t *elem, void t8_default_scheme_pyramid_c::element_construct_boundary_face (const t8_element_t *elem, int face, - t8_element_t *boundary, - const t8_scheme *boundary_scheme) const + t8_element_t *boundary, const t8_scheme *scheme) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_boundary_face ((const t8_dpyramid_t *) elem, face, boundary); - T8_ASSERT (boundary_scheme->element_is_valid (boundary)); + T8_ASSERT ( + scheme->element_is_valid (static_cast (t8_eclass_face_types[T8_ECLASS_PYRAMID][face]), boundary)); } int -t8_default_scheme_pyramid_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_pyramid_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { - T8_ASSERT (face_scheme->element_is_valid (face)); + T8_ASSERT (element_is_valid (elem)); + T8_ASSERT (face_eclass == T8_ECLASS_TRIANGLE || face_eclass == T8_ECLASS_QUAD); + T8_ASSERT (scheme->element_is_valid (face_eclass, elem)); return t8_dpyramid_extrude_face (face, (t8_dpyramid_t *) elem, root_face); T8_ASSERT (element_is_valid (elem)); } diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx index 4a4e6578a3..2a2a78cac0 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx @@ -37,12 +37,19 @@ class t8_default_scheme_pyramid_c: public t8_eclass_scheme, - public t8_default_scheme_common_c { + public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_pyramid_c (void); ~t8_default_scheme_pyramid_c (); + + /** Return the size of a prism element. + * \return The size of an element of class prism. + */ + size_t + get_element_size (void) const; + /** Allocate memory for an array of pyramids and initialize them. * \param [in] length The number of pyramid elements to be allocated. * \param [in,out] elems On input an array of \b length many unallocated @@ -362,18 +369,23 @@ class t8_default_scheme_pyramid_c: SC_ABORT ("This function is not implemented yet.\n"); } - /** Given a boundary face inside a root tree's face construct the element inside the root tree that has the given - * face as a face. - * \param [in] face A face element. - * \param [in] face_scheme The scheme for the face element. - * \param [in,out] elem An allocated element. The entries will be filled with the data of the element that has - * \a face as a face and lies within the root tree. - * \param [in] root_face The index of the face of the root tree in which \a face lies. - * \return The face number of the face of \a elem that coincides with \a face. + /** Given a boundary face inside a root tree's face construct + * the element inside the root tree that has the given face as a + * face. + * \param [in] face A face element. + * \param [in] face_eclass The eclass for the face element. + * \param [in,out] elem An allocated element. The entries will be filled with + * the data of the element that has \a face as a face and + * lies within the root tree. + * \param [in] root_face The index of the face of the root tree in which \a face + * lies. + * \param [in] scheme The scheme collection with a scheme for the eclass of the face. + * \return The face number of the face of \a elem that coincides + * with \a face. */ int - element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const; + element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, t8_element_t *elem, int root_face, + const t8_scheme *scheme) const; /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -398,14 +410,16 @@ class t8_default_scheme_pyramid_c: /** Construct the boundary element at a specific face. * \param [in] elem The input element. - * \param [in] face The index of the face of which to construct the boundary element. - * \param [in,out] boundary An allocated element of dimension of \a element minus 1. The entries will be filled with - * the entries of the face of \a element. - * \param [in] boundary_scheme The scheme for the eclass of the boundary face. + * \param [in] face The index of the face of which to construct the + * boundary element. + * \param [in,out] boundary An allocated element of dimension of \a element + * minus 1. The entries will be filled with the entries + * of the face of \a element. + * \param [in] scheme The scheme containing an eclass scheme for the boundary face. */ void element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme_c *boundary_scheme) const; + const t8_scheme *scheme) const; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx index 43c68206ae..71c83d24a8 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx @@ -24,6 +24,7 @@ #include #include #include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); @@ -33,9 +34,11 @@ T8_EXTERN_C_BEGIN (); t8_linearidx_t element_get_linear_id (const t8_element_t *elem, int level); -#ifdef T8_ENABLE_DEBUG - -#endif /* T8_ENABLE_DEBUG */ +size_t +t8_default_scheme_quad_c::get_element_size (void) const +{ + return sizeof (t8_pquad_t); +} int t8_default_scheme_quad_c::get_maxlevel (void) const @@ -487,16 +490,15 @@ t8_default_scheme_quad_c::element_transform_face (const t8_element_t *elem1, t8_ } int -t8_default_scheme_quad_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_quad_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { const t8_dline_t *l = (const t8_dline_t *) face; p4est_quadrant_t *q = (p4est_quadrant_t *) elem; T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (T8_COMMON_IS_TYPE (face_scheme, const t8_default_scheme_line_c *)); - T8_ASSERT (face_scheme->eclass == T8_ECLASS_LINE); - T8_ASSERT (face_scheme->element_is_valid (elem)); + T8_ASSERT (face_eclass == T8_ECLASS_LINE); + T8_ASSERT (scheme->element_is_valid (face_eclass, elem)); T8_ASSERT (0 <= root_face && root_face < P4EST_FACES); /* * The faces of the root quadrant are enumerated like this: @@ -586,15 +588,13 @@ t8_default_scheme_quad_c::element_construct_last_descendant_face (const t8_eleme void t8_default_scheme_quad_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *boundary_scheme) const + const t8_scheme *scheme) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; t8_dline_t *l = (t8_dline_t *) boundary; T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (T8_COMMON_IS_TYPE (boundary_scheme, const t8_default_scheme_line_c *)); - T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_LINE); - T8_ASSERT (boundary_scheme->element_is_valid (boundary)); + T8_ASSERT (scheme->element_is_valid (T8_ECLASS_LINE, boundary)); T8_ASSERT (0 <= face && face < P4EST_FACES); /* The level of the boundary element is the same as the quadrant's level */ l->level = q->level; diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx index bcd7f2f08a..1f85e3755c 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx @@ -76,14 +76,21 @@ typedef p4est_quadrant_t t8_pquad_t; (quad)->p.user_long = (long) (coord); \ } while (0) -class t8_default_scheme_quad_c::public t8_eclass_scheme, public t8_default_scheme_common_c -{ +class t8_default_scheme_quad_c: + public t8_eclass_scheme, + public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_quad_c (); ~t8_default_scheme_quad_c (); + /** Return the size of a quad element. + * \return The size of an element of class quad. + */ + size_t + get_element_size (void) const; + /** Allocate memory for an array of quadrilaterals and initialize them. * \param [in] length The number of quad elements to be allocated. * \param [in,out] elems On input an array of \b length many unallocated @@ -101,7 +108,8 @@ class t8_default_scheme_quad_c::public t8_eclass_scheme elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - int element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -157,7 +170,8 @@ class t8_default_scheme_quad_c::public t8_eclass_scheme #include #include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); typedef t8_dtet_t t8_default_tet_t; +size_t +t8_default_scheme_tet_c::get_element_size (void) const +{ + return sizeof (t8_dtet_t); +} + int t8_default_scheme_tet_c::get_maxlevel (void) const { @@ -245,15 +252,15 @@ t8_default_scheme_tet_c::element_get_tree_face (const t8_element_t *elem, int fa * both in t8_dtri_bits.c. This would be needed by an implementation, at least * for tets. */ int -t8_default_scheme_tet_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_tet_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { const t8_dtri_t *b = (const t8_dtri_t *) face; t8_dtet_t *t = (t8_dtet_t *) elem; T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (face_scheme->eclass == T8_ECLASS_TRIANGLE); - T8_ASSERT (face_scheme->element_is_valid (face)); + T8_ASSERT (face_eclass == T8_ECLASS_TRIANGLE); + T8_ASSERT (scheme->element_is_valid (face_eclass, face)); T8_ASSERT (0 <= root_face && root_face < T8_DTET_FACES); t->level = b->level; switch (root_face) { @@ -322,15 +329,14 @@ t8_default_scheme_tet_c::element_construct_last_descendant_face (const t8_elemen * both in t8_dtet_bits.c. */ void t8_default_scheme_tet_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *boundary_scheme) const + const t8_scheme *scheme) const { const t8_default_tet_t *t = (const t8_default_tet_t *) elem; t8_dtri_t *b = (t8_dtri_t *) boundary; int face_cat; T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_TRIANGLE); - T8_ASSERT (boundary_scheme->element_is_valid (boundary)); + T8_ASSERT (scheme->element_is_valid (T8_ECLASS_TRIANGLE, boundary)); T8_ASSERT (0 <= face && face < T8_DTET_FACES); /* The level of the boundary element is the same as the quadrant's level */ b->level = t->level; diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx index 6d2b3e174b..d04b7b7ad0 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx @@ -33,13 +33,21 @@ #include #include -class t8_default_scheme_tet_c: public t8_eclass_scheme, public t8_default_scheme_common_c { +class t8_default_scheme_tet_c: + public t8_eclass_scheme, + public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_tet_c (); ~t8_default_scheme_tet_c (); + /** Return the size of a tet element. + * \return The size of an element of class tet. + */ + size_t + get_element_size (void) const; + /** Allocate memory for an array of tetrahedra and initialize them. * \param [in] length The number of tet elements to be allocated. * \param [in,out] elems On input an array of \b length many unallocated element pointers. On output all these @@ -331,18 +339,23 @@ class t8_default_scheme_tet_c: public t8_eclass_scheme, SC_ABORT ("This function is not implemented yet.\n"); } - /** Given a boundary face inside a root tree's face construct the element inside the root tree that has the given - * face as a face. + /** Given a boundary face inside a root tree's face construct + * the element inside the root tree that has the given face as a + * face. * \param [in] face A face element. - * \param [in] face_scheme The scheme for the face element. - * \param [in,out] elem An allocated element. The entries will be filled with the data of the element that has - * \a face as a face and lies within the root tree. - * \param [in] root_face The index of the face of the root tree in which \a face lies. - * \return The face number of the face of \a elem that coincides with \a face. + * \param [in] face_eclass The eclass for the face element. + * \param [in,out] elem An allocated element. The entries will be filled with + * the data of the element that has \a face as a face and + * lies within the root tree. + * \param [in] root_face The index of the face of the root tree in which \a face + * lies. + * \param [in] scheme The scheme collection with a scheme for the eclass of the face. + * \return The face number of the face of \a elem that coincides + * with \a face. */ int - element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const; + element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, t8_element_t *elem, int root_face, + const t8_scheme *scheme) const; /** Construct the first descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -370,13 +383,14 @@ class t8_default_scheme_tet_c: public t8_eclass_scheme, * \param [in] elem The input element. * \param [in] face The index of the face of which to construct the * boundary element. - * \param [in,out] boundary An allocated element of dimension of \a element minus 1. The entries will be filled with - * the entries of the face of \a element. - * \param [in] boundary_scheme The scheme for the eclass of the boundary face. + * \param [in,out] boundary An allocated element of dimension of \a element + * minus 1. The entries will be filled with the entries + * of the face of \a element. + * \param [in] scheme The scheme containing an eclass scheme for the boundary face. */ void element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme_c *boundary_scheme) const; + const t8_scheme *scheme) const; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.cxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.cxx index 7e29aafe67..ca1bdc66dd 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.cxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.cxx @@ -26,10 +26,17 @@ #include #include #include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); +size_t +t8_default_scheme_tri_c::get_element_size (void) const +{ + return sizeof (t8_dtri_t); +} + int t8_default_scheme_tri_c::get_maxlevel (void) const { @@ -268,16 +275,15 @@ t8_default_scheme_tri_c::element_transform_face (const t8_element_t *elem1, t8_e * both in t8_dtri_bits.c. This would be needed by an implementation, at least * for tets. */ int -t8_default_scheme_tri_c::element_extrude_face (const t8_element_t *face, const t8_scheme *face_scheme, - t8_element_t *elem, int root_face) const +t8_default_scheme_tri_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { const t8_dline_t *l = (const t8_dline_t *) face; t8_dtri_t *t = (t8_dtri_t *) elem; T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (T8_COMMON_IS_TYPE (face_scheme, const t8_default_scheme_line_c *)); - T8_ASSERT (face_scheme->eclass == T8_ECLASS_LINE); - T8_ASSERT (face_scheme->element_is_valid (face)); + T8_ASSERT (face_eclass == T8_ECLASS_LINE); + T8_ASSERT (scheme->element_is_valid (face_eclass, face)); T8_ASSERT (0 <= root_face && root_face < T8_DTRI_FACES); /* * The faces of the root triangle are enumerated like this @@ -347,15 +353,13 @@ t8_default_scheme_tri_c::element_construct_last_descendant_face (const t8_elemen /* Construct the boundary element at a specific face. */ void t8_default_scheme_tri_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *boundary_scheme) const + const t8_scheme *scheme) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; t8_dline_t *l = (t8_dline_t *) boundary; T8_ASSERT (element_is_valid (elem)); - T8_ASSERT (T8_COMMON_IS_TYPE (boundary_scheme, const t8_default_scheme_line_c *)); - T8_ASSERT (boundary_scheme->eclass == T8_ECLASS_LINE); - T8_ASSERT (boundary_scheme->element_is_valid (boundary)); + T8_ASSERT (scheme->element_is_valid (T8_ECLASS_LINE, boundary)); T8_ASSERT (0 <= face && face < T8_DTRI_FACES); /* The level of the boundary element is the same as the quadrant's level */ l->level = t->level; diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx index de9916ed42..a9d44c0298 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx @@ -32,14 +32,21 @@ #include #include -class t8_default_scheme_tri_c::public t8_eclass_scheme, public t8_default_scheme_common_c -{ +class t8_default_scheme_tri_c: + public t8_eclass_scheme, + public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_tri_c (); ~t8_default_scheme_tri_c (); + /** Return the size of a tri element. + * \return The size of an element of class tri. + */ + size_t + get_element_size (void) const; + /** Allocate memory for an array of triangles and initialize them. * \param [in] length The number of tri elements to be allocated. * \param [in,out] elems On input an array of \b length many unallocated @@ -57,7 +64,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \see element_init * \see element_is_valid */ - void element_new (int length, t8_element_t **elem) const; + void + element_new (int length, t8_element_t **elem) const; /** Initialize an array of allocated tri elements. * \param [in] length The number of tri elements to be initialized. @@ -76,18 +84,21 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \see element_new * \see element_is_valid */ - void element_init (int length, t8_element_t *elem) const; + void + element_init (int length, t8_element_t *elem) const; /** Return the refinement level of an element. * \param [in] elem The element whose level should be returned. * \return The level of \b elem. */ - int element_get_level (const t8_element_t *elem) const; + int + element_get_level (const t8_element_t *elem) const; /** Return the maximum allowed level for this element class. * \return The maximum allowed level for elements of this class. */ - int get_maxlevel (void) const; + int + get_maxlevel (void) const; /** Copy all entries of \b source to \b dest. \b dest must be an existing element. No memory is allocated by this * function. @@ -95,7 +106,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in,out] dest This element's entries will be overwritten with the entries of \b source. * \note \a source and \a dest may point to the same element. */ - void element_copy (const t8_element_t *source, t8_element_t *dest) const; + void + element_copy (const t8_element_t *source, t8_element_t *dest) const; /** Compare two elements. * \param [in] elem1 The first element. @@ -103,7 +115,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \return negative if elem1 < elem2, zero if elem1 equals elem2 and positive if elem1 > elem2. * If elem2 is a copy of elem1 then the elements are equal. */ - int element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Check if two elements are equal. * \param [in] ts Implementation of a class scheme. @@ -111,7 +124,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in] elem2 The second element. * \return 1 if the elements are equal, 0 if they are not equal */ - int element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; + int + element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const; /** Compute the parent of a given element \b elem and store it in \b parent. * \b parent needs to be an existing element. No memory is allocated by this function. @@ -122,7 +136,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * this element must exist and match the element class of the parent. For a pyramid, for * example, it may be either a tetrahedron or a pyramid depending on \b elem's childid. */ - void element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; + void + element_get_parent (const t8_element_t *elem, t8_element_t *parent) const; /** Compute a specific sibling of a given tri element \b elem and store it in \b sibling. * \b sibling needs to be an existing element. No memory is allocated by this function. @@ -133,32 +148,37 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in,out] sibling This element's entries will be overwritten by those of \b elem's sibid-th sibling. * The storage for this element must existand match the element class of the sibling. */ - void element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; + void + element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const; /** Compute the number of faces of a given element. * \param [in] elem The element. * \return The number of faces of \a elem. */ - int element_get_num_faces (const t8_element_t *elem) const; + int + element_get_num_faces (const t8_element_t *elem) const; /** Compute the maximum number of faces of a given element and all of its descendants. * \param [in] elem The element. * \return The maximum number of faces of \a elem and its descendants. */ - int element_get_max_num_faces (const t8_element_t *elem) const; + int + element_get_max_num_faces (const t8_element_t *elem) const; /** Return the number of children of an element when it is refined. * \param [in] elem The element whose number of children is returned. * \return The number of children of \a elem if it is to be refined. */ - int element_get_num_children (const t8_element_t *elem) const; + int + element_get_num_children (const t8_element_t *elem) const; /** Return the number of children of an element's face when the element is refined. * \param [in] elem The element whose face is considered. * \param [in] face A face of \a elem. * \return The number of children of \a face if \a elem is to be refined. */ - int element_get_num_face_children (const t8_element_t *elem, int face) const; + int + element_get_num_face_children (const t8_element_t *elem, int face) const; /** Return the corner number of an element's face corner. * \param [in] element The element. @@ -166,7 +186,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in] corner A corner index for the face 0 <= \a corner < num_face_corners. * \return The corner number of the \a corner-th vertex of \a face. */ - int element_get_face_corner (const t8_element_t *element, int face, int corner) const; + int + element_get_face_corner (const t8_element_t *element, int face, int corner) const; /** Return the face numbers of the faces sharing an element's corner. * \param [in] element The element. @@ -174,7 +195,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in] face A face index for \a corner. * \return The face number of the \a face-th face at \a corner. */ - int element_get_corner_face (const t8_element_t *element, int corner, int face) const; + int + element_get_corner_face (const t8_element_t *element, int corner, int face) const; /** Construct the child element of a given number. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -183,7 +205,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * On output, a valid element. * It is valid to call this function with elem = child. */ - void element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; + void + element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const; /** Construct all children of a given element. * \param [in] elem This must be a valid element, bigger than maxlevel. @@ -193,27 +216,31 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * It is valid to call this function with elem = c[0]. * \see element_get_num_children */ - void element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; + void + element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const; /** Compute the child id of an element. * \param [in] elem This must be a valid element. * \return The child id of elem. */ - int element_get_child_id (const t8_element_t *elem) const; + int + element_get_child_id (const t8_element_t *elem) const; /** Compute the ancestor id of an element, that is the child id at a given level. * \param [in] elem This must be a valid element. * \param [in] level A refinement level. Must satisfy \a level < elem.level * \return The child_id of \a elem in regard to its \a level ancestor. */ - int element_get_ancestor_id (const t8_element_t *elem, int level) const; + int + element_get_ancestor_id (const t8_element_t *elem, int level) const; /** Query whether a given set of elements is a family or not. * \param [in] fam An array of as many elements as an element of class \b ts has siblings. * \return Zero if \b fam is not a family, nonzero if it is. * \note level 0 elements do not form a family. */ - int elements_are_family (t8_element_t *const *fam) const; + int + elements_are_family (t8_element_t *const *fam) const; /** Compute the nearest common ancestor of two elements. That is, the element with highest level that still has both * given elements as descendants. @@ -222,14 +249,16 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in,out] nca The storage for this element must exist and match the element class of the child. On output * the unique nearest common ancestor of \b elem1 and \b elem2. */ - void element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; + void + element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const; /** Compute the shape of the face of an element. * \param [in] elem The element. * \param [in] face A face of \a elem. * \return The element shape of the face. */ - t8_element_shape_t element_get_face_shape (const t8_element_t *elem, int face) const; + t8_element_shape_t + element_get_face_shape (const t8_element_t *elem, int face) const; /** Given an element and a face of the element, compute all children of the element that touch the face. * \param [in] elem The element. @@ -242,8 +271,9 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * on output its i-th entry is the child_id of the i-th face_child. * It is valid to call this function with elem = children[0]. */ - void element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, - int *child_indices) const; + void + element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children, + int *child_indices) const; /** Given a face of an element and a child number of a child of that face, return the face number * of the child of the element that matches the child face. @@ -263,7 +293,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * order of children from a call to \ref element_get_children_at_face. * \return The face number of the face of a child of \a elem that coincides with \a face_child. */ - int element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const; + int + element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const; /** Given a face of an element return the face number of the parent of the element that matches the element's face. * Or return -1 if no face of the parent matches the face. @@ -272,7 +303,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \return If \a face of \a elem is also a face of \a elem's parent, the face number of this face. Otherwise -1. * \note For the root element this function always returns \a face. */ - int element_face_get_parent_face (const t8_element_t *elem, int face) const; + int + element_face_get_parent_face (const t8_element_t *elem, int face) const; /** Given an element and a face of this element. If the face lies on the tree boundary, return the face number of * the tree face. If not the return value is arbitrary. @@ -281,7 +313,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \return The index of the tree face that \a face is a subface of, if \a face is on a tree boundary. Any arbitrary * integer if \a is not at a tree boundary. */ - int element_get_tree_face (const t8_element_t *elem, int face) const; + int + element_get_tree_face (const t8_element_t *elem, int face) const; /** Suppose we have two trees that share a common face f. Given an element e that is a subface of f in one of the * trees and given the orientation of the tree connection, construct the face element of the respective tree @@ -297,20 +330,27 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * f, * descendant of \a elem that shares a face with \a face. * \param [in] level The level, at which the first descendant is constructed */ - void element_construct_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) - const; + void + element_construct_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, + int level) const; /** Construct the last descendant of an element at a given level that touches a given face. * \param [in] elem The input element. @@ -329,24 +370,29 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * descendant of \a elem that shares a face with \a face. * \param [in] level The level, at which the last descendant is constructed */ - void element_construct_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) - const; + void + element_construct_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const; + /** Construct the boundary element at a specific face. * \param [in] elem The input element. - * \param [in] face The index of the face of which to construct the boundary element. - * \param [in,out] boundary An allocated element of dimension of \a element minus 1. The entries will be filled with - * the entries of the face of \a element. - * \param [in] boundary_scheme The scheme for the eclass of the boundary face. + * \param [in] face The index of the face of which to construct the + * boundary element. + * \param [in,out] boundary An allocated element of dimension of \a element + * minus 1. The entries will be filled with the entries + * of the face of \a element. + * \param [in] scheme The scheme containing an eclass scheme for the boundary face. */ - void element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme_c *boundary_scheme) const; + void + element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *scheme) const; /** Compute whether a given element shares a given face with its root tree. * \param [in] elem The input element. * \param [in] face A face of \a elem. * \return True if \a face is a subface of the element's root element. */ - int element_is_root_boundary (const t8_element_t *elem, int face) const; + int + element_is_root_boundary (const t8_element_t *elem, int face) const; /** Construct the face neighbor of a given element if this face neighbor is inside the root tree. Return 0 otherwise. * \param [in] elem The element to be considered. @@ -358,8 +404,9 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \return True if \a neigh is inside the root tree. False if not. In this case \a neigh's data can be * arbitrary on output. */ - int element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) - const; + int + element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const; /** Initialize the entries of an allocated element according to a given linear id in a uniform refinement. * \param [in,out] elem The element whose entries will be set. @@ -367,35 +414,40 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in] id The linear id. * id must fulfil 0 <= id < 'number of leaves in the uniform refinement' */ - void element_set_linear_id (t8_element_t * elem, int level, t8_linearidx_t id) const; + void + element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const; /** Compute the linear id of a given element in a hypothetical uniform refinement of a given level. * \param [in] elem The element whose id we compute. * \param [in] level The level of the uniform refinement to consider. * \return The linear id of the element. */ - t8_linearidx_t element_get_linear_id (const t8_element_t *elem, int level) const; + t8_linearidx_t + element_get_linear_id (const t8_element_t *elem, int level) const; /** Compute the first descendant of a given element. * \param [in] elem The element whose descendant is computed. * \param [out] desc The first element in a uniform refinement of \a elem of the given level. * \param [in] level The level, at which the descendant is computed. */ - void element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Compute the last descendant of a given element. * \param [in] elem The element whose descendant is computed. * \param [out] desc The last element in a uniform refinement of \a elem of the given level. * \param [in] level The level, at which the descendant is computed. */ - void element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; + void + element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const; /** Construct the successor in a uniform refinement of a given element. * \param [in] elem1 The element whose successor should be constructed. * \param [in,out] elem2 The element whose entries will be set. * \param [in] level The level of the uniform refinement to consider. */ - void element_construct_successor (const t8_element_t *elem, t8_element_t *succ) const; + void + element_construct_successor (const t8_element_t *elem, t8_element_t *succ) const; /** Get the integer coordinates of the anchor node of an element. The default scheme implements the Morton type SFCs. * In these SFCs the elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and L the maximum @@ -404,7 +456,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in] elem The element. * \param [out] anchor The integer coordinates of the anchor node in the cube [0,1]^(dL) */ - void element_get_anchor (const t8_element_t *elem, int anchor[3]) const; + void + element_get_anchor (const t8_element_t *elem, int anchor[3]) const; /** Compute the integer coordinates of a given element vertex. The default scheme implements the Morton type SFCs. * In these SFCs the elements are positioned in a cube [0,1]^(dL) with dimension d (=0,1,2,3) and L the maximum @@ -414,7 +467,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [out] coords An array of at least as many integers as the element's dimension whose entries will be * filled with the coordinates of \a vertex. */ - void element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; + void + element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const; /** Compute the coordinates of a given element vertex inside a reference tree * that is embedded into [0,1]^d (d = dimension). @@ -425,7 +479,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \warning coords should be zero-initialized, as only the first d coords will be set, but when used elsewhere * all coords might be used. */ - void element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; + void + element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const; /** Convert points in the reference space of an element to points in the * reference space of the tree. @@ -437,14 +492,16 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [out] out_coords The coordinates of the points in the * reference space of the tree. */ - void element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, - double *out_coords) const; + void + element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords, + double *out_coords) const; /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. * Returns false otherwise. * * \return 0, because tris refine regularly */ - int refines_irregular (void) const; + int + refines_irregular (void) const; #ifdef T8_ENABLE_DEBUG /** Query whether a given element can be considered as 'valid' and it is @@ -461,7 +518,8 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \note We recommend to use the assertion T8_ASSERT (element_is_valid (elem)) * in the implementation of each of the functions in this file. */ - int element_is_valid (const t8_element_t *t) const; + int + element_is_valid (const t8_element_t *t) const; /** * Print a given element. For a example for a triangle print the coordinates @@ -470,13 +528,15 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * * \param [in] elem The element to print */ - void element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; + void + element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const; #endif /** Fills an element with the root element. * \param [in,out] elem The element to be filled with root. */ - void get_root (t8_element_t * elem) const; + void + get_root (t8_element_t *elem) const; /** Pack multiple elements into contiguous memory, so they can be sent via MPI. * \param [in] elements Array of elements that are to be packed @@ -486,15 +546,17 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in, out] position the position of the first byte that is not already packed * \param [in] comm MPI Communicator */ - void element_MPI_Pack (t8_element_t * *const elements, const unsigned int count, void *send_buffer, int buffer_size, - int *position, sc_MPI_Comm comm) const; + void + element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, + int *position, sc_MPI_Comm comm) const; /** Determine an upper bound for the size of the packed message of \b count elements * \param [in] count Number of elements to pack * \param [in] comm MPI Communicator * \param [out] pack_size upper bound on the message size */ - void element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; + void + element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const; /** Unpack multiple elements from contiguous memory that was received via MPI. * \param [in] recvbuf Buffer from which to unpack the elements @@ -504,6 +566,7 @@ class t8_default_scheme_tri_c::public t8_eclass_scheme, * \param [in] count Number of elements to unpack * \param [in] comm MPI Communicator */ - void element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, - const unsigned int count, sc_MPI_Comm comm) const; + void + element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const unsigned int count, sc_MPI_Comm comm) const; }; diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.cxx index 57a16d88b3..099638e10f 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.cxx @@ -27,6 +27,12 @@ /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); +size_t +t8_default_scheme_vertex_c::get_element_size (void) const +{ + return sizeof (t8_dvertex_t); +} + int t8_default_scheme_vertex_c::get_maxlevel (void) const { diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx index 64b95deb9e..d1c026a993 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx @@ -35,12 +35,19 @@ class t8_default_scheme_vertex_c: public t8_eclass_scheme, - public t8_default_scheme_common_c { + public t8_default_scheme_common_c { public: /** Constructor. */ t8_default_scheme_vertex_c (); ~t8_default_scheme_vertex_c (); + + /** Return the size of a vertex element. + * \return The size of an element of class vertex. + */ + size_t + get_element_size (void) const; + /** Allocate memory for an array of vertices and initialize them. * \param [in] length The number of vertex elements to be allocated. * \param [in,out] elems On input an array of \b length many unallocated @@ -392,18 +399,19 @@ class t8_default_scheme_vertex_c: * the element inside the root tree that has the given face as a * face. * \param [in] face A face element. - * \param [in] face_scheme The scheme for the face element. + * \param [in] face_eclass The eclass for the face element. * \param [in,out] elem An allocated element. The entries will be filled with * the data of the element that has \a face as a face and * lies within the root tree. * \param [in] root_face The index of the face of the root tree in which \a face * lies. + * \param [in] scheme The scheme collection with a scheme for the eclass of the face. * \return The face number of the face of \a elem that coincides * with \a face. */ int - element_extrude_face (const t8_element_t *face, const t8_scheme_c *face_scheme, t8_element_t *elem, - int root_face) const + element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, t8_element_t *elem, int root_face, + const t8_scheme *scheme) const { SC_ABORT ("Not implemented.\n"); return 0; /* prevents compiler warning */ @@ -447,11 +455,11 @@ class t8_default_scheme_vertex_c: * \param [in,out] boundary An allocated element of dimension of \a element * minus 1. The entries will be filled with the entries * of the face of \a element. - * \param [in] boundary_scheme The scheme for the eclass of the boundary face. + * \param [in] scheme The scheme containing an eclass scheme for the boundary face. */ void element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme_c *boundary_scheme) const + const t8_scheme *scheme) const { SC_ABORT ("Not implemented.\n"); return; /* prevents compiler warning */ diff --git a/src/t8_schemes/t8_scheme.hxx b/src/t8_schemes/t8_scheme.hxx index 8400db5e5a..15b0acc6ba 100644 --- a/src/t8_schemes/t8_scheme.hxx +++ b/src/t8_schemes/t8_scheme.hxx @@ -38,20 +38,20 @@ class t8_scheme { /* clang-format off */ using scheme_var = std::variant< /* Default schemes */ - t8_default_vertex, - t8_default_line, - t8_default_quad, - t8_default_tri, - t8_default_hex, - t8_default_tet, - t8_default_prism, - t8_default_pyramid + t8_default_scheme_vertex_c, + t8_default_scheme_line_c, + t8_default_scheme_quad_c, + t8_default_scheme_tri_c, + t8_default_scheme_hex_c, + t8_default_scheme_tet_c, + t8_default_scheme_prism_c, + t8_default_scheme_pyramid_c >; /* clang-format on */ using scheme_container = std::array; private: - Scheme_container eclass_schemes; + scheme_container eclass_schemes; public: /** Return the size of any element of a given class. @@ -63,7 +63,7 @@ class t8_scheme { inline size_t get_element_size (t8_eclass_t tree_class) const { - return std::visit ([&] (auto &&scheme) { return scheme.get_element_size (elem); }, eclass_schemes[tree_class]); + return std::visit ([&] (auto &&scheme) { return scheme.get_element_size (); }, eclass_schemes[tree_class]); }; /** Returns true, if there is one element in the tree, that does not refine into 2^dim children. From f9526e33eade5dccfdb474b4d7f2a4c8d8b4d0db Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Fri, 8 Nov 2024 10:28:04 +0100 Subject: [PATCH 10/11] capturing progress --- example/version/t8_version.cxx | 2 +- src/t8_cmesh/t8_cmesh_readmshfile.cxx | 2 +- src/t8_element.hxx | 6 +- .../t8_geometry_examples.cxx | 2 +- src/t8_schemes/t8_default/t8_default.cxx | 32 ++-- .../t8_default_common/t8_default_common.hxx | 11 +- .../t8_default_hex/t8_default_hex.cxx | 137 +++++++--------- .../t8_default_hex/t8_default_hex.hxx | 9 +- .../t8_default_line/t8_default_line.cxx | 138 +++++++--------- .../t8_default_line/t8_default_line.hxx | 9 +- .../t8_default_prism/t8_default_prism.cxx | 138 +++++++--------- .../t8_default_prism/t8_default_prism.hxx | 10 +- .../t8_default_pyramid/t8_default_pyramid.cxx | 148 ++++++++---------- .../t8_default_pyramid/t8_default_pyramid.hxx | 10 +- .../t8_default_quad/t8_default_quad.cxx | 145 ++++++++--------- .../t8_default_quad/t8_default_quad.hxx | 8 +- .../t8_default_tet/t8_default_tet.cxx | 138 +++++++--------- .../t8_default_tet/t8_default_tet.hxx | 9 +- .../t8_default_tet/t8_dtet_connectivity.h | 2 +- .../t8_default_tri/t8_default_tri.cxx | 144 ++++++++--------- .../t8_default_tri/t8_default_tri.hxx | 9 +- .../t8_default_vertex/t8_default_vertex.cxx | 112 ++++++------- .../t8_default_vertex/t8_default_vertex.hxx | 10 +- src/t8_schemes/t8_scheme.hxx | 63 ++++++-- src/t8_schemes/t8_scheme_builder.hxx | 14 +- test/t8_schemes/t8_gtest_default.cxx | 16 +- 26 files changed, 610 insertions(+), 714 deletions(-) diff --git a/example/version/t8_version.cxx b/example/version/t8_version.cxx index 655315be42..ff85cbf15f 100644 --- a/example/version/t8_version.cxx +++ b/example/version/t8_version.cxx @@ -66,7 +66,7 @@ main (int argc, char **argv) opt = sc_options_new (argv[0]); sc_options_add_switch (opt, 'h', "help", &helpme, "Display a short help message."); sc_options_add_switch (opt, 'v', "verbose", &verbose, - "Print more information. In particual major, minor and patch version."); + "Print more information. In particular major, minor and patch version."); int parsed = sc_options_parse (t8_get_package_id (), SC_LP_ERROR, opt, argc, argv); diff --git a/src/t8_cmesh/t8_cmesh_readmshfile.cxx b/src/t8_cmesh/t8_cmesh_readmshfile.cxx index 18479c58d5..e6182e94e9 100644 --- a/src/t8_cmesh/t8_cmesh_readmshfile.cxx +++ b/src/t8_cmesh/t8_cmesh_readmshfile.cxx @@ -1522,7 +1522,7 @@ t8_cmesh_msh_file_4_read_eles (t8_cmesh_t cmesh, FILE *fp, sc_hash_t *vertices, typedef struct { t8_locidx_t ltree_id; /* The local id of the tree this face belongs to */ - int8_t face_number; /* The number of that face whitin the tree */ + int8_t face_number; /* The number of that face within the tree */ int num_vertices; /* The number of vertices of this face. */ long *vertices; /* The indices of these vertices. */ } t8_msh_file_face_t; diff --git a/src/t8_element.hxx b/src/t8_element.hxx index b8a23876b3..db3d1c1d7d 100644 --- a/src/t8_element.hxx +++ b/src/t8_element.hxx @@ -42,8 +42,8 @@ class t8_eclass_scheme: public t8_crtp { * \param [in] tree_class The tree class of this element scheme. * \param [in] elem_size The size of the elements this scheme holds. */ - t8_eclass_scheme (const t8_eclass_t tree_class, const size_t elem_size) - : element_size (elem_size), eclass (tree_class) {}; + t8_eclass_scheme (const t8_eclass_t tree_class, const size_t elem_size, void *ts_context) + : element_size (elem_size), eclass (tree_class), ts_context (ts_context) {}; friend TUnderlyingEclassScheme; protected: @@ -55,7 +55,7 @@ class t8_eclass_scheme: public t8_crtp { /** The destructor. It does nothing but has to be defined since * we may want to delete an eclass_scheme that is actually inherited - * (for example t8_default_scheme_quad_c) and providing an implementation + * (for example t8_default_scheme_quad) and providing an implementation * for the destructor ensures that the * destructor of the child class will be executed. */ ~t8_scheme () diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx index 04fcadf40f..2dca1e705a 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_examples.cxx @@ -97,7 +97,7 @@ t8_geom_evaluate_sphere_tri_prism (const double *active_tree_vertices, const t8_ { // All elements are aligned such that the reference z-direction follows the // outward radial direction of the sphere. Hence the inner radius is equal to - // the norm of the first positition vector of `active_tree_vertices`. + // the norm of the first position vector of `active_tree_vertices`. const double inner_radius = t8_vec_norm (active_tree_vertices); t8_geom_compute_linear_geometry (eclass, active_tree_vertices, ref_coords, num_coords, out_coords); diff --git a/src/t8_schemes/t8_default/t8_default.cxx b/src/t8_schemes/t8_default/t8_default.cxx index b11d6803a4..6371009961 100644 --- a/src/t8_schemes/t8_default/t8_default.cxx +++ b/src/t8_schemes/t8_default/t8_default.cxx @@ -35,14 +35,14 @@ t8_scheme_new_default_cxx (void) s = T8_ALLOC_ZERO (t8_scheme, 1); t8_refcount_init (&s->rc); - s->eclass_schemes[T8_ECLASS_VERTEX] = new t8_default_scheme_vertex_c (); - s->eclass_schemes[T8_ECLASS_LINE] = new t8_default_scheme_line_c (); - s->eclass_schemes[T8_ECLASS_QUAD] = new t8_default_scheme_quad_c (); - s->eclass_schemes[T8_ECLASS_HEX] = new t8_default_scheme_hex_c (); - s->eclass_schemes[T8_ECLASS_TRIANGLE] = new t8_default_scheme_tri_c (); - s->eclass_schemes[T8_ECLASS_TET] = new t8_default_scheme_tet_c (); - s->eclass_schemes[T8_ECLASS_PRISM] = new t8_default_scheme_prism_c (); - s->eclass_schemes[T8_ECLASS_PYRAMID] = new t8_default_scheme_pyramid_c (); + s->eclass_schemes[T8_ECLASS_VERTEX] = new t8_default_scheme_vertex (); + s->eclass_schemes[T8_ECLASS_LINE] = new t8_default_scheme_line (); + s->eclass_schemes[T8_ECLASS_QUAD] = new t8_default_scheme_quad (); + s->eclass_schemes[T8_ECLASS_HEX] = new t8_default_scheme_hex (); + s->eclass_schemes[T8_ECLASS_TRIANGLE] = new t8_default_scheme_tri (); + s->eclass_schemes[T8_ECLASS_TET] = new t8_default_scheme_tet (); + s->eclass_schemes[T8_ECLASS_PRISM] = new t8_default_scheme_prism (); + s->eclass_schemes[T8_ECLASS_PYRAMID] = new t8_default_scheme_pyramid (); T8_ASSERT (s->eclass_schemes[T8_ECLASS_VERTEX]->t8_element_maxlevel () >= s->eclass_schemes[T8_ECLASS_LINE]->t8_element_maxlevel ()); @@ -71,21 +71,21 @@ t8_eclass_scheme_is_default (t8_scheme *ts) { switch (ts->eclass) { case T8_ECLASS_VERTEX: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_vertex_c *); + return T8_COMMON_IS_TYPE (ts, t8_default_scheme_vertex *); case T8_ECLASS_LINE: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_line_c *); + return T8_COMMON_IS_TYPE (ts, t8_default_scheme_line *); case T8_ECLASS_QUAD: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_quad_c *); + return T8_COMMON_IS_TYPE (ts, t8_default_scheme_quad *); case T8_ECLASS_TRIANGLE: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_tri_c *); + return T8_COMMON_IS_TYPE (ts, t8_default_scheme_tri *); case T8_ECLASS_HEX: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_hex_c *); + return T8_COMMON_IS_TYPE (ts, t8_default_scheme_hex *); case T8_ECLASS_TET: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_tet_c *); + return T8_COMMON_IS_TYPE (ts, t8_default_scheme_tet *); case T8_ECLASS_PRISM: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_prism_c *); + return T8_COMMON_IS_TYPE (ts, t8_default_scheme_prism *); case T8_ECLASS_PYRAMID: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_pyramid_c *); + return T8_COMMON_IS_TYPE (ts, t8_default_scheme_pyramid *); default: SC_ABORT_NOT_REACHED (); } diff --git a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx index a52f767d2a..17c58a2183 100644 --- a/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx +++ b/src/t8_schemes/t8_default/t8_default_common/t8_default_common.hxx @@ -85,10 +85,17 @@ count_leaves_from_level (int element_level, int refinement_level, int dimension) } template -class t8_default_scheme_common_c: t8_eclass_scheme { +class t8_default_scheme_common: private t8_eclass_scheme { + private: + t8_default_scheme_common (const t8_eclass_t tree_class, const size_t elem_size) + : t8_eclass_scheme (tree_class, elem_size, sc_mempool_new (elem_size);) + { + } + friend TUnderlyingEclassScheme; + public: /** Destructor for all default schemes */ - ~t8_default_scheme_common_c () + ~t8_default_scheme_common () { T8_ASSERT (ts_context != NULL); SC_ASSERT (((sc_mempool_t *) ts_context)->elem_count == 0); diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx index aa915178d8..41ea2300f9 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.cxx @@ -35,26 +35,26 @@ T8_EXTERN_C_BEGIN (); size_t -t8_default_scheme_hex_c::get_element_size (void) const +t8_default_scheme_hex::get_element_size (void) const { return sizeof (t8_phex_t); } int -t8_default_scheme_hex_c::get_maxlevel (void) const +t8_default_scheme_hex::get_maxlevel (void) const { return HEX_REFINE_MAXLEVEL; } int -t8_default_scheme_hex_c::element_get_level (const t8_element_t *elem) const +t8_default_scheme_hex::element_get_level (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return (int) ((const p8est_quadrant_t *) elem)->level; } void -t8_default_scheme_hex_c::element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_hex::element_copy (const t8_element_t *source, t8_element_t *dest) const { T8_ASSERT (element_is_valid (source)); T8_ASSERT (element_is_valid (dest)); @@ -62,7 +62,7 @@ t8_default_scheme_hex_c::element_copy (const t8_element_t *source, t8_element_t } int -t8_default_scheme_hex_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_hex::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -71,13 +71,13 @@ t8_default_scheme_hex_c::element_compare (const t8_element_t *elem1, const t8_el } int -t8_default_scheme_hex_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_hex::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return p8est_quadrant_is_equal ((const p8est_quadrant_t *) elem1, (const p8est_quadrant_t *) elem2); } void -t8_default_scheme_hex_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_hex::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (parent)); @@ -85,7 +85,7 @@ t8_default_scheme_hex_c::element_get_parent (const t8_element_t *elem, t8_elemen } void -t8_default_scheme_hex_c::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const +t8_default_scheme_hex::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (sibling)); @@ -93,34 +93,34 @@ t8_default_scheme_hex_c::element_get_sibling (const t8_element_t *elem, int sibi } int -t8_default_scheme_hex_c::element_get_num_faces (const t8_element_t *elem) const +t8_default_scheme_hex::element_get_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return P8EST_FACES; } int -t8_default_scheme_hex_c::element_get_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_hex::element_get_max_num_faces (const t8_element_t *elem) const { return P8EST_FACES; } int -t8_default_scheme_hex_c::element_get_num_children (const t8_element_t *elem) const +t8_default_scheme_hex::element_get_num_children (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return P8EST_CHILDREN; } int -t8_default_scheme_hex_c::element_get_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_hex::element_get_num_face_children (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return 4; } int -t8_default_scheme_hex_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_hex::element_get_face_corner (const t8_element_t *element, int face, int corner) const { T8_ASSERT (element_is_valid (element)); T8_ASSERT (0 <= face && face < P8EST_FACES); @@ -130,7 +130,7 @@ t8_default_scheme_hex_c::element_get_face_corner (const t8_element_t *element, i } void -t8_default_scheme_hex_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_hex::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; const p4est_qcoord_t shift = P8EST_QUADRANT_LEN (q->level + 1); @@ -152,7 +152,7 @@ t8_default_scheme_hex_c::element_get_child (const t8_element_t *elem, int childi } void -t8_default_scheme_hex_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_hex::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { T8_ASSERT (element_is_valid (elem)); #ifdef T8_ENABLE_DEBUG @@ -169,20 +169,20 @@ t8_default_scheme_hex_c::element_get_children (const t8_element_t *elem, int len } int -t8_default_scheme_hex_c::element_get_child_id (const t8_element_t *elem) const +t8_default_scheme_hex::element_get_child_id (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return p8est_quadrant_child_id ((const p8est_quadrant_t *) elem); } int -t8_default_scheme_hex_c::element_get_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_hex::element_get_ancestor_id (const t8_element_t *elem, int level) const { return p8est_quadrant_ancestor_id ((p8est_quadrant_t *) elem, level); } int -t8_default_scheme_hex_c::elements_are_family (t8_element_t *const *fam) const +t8_default_scheme_hex::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG { @@ -196,7 +196,7 @@ t8_default_scheme_hex_c::elements_are_family (t8_element_t *const *fam) const } void -t8_default_scheme_hex_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const +t8_default_scheme_hex::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -205,15 +205,15 @@ t8_default_scheme_hex_c::element_get_nca (const t8_element_t *elem1, const t8_el } t8_element_shape_t -t8_default_scheme_hex_c::element_get_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_hex::element_get_face_shape (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return T8_ECLASS_QUAD; } void -t8_default_scheme_hex_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_hex::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { int child_ids_local[4], i, *child_ids; @@ -263,7 +263,7 @@ t8_default_scheme_hex_c::element_get_children_at_face (const t8_element_t *elem, } int -t8_default_scheme_hex_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_hex::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { T8_ASSERT (element_is_valid (elem)); /* For octants the face enumeration of children is the same as for the parent. */ @@ -271,7 +271,7 @@ t8_default_scheme_hex_c::element_face_get_child_face (const t8_element_t *elem, } int -t8_default_scheme_hex_c::element_face_get_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_hex::element_face_get_parent_face (const t8_element_t *elem, int face) const { int child_id; const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; @@ -291,7 +291,7 @@ t8_default_scheme_hex_c::element_face_get_parent_face (const t8_element_t *elem, } int -t8_default_scheme_hex_c::element_get_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_hex::element_get_tree_face (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < P8EST_FACES); @@ -300,8 +300,8 @@ t8_default_scheme_hex_c::element_get_tree_face (const t8_element_t *elem, int fa } int -t8_default_scheme_hex_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, - t8_element_t *elem, int root_face, const t8_scheme *scheme) const +t8_default_scheme_hex::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { const p4est_quadrant_t *b = (const p4est_quadrant_t *) face; p8est_quadrant_t *q = (p8est_quadrant_t *) elem; @@ -364,8 +364,8 @@ t8_default_scheme_hex_c::element_extrude_face (const t8_element_t *face, const t /** Construct the first descendant of an element that touches a given face. */ void -t8_default_scheme_hex_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_hex::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p8est_quadrant_t *desc = (p8est_quadrant_t *) first_desc; @@ -382,8 +382,8 @@ t8_default_scheme_hex_c::element_construct_first_descendant_face (const t8_eleme /** Construct the last descendant of an element that touches a given face. */ void -t8_default_scheme_hex_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, - t8_element_t *last_desc, int level) const +t8_default_scheme_hex::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p8est_quadrant_t *desc = (p8est_quadrant_t *) last_desc; @@ -399,8 +399,8 @@ t8_default_scheme_hex_c::element_construct_last_descendant_face (const t8_elemen } void -t8_default_scheme_hex_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *scheme) const +t8_default_scheme_hex::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *scheme) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p4est_quadrant_t *b = (p4est_quadrant_t *) boundary; @@ -435,7 +435,7 @@ t8_default_scheme_hex_c::element_construct_boundary_face (const t8_element_t *el } int -t8_default_scheme_hex_c::element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_hex::element_is_root_boundary (const t8_element_t *elem, int face) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p4est_qcoord_t coord; @@ -454,8 +454,8 @@ t8_default_scheme_hex_c::element_is_root_boundary (const t8_element_t *elem, int } int -t8_default_scheme_hex_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, - int face, int *neigh_face) const +t8_default_scheme_hex::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const { const p8est_quadrant_t *q = (const p8est_quadrant_t *) elem; p8est_quadrant_t *n = (p8est_quadrant_t *) neigh; @@ -480,7 +480,7 @@ t8_default_scheme_hex_c::element_construct_face_neighbor_inside (const t8_elemen } void -t8_default_scheme_hex_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_hex::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= HEX_LINEAR_MAXLEVEL); @@ -490,7 +490,7 @@ t8_default_scheme_hex_c::element_set_linear_id (t8_element_t *elem, int level, t } t8_linearidx_t -t8_default_scheme_hex_c::element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_hex::element_get_linear_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= HEX_LINEAR_MAXLEVEL); @@ -499,8 +499,8 @@ t8_default_scheme_hex_c::element_get_linear_id (const t8_element_t *elem, int le } void -t8_default_scheme_hex_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_hex::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -509,8 +509,7 @@ t8_default_scheme_hex_c::element_construct_first_descendant (const t8_element_t } void -t8_default_scheme_hex_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_hex::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -519,7 +518,7 @@ t8_default_scheme_hex_c::element_construct_last_descendant (const t8_element_t * } void -t8_default_scheme_hex_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_hex::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -528,7 +527,7 @@ t8_default_scheme_hex_c::element_construct_successor (const t8_element_t *elem1, } void -t8_default_scheme_hex_c::element_get_anchor (const t8_element_t *elem, int coord[3]) const +t8_default_scheme_hex::element_get_anchor (const t8_element_t *elem, int coord[3]) const { p8est_quadrant_t *q; @@ -540,7 +539,7 @@ t8_default_scheme_hex_c::element_get_anchor (const t8_element_t *elem, int coord } void -t8_default_scheme_hex_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_hex::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) elem; @@ -555,8 +554,8 @@ t8_default_scheme_hex_c::element_get_vertex_integer_coords (const t8_element_t * } void -t8_default_scheme_hex_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_hex::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= vertex && vertex < 8); @@ -572,25 +571,25 @@ t8_default_scheme_hex_c::element_get_vertex_reference_coords (const t8_element_t } void -t8_default_scheme_hex_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_hex::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { T8_ASSERT (element_is_valid (elem)); t8_dhex_compute_reference_coords ((const t8_dhex_t *) elem, ref_coords, num_coords, out_coords); } int -t8_default_scheme_hex_c::refines_irregular () const +t8_default_scheme_hex::refines_irregular () const { /* Hex always refine regularly */ return 0; } void -t8_default_scheme_hex_c::element_new (int length, t8_element_t **elem) const +t8_default_scheme_hex::element_new (int length, t8_element_t **elem) const { /* allocate memory for a hex */ - t8_default_scheme_common_c::element_new (length, elem); + t8_default_scheme_common::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG @@ -605,7 +604,7 @@ t8_default_scheme_hex_c::element_new (int length, t8_element_t **elem) const } void -t8_default_scheme_hex_c::element_init (int length, t8_element_t *elem) const +t8_default_scheme_hex::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG p8est_quadrant_t *quads = (p8est_quadrant_t *) elem; @@ -619,7 +618,7 @@ t8_default_scheme_hex_c::element_init (int length, t8_element_t *elem) const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_hex_c::element_is_valid (const t8_element_t *elem) const +t8_default_scheme_hex::element_is_valid (const t8_element_t *elem) const { /* TODO: additional checks? do we set pad8 or similar? */ @@ -628,7 +627,7 @@ t8_default_scheme_hex_c::element_is_valid (const t8_element_t *elem) const } void -t8_default_scheme_hex_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const +t8_default_scheme_hex::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); @@ -637,24 +636,8 @@ t8_default_scheme_hex_c::element_to_string (const t8_element_t *elem, char *debu } #endif -/* Constructor */ -t8_default_scheme_hex_c::t8_default_scheme_hex_c (void) -{ - eclass = T8_ECLASS_HEX; - element_size = sizeof (t8_phex_t); - ts_context = sc_mempool_new (element_size); -} - -t8_default_scheme_hex_c::~t8_default_scheme_hex_c () -{ - /* This destructor is empty since the destructor of the - * default_common scheme is called automatically and it - * suffices to destroy the quad_scheme. - * However we need to provide an implementation of the destructor - * and hence this empty function. */ -} void -t8_default_scheme_hex_c::get_root (t8_element_t *elem) const +t8_default_scheme_hex::get_root (t8_element_t *elem) const { p8est_quadrant_t *hex = (p8est_quadrant_t *) elem; p8est_quadrant_set_morton (hex, 0, 0); @@ -663,8 +646,8 @@ t8_default_scheme_hex_c::get_root (t8_element_t *elem) const /* each hex is packed as x,y,z coordinates and the level */ void -t8_default_scheme_hex_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, - const int buffer_size, int *position, sc_MPI_Comm comm) const +t8_default_scheme_hex::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { int mpiret; p8est_quadrant_t **quads = (p8est_quadrant_t **) elements; @@ -682,7 +665,7 @@ t8_default_scheme_hex_c::element_MPI_Pack (t8_element_t **const elements, const /* each hex is packed as x,y,z coordinates and the level */ void -t8_default_scheme_hex_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_hex::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -703,8 +686,8 @@ t8_default_scheme_hex_c::element_MPI_Pack_size (const unsigned int count, sc_MPI /* each hex is packed as x,y,z coordinates and the level */ void -t8_default_scheme_hex_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const +t8_default_scheme_hex::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const unsigned int count, sc_MPI_Comm comm) const { int mpiret; p8est_quadrant_t **quads = (p8est_quadrant_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx index 6c7a9e0ed5..75e54cb9a0 100644 --- a/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx +++ b/src/t8_schemes/t8_default/t8_default_hex/t8_default_hex.hxx @@ -30,6 +30,7 @@ #include #include #include +#include /** The class holding a hexahedral element in the default scheme. * We make this definition public for interoperability of element classes. @@ -37,14 +38,12 @@ */ typedef p8est_quadrant_t t8_phex_t; -class t8_default_scheme_hex_c: - public t8_eclass_scheme, - public t8_default_scheme_common_c { +class t8_default_scheme_hex: private t8_default_scheme_common { public: /** Constructor. */ - t8_default_scheme_hex_c (); + t8_default_scheme_hex (): t8_default_scheme_common (T8_ECLASS_HEX, sizeof (t8_phex_t)) {}; - ~t8_default_scheme_hex_c (); + ~t8_default_scheme_hex () {}; /** Return the size of a hex element. * \return The size of an element of class hex. diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx index 1681cde65d..0a78491ac5 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.cxx @@ -32,26 +32,26 @@ typedef t8_dline_t t8_default_line_t; T8_EXTERN_C_BEGIN (); size_t -t8_default_scheme_line_c::get_element_size (void) const +t8_default_scheme_line::get_element_size (void) const { return sizeof (t8_dline_t); } int -t8_default_scheme_line_c::get_maxlevel (void) const +t8_default_scheme_line::get_maxlevel (void) const { return T8_DLINE_MAXLEVEL; } int -t8_default_scheme_line_c::element_get_level (const t8_element_t *elem) const +t8_default_scheme_line::element_get_level (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dline_get_level ((const t8_dline_t *) elem); } void -t8_default_scheme_line_c::element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_line::element_copy (const t8_element_t *source, t8_element_t *dest) const { T8_ASSERT (element_is_valid (source)); T8_ASSERT (element_is_valid (dest)); @@ -59,7 +59,7 @@ t8_default_scheme_line_c::element_copy (const t8_element_t *source, t8_element_t } int -t8_default_scheme_line_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_line::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -67,13 +67,13 @@ t8_default_scheme_line_c::element_compare (const t8_element_t *elem1, const t8_e } int -t8_default_scheme_line_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_line::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dline_equal ((const t8_dline_t *) elem1, (const t8_dline_t *) elem2); } void -t8_default_scheme_line_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_line::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { const t8_default_line_t *l = (const t8_default_line_t *) elem; t8_default_line_t *p = (t8_default_line_t *) parent; @@ -84,7 +84,7 @@ t8_default_scheme_line_c::element_get_parent (const t8_element_t *elem, t8_eleme } void -t8_default_scheme_line_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_line::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const t8_default_line_t *l = (const t8_default_line_t *) elem; t8_default_line_t *c = (t8_default_line_t *) child; @@ -95,8 +95,7 @@ t8_default_scheme_line_c::element_get_child (const t8_element_t *elem, int child } void -t8_default_scheme_line_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, - t8_element_t *nca) const +t8_default_scheme_line::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -105,15 +104,15 @@ t8_default_scheme_line_c::element_get_nca (const t8_element_t *elem1, const t8_e } t8_element_shape_t -t8_default_scheme_line_c::element_get_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_line::element_get_face_shape (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return T8_ECLASS_VERTEX; } void -t8_default_scheme_line_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_line::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); @@ -129,7 +128,7 @@ t8_default_scheme_line_c::element_get_children_at_face (const t8_element_t *elem } int -t8_default_scheme_line_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_line::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); @@ -140,7 +139,7 @@ t8_default_scheme_line_c::element_face_get_child_face (const t8_element_t *elem, } int -t8_default_scheme_line_c::element_face_get_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_line::element_face_get_parent_face (const t8_element_t *elem, int face) const { /* The number of faces does not change from parent to child */ T8_ASSERT (element_is_valid (elem)); @@ -149,7 +148,7 @@ t8_default_scheme_line_c::element_face_get_parent_face (const t8_element_t *elem } int -t8_default_scheme_line_c::element_get_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_line::element_get_tree_face (const t8_element_t *elem, int face) const { /* The number of faces does not change from tree to element */ T8_ASSERT (element_is_valid (elem)); @@ -158,8 +157,8 @@ t8_default_scheme_line_c::element_get_tree_face (const t8_element_t *elem, int f } void -t8_default_scheme_line_c::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, - int sign, int is_smaller_face) const +t8_default_scheme_line::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, + int sign, int is_smaller_face) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -174,8 +173,8 @@ t8_default_scheme_line_c::element_transform_face (const t8_element_t *elem1, t8_ * the element inside the root tree that has the given face as a * face. */ int -t8_default_scheme_line_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, - t8_element_t *elem, int root_face, const t8_scheme *scheme) const +t8_default_scheme_line::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (face_eclass == T8_ECLASS_VERTEX); @@ -186,8 +185,8 @@ t8_default_scheme_line_c::element_extrude_face (const t8_element_t *face, const /** Construct the boundary element at a specific face. */ void -t8_default_scheme_line_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *scheme) const +t8_default_scheme_line::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *scheme) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (scheme->element_is_valid (T8_ECLASS_VERTEX, boundary)); @@ -200,8 +199,8 @@ t8_default_scheme_line_c::element_construct_boundary_face (const t8_element_t *e /** Construct the first descendant of an element that touches a given face. */ void -t8_default_scheme_line_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_line::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (first_desc)); @@ -220,8 +219,8 @@ t8_default_scheme_line_c::element_construct_first_descendant_face (const t8_elem } void -t8_default_scheme_line_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, - t8_element_t *last_desc, int level) const +t8_default_scheme_line::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (last_desc)); @@ -233,7 +232,7 @@ t8_default_scheme_line_c::element_construct_last_descendant_face (const t8_eleme } int -t8_default_scheme_line_c::element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_line::element_is_root_boundary (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); @@ -242,8 +241,8 @@ t8_default_scheme_line_c::element_is_root_boundary (const t8_element_t *elem, in } int -t8_default_scheme_line_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, - int face, int *neigh_face) const +t8_default_scheme_line::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (neigh)); @@ -254,7 +253,7 @@ t8_default_scheme_line_c::element_construct_face_neighbor_inside (const t8_eleme } void -t8_default_scheme_line_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_line::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL); @@ -264,7 +263,7 @@ t8_default_scheme_line_c::element_set_linear_id (t8_element_t *elem, int level, } void -t8_default_scheme_line_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_line::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -274,8 +273,8 @@ t8_default_scheme_line_c::element_construct_successor (const t8_element_t *elem1 } void -t8_default_scheme_line_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_line::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -285,8 +284,8 @@ t8_default_scheme_line_c::element_construct_first_descendant (const t8_element_t } void -t8_default_scheme_line_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_line::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -295,23 +294,23 @@ t8_default_scheme_line_c::element_construct_last_descendant (const t8_element_t } void -t8_default_scheme_line_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_line::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dline_vertex_integer_coords ((const t8_dline_t *) elem, vertex, coords); } void -t8_default_scheme_line_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_line::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dline_vertex_ref_coords ((const t8_dline_t *) elem, vertex, coords); } void -t8_default_scheme_line_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_line::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (ref_coords != NULL); @@ -319,7 +318,7 @@ t8_default_scheme_line_c::element_get_reference_coords (const t8_element_t *elem } t8_linearidx_t -t8_default_scheme_line_c::element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_line::element_get_linear_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DLINE_MAXLEVEL); @@ -328,28 +327,28 @@ t8_default_scheme_line_c::element_get_linear_id (const t8_element_t *elem, int l } int -t8_default_scheme_line_c::element_get_num_faces (const t8_element_t *elem) const +t8_default_scheme_line::element_get_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DLINE_FACES; } int -t8_default_scheme_line_c::element_get_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_line::element_get_max_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DLINE_FACES; } int -t8_default_scheme_line_c::element_get_num_children (const t8_element_t *elem) const +t8_default_scheme_line::element_get_num_children (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DLINE_CHILDREN; } int -t8_default_scheme_line_c::element_get_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_line::element_get_num_face_children (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DLINE_FACES); @@ -358,14 +357,14 @@ t8_default_scheme_line_c::element_get_num_face_children (const t8_element_t *ele } int -t8_default_scheme_line_c::element_get_child_id (const t8_element_t *elem) const +t8_default_scheme_line::element_get_child_id (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dline_child_id ((const t8_dline_t *) elem); } void -t8_default_scheme_line_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_line::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (length == T8_DLINE_CHILDREN); @@ -374,14 +373,14 @@ t8_default_scheme_line_c::element_get_children (const t8_element_t *elem, int le } int -t8_default_scheme_line_c::element_get_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_line::element_get_ancestor_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); return t8_dline_ancestor_id ((const t8_dline_t *) elem, level); } int -t8_default_scheme_line_c::elements_are_family (t8_element_t *const *fam) const +t8_default_scheme_line::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG int i; @@ -393,7 +392,7 @@ t8_default_scheme_line_c::elements_are_family (t8_element_t *const *fam) const } int -t8_default_scheme_line_c::refines_irregular () const +t8_default_scheme_line::refines_irregular () const { /*lines always refine regularly */ return 0; @@ -401,13 +400,13 @@ t8_default_scheme_line_c::refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_line_c::element_is_valid (const t8_element_t *elem) const +t8_default_scheme_line::element_is_valid (const t8_element_t *elem) const { return t8_dline_is_valid ((const t8_dline_t *) elem); } void -t8_default_scheme_line_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const +t8_default_scheme_line::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); @@ -417,10 +416,10 @@ t8_default_scheme_line_c::element_to_string (const t8_element_t *elem, char *deb #endif void -t8_default_scheme_line_c::element_new (int length, t8_element_t **elem) const +t8_default_scheme_line::element_new (int length, t8_element_t **elem) const { /* allocate memory for a line */ - t8_default_scheme_common_c::element_new (length, elem); + t8_default_scheme_common::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG @@ -434,7 +433,7 @@ t8_default_scheme_line_c::element_new (int length, t8_element_t **elem) const } void -t8_default_scheme_line_c::element_init (int length, t8_element_t *elem) const +t8_default_scheme_line::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dline_t *lines = (t8_dline_t *) elem; @@ -444,27 +443,10 @@ t8_default_scheme_line_c::element_init (int length, t8_element_t *elem) const #endif } -/* Constructor */ -t8_default_scheme_line_c::t8_default_scheme_line_c (void) -{ - eclass = T8_ECLASS_LINE; - element_size = sizeof (t8_default_line_t); - ts_context = sc_mempool_new (element_size); -} - -t8_default_scheme_line_c::~t8_default_scheme_line_c () -{ - /* This destructor is empty since the destructor of the - * default_common scheme is called automatically and it - * suffices to destroy the quad_scheme. - * However we need to provide an implementation of the destructor - * and hence this empty function. */ -} - /* each line is packed as an x coordinate and the level */ void -t8_default_scheme_line_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, - const int buffer_size, int *position, sc_MPI_Comm comm) const +t8_default_scheme_line::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { t8_default_line_t **lines = (t8_default_line_t **) elements; int mpiret; @@ -478,7 +460,7 @@ t8_default_scheme_line_c::element_MPI_Pack (t8_element_t **const elements, const /* each line is packed as an x coordinate and the level */ void -t8_default_scheme_line_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_line::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -497,8 +479,8 @@ t8_default_scheme_line_c::element_MPI_Pack_size (const unsigned int count, sc_MP /* each line is packed as an x coordinate and the level */ void -t8_default_scheme_line_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const +t8_default_scheme_line::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const { int mpiret; t8_default_line_t **lines = (t8_default_line_t **) elements; @@ -511,7 +493,7 @@ t8_default_scheme_line_c::element_MPI_Unpack (void *recvbuf, const int buffer_si } void -t8_default_scheme_line_c::get_root (t8_element_t *elem) const +t8_default_scheme_line::get_root (t8_element_t *elem) const { t8_dline_t *line = (t8_dline_t *) elem; line->level = 0; diff --git a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx index dcbb33163b..cf472b8978 100644 --- a/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx +++ b/src/t8_schemes/t8_default/t8_default_line/t8_default_line.hxx @@ -31,19 +31,18 @@ #include #include #include +#include /** Provide an implementation for the line element class. * It is written as a self-contained library in the t8_dline_* files. */ -class t8_default_scheme_line_c: - public t8_eclass_scheme, - public t8_default_scheme_common_c { +class t8_default_scheme_line: private t8_default_scheme_common { public: /** Constructor. */ - t8_default_scheme_line_c (); + t8_default_scheme_line (): t8_default_scheme_common (T8_ECLASS_LINE, sizeof (t8_dline_t)) {}; - ~t8_default_scheme_line_c (); + ~t8_default_scheme_line () {}; /** Return the size of a line element. * \return The size of an element of class line. diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx index 6d03e2efe6..f776e740f5 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.cxx @@ -31,16 +31,16 @@ typedef t8_dprism_t t8_default_prism_t; T8_EXTERN_C_BEGIN (); size_t -t8_default_scheme_prism_c::get_element_size (void) const +t8_default_scheme_prism::get_element_size (void) const { return sizeof (t8_dprism_t); } void -t8_default_scheme_prism_c::element_new (int length, t8_element_t **elem) const +t8_default_scheme_prism::element_new (int length, t8_element_t **elem) const { /* allocate memory for a tet */ - t8_default_scheme_common_c::element_new (length, elem); + t8_default_scheme_common::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG @@ -54,7 +54,7 @@ t8_default_scheme_prism_c::element_new (int length, t8_element_t **elem) const } void -t8_default_scheme_prism_c::element_init (int length, t8_element_t *elem) const +t8_default_scheme_prism::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dprism_t *prism = (t8_dprism_t *) elem; @@ -67,20 +67,20 @@ t8_default_scheme_prism_c::element_init (int length, t8_element_t *elem) const } int -t8_default_scheme_prism_c::get_maxlevel (void) const +t8_default_scheme_prism::get_maxlevel (void) const { return T8_DPRISM_MAXLEVEL; } int -t8_default_scheme_prism_c::element_get_level (const t8_element_t *elem) const +t8_default_scheme_prism::element_get_level (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dprism_get_level ((const t8_dprism_t *) elem); } t8_element_shape_t -t8_default_scheme_prism_c::element_get_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_prism::element_get_face_shape (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); @@ -89,7 +89,7 @@ t8_default_scheme_prism_c::element_get_face_shape (const t8_element_t *elem, int } void -t8_default_scheme_prism_c::element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_prism::element_copy (const t8_element_t *source, t8_element_t *dest) const { T8_ASSERT (element_is_valid (source)); t8_dprism_copy ((const t8_dprism_t *) source, (t8_dprism_t *) dest); @@ -97,7 +97,7 @@ t8_default_scheme_prism_c::element_copy (const t8_element_t *source, t8_element_ } int -t8_default_scheme_prism_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_prism::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -105,13 +105,13 @@ t8_default_scheme_prism_c::element_compare (const t8_element_t *elem1, const t8_ } int -t8_default_scheme_prism_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_prism::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dprism_equal ((const t8_dprism_t *) elem1, (const t8_dprism_t *) elem2); } void -t8_default_scheme_prism_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_prism::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { T8_ASSERT (element_is_valid (elem)); t8_dprism_parent ((const t8_dprism_t *) elem, (t8_dprism_t *) parent); @@ -119,21 +119,21 @@ t8_default_scheme_prism_c::element_get_parent (const t8_element_t *elem, t8_elem } int -t8_default_scheme_prism_c::element_get_num_children (const t8_element_t *elem) const +t8_default_scheme_prism::element_get_num_children (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DPRISM_CHILDREN; } int -t8_default_scheme_prism_c::element_get_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_prism::element_get_num_face_children (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return t8_dprism_num_face_children ((const t8_dprism_t *) elem, face); } int -t8_default_scheme_prism_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_prism::element_get_face_corner (const t8_element_t *element, int face, int corner) const { T8_ASSERT (element_is_valid (element)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); @@ -143,21 +143,21 @@ t8_default_scheme_prism_c::element_get_face_corner (const t8_element_t *element, } int -t8_default_scheme_prism_c::element_get_num_faces (const t8_element_t *elem) const +t8_default_scheme_prism::element_get_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DPRISM_FACES; } int -t8_default_scheme_prism_c::element_get_child_id (const t8_element_t *elem) const +t8_default_scheme_prism::element_get_child_id (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dprism_child_id ((const t8_dprism_t *) elem); } void -t8_default_scheme_prism_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_prism::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { T8_ASSERT (element_is_valid (elem)); t8_dprism_child ((const t8_dprism_t *) elem, childid, (t8_dprism_t *) child); @@ -165,14 +165,14 @@ t8_default_scheme_prism_c::element_get_child (const t8_element_t *elem, int chil } int -t8_default_scheme_prism_c::element_get_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_prism::element_get_max_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DPRISM_FACES; } void -t8_default_scheme_prism_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_prism::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (length == T8_DPRISM_CHILDREN); @@ -185,15 +185,15 @@ t8_default_scheme_prism_c::element_get_children (const t8_element_t *elem, int l } int -t8_default_scheme_prism_c::element_get_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_prism::element_get_ancestor_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); return t8_dprism_ancestor_id ((t8_dprism_t *) elem, level); } void -t8_default_scheme_prism_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_prism::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); @@ -207,7 +207,7 @@ t8_default_scheme_prism_c::element_get_children_at_face (const t8_element_t *ele } int -t8_default_scheme_prism_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_prism::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); @@ -216,7 +216,7 @@ t8_default_scheme_prism_c::element_face_get_child_face (const t8_element_t *elem } int -t8_default_scheme_prism_c::element_face_get_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_prism::element_face_get_parent_face (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); @@ -224,7 +224,7 @@ t8_default_scheme_prism_c::element_face_get_parent_face (const t8_element_t *ele } int -t8_default_scheme_prism_c::element_get_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_prism::element_get_tree_face (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); @@ -232,8 +232,8 @@ t8_default_scheme_prism_c::element_get_tree_face (const t8_element_t *elem, int } int -t8_default_scheme_prism_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, - t8_element_t *elem, int root_face, const t8_scheme *scheme) const +t8_default_scheme_prism::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { T8_ASSERT (scheme->element_is_valid (face_eclass, face)); T8_ASSERT (0 <= root_face && root_face < T8_DPRISM_FACES); @@ -247,7 +247,7 @@ t8_default_scheme_prism_c::element_extrude_face (const t8_element_t *face, const } int -t8_default_scheme_prism_c::elements_are_family (t8_element_t *const *fam) const +t8_default_scheme_prism::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG int i; @@ -259,8 +259,7 @@ t8_default_scheme_prism_c::elements_are_family (t8_element_t *const *fam) const } void -t8_default_scheme_prism_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, - t8_element_t *nca) const +t8_default_scheme_prism::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -273,8 +272,8 @@ t8_default_scheme_prism_c::element_get_nca (const t8_element_t *elem1, const t8_ } void -t8_default_scheme_prism_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *scheme) const +t8_default_scheme_prism::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *scheme) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); @@ -292,8 +291,8 @@ const int t8_dprism_face_corner[5][4] = { }; void -t8_default_scheme_prism_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_prism::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); @@ -305,8 +304,8 @@ t8_default_scheme_prism_c::element_construct_first_descendant_face (const t8_ele } void -t8_default_scheme_prism_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, - t8_element_t *last_desc, int level) const +t8_default_scheme_prism::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DPRISM_FACES); @@ -323,15 +322,15 @@ t8_default_scheme_prism_c::element_construct_last_descendant_face (const t8_elem } int -t8_default_scheme_prism_c::element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_prism::element_is_root_boundary (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return t8_dprism_is_root_boundary ((const t8_dprism_t *) elem, face); } int -t8_default_scheme_prism_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, - int face, int *neigh_face) const +t8_default_scheme_prism::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, + int face, int *neigh_face) const { const t8_dprism_t *p = (const t8_dprism_t *) elem; t8_dprism_t *n = (t8_dprism_t *) neigh; @@ -347,7 +346,7 @@ t8_default_scheme_prism_c::element_construct_face_neighbor_inside (const t8_elem } void -t8_default_scheme_prism_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_prism::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL); T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << 3 * level); @@ -358,7 +357,7 @@ t8_default_scheme_prism_c::element_set_linear_id (t8_element_t *elem, int level, } void -t8_default_scheme_prism_c::element_construct_successor (const t8_element_t *elem, t8_element_t *s) const +t8_default_scheme_prism::element_construct_successor (const t8_element_t *elem, t8_element_t *s) const { T8_ASSERT (1 <= element_get_level (elem) && element_get_level (elem) <= T8_DPRISM_MAXLEVEL); T8_ASSERT (element_is_valid (elem)); @@ -368,8 +367,8 @@ t8_default_scheme_prism_c::element_construct_successor (const t8_element_t *elem } void -t8_default_scheme_prism_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_prism::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL); T8_ASSERT (element_is_valid (elem)); @@ -378,8 +377,8 @@ t8_default_scheme_prism_c::element_construct_first_descendant (const t8_element_ } void -t8_default_scheme_prism_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_prism::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (0 <= level && level <= T8_DPRISM_MAXLEVEL); T8_ASSERT (element_is_valid (elem)); @@ -388,7 +387,7 @@ t8_default_scheme_prism_c::element_construct_last_descendant (const t8_element_t } void -t8_default_scheme_prism_c::element_get_anchor (const t8_element_t *elem, int anchor[3]) const +t8_default_scheme_prism::element_get_anchor (const t8_element_t *elem, int anchor[3]) const { t8_dprism_t *prism = (t8_dprism_t *) elem; T8_ASSERT (element_is_valid (elem)); @@ -398,37 +397,37 @@ t8_default_scheme_prism_c::element_get_anchor (const t8_element_t *elem, int anc } void -t8_default_scheme_prism_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_prism::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dprism_vertex_integer_coords ((const t8_dprism_t *) elem, vertex, coords); } void -t8_default_scheme_prism_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_prism::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dprism_vertex_ref_coords ((const t8_dprism_t *) elem, vertex, coords); } void -t8_default_scheme_prism_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_prism::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { T8_ASSERT (element_is_valid (elem)); t8_dprism_compute_reference_coords ((const t8_dprism_t *) elem, ref_coords, num_coords, out_coords); } t8_linearidx_t -t8_default_scheme_prism_c::element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_prism::element_get_linear_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); return t8_dprism_linear_id ((const t8_dprism_t *) elem, level); } int -t8_default_scheme_prism_c::refines_irregular (void) const +t8_default_scheme_prism::refines_irregular (void) const { /*prisms refine regularly */ return 0; @@ -437,14 +436,14 @@ t8_default_scheme_prism_c::refines_irregular (void) const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_prism_c::element_is_valid (const t8_element_t *elem) const +t8_default_scheme_prism::element_is_valid (const t8_element_t *elem) const { T8_ASSERT (elem != NULL); return t8_dprism_is_valid ((const t8_dprism_t *) elem); } void -t8_default_scheme_prism_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const +t8_default_scheme_prism::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); @@ -455,24 +454,8 @@ t8_default_scheme_prism_c::element_to_string (const t8_element_t *elem, char *de #endif /* T8_ENABLE_DEBUG */ -/* Constructor */ -t8_default_scheme_prism_c::t8_default_scheme_prism_c (void) -{ - eclass = T8_ECLASS_PRISM; - element_size = sizeof (t8_default_prism_t); - ts_context = sc_mempool_new (element_size); -} - -t8_default_scheme_prism_c::~t8_default_scheme_prism_c () -{ - /* This destructor is empty since the destructor of the - * default_common scheme is called automatically and it - * suffices to destroy the quad_scheme. - * However we need to provide an implementation of the destructor - * and hence this empty function. */ -} void -t8_default_scheme_prism_c::get_root (t8_element_t *elem) const +t8_default_scheme_prism::get_root (t8_element_t *elem) const { t8_dprism_t *prism = (t8_dprism_t *) elem; prism->line.level = 0; @@ -484,8 +467,8 @@ t8_default_scheme_prism_c::get_root (t8_element_t *elem) const } /* each prism is packed as x (line.x), y (tri.x), z(tri.y) coordinates, type and the level */ void -t8_default_scheme_prism_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, - const int buffer_size, int *position, sc_MPI_Comm comm) const +t8_default_scheme_prism::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { int mpiret; t8_default_prism_t **prisms = (t8_default_prism_t **) elements; @@ -507,7 +490,7 @@ t8_default_scheme_prism_c::element_MPI_Pack (t8_element_t **const elements, cons /* each prism is packed as x (line.x), y (tri.x), z(tri.y) coordinates, type and the level */ void -t8_default_scheme_prism_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_prism::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -528,9 +511,8 @@ t8_default_scheme_prism_c::element_MPI_Pack_size (const unsigned int count, sc_M /* each prism is packed as x (line.x), y (tri.x), z(tri.y) coordinates, type and the level */ void -t8_default_scheme_prism_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_prism::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const { int mpiret; t8_default_prism_t **prisms = (t8_default_prism_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx index 723a97c457..1b59c66e91 100644 --- a/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx +++ b/src/t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx @@ -32,19 +32,19 @@ #include #include #include +#include /** Provide an implementation for the prism element class. * It is written as a self-contained library in the t8_dprism_* files. */ -class t8_default_scheme_prism_c: - public t8_eclass_scheme, - public t8_default_scheme_common_c { +class t8_default_scheme_prism: private t8_default_scheme_common { public: /** Constructor. */ - t8_default_scheme_prism_c (void); + t8_default_scheme_prism () + : t8_default_scheme_common (T8_ECLASS_PRISM, sizeof (t8_dprism_t)) {}; - ~t8_default_scheme_prism_c (); + ~t8_default_scheme_prism () {}; /** Return the size of a prism element. * \return The size of an element of class prism. diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx index c1fb9216a2..5512b8e847 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.cxx @@ -33,16 +33,16 @@ typedef t8_dpyramid_t t8_default_pyramid_t; T8_EXTERN_C_BEGIN (); size_t -t8_default_scheme_pyramid_c::get_element_size (void) const +t8_default_scheme_pyramid::get_element_size (void) const { return sizeof (t8_dpyramid_t); } void -t8_default_scheme_pyramid_c::element_new (int length, t8_element_t **elem) const +t8_default_scheme_pyramid::element_new (int length, t8_element_t **elem) const { /* allocate memory for a tet */ - t8_default_scheme_common_c::element_new (length, elem); + t8_default_scheme_common::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG @@ -56,7 +56,7 @@ t8_default_scheme_pyramid_c::element_new (int length, t8_element_t **elem) const } void -t8_default_scheme_pyramid_c::element_init (int length, t8_element_t *elem) const +t8_default_scheme_pyramid::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dpyramid_t *pyramid = (t8_dpyramid_t *) elem; @@ -70,20 +70,20 @@ t8_default_scheme_pyramid_c::element_init (int length, t8_element_t *elem) const } int -t8_default_scheme_pyramid_c::get_maxlevel (void) const +t8_default_scheme_pyramid::get_maxlevel (void) const { return T8_DPYRAMID_MAXLEVEL; } int -t8_default_scheme_pyramid_c::element_get_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_pyramid::element_get_max_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_max_num_faces ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::element_get_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_pyramid::element_get_ancestor_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DPYRAMID_MAXLEVEL); @@ -91,35 +91,35 @@ t8_default_scheme_pyramid_c::element_get_ancestor_id (const t8_element_t *elem, } int -t8_default_scheme_pyramid_c::element_get_num_children (const t8_element_t *elem) const +t8_default_scheme_pyramid::element_get_num_children (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_num_children ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::t8_element_num_corners (const t8_element_t *elem) const +t8_default_scheme_pyramid::t8_element_num_corners (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_num_corners ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::t8_element_num_siblings (const t8_element_t *elem) const +t8_default_scheme_pyramid::t8_element_num_siblings (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_num_siblings ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::element_get_num_faces (const t8_element_t *elem) const +t8_default_scheme_pyramid::element_get_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_num_faces ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_pyramid::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -127,13 +127,13 @@ t8_default_scheme_pyramid_c::element_compare (const t8_element_t *elem1, const t } int -t8_default_scheme_pyramid_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_pyramid::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dpyramid_equal ((const t8_dpyramid_t *) elem1, (const t8_dpyramid_t *) elem2); } void -t8_default_scheme_pyramid_c::element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_pyramid::element_copy (const t8_element_t *source, t8_element_t *dest) const { T8_ASSERT (element_is_valid (source)); t8_dpyramid_copy ((const t8_dpyramid_t *) source, (t8_dpyramid_t *) dest); @@ -141,7 +141,7 @@ t8_default_scheme_pyramid_c::element_copy (const t8_element_t *source, t8_elemen } void -t8_default_scheme_pyramid_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_pyramid::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= childid && childid < t8_dpyramid_num_children ((const t8_dpyramid_t *) elem)); @@ -150,7 +150,7 @@ t8_default_scheme_pyramid_c::element_get_child (const t8_element_t *elem, int ch } void -t8_default_scheme_pyramid_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_pyramid::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_children ((const t8_dpyramid_t *) elem, (t8_dpyramid_t **) c); @@ -162,8 +162,8 @@ t8_default_scheme_pyramid_c::element_get_children (const t8_element_t *elem, int } void -t8_default_scheme_pyramid_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_pyramid::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_children_at_face ((const t8_dpyramid_t *) elem, face, (t8_dpyramid_t **) children, num_children, @@ -176,44 +176,44 @@ t8_default_scheme_pyramid_c::element_get_children_at_face (const t8_element_t *e } int -t8_default_scheme_pyramid_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_pyramid::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_face_child_face ((const t8_dpyramid_t *) elem, face, face_child); } t8_element_shape_t -t8_default_scheme_pyramid_c::element_get_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid::element_get_face_shape (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_face_shape ((const t8_dpyramid_t *) elem, face); } int -t8_default_scheme_pyramid_c::element_get_child_id (const t8_element_t *p) const +t8_default_scheme_pyramid::element_get_child_id (const t8_element_t *p) const { T8_ASSERT (element_is_valid (p)); return t8_dpyramid_child_id ((const t8_dpyramid_t *) p); } int -t8_default_scheme_pyramid_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, - int face, int *neigh_face) const +t8_default_scheme_pyramid::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, + int face, int *neigh_face) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_face_neighbor_inside ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) neigh, face, neigh_face); } int -t8_default_scheme_pyramid_c::element_face_get_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid::element_face_get_parent_face (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_face_parent_face ((const t8_dpyramid_t *) elem, face); } void -t8_default_scheme_pyramid_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_pyramid::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_first_descendant ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) desc, level); @@ -221,8 +221,8 @@ t8_default_scheme_pyramid_c::element_construct_first_descendant (const t8_elemen } void -t8_default_scheme_pyramid_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_pyramid::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_first_descendant_face ((const t8_dpyramid_t *) elem, face, (t8_dpyramid_t *) first_desc, level); @@ -230,28 +230,28 @@ t8_default_scheme_pyramid_c::element_construct_first_descendant_face (const t8_e } int -t8_default_scheme_pyramid_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_pyramid::element_get_face_corner (const t8_element_t *element, int face, int corner) const { T8_ASSERT (element_is_valid (element)); return t8_dpyramid_get_face_corner ((const t8_dpyramid_t *) element, face, corner); } int -t8_default_scheme_pyramid_c::element_get_level (const t8_element_t *elem) const +t8_default_scheme_pyramid::element_get_level (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_get_level ((const t8_dpyramid_t *) elem); } void -t8_default_scheme_pyramid_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_pyramid::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { t8_dpyramid_init_linear_id ((t8_dpyramid_t *) elem, level, id); T8_ASSERT (element_is_valid (elem)); } int -t8_default_scheme_pyramid_c::elements_are_family (t8_element_t *const *fam) const +t8_default_scheme_pyramid::elements_are_family (t8_element_t *const *fam) const { #if T8_ENABLE_DEBUG int num_siblings = t8_element_num_siblings (fam[0]); @@ -263,15 +263,15 @@ t8_default_scheme_pyramid_c::elements_are_family (t8_element_t *const *fam) cons } int -t8_default_scheme_pyramid_c::element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid::element_is_root_boundary (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_is_root_boundary ((const t8_dpyramid_t *) elem, face); } void -t8_default_scheme_pyramid_c::element_construct_boundary_face (const t8_element_t *elem, int face, - t8_element_t *boundary, const t8_scheme *scheme) const +t8_default_scheme_pyramid::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *scheme) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_boundary_face ((const t8_dpyramid_t *) elem, face, boundary); @@ -280,8 +280,8 @@ t8_default_scheme_pyramid_c::element_construct_boundary_face (const t8_element_t } int -t8_default_scheme_pyramid_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, - t8_element_t *elem, int root_face, const t8_scheme *scheme) const +t8_default_scheme_pyramid::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (face_eclass == T8_ECLASS_TRIANGLE || face_eclass == T8_ECLASS_QUAD); @@ -291,36 +291,36 @@ t8_default_scheme_pyramid_c::element_extrude_face (const t8_element_t *face, con } t8_element_shape_t -t8_default_scheme_pyramid_c::t8_element_shape (const t8_element_t *elem) const +t8_default_scheme_pyramid::t8_element_shape (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_shape ((const t8_dpyramid_t *) elem); } int -t8_default_scheme_pyramid_c::element_get_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid::element_get_tree_face (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_tree_face ((const t8_dpyramid_t *) elem, face); } int -t8_default_scheme_pyramid_c::element_get_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_pyramid::element_get_num_face_children (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return T8_DPYRAMID_FACE_CHILDREN; } t8_linearidx_t -t8_default_scheme_pyramid_c::element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_pyramid::element_get_linear_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); return t8_dpyramid_linear_id ((const t8_dpyramid_t *) elem, level); } void -t8_default_scheme_pyramid_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_pyramid::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_last_descendant ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) desc, level); @@ -328,8 +328,8 @@ t8_default_scheme_pyramid_c::element_construct_last_descendant (const t8_element } void -t8_default_scheme_pyramid_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, - t8_element_t *last_desc, int level) const +t8_default_scheme_pyramid::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_last_descendant_face ((const t8_dpyramid_t *) elem, face, (t8_dpyramid_t *) last_desc, level); @@ -337,7 +337,7 @@ t8_default_scheme_pyramid_c::element_construct_last_descendant_face (const t8_el } void -t8_default_scheme_pyramid_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_pyramid::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_parent ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) parent); @@ -345,7 +345,7 @@ t8_default_scheme_pyramid_c::element_get_parent (const t8_element_t *elem, t8_el } void -t8_default_scheme_pyramid_c::element_construct_successor (const t8_element_t *elem, t8_element_t *s) const +t8_default_scheme_pyramid::element_construct_successor (const t8_element_t *elem, t8_element_t *s) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_successor ((const t8_dpyramid_t *) elem, (t8_dpyramid_t *) s, element_get_level (elem)); @@ -353,7 +353,7 @@ t8_default_scheme_pyramid_c::element_construct_successor (const t8_element_t *el } void -t8_default_scheme_pyramid_c::element_get_anchor (const t8_element_t *elem, int anchor[3]) const +t8_default_scheme_pyramid::element_get_anchor (const t8_element_t *elem, int anchor[3]) const { t8_dpyramid_t *pyra = (t8_dpyramid_t *) elem; @@ -364,15 +364,15 @@ t8_default_scheme_pyramid_c::element_get_anchor (const t8_element_t *elem, int a } void -t8_default_scheme_pyramid_c::element_get_vertex_integer_coords (const t8_element_t *t, int vertex, int coords[]) const +t8_default_scheme_pyramid::element_get_vertex_integer_coords (const t8_element_t *t, int vertex, int coords[]) const { T8_ASSERT (element_is_valid (t)); t8_dpyramid_compute_integer_coords ((const t8_dpyramid_t *) t, vertex, coords); } void -t8_default_scheme_pyramid_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, - t8_element_t *nca) const +t8_default_scheme_pyramid::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, + t8_element_t *nca) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -383,23 +383,23 @@ t8_default_scheme_pyramid_c::element_get_nca (const t8_element_t *elem1, const t } void -t8_default_scheme_pyramid_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_pyramid::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_vertex_reference_coords ((const t8_dpyramid_t *) elem, vertex, coords); } void -t8_default_scheme_pyramid_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_pyramid::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { T8_ASSERT (element_is_valid (elem)); t8_dpyramid_compute_reference_coords ((const t8_dpyramid_t *) elem, ref_coords, num_coords, out_coords); } int -t8_default_scheme_pyramid_c::refines_irregular () const +t8_default_scheme_pyramid::refines_irregular () const { /*Pyramids do not refine regularly */ return 1; @@ -407,15 +407,14 @@ t8_default_scheme_pyramid_c::refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_pyramid_c::element_is_valid (const t8_element_t *elem) const +t8_default_scheme_pyramid::element_is_valid (const t8_element_t *elem) const { T8_ASSERT (elem != NULL); return t8_dpyramid_is_valid ((const t8_dpyramid_t *) elem); } void -t8_default_scheme_pyramid_c::element_to_string (const t8_element_t *elem, char *debug_string, - const int string_size) const +t8_default_scheme_pyramid::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); @@ -426,24 +425,8 @@ t8_default_scheme_pyramid_c::element_to_string (const t8_element_t *elem, char * } #endif -/* Constructor */ -t8_default_scheme_pyramid_c::t8_default_scheme_pyramid_c (void) -{ - eclass = T8_ECLASS_PYRAMID; - element_size = sizeof (t8_default_pyramid_t); - ts_context = sc_mempool_new (element_size); -} - -t8_default_scheme_pyramid_c::~t8_default_scheme_pyramid_c () -{ - /* This destructor is empty since the destructor of the - * default_common scheme is called automatically and it - * suffices to destroy the quad_scheme. - * However we need to provide an implementation of the destructor - * and hence this empty function. */ -} void -t8_default_scheme_pyramid_c::get_root (t8_element_t *elem) const +t8_default_scheme_pyramid::get_root (t8_element_t *elem) const { t8_dpyramid_t *pyramid = (t8_dpyramid_t *) elem; pyramid->pyramid.level = 0; @@ -455,9 +438,8 @@ t8_default_scheme_pyramid_c::get_root (t8_element_t *elem) const } /* each pyramid is packed as a tet and the switch_shape_at_level marker */ void -t8_default_scheme_pyramid_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_pyramid::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { t8_default_pyramid_t **pyramids = (t8_default_pyramid_t **) elements; for (unsigned int ielem = 0; ielem < count; ielem++) { @@ -471,7 +453,7 @@ t8_default_scheme_pyramid_c::element_MPI_Pack (t8_element_t **const elements, co /* each pyramid is packed as a tet and the switch_shape_at_level marker */ void -t8_default_scheme_pyramid_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_pyramid::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -488,9 +470,9 @@ t8_default_scheme_pyramid_c::element_MPI_Pack_size (const unsigned int count, sc /* each pyramid is packed as a tet and the switch_shape_at_level marker */ void -t8_default_scheme_pyramid_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_pyramid::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, + sc_MPI_Comm comm) const { int mpiret; t8_default_pyramid_t **pyramids = (t8_default_pyramid_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx index 2a2a78cac0..49fa98a7e5 100644 --- a/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx +++ b/src/t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx @@ -30,19 +30,19 @@ #include #include +#include /** Provide an implementation for the pyramid element class. It is written as a self-contained library in the * t8_dpyramid_* files. */ -class t8_default_scheme_pyramid_c: - public t8_eclass_scheme, - public t8_default_scheme_common_c { +class t8_default_scheme_pyramid: private t8_default_scheme_common { public: /** Constructor. */ - t8_default_scheme_pyramid_c (void); + t8_default_scheme_pyramid () + : t8_default_scheme_common (T8_ECLASS_PYRAMID, sizeof (t8_dpyramid_t)) {}; - ~t8_default_scheme_pyramid_c (); + ~t8_default_scheme_pyramid () {}; /** Return the size of a prism element. * \return The size of an element of class prism. diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx index 71c83d24a8..8d17d39835 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.cxx @@ -35,19 +35,19 @@ t8_linearidx_t element_get_linear_id (const t8_element_t *elem, int level); size_t -t8_default_scheme_quad_c::get_element_size (void) const +t8_default_scheme_quad::get_element_size (void) const { return sizeof (t8_pquad_t); } int -t8_default_scheme_quad_c::get_maxlevel (void) const +t8_default_scheme_quad::get_maxlevel (void) const { return P4EST_QMAXLEVEL; } int -t8_default_scheme_quad_c::element_get_level (const t8_element_t *elem) const +t8_default_scheme_quad::element_get_level (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return (int) ((const p4est_quadrant_t *) elem)->level; @@ -64,7 +64,7 @@ element_copy_surround (const p4est_quadrant_t *q, p4est_quadrant_t *r) } void -t8_default_scheme_quad_c::element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_quad::element_copy (const t8_element_t *source, t8_element_t *dest) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) source; p4est_quadrant_t *r = (p4est_quadrant_t *) dest; @@ -80,7 +80,7 @@ t8_default_scheme_quad_c::element_copy (const t8_element_t *source, t8_element_t } int -t8_default_scheme_quad_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_quad::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -89,13 +89,13 @@ t8_default_scheme_quad_c::element_compare (const t8_element_t *elem1, const t8_e } int -t8_default_scheme_quad_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_quad::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return p4est_quadrant_is_equal ((const p4est_quadrant_t *) elem1, (const p4est_quadrant_t *) elem2); } void -t8_default_scheme_quad_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_quad::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *r = (p4est_quadrant_t *) parent; @@ -107,7 +107,7 @@ t8_default_scheme_quad_c::element_get_parent (const t8_element_t *elem, t8_eleme } void -t8_default_scheme_quad_c::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const +t8_default_scheme_quad::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *r = (p4est_quadrant_t *) sibling; @@ -119,34 +119,34 @@ t8_default_scheme_quad_c::element_get_sibling (const t8_element_t *elem, int sib } int -t8_default_scheme_quad_c::element_get_num_faces (const t8_element_t *elem) const +t8_default_scheme_quad::element_get_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return P4EST_FACES; } int -t8_default_scheme_quad_c::element_get_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_quad::element_get_max_num_faces (const t8_element_t *elem) const { return P4EST_FACES; } int -t8_default_scheme_quad_c::element_get_num_children (const t8_element_t *elem) const +t8_default_scheme_quad::element_get_num_children (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return P4EST_CHILDREN; } int -t8_default_scheme_quad_c::element_get_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_quad::element_get_num_face_children (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return 2; } int -t8_default_scheme_quad_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_quad::element_get_face_corner (const t8_element_t *element, int face, int corner) const { /* * 2 f_2 3 @@ -164,7 +164,7 @@ t8_default_scheme_quad_c::element_get_face_corner (const t8_element_t *element, } int -t8_default_scheme_quad_c::element_get_corner_face (const t8_element_t *element, int corner, int face) const +t8_default_scheme_quad::element_get_corner_face (const t8_element_t *element, int corner, int face) const { T8_ASSERT (element_is_valid (element)); T8_ASSERT (0 <= corner && corner < P4EST_CHILDREN); @@ -173,7 +173,7 @@ t8_default_scheme_quad_c::element_get_corner_face (const t8_element_t *element, } void -t8_default_scheme_quad_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_quad::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; const p4est_qcoord_t shift = P4EST_QUADRANT_LEN (q->level + 1); @@ -196,7 +196,7 @@ t8_default_scheme_quad_c::element_get_child (const t8_element_t *elem, int child } void -t8_default_scheme_quad_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_quad::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; int i; @@ -219,20 +219,20 @@ t8_default_scheme_quad_c::element_get_children (const t8_element_t *elem, int le } int -t8_default_scheme_quad_c::element_get_child_id (const t8_element_t *elem) const +t8_default_scheme_quad::element_get_child_id (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return p4est_quadrant_child_id ((const p4est_quadrant_t *) elem); } int -t8_default_scheme_quad_c::element_get_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_quad::element_get_ancestor_id (const t8_element_t *elem, int level) const { return p4est_quadrant_ancestor_id ((p4est_quadrant_t *) elem, level); } int -t8_default_scheme_quad_c::elements_are_family (t8_element_t *const *fam) const +t8_default_scheme_quad::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG int i; @@ -244,7 +244,7 @@ t8_default_scheme_quad_c::elements_are_family (t8_element_t *const *fam) const } void -t8_default_scheme_quad_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_quad::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= P4EST_QMAXLEVEL); @@ -255,7 +255,7 @@ t8_default_scheme_quad_c::element_set_linear_id (t8_element_t *elem, int level, } t8_linearidx_t -t8_default_scheme_quad_c::element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_quad::element_get_linear_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= P4EST_QMAXLEVEL); @@ -264,8 +264,8 @@ t8_default_scheme_quad_c::element_get_linear_id (const t8_element_t *elem, int l } void -t8_default_scheme_quad_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_quad::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -275,8 +275,8 @@ t8_default_scheme_quad_c::element_construct_first_descendant (const t8_element_t } void -t8_default_scheme_quad_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_quad::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -286,7 +286,7 @@ t8_default_scheme_quad_c::element_construct_last_descendant (const t8_element_t } void -t8_default_scheme_quad_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_quad::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -296,8 +296,7 @@ t8_default_scheme_quad_c::element_construct_successor (const t8_element_t *elem1 } void -t8_default_scheme_quad_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, - t8_element_t *nca) const +t8_default_scheme_quad::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const { const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem1; const p4est_quadrant_t *q2 = (const p4est_quadrant_t *) elem2; @@ -311,15 +310,15 @@ t8_default_scheme_quad_c::element_get_nca (const t8_element_t *elem1, const t8_e } t8_element_shape_t -t8_default_scheme_quad_c::element_get_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_quad::element_get_face_shape (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return T8_ECLASS_LINE; } void -t8_default_scheme_quad_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_quad::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { int first_child, second_child; @@ -385,7 +384,7 @@ t8_default_scheme_quad_c::element_get_children_at_face (const t8_element_t *elem } int -t8_default_scheme_quad_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_quad::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { T8_ASSERT (element_is_valid (elem)); /* For quadrants the face enumeration of children is the same as for the parent. */ @@ -393,7 +392,7 @@ t8_default_scheme_quad_c::element_face_get_child_face (const t8_element_t *elem, } int -t8_default_scheme_quad_c::element_face_get_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_quad::element_face_get_parent_face (const t8_element_t *elem, int face) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; int child_id; @@ -412,8 +411,8 @@ t8_default_scheme_quad_c::element_face_get_parent_face (const t8_element_t *elem } void -t8_default_scheme_quad_c::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, - int sign, int is_smaller_face) const +t8_default_scheme_quad::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, + int sign, int is_smaller_face) const { const p4est_quadrant_t *qin = (const p4est_quadrant_t *) elem1; const p4est_quadrant_t *q; @@ -490,8 +489,8 @@ t8_default_scheme_quad_c::element_transform_face (const t8_element_t *elem1, t8_ } int -t8_default_scheme_quad_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, - t8_element_t *elem, int root_face, const t8_scheme *scheme) const +t8_default_scheme_quad::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { const t8_dline_t *l = (const t8_dline_t *) face; p4est_quadrant_t *q = (p4est_quadrant_t *) elem; @@ -542,7 +541,7 @@ t8_default_scheme_quad_c::element_extrude_face (const t8_element_t *face, const } int -t8_default_scheme_quad_c::element_get_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_quad::element_get_tree_face (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < P4EST_FACES); @@ -552,8 +551,8 @@ t8_default_scheme_quad_c::element_get_tree_face (const t8_element_t *elem, int f /** Construct the first descendant of an element that touches a given face. */ void -t8_default_scheme_quad_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_quad::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *desc = (p4est_quadrant_t *) first_desc; @@ -570,8 +569,8 @@ t8_default_scheme_quad_c::element_construct_first_descendant_face (const t8_elem /** Construct the last descendant of an element that touches a given face. */ void -t8_default_scheme_quad_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, - t8_element_t *last_desc, int level) const +t8_default_scheme_quad::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *desc = (p4est_quadrant_t *) last_desc; @@ -587,8 +586,8 @@ t8_default_scheme_quad_c::element_construct_last_descendant_face (const t8_eleme } void -t8_default_scheme_quad_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *scheme) const +t8_default_scheme_quad::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *scheme) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; t8_dline_t *l = (t8_dline_t *) boundary; @@ -614,7 +613,7 @@ t8_default_scheme_quad_c::element_construct_boundary_face (const t8_element_t *e } int -t8_default_scheme_quad_c::element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_quad::element_is_root_boundary (const t8_element_t *elem, int face) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_qcoord_t coord; @@ -632,8 +631,8 @@ t8_default_scheme_quad_c::element_is_root_boundary (const t8_element_t *elem, in } int -t8_default_scheme_quad_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, - int face, int *neigh_face) const +t8_default_scheme_quad::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const { const p4est_quadrant_t *q = (const p4est_quadrant_t *) elem; p4est_quadrant_t *n = (p4est_quadrant_t *) neigh; @@ -655,7 +654,7 @@ t8_default_scheme_quad_c::element_construct_face_neighbor_inside (const t8_eleme } void -t8_default_scheme_quad_c::element_get_anchor (const t8_element_t *elem, int coord[3]) const +t8_default_scheme_quad::element_get_anchor (const t8_element_t *elem, int coord[3]) const { p4est_quadrant_t *q; @@ -668,7 +667,7 @@ t8_default_scheme_quad_c::element_get_anchor (const t8_element_t *elem, int coor } void -t8_default_scheme_quad_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_quad::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { const p4est_quadrant_t *q1 = (const p4est_quadrant_t *) elem; @@ -683,8 +682,8 @@ t8_default_scheme_quad_c::element_get_vertex_integer_coords (const t8_element_t } void -t8_default_scheme_quad_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_quad::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= vertex && vertex < 4); @@ -699,18 +698,18 @@ t8_default_scheme_quad_c::element_get_vertex_reference_coords (const t8_element_ } void -t8_default_scheme_quad_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_quad::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { T8_ASSERT (element_is_valid (elem)); t8_dquad_compute_reference_coords ((const t8_dquad_t *) elem, ref_coords, num_coords, out_coords); } void -t8_default_scheme_quad_c::element_new (int length, t8_element_t **elem) const +t8_default_scheme_quad::element_new (int length, t8_element_t **elem) const { /* allocate memory for a quad */ - t8_default_scheme_common_c::element_new (length, elem); + t8_default_scheme_common::element_new (length, elem); /* in debug mode, set sensible default values. */ { @@ -723,7 +722,7 @@ t8_default_scheme_quad_c::element_new (int length, t8_element_t **elem) const } void -t8_default_scheme_quad_c::element_init (int length, t8_element_t *elem) const +t8_default_scheme_quad::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG p4est_quadrant_t *quads = (p4est_quadrant_t *) elem; @@ -740,7 +739,7 @@ t8_default_scheme_quad_c::element_init (int length, t8_element_t *elem) const * Returns false otherwise. */ int -t8_default_scheme_quad_c::refines_irregular () const +t8_default_scheme_quad::refines_irregular () const { /*Quad refine regularly */ return 0; @@ -748,7 +747,7 @@ t8_default_scheme_quad_c::refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_quad_c::element_is_valid (const t8_element_t *elem) const +t8_default_scheme_quad::element_is_valid (const t8_element_t *elem) const { /* TODO: additional checks? do we set pad8 or similar? */ @@ -756,7 +755,7 @@ t8_default_scheme_quad_c::element_is_valid (const t8_element_t *elem) const } void -t8_default_scheme_quad_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const +t8_default_scheme_quad::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); @@ -765,24 +764,8 @@ t8_default_scheme_quad_c::element_to_string (const t8_element_t *elem, char *deb } #endif -/* Constructor */ -t8_default_scheme_quad_c::t8_default_scheme_quad_c (void) -{ - eclass = T8_ECLASS_QUAD; - element_size = sizeof (t8_pquad_t); - ts_context = sc_mempool_new (element_size); -} - -t8_default_scheme_quad_c::~t8_default_scheme_quad_c () -{ - /* This destructor is empty since the destructor of the - * default_common scheme is called automatically and it - * suffices to destroy the quad_scheme. - * However we need to provide an implementation of the destructor - * and hence this empty function. */ -} void -t8_default_scheme_quad_c::get_root (t8_element_t *elem) const +t8_default_scheme_quad::get_root (t8_element_t *elem) const { t8_pquad_t *quad = (t8_pquad_t *) elem; p4est_quadrant_set_morton (quad, 0, 0); @@ -790,8 +773,8 @@ t8_default_scheme_quad_c::get_root (t8_element_t *elem) const } /* each quad is packed as x,y coordinates and the level */ void -t8_default_scheme_quad_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, - const int buffer_size, int *position, sc_MPI_Comm comm) const +t8_default_scheme_quad::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { int mpiret; p4est_quadrant_t **quads = (p4est_quadrant_t **) elements; @@ -807,7 +790,7 @@ t8_default_scheme_quad_c::element_MPI_Pack (t8_element_t **const elements, const /* each quad is packed as x,y coordinates and the level */ void -t8_default_scheme_quad_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_quad::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -828,8 +811,8 @@ t8_default_scheme_quad_c::element_MPI_Pack_size (const unsigned int count, sc_MP /* each quad is packed as x,y coordinates and the level */ void -t8_default_scheme_quad_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const +t8_default_scheme_quad::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const { int mpiret; p4est_quadrant_t **quads = (p4est_quadrant_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx index 1f85e3755c..e3b7ef9b94 100644 --- a/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx +++ b/src/t8_schemes/t8_default/t8_default_quad/t8_default_quad.hxx @@ -76,14 +76,12 @@ typedef p4est_quadrant_t t8_pquad_t; (quad)->p.user_long = (long) (coord); \ } while (0) -class t8_default_scheme_quad_c: - public t8_eclass_scheme, - public t8_default_scheme_common_c { +class t8_default_scheme_quad: private t8_default_scheme_common { public: /** Constructor. */ - t8_default_scheme_quad_c (); + t8_default_scheme_quad (): t8_default_scheme_common (T8_ECLASS_QUAD, sizeof (t8_pquad_t)) {}; - ~t8_default_scheme_quad_c (); + ~t8_default_scheme_quad () {}; /** Return the size of a quad element. * \return The size of an element of class quad. diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx index c857ef0307..4092838591 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.cxx @@ -33,26 +33,26 @@ T8_EXTERN_C_BEGIN (); typedef t8_dtet_t t8_default_tet_t; size_t -t8_default_scheme_tet_c::get_element_size (void) const +t8_default_scheme_tet::get_element_size (void) const { return sizeof (t8_dtet_t); } int -t8_default_scheme_tet_c::get_maxlevel (void) const +t8_default_scheme_tet::get_maxlevel (void) const { return T8_DTET_MAXLEVEL; } int -t8_default_scheme_tet_c::element_get_level (const t8_element_t *elem) const +t8_default_scheme_tet::element_get_level (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dtet_get_level ((t8_dtet_t *) elem); } void -t8_default_scheme_tet_c::element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_tet::element_copy (const t8_element_t *source, t8_element_t *dest) const { T8_ASSERT (element_is_valid (source)); T8_ASSERT (element_is_valid (dest)); @@ -60,19 +60,19 @@ t8_default_scheme_tet_c::element_copy (const t8_element_t *source, t8_element_t } int -t8_default_scheme_tet_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_tet::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dtet_compare ((const t8_dtet_t *) elem1, (const t8_dtet_t *) elem2); } int -t8_default_scheme_tet_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_tet::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dtet_equal ((const t8_dtet_t *) elem1, (const t8_dtet_t *) elem2); } void -t8_default_scheme_tet_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_tet::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { const t8_default_tet_t *t = (const t8_default_tet_t *) elem; t8_default_tet_t *p = (t8_default_tet_t *) parent; @@ -83,7 +83,7 @@ t8_default_scheme_tet_c::element_get_parent (const t8_element_t *elem, t8_elemen } void -t8_default_scheme_tet_c::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const +t8_default_scheme_tet::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { const t8_default_tet_t *t = (const t8_default_tet_t *) elem; t8_default_tet_t *s = (t8_default_tet_t *) sibling; @@ -94,34 +94,34 @@ t8_default_scheme_tet_c::element_get_sibling (const t8_element_t *elem, int sibi } int -t8_default_scheme_tet_c::element_get_num_faces (const t8_element_t *elem) const +t8_default_scheme_tet::element_get_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DTET_FACES; } int -t8_default_scheme_tet_c::element_get_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_tet::element_get_max_num_faces (const t8_element_t *elem) const { return T8_DTET_FACES; } int -t8_default_scheme_tet_c::element_get_num_children (const t8_element_t *elem) const +t8_default_scheme_tet::element_get_num_children (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DTET_CHILDREN; } int -t8_default_scheme_tet_c::element_get_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_tet::element_get_num_face_children (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return T8_DTET_FACE_CHILDREN; } int -t8_default_scheme_tet_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_tet::element_get_face_corner (const t8_element_t *element, int face, int corner) const { T8_ASSERT (0 <= face && face < T8_DTET_FACES); T8_ASSERT (0 <= corner && corner < 3); @@ -129,7 +129,7 @@ t8_default_scheme_tet_c::element_get_face_corner (const t8_element_t *element, i } void -t8_default_scheme_tet_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_tet::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const t8_default_tet_t *t = (const t8_default_tet_t *) elem; t8_default_tet_t *c = (t8_default_tet_t *) child; @@ -140,7 +140,7 @@ t8_default_scheme_tet_c::element_get_child (const t8_element_t *elem, int childi } void -t8_default_scheme_tet_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_tet::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { T8_ASSERT (length == T8_DTET_CHILDREN); T8_ASSERT (element_is_valid (elem)); @@ -154,20 +154,20 @@ t8_default_scheme_tet_c::element_get_children (const t8_element_t *elem, int len } int -t8_default_scheme_tet_c::element_get_child_id (const t8_element_t *elem) const +t8_default_scheme_tet::element_get_child_id (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dtet_child_id ((const t8_dtet_t *) elem); } int -t8_default_scheme_tet_c::element_get_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_tet::element_get_ancestor_id (const t8_element_t *elem, int level) const { return t8_dtet_ancestor_id ((t8_dtet_t *) elem, level); } int -t8_default_scheme_tet_c::elements_are_family (t8_element_t *const *fam) const +t8_default_scheme_tet::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG int i; @@ -179,7 +179,7 @@ t8_default_scheme_tet_c::elements_are_family (t8_element_t *const *fam) const } void -t8_default_scheme_tet_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const +t8_default_scheme_tet::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const { const t8_default_tet_t *t1 = (const t8_default_tet_t *) elem1; const t8_default_tet_t *t2 = (const t8_default_tet_t *) elem2; @@ -191,15 +191,15 @@ t8_default_scheme_tet_c::element_get_nca (const t8_element_t *elem1, const t8_el } t8_element_shape_t -t8_default_scheme_tet_c::element_get_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_tet::element_get_face_shape (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return T8_ECLASS_TRIANGLE; } void -t8_default_scheme_tet_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_tet::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { const t8_dtet_t *t = (const t8_dtet_t *) elem; t8_dtet_t **c = (t8_dtet_t **) children; @@ -222,7 +222,7 @@ t8_default_scheme_tet_c::element_get_children_at_face (const t8_element_t *elem, } int -t8_default_scheme_tet_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_tet::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DTET_FACES); @@ -231,7 +231,7 @@ t8_default_scheme_tet_c::element_face_get_child_face (const t8_element_t *elem, } int -t8_default_scheme_tet_c::element_face_get_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_tet::element_face_get_parent_face (const t8_element_t *elem, int face) const { T8_ASSERT (0 <= face && face < T8_DTET_FACES); @@ -239,7 +239,7 @@ t8_default_scheme_tet_c::element_face_get_parent_face (const t8_element_t *elem, } int -t8_default_scheme_tet_c::element_get_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_tet::element_get_tree_face (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DTET_FACES); @@ -252,8 +252,8 @@ t8_default_scheme_tet_c::element_get_tree_face (const t8_element_t *elem, int fa * both in t8_dtri_bits.c. This would be needed by an implementation, at least * for tets. */ int -t8_default_scheme_tet_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, - t8_element_t *elem, int root_face, const t8_scheme *scheme) const +t8_default_scheme_tet::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { const t8_dtri_t *b = (const t8_dtri_t *) face; t8_dtet_t *t = (t8_dtet_t *) elem; @@ -296,8 +296,8 @@ t8_default_scheme_tet_c::element_extrude_face (const t8_element_t *face, const t } void -t8_default_scheme_tet_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_tet::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DTET_FACES); @@ -310,8 +310,8 @@ t8_default_scheme_tet_c::element_construct_first_descendant_face (const t8_eleme } void -t8_default_scheme_tet_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, - t8_element_t *last_desc, int level) const +t8_default_scheme_tet::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DTET_FACES); @@ -328,8 +328,8 @@ t8_default_scheme_tet_c::element_construct_last_descendant_face (const t8_elemen * the compile logic does not allow for t8_dtri_t and t8_dtet_t to exist * both in t8_dtet_bits.c. */ void -t8_default_scheme_tet_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *scheme) const +t8_default_scheme_tet::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *scheme) const { const t8_default_tet_t *t = (const t8_default_tet_t *) elem; t8_dtri_t *b = (t8_dtri_t *) boundary; @@ -374,7 +374,7 @@ t8_default_scheme_tet_c::element_construct_boundary_face (const t8_element_t *el } int -t8_default_scheme_tet_c::element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_tet::element_is_root_boundary (const t8_element_t *elem, int face) const { const t8_dtet_t *t = (const t8_dtet_t *) elem; @@ -383,8 +383,8 @@ t8_default_scheme_tet_c::element_is_root_boundary (const t8_element_t *elem, int } int -t8_default_scheme_tet_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, - int face, int *neigh_face) const +t8_default_scheme_tet::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const { const t8_dtet_t *t = (const t8_dtet_t *) elem; t8_dtet_t *n = (t8_dtet_t *) neigh; @@ -399,7 +399,7 @@ t8_default_scheme_tet_c::element_construct_face_neighbor_inside (const t8_elemen } void -t8_default_scheme_tet_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_tet::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { T8_ASSERT (0 <= level && level <= T8_DTET_MAXLEVEL); T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << 3 * level); @@ -409,7 +409,7 @@ t8_default_scheme_tet_c::element_set_linear_id (t8_element_t *elem, int level, t } t8_linearidx_t -t8_default_scheme_tet_c::element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_tet::element_get_linear_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DTET_MAXLEVEL); @@ -418,7 +418,7 @@ t8_default_scheme_tet_c::element_get_linear_id (const t8_element_t *elem, int le } void -t8_default_scheme_tet_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_tet::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -428,8 +428,8 @@ t8_default_scheme_tet_c::element_construct_successor (const t8_element_t *elem1, } void -t8_default_scheme_tet_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_tet::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -438,8 +438,7 @@ t8_default_scheme_tet_c::element_construct_first_descendant (const t8_element_t } void -t8_default_scheme_tet_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_tet::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -448,7 +447,7 @@ t8_default_scheme_tet_c::element_construct_last_descendant (const t8_element_t * } void -t8_default_scheme_tet_c::element_get_anchor (const t8_element_t *elem, int anchor[3]) const +t8_default_scheme_tet::element_get_anchor (const t8_element_t *elem, int anchor[3]) const { t8_dtet_t *tet = (t8_dtet_t *) elem; T8_ASSERT (element_is_valid (elem)); @@ -459,23 +458,23 @@ t8_default_scheme_tet_c::element_get_anchor (const t8_element_t *elem, int ancho } void -t8_default_scheme_tet_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_tet::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dtet_compute_integer_coords ((const t8_default_tet_t *) elem, vertex, coords); } void -t8_default_scheme_tet_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_tet::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dtet_compute_vertex_ref_coords ((const t8_default_tet_t *) elem, vertex, coords); } void -t8_default_scheme_tet_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_tet::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { T8_ASSERT (element_is_valid (elem)); t8_dtet_compute_reference_coords ((const t8_dtet_t *) elem, ref_coords, num_coords, out_coords); @@ -485,7 +484,7 @@ t8_default_scheme_tet_c::element_get_reference_coords (const t8_element_t *elem, * Returns false otherwise. */ int -t8_default_scheme_tet_c::refines_irregular () const +t8_default_scheme_tet::refines_irregular () const { /*Tets refine regularly */ return 0; @@ -493,14 +492,14 @@ t8_default_scheme_tet_c::refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_tet_c::element_is_valid (const t8_element_t *t) const +t8_default_scheme_tet::element_is_valid (const t8_element_t *t) const { return t8_dtet_is_valid ((const t8_dtet_t *) t); } void -t8_default_scheme_tet_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const +t8_default_scheme_tet::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); @@ -511,10 +510,10 @@ t8_default_scheme_tet_c::element_to_string (const t8_element_t *elem, char *debu #endif void -t8_default_scheme_tet_c::element_new (int length, t8_element_t **elem) const +t8_default_scheme_tet::element_new (int length, t8_element_t **elem) const { /* allocate memory for a tet */ - t8_default_scheme_common_c::element_new (length, elem); + t8_default_scheme_common::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG @@ -528,7 +527,7 @@ t8_default_scheme_tet_c::element_new (int length, t8_element_t **elem) const } void -t8_default_scheme_tet_c::element_init (int length, t8_element_t *elem) const +t8_default_scheme_tet::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dtet_t *tets = (t8_dtet_t *) elem; @@ -538,25 +537,8 @@ t8_default_scheme_tet_c::element_init (int length, t8_element_t *elem) const #endif } -/* Constructor */ -t8_default_scheme_tet_c::t8_default_scheme_tet_c (void) -{ - eclass = T8_ECLASS_TET; - element_size = sizeof (t8_dtet_t); - ts_context = sc_mempool_new (element_size); -} - -/* Destructor */ -t8_default_scheme_tet_c::~t8_default_scheme_tet_c () -{ - /* This destructor is empty since the destructor of the - * default_common scheme is called automatically and it - * suffices to destroy the quad_scheme. - * However we need to provide an implementation of the destructor - * and hence this empty function. */ -} void -t8_default_scheme_tet_c::get_root (t8_element_t *elem) const +t8_default_scheme_tet::get_root (t8_element_t *elem) const { t8_dtet_t *tet = (t8_dtet_t *) elem; tet->level = 0; @@ -567,23 +549,23 @@ t8_default_scheme_tet_c::get_root (t8_element_t *elem) const } /* use macro tri functionality */ void -t8_default_scheme_tet_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, - const int buffer_size, int *position, sc_MPI_Comm comm) const +t8_default_scheme_tet::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { t8_dtet_element_pack ((t8_dtet_t **) elements, count, send_buffer, buffer_size, position, comm); } /* use macro tri functionality */ void -t8_default_scheme_tet_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_tet::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { t8_dtet_element_pack_size (count, comm, pack_size); } /* use macro tri functionality */ void -t8_default_scheme_tet_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const +t8_default_scheme_tet::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const unsigned int count, sc_MPI_Comm comm) const { t8_dtet_element_unpack (recvbuf, buffer_size, position, (t8_dtet_t **) elements, count, comm); } diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx index d04b7b7ad0..954dd10960 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx @@ -32,15 +32,14 @@ #include #include #include +#include -class t8_default_scheme_tet_c: - public t8_eclass_scheme, - public t8_default_scheme_common_c { +class t8_default_scheme_tet: private t8_default_scheme_common { public: /** Constructor. */ - t8_default_scheme_tet_c (); + t8_default_scheme_tet (): t8_default_scheme_common (T8_ECLASS_TET, sizeof (t8_dtet_t)) {}; - ~t8_default_scheme_tet_c (); + ~t8_default_scheme_tet () {}; /** Return the size of a tet element. * \return The size of an element of class tet. diff --git a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_connectivity.h b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_connectivity.h index 271c68059e..4b790e8fa5 100644 --- a/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_connectivity.h +++ b/src/t8_schemes/t8_default/t8_default_tet/t8_dtet_connectivity.h @@ -73,7 +73,7 @@ extern const int t8_dtet_parenttype_Iloc_to_cid[6][8]; * of the respective boundary triangle. * I.e. {2, 1} means the boundary triangle is of category 2 and type 1. * The category determines how the coordinates of the triangle are computed - * from the parent. \see t8_default_scheme_tet_c::t8_element_boundary. + * from the parent. \see t8_default_scheme_tet::t8_element_boundary. * Invalid inpute values are represented by -1. */ extern const int t8_dtet_type_face_to_boundary[6][4][2]; diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.cxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.cxx index ca1bdc66dd..b0ee8572ea 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.cxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.cxx @@ -32,26 +32,26 @@ T8_EXTERN_C_BEGIN (); size_t -t8_default_scheme_tri_c::get_element_size (void) const +t8_default_scheme_tri::get_element_size (void) const { return sizeof (t8_dtri_t); } int -t8_default_scheme_tri_c::get_maxlevel (void) const +t8_default_scheme_tri::get_maxlevel (void) const { return T8_DTRI_MAXLEVEL; } int -t8_default_scheme_tri_c::element_get_level (const t8_element_t *elem) const +t8_default_scheme_tri::element_get_level (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dtri_get_level ((t8_dtri_t *) elem); } void -t8_default_scheme_tri_c::element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_tri::element_copy (const t8_element_t *source, t8_element_t *dest) const { T8_ASSERT (element_is_valid (source)); T8_ASSERT (element_is_valid (dest)); @@ -59,7 +59,7 @@ t8_default_scheme_tri_c::element_copy (const t8_element_t *source, t8_element_t } int -t8_default_scheme_tri_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_tri::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -68,13 +68,13 @@ t8_default_scheme_tri_c::element_compare (const t8_element_t *elem1, const t8_el } int -t8_default_scheme_tri_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_tri::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dtri_equal ((const t8_dtri_t *) elem1, (const t8_dtri_t *) elem2); } void -t8_default_scheme_tri_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_tri::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; t8_dtri_t *p = (t8_dtri_t *) parent; @@ -85,7 +85,7 @@ t8_default_scheme_tri_c::element_get_parent (const t8_element_t *elem, t8_elemen } void -t8_default_scheme_tri_c::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const +t8_default_scheme_tri::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; t8_dtri_t *s = (t8_dtri_t *) sibling; @@ -95,34 +95,34 @@ t8_default_scheme_tri_c::element_get_sibling (const t8_element_t *elem, int sibi } int -t8_default_scheme_tri_c::element_get_num_faces (const t8_element_t *elem) const +t8_default_scheme_tri::element_get_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DTRI_FACES; } int -t8_default_scheme_tri_c::element_get_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_tri::element_get_max_num_faces (const t8_element_t *elem) const { return T8_DTRI_FACES; } int -t8_default_scheme_tri_c::element_get_num_children (const t8_element_t *elem) const +t8_default_scheme_tri::element_get_num_children (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DTRI_CHILDREN; } int -t8_default_scheme_tri_c::element_get_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_tri::element_get_num_face_children (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return T8_DTRI_FACE_CHILDREN; } int -t8_default_scheme_tri_c::element_get_face_corner (const t8_element_t *element, int face, int corner) const +t8_default_scheme_tri::element_get_face_corner (const t8_element_t *element, int face, int corner) const { T8_ASSERT (element_is_valid (element)); T8_ASSERT (0 <= face && face < T8_DTRI_FACES); @@ -131,7 +131,7 @@ t8_default_scheme_tri_c::element_get_face_corner (const t8_element_t *element, i } int -t8_default_scheme_tri_c::element_get_corner_face (const t8_element_t *element, int corner, int face) const +t8_default_scheme_tri::element_get_corner_face (const t8_element_t *element, int corner, int face) const { T8_ASSERT (element_is_valid (element)); T8_ASSERT (0 <= corner && corner < T8_DTRI_CORNERS); @@ -140,7 +140,7 @@ t8_default_scheme_tri_c::element_get_corner_face (const t8_element_t *element, i } void -t8_default_scheme_tri_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_tri::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; t8_dtri_t *c = (t8_dtri_t *) child; @@ -151,7 +151,7 @@ t8_default_scheme_tri_c::element_get_child (const t8_element_t *elem, int childi } void -t8_default_scheme_tri_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_tri::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { T8_ASSERT (element_is_valid (elem)); #ifdef T8_ENABLE_DEBUG @@ -168,20 +168,20 @@ t8_default_scheme_tri_c::element_get_children (const t8_element_t *elem, int len } int -t8_default_scheme_tri_c::element_get_child_id (const t8_element_t *elem) const +t8_default_scheme_tri::element_get_child_id (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dtri_child_id ((t8_dtri_t *) elem); } int -t8_default_scheme_tri_c::element_get_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_tri::element_get_ancestor_id (const t8_element_t *elem, int level) const { return t8_dtri_ancestor_id ((t8_dtri_t *) elem, level); } int -t8_default_scheme_tri_c::elements_are_family (t8_element_t *const *fam) const +t8_default_scheme_tri::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG { @@ -195,7 +195,7 @@ t8_default_scheme_tri_c::elements_are_family (t8_element_t *const *fam) const } void -t8_default_scheme_tri_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const +t8_default_scheme_tri::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const { const t8_dtri_t *t1 = (const t8_dtri_t *) elem1; const t8_dtri_t *t2 = (const t8_dtri_t *) elem2; @@ -207,15 +207,15 @@ t8_default_scheme_tri_c::element_get_nca (const t8_element_t *elem1, const t8_el } t8_element_shape_t -t8_default_scheme_tri_c::element_get_face_shape (const t8_element_t *elem, int face) const +t8_default_scheme_tri::element_get_face_shape (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return T8_ECLASS_LINE; } void -t8_default_scheme_tri_c::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], - int num_children, int *child_indices) const +t8_default_scheme_tri::element_get_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], + int num_children, int *child_indices) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; t8_dtri_t **c = (t8_dtri_t **) children; @@ -236,7 +236,7 @@ t8_default_scheme_tri_c::element_get_children_at_face (const t8_element_t *elem, } int -t8_default_scheme_tri_c::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const +t8_default_scheme_tri::element_face_get_child_face (const t8_element_t *elem, int face, int face_child) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DTRI_FACES); @@ -245,7 +245,7 @@ t8_default_scheme_tri_c::element_face_get_child_face (const t8_element_t *elem, } int -t8_default_scheme_tri_c::element_face_get_parent_face (const t8_element_t *elem, int face) const +t8_default_scheme_tri::element_face_get_parent_face (const t8_element_t *elem, int face) const { T8_ASSERT (0 <= face && face < T8_DTRI_FACES); @@ -253,7 +253,7 @@ t8_default_scheme_tri_c::element_face_get_parent_face (const t8_element_t *elem, } int -t8_default_scheme_tri_c::element_get_tree_face (const t8_element_t *elem, int face) const +t8_default_scheme_tri::element_get_tree_face (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= face && face < T8_DTRI_FACES); @@ -261,8 +261,8 @@ t8_default_scheme_tri_c::element_get_tree_face (const t8_element_t *elem, int fa } void -t8_default_scheme_tri_c::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, - int sign, int is_smaller_face) const +t8_default_scheme_tri::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, + int sign, int is_smaller_face) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -275,8 +275,8 @@ t8_default_scheme_tri_c::element_transform_face (const t8_element_t *elem1, t8_e * both in t8_dtri_bits.c. This would be needed by an implementation, at least * for tets. */ int -t8_default_scheme_tri_c::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, - t8_element_t *elem, int root_face, const t8_scheme *scheme) const +t8_default_scheme_tri::element_extrude_face (const t8_element_t *face, const t8_eclass_t face_eclass, + t8_element_t *elem, int root_face, const t8_scheme *scheme) const { const t8_dline_t *l = (const t8_dline_t *) face; t8_dtri_t *t = (t8_dtri_t *) elem; @@ -324,8 +324,8 @@ t8_default_scheme_tri_c::element_extrude_face (const t8_element_t *face, const t } void -t8_default_scheme_tri_c::element_construct_first_descendant_face (const t8_element_t *elem, int face, - t8_element_t *first_desc, int level) const +t8_default_scheme_tri::element_construct_first_descendant_face (const t8_element_t *elem, int face, + t8_element_t *first_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DTRI_FACES); @@ -338,8 +338,8 @@ t8_default_scheme_tri_c::element_construct_first_descendant_face (const t8_eleme } void -t8_default_scheme_tri_c::element_construct_last_descendant_face (const t8_element_t *elem, int face, - t8_element_t *last_desc, int level) const +t8_default_scheme_tri::element_construct_last_descendant_face (const t8_element_t *elem, int face, + t8_element_t *last_desc, int level) const { int corner; T8_ASSERT (0 <= face && face < T8_DTRI_FACES); @@ -352,8 +352,8 @@ t8_default_scheme_tri_c::element_construct_last_descendant_face (const t8_elemen /* Construct the boundary element at a specific face. */ void -t8_default_scheme_tri_c::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, - const t8_scheme *scheme) const +t8_default_scheme_tri::element_construct_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary, + const t8_scheme *scheme) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; t8_dline_t *l = (t8_dline_t *) boundary; @@ -388,7 +388,7 @@ t8_default_scheme_tri_c::element_construct_boundary_face (const t8_element_t *el } int -t8_default_scheme_tri_c::element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_tri::element_is_root_boundary (const t8_element_t *elem, int face) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; T8_ASSERT (element_is_valid (elem)); @@ -397,8 +397,8 @@ t8_default_scheme_tri_c::element_is_root_boundary (const t8_element_t *elem, int } int -t8_default_scheme_tri_c::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, - int face, int *neigh_face) const +t8_default_scheme_tri::element_construct_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, + int *neigh_face) const { const t8_dtri_t *t = (const t8_dtri_t *) elem; t8_dtri_t *n = (t8_dtri_t *) neigh; @@ -414,7 +414,7 @@ t8_default_scheme_tri_c::element_construct_face_neighbor_inside (const t8_elemen } void -t8_default_scheme_tri_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_tri::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DTRI_MAXLEVEL); @@ -424,7 +424,7 @@ t8_default_scheme_tri_c::element_set_linear_id (t8_element_t *elem, int level, t } t8_linearidx_t -t8_default_scheme_tri_c::element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_tri::element_get_linear_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DTRI_MAXLEVEL); @@ -433,8 +433,8 @@ t8_default_scheme_tri_c::element_get_linear_id (const t8_element_t *elem, int le } void -t8_default_scheme_tri_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_tri::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -443,8 +443,7 @@ t8_default_scheme_tri_c::element_construct_first_descendant (const t8_element_t } void -t8_default_scheme_tri_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_tri::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -453,7 +452,7 @@ t8_default_scheme_tri_c::element_construct_last_descendant (const t8_element_t * } void -t8_default_scheme_tri_c::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const +t8_default_scheme_tri::element_construct_successor (const t8_element_t *elem1, t8_element_t *elem2) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -463,7 +462,7 @@ t8_default_scheme_tri_c::element_construct_successor (const t8_element_t *elem1, } void -t8_default_scheme_tri_c::element_get_anchor (const t8_element_t *elem, int anchor[3]) const +t8_default_scheme_tri::element_get_anchor (const t8_element_t *elem, int anchor[3]) const { t8_dtri_t *tri = (t8_dtri_t *) elem; @@ -474,30 +473,30 @@ t8_default_scheme_tri_c::element_get_anchor (const t8_element_t *elem, int ancho } void -t8_default_scheme_tri_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_tri::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dtri_compute_integer_coords ((const t8_dtri_t *) elem, vertex, coords); } void -t8_default_scheme_tri_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_tri::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dtri_compute_vertex_ref_coords ((const t8_dtri_t *) elem, vertex, coords); } void -t8_default_scheme_tri_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_tri::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { T8_ASSERT (element_is_valid (elem)); t8_dtri_compute_reference_coords ((const t8_dtri_t *) elem, ref_coords, num_coords, 0, out_coords); } int -t8_default_scheme_tri_c::refines_irregular () const +t8_default_scheme_tri::refines_irregular () const { /*tris refine regularly */ return 0; @@ -505,13 +504,13 @@ t8_default_scheme_tri_c::refines_irregular () const #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_tri_c::element_is_valid (const t8_element_t *t) const +t8_default_scheme_tri::element_is_valid (const t8_element_t *t) const { return t8_dtri_is_valid ((const t8_dtri_t *) t); } void -t8_default_scheme_tri_c::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const +t8_default_scheme_tri::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); @@ -521,10 +520,10 @@ t8_default_scheme_tri_c::element_to_string (const t8_element_t *elem, char *debu #endif void -t8_default_scheme_tri_c::element_new (int length, t8_element_t **elem) const +t8_default_scheme_tri::element_new (int length, t8_element_t **elem) const { /* allocate memory for a tet */ - t8_default_scheme_common_c::element_new (length, elem); + t8_default_scheme_common::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG @@ -538,7 +537,7 @@ t8_default_scheme_tri_c::element_new (int length, t8_element_t **elem) const } void -t8_default_scheme_tri_c::element_init (int length, t8_element_t *elem) const +t8_default_scheme_tri::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dtri_t *tris = (t8_dtri_t *) elem; @@ -548,25 +547,8 @@ t8_default_scheme_tri_c::element_init (int length, t8_element_t *elem) const #endif } -/* Constructor */ -t8_default_scheme_tri_c::t8_default_scheme_tri_c (void) -{ - eclass = T8_ECLASS_TRIANGLE; - element_size = sizeof (t8_dtri_t); - ts_context = sc_mempool_new (element_size); -} - -/* Destructor */ -t8_default_scheme_tri_c::~t8_default_scheme_tri_c () -{ - /* This destructor is empty since the destructor of the - * default_common scheme is called automatically and it - * suffices to destroy the quad_scheme. - * However we need to provide an implementation of the destructor - * and hence this empty function. */ -} void -t8_default_scheme_tri_c::get_root (t8_element_t *elem) const +t8_default_scheme_tri::get_root (t8_element_t *elem) const { t8_dtri_t *tri = (t8_dtri_t *) elem; tri->level = 0; @@ -576,23 +558,23 @@ t8_default_scheme_tri_c::get_root (t8_element_t *elem) const } /* use macro tri functionality */ void -t8_default_scheme_tri_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, - const int buffer_size, int *position, sc_MPI_Comm comm) const +t8_default_scheme_tri::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { t8_dtri_element_pack ((t8_dtri_t **) elements, count, send_buffer, buffer_size, position, comm); } /* use macro tri functionality */ void -t8_default_scheme_tri_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_tri::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { t8_dtri_element_pack_size (count, comm, pack_size); } /* use macro tri functionality */ void -t8_default_scheme_tri_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const +t8_default_scheme_tri::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, + const unsigned int count, sc_MPI_Comm comm) const { t8_dtri_element_unpack (recvbuf, buffer_size, position, (t8_dtri_t **) elements, count, comm); } diff --git a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx index a9d44c0298..dec6388d2e 100644 --- a/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx +++ b/src/t8_schemes/t8_default/t8_default_tri/t8_default_tri.hxx @@ -31,15 +31,14 @@ #include #include #include +#include -class t8_default_scheme_tri_c: - public t8_eclass_scheme, - public t8_default_scheme_common_c { +class t8_default_scheme_tri: private t8_default_scheme_common { public: /** Constructor. */ - t8_default_scheme_tri_c (); + t8_default_scheme_tri (): t8_default_scheme_common (T8_ECLASS_TRIANGLE, sizeof (t8_dtri_t)) {}; - ~t8_default_scheme_tri_c (); + ~t8_default_scheme_tri () {}; /** Return the size of a tri element. * \return The size of an element of class tri. diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.cxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.cxx index 099638e10f..4bb8aadb7f 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.cxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.cxx @@ -28,26 +28,26 @@ T8_EXTERN_C_BEGIN (); size_t -t8_default_scheme_vertex_c::get_element_size (void) const +t8_default_scheme_vertex::get_element_size (void) const { return sizeof (t8_dvertex_t); } int -t8_default_scheme_vertex_c::get_maxlevel (void) const +t8_default_scheme_vertex::get_maxlevel (void) const { return T8_DVERTEX_MAXLEVEL; } int -t8_default_scheme_vertex_c::element_get_level (const t8_element_t *elem) const +t8_default_scheme_vertex::element_get_level (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dvertex_get_level ((const t8_dvertex_t *) elem); } void -t8_default_scheme_vertex_c::element_copy (const t8_element_t *source, t8_element_t *dest) const +t8_default_scheme_vertex::element_copy (const t8_element_t *source, t8_element_t *dest) const { T8_ASSERT (element_is_valid (source)); T8_ASSERT (element_is_valid (dest)); @@ -55,19 +55,19 @@ t8_default_scheme_vertex_c::element_copy (const t8_element_t *source, t8_element } int -t8_default_scheme_vertex_c::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_vertex::element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dvertex_compare ((const t8_dvertex_t *) elem1, (const t8_dvertex_t *) elem2); } int -t8_default_scheme_vertex_c::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const +t8_default_scheme_vertex::element_is_equal (const t8_element_t *elem1, const t8_element_t *elem2) const { return t8_dvertex_equal ((const t8_dvertex_t *) elem1, (const t8_dvertex_t *) elem2); } void -t8_default_scheme_vertex_c::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const +t8_default_scheme_vertex::element_get_parent (const t8_element_t *elem, t8_element_t *parent) const { const t8_dvertex_t *v = (const t8_dvertex_t *) elem; t8_dvertex_t *p = (t8_dvertex_t *) parent; @@ -78,7 +78,7 @@ t8_default_scheme_vertex_c::element_get_parent (const t8_element_t *elem, t8_ele } void -t8_default_scheme_vertex_c::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const +t8_default_scheme_vertex::element_get_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const { const t8_dvertex_t *v = (const t8_dvertex_t *) elem; t8_dvertex_t *s = (t8_dvertex_t *) sibling; @@ -89,34 +89,34 @@ t8_default_scheme_vertex_c::element_get_sibling (const t8_element_t *elem, int s } int -t8_default_scheme_vertex_c::element_get_num_faces (const t8_element_t *elem) const +t8_default_scheme_vertex::element_get_num_faces (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DVERTEX_FACES; } int -t8_default_scheme_vertex_c::element_get_max_num_faces (const t8_element_t *elem) const +t8_default_scheme_vertex::element_get_max_num_faces (const t8_element_t *elem) const { return T8_DVERTEX_FACES; } int -t8_default_scheme_vertex_c::element_get_num_children (const t8_element_t *elem) const +t8_default_scheme_vertex::element_get_num_children (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return T8_DVERTEX_CHILDREN; } int -t8_default_scheme_vertex_c::element_get_num_face_children (const t8_element_t *elem, int face) const +t8_default_scheme_vertex::element_get_num_face_children (const t8_element_t *elem, int face) const { T8_ASSERT (element_is_valid (elem)); return T8_DVERTEX_FACE_CHILDREN; } void -t8_default_scheme_vertex_c::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const +t8_default_scheme_vertex::element_get_child (const t8_element_t *elem, int childid, t8_element_t *child) const { const t8_dvertex_t *v = (const t8_dvertex_t *) elem; t8_dvertex_t *c = (t8_dvertex_t *) child; @@ -128,7 +128,7 @@ t8_default_scheme_vertex_c::element_get_child (const t8_element_t *elem, int chi } void -t8_default_scheme_vertex_c::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const +t8_default_scheme_vertex::element_get_children (const t8_element_t *elem, int length, t8_element_t *c[]) const { T8_ASSERT (length == T8_DVERTEX_CHILDREN); T8_ASSERT (element_is_valid (elem)); @@ -142,20 +142,20 @@ t8_default_scheme_vertex_c::element_get_children (const t8_element_t *elem, int } int -t8_default_scheme_vertex_c::element_get_child_id (const t8_element_t *elem) const +t8_default_scheme_vertex::element_get_child_id (const t8_element_t *elem) const { T8_ASSERT (element_is_valid (elem)); return t8_dvertex_child_id ((const t8_dvertex_t *) elem); } int -t8_default_scheme_vertex_c::element_get_ancestor_id (const t8_element_t *elem, int level) const +t8_default_scheme_vertex::element_get_ancestor_id (const t8_element_t *elem, int level) const { return t8_dvertex_ancestor_id ((const t8_dvertex_t *) elem, level); } int -t8_default_scheme_vertex_c::elements_are_family (t8_element_t *const *fam) const +t8_default_scheme_vertex::elements_are_family (t8_element_t *const *fam) const { #ifdef T8_ENABLE_DEBUG int i; @@ -167,8 +167,8 @@ t8_default_scheme_vertex_c::elements_are_family (t8_element_t *const *fam) const } void -t8_default_scheme_vertex_c::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, - t8_element_t *nca) const +t8_default_scheme_vertex::element_get_nca (const t8_element_t *elem1, const t8_element_t *elem2, + t8_element_t *nca) const { const t8_dvertex_t *v1 = (const t8_dvertex_t *) elem1; const t8_dvertex_t *v2 = (const t8_dvertex_t *) elem2; @@ -182,8 +182,8 @@ t8_default_scheme_vertex_c::element_get_nca (const t8_element_t *elem1, const t8 /** Transform the coordinates of a vertex considered as boundary element * in a tree-tree connection. */ void -t8_default_scheme_vertex_c::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, - int sign, int is_smaller_face) const +t8_default_scheme_vertex::element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, + int sign, int is_smaller_face) const { T8_ASSERT (element_is_valid (elem1)); T8_ASSERT (element_is_valid (elem2)); @@ -192,7 +192,7 @@ t8_default_scheme_vertex_c::element_transform_face (const t8_element_t *elem1, t } int -t8_default_scheme_vertex_c::element_is_root_boundary (const t8_element_t *elem, int face) const +t8_default_scheme_vertex::element_is_root_boundary (const t8_element_t *elem, int face) const { const t8_dvertex_t *v = (const t8_dvertex_t *) elem; @@ -201,7 +201,7 @@ t8_default_scheme_vertex_c::element_is_root_boundary (const t8_element_t *elem, } void -t8_default_scheme_vertex_c::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const +t8_default_scheme_vertex::element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const { T8_ASSERT (0 <= level && level <= T8_DVERTEX_MAXLEVEL); T8_ASSERT (0 <= id && id < ((t8_linearidx_t) 1) << 3 * level); @@ -211,7 +211,7 @@ t8_default_scheme_vertex_c::element_set_linear_id (t8_element_t *elem, int level } t8_linearidx_t -t8_default_scheme_vertex_c::element_get_linear_id (const t8_element_t *elem, int level) const +t8_default_scheme_vertex::element_get_linear_id (const t8_element_t *elem, int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (0 <= level && level <= T8_DVERTEX_MAXLEVEL); @@ -220,8 +220,8 @@ t8_default_scheme_vertex_c::element_get_linear_id (const t8_element_t *elem, int } void -t8_default_scheme_vertex_c::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_vertex::element_construct_first_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -230,8 +230,8 @@ t8_default_scheme_vertex_c::element_construct_first_descendant (const t8_element } void -t8_default_scheme_vertex_c::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, - int level) const +t8_default_scheme_vertex::element_construct_last_descendant (const t8_element_t *elem, t8_element_t *desc, + int level) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (element_is_valid (desc)); @@ -240,7 +240,7 @@ t8_default_scheme_vertex_c::element_construct_last_descendant (const t8_element_ } void -t8_default_scheme_vertex_c::element_get_anchor (const t8_element_t *elem, int anchor[3]) const +t8_default_scheme_vertex::element_get_anchor (const t8_element_t *elem, int anchor[3]) const { T8_ASSERT (element_is_valid (elem)); @@ -250,15 +250,15 @@ t8_default_scheme_vertex_c::element_get_anchor (const t8_element_t *elem, int an } void -t8_default_scheme_vertex_c::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const +t8_default_scheme_vertex::element_get_vertex_integer_coords (const t8_element_t *elem, int vertex, int coords[]) const { T8_ASSERT (element_is_valid (elem)); t8_dvertex_vertex_integer_coords ((const t8_dvertex_t *) elem, vertex, coords); } void -t8_default_scheme_vertex_c::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, - double coords[]) const +t8_default_scheme_vertex::element_get_vertex_reference_coords (const t8_element_t *elem, const int vertex, + double coords[]) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (vertex == 0); @@ -267,8 +267,8 @@ t8_default_scheme_vertex_c::element_get_vertex_reference_coords (const t8_elemen } void -t8_default_scheme_vertex_c::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, - const size_t num_coords, double *out_coords) const +t8_default_scheme_vertex::element_get_reference_coords (const t8_element_t *elem, const double *ref_coords, + const size_t num_coords, double *out_coords) const { T8_ASSERT (element_is_valid (elem)); t8_dvertex_compute_reference_coords ((const t8_dvertex_t *) elem, ref_coords, num_coords, out_coords); @@ -276,15 +276,14 @@ t8_default_scheme_vertex_c::element_get_reference_coords (const t8_element_t *el #ifdef T8_ENABLE_DEBUG int -t8_default_scheme_vertex_c::element_is_valid (const t8_element_t *elem) const +t8_default_scheme_vertex::element_is_valid (const t8_element_t *elem) const { return t8_dvertex_is_valid ((const t8_dvertex_t *) elem); } void -t8_default_scheme_vertex_c::element_to_string (const t8_element_t *elem, char *debug_string, - const int string_size) const +t8_default_scheme_vertex::element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const { T8_ASSERT (element_is_valid (elem)); T8_ASSERT (debug_string != NULL); @@ -294,17 +293,17 @@ t8_default_scheme_vertex_c::element_to_string (const t8_element_t *elem, char *d #endif int -t8_default_scheme_vertex_c::refines_irregular () const +t8_default_scheme_vertex::refines_irregular () const { /*vertices refine regularly */ return 0; } void -t8_default_scheme_vertex_c::element_new (int length, t8_element_t **elem) const +t8_default_scheme_vertex::element_new (int length, t8_element_t **elem) const { /* allocate memory for a vertex */ - t8_default_scheme_common_c::element_new (length, elem); + t8_default_scheme_common::element_new (length, elem); /* in debug mode, set sensible default values. */ #ifdef T8_ENABLE_DEBUG @@ -318,7 +317,7 @@ t8_default_scheme_vertex_c::element_new (int length, t8_element_t **elem) const } void -t8_default_scheme_vertex_c::element_init (int length, t8_element_t *elem) const +t8_default_scheme_vertex::element_init (int length, t8_element_t *elem) const { #ifdef T8_ENABLE_DEBUG t8_dvertex_t *vertexs = (t8_dvertex_t *) elem; @@ -328,34 +327,16 @@ t8_default_scheme_vertex_c::element_init (int length, t8_element_t *elem) const #endif } -/* Constructor */ -t8_default_scheme_vertex_c::t8_default_scheme_vertex_c (void) -{ - eclass = T8_ECLASS_VERTEX; - element_size = sizeof (t8_dvertex_t); - ts_context = sc_mempool_new (element_size); -} - -/* Destructor */ -t8_default_scheme_vertex_c::~t8_default_scheme_vertex_c () -{ - /* This destructor is empty since the destructor of the - * default_common scheme is called automatically and it - * suffices to destroy the quad_scheme. - * However we need to provide an implementation of the destructor - * and hence this empty function. */ -} void -t8_default_scheme_vertex_c::get_root (t8_element_t *elem) const +t8_default_scheme_vertex::get_root (t8_element_t *elem) const { t8_dvertex_t *vertex = (t8_dvertex_t *) elem; vertex->level = 0; } /* vertices are packed as the level */ void -t8_default_scheme_vertex_c::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, - void *send_buffer, const int buffer_size, int *position, - sc_MPI_Comm comm) const +t8_default_scheme_vertex::element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, + const int buffer_size, int *position, sc_MPI_Comm comm) const { int mpiret; t8_dvertex_t **vertices = (t8_dvertex_t **) elements; @@ -367,7 +348,7 @@ t8_default_scheme_vertex_c::element_MPI_Pack (t8_element_t **const elements, con /* vertices are packed as the level */ void -t8_default_scheme_vertex_c::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const +t8_default_scheme_vertex::element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const { int singlesize = 0; int datasize = 0; @@ -382,9 +363,8 @@ t8_default_scheme_vertex_c::element_MPI_Pack_size (const unsigned int count, sc_ /* vertices are packed as the level */ void -t8_default_scheme_vertex_c::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, - t8_element_t **elements, const unsigned int count, - sc_MPI_Comm comm) const +t8_default_scheme_vertex::element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, + t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const { int mpiret; t8_dvertex_t **vertices = (t8_dvertex_t **) elements; diff --git a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx index d1c026a993..aed64dd093 100644 --- a/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx +++ b/src/t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.hxx @@ -32,15 +32,15 @@ #include #include #include +#include -class t8_default_scheme_vertex_c: - public t8_eclass_scheme, - public t8_default_scheme_common_c { +class t8_default_scheme_vertex: private t8_default_scheme_common { public: /** Constructor. */ - t8_default_scheme_vertex_c (); + t8_default_scheme_vertex () + : t8_default_scheme_common (T8_ECLASS_VERTEX, sizeof (t8_dvertex_t)) {}; - ~t8_default_scheme_vertex_c (); + ~t8_default_scheme_vertex () {}; /** Return the size of a vertex element. * \return The size of an element of class vertex. diff --git a/src/t8_schemes/t8_scheme.hxx b/src/t8_schemes/t8_scheme.hxx index 15b0acc6ba..614eaab538 100644 --- a/src/t8_schemes/t8_scheme.hxx +++ b/src/t8_schemes/t8_scheme.hxx @@ -23,6 +23,8 @@ #pragma once #include +#include +#include #include #include @@ -32,28 +34,65 @@ class t8_scheme { friend class t8_scheme_builder; public: - t8_scheme () {}; - ~t8_scheme () {}; + t8_scheme () + { + t8_refcount_init (&rc); + }; + + ~t8_scheme () + { + if (sc_refcount_is_active (&rc)) { + T8_ASSERT (t8_refcount_is_last (&rc)); + t8_refcount_unref (&rc); + } + t8_debugf ("Deleted the scheme.\n"); + }; /* clang-format off */ + + /** Variant to hold an eclass scheme. */ using scheme_var = std::variant< /* Default schemes */ - t8_default_scheme_vertex_c, - t8_default_scheme_line_c, - t8_default_scheme_quad_c, - t8_default_scheme_tri_c, - t8_default_scheme_hex_c, - t8_default_scheme_tet_c, - t8_default_scheme_prism_c, - t8_default_scheme_pyramid_c + t8_default_scheme_vertex, + t8_default_scheme_line, + t8_default_scheme_quad, + t8_default_scheme_tri, + t8_default_scheme_hex, + t8_default_scheme_tet, + t8_default_scheme_prism, + t8_default_scheme_pyramid >; /* clang-format on */ - using scheme_container = std::array; + + using scheme_container = std::array; /**< Container type for holding eclass schemes. */ private: - scheme_container eclass_schemes; + scheme_container eclass_schemes; /**< The container holding the eclass schemes. */ + t8_refcount_t rc; /**< The reference count of the scheme. TODO: Replace by shared_ptr when forest becomes a class. */ public: + /** + * Increase the reference count of the scheme. + */ + inline void + ref () + { + t8_refcount_ref (&rc); + } + + /** + * Decrease the reference count of the scheme. + * If the reference count reaches zero, the scheme is deleted. + */ + inline void + unref () + { + if (t8_refcount_unref (&rc)) { + t8_debugf ("Deleting the geometry_handler.\n"); + delete this; + } + } + /** Return the size of any element of a given class. * \param [in] tree_class The eclass of the current tree. * \return The size of an element of class \a tree_class. diff --git a/src/t8_schemes/t8_scheme_builder.hxx b/src/t8_schemes/t8_scheme_builder.hxx index f869876fdd..35e11cac94 100644 --- a/src/t8_schemes/t8_scheme_builder.hxx +++ b/src/t8_schemes/t8_scheme_builder.hxx @@ -31,25 +31,25 @@ class Scheme_builder { public: - Scheme_builder () {}; + Scheme_builder (): scheme (new t8_scheme) {}; ~Scheme_builder () {}; - using Scheme_v = Scheme::Scheme_v; + using scheme_var = t8_scheme::scheme_var; - template + template void - add_eclass_scheme (eclass tree_class, _args &&...args) + add_eclass_scheme (t8_eclass_t tree_class, _Args &&...args) { - scheme.eclass_schemes[tree_class] = Multilevel_element_scheme (std::forward<_args> (args)...); + scheme->eclass_schemes[tree_class] = TEclass_Scheme (std::forward<_Args> (args)...); } - const Scheme + const t8_scheme * build_scheme () const { return scheme; } private: - Scheme scheme; + t8_scheme *scheme; bool multilevel; }; diff --git a/test/t8_schemes/t8_gtest_default.cxx b/test/t8_schemes/t8_gtest_default.cxx index 84573ac09e..33a02125e6 100644 --- a/test/t8_schemes/t8_gtest_default.cxx +++ b/test/t8_schemes/t8_gtest_default.cxx @@ -46,28 +46,28 @@ class gtest_default_scheme: public testing::TestWithParam { const t8_eclass_t eclass = GetParam (); switch (eclass) { case T8_ECLASS_VERTEX: - eclass_scheme = new t8_default_scheme_vertex_c (); + eclass_scheme = new t8_default_scheme_vertex (); break; case T8_ECLASS_LINE: - eclass_scheme = new t8_default_scheme_line_c (); + eclass_scheme = new t8_default_scheme_line (); break; case T8_ECLASS_QUAD: - eclass_scheme = new t8_default_scheme_quad_c (); + eclass_scheme = new t8_default_scheme_quad (); break; case T8_ECLASS_TRIANGLE: - eclass_scheme = new t8_default_scheme_tri_c (); + eclass_scheme = new t8_default_scheme_tri (); break; case T8_ECLASS_HEX: - eclass_scheme = new t8_default_scheme_hex_c (); + eclass_scheme = new t8_default_scheme_hex (); break; case T8_ECLASS_TET: - eclass_scheme = new t8_default_scheme_tet_c (); + eclass_scheme = new t8_default_scheme_tet (); break; case T8_ECLASS_PRISM: - eclass_scheme = new t8_default_scheme_prism_c (); + eclass_scheme = new t8_default_scheme_prism (); break; case T8_ECLASS_PYRAMID: - eclass_scheme = new t8_default_scheme_pyramid_c (); + eclass_scheme = new t8_default_scheme_pyramid (); break; default: SC_ABORT_NOT_REACHED (); From 332a32c7650b1de06191c5ac47b2520befa98a45 Mon Sep 17 00:00:00 2001 From: Sandro Elsweijer Date: Fri, 8 Nov 2024 15:04:37 +0100 Subject: [PATCH 11/11] capturing progress --- .../t8_fortran_interface.c | 2 +- benchmarks/ExtremeScaling/bunny.cxx | 4 +- benchmarks/t8_time_fractal.cxx | 2 +- benchmarks/t8_time_prism_adapt.cxx | 2 +- benchmarks/time_forest_partition.cxx | 4 +- benchmarks/time_new_refine.c | 4 +- .../gmsh/t8_load_and_refine_square_w_hole.cxx | 4 +- example/IO/cmesh/gmsh/t8_read_msh_file.cxx | 2 +- example/IO/cmesh/t8_cmesh_load_save.cxx | 4 +- .../IO/cmesh/tetgen/t8_forest_from_tetgen.cxx | 2 +- .../cmesh/triangle/t8_read_triangle_file.cxx | 2 +- .../IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx | 4 +- example/IO/forest/gmsh/t8_gmsh_to_vtk.cxx | 2 +- .../forest/netcdf/t8_write_forest_netcdf.cxx | 4 +- example/advect/t8_advection.cxx | 4 +- example/cmesh/t8_cmesh_geometry_examples.cxx | 18 ++--- example/cmesh/t8_cmesh_hypercube_pad.cxx | 2 +- example/cmesh/t8_cmesh_partition.cxx | 2 +- example/forest/t8_test_face_iterate.cxx | 4 +- example/forest/t8_test_ghost.cxx | 4 +- .../forest/t8_test_ghost_large_level_diff.cxx | 27 ++++---- example/geometry/t8_example_geometries.cxx | 2 +- example/remove/t8_example_empty_trees.cxx | 2 +- example/remove/t8_example_gauss_blob.cxx | 2 +- example/remove/t8_example_spheres.cxx | 2 +- src/t8_cmesh/t8_cmesh_examples.cxx | 4 +- .../t8_geometry_lagrange.cxx | 2 +- src/t8_schemes/t8_default/t8_default.cxx | 68 ++++++------------- src/t8_schemes/t8_default/t8_default.hxx | 13 ++-- .../t8_default/t8_default_c_interface.h | 13 ++-- src/t8_schemes/t8_scheme.hxx | 12 ++++ src/t8_schemes/t8_scheme_builder.hxx | 8 +-- test/t8_IO/t8_gtest_vtk_writer.cxx | 2 +- test/t8_cmesh/t8_gtest_cmesh_partition.cxx | 4 +- .../t8_cmesh/t8_gtest_multiple_attributes.cxx | 2 +- test/t8_forest/t8_gtest_balance.cxx | 4 +- test/t8_forest/t8_gtest_element_is_leaf.cxx | 2 +- test/t8_forest/t8_gtest_element_volume.cxx | 2 +- test/t8_forest/t8_gtest_find_owner.cxx | 2 +- test/t8_forest/t8_gtest_forest_commit.cxx | 2 +- .../t8_forest/t8_gtest_forest_face_normal.cxx | 2 +- test/t8_forest/t8_gtest_ghost_and_owner.cxx | 2 +- test/t8_forest/t8_gtest_ghost_delete.cxx | 2 +- test/t8_forest/t8_gtest_ghost_exchange.cxx | 2 +- test/t8_forest/t8_gtest_half_neighbors.cxx | 2 +- test/t8_forest/t8_gtest_partition_data.cxx | 2 +- test/t8_forest/t8_gtest_search.cxx | 2 +- test/t8_forest/t8_gtest_transform.cxx | 2 +- test/t8_forest/t8_gtest_user_data.cxx | 4 +- .../t8_gtest_empty_global_tree.cxx | 4 +- .../t8_gtest_empty_local_tree.cxx | 2 +- .../t8_gtest_iterate_replace.cxx | 2 +- .../t8_gtest_permute_hole.cxx | 2 +- .../t8_gtest_recursive.cxx | 2 +- test/t8_geometry/t8_gtest_point_inside.cxx | 6 +- test/t8_schemes/t8_gtest_ancestor.cxx | 2 +- test/t8_schemes/t8_gtest_default.cxx | 54 ++------------- test/t8_schemes/t8_gtest_descendant.cxx | 2 +- test/t8_schemes/t8_gtest_dfs_base.hxx | 2 +- .../t8_gtest_element_count_leaves.cxx | 2 +- .../t8_gtest_element_ref_coords.cxx | 2 +- test/t8_schemes/t8_gtest_face_neigh.cxx | 2 +- test/t8_schemes/t8_gtest_init_linear_id.cxx | 2 +- test/t8_schemes/t8_gtest_nca.cxx | 2 +- test/t8_schemes/t8_gtest_root.cxx | 2 +- test/t8_schemes/t8_gtest_successor.cxx | 2 +- .../features/t8_features_curved_meshes.cxx | 2 +- tutorials/general/t8_step2_uniform_forest.cxx | 2 +- tutorials/general/t8_step3_adapt_forest.cxx | 2 +- .../t8_step4_partition_balance_ghost.cxx | 2 +- tutorials/general/t8_step5_element_data.cxx | 2 +- .../t8_step5_element_data_c_interface.c | 2 +- tutorials/general/t8_step6_stencil.cxx | 2 +- tutorials/general/t8_step7_interpolation.cxx | 2 +- tutorials/general/t8_tutorial_search.cxx | 2 +- 75 files changed, 165 insertions(+), 216 deletions(-) diff --git a/api/t8_fortran_interface/t8_fortran_interface.c b/api/t8_fortran_interface/t8_fortran_interface.c index e594dd1afa..ddb5c05767 100644 --- a/api/t8_fortran_interface/t8_fortran_interface.c +++ b/api/t8_fortran_interface/t8_fortran_interface.c @@ -117,7 +117,7 @@ t8_cmesh_new_periodic_tri_wrap (sc_MPI_Comm *Ccomm) t8_forest_t t8_forest_new_uniform_default (t8_cmesh_t cmesh, int level, int do_face_ghost, sc_MPI_Comm *comm) { - t8_scheme_c *default_scheme = t8_scheme_new_default_cxx (); + t8_scheme_c *default_scheme = t8_scheme_new_default (); T8_ASSERT (comm != NULL); return t8_forest_new_uniform (cmesh, default_scheme, level, do_face_ghost, *comm); diff --git a/benchmarks/ExtremeScaling/bunny.cxx b/benchmarks/ExtremeScaling/bunny.cxx index 25a53a3f9c..be663fa048 100644 --- a/benchmarks/ExtremeScaling/bunny.cxx +++ b/benchmarks/ExtremeScaling/bunny.cxx @@ -196,7 +196,7 @@ main (int argc, char **argv) t8_forest_init (&forest_p8); t8_forest_set_cmesh (forest_p8, cmesh_p8, sc_MPI_COMM_WORLD); t8_forest_set_level (forest_p8, level); - t8_forest_set_scheme (forest_p8, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest_p8, t8_scheme_new_default ()); sc_flops_shot (&fi, &snapshot); sc_stats_set1 (&stats[5], snapshot.iwtime, "t8 forest p8 New level 4"); sc_flops_snap (&fi, &snapshot); @@ -227,7 +227,7 @@ main (int argc, char **argv) t8_forest_init (&forest_t8); t8_forest_set_cmesh (forest_t8, cmesh_p8, sc_MPI_COMM_WORLD); t8_forest_set_level (forest_t8, level); - t8_forest_set_scheme (forest_t8, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest_t8, t8_scheme_new_default ()); sc_flops_shot (&fi, &snapshot); sc_stats_set1 (&stats[7], snapshot.iwtime, "t8 forest t8 New Level 4"); sc_flops_snap (&fi, &snapshot); diff --git a/benchmarks/t8_time_fractal.cxx b/benchmarks/t8_time_fractal.cxx index d0cffdee69..71988c2f91 100644 --- a/benchmarks/t8_time_fractal.cxx +++ b/benchmarks/t8_time_fractal.cxx @@ -278,7 +278,7 @@ t8_construct_fractal (int level_initial, int level_end, const int iterative, con t8_forest_init (&forest); t8_forest_set_cmesh (forest, cmesh, sc_MPI_COMM_WORLD); - t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest, t8_scheme_new_default ()); t8_forest_set_level (forest, level_initial); t8_forest_commit (forest); diff --git a/benchmarks/t8_time_prism_adapt.cxx b/benchmarks/t8_time_prism_adapt.cxx index d31459c76b..b9e7c6b89a 100644 --- a/benchmarks/t8_time_prism_adapt.cxx +++ b/benchmarks/t8_time_prism_adapt.cxx @@ -97,7 +97,7 @@ t8_time_refine (int start_level, int end_level, int create_forest, int cube, int else { t8_forest_set_cmesh (forest, t8_cmesh_new_hypercube (eclass, sc_MPI_COMM_WORLD, 0, 0, 0), sc_MPI_COMM_WORLD); } - t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest, t8_scheme_new_default ()); t8_forest_set_level (forest, start_level); sc_flops_start (&fi); sc_flops_snap (&fi, &snapshot); diff --git a/benchmarks/time_forest_partition.cxx b/benchmarks/time_forest_partition.cxx index bfa523b501..04632b95c2 100644 --- a/benchmarks/time_forest_partition.cxx +++ b/benchmarks/time_forest_partition.cxx @@ -199,7 +199,7 @@ t8_time_forest_cmesh_mshfile (t8_cmesh_t cmesh, const char *vtu_prefix, sc_MPI_C t8_forest_init (&forest); t8_forest_set_cmesh (forest, cmesh, comm); /* Set the element scheme */ - t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest, t8_scheme_new_default ()); /* Set the initial refinement level */ t8_forest_set_level (forest, init_level); /* Commit the forest */ @@ -324,7 +324,7 @@ t8_time_forest_create_cmesh (const char *msh_file, int mesh_dim, const char *cme /* partition the cmesh uniformly */ t8_cmesh_init (&cmesh_partition); t8_cmesh_set_derive (cmesh_partition, cmesh); - t8_cmesh_set_partition_uniform (cmesh_partition, init_level, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, init_level, t8_scheme_new_default ()); t8_cmesh_set_profiling (cmesh_partition, 1); t8_cmesh_commit (cmesh_partition, comm); return cmesh_partition; diff --git a/benchmarks/time_new_refine.c b/benchmarks/time_new_refine.c index 8bb1bdb245..90dcbb58f1 100644 --- a/benchmarks/time_new_refine.c +++ b/benchmarks/time_new_refine.c @@ -83,7 +83,7 @@ t8_timings_adapt (int start_l, int end_l, int runs, int dim) t8_cmesh_new_hypercube (eclass, sc_MPI_COMM_WORLD, 0), 0); */ t8_forest_set_cmesh (forests[0], t8_cmesh_new_bigmesh (eclass, 512, sc_MPI_COMM_WORLD), sc_MPI_COMM_WORLD); - t8_forest_set_scheme (forests[0], t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forests[0], t8_scheme_new_default ()); t8_forest_set_level (forests[0], start_l); t8_forest_commit (forests[0]); @@ -132,7 +132,7 @@ t8_timings_new (int level, int dim) t8_forest_init (&forest); t8_forest_set_cmesh (forest, t8_cmesh_new_hypercube (eclass, sc_MPI_COMM_WORLD, 0, 0, 0), sc_MPI_COMM_WORLD); - t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest, t8_scheme_new_default ()); t8_forest_set_level (forest, level); t8_forest_commit (forest); diff --git a/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx b/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx index 69c89c5258..452149901d 100644 --- a/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx +++ b/example/IO/cmesh/gmsh/t8_load_and_refine_square_w_hole.cxx @@ -149,12 +149,12 @@ t8_load_refine_build_forest (t8_cmesh_t cmesh, sc_MPI_Comm comm, int level) t8_cmesh_t cmesh_partition; t8_cmesh_init (&cmesh_partition); - t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default ()); t8_cmesh_set_derive (cmesh_partition, cmesh); t8_cmesh_commit (cmesh_partition, comm); t8_forest_init (&forest); - t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest, t8_scheme_new_default ()); t8_forest_set_cmesh (forest, cmesh_partition, comm); t8_forest_set_level (forest, level); t8_forest_commit (forest); diff --git a/example/IO/cmesh/gmsh/t8_read_msh_file.cxx b/example/IO/cmesh/gmsh/t8_read_msh_file.cxx index 48616cf92f..3eed365432 100644 --- a/example/IO/cmesh/gmsh/t8_read_msh_file.cxx +++ b/example/IO/cmesh/gmsh/t8_read_msh_file.cxx @@ -59,7 +59,7 @@ t8_read_msh_partition (t8_cmesh_t cmesh, const char *prefix) t8_cmesh_init (&p_mesh); t8_cmesh_set_derive (p_mesh, cmesh); - t8_cmesh_set_partition_uniform (p_mesh, 0, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (p_mesh, 0, t8_scheme_new_default ()); t8_cmesh_commit (p_mesh, sc_MPI_COMM_WORLD); snprintf (vtk_prefix, BUFSIZ, "%s_partition", prefix); t8_read_msh_file_vtk (p_mesh, vtk_prefix); diff --git a/example/IO/cmesh/t8_cmesh_load_save.cxx b/example/IO/cmesh/t8_cmesh_load_save.cxx index c4d2aa8a5d..b867b7bd51 100644 --- a/example/IO/cmesh/t8_cmesh_load_save.cxx +++ b/example/IO/cmesh/t8_cmesh_load_save.cxx @@ -44,7 +44,7 @@ t8_cmesh_load_distribute (const char *fileprefix, int num_files, int no_vtk) } t8_cmesh_init (&cmesh_partition); t8_cmesh_set_derive (cmesh_partition, cmesh); - t8_cmesh_set_partition_uniform (cmesh_partition, 0, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, 0, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_partition, sc_MPI_COMM_WORLD); if (!no_vtk) { t8_cmesh_vtk_write_file (cmesh_partition, "cmesh_dist_loaded_partition"); @@ -67,7 +67,7 @@ t8_cmesh_save_cmesh (const char *mshfile, int dim) cmesh = t8_cmesh_from_msh_file (mshfile, 1, sc_MPI_COMM_WORLD, dim, 0, 0); t8_cmesh_init (&cmesh_partition); t8_cmesh_set_derive (cmesh_partition, cmesh); - t8_cmesh_set_partition_uniform (cmesh_partition, 0, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, 0, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_partition, sc_MPI_COMM_WORLD); cmesh = cmesh_partition; } diff --git a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx index b6a86273c7..c2993793b3 100644 --- a/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx +++ b/example/IO/cmesh/tetgen/t8_forest_from_tetgen.cxx @@ -67,7 +67,7 @@ t8_forest_from_cmesh (t8_cmesh_t cmesh, int level, const char *prefix) t8_debugf ("Construct Forest from Tetmesh\n"); t8_forest_init (&forest); t8_forest_set_cmesh (forest, cmesh, sc_MPI_COMM_WORLD); - t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest, t8_scheme_new_default ()); t8_forest_set_level (forest, level); t8_forest_commit (forest); t8_debugf ("Committed forest. Has %i elements.\n", t8_forest_get_local_num_elements (forest)); diff --git a/example/IO/cmesh/triangle/t8_read_triangle_file.cxx b/example/IO/cmesh/triangle/t8_read_triangle_file.cxx index b1a21c6c08..25ea9f5ddf 100644 --- a/example/IO/cmesh/triangle/t8_read_triangle_file.cxx +++ b/example/IO/cmesh/triangle/t8_read_triangle_file.cxx @@ -46,7 +46,7 @@ t8_read_triangle_file_build_cmesh (const char *prefix, int do_dup, int do_partit t8_cmesh_init (&cmesh_part); t8_cmesh_ref (cmesh); t8_cmesh_set_derive (cmesh_part, cmesh); - t8_cmesh_set_partition_uniform (cmesh_part, 1, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_part, 1, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_part, sc_MPI_COMM_WORLD); snprintf (fileprefix, BUFSIZ, "%s_t8_triangle_partition", prefix); if (!t8_cmesh_vtk_write_file (cmesh_part, fileprefix)) { diff --git a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx index 05a742f18f..91eb788b7f 100644 --- a/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx +++ b/example/IO/cmesh/vtk/t8_cmesh_read_from_vtk.cxx @@ -55,7 +55,7 @@ t8_forest_construct_from_vtk (const char *prefix, sc_MPI_Comm comm, const int va if (partition) { t8_cmesh_init (&cmesh); t8_cmesh_set_derive (cmesh, cmesh_in); - t8_cmesh_set_partition_uniform (cmesh, 0, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh, 0, t8_scheme_new_default ()); t8_cmesh_commit (cmesh, comm); snprintf (out_file, BUFSIZ - 16, "%s_cmesh_partition", out_prefix); t8_cmesh_vtk_write_file (cmesh, out_file); @@ -70,7 +70,7 @@ t8_forest_construct_from_vtk (const char *prefix, sc_MPI_Comm comm, const int va /* Initialize the cmesh of the forest */ t8_forest_set_cmesh (forest, cmesh, sc_MPI_COMM_WORLD); /* Set the scheme of the forest. In this case, the default schemes are used */ - t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest, t8_scheme_new_default ()); t8_forest_commit (forest); t8_vtk_data_field_t *vtk_data; diff --git a/example/IO/forest/gmsh/t8_gmsh_to_vtk.cxx b/example/IO/forest/gmsh/t8_gmsh_to_vtk.cxx index fb8c862b89..3c07ebaf49 100644 --- a/example/IO/forest/gmsh/t8_gmsh_to_vtk.cxx +++ b/example/IO/forest/gmsh/t8_gmsh_to_vtk.cxx @@ -97,7 +97,7 @@ main (int argc, char **argv) cmesh = t8_cmesh_from_msh_file (fileprefix, 0, sc_MPI_COMM_WORLD, dim, 0, use_cad); // Construct a forest from the cmesh. - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), level, 0, comm); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), level, 0, comm); T8_ASSERT (t8_forest_is_committed (forest)); { diff --git a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx index 6699ec2e39..e32e8ddd86 100644 --- a/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx +++ b/example/IO/forest/netcdf/t8_write_forest_netcdf.cxx @@ -195,7 +195,7 @@ t8_example_compare_performance_netcdf_var_properties (sc_MPI_Comm comm, int fore retval = sc_MPI_Comm_rank (comm, &mpirank); SC_CHECK_MPI (retval); /* Create a default scheme */ - default_scheme = t8_scheme_new_default_cxx (); + default_scheme = t8_scheme_new_default (); /* Construct a 3D hybrid hypercube as a cmesh */ cmesh = t8_cmesh_new_hypercube_hybrid (comm, 1, 0); @@ -343,7 +343,7 @@ t8_example_netcdf_write_forest (sc_MPI_Comm comm, int forest_refinement_level, i SC_CHECK_MPI (retval); /* Create a default scheme */ - default_scheme = t8_scheme_new_default_cxx (); + default_scheme = t8_scheme_new_default (); /* Construct a cube coarse mesh */ /* Construct a 3D hybrid hypercube as a cmesh */ diff --git a/example/advect/t8_advection.cxx b/example/advect/t8_advection.cxx index 51c4e3b084..146c609c99 100644 --- a/example/advect/t8_advection.cxx +++ b/example/advect/t8_advection.cxx @@ -851,7 +851,7 @@ t8_advect_create_cmesh (sc_MPI_Comm comm, int cube_type, const char *mshfile, in } /* partition this cmesh according to the initial refinement level */ t8_cmesh_init (&cmesh_partition); - t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default ()); t8_cmesh_set_derive (cmesh_partition, cmesh); t8_cmesh_commit (cmesh_partition, comm); return cmesh_partition; @@ -937,7 +937,7 @@ t8_advect_problem_init (t8_cmesh_t cmesh, t8_flow_function_3d_fn u, t8_example_l } /* Construct uniform forest with ghosts */ - default_scheme = t8_scheme_new_default_cxx (); + default_scheme = t8_scheme_new_default (); problem->forest = t8_forest_new_uniform (cmesh, default_scheme, level, 1, comm); diff --git a/example/cmesh/t8_cmesh_geometry_examples.cxx b/example/cmesh/t8_cmesh_geometry_examples.cxx index 99575d20d1..10b273694f 100644 --- a/example/cmesh/t8_cmesh_geometry_examples.cxx +++ b/example/cmesh/t8_cmesh_geometry_examples.cxx @@ -119,7 +119,7 @@ main (int argc, char **argv) t8_cmesh_t cmesh = t8_cmesh_new_quadrangulated_disk (radius, comm); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); @@ -139,7 +139,7 @@ main (int argc, char **argv) t8_cmesh_t cmesh = t8_cmesh_new_triangulated_spherical_surface_octahedron (radius, comm); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); @@ -159,7 +159,7 @@ main (int argc, char **argv) t8_cmesh_t cmesh = t8_cmesh_new_triangulated_spherical_surface_icosahedron (radius, comm); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); @@ -179,7 +179,7 @@ main (int argc, char **argv) t8_cmesh_t cmesh = t8_cmesh_new_triangulated_spherical_surface_cube (radius, comm); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); @@ -199,7 +199,7 @@ main (int argc, char **argv) t8_cmesh_t cmesh = t8_cmesh_new_quadrangulated_spherical_surface (radius, comm); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); @@ -224,7 +224,7 @@ main (int argc, char **argv) t8_cmesh_t cmesh = t8_cmesh_new_cubed_spherical_shell (inner_radius, shell_thickness, num_levels, num_layers, comm); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); @@ -248,7 +248,7 @@ main (int argc, char **argv) t8_cmesh_t cmesh = t8_cmesh_new_prismed_spherical_shell_octahedron (inner_radius, shell_thickness, num_levels, num_layers, comm); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); @@ -272,7 +272,7 @@ main (int argc, char **argv) t8_cmesh_t cmesh = t8_cmesh_new_prismed_spherical_shell_icosahedron (inner_radius, shell_thickness, num_levels, num_layers, comm); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); @@ -292,7 +292,7 @@ main (int argc, char **argv) t8_cmesh_t cmesh = t8_cmesh_new_cubed_sphere (radius, comm); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, comm); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, comm); t8_cmesh_vtk_write_file (cmesh, prefix_cmesh); t8_global_productionf ("Wrote %s.pvtu\n", prefix_cmesh); diff --git a/example/cmesh/t8_cmesh_hypercube_pad.cxx b/example/cmesh/t8_cmesh_hypercube_pad.cxx index 3b023caba5..037c3a661c 100644 --- a/example/cmesh/t8_cmesh_hypercube_pad.cxx +++ b/example/cmesh/t8_cmesh_hypercube_pad.cxx @@ -54,7 +54,7 @@ main (int argc, char **argv) t8_global_productionf (" [step1] Created coarse mesh.\n"); t8_global_productionf (" [step1] Local number of trees:\t%i\n", local_num_trees); t8_global_productionf (" [step1] Global number of trees:\t%li\n", global_num_trees); - t8_scheme *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default (); t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, 0, 0, sc_MPI_COMM_WORLD); t8_forest_vtk_write_file (forest, prefix, 1, 1, 1, 1, 0, 0, NULL); t8_forest_unref (&forest); diff --git a/example/cmesh/t8_cmesh_partition.cxx b/example/cmesh/t8_cmesh_partition.cxx index fe2d8d7755..f001e6e209 100644 --- a/example/cmesh/t8_cmesh_partition.cxx +++ b/example/cmesh/t8_cmesh_partition.cxx @@ -108,7 +108,7 @@ t8_partition (int level, int partition_from) /* We still need access to cmesh later */ t8_cmesh_ref (cmesh); t8_cmesh_set_derive (cmesh_part, cmesh); - t8_cmesh_set_partition_uniform (cmesh_part, level, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_part, level, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_part, sc_MPI_COMM_WORLD); if (mpisize > 1 && 1) { t8_cmesh_init (&cmesh_part2); diff --git a/example/forest/t8_test_face_iterate.cxx b/example/forest/t8_test_face_iterate.cxx index 8da5435750..9e82722880 100644 --- a/example/forest/t8_test_face_iterate.cxx +++ b/example/forest/t8_test_face_iterate.cxx @@ -116,7 +116,7 @@ t8_test_fiterate_refine_and_partition (t8_cmesh_t cmesh, int level, sc_MPI_Comm /* partition the initial cmesh according to a uniform forest */ t8_cmesh_init (&cmesh_partition); t8_cmesh_set_derive (cmesh_partition, cmesh); - t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_partition, comm); } else { @@ -126,7 +126,7 @@ t8_test_fiterate_refine_and_partition (t8_cmesh_t cmesh, int level, sc_MPI_Comm if (!no_vtk) { t8_cmesh_vtk_write_file (cmesh_partition, "test_fiterate_cmesh1"); } - forest = t8_forest_new_uniform (cmesh_partition, t8_scheme_new_default_cxx (), level, 0, comm); + forest = t8_forest_new_uniform (cmesh_partition, t8_scheme_new_default (), level, 0, comm); t8_test_fiterate (forest); t8_forest_init (&forest_adapt); diff --git a/example/forest/t8_test_ghost.cxx b/example/forest/t8_test_ghost.cxx index 75750dd500..cfbbedcfb8 100644 --- a/example/forest/t8_test_ghost.cxx +++ b/example/forest/t8_test_ghost.cxx @@ -125,7 +125,7 @@ t8_test_ghost_refine_and_partition (t8_cmesh_t cmesh, const int level, sc_MPI_Co /* partition the initial cmesh according to a uniform forest */ t8_cmesh_init (&cmesh_partition); t8_cmesh_set_derive (cmesh_partition, cmesh); - t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_partition, comm); } else { @@ -135,7 +135,7 @@ t8_test_ghost_refine_and_partition (t8_cmesh_t cmesh, const int level, sc_MPI_Co if (!no_vtk) { t8_cmesh_vtk_write_file (cmesh_partition, "test_ghost_cmesh1"); } - forest = t8_forest_new_uniform (cmesh_partition, t8_scheme_new_default_cxx (), level, 1, comm); + forest = t8_forest_new_uniform (cmesh_partition, t8_scheme_new_default (), level, 1, comm); /* adapt (if desired), partition and create ghosts for the forest */ t8_forest_init (&forest_ghost); diff --git a/example/forest/t8_test_ghost_large_level_diff.cxx b/example/forest/t8_test_ghost_large_level_diff.cxx index 541433e823..b4cfea288b 100644 --- a/example/forest/t8_test_ghost_large_level_diff.cxx +++ b/example/forest/t8_test_ghost_large_level_diff.cxx @@ -64,26 +64,27 @@ * If the mesh is not 3D then no element is refined. * * Warning: this refinement schemes only works with the default element - * scheme (see t8_scheme_new_default_cxx in t8_default/t8_default.hxx). + * scheme (see t8_scheme_new_default in t8_default/t8_default.hxx). */ static int -t8_ghost_fractal_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_locidx_t lelement_id, - t8_scheme *ts, const int is_family, const int num_elements, t8_element_t *elements[]) +t8_ghost_fractal_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_eclass_t tree_class, + t8_locidx_t lelement_id, t8_scheme *ts, int is_family, int num_elements, + t8_element_t *elements[]) { int level; int type, child_id; - T8_ASSERT (!is_family || num_elements == ts->t8_element_num_children (elements[0])); - T8_ASSERT (t8_eclass_scheme_is_default (ts)); + T8_ASSERT (!is_family || num_elements == ts->element_get_num_children (tree_class, elements[0])); + T8_ASSERT (t8_eclass_scheme_is_default (ts, tree_class)); - level = ts->t8_element_level (elements[0]); + level = ts->element_get_level (tree_class, elements[0]); if (level >= *(int *) t8_forest_get_user_data (forest)) { return 0; } - if (ts->eclass == T8_ECLASS_PRISM) { + if (tree_class == T8_ECLASS_PRISM) { type = ((t8_dprism_t *) elements[0])->tri.type; /* refine type 0 except those with child_id 3 or 4 */ if (type == 0) { - child_id = ts->t8_element_child_id (elements[0]); + child_id = ts->element_get_child_id (tree_class, elements[0]); /* Not refining */ if (child_id == 3 || child_id == 4) { return 0; @@ -95,7 +96,7 @@ t8_ghost_fractal_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t } return 0; } - else if (ts->eclass == T8_ECLASS_TET) { + else if (tree_class == T8_ECLASS_TET) { type = ((t8_dtet_t *) elements[0])->type; /* Refine tets of type 0, 3 or 5 */ if (type == 0 || type == 3 || type == 5) { @@ -103,8 +104,8 @@ t8_ghost_fractal_adapt (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t } return 0; } - else if (ts->eclass == T8_ECLASS_HEX) { - child_id = ts->t8_element_child_id (elements[0]); + else if (tree_class == T8_ECLASS_HEX) { + child_id = ts->element_get_child_id (tree_class, elements[0]); if (child_id == 0 || child_id == 3 || child_id == 5 || child_id == 6) { return 1; }; @@ -142,7 +143,7 @@ t8_ghost_large_level_diff (const char *prefix, int dim, int level, int refine, i } t8_cmesh_init (&cmesh_partition); t8_cmesh_set_derive (cmesh_partition, cmesh); - t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_partition, comm); if (!no_vtk) { t8_cmesh_vtk_write_file (cmesh_partition, "partitioned_cmesh"); @@ -151,7 +152,7 @@ t8_ghost_large_level_diff (const char *prefix, int dim, int level, int refine, i /* New */ t8_forest_init (&forest); t8_forest_set_cmesh (forest, cmesh_partition, comm); - t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest, t8_scheme_new_default ()); t8_forest_set_level (forest, level); sc_flops_start (&fi); sc_flops_snap (&fi, &snapshot); diff --git a/example/geometry/t8_example_geometries.cxx b/example/geometry/t8_example_geometries.cxx index 744582ba31..f3770c71e4 100644 --- a/example/geometry/t8_example_geometries.cxx +++ b/example/geometry/t8_example_geometries.cxx @@ -1022,7 +1022,7 @@ t8_analytic_geom (int level, t8_example_geom_type geom_type) * 2 and refine recursively only along the boundary. */ uniform_level = geom_type == T8_GEOM_CIRCLE ? SC_MIN (2, level) : level; /* Create a uniform forest */ - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), uniform_level, 0, sc_MPI_COMM_WORLD); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), uniform_level, 0, sc_MPI_COMM_WORLD); if (geom_type == T8_GEOM_CIRCLE) { t8_forest_t forest_adapt; /* Create a forest that is only refined at the tree boundaries. diff --git a/example/remove/t8_example_empty_trees.cxx b/example/remove/t8_example_empty_trees.cxx index 7447d27b49..34a6f746b3 100644 --- a/example/remove/t8_example_empty_trees.cxx +++ b/example/remove/t8_example_empty_trees.cxx @@ -55,7 +55,7 @@ t8_strip_of_quads (t8_gloidx_t num_trees, t8_gloidx_t empty_tree, const char **v t8_cmesh_t cmesh = t8_cmesh_new_hypercube_pad (T8_ECLASS_QUAD, sc_MPI_COMM_WORLD, boundary_coords, num_trees, 1, 0, use_axis_alined); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), 0, 0, sc_MPI_COMM_WORLD); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), 0, 0, sc_MPI_COMM_WORLD); t8_forest_write_vtk (forest, *vtuname); t8_debugf ("Output to %s\n", *vtuname); diff --git a/example/remove/t8_example_gauss_blob.cxx b/example/remove/t8_example_gauss_blob.cxx index dce89ce3d6..04632eee5e 100644 --- a/example/remove/t8_example_gauss_blob.cxx +++ b/example/remove/t8_example_gauss_blob.cxx @@ -151,7 +151,7 @@ t8_construct_spheres (const int initial_level, const double radius_inner, const * Its center is therefore the center of the corresponding surface. */ struct t8_adapt_data adapt_data = { remove_scope, radius_inner, radius_outer, { 0.5, 0.5, 0.5 } }; - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), initial_level, 0, sc_MPI_COMM_WORLD); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), initial_level, 0, sc_MPI_COMM_WORLD); forest = t8_forest_new_adapt (forest, t8_adapt_refine, 0, 0, &adapt_data); if (remove_scope > 0) { forest = t8_forest_new_adapt (forest, t8_adapt_remove, 0, 0, &adapt_data); diff --git a/example/remove/t8_example_spheres.cxx b/example/remove/t8_example_spheres.cxx index aedbc302d2..6bca767c8b 100644 --- a/example/remove/t8_example_spheres.cxx +++ b/example/remove/t8_example_spheres.cxx @@ -110,7 +110,7 @@ t8_construct_spheres (const int initial_level, const double radius_inner, const = { 1.0, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.5, 1.0, 0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0 }; struct t8_adapt_data adapt_data = { num_spheres, radius_inner, radius_outer, midpoints }; - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), initial_level, 0, sc_MPI_COMM_WORLD); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), initial_level, 0, sc_MPI_COMM_WORLD); forest = t8_forest_new_adapt (forest, t8_adapt_callback_refine, 0, 0, &adapt_data); forest = t8_forest_new_adapt (forest, t8_adapt_callback_remove, 0, 0, &adapt_data); diff --git a/src/t8_cmesh/t8_cmesh_examples.cxx b/src/t8_cmesh/t8_cmesh_examples.cxx index c56dad878e..46317bf01b 100644 --- a/src/t8_cmesh/t8_cmesh_examples.cxx +++ b/src/t8_cmesh/t8_cmesh_examples.cxx @@ -3288,8 +3288,8 @@ t8_cmesh_new_spherical_shell (t8_eclass_t eclass, t8_geometry_c *geometry, sc_MPI_Comm_split (comm, mpi_rank, mpi_rank, &local_comm); /* Create 2D quadrangulated spherical surface of given refinement level per patch. */ - t8_forest_t forest = t8_forest_new_uniform (inner_sphere_creator (inner_radius, local_comm), - t8_scheme_new_default_cxx (), num_levels, 0, local_comm); + t8_forest_t forest = t8_forest_new_uniform (inner_sphere_creator (inner_radius, local_comm), t8_scheme_new_default (), + num_levels, 0, local_comm); /* clang-format off */ const int ntrees = t8_forest_get_local_num_elements (forest) * num_layers; /* Number of 3D cmesh elements resp. trees. */ diff --git a/src/t8_geometry/t8_geometry_implementations/t8_geometry_lagrange.cxx b/src/t8_geometry/t8_geometry_implementations/t8_geometry_lagrange.cxx index f151a90ee5..75b26fd5c6 100644 --- a/src/t8_geometry/t8_geometry_implementations/t8_geometry_lagrange.cxx +++ b/src/t8_geometry/t8_geometry_implementations/t8_geometry_lagrange.cxx @@ -259,7 +259,7 @@ t8_forest_t t8_lagrange_element::create_uniform_forest (t8_cmesh_t cmesh, uint32_t level) const { t8_forest_t forest; - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), level, 0, sc_MPI_COMM_WORLD); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), level, 0, sc_MPI_COMM_WORLD); return forest; } diff --git a/src/t8_schemes/t8_default/t8_default.cxx b/src/t8_schemes/t8_default/t8_default.cxx index 6371009961..268564e1c9 100644 --- a/src/t8_schemes/t8_default/t8_default.cxx +++ b/src/t8_schemes/t8_default/t8_default.cxx @@ -20,72 +20,48 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include #include -#include +#include /* We want to export the whole implementation to be callable from "C" */ T8_EXTERN_C_BEGIN (); t8_scheme * -t8_scheme_new_default_cxx (void) +t8_scheme_new_default (void) { - t8_scheme *s; + t8_scheme_builder builder; - s = T8_ALLOC_ZERO (t8_scheme, 1); - t8_refcount_init (&s->rc); - - s->eclass_schemes[T8_ECLASS_VERTEX] = new t8_default_scheme_vertex (); - s->eclass_schemes[T8_ECLASS_LINE] = new t8_default_scheme_line (); - s->eclass_schemes[T8_ECLASS_QUAD] = new t8_default_scheme_quad (); - s->eclass_schemes[T8_ECLASS_HEX] = new t8_default_scheme_hex (); - s->eclass_schemes[T8_ECLASS_TRIANGLE] = new t8_default_scheme_tri (); - s->eclass_schemes[T8_ECLASS_TET] = new t8_default_scheme_tet (); - s->eclass_schemes[T8_ECLASS_PRISM] = new t8_default_scheme_prism (); - s->eclass_schemes[T8_ECLASS_PYRAMID] = new t8_default_scheme_pyramid (); - - T8_ASSERT (s->eclass_schemes[T8_ECLASS_VERTEX]->t8_element_maxlevel () - >= s->eclass_schemes[T8_ECLASS_LINE]->t8_element_maxlevel ()); - T8_ASSERT (s->eclass_schemes[T8_ECLASS_LINE]->t8_element_maxlevel () - >= s->eclass_schemes[T8_ECLASS_QUAD]->t8_element_maxlevel ()); - T8_ASSERT (s->eclass_schemes[T8_ECLASS_LINE]->t8_element_maxlevel () - >= s->eclass_schemes[T8_ECLASS_TRIANGLE]->t8_element_maxlevel ()); - T8_ASSERT (s->eclass_schemes[T8_ECLASS_TRIANGLE]->t8_element_maxlevel () - >= s->eclass_schemes[T8_ECLASS_TET]->t8_element_maxlevel ()); - T8_ASSERT (s->eclass_schemes[T8_ECLASS_TRIANGLE]->t8_element_maxlevel () - >= s->eclass_schemes[T8_ECLASS_PRISM]->t8_element_maxlevel ()); - T8_ASSERT (s->eclass_schemes[T8_ECLASS_TRIANGLE]->t8_element_maxlevel () - >= s->eclass_schemes[T8_ECLASS_PYRAMID]->t8_element_maxlevel ()); - T8_ASSERT (s->eclass_schemes[T8_ECLASS_QUAD]->t8_element_maxlevel () - >= s->eclass_schemes[T8_ECLASS_HEX]->t8_element_maxlevel ()); - T8_ASSERT (s->eclass_schemes[T8_ECLASS_QUAD]->t8_element_maxlevel () - >= s->eclass_schemes[T8_ECLASS_PRISM]->t8_element_maxlevel ()); - T8_ASSERT (s->eclass_schemes[T8_ECLASS_QUAD]->t8_element_maxlevel () - >= s->eclass_schemes[T8_ECLASS_PYRAMID]->t8_element_maxlevel ()); - - return s; + builder.add_eclass_scheme (T8_ECLASS_VERTEX); + builder.add_eclass_scheme (T8_ECLASS_LINE); + builder.add_eclass_scheme (T8_ECLASS_QUAD); + builder.add_eclass_scheme (T8_ECLASS_HEX); + builder.add_eclass_scheme (T8_ECLASS_TRIANGLE); + builder.add_eclass_scheme (T8_ECLASS_TET); + builder.add_eclass_scheme (T8_ECLASS_PRISM); + builder.add_eclass_scheme (T8_ECLASS_PYRAMID); + return builder.build_scheme (); } int -t8_eclass_scheme_is_default (t8_scheme *ts) +t8_eclass_scheme_is_default (t8_scheme *scheme, t8_eclass_t eclass) { - switch (ts->eclass) { + switch (eclass) { case T8_ECLASS_VERTEX: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_vertex *); + return scheme->check_eclass_scheme_type (T8_ECLASS_VERTEX); case T8_ECLASS_LINE: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_line *); + return scheme->check_eclass_scheme_type (T8_ECLASS_LINE); case T8_ECLASS_QUAD: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_quad *); + return scheme->check_eclass_scheme_type (T8_ECLASS_QUAD); case T8_ECLASS_TRIANGLE: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_tri *); + return scheme->check_eclass_scheme_type (T8_ECLASS_TRIANGLE); case T8_ECLASS_HEX: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_hex *); + return scheme->check_eclass_scheme_type (T8_ECLASS_HEX); case T8_ECLASS_TET: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_tet *); + return scheme->check_eclass_scheme_type (T8_ECLASS_TET); case T8_ECLASS_PRISM: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_prism *); + return scheme->check_eclass_scheme_type (T8_ECLASS_PRISM); case T8_ECLASS_PYRAMID: - return T8_COMMON_IS_TYPE (ts, t8_default_scheme_pyramid *); + return scheme->check_eclass_scheme_type (T8_ECLASS_PYRAMID); default: SC_ABORT_NOT_REACHED (); } diff --git a/src/t8_schemes/t8_default/t8_default.hxx b/src/t8_schemes/t8_default/t8_default.hxx index dc61f99f0d..2696ba2079 100644 --- a/src/t8_schemes/t8_default/t8_default.hxx +++ b/src/t8_schemes/t8_default/t8_default.hxx @@ -42,15 +42,16 @@ T8_EXTERN_C_BEGIN (); /** Return the default element implementation of t8code. */ -t8_scheme_c * -t8_scheme_new_default_cxx (void); +t8_scheme * +t8_scheme_new_default (void); /** Check whether a given eclass_scheme is one of the default schemes. - * \param [in] ts A (pointer to a) scheme - * \return True (non-zero) if \a ts is one of the default schemes, - * false (zero) otherwise. + * \param [in] scheme A (pointer to a) scheme + * \param [in] eclass The eclass to check + * \return True (non-zero) if \a ts is one of the default schemes, + * false (zero) otherwise. */ int -t8_eclass_scheme_is_default (t8_scheme_c *ts); +t8_eclass_scheme_is_default (const t8_scheme *scheme, const t8_eclass_t eclass); T8_EXTERN_C_END (); diff --git a/src/t8_schemes/t8_default/t8_default_c_interface.h b/src/t8_schemes/t8_default/t8_default_c_interface.h index 36a6d0cee6..3a8201e876 100644 --- a/src/t8_schemes/t8_default/t8_default_c_interface.h +++ b/src/t8_schemes/t8_default/t8_default_c_interface.h @@ -31,17 +31,18 @@ T8_EXTERN_C_BEGIN (); -/** Return the default element implementation of t8code. */ +/** Return the default scheme implementation of t8code. */ t8_scheme_c * -t8_scheme_new_default_cxx (void); +t8_scheme_new_default (void); /** Check whether a given eclass_scheme is one of the default schemes. - * \param [in] ts A (pointer to a) scheme - * \return True (non-zero) if \a ts is one of the default schemes, - * false (zero) otherwise. + * \param [in] scheme A (pointer to a) scheme + * \param [in] eclass The eclass to check + * \return True (non-zero) if \a ts is one of the default schemes, + * false (zero) otherwise. */ int -t8_eclass_scheme_is_default (t8_scheme_c *ts); +t8_eclass_scheme_is_default (const t8_scheme_c *scheme, const t8_eclass_t eclass); T8_EXTERN_C_END (); diff --git a/src/t8_schemes/t8_scheme.hxx b/src/t8_schemes/t8_scheme.hxx index 614eaab538..fe1ff70005 100644 --- a/src/t8_schemes/t8_scheme.hxx +++ b/src/t8_schemes/t8_scheme.hxx @@ -93,6 +93,18 @@ class t8_scheme { } } + /** Check if the scheme is of a specific type. + * \tparam TEclass_Scheme The type of the scheme to check for. + * \param [in] tree_class The eclass of the current tree. + * \return True if the scheme is of type \a TEclass_Scheme, false otherwise. + */ + template + inline bool + check_eclass_scheme_type (t8_eclass_t tree_class) const + { + return std::holds_alternative (eclass_schemes[tree_class]); + } + /** Return the size of any element of a given class. * \param [in] tree_class The eclass of the current tree. * \return The size of an element of class \a tree_class. diff --git a/src/t8_schemes/t8_scheme_builder.hxx b/src/t8_schemes/t8_scheme_builder.hxx index 35e11cac94..9f3f038a42 100644 --- a/src/t8_schemes/t8_scheme_builder.hxx +++ b/src/t8_schemes/t8_scheme_builder.hxx @@ -29,10 +29,10 @@ #include -class Scheme_builder { +class t8_scheme_builder { public: - Scheme_builder (): scheme (new t8_scheme) {}; - ~Scheme_builder () {}; + t8_scheme_builder (): scheme (new t8_scheme) {}; + ~t8_scheme_builder () {}; using scheme_var = t8_scheme::scheme_var; @@ -43,7 +43,7 @@ class Scheme_builder { scheme->eclass_schemes[tree_class] = TEclass_Scheme (std::forward<_Args> (args)...); } - const t8_scheme * + t8_scheme * build_scheme () const { return scheme; diff --git a/test/t8_IO/t8_gtest_vtk_writer.cxx b/test/t8_IO/t8_gtest_vtk_writer.cxx index 9cd7356d39..8e396850e8 100644 --- a/test/t8_IO/t8_gtest_vtk_writer.cxx +++ b/test/t8_IO/t8_gtest_vtk_writer.cxx @@ -49,7 +49,7 @@ t8_forest_t make_grid () { t8_cmesh_t cmesh = make_grid (); - t8_scheme *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default (); return t8_forest_new_uniform (cmesh, scheme, 2, 0, sc_MPI_COMM_WORLD); } diff --git a/test/t8_cmesh/t8_gtest_cmesh_partition.cxx b/test/t8_cmesh/t8_gtest_cmesh_partition.cxx index d5b41e8555..f595a2b161 100644 --- a/test/t8_cmesh/t8_gtest_cmesh_partition.cxx +++ b/test/t8_cmesh/t8_gtest_cmesh_partition.cxx @@ -86,7 +86,7 @@ TEST_P (t8_cmesh_partition_class, test_cmesh_partition_concentrate) t8_cmesh_init (&cmesh_partition); t8_cmesh_set_derive (cmesh_partition, cmesh_original); /* Uniform partition according to level */ - t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, level, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_partition, sc_MPI_COMM_WORLD); test_cmesh_committed (cmesh_partition); @@ -126,7 +126,7 @@ TEST_P (t8_cmesh_partition_class, test_cmesh_partition_concentrate) for (int i = 0; i < 2; i++) { t8_cmesh_init (&cmesh_partition_new2); t8_cmesh_set_derive (cmesh_partition_new2, cmesh_partition_new1); - t8_cmesh_set_partition_uniform (cmesh_partition_new2, level, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition_new2, level, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_partition_new2, sc_MPI_COMM_WORLD); cmesh_partition_new1 = cmesh_partition_new2; } diff --git a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx index 7e3fad23df..4e181119f2 100644 --- a/test/t8_cmesh/t8_gtest_multiple_attributes.cxx +++ b/test/t8_cmesh/t8_gtest_multiple_attributes.cxx @@ -35,7 +35,7 @@ t8_cmesh_partition_cmesh (t8_cmesh_t cmesh, sc_MPI_Comm comm) t8_cmesh_t cmesh_partition; t8_cmesh_init (&cmesh_partition); t8_cmesh_set_derive (cmesh_partition, cmesh); - t8_cmesh_set_partition_uniform (cmesh_partition, 0, t8_scheme_new_default_cxx ()); + t8_cmesh_set_partition_uniform (cmesh_partition, 0, t8_scheme_new_default ()); t8_cmesh_commit (cmesh_partition, comm); return cmesh_partition; } diff --git a/test/t8_forest/t8_gtest_balance.cxx b/test/t8_forest/t8_gtest_balance.cxx index 4ad034cc9c..954f03855f 100644 --- a/test/t8_forest/t8_gtest_balance.cxx +++ b/test/t8_forest/t8_gtest_balance.cxx @@ -65,7 +65,7 @@ TEST_P (gtest_balance, confirm_is_balanced_check_for_uniform_forests) if (ieclass == t8_eclass_t::T8_ECLASS_PYRAMID && ido_periodic == 1) GTEST_SKIP_ ("The pyramid cube mesh cannot be periodic."); - t8_scheme *default_scheme = t8_scheme_new_default_cxx (); + t8_scheme *default_scheme = t8_scheme_new_default (); t8_cmesh_t cmesh = t8_cmesh_new_hypercube (ieclass, sc_MPI_COMM_WORLD, 0, 0, ido_periodic); t8_forest_t forest = t8_forest_new_uniform (cmesh, default_scheme, ilevel, 0, sc_MPI_COMM_WORLD); @@ -132,7 +132,7 @@ t8_gtest_obtain_forest_for_balance_tests (const std::vector &trees_ t8_forest_t forest; t8_forest_init (&forest); t8_forest_set_cmesh (forest, cmesh, sc_MPI_COMM_WORLD); - t8_forest_set_scheme (forest, t8_scheme_new_default_cxx ()); + t8_forest_set_scheme (forest, t8_scheme_new_default ()); t8_forest_commit (forest); gtest_balance_adapt_data adapt_data; diff --git a/test/t8_forest/t8_gtest_element_is_leaf.cxx b/test/t8_forest/t8_gtest_element_is_leaf.cxx index bb95f7fec8..a5b2a87539 100644 --- a/test/t8_forest/t8_gtest_element_is_leaf.cxx +++ b/test/t8_forest/t8_gtest_element_is_leaf.cxx @@ -75,7 +75,7 @@ class element_is_leaf: public testing::TestWithParam (GetParam ()); level = std::get<1> (GetParam ()); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); t8_cmesh_t cmesh = t8_cmesh_new_hypercube (eclass, sc_MPI_COMM_WORLD, 0, 0, 0); forest = t8_forest_new_uniform (cmesh, scheme, level, 0, sc_MPI_COMM_WORLD); } diff --git a/test/t8_forest/t8_gtest_find_owner.cxx b/test/t8_forest/t8_gtest_find_owner.cxx index 93a58bd706..e05a3bd465 100644 --- a/test/t8_forest/t8_gtest_find_owner.cxx +++ b/test/t8_forest/t8_gtest_find_owner.cxx @@ -40,7 +40,7 @@ class forest_find_owner: public testing::TestWithParam { { eclass = GetParam (); - default_scheme = t8_scheme_new_default_cxx (); + default_scheme = t8_scheme_new_default (); /* Construct a coarse mesh of one tree */ cmesh = t8_cmesh_new_from_class (eclass, sc_MPI_COMM_WORLD); } diff --git a/test/t8_forest/t8_gtest_forest_commit.cxx b/test/t8_forest/t8_gtest_forest_commit.cxx index 51c9bf55ab..2d17b470ca 100644 --- a/test/t8_forest/t8_gtest_forest_commit.cxx +++ b/test/t8_forest/t8_gtest_forest_commit.cxx @@ -137,7 +137,7 @@ TEST_P (forest_commit, test_forest_commit) const int level_step = 2; - t8_scheme *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default (); /* Compute the first level, such that no process is empty */ int min_level = t8_forest_min_nonempty_level (cmesh, scheme); diff --git a/test/t8_forest/t8_gtest_forest_face_normal.cxx b/test/t8_forest/t8_gtest_forest_face_normal.cxx index 8033e011cc..fa600e1cfb 100644 --- a/test/t8_forest/t8_gtest_forest_face_normal.cxx +++ b/test/t8_forest/t8_gtest_forest_face_normal.cxx @@ -41,7 +41,7 @@ class class_forest_face_normal: public testing::TestWithParam (GetParam ()); level = std::get<1> (GetParam ()); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); t8_cmesh_t cmesh = t8_cmesh_new_hypercube (eclass, sc_MPI_COMM_WORLD, 0, 0, 0); const int do_face_ghost = 1; forest = t8_forest_new_uniform (cmesh, scheme, level, do_face_ghost, sc_MPI_COMM_WORLD); diff --git a/test/t8_forest/t8_gtest_ghost_and_owner.cxx b/test/t8_forest/t8_gtest_ghost_and_owner.cxx index 6907bf8cab..624918540c 100644 --- a/test/t8_forest/t8_gtest_ghost_and_owner.cxx +++ b/test/t8_forest/t8_gtest_ghost_and_owner.cxx @@ -42,7 +42,7 @@ class forest_ghost_owner: public testing::TestWithParam { SetUp () override { - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); /* Construct a cmesh */ cmesh = GetParam ()->cmesh_create (); if (t8_cmesh_is_empty (cmesh)) { diff --git a/test/t8_forest/t8_gtest_ghost_delete.cxx b/test/t8_forest/t8_gtest_ghost_delete.cxx index 191384c0b2..da20a66294 100644 --- a/test/t8_forest/t8_gtest_ghost_delete.cxx +++ b/test/t8_forest/t8_gtest_ghost_delete.cxx @@ -78,7 +78,7 @@ class DISABLED_forest_ghost_exchange_holes: public testing::Test { if (comm != sc_MPI_COMM_NULL) { sc_MPI_Comm_size (comm, &size); T8_ASSERT (size <= 2); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); /* Construct a cmesh */ cmesh = t8_cmesh_new_hypercube (T8_ECLASS_QUAD, comm, 0, 0, 0); } diff --git a/test/t8_forest/t8_gtest_ghost_exchange.cxx b/test/t8_forest/t8_gtest_ghost_exchange.cxx index 279e9240b0..971e1afa4a 100644 --- a/test/t8_forest/t8_gtest_ghost_exchange.cxx +++ b/test/t8_forest/t8_gtest_ghost_exchange.cxx @@ -48,7 +48,7 @@ class forest_ghost_exchange: public testing::TestWithParam void SetUp () override { - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); /* Construct a cmesh */ cmesh = GetParam ()->cmesh_create (); if (t8_cmesh_is_empty (cmesh)) { diff --git a/test/t8_forest/t8_gtest_half_neighbors.cxx b/test/t8_forest/t8_gtest_half_neighbors.cxx index 4ffbde3d5d..88389b253a 100644 --- a/test/t8_forest/t8_gtest_half_neighbors.cxx +++ b/test/t8_forest/t8_gtest_half_neighbors.cxx @@ -42,7 +42,7 @@ class forest_half_neighbors: public testing::TestWithParam (GetParam ()); cmesh_type = std::get<1> (GetParam ()); - default_scheme = t8_scheme_new_default_cxx (); + default_scheme = t8_scheme_new_default (); /* Construct a coarse mesh of one tree */ cmesh = t8_cmesh_new_from_class (eclass, sc_MPI_COMM_WORLD); } diff --git a/test/t8_forest/t8_gtest_partition_data.cxx b/test/t8_forest/t8_gtest_partition_data.cxx index 4e19fa2ffb..a5f36b224e 100644 --- a/test/t8_forest/t8_gtest_partition_data.cxx +++ b/test/t8_forest/t8_gtest_partition_data.cxx @@ -225,7 +225,7 @@ TEST (partition_data, test_partition_data) { /* Build a forest */ t8_cmesh_t cmesh = t8_cmesh_new_hypercube (T8_ECLASS_TRIANGLE, sc_MPI_COMM_WORLD, 0, 0, 0); - t8_scheme* scheme = t8_scheme_new_default_cxx (); + t8_scheme* scheme = t8_scheme_new_default (); t8_forest_t base_forest = t8_forest_new_uniform (cmesh, scheme, 1, 0, sc_MPI_COMM_WORLD); /* Adapt the forest examplary. */ diff --git a/test/t8_forest/t8_gtest_search.cxx b/test/t8_forest/t8_gtest_search.cxx index 17c63001a8..53c9a27439 100644 --- a/test/t8_forest/t8_gtest_search.cxx +++ b/test/t8_forest/t8_gtest_search.cxx @@ -38,7 +38,7 @@ class forest_search: public testing::TestWithParam> { eclass = std::get<0> (GetParam ()); level = std::get<1> (GetParam ()); - default_scheme = t8_scheme_new_default_cxx (); + default_scheme = t8_scheme_new_default (); /* Construct a cube coarse mesh */ cmesh = t8_cmesh_new_hypercube (eclass, sc_MPI_COMM_WORLD, 0, 0, 0); /* Build a uniform forest */ diff --git a/test/t8_forest/t8_gtest_transform.cxx b/test/t8_forest/t8_gtest_transform.cxx index 4926ebcecf..36f7faeb1c 100644 --- a/test/t8_forest/t8_gtest_transform.cxx +++ b/test/t8_forest/t8_gtest_transform.cxx @@ -47,7 +47,7 @@ class forest_transform: public testing::TestWithParam level = std::get<1> (GetParam ()); t8_debugf ("\n\n\nTesting eclass %s with level %i", t8_eclass_to_string[eclass], level); - default_scheme = t8_scheme_new_default_cxx (); + default_scheme = t8_scheme_new_default (); /* Construct a coarse mesh of one tree */ cmesh = t8_cmesh_new_from_class (eclass, sc_MPI_COMM_WORLD); diff --git a/test/t8_forest/t8_gtest_user_data.cxx b/test/t8_forest/t8_gtest_user_data.cxx index 23513b4c13..b05b7c3ed6 100644 --- a/test/t8_forest/t8_gtest_user_data.cxx +++ b/test/t8_forest/t8_gtest_user_data.cxx @@ -38,7 +38,7 @@ TEST (user_data, test_user_data) { /* Build a forest */ t8_cmesh_t cmesh = t8_cmesh_new_hypercube (T8_ECLASS_TRIANGLE, sc_MPI_COMM_WORLD, 0, 0, 0); - t8_scheme *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default (); t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, 1, 0, sc_MPI_COMM_WORLD); /* Define user data */ double data = 42.42; @@ -96,7 +96,7 @@ TEST (user_data, test_user_function) { /* Build a forest */ t8_cmesh_t cmesh = t8_cmesh_new_hypercube (T8_ECLASS_TRIANGLE, sc_MPI_COMM_WORLD, 0, 0, 0); - t8_scheme *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default (); t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, 1, 0, sc_MPI_COMM_WORLD); double (*funpointer) (int); diff --git a/test/t8_forest_incomplete/t8_gtest_empty_global_tree.cxx b/test/t8_forest_incomplete/t8_gtest_empty_global_tree.cxx index 67073496f1..c7ed29bae1 100644 --- a/test/t8_forest_incomplete/t8_gtest_empty_global_tree.cxx +++ b/test/t8_forest_incomplete/t8_gtest_empty_global_tree.cxx @@ -45,8 +45,8 @@ class DISABLED_global_tree: public testing::TestWithParam (GetParam ()); testcase = std::get<1> (GetParam ()); - forest = t8_forest_new_uniform (t8_cmesh_new_bigmesh (eclass, 3, sc_MPI_COMM_WORLD), t8_scheme_new_default_cxx (), - 0, 0, sc_MPI_COMM_WORLD); + forest = t8_forest_new_uniform (t8_cmesh_new_bigmesh (eclass, 3, sc_MPI_COMM_WORLD), t8_scheme_new_default (), 0, 0, + sc_MPI_COMM_WORLD); } void TearDown () override diff --git a/test/t8_forest_incomplete/t8_gtest_empty_local_tree.cxx b/test/t8_forest_incomplete/t8_gtest_empty_local_tree.cxx index 1216a6255d..0776a83f1f 100644 --- a/test/t8_forest_incomplete/t8_gtest_empty_local_tree.cxx +++ b/test/t8_forest_incomplete/t8_gtest_empty_local_tree.cxx @@ -64,7 +64,7 @@ class DISABLED_local_tree: public testing::TestWithParam { eclass = GetParam (); sc_MPI_Comm_size (sc_MPI_COMM_WORLD, &MPI_size); - forest = t8_forest_new_uniform (t8_cmesh_new_from_class (eclass, sc_MPI_COMM_WORLD), t8_scheme_new_default_cxx (), + forest = t8_forest_new_uniform (t8_cmesh_new_from_class (eclass, sc_MPI_COMM_WORLD), t8_scheme_new_default (), MPI_size, 0, sc_MPI_COMM_WORLD); /* TODO: The level does not need to be as big as MPI_SIZE, only as big so that each process has at least one element */ diff --git a/test/t8_forest_incomplete/t8_gtest_iterate_replace.cxx b/test/t8_forest_incomplete/t8_gtest_iterate_replace.cxx index 0279c3e9b0..067c526d77 100644 --- a/test/t8_forest_incomplete/t8_gtest_iterate_replace.cxx +++ b/test/t8_forest_incomplete/t8_gtest_iterate_replace.cxx @@ -46,7 +46,7 @@ class forest_iterate: public testing::TestWithParam { t8_cmesh_unref (&cmesh); GTEST_SKIP (); } - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), 4, 0, sc_MPI_COMM_WORLD); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), 4, 0, sc_MPI_COMM_WORLD); } void TearDown () override diff --git a/test/t8_forest_incomplete/t8_gtest_permute_hole.cxx b/test/t8_forest_incomplete/t8_gtest_permute_hole.cxx index 6f0ac431a3..92b3195516 100644 --- a/test/t8_forest_incomplete/t8_gtest_permute_hole.cxx +++ b/test/t8_forest_incomplete/t8_gtest_permute_hole.cxx @@ -70,7 +70,7 @@ class forest_permute: public testing::TestWithParam { #else level = eclass < 4 ? 2 : 1; #endif - forest = t8_forest_new_uniform (t8_cmesh_new_from_class (eclass, sc_MPI_COMM_WORLD), t8_scheme_new_default_cxx (), + forest = t8_forest_new_uniform (t8_cmesh_new_from_class (eclass, sc_MPI_COMM_WORLD), t8_scheme_new_default (), level, 0, sc_MPI_COMM_WORLD); sc_MPI_Comm_size (sc_MPI_COMM_WORLD, &MPI_size); diff --git a/test/t8_forest_incomplete/t8_gtest_recursive.cxx b/test/t8_forest_incomplete/t8_gtest_recursive.cxx index db3cb5100d..0e82c08a5f 100644 --- a/test/t8_forest_incomplete/t8_gtest_recursive.cxx +++ b/test/t8_forest_incomplete/t8_gtest_recursive.cxx @@ -47,7 +47,7 @@ class recursive_tree: public testing::TestWithParam { /* Construct a cmesh such that each process will get one rooted tree */ cmesh = t8_cmesh_new_bigmesh (eclass, MPI_size, sc_MPI_COMM_WORLD); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); t8_schemexx_ref (scheme); t8_cmesh_ref (cmesh); diff --git a/test/t8_geometry/t8_gtest_point_inside.cxx b/test/t8_geometry/t8_gtest_point_inside.cxx index 103eb4db86..38b495f530 100644 --- a/test/t8_geometry/t8_gtest_point_inside.cxx +++ b/test/t8_geometry/t8_gtest_point_inside.cxx @@ -58,7 +58,7 @@ TEST (t8_point_inside, test_point_inside_specific_triangle) /* We use standard linear geometry */ t8_cmesh_register_geometry (cmesh, 2); t8_cmesh_commit (cmesh, sc_MPI_COMM_WORLD); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), 0, 0, sc_MPI_COMM_WORLD); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), 0, 0, sc_MPI_COMM_WORLD); if (t8_forest_get_local_num_elements (forest) <= 0) { /* Skip empty forests (can occur when executed in parallel) */ @@ -99,7 +99,7 @@ TEST (t8_point_inside, test_point_inside_specific_quad) /* We use standard linear geometry */ t8_cmesh_register_geometry (cmesh, 2); t8_cmesh_commit (cmesh, sc_MPI_COMM_WORLD); - t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), 0, 0, sc_MPI_COMM_WORLD); + t8_forest_t forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), 0, 0, sc_MPI_COMM_WORLD); if (t8_forest_get_local_num_elements (forest) <= 0) { /* Skip empty forests (can occur when executed in parallel) */ @@ -170,7 +170,7 @@ TEST_P (geometry_point_inside, test_point_inside) t8_debugf ("Testing eclass %s, uniform level %i with approx. %i points per element.\n", t8_eclass_to_string[eclass], level, num_points_to_generate); - t8_scheme *default_scheme = t8_scheme_new_default_cxx (); + t8_scheme *default_scheme = t8_scheme_new_default (); /* We translate the coordinates of the cmesh to create a non-standard case. * In particular, we want the 1D and 2D elements to move outside of axis diff --git a/test/t8_schemes/t8_gtest_ancestor.cxx b/test/t8_schemes/t8_gtest_ancestor.cxx index 33ca059b8e..d14b56fc5a 100644 --- a/test/t8_schemes/t8_gtest_ancestor.cxx +++ b/test/t8_schemes/t8_gtest_ancestor.cxx @@ -38,7 +38,7 @@ class ancestor: public testing::TestWithParam { SetUp () override { eclass = GetParam (); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); ts = scheme->eclass_schemes[eclass]; ts->t8_element_new (1, &correct_ancestor); ts->t8_element_new (1, &desc_a); diff --git a/test/t8_schemes/t8_gtest_default.cxx b/test/t8_schemes/t8_gtest_default.cxx index 33a02125e6..c5cc37d2a5 100644 --- a/test/t8_schemes/t8_gtest_default.cxx +++ b/test/t8_schemes/t8_gtest_default.cxx @@ -37,54 +37,12 @@ #include #include -class gtest_default_scheme: public testing::TestWithParam { - protected: - void - SetUp () override - { - /* Construct every eclass scheme explixitly */ - const t8_eclass_t eclass = GetParam (); - switch (eclass) { - case T8_ECLASS_VERTEX: - eclass_scheme = new t8_default_scheme_vertex (); - break; - case T8_ECLASS_LINE: - eclass_scheme = new t8_default_scheme_line (); - break; - case T8_ECLASS_QUAD: - eclass_scheme = new t8_default_scheme_quad (); - break; - case T8_ECLASS_TRIANGLE: - eclass_scheme = new t8_default_scheme_tri (); - break; - case T8_ECLASS_HEX: - eclass_scheme = new t8_default_scheme_hex (); - break; - case T8_ECLASS_TET: - eclass_scheme = new t8_default_scheme_tet (); - break; - case T8_ECLASS_PRISM: - eclass_scheme = new t8_default_scheme_prism (); - break; - case T8_ECLASS_PYRAMID: - eclass_scheme = new t8_default_scheme_pyramid (); - break; - default: - SC_ABORT_NOT_REACHED (); - } - } - void - TearDown () override - { - delete (eclass_scheme); - } - t8_scheme *eclass_scheme; -}; - -TEST_P (gtest_default_scheme, is_default) +TEST (gtest_default_scheme, is_default) { /* TODO: Implement an EXPECT_FALSE check for non-default schemes */ - EXPECT_TRUE (t8_eclass_scheme_is_default (eclass_scheme)); + t8_scheme *scheme = t8_scheme_new_default (); + for (int eclass = T8_ECLASS_VERTEX; eclass < T8_ECLASS_COUNT; ++eclass) { + EXPECT_TRUE (t8_eclass_scheme_is_default (scheme, static_cast (eclass))); + } + scheme->unref (); } - -INSTANTIATE_TEST_SUITE_P (t8_gtest_default_scheme, gtest_default_scheme, AllEclasses, print_eclass); diff --git a/test/t8_schemes/t8_gtest_descendant.cxx b/test/t8_schemes/t8_gtest_descendant.cxx index a4fb77735f..eedf498f35 100644 --- a/test/t8_schemes/t8_gtest_descendant.cxx +++ b/test/t8_schemes/t8_gtest_descendant.cxx @@ -35,7 +35,7 @@ class class_schemes_descendant: public testing::TestWithParam { { eclass = GetParam (); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); ts = scheme->eclass_schemes[eclass]; ts->t8_element_new (1, &elem); ts->t8_element_new (1, &desc); diff --git a/test/t8_schemes/t8_gtest_dfs_base.hxx b/test/t8_schemes/t8_gtest_dfs_base.hxx index 95aaef49f4..69e9395fcb 100644 --- a/test/t8_schemes/t8_gtest_dfs_base.hxx +++ b/test/t8_schemes/t8_gtest_dfs_base.hxx @@ -59,7 +59,7 @@ class TestDFS: public testing::TestWithParam { void dfs_test_setup () { - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); eclass = GetParam (); ts = scheme->eclass_schemes[eclass]; ts->t8_element_new (1, &element); diff --git a/test/t8_schemes/t8_gtest_element_count_leaves.cxx b/test/t8_schemes/t8_gtest_element_count_leaves.cxx index a434b26ada..75960ce7e2 100644 --- a/test/t8_schemes/t8_gtest_element_count_leaves.cxx +++ b/test/t8_schemes/t8_gtest_element_count_leaves.cxx @@ -50,7 +50,7 @@ class class_element_leaves: public testing::TestWithParam { } t8_eclass eclass; t8_scheme *class_scheme; - t8_scheme *ts = t8_scheme_new_default_cxx (); + t8_scheme *ts = t8_scheme_new_default (); }; TEST_P (class_element_leaves, test_element_count_leaves_root) diff --git a/test/t8_schemes/t8_gtest_element_ref_coords.cxx b/test/t8_schemes/t8_gtest_element_ref_coords.cxx index 6d81ec4af3..e2b30e7721 100644 --- a/test/t8_schemes/t8_gtest_element_ref_coords.cxx +++ b/test/t8_schemes/t8_gtest_element_ref_coords.cxx @@ -229,7 +229,7 @@ class class_ref_coords: public testing::TestWithParam (params); const int level = std::get<1> (params); t8_cmesh_t cmesh = t8_cmesh_new_from_class (eclass, sc_MPI_COMM_WORLD); - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), level, 0, sc_MPI_COMM_WORLD); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), level, 0, sc_MPI_COMM_WORLD); t8_forest_init (&forest_partition); t8_forest_set_partition (forest_partition, forest, 0); t8_forest_commit (forest_partition); diff --git a/test/t8_schemes/t8_gtest_face_neigh.cxx b/test/t8_schemes/t8_gtest_face_neigh.cxx index 57af14048b..f9d89d463a 100644 --- a/test/t8_schemes/t8_gtest_face_neigh.cxx +++ b/test/t8_schemes/t8_gtest_face_neigh.cxx @@ -36,7 +36,7 @@ class face_neigh: public testing::TestWithParam { SetUp () override { eclass = GetParam (); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); ts = scheme->eclass_schemes[eclass]; ts->t8_element_new (1, &element); diff --git a/test/t8_schemes/t8_gtest_init_linear_id.cxx b/test/t8_schemes/t8_gtest_init_linear_id.cxx index 8a9e0a0077..fb8d609749 100644 --- a/test/t8_schemes/t8_gtest_init_linear_id.cxx +++ b/test/t8_schemes/t8_gtest_init_linear_id.cxx @@ -34,7 +34,7 @@ class linear_id: public testing::TestWithParam { SetUp () override { eclass = GetParam (); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); ts = scheme->eclass_schemes[eclass]; ts->t8_element_new (1, &element); ts->t8_element_new (1, &child); diff --git a/test/t8_schemes/t8_gtest_nca.cxx b/test/t8_schemes/t8_gtest_nca.cxx index a8cbb8a0d2..26f30d548b 100644 --- a/test/t8_schemes/t8_gtest_nca.cxx +++ b/test/t8_schemes/t8_gtest_nca.cxx @@ -37,7 +37,7 @@ class nca: public testing::TestWithParam { SetUp () override { eclass = GetParam (); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); ts = scheme->eclass_schemes[eclass]; ts->t8_element_new (1, &correct_nca); ts->t8_element_new (1, &desc_a); diff --git a/test/t8_schemes/t8_gtest_root.cxx b/test/t8_schemes/t8_gtest_root.cxx index baa7d5b9e4..917d2fbc3a 100644 --- a/test/t8_schemes/t8_gtest_root.cxx +++ b/test/t8_schemes/t8_gtest_root.cxx @@ -35,7 +35,7 @@ class root: public testing::TestWithParam { SetUp () override { eclass = GetParam (); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); ts = scheme->eclass_schemes[eclass]; ts->t8_element_new (1, &element); ts->t8_element_root (element); diff --git a/test/t8_schemes/t8_gtest_successor.cxx b/test/t8_schemes/t8_gtest_successor.cxx index c3d5690c25..82f84ed6f0 100644 --- a/test/t8_schemes/t8_gtest_successor.cxx +++ b/test/t8_schemes/t8_gtest_successor.cxx @@ -33,7 +33,7 @@ class class_successor: public testing::TestWithParam { { eclass = GetParam (); - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); ts = scheme->eclass_schemes[eclass]; ts->t8_element_new (1, &element); diff --git a/tutorials/features/t8_features_curved_meshes.cxx b/tutorials/features/t8_features_curved_meshes.cxx index f234607963..bcdacb0b82 100644 --- a/tutorials/features/t8_features_curved_meshes.cxx +++ b/tutorials/features/t8_features_curved_meshes.cxx @@ -439,7 +439,7 @@ main (int argc, char **argv) /* Read in the naca mesh from the msh file and the naca geometry from the brep file */ cmesh = t8_cmesh_from_msh_file (fp.c_str (), 0, sc_MPI_COMM_WORLD, dim, 0, cad || geometry); /* Construct a forest from the cmesh */ - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), level, 0, comm); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), level, 0, comm); T8_ASSERT (t8_forest_is_committed (forest)); if (geometry) { t8_naca_geometry_refinement (forest, fp, level, rlevel_dorsal, rlevel_ventral, dim); diff --git a/tutorials/general/t8_step2_uniform_forest.cxx b/tutorials/general/t8_step2_uniform_forest.cxx index 956a48fc53..d5e1cea027 100644 --- a/tutorials/general/t8_step2_uniform_forest.cxx +++ b/tutorials/general/t8_step2_uniform_forest.cxx @@ -84,7 +84,7 @@ t8_step2_build_uniform_forest (sc_MPI_Comm comm, t8_cmesh_t cmesh, int level) t8_scheme *scheme; /* Create the refinement scheme. */ - scheme = t8_scheme_new_default_cxx (); + scheme = t8_scheme_new_default (); /* Creat the uniform forest. */ forest = t8_forest_new_uniform (cmesh, scheme, level, 0, comm); diff --git a/tutorials/general/t8_step3_adapt_forest.cxx b/tutorials/general/t8_step3_adapt_forest.cxx index c1ccc3afb3..4f10684d4e 100644 --- a/tutorials/general/t8_step3_adapt_forest.cxx +++ b/tutorials/general/t8_step3_adapt_forest.cxx @@ -211,7 +211,7 @@ t8_step3_main (int argc, char **argv) /* Build a cube cmesh with tet, hex, and prism trees. */ cmesh = t8_cmesh_new_hypercube_hybrid (comm, 0, 0); t8_global_productionf (" [step3] Created coarse mesh.\n"); - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), level, 0, comm); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), level, 0, comm); /* Print information of the forest. */ t8_global_productionf (" [step3] Created uniform forest.\n"); diff --git a/tutorials/general/t8_step4_partition_balance_ghost.cxx b/tutorials/general/t8_step4_partition_balance_ghost.cxx index 2c75649751..38892ee479 100644 --- a/tutorials/general/t8_step4_partition_balance_ghost.cxx +++ b/tutorials/general/t8_step4_partition_balance_ghost.cxx @@ -232,7 +232,7 @@ t8_step4_main (int argc, char **argv) /* Build a cube cmesh with tet, hex, and prism trees. */ cmesh = t8_cmesh_new_hypercube_hybrid (comm, 0, 0); t8_global_productionf (" [step4] Created coarse mesh.\n"); - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), level, 0, comm); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), level, 0, comm); /* Print information of the forest. */ t8_step3_print_forest_information (forest); diff --git a/tutorials/general/t8_step5_element_data.cxx b/tutorials/general/t8_step5_element_data.cxx index 7689ae14ac..40b2e12542 100644 --- a/tutorials/general/t8_step5_element_data.cxx +++ b/tutorials/general/t8_step5_element_data.cxx @@ -65,7 +65,7 @@ static t8_forest_t t8_step5_build_forest (sc_MPI_Comm comm, int level) { t8_cmesh_t cmesh = t8_cmesh_new_hypercube_hybrid (comm, 0, 0); - t8_scheme *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default (); struct t8_step3_adapt_data adapt_data = { { 0.5, 0.5, 1 }, /* Midpoints of the sphere. */ 0.2, /* Refine if inside this radius. */ diff --git a/tutorials/general/t8_step5_element_data_c_interface.c b/tutorials/general/t8_step5_element_data_c_interface.c index 0180cd373c..b29a0cbd5b 100644 --- a/tutorials/general/t8_step5_element_data_c_interface.c +++ b/tutorials/general/t8_step5_element_data_c_interface.c @@ -68,7 +68,7 @@ static t8_forest_t t8_step5_build_forest (sc_MPI_Comm comm, int level) { t8_cmesh_t cmesh = t8_cmesh_new_hypercube_hybrid (comm, 0, 0); - t8_scheme_c *scheme = t8_scheme_new_default_cxx (); + t8_scheme_c *scheme = t8_scheme_new_default (); struct t8_step3_adapt_data adapt_data = { { 0.5, 0.5, 1 }, /* Midpoints of the sphere. */ 0.2, /* Refine if inside this radius. */ diff --git a/tutorials/general/t8_step6_stencil.cxx b/tutorials/general/t8_step6_stencil.cxx index 37b83a97f5..6e49dbf6a3 100644 --- a/tutorials/general/t8_step6_stencil.cxx +++ b/tutorials/general/t8_step6_stencil.cxx @@ -83,7 +83,7 @@ t8_step6_build_forest (sc_MPI_Comm comm, int dim, int level) { t8_cmesh_t cmesh = t8_cmesh_new_periodic (comm, dim); - t8_scheme *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default (); struct t8_step3_adapt_data adapt_data = { { 0.0, 0.0, 0.0 }, /* Midpoints of the sphere. */ 0.5, /* Refine if inside this radius. */ diff --git a/tutorials/general/t8_step7_interpolation.cxx b/tutorials/general/t8_step7_interpolation.cxx index 3a83deac5d..abae599b72 100644 --- a/tutorials/general/t8_step7_interpolation.cxx +++ b/tutorials/general/t8_step7_interpolation.cxx @@ -285,7 +285,7 @@ t8_interpolation () t8_step7_adapt_data *data; double centroid[3]; const double midpoint[3] = { 0.5, 0.5, 1 }; - t8_scheme *scheme = t8_scheme_new_default_cxx (); + t8_scheme *scheme = t8_scheme_new_default (); /* Construct a cmesh */ t8_cmesh_t cmesh = t8_cmesh_new_from_class (T8_ECLASS_HEX, sc_MPI_COMM_WORLD); diff --git a/tutorials/general/t8_tutorial_search.cxx b/tutorials/general/t8_tutorial_search.cxx index 8a056468e9..07b8c0f8b2 100644 --- a/tutorials/general/t8_tutorial_search.cxx +++ b/tutorials/general/t8_tutorial_search.cxx @@ -404,7 +404,7 @@ main (int argc, char **argv) /* Build a cube cmesh with tet, hex, and prism trees. */ cmesh = t8_cmesh_new_hypercube_hybrid (comm, 0, 0); /* Build a uniform forest on it. */ - forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default_cxx (), level, 0, comm); + forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), level, 0, comm); /* Adapt the forest. We can reuse the forest variable, since the new adapted * forest will take ownership of the old forest and destroy it.