Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone scheme #1331

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
aa3c057
start implementing a standalone scheme
ole-alb Dec 12, 2024
f8e9398
add anc as abbreviation for ancestor
ole-alb Dec 13, 2024
ac28b37
implement refinement and debug functions
ole-alb Dec 13, 2024
0f0b69c
rename anc to ancestor_elem
ole-alb Dec 16, 2024
7149015
move templated implementation to header file
ole-alb Dec 17, 2024
b1489a7
remove anc
ole-alb Dec 17, 2024
7a45d2d
add standalone scheme
ole-alb Dec 17, 2024
7ffe587
add new standalone functions
ole-alb Dec 19, 2024
48bec60
standalone scheme update
ole-alb Dec 20, 2024
1d2ca57
Merge remote-tracking branch 'origin/multiple-schemes-tests' into sta…
ole-alb Dec 20, 2024
03857e2
make linear id function iterative
ole-alb Jan 10, 2025
54c8a95
clean up code../src/t8_schemes/t8_standalone/t8_standalone_implementa…
ole-alb Jan 10, 2025
40dd6a4
update standalone scheme
ole-alb Jan 10, 2025
21cf42c
Merge branch 'multiple-schemes-tests' into standalone-tests
ole-alb Jan 10, 2025
076364f
Merge remote-tracking branch 'origin/multiple-schemes-tests' into sta…
ole-alb Jan 10, 2025
d408457
clean up code
ole-alb Jan 13, 2025
a26918f
Merge remote-tracking branch 'origin/multiple-schemes-tests' into sta…
ole-alb Jan 13, 2025
b684e7f
build standalone scheme
ole-alb Jan 14, 2025
9f7f8df
don't use type at this stage
ole-alb Jan 14, 2025
7378c5d
Update Copyright
ole-alb Jan 14, 2025
881d543
Update Copyright
ole-alb Jan 14, 2025
bde255f
remove _t
ole-alb Jan 14, 2025
3140393
Merge remote-tracking branch 'origin/standalone-scheme' into standalo…
ole-alb Jan 14, 2025
722e6ec
change ts_context to scheme_context
ole-alb Jan 14, 2025
cc133be
add MPI_pack and _unpack
ole-alb Jan 15, 2025
b28d519
only test face functionality for the default scheme
ole-alb Jan 15, 2025
3dadfd8
add bithelper functions
ole-alb Jan 15, 2025
cda795d
add comments
ole-alb Jan 15, 2025
15cd638
Add getter for eclass
ole-alb Jan 15, 2025
ad76bc4
merge with main
ole-alb Jan 15, 2025
72bf657
Merge remote-tracking branch 'origin/standalone-scheme' into standalo…
ole-alb Jan 15, 2025
62b6d38
fix error
ole-alb Jan 15, 2025
5226d80
fix comments
ole-alb Jan 16, 2025
cf26ec9
add comments
ole-alb Jan 16, 2025
997f0c2
fix comments
ole-alb Jan 16, 2025
ae23de3
fix comments
ole-alb Jan 16, 2025
f28f206
revert changes
ole-alb Jan 16, 2025
b26579c
only test face functions with default scheme
ole-alb Jan 16, 2025
29cfe87
Merge remote-tracking branch 'origin/main' into standalone-scheme
ole-alb Jan 16, 2025
453e36a
fix duplication
ole-alb Jan 16, 2025
d8f5ff6
correct blank spaces
ole-alb Jan 16, 2025
a67b593
correct blank spaces
ole-alb Jan 16, 2025
df777b6
clean up unused code
ole-alb Jan 16, 2025
151342f
fix error
ole-alb Jan 16, 2025
45cf047
fix error
ole-alb Jan 16, 2025
6212937
fix error
ole-alb Jan 16, 2025
dd0b666
delete unused varibale
ole-alb Jan 16, 2025
0a19054
delete unused varibale
ole-alb Jan 16, 2025
3545f86
delete unused code
ole-alb Jan 16, 2025
5ec516d
apply review
ole-alb Jan 17, 2025
f3f6082
apply review
ole-alb Jan 20, 2025
e09f725
remove class from internal function calls
ole-alb Jan 20, 2025
e01bc0f
make all inlined functions constexpr
ole-alb Jan 20, 2025
96c307f
add noexcept to all functions
ole-alb Jan 20, 2025
bf940b8
declare the level as t8_element_level instead int
ole-alb Jan 20, 2025
39bcfb5
Apply suggestions from code review
ole-alb Jan 21, 2025
d57ea78
apply review
ole-alb Jan 21, 2025
78c4916
indent standalone_elements
ole-alb Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ target_sources( T8 PRIVATE
t8_schemes/t8_default/t8_default_tri/t8_dtri_connectivity.c
t8_schemes/t8_default/t8_default_vertex/t8_default_vertex.cxx
t8_schemes/t8_default/t8_default_vertex/t8_dvertex_bits.c
t8_schemes/t8_standalone/t8_standalone.cxx
t8_vtk/t8_vtk_polydata.cxx
t8_vtk/t8_vtk_unstructured.cxx
t8_vtk/t8_vtk_parallel.cxx
Expand Down
8 changes: 7 additions & 1 deletion src/t8_schemes/t8_scheme.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <t8_schemes/t8_default/t8_default_tet/t8_default_tet.hxx>
#include <t8_schemes/t8_default/t8_default_prism/t8_default_prism.hxx>
#include <t8_schemes/t8_default/t8_default_pyramid/t8_default_pyramid.hxx>
#include <t8_schemes/t8_standalone/t8_standalone.hxx>
#include <t8_schemes/t8_standalone/t8_standalone_implementation.hxx>
#include <string>
#if T8_ENABLE_DEBUG
// Only needed for t8_debug_print_type
Expand Down Expand Up @@ -92,7 +94,11 @@ class t8_scheme {
t8_default_scheme_hex,
t8_default_scheme_tet,
t8_default_scheme_prism,
t8_default_scheme_pyramid
t8_default_scheme_pyramid,
t8_standalone_scheme<T8_ECLASS_VERTEX>,
t8_standalone_scheme<T8_ECLASS_LINE>,
t8_standalone_scheme<T8_ECLASS_QUAD>,
t8_standalone_scheme<T8_ECLASS_HEX>
>;
/* clang-format on */

Expand Down
72 changes: 72 additions & 0 deletions src/t8_schemes/t8_standalone/t8_standalone.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
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) 2025 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 <t8_schemes/t8_standalone/t8_standalone.hxx>
#include <t8_schemes/t8_scheme_builder.hxx>

/* We want to export the whole implementation to be callable from "C" */
T8_EXTERN_C_BEGIN ();

t8_scheme *
t8_scheme_new_standalone (void)
{
t8_scheme_builder builder;

builder.add_eclass_scheme<t8_standalone_scheme<T8_ECLASS_VERTEX>> ();
builder.add_eclass_scheme<t8_standalone_scheme<T8_ECLASS_LINE>> ();
builder.add_eclass_scheme<t8_standalone_scheme<T8_ECLASS_QUAD>> ();
builder.add_eclass_scheme<t8_default_scheme_tri> ();
builder.add_eclass_scheme<t8_standalone_scheme<T8_ECLASS_HEX>> ();
builder.add_eclass_scheme<t8_default_scheme_tet> ();
builder.add_eclass_scheme<t8_default_scheme_prism> ();
builder.add_eclass_scheme<t8_default_scheme_pyramid> ();
// builder.add_eclass_scheme<t8_standalone_scheme<T8_ECLASS_PYRAMID>> (); //ADD if PYRAMID in "element_get_shape"
return builder.build_scheme ();
}

int
t8_eclass_scheme_is_standalone (const t8_scheme *scheme, const t8_eclass_t eclass)
{
switch (eclass) {
case T8_ECLASS_VERTEX:
return scheme->check_eclass_scheme_type<t8_standalone_scheme<T8_ECLASS_VERTEX>> (T8_ECLASS_VERTEX);
case T8_ECLASS_LINE:
return scheme->check_eclass_scheme_type<t8_standalone_scheme<T8_ECLASS_LINE>> (T8_ECLASS_LINE);
case T8_ECLASS_QUAD:
return scheme->check_eclass_scheme_type<t8_standalone_scheme<T8_ECLASS_QUAD>> (T8_ECLASS_QUAD);
// case T8_ECLASS_TRIANGLE:
// return scheme->check_eclass_scheme_type<t8_standalone_scheme<T8_ECLASS_TRIANGLE>> (T8_ECLASS_TRIANGLE);
case T8_ECLASS_HEX:
return scheme->check_eclass_scheme_type<t8_standalone_scheme<T8_ECLASS_HEX>> (T8_ECLASS_HEX);
// case T8_ECLASS_TET:
// return scheme->check_eclass_scheme_type<t8_standalone_scheme<T8_ECLASS_PRISM>> (T8_ECLASS_TET);
// case T8_ECLASS_PRISM:
// return scheme->check_eclass_scheme_type<t8_standalone_scheme<T8_ECLASS_PRISM>> (T8_ECLASS_PRISM);
// case T8_ECLASS_PYRAMID:
// return scheme->check_eclass_scheme_type<t8_standalone_scheme<T8_ECLASS_PYRAMID>> (T8_ECLASS_PYRAMID);
default:
SC_ABORT_NOT_REACHED ();
}
return 0; /* Default return value false */
}

T8_EXTERN_C_END ();
46 changes: 46 additions & 0 deletions src/t8_schemes/t8_standalone/t8_standalone.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
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) 2025 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.
*/

