From aac3da7cd169eb8c8e966aeb08c29535268e80a6 Mon Sep 17 00:00:00 2001 From: Tim Griesbach Date: Wed, 18 Oct 2023 20:34:30 +0200 Subject: [PATCH 1/6] Add domain constructor for given p4est --- src/fclaw2d_convenience.c | 14 ++++++++++++++ src/fclaw2d_convenience.h | 12 ++++++++++++ src/fclaw2d_to_3d.h | 1 + src/fclaw3d_convenience.h | 12 ++++++++++++ 4 files changed, 39 insertions(+) diff --git a/src/fclaw2d_convenience.c b/src/fclaw2d_convenience.c index 7a61225ff..4e6d99959 100644 --- a/src/fclaw2d_convenience.c +++ b/src/fclaw2d_convenience.c @@ -310,6 +310,20 @@ fclaw2d_domain_new (p4est_wrap_t * wrap, sc_keyvalue_t * attributes) return domain; } +fclaw2d_domain_t * +fclaw2d_domain_new_p4est (p4est_t *p4est) +{ + FCLAW_ASSERT (p4est != NULL); + + p4est_wrap_t *wrap; + + /* create p4est_wrap from the given p4est */ + wrap = p4est_wrap_new_p4est (p4est, 0, P4EST_CONNECT_FULL, NULL, NULL); + + /* attributes of the created domain is initialized by sc_keyvalue_new */ + return fclaw2d_domain_new (wrap, NULL); +} + static void fclaw2d_check_initial_level (sc_MPI_Comm mpicomm, int initial_level) { diff --git a/src/fclaw2d_convenience.h b/src/fclaw2d_convenience.h index bb30db211..e23906eb5 100644 --- a/src/fclaw2d_convenience.h +++ b/src/fclaw2d_convenience.h @@ -28,6 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #ifdef __cplusplus @@ -38,6 +39,17 @@ extern "C" #endif #endif +/** Construct a domain from a given p4est. + * + * This function takes ownership of the passed p4est and its connectivity. + * + * \param [in] p4est The p4est that is used to create the domain. + * \return A domain that is constructed based on the given + * p4est and in particular with a pp based on the + * given p4est. + */ +fclaw2d_domain_t *fclaw2d_domain_new_p4est (p4est_t *p4est); + fclaw2d_domain_t *fclaw2d_domain_new_unitsquare (sc_MPI_Comm mpicomm, int initial_level); diff --git a/src/fclaw2d_to_3d.h b/src/fclaw2d_to_3d.h index e66769698..f6d03e9b2 100644 --- a/src/fclaw2d_to_3d.h +++ b/src/fclaw2d_to_3d.h @@ -172,6 +172,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define fclaw2d_domain_new_unitsquare fclaw3d_domain_new_unitcube #define fclaw2d_domain_new_brick fclaw3d_domain_new_brick #define fclaw2d_domain_new_conn fclaw3d_domain_new_conn +#define fclaw2d_domain_new_p4est fclaw3d_domain_new_p8est #define fclaw2d_domain_num_faces fclaw3d_domain_num_faces #define fclaw2d_domain_num_corners fclaw3d_domain_num_corners #define fclaw2d_domain_num_face_corners fclaw3d_domain_num_face_corners diff --git a/src/fclaw3d_convenience.h b/src/fclaw3d_convenience.h index da583b0fe..80ca48ffe 100644 --- a/src/fclaw3d_convenience.h +++ b/src/fclaw3d_convenience.h @@ -27,6 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define FCLAW3D_CONVENIENCE_H #include +#include #include #ifdef __cplusplus @@ -37,6 +38,17 @@ extern "C" #endif #endif +/** Construct a domain from a given p8est. + * + * This function takes ownership of the passed p8est and its connectivity. + * + * \param [in] p8est The p8est that is used to create the domain. + * \return A domain that is constructed based on the given + * p8est and in particular with a pp based on the + * given p8est. + */ +fclaw3d_domain_t *fclaw3d_domain_new_p8est (p8est_t *p8est); + fclaw3d_domain_t *fclaw3d_domain_new_unitcube (sc_MPI_Comm mpicomm, int initial_level); From 9dd39be7fae6a5741c6f3c95605370e2ad202dff Mon Sep 17 00:00:00 2001 From: Tim Griesbach Date: Thu, 19 Oct 2023 18:56:38 +0200 Subject: [PATCH 2/6] domain_new_p4est: Add user_pointer condition --- src/fclaw2d_convenience.c | 1 + src/fclaw2d_convenience.h | 4 +++- src/fclaw3d_convenience.h | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/fclaw2d_convenience.c b/src/fclaw2d_convenience.c index 63f2d258f..340f31ba9 100644 --- a/src/fclaw2d_convenience.c +++ b/src/fclaw2d_convenience.c @@ -314,6 +314,7 @@ fclaw2d_domain_t * fclaw2d_domain_new_p4est (p4est_t *p4est) { FCLAW_ASSERT (p4est != NULL); + FCLAW_ASSERT (p4est->user_pointer == NULL); p4est_wrap_t *wrap; diff --git a/src/fclaw2d_convenience.h b/src/fclaw2d_convenience.h index 2032f0a01..6ca1b16d4 100644 --- a/src/fclaw2d_convenience.h +++ b/src/fclaw2d_convenience.h @@ -42,7 +42,9 @@ extern "C" * * This function takes ownership of the passed p4est and its connectivity. * - * \param [in] p4est The p4est that is used to create the domain. + * \param [in,out] p4est The p4est that is used to create the domain. + * p4est->user_pointer must be NULL and will be + * changed. * \return A domain that is constructed based on the given * p4est and in particular with a pp based on the * given p4est. diff --git a/src/fclaw3d_convenience.h b/src/fclaw3d_convenience.h index 80ca48ffe..c8be71b7c 100644 --- a/src/fclaw3d_convenience.h +++ b/src/fclaw3d_convenience.h @@ -42,7 +42,9 @@ extern "C" * * This function takes ownership of the passed p8est and its connectivity. * - * \param [in] p8est The p8est that is used to create the domain. + * \param [in,out] p8est The p8est that is used to create the domain. + * p8est->user_pointer must be NULL and will be + * changed. * \return A domain that is constructed based on the given * p8est and in particular with a pp based on the * given p8est. From 1c9838ee965e3f622b1c2c86a2f1c69931bc8b88 Mon Sep 17 00:00:00 2001 From: Tim Griesbach Date: Thu, 19 Oct 2023 18:57:14 +0200 Subject: [PATCH 3/6] domain_new_p4est: Remove redundant include --- src/fclaw2d_convenience.h | 1 - src/fclaw3d_convenience.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/fclaw2d_convenience.h b/src/fclaw2d_convenience.h index 6ca1b16d4..3fc52d298 100644 --- a/src/fclaw2d_convenience.h +++ b/src/fclaw2d_convenience.h @@ -28,7 +28,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include #ifdef __cplusplus extern "C" diff --git a/src/fclaw3d_convenience.h b/src/fclaw3d_convenience.h index c8be71b7c..68eb67012 100644 --- a/src/fclaw3d_convenience.h +++ b/src/fclaw3d_convenience.h @@ -28,7 +28,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include #ifdef __cplusplus extern "C" From 5b16e77c6a08ddb69a26db41e2aa2a5267a55795 Mon Sep 17 00:00:00 2001 From: Tim Griesbach Date: Mon, 23 Oct 2023 12:27:28 +0200 Subject: [PATCH 4/6] domain_new_p4est: Assume resetting of p4est data size --- src/fclaw2d_convenience.c | 2 ++ src/fclaw2d_convenience.h | 3 ++- src/fclaw3d_convenience.h | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fclaw2d_convenience.c b/src/fclaw2d_convenience.c index 340f31ba9..b0fa8dc26 100644 --- a/src/fclaw2d_convenience.c +++ b/src/fclaw2d_convenience.c @@ -321,6 +321,8 @@ fclaw2d_domain_new_p4est (p4est_t *p4est) /* create p4est_wrap from the given p4est */ wrap = p4est_wrap_new_p4est (p4est, 0, P4EST_CONNECT_FULL, NULL, NULL); + FCLAW_ASSERT (wrap->p4est->data_size == 0); + /* attributes of the created domain is initialized by sc_keyvalue_new */ return fclaw2d_domain_new (wrap, NULL); } diff --git a/src/fclaw2d_convenience.h b/src/fclaw2d_convenience.h index 3fc52d298..8941c0814 100644 --- a/src/fclaw2d_convenience.h +++ b/src/fclaw2d_convenience.h @@ -43,7 +43,8 @@ extern "C" * * \param [in,out] p4est The p4est that is used to create the domain. * p4est->user_pointer must be NULL and will be - * changed. + * changed. The data size will be set to 0 and the + * quadrant data will be freed. * \return A domain that is constructed based on the given * p4est and in particular with a pp based on the * given p4est. diff --git a/src/fclaw3d_convenience.h b/src/fclaw3d_convenience.h index 68eb67012..2cb5751a5 100644 --- a/src/fclaw3d_convenience.h +++ b/src/fclaw3d_convenience.h @@ -43,7 +43,8 @@ extern "C" * * \param [in,out] p8est The p8est that is used to create the domain. * p8est->user_pointer must be NULL and will be - * changed. + * changed. The data size will be set to 0 and the + * quadrant data will be freed. * \return A domain that is constructed based on the given * p8est and in particular with a pp based on the * given p8est. From 89f6aeda9707937745067956f47dbb2a11cb0247 Mon Sep 17 00:00:00 2001 From: Tim Griesbach Date: Mon, 23 Oct 2023 13:43:31 +0200 Subject: [PATCH 5/6] domain_new_p4est: Polish documentation --- src/fclaw2d_convenience.h | 5 +++-- src/fclaw3d_convenience.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fclaw2d_convenience.h b/src/fclaw2d_convenience.h index 8941c0814..6f526bd0f 100644 --- a/src/fclaw2d_convenience.h +++ b/src/fclaw2d_convenience.h @@ -43,8 +43,9 @@ extern "C" * * \param [in,out] p4est The p4est that is used to create the domain. * p4est->user_pointer must be NULL and will be - * changed. The data size will be set to 0 and the - * quadrant data will be freed. + * changed to pointing to a p4est_wrap created using + * the given p4est. The data size of the p4est will + * be set to 0 and its quadrant data will be freed. * \return A domain that is constructed based on the given * p4est and in particular with a pp based on the * given p4est. diff --git a/src/fclaw3d_convenience.h b/src/fclaw3d_convenience.h index 2cb5751a5..7428e43f8 100644 --- a/src/fclaw3d_convenience.h +++ b/src/fclaw3d_convenience.h @@ -43,8 +43,9 @@ extern "C" * * \param [in,out] p8est The p8est that is used to create the domain. * p8est->user_pointer must be NULL and will be - * changed. The data size will be set to 0 and the - * quadrant data will be freed. + * changed to pointing to a p8est_wrap created using + * the given p8est. The data size of the p8est will + * be set to 0 and its quadrant data will be freed. * \return A domain that is constructed based on the given * p8est and in particular with a pp based on the * given p8est. From d8312e754dc15d59a18410962c6835f939145da0 Mon Sep 17 00:00:00 2001 From: Tim Griesbach Date: Fri, 27 Oct 2023 17:02:01 +0200 Subject: [PATCH 6/6] Update p4est and libsc --- p4est | 2 +- sc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/p4est b/p4est index 2c8e5714f..a5d9031f0 160000 --- a/p4est +++ b/p4est @@ -1 +1 @@ -Subproject commit 2c8e5714f8d014a779f32e3832b45fc088bbb789 +Subproject commit a5d9031f04962b7305367476e4e830aa4a4da669 diff --git a/sc b/sc index 0ea2196a0..64a750888 160000 --- a/sc +++ b/sc @@ -1 +1 @@ -Subproject commit 0ea2196a06e64888dfeae06da47f3267d87684c7 +Subproject commit 64a7508885cc6a55895758023e00227a6786111f