#ifndef T8_STANDALONE_HXX
#define T8_STANDALONE_HXX

#include <t8_schemes/t8_scheme.hxx>
#include <t8_schemes/t8_standalone/t8_standalone_implementation.hxx>

T8_EXTERN_C_BEGIN ();

/** Return the standalone element implementation of t8code. */
t8_scheme *
t8_scheme_new_standalone (void);

/** Check whether a given eclass_scheme is one of the standalone schemes.
* \param [in] scheme A (pointer to a) scheme
* \param [in] eclass The eclass to check
* \return True (non-zero) if \a scheme is one of the default schemes,
* false (zero) otherwise.
*/
int
t8_eclass_scheme_is_standalone (const t8_scheme *scheme, const t8_eclass_t eclass);

T8_EXTERN_C_END ();

#endif /* !T8_STANDALONE_HXX */
84 changes: 84 additions & 0 deletions src/t8_schemes/t8_standalone/t8_standalone_elements.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
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) 2025 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.
*/

#ifndef T8_STANDALONE_ELEMENTS_HXX
lukasdreyer marked this conversation as resolved.
Show resolved Hide resolved
#define T8_STANDALONE_ELEMENTS_HXX

#include <t8.h>
#include <array>
#include <bitset>

#define t8_standalone_element t8_standalone

constexpr uint8_t T8_ELEMENT_DIM[T8_ECLASS_COUNT] = { 0, 1, 2, 2, 3, 3, 3, 3 };
constexpr uint8_t T8_ELEMENT_MAXLEVEL[T8_ECLASS_COUNT] = { 255, 30, 29, 29, 21, 21, 21, 18 };
constexpr uint8_t T8_ELEMENT_MAX_NUM_FACES[T8_ECLASS_COUNT] = { 1, 2, 4, 3, 6, 4, 5, 5 };
constexpr uint8_t T8_ELEMENT_NUM_CHILDREN[T8_ECLASS_COUNT] = { 1, 2, 4, 4, 8, 8, 8, 10 };
constexpr uint8_t T8_ELEMENT_NUM_CORNERS[T8_ECLASS_COUNT] = { 1, 2, 4, 3, 8, 4, 6, 5 };
constexpr uint8_t T8_ELEMENT_NUM_FACES[T8_ECLASS_COUNT] = { 0, 2, 4, 3, 6, 4, 5, 5 };
constexpr uint8_t T8_ELEMENT_MAX_NUM_FACECHILDREN[T8_ECLASS_COUNT] = { 0, 1, 2, 2, 4, 4, 4, 4 };

constexpr uint8_t T8_ELEMENT_NUM_EQUATIONS[T8_ECLASS_COUNT] = { 0, 0, 0, 1, 0, 3, 1, 2 };

/**PARENT CHILD BIJECTION*/
template <t8_eclass_t TEclass>
constexpr int8_t t8_element_type_Iloc_to_childtype[1 << T8_ELEMENT_NUM_EQUATIONS[TEclass]]
[T8_ELEMENT_NUM_CHILDREN[TEclass]];
template <t8_eclass_t TEclass>
constexpr int8_t t8_element_type_Iloc_to_childcubeid[1 << T8_ELEMENT_NUM_EQUATIONS[TEclass]]
[T8_ELEMENT_NUM_CHILDREN[TEclass]];
template <t8_eclass_t TEclass>
constexpr int8_t t8_element_type_cubeid_to_parenttype[1 << T8_ELEMENT_NUM_EQUATIONS[TEclass]]
[1 << T8_ELEMENT_DIM[TEclass]];
template <t8_eclass_t TEclass>
constexpr int8_t t8_element_type_cubeid_to_Iloc[1 << T8_ELEMENT_NUM_EQUATIONS[TEclass]][1 << T8_ELEMENT_DIM[TEclass]];

/**TYPE EQUATIONS*/
template <t8_eclass_t TEclass>
constexpr int8_t t8_type_edge_equations[T8_ELEMENT_NUM_EQUATIONS[TEclass]][2];

/**VERTEX*/
template <t8_eclass_t TEclass>
constexpr int8_t t8_type_vertex_dim_to_binary[1 << T8_ELEMENT_NUM_EQUATIONS[TEclass]][T8_ELEMENT_NUM_CORNERS[TEclass]]
[T8_ELEMENT_DIM[TEclass]];
ole-alb marked this conversation as resolved.
Show resolved Hide resolved

typedef uint32_t t8_element_coord;
typedef uint8_t t8_element_level;
typedef int8_t t8_cube_id;

template <t8_eclass_t TEclass>
using t8_element_type = std::bitset<T8_ELEMENT_NUM_EQUATIONS[TEclass]>;

template <t8_eclass_t TEclass>
using t8_element_coords = std::array<t8_element_coord, T8_ELEMENT_DIM[TEclass]>;

template <t8_eclass_t TEclass>
struct t8_standalone_element
{
/** The refinement level of the element relative to the root at level 0. */
t8_element_level level;

/** The coordinates of the anchor vertex of the element. */
t8_element_coords<TEclass> coords;
};

#endif /* T8_STANDALONE_ELEMENTS_HXX */
Loading
Loading