diff --git a/.github/workflows/ci_cmake.yml b/.github/workflows/ci_cmake.yml index e57a4951d..1523b8568 100644 --- a/.github/workflows/ci_cmake.yml +++ b/.github/workflows/ci_cmake.yml @@ -116,7 +116,7 @@ jobs: mac: - runs-on: macos-11 + runs-on: macos-14 name: CMake build on MacOS env: HOMEBREW_NO_INSTALL_CLEANUP: 1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 77cdf0914..cf4113efc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13...3.20) +cmake_minimum_required(VERSION 3.14...3.28) include(cmake/GitVersionGen.cmake) @@ -158,4 +158,9 @@ if(applications) add_subdirectory(applications) endif(applications) -include(cmake/documentation.cmake) \ No newline at end of file +include(cmake/documentation.cmake) + +# --- auto-ignore build directory +if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + file(GENERATE OUTPUT .gitignore CONTENT "*") +endif() diff --git a/Doxyfile.in b/Doxyfile.in index b93ee7901..29b13030e 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -779,7 +779,7 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = +EXCLUDE = src/fclaw2d_to_3d.h # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/applications/clawpack/acoustics/2d/interface/interface.cpp b/applications/clawpack/acoustics/2d/interface/interface.cpp index 87fdcfb0a..1e9ed4c16 100644 --- a/applications/clawpack/acoustics/2d/interface/interface.cpp +++ b/applications/clawpack/acoustics/2d/interface/interface.cpp @@ -25,8 +25,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "interface_user.h" -#include -#include +#include +#include #include #include @@ -35,38 +35,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static void -create_domain_map (fclaw2d_global_t * glob) +create_domain_map (fclaw_global_t * glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); /* Create "empty" mapping */ - fclaw2d_map_context_t* cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t* cont = fclaw_map_new_nomap(); /* Store the domain in the glob struct */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* Store the mapping context in the glob */ - fclaw2d_global_store_map(glob, cont); + fclaw_map_store(glob, cont); /* List some info */ - fclaw2d_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ const user_options_t *user_opt = interface_get_options(glob); @@ -84,9 +78,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } @@ -100,14 +94,14 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = interface_options_register(app, "fclaw_options.ini"); @@ -125,12 +119,12 @@ main (int argc, char **argv) /* Create global structure which stores the domain, timers, etc */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = - fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = + fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); interface_options_store (glob, user_opt); @@ -140,7 +134,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/acoustics/2d/interface/interface_options.c b/applications/clawpack/acoustics/2d/interface/interface_options.c index ca28a2b32..c351364e2 100644 --- a/applications/clawpack/acoustics/2d/interface/interface_options.c +++ b/applications/clawpack/acoustics/2d/interface/interface_options.c @@ -103,14 +103,14 @@ user_options_t* interface_options_register (fclaw_app_t * app, return user; } -void interface_options_store (fclaw2d_global_t* glob, user_options_t* user) +void interface_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* interface_get_options(fclaw2d_global_t* glob) +const user_options_t* interface_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/acoustics/2d/interface/interface_user.cpp b/applications/clawpack/acoustics/2d/interface/interface_user.cpp index 119bb0fcb..f4896b49e 100644 --- a/applications/clawpack/acoustics/2d/interface/interface_user.cpp +++ b/applications/clawpack/acoustics/2d/interface/interface_user.cpp @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "interface_user.h" -#include +#include #include #include @@ -35,15 +35,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../rp/acoustics_user_fort.h" -void interface_problem_setup(fclaw2d_global_t* glob) +void interface_problem_setup(fclaw_global_t* glob) { const user_options_t* user = interface_get_options(glob); INTERFACE_SETPROB(&user->rhol,&user->cl,&user->rhor,&user->cr); } -void interface_link_solvers(fclaw2d_global_t *glob) +void interface_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &interface_problem_setup; /* Version-independent */ diff --git a/applications/clawpack/acoustics/2d/interface/interface_user.h b/applications/clawpack/acoustics/2d/interface/interface_user.h index 0ab68a69d..8086d46e6 100644 --- a/applications/clawpack/acoustics/2d/interface/interface_user.h +++ b/applications/clawpack/acoustics/2d/interface/interface_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef INTERFACE_USER_H #define INTERFACE_USER_H -#include +#include #ifdef __cplusplus extern "C" @@ -53,16 +53,16 @@ typedef struct user_options user_options_t* interface_options_register (fclaw_app_t * app, const char *configfile); -void interface_options_store (fclaw2d_global_t* glob, user_options_t* user); +void interface_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* interface_get_options(fclaw2d_global_t* glob); +const user_options_t* interface_get_options(fclaw_global_t* glob); -void interface_problem_setup(fclaw2d_global_t* glob); +void interface_problem_setup(fclaw_global_t* glob); -void interface_link_solvers(fclaw2d_global_t *glob); +void interface_link_solvers(fclaw_global_t *glob); -fclaw2d_map_context_t* fclaw2d_map_new_nomap(); +fclaw_map_context_t* fclaw_map_new_nomap(); /* ----------------------------- Fortran code ----------------------------------------- */ diff --git a/applications/clawpack/acoustics/2d/radial/fclaw2d_map_pillowdisk.c b/applications/clawpack/acoustics/2d/radial/fclaw2d_map_pillowdisk.c index 3568d94da..fbc626f2c 100644 --- a/applications/clawpack/acoustics/2d/radial/fclaw2d_map_pillowdisk.c +++ b/applications/clawpack/acoustics/2d/radial/fclaw2d_map_pillowdisk.c @@ -1,6 +1,6 @@ /* Spherical disk in xy plane. Matches p4est_connectivity_new_disk (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -12,39 +12,39 @@ extern "C" static int -fclaw2d_map_query_pillowdisk (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowdisk (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -59,11 +59,11 @@ fclaw2d_map_query_pillowdisk (fclaw2d_map_context_t * cont, int query_identifier static void -fclaw2d_map_c2m_pillowdisk(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowdisk(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { - MAPC2M_PILLOWDISK(&blockno,&xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_C2M_PILLOWDISK(&blockno,&xc,&yc,xp,yp,zp); /* These can probably be replaced by C functions at some point. */ scale_map(cont, xp,yp,zp); @@ -73,13 +73,13 @@ fclaw2d_map_c2m_pillowdisk(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], const double shift[], const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowdisk; cont->mapc2m = fclaw2d_map_c2m_pillowdisk; diff --git a/applications/clawpack/acoustics/2d/radial/fclaw2d_map_pillowdisk5.c b/applications/clawpack/acoustics/2d/radial/fclaw2d_map_pillowdisk5.c index c21e151eb..1825b01e4 100644 --- a/applications/clawpack/acoustics/2d/radial/fclaw2d_map_pillowdisk5.c +++ b/applications/clawpack/acoustics/2d/radial/fclaw2d_map_pillowdisk5.c @@ -1,6 +1,6 @@ /* Spherical disk in xy plane. Matches p4est_connectivity_new_disk (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -12,39 +12,39 @@ extern "C" static int -fclaw2d_map_query_pillowdisk5 (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowdisk5 (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -59,12 +59,12 @@ fclaw2d_map_query_pillowdisk5 (fclaw2d_map_context_t * cont, int query_identifie static void -fclaw2d_map_c2m_pillowdisk5(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowdisk5(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { double alpha = cont->user_double[0]; - MAPC2M_PILLOWDISK5(&blockno,&xc,&yc,xp,yp,zp,&alpha); + FCLAW_MAP_2D_C2M_PILLOWDISK5(&blockno,&xc,&yc,xp,yp,zp,&alpha); rotate_map(cont,xp,yp,zp); @@ -72,14 +72,14 @@ fclaw2d_map_c2m_pillowdisk5(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], const double shift[], const double rotate[], const double alpha) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowdisk5; cont->mapc2m = fclaw2d_map_c2m_pillowdisk5; diff --git a/applications/clawpack/acoustics/2d/radial/radial.cpp b/applications/clawpack/acoustics/2d/radial/radial.cpp index f78c8b235..bf867ae95 100644 --- a/applications/clawpack/acoustics/2d/radial/radial.cpp +++ b/applications/clawpack/acoustics/2d/radial/radial.cpp @@ -25,14 +25,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "radial_user.h" -#include +#include /* ------------------------- Start of program ---------------------------- */ static void -create_domain(fclaw2d_global_t * glob) +create_domain(fclaw_global_t * glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); /* Local variables */ double rotate[2]; @@ -41,8 +41,8 @@ create_domain(fclaw2d_global_t * glob) rotate[1] = fclaw_opt->theta; /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; const user_options_t *user = radial_get_options(glob); switch (user->example) @@ -50,15 +50,15 @@ create_domain(fclaw2d_global_t * glob) case 0: /* Use [ax,bx]x[ay,by] */ domain = - fclaw2d_domain_new_unitsquare (glob->mpicomm, + fclaw_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); - cont = fclaw2d_map_new_nomap (); + cont = fclaw_map_new_nomap (); break; case 1: /* Map five-patch square to a disk using the pillowdisk. Input parameter alpha needed for five patch square */ domain = - fclaw2d_domain_new_disk (glob->mpicomm, 0, 0, + fclaw_domain_new_2d_disk (glob->mpicomm, 0, 0, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowdisk5 (fclaw_opt->scale, fclaw_opt->shift, @@ -67,7 +67,7 @@ create_domain(fclaw2d_global_t * glob) case 2: /* Map single Cartesian square to a pillowdisk */ domain = - fclaw2d_domain_new_unitsquare (glob->mpicomm, + fclaw_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowdisk (fclaw_opt->scale, fclaw_opt->shift, @@ -77,23 +77,18 @@ create_domain(fclaw2d_global_t * glob) SC_ABORT_NOT_REACHED (); } - fclaw2d_global_store_domain (glob, domain); - fclaw2d_global_store_map (glob, cont); + fclaw_global_store_domain (glob, domain); + fclaw_map_store (glob, cont); - fclaw2d_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ const user_options_t *user_opt = radial_get_options(glob); @@ -112,9 +107,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } @@ -127,14 +122,14 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = radial_options_register(app, "fclaw_options.ini"); @@ -155,12 +150,12 @@ main (int argc, char **argv) /* Create global structure which stores the domain, timers, etc */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = - fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = + fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); radial_options_store (glob, user_opt); @@ -169,7 +164,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/acoustics/2d/radial/radial_options.c b/applications/clawpack/acoustics/2d/radial/radial_options.c index 6b78c32ba..30c5af02f 100644 --- a/applications/clawpack/acoustics/2d/radial/radial_options.c +++ b/applications/clawpack/acoustics/2d/radial/radial_options.c @@ -159,18 +159,18 @@ user_options_t* radial_options_register (fclaw_app_t * app, return user; } -void radial_options_store (fclaw2d_global_t* glob, user_options_t* user) +void radial_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -user_options_t* radial_get_options(fclaw2d_global_t* glob) +user_options_t* radial_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } void radial_global_post_process(fclaw_options_t *fclaw_opt, - fclaw2d_clawpatch_options_t *clawpatch_opt, + fclaw_clawpatch_options_t *clawpatch_opt, user_options_t *user_opt) { if (user_opt->example == 1) diff --git a/applications/clawpack/acoustics/2d/radial/radial_user.cpp b/applications/clawpack/acoustics/2d/radial/radial_user.cpp index 27635569d..aabadfa33 100644 --- a/applications/clawpack/acoustics/2d/radial/radial_user.cpp +++ b/applications/clawpack/acoustics/2d/radial/radial_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "radial_user.h" static -void radial_problem_setup(fclaw2d_global_t* glob) +void radial_problem_setup(fclaw_global_t* glob) { user_options_t* user = radial_get_options(glob); @@ -39,7 +39,7 @@ void radial_problem_setup(fclaw2d_global_t* glob) } /* We want to make sure node 0 gets here before proceeding */ - fclaw2d_domain_barrier (glob->domain); /* redundant? */ + fclaw_domain_barrier (glob->domain); /* redundant? */ /* rho, bulk are inputs; cc and zz are outputs. Results are stored in a common block */ @@ -47,12 +47,12 @@ void radial_problem_setup(fclaw2d_global_t* glob) } static -void radial_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void radial_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { - if (fclaw2d_patch_is_ghost(patch)) + if (fclaw_patch_is_ghost(patch)) { /* Mapped info is needed only for an update */ return; @@ -60,17 +60,17 @@ void radial_patch_setup(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *xp,*yp,*zp; double *xd,*yd,*zd,*area; - fclaw2d_clawpatch_metric_data(glob,patch,&xp,&yp,&zp, + fclaw_clawpatch_2d_metric_data(glob,patch,&xp,&yp,&zp, &xd,&yd,&zd,&area); double *xnormals,*ynormals,*xtangents,*ytangents; double *surfnormals,*edgelengths,*curvature; - fclaw2d_clawpatch_metric_data2(glob,patch, + fclaw_clawpatch_2d_metric_data2(glob,patch, &xnormals,&ynormals, &xtangents,&ytangents, &surfnormals,&edgelengths, @@ -78,7 +78,7 @@ void radial_patch_setup(fclaw2d_global_t *glob, int maux; double* aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); const user_options_t* user = radial_get_options(glob); @@ -94,9 +94,9 @@ void radial_patch_setup(fclaw2d_global_t *glob, } -void radial_link_solvers(fclaw2d_global_t *glob) +void radial_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &radial_problem_setup; /* Version-independent */ @@ -114,7 +114,7 @@ void radial_link_solvers(fclaw2d_global_t *glob) } else if (user->example == 1 || user->example == 2) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &radial_patch_setup; @@ -135,7 +135,7 @@ void radial_link_solvers(fclaw2d_global_t *glob) } else if (user->example == 1 || user->example == 2) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &radial_patch_setup; diff --git a/applications/clawpack/acoustics/2d/radial/radial_user.h b/applications/clawpack/acoustics/2d/radial/radial_user.h index 130332e7c..5cea6c439 100644 --- a/applications/clawpack/acoustics/2d/radial/radial_user.h +++ b/applications/clawpack/acoustics/2d/radial/radial_user.h @@ -26,10 +26,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef RADIAL_USER_H #define RADIAL_USER_H -#include +#include -#include -#include +#include +#include #include #include @@ -66,18 +66,18 @@ typedef struct user_options } user_options_t; -void radial_link_solvers(fclaw2d_global_t *glob); +void radial_link_solvers(fclaw_global_t *glob); /* --------------------------------- Options ------------------------------------- */ user_options_t* radial_options_register (fclaw_app_t * app, const char *configfile); -void radial_options_store (fclaw2d_global_t* glob, user_options_t* user); +void radial_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* radial_get_options(fclaw2d_global_t* glob); +user_options_t* radial_get_options(fclaw_global_t* glob); void radial_global_post_process(fclaw_options_t *fclaw_opt, - fclaw2d_clawpatch_options_t *clawpatch_opt, + fclaw_clawpatch_options_t *clawpatch_opt, user_options_t *user_opt); @@ -109,12 +109,12 @@ void CLAWPACK5_SETAUX_MANIFOLD(const int* mbc, /* -------------------------------- Mappings ------------------------------------- */ -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], const double shift[], const double rotate[], const double alpha); -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], const double shift[], const double rotate[]); diff --git a/applications/clawpack/acoustics/2d/radial/user_5.0/qinit.f90 b/applications/clawpack/acoustics/2d/radial/user_5.0/qinit.f90 index a7ef526f7..b58614b8c 100644 --- a/applications/clawpack/acoustics/2d/radial/user_5.0/qinit.f90 +++ b/applications/clawpack/acoustics/2d/radial/user_5.0/qinit.f90 @@ -13,7 +13,7 @@ SUBROUTINE clawpack5_qinit(meqn,mbc,mx,my,xlower,ylower, & INTEGER blockno, fc2d_clawpack5_get_block INTEGER*8 cont, fclaw_map_get_context - LOGICAL fclaw2d_map_is_used + LOGICAL fclaw_map_is_used DOUBLE PRECISION pi COMMON /compi/ pi @@ -27,8 +27,8 @@ SUBROUTINE clawpack5_qinit(meqn,mbc,mx,my,xlower,ylower, & xc = xlower + (i-0.5d0)*dx DO j = 1-mbc,my+mbc yc = ylower + (j-0.5d0)*dy - IF (fclaw2d_map_is_used(cont)) THEN - CALL fclaw2d_map_c2m(cont,blockno,xc,yc,xp,yp,zp) + IF (fclaw_map_is_used(cont)) THEN + CALL fclaw_map_2d_c2m(cont,blockno,xc,yc,xp,yp,zp) r = SQRT(xp**2 + yp**2) ELSE r = SQRT(xc**2 + yc**2) diff --git a/applications/clawpack/advection/2d/adv_order3/periodic.cpp b/applications/clawpack/advection/2d/adv_order3/periodic.cpp index d1ce07547..c87688171 100644 --- a/applications/clawpack/advection/2d/adv_order3/periodic.cpp +++ b/applications/clawpack/advection/2d/adv_order3/periodic.cpp @@ -25,10 +25,10 @@ #include "periodic_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -37,12 +37,12 @@ #include static -fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* gparms) +fclaw_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* gparms) { /* Mapped, multi-block domain */ p4est_connectivity_t *conn = NULL; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL, *brick = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL, *brick = NULL; int mi = gparms->mi; int mj = gparms->mj; @@ -52,29 +52,29 @@ fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* gparms) /* Map unit square to disk using mapc2m_disk.f */ conn = p4est_connectivity_new_brick(mi,mj,a,b); brick = fclaw2d_map_new_brick_conn (conn,mi,mj); - cont = fclaw2d_map_new_nomap_brick(brick); + cont = fclaw_map_new_nomap_brick(brick); domain = fclaw2d_domain_new_conn_map (mpicomm, gparms->minlevel, conn, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); return domain; } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { const user_options_t *user_opt; /* --------------------------------------------------------------- Set domain data. --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); + you_can_safely_remove_this_call(glob->domain); user_opt = periodic_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -91,9 +91,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -106,12 +106,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; - fclaw2d_global_t *glob; - fclaw2d_domain_t *domain; + fclaw_global_t *glob; + fclaw_domain_t *domain; sc_MPI_Comm mpicomm; /* Initialize application */ @@ -119,7 +119,7 @@ main (int argc, char **argv) /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = periodic_options_register(app, "fclaw_options.ini"); @@ -136,19 +136,19 @@ main (int argc, char **argv) domain = create_domain(mpicomm, fclaw_opt); /* Create global structure which stores the domain, timers, etc */ - glob = fclaw2d_global_new(); - fclaw2d_global_store_domain(glob, domain); + glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); periodic_options_store (glob, user_opt); run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/adv_order3/periodic_options.c b/applications/clawpack/advection/2d/adv_order3/periodic_options.c index c006f2663..8df2735c7 100644 --- a/applications/clawpack/advection/2d/adv_order3/periodic_options.c +++ b/applications/clawpack/advection/2d/adv_order3/periodic_options.c @@ -158,12 +158,12 @@ user_options_t* periodic_options_register (fclaw_app_t * app, return user; } -void periodic_options_store (fclaw2d_global_t* glob, user_options_t* user) +void periodic_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* periodic_get_options(fclaw2d_global_t* glob) +const user_options_t* periodic_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/adv_order3/periodic_user.cpp b/applications/clawpack/advection/2d/adv_order3/periodic_user.cpp index 2d3d795f9..db24213b6 100644 --- a/applications/clawpack/advection/2d/adv_order3/periodic_user.cpp +++ b/applications/clawpack/advection/2d/adv_order3/periodic_user.cpp @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "periodic_user.h" -#include +#include /* Two versions of Clawpack */ #include @@ -34,11 +34,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include +#include #include static -void periodic_problem_setup(fclaw2d_global_t* glob) +void periodic_problem_setup(fclaw_global_t* glob) { const user_options_t* user = periodic_get_options(glob); @@ -51,14 +51,14 @@ void periodic_problem_setup(fclaw2d_global_t* glob) fprintf(f, "%20.16f %s",user->vbar,"\% vbar\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); PERIODIC_SETPROB(); } static -void cb_periodic_output_ascii (fclaw2d_domain_t * domain, - fclaw2d_patch_t * this_patch, +void cb_periodic_output_ascii (fclaw_domain_t * domain, + fclaw_patch_t * this_patch, int this_block_idx, int this_patch_idx, void *user) { @@ -69,11 +69,11 @@ void cb_periodic_output_ascii (fclaw2d_domain_t * domain, double *q, *error, *soln; int iframe; - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) s->glob; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) s->glob; //fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); const user_options_t *user_opt = periodic_get_options(glob); @@ -83,16 +83,16 @@ void cb_periodic_output_ascii (fclaw2d_domain_t * domain, /* Get info not readily available to user */ - fclaw2d_patch_get_info(glob->domain,this_patch, + fclaw_patch_get_info(glob->domain,this_patch, this_block_idx,this_patch_idx, &patch_num,&level); - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - error = fclaw2d_clawpatch_get_error(glob,this_patch); - soln = fclaw2d_clawpatch_get_exactsoln(glob,this_patch); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + error = fclaw_clawpatch_get_error(glob,this_patch); + soln = fclaw_clawpatch_get_exactsoln(glob,this_patch); char fname[BUFSIZ]; snprintf (fname, BUFSIZ, "%s.q%04d", fclaw_opt->prefix, iframe); @@ -113,9 +113,9 @@ void cb_periodic_output_ascii (fclaw2d_domain_t * domain, -void periodic_link_solvers(fclaw2d_global_t *glob) +void periodic_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &periodic_problem_setup; /* Version-independent */ @@ -130,11 +130,11 @@ void periodic_link_solvers(fclaw2d_global_t *glob) clawpack46_vt->fort_rpt2 = &CLAWPACK46_RPT2; clawpack46_vt->fort_rpn2_cons = &RPN2CONS_UPDATE; - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); clawpatch_vt->fort_tag4coarsening = &TAG4COARSENING; clawpatch_vt->fort_tag4refinement = &TAG4REFINEMENT; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); if (fclaw_opt->compute_error) { clawpatch_vt->fort_compute_patch_error = &PERIODIC_COMPUTE_ERROR; diff --git a/applications/clawpack/advection/2d/adv_order3/periodic_user.h b/applications/clawpack/advection/2d/adv_order3/periodic_user.h index 310c5207a..8aa67dbf6 100644 --- a/applications/clawpack/advection/2d/adv_order3/periodic_user.h +++ b/applications/clawpack/advection/2d/adv_order3/periodic_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef PERIODIC_USER_H #define PERIODIC_USER_H -#include +#include #include @@ -56,13 +56,13 @@ typedef struct user_options user_options_t* periodic_options_register (fclaw_app_t * app, const char *configfile); -void periodic_options_store (fclaw2d_global_t* glob, user_options_t* user); +void periodic_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* periodic_get_options(fclaw2d_global_t* glob); +const user_options_t* periodic_get_options(fclaw_global_t* glob); /* ------------------- Public functions defined in periodic_user -----------------------*/ -void periodic_link_solvers(fclaw2d_global_t *glob); +void periodic_link_solvers(fclaw_global_t *glob); /* ------------------------------------ Fortran ----------------------------------------*/ #define PERIODIC_SETPROB FCLAW_F77_FUNC(periodic_setprob, PERIODIC_SETPROB) @@ -98,7 +98,7 @@ void PERIODIC_FORT_INTERPOLATE_FACE(const int* mx, const int* my, const int* idir, const int* iside, const int* num_neighbors, const int* refratio, const int* igrid, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); #define PERIODIC_FORT_INTERPOLATE_CORNER \ @@ -108,7 +108,7 @@ void PERIODIC_FORT_INTERPOLATE_CORNER(const int* mx, const int* my, const int* mbc,const int* meqn, const int* a_refratio, double this_q[], double neighbor_q[], const int* a_corner, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); diff --git a/applications/clawpack/advection/2d/adv_order3/user_4.6/tag4refinement.f b/applications/clawpack/advection/2d/adv_order3/user_4.6/tag4refinement.f index 29bd5c1d3..9f76900fb 100644 --- a/applications/clawpack/advection/2d/adv_order3/user_4.6/tag4refinement.f +++ b/applications/clawpack/advection/2d/adv_order3/user_4.6/tag4refinement.f @@ -14,7 +14,7 @@ subroutine tag4refinement(mx,my,mbc, common /refinement_comm/ refinement_strategy integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used integer example common /example_comm/ example diff --git a/applications/clawpack/advection/2d/all/advection_b4step2_manifold.c b/applications/clawpack/advection/2d/all/advection_b4step2_manifold.c index c651258ab..cfc9b2352 100644 --- a/applications/clawpack/advection/2d/all/advection_b4step2_manifold.c +++ b/applications/clawpack/advection/2d/all/advection_b4step2_manifold.c @@ -25,8 +25,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "advection_user.h" -void advection_b4step2_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void advection_b4step2_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -35,16 +35,16 @@ void advection_b4step2_manifold(fclaw2d_global_t *glob, { int mx, my, mbc; double xlower,ylower, dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *xp,*yp,*zp,*xd,*yd,*zd; double *area; - fclaw2d_clawpatch_metric_data(glob,patch,&xp,&yp,&zp,&xd,&yd,&zd,&area); + fclaw_clawpatch_2d_metric_data(glob,patch,&xp,&yp,&zp,&xd,&yd,&zd,&area); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); if (claw_version == 4) USER46_B4STEP2_MANIFOLD(&mx,&my,&mbc,&dx,&dy,&t,&maux,aux,&blockno,xd,yd,zd); diff --git a/applications/clawpack/advection/2d/all/advection_patch_setup_manifold.c b/applications/clawpack/advection/2d/all/advection_patch_setup_manifold.c index 516e45a86..b2632c738 100644 --- a/applications/clawpack/advection/2d/all/advection_patch_setup_manifold.c +++ b/applications/clawpack/advection/2d/all/advection_patch_setup_manifold.c @@ -25,25 +25,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "advection_user.h" -void advection_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void advection_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int block, int patchno, int claw_version) { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *xd,*yd,*zd,*area; double *xp,*yp,*zp; - fclaw2d_clawpatch_metric_data(glob,patch,&xp,&yp,&zp, + fclaw_clawpatch_2d_metric_data(glob,patch,&xp,&yp,&zp, &xd,&yd,&zd,&area); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); if (claw_version == 4) USER46_SETAUX_MANIFOLD(&mbc,&mx,&my,&xlower,&ylower, diff --git a/applications/clawpack/advection/2d/all/advection_user.h b/applications/clawpack/advection/2d/all/advection_user.h index a71461098..0789afbd9 100644 --- a/applications/clawpack/advection/2d/all/advection_user.h +++ b/applications/clawpack/advection/2d/all/advection_user.h @@ -26,13 +26,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ADVECTION_USER_2D_H #define ADVECTION_USER_2D_H -#include +#include -#include +#include /* Headers for both Clawpack 4.6 and Clawpack 5.0 */ -#include -#include +#include +#include #include @@ -65,14 +65,14 @@ extern "C" /* Common patch setup - this calls a common SETAUX routine that sets velocities based on a streamfunction */ -void advection_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void advection_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int block, int patchno, int claw_version); -void advection_b4step2_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void advection_b4step2_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_annulus.c b/applications/clawpack/advection/2d/all/fclaw2d_map_annulus.c index 6cd43b7c8..1186f01e9 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_annulus.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_annulus.c @@ -1,6 +1,6 @@ /* Pillow grid surface. Matches p4est_connectivity_new_pillow (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -11,42 +11,42 @@ extern "C" #endif static int -fclaw2d_map_query_annulus (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_annulus (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -61,7 +61,7 @@ fclaw2d_map_query_annulus (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_annulus (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_annulus (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { @@ -69,7 +69,7 @@ fclaw2d_map_c2m_annulus (fclaw2d_map_context_t * cont, int blockno, /* Scale's brick mapping to [0,1]x[0,1] */ /* fclaw2d_map_context_t *brick_map = (fclaw2d_map_context_t*) cont->user_data; */ - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); /* blockno is ignored in the current annulus mapping; it just assumes a single "logical" block in [0,1]x[0,1] */ @@ -77,22 +77,22 @@ fclaw2d_map_c2m_annulus (fclaw2d_map_context_t * cont, int blockno, double theta[2]; theta[0] = cont->user_double[1]; theta[1] = cont->user_double[2]; - MAPC2M_ANNULUS(&blockno,&xc1,&yc1,xp,yp,zp,&beta,theta); + FCLAW_MAP_2D_C2M_ANNULUS(&blockno,&xc1,&yc1,xp,yp,zp,&beta,theta); scale_map(cont, xp,yp,zp); rotate_map(cont, xp, yp, zp); } -fclaw2d_map_context_t * - fclaw2d_map_new_annulus (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_annulus (fclaw_map_context_t* brick, const double scale[], const double rotate[], const double beta, const double theta[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_annulus; cont->mapc2m = fclaw2d_map_c2m_annulus; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_bilinear.c b/applications/clawpack/advection/2d/all/fclaw2d_map_bilinear.c index 5a038780b..889494878 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_bilinear.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_bilinear.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -18,43 +18,43 @@ void MAPC2M_BILINEAR(int* blockno, double* xc, double *yc, double *center); static int -fclaw2d_map_query_bilinear (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_bilinear (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BILINEAR: + case FCLAW_MAP_QUERY_IS_BILINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -82,7 +82,7 @@ fclaw2d_map_c2m_basis_bilinear(fclaw2d_map_context_t * cont, static void -fclaw2d_map_c2m_bilinear(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_bilinear(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { @@ -125,14 +125,14 @@ fclaw3dx_map_c2m_bilinear(fclaw2d_map_context_t * cont, int blockno, #endif -fclaw2d_map_context_t* fclaw2d_map_new_bilinear(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_bilinear(fclaw_map_context_t *brick, const double scale[], const double shift[], const double center[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO(fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO(fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_bilinear; cont->mapc2m = fclaw2d_map_c2m_bilinear; //cont->mapc2m_3dx = fclaw3dx_map_c2m_bilinear; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_cart.c b/applications/clawpack/advection/2d/all/fclaw2d_map_cart.c index 07821416d..278b112c3 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_cart.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_cart.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -12,41 +12,41 @@ extern "C" #endif static int -fclaw2d_map_query_cart (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_cart (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -61,16 +61,16 @@ fclaw2d_map_query_cart (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_cart(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_cart(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* Brick mapping to computational coordinates [0,1]x[0,1] */ double xc1, yc1, zc1; - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); /* Unit square in [-1,1] x [-1,1] */ - MAPC2M_CART(&blockno,&xc1,&yc1,xp,yp,zp); + FCLAW_MAP_2D_C2M_CART(&blockno,&xc1,&yc1,xp,yp,zp); if (cont->is_extruded == 0) { @@ -104,13 +104,13 @@ fclaw3dx_map_c2m_cart(fclaw2d_map_context_t * cont, int blockno, } #endif -fclaw2d_map_context_t* fclaw2d_map_new_cart(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_cart(fclaw_map_context_t *brick, const double scale[], const double shift[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_cart; cont->mapc2m = fclaw2d_map_c2m_cart; cont->brick = brick; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_cubedsphere.c b/applications/clawpack/advection/2d/all/fclaw2d_map_cubedsphere.c index 4c951314d..0261a04fd 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_cubedsphere.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_cubedsphere.c @@ -1,6 +1,6 @@ /* Cubed sphere surface. Matches p4est_connectivity_new_cubed (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -9,42 +9,42 @@ extern "C" static int -fclaw2d_map_query_cubedsphere (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_cubedsphere (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -59,11 +59,11 @@ fclaw2d_map_query_cubedsphere (fclaw2d_map_context_t * cont, int query_identifie static void -fclaw2d_map_c2m_cubedsphere (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_cubedsphere (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { - MAPC2M_CUBEDSPHERE(&blockno, &xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_C2M_CUBEDSPHERE(&blockno, &xc,&yc,xp,yp,zp); if (cont->is_extruded == 0) { @@ -74,13 +74,13 @@ fclaw2d_map_c2m_cubedsphere (fclaw2d_map_context_t * cont, int blockno, -fclaw2d_map_context_t * +fclaw_map_context_t * fclaw2d_map_new_cubedsphere(const double scale[], const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_cubedsphere; cont->mapc2m = fclaw2d_map_c2m_cubedsphere; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_fivepatch.c b/applications/clawpack/advection/2d/all/fclaw2d_map_fivepatch.c index 62cb34c61..6063a6a7a 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_fivepatch.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_fivepatch.c @@ -1,6 +1,6 @@ /* Five bilinear patches */ -#include +#include #ifdef __cplusplus extern "C" @@ -12,41 +12,41 @@ extern "C" #endif static int -fclaw2d_map_query_fivepatch(fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_fivepatch(fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -61,13 +61,13 @@ fclaw2d_map_query_fivepatch(fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_fivepatch(fclaw2d_map_context_t* cont, int blockno, +fclaw2d_map_c2m_fivepatch(fclaw_map_context_t* cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* five patch square in [-1,1]x[-1,1] */ double alpha = cont->user_double[0]; - MAPC2M_FIVEPATCH(&blockno,&xc,&yc,xp,yp,zp,&alpha); + FCLAW_MAP_2D_C2M_FIVEPATCH(&blockno,&xc,&yc,xp,yp,zp,&alpha); if (cont->is_extruded == 0) { @@ -97,13 +97,13 @@ fclaw3dx_map_c2m_fivepatch(fclaw2d_map_context_t* cont, int blockno, #endif -fclaw2d_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], const double shift[], const double alpha) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_fivepatch; cont->mapc2m = fclaw2d_map_c2m_fivepatch; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_latlong.c b/applications/clawpack/advection/2d/all/fclaw2d_map_latlong.c index a8a038384..b93720917 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_latlong.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_latlong.c @@ -1,6 +1,6 @@ /* Pillow grid surface. Matches p4est_connectivity_new_pillow (). */ -#include +#include #if 0 /* Fix syntax highlighting */ @@ -8,42 +8,42 @@ static int -fclaw2d_map_query_latlong (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_latlong (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -58,7 +58,7 @@ fclaw2d_map_query_latlong (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_latlong (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_latlong (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { @@ -68,7 +68,7 @@ fclaw2d_map_c2m_latlong (fclaw2d_map_context_t * cont, int blockno, /* fclaw2d_map_context_t *brick_map = (fclaw2d_map_context_t*) cont->user_data; */ /* Scale's brick mapping to [0,1]x[0,1] to create a single "logical" block */ - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); /* Scale into lat/long box */ lat[0] = cont->user_double[0]; @@ -80,7 +80,7 @@ fclaw2d_map_c2m_latlong (fclaw2d_map_context_t * cont, int blockno, /* blockno is ignored in the current latlong mapping; it just assumes a single "logical" block in [long0,long1]x[lat0,lat1] */ - MAPC2M_LATLONG(&blockno,&xc2,&yc2,xp,yp,zp); + FCLAW_MAP_2D_C2M_LATLONG(&blockno,&xc2,&yc2,xp,yp,zp); if (cont->is_extruded == 0) { @@ -91,17 +91,17 @@ fclaw2d_map_c2m_latlong (fclaw2d_map_context_t * cont, int blockno, -fclaw2d_map_context_t * - fclaw2d_map_new_latlong (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_latlong (fclaw_map_context_t* brick, const double scale[], const double rotate[], const double lat[], const double longitude[], const int a, const int b) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_latlong; cont->mapc2m = fclaw2d_map_c2m_latlong; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_pillowdisk.c b/applications/clawpack/advection/2d/all/fclaw2d_map_pillowdisk.c index 6009c922e..38658ef73 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_pillowdisk.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_pillowdisk.c @@ -1,6 +1,6 @@ /* Spherical disk in xy plane. Matches p4est_connectivity_new_disk (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -13,40 +13,40 @@ extern "C" static int -fclaw2d_map_query_pillowdisk (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowdisk (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -61,12 +61,12 @@ fclaw2d_map_query_pillowdisk (fclaw2d_map_context_t * cont, int query_identifier static void -fclaw2d_map_c2m_pillowdisk(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowdisk(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* Unit disk centered at (0,0) */ - MAPC2M_PILLOWDISK(&blockno,&xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_C2M_PILLOWDISK(&blockno,&xc,&yc,xp,yp,zp); if (cont->is_extruded == 0) { @@ -76,13 +76,13 @@ fclaw2d_map_c2m_pillowdisk(fclaw2d_map_context_t * cont, int blockno, } } -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], const double shift[], const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowdisk; cont->mapc2m = fclaw2d_map_c2m_pillowdisk; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_pillowdisk5.c b/applications/clawpack/advection/2d/all/fclaw2d_map_pillowdisk5.c index 85c2ead09..b4e3e1304 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_pillowdisk5.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_pillowdisk5.c @@ -1,6 +1,6 @@ /* Spherical disk in xy plane. Matches p4est_connectivity_new_disk (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -9,39 +9,39 @@ extern "C" static int -fclaw2d_map_query_pillowdisk5 (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowdisk5 (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -56,13 +56,13 @@ fclaw2d_map_query_pillowdisk5 (fclaw2d_map_context_t * cont, int query_identifie static void -fclaw2d_map_c2m_pillowdisk5(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowdisk5(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* Unit disk centered at (0,0) */ double alpha = cont->user_double[0]; - MAPC2M_PILLOWDISK5(&blockno,&xc,&yc,xp,yp,zp,&alpha); + FCLAW_MAP_2D_C2M_PILLOWDISK5(&blockno,&xc,&yc,xp,yp,zp,&alpha); if (cont->is_extruded == 0) { @@ -72,14 +72,14 @@ fclaw2d_map_c2m_pillowdisk5(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], const double shift[], const double rotate[], const double alpha) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowdisk5; cont->mapc2m = fclaw2d_map_c2m_pillowdisk5; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_pillowsphere.c b/applications/clawpack/advection/2d/all/fclaw2d_map_pillowsphere.c index 1787efbb5..b29c9ff19 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_pillowsphere.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_pillowsphere.c @@ -1,6 +1,6 @@ /* Pillow grid surface. Matches p4est_connectivity_new_pillow (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -9,46 +9,46 @@ extern "C" static int -fclaw2d_map_query_pillowsphere (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowsphere (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_HEMISPHERE: + case FCLAW_MAP_QUERY_IS_HEMISPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -63,11 +63,11 @@ fclaw2d_map_query_pillowsphere (fclaw2d_map_context_t * cont, int query_identifi static void -fclaw2d_map_c2m_pillowsphere (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowsphere (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { - MAPC2M_PILLOWSPHERE(&blockno,&xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_C2M_PILLOWSPHERE(&blockno,&xc,&yc,xp,yp,zp); if (cont->is_extruded == 0) { @@ -76,13 +76,13 @@ fclaw2d_map_c2m_pillowsphere (fclaw2d_map_context_t * cont, int blockno, } } -fclaw2d_map_context_t * +fclaw_map_context_t * fclaw2d_map_new_pillowsphere(const double scale[], const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowsphere; cont->mapc2m = fclaw2d_map_c2m_pillowsphere; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_pillowsphere5.c b/applications/clawpack/advection/2d/all/fclaw2d_map_pillowsphere5.c index 0947b4d5e..25786f32b 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_pillowsphere5.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_pillowsphere5.c @@ -1,6 +1,6 @@ /* Five bilinear patches */ -#include +#include #ifdef __cplusplus extern "C" @@ -11,43 +11,43 @@ extern "C" #endif static int -fclaw2d_map_query_pillowsphere5(fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowsphere5(fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_HEMISPHERE: + case FCLAW_MAP_QUERY_IS_HEMISPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -62,16 +62,16 @@ fclaw2d_map_query_pillowsphere5(fclaw2d_map_context_t * cont, int query_identifi static void -fclaw2d_map_c2m_pillowsphere5(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowsphere5(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { double xp1, yp1, zp1; double alpha = cont->user_double[0]; - MAPC2M_FIVEPATCH(&blockno,&xc,&yc,&xp1,&yp1,&zp1,&alpha); + FCLAW_MAP_2D_C2M_FIVEPATCH(&blockno,&xc,&yc,&xp1,&yp1,&zp1,&alpha); xp1 = (xp1 + 1)/2.0; yp1 = (yp1 + 1)/2.0; - MAPC2M_PILLOWSPHERE(&blockno,&xp1,&yp1,xp,yp,zp); + FCLAW_MAP_2D_C2M_PILLOWSPHERE(&blockno,&xp1,&yp1,xp,yp,zp); /* These can probably be replaced by C functions at some point. */ scale_map(cont,xp,yp,zp); @@ -80,7 +80,7 @@ fclaw2d_map_c2m_pillowsphere5(fclaw2d_map_context_t * cont, int blockno, } static void -fclaw3dx_map_c2m_pillowsphere5(fclaw2d_map_context_t * cont, int blockno, +fclaw3dx_map_c2m_pillowsphere5(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) { @@ -88,7 +88,7 @@ fclaw3dx_map_c2m_pillowsphere5(fclaw2d_map_context_t * cont, int blockno, /* map to fivepatch square in [-1,1]x[-1,1] */ double xp1, yp1, zp1; double alpha = cont->user_double[0]; - MAPC2M_FIVEPATCH(&blockno,&xc,&yc,&xp1,&yp1,&zp1,&alpha); + FCLAW_MAP_2D_C2M_FIVEPATCH(&blockno,&xc,&yc,&xp1,&yp1,&zp1,&alpha); /* Map to unit square */ xp1 = (xp1 + 1)/2.0; @@ -99,7 +99,7 @@ fclaw3dx_map_c2m_pillowsphere5(fclaw2d_map_context_t * cont, int blockno, Note : Since we only have a single unit square, we will only have the upper half of the sphere */ - MAPC2M_PILLOWSPHERE(&blockno,&xp1,&yp1,xp,yp,zp); + FCLAW_MAP_2D_C2M_PILLOWSPHERE(&blockno,&xp1,&yp1,xp,yp,zp); /* Map point on sphere to point in shell */ @@ -124,16 +124,16 @@ fclaw3dx_map_c2m_pillowsphere5(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_pillowsphere5(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowsphere5(const double scale[], const double rotate[], const double alpha) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowsphere5; cont->mapc2m = fclaw2d_map_c2m_pillowsphere5; - cont->mapc2m_3dx = fclaw3dx_map_c2m_pillowsphere5; + cont->mapc2m_3d = fclaw3dx_map_c2m_pillowsphere5; cont->user_double[0] = alpha; diff --git a/applications/clawpack/advection/2d/all/fclaw2d_map_torus.c b/applications/clawpack/advection/2d/all/fclaw2d_map_torus.c index ae19d746d..1770480c2 100644 --- a/applications/clawpack/advection/2d/all/fclaw2d_map_torus.c +++ b/applications/clawpack/advection/2d/all/fclaw2d_map_torus.c @@ -1,6 +1,6 @@ /* Pillow grid surface. Matches p4est_connectivity_new_pillow (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -11,42 +11,42 @@ extern "C" #endif static int -fclaw2d_map_query_torus (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_torus (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -61,35 +61,35 @@ fclaw2d_map_query_torus (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_torus (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_torus (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* Data is not already in brick domain */ double xc1,yc1,zc1; - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); double alpha = cont->user_double[0]; double beta = cont->user_double[1]; /* Don't pass in block number */ - MAPC2M_TORUS(&xc1,&yc1,xp,yp,zp,&alpha,&beta); + FCLAW_MAP_2D_C2M_TORUS(&xc1,&yc1,xp,yp,zp,&alpha,&beta); scale_map(cont,xp,yp,zp); rotate_map(cont,xp,yp,zp); } -fclaw2d_map_context_t * - fclaw2d_map_new_torus (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_torus (fclaw_map_context_t* brick, const double scale[], const double rotate[], const double alpha, const double beta) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_torus; cont->mapc2m = fclaw2d_map_c2m_torus; diff --git a/applications/clawpack/advection/2d/annulus/annulus.cpp b/applications/clawpack/advection/2d/annulus/annulus.cpp index ca40c3536..5e8a25b2c 100644 --- a/applications/clawpack/advection/2d/annulus/annulus.cpp +++ b/applications/clawpack/advection/2d/annulus/annulus.cpp @@ -29,13 +29,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ------------- Create the domain --------------------- */ static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* --------------------------------------------------------------- Mapping geometry --------------------------------------------------------------- */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; int a = fclaw_opt->periodic_x; @@ -49,17 +49,17 @@ void create_domain(fclaw2d_global_t *glob) rotate[1] = pi*fclaw_opt->phi/180.0; /* Annulus : Mapped, multi-block domain */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_t *domain = + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Create mapping context (annulus based on a brick) */ const user_options_t *user = (user_options_t*) annulus_get_options(glob); - fclaw2d_map_context_t *brick = - fclaw2d_map_new_brick(domain, mi, mj, a, b); + fclaw_map_context_t *brick = + fclaw_map_new_2d_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = + fclaw_map_context_t *cont = fclaw2d_map_new_annulus(brick, fclaw_opt->scale, rotate, @@ -67,28 +67,23 @@ void create_domain(fclaw2d_global_t *glob) user->theta); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - user_options_t *user_opt = (user_options_t*) annulus_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); if (user_opt->claw_version == 4) { @@ -101,9 +96,9 @@ void run_program(fclaw2d_global_t* glob) annulus_link_solvers(glob); - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } @@ -115,13 +110,13 @@ main (int argc, char **argv) /* Register options packages */ fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; user_options_t *user_opt; fclaw_opt = fclaw_options_register (app, NULL,"fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register (app, "clawpatch","fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register (app, "clawpatch","fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register (app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register (app, "clawpack5", "fclaw_options.ini"); user_opt = annulus_options_register (app,"fclaw_options.ini"); @@ -137,10 +132,10 @@ main (int argc, char **argv) /* Create glob */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); annulus_options_store (glob, user_opt); @@ -150,7 +145,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy (glob); + fclaw_global_destroy (glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/annulus/annulus_options.c b/applications/clawpack/advection/2d/annulus/annulus_options.c index c98a660f0..89f672856 100644 --- a/applications/clawpack/advection/2d/annulus/annulus_options.c +++ b/applications/clawpack/advection/2d/annulus/annulus_options.c @@ -158,13 +158,13 @@ user_options_t* annulus_options_register (fclaw_app_t * app, return user; } -void annulus_options_store (fclaw2d_global_t* glob, user_options_t* user) +void annulus_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* annulus_get_options(fclaw2d_global_t* glob) +const user_options_t* annulus_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/annulus/annulus_user.cpp b/applications/clawpack/advection/2d/annulus/annulus_user.cpp index e7b27d196..3a771fe79 100644 --- a/applications/clawpack/advection/2d/annulus/annulus_user.cpp +++ b/applications/clawpack/advection/2d/annulus/annulus_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "annulus_user.h" static -void annulus_problem_setup(fclaw2d_global_t *glob) +void annulus_problem_setup(fclaw_global_t *glob) { const user_options_t *user = annulus_get_options(glob); @@ -38,15 +38,15 @@ void annulus_problem_setup(fclaw2d_global_t *glob) } /* Make sure node 0 writes 'setprob.data' before proceeding */ - fclaw2d_domain_barrier (glob->domain); /* redundant? */ + fclaw_domain_barrier (glob->domain); /* redundant? */ SETPROB(); } static -void annulus_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void annulus_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -56,12 +56,12 @@ void annulus_patch_setup(fclaw2d_global_t *glob, } -void annulus_link_solvers(fclaw2d_global_t *glob) +void annulus_link_solvers(fclaw_global_t *glob) { const user_options_t *user = annulus_get_options(glob); - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); vt->problem_setup = &annulus_problem_setup; patch_vt->setup = &annulus_patch_setup; diff --git a/applications/clawpack/advection/2d/annulus/annulus_user.h b/applications/clawpack/advection/2d/annulus/annulus_user.h index c9dee7ee4..2044a2ea3 100644 --- a/applications/clawpack/advection/2d/annulus/annulus_user.h +++ b/applications/clawpack/advection/2d/annulus/annulus_user.h @@ -52,14 +52,14 @@ typedef struct user_options user_options_t; -void annulus_link_solvers(fclaw2d_global_t *glob); +void annulus_link_solvers(fclaw_global_t *glob); user_options_t* annulus_options_register (fclaw_app_t * app, const char *configfile); -void annulus_options_store (fclaw2d_global_t* glob, user_options_t* user); +void annulus_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* annulus_get_options(fclaw2d_global_t *glob); +const user_options_t* annulus_get_options(fclaw_global_t *glob); #ifdef __cplusplus #if 0 diff --git a/applications/clawpack/advection/2d/annulus/fdisc.f b/applications/clawpack/advection/2d/annulus/fdisc.f index 174314452..e25fb40da 100644 --- a/applications/clawpack/advection/2d/annulus/fdisc.f +++ b/applications/clawpack/advection/2d/annulus/fdisc.f @@ -16,7 +16,7 @@ double precision function fdisc(blockno,xc,yc) pi = 4.0*atan(1.0) pi2 = 2*pi - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) c # Torus or annulus diff --git a/applications/clawpack/advection/2d/correlatedcb/correlatedcb.cpp b/applications/clawpack/advection/2d/correlatedcb/correlatedcb.cpp index 7cb923ea1..81737dcde 100644 --- a/applications/clawpack/advection/2d/correlatedcb/correlatedcb.cpp +++ b/applications/clawpack/advection/2d/correlatedcb/correlatedcb.cpp @@ -25,9 +25,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "correlatedcb_user.h" -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); /* Used locally */ double pi = M_PI; @@ -36,20 +36,20 @@ void create_domain(fclaw2d_global_t *glob) rotate[0] = pi*fclaw_opt->theta/180.0; rotate[1] = 0; - fclaw2d_map_context_t *cont = NULL; - fclaw2d_domain_t *domain = NULL; + fclaw_map_context_t *cont = NULL; + fclaw_domain_t *domain = NULL; const user_options_t *user_opt = correlatedcb_get_options(glob); switch (user_opt->mapping) { case 0: domain = - fclaw2d_domain_new_cubedsphere (glob->mpicomm, + fclaw_domain_new_2d_cubedsphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_cubedsphere (fclaw_opt->scale, rotate); break; case 1: domain = - fclaw2d_domain_new_twosphere (glob->mpicomm, fclaw_opt->minlevel); + fclaw_domain_new_2d_twosphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowsphere (fclaw_opt->scale, rotate); break; default: @@ -57,29 +57,24 @@ void create_domain(fclaw2d_global_t *glob) } /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = correlatedcb_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -96,9 +91,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } @@ -108,14 +103,14 @@ main (int argc, char **argv) /* Initialize application */ fclaw_app_t *app = fclaw_app_new (&argc, &argv, NULL); - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; fclaw_options_t *fclaw_opt; user_options_t *user_opt; fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = correlatedcb_options_register(app, "fclaw_options.ini"); @@ -131,11 +126,11 @@ main (int argc, char **argv) /* Create glob */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); correlatedcb_options_store (glob, user_opt); @@ -146,7 +141,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/correlatedcb/correlatedcb_options.c b/applications/clawpack/advection/2d/correlatedcb/correlatedcb_options.c index afb22481e..d8b25fbbb 100644 --- a/applications/clawpack/advection/2d/correlatedcb/correlatedcb_options.c +++ b/applications/clawpack/advection/2d/correlatedcb/correlatedcb_options.c @@ -154,14 +154,14 @@ user_options_t* correlatedcb_options_register (fclaw_app_t * app, return user; } -void correlatedcb_options_store (fclaw2d_global_t* glob, user_options_t* user) +void correlatedcb_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* correlatedcb_get_options(fclaw2d_global_t* glob) +const user_options_t* correlatedcb_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } /* ------------------------- ... and here ---------------------------- */ diff --git a/applications/clawpack/advection/2d/correlatedcb/correlatedcb_user.cpp b/applications/clawpack/advection/2d/correlatedcb/correlatedcb_user.cpp index 757e09cc9..9c01072af 100644 --- a/applications/clawpack/advection/2d/correlatedcb/correlatedcb_user.cpp +++ b/applications/clawpack/advection/2d/correlatedcb/correlatedcb_user.cpp @@ -26,15 +26,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "correlatedcb_user.h" static -void correlatedcb_problem_setup(fclaw2d_global_t* glob) +void correlatedcb_problem_setup(fclaw_global_t* glob) { SETPROB(); } static -void correlatedcb_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void correlatedcb_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -43,8 +43,8 @@ void correlatedcb_patch_setup_manifold(fclaw2d_global_t *glob, } static -void correlatedcb_b4step2_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void correlatedcb_b4step2_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -54,18 +54,18 @@ void correlatedcb_b4step2_manifold(fclaw2d_global_t *glob, advection_b4step2_manifold(glob,patch,blockno,patchno,t,dt,user->claw_version); } -void correlatedcb_link_solvers(fclaw2d_global_t *glob) +void correlatedcb_link_solvers(fclaw_global_t *glob) { /* Custom setprob */ - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &correlatedcb_problem_setup; /* Version-independent */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &correlatedcb_patch_setup_manifold; const user_options_t* user = correlatedcb_get_options(glob); if (user->mapping == 1) - fclaw2d_clawpatch_use_pillowsphere(glob); + fclaw_clawpatch_use_pillowsphere(glob); if (user->claw_version == 4) diff --git a/applications/clawpack/advection/2d/correlatedcb/correlatedcb_user.h b/applications/clawpack/advection/2d/correlatedcb/correlatedcb_user.h index 252d7b740..7f2338595 100644 --- a/applications/clawpack/advection/2d/correlatedcb/correlatedcb_user.h +++ b/applications/clawpack/advection/2d/correlatedcb/correlatedcb_user.h @@ -45,14 +45,14 @@ typedef struct user_options } user_options_t; -void correlatedcb_link_solvers(struct fclaw2d_global *glob); +void correlatedcb_link_solvers(struct fclaw_global *glob); -const user_options_t* correlatedcb_get_options(fclaw2d_global_t* glob); +const user_options_t* correlatedcb_get_options(fclaw_global_t* glob); user_options_t* correlatedcb_options_register (fclaw_app_t * app, const char *configfile); -void correlatedcb_options_store (fclaw2d_global_t* glob, user_options_t* user); +void correlatedcb_options_store (fclaw_global_t* glob, user_options_t* user); #ifdef __cplusplus diff --git a/applications/clawpack/advection/2d/correlatedcb/user_4.6/qinit.f b/applications/clawpack/advection/2d/correlatedcb/user_4.6/qinit.f index 3b1204745..a5151dd48 100644 --- a/applications/clawpack/advection/2d/correlatedcb/user_4.6/qinit.f +++ b/applications/clawpack/advection/2d/correlatedcb/user_4.6/qinit.f @@ -26,7 +26,7 @@ subroutine clawpack46_qinit(maxmx,maxmy,meqn,mbc, yc = ylower + (j-0.5d0)*dy do i = 1-mbc,mx+mbc xc = xlower + (i-0.5d0)*dx - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) q(i,j,1) = cosine_bell_sum(xp,yp,zp) if (meqn .eq. 2) then diff --git a/applications/clawpack/advection/2d/correlatedcb/user_5.0/qinit.f90 b/applications/clawpack/advection/2d/correlatedcb/user_5.0/qinit.f90 index ac4ff460f..5eb60d25e 100644 --- a/applications/clawpack/advection/2d/correlatedcb/user_5.0/qinit.f90 +++ b/applications/clawpack/advection/2d/correlatedcb/user_5.0/qinit.f90 @@ -24,7 +24,7 @@ SUBROUTINE clawpack5_qinit(meqn,mbc,mx,my,xlower,ylower,dx,dy,q,maux,aux) yc = ylower + (j-0.5d0)*dy DO i = 1-mbc,mx+mbc xc = xlower + (i-0.5d0)*dx - CALL fclaw2d_map_c2m(cont, blockno,xc,yc,xp,yp,zp) + CALL fclaw_map_2d_c2m(cont, blockno,xc,yc,xp,yp,zp) q(1,i,j) = cosine_bell_sum(xp,yp,zp) IF (meqn .EQ. 2) THEN !! # Set non-linear relationship between two tracers diff --git a/applications/clawpack/advection/2d/disk/disk.cpp b/applications/clawpack/advection/2d/disk/disk.cpp index 5fa9308d5..a309ef64e 100644 --- a/applications/clawpack/advection/2d/disk/disk.cpp +++ b/applications/clawpack/advection/2d/disk/disk.cpp @@ -28,10 +28,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../all/advection_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* Used locally */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); double pi = M_PI; double rotate[2]; rotate[0] = pi*fclaw_opt->theta/180.0; @@ -41,16 +41,16 @@ void create_domain(fclaw2d_global_t *glob) /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain = NULL; - fclaw2d_map_context_t *cont = NULL; - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + fclaw_domain_t *domain = NULL; + fclaw_map_context_t *cont = NULL; + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); switch (user_opt->example) { case 0: /* Map unit square to the pillow disk using mapc2m_pillowdisk.f */ domain = - fclaw2d_domain_new_unitsquare (glob->mpicomm, + fclaw_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowdisk (fclaw_opt->scale, fclaw_opt->shift, @@ -64,7 +64,7 @@ void create_domain(fclaw2d_global_t *glob) exit(0); } domain = - fclaw2d_domain_new_disk (glob->mpicomm, 0, 0, + fclaw_domain_new_2d_disk (glob->mpicomm, 0, 0, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowdisk5 (fclaw_opt->scale, fclaw_opt->shift, @@ -75,29 +75,24 @@ void create_domain(fclaw2d_global_t *glob) SC_ABORT_NOT_REACHED (); } /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = disk_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -114,9 +109,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -127,13 +122,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = disk_options_register(app, "fclaw_options.ini"); @@ -149,14 +144,14 @@ main (int argc, char **argv) /* Create glob */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Move this here in case vexit >= 2 */ //fclaw_app_print_options(app); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); disk_options_store (glob, user_opt); @@ -167,7 +162,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/disk/disk_options.c b/applications/clawpack/advection/2d/disk/disk_options.c index dc3a5da36..fd7f2237d 100644 --- a/applications/clawpack/advection/2d/disk/disk_options.c +++ b/applications/clawpack/advection/2d/disk/disk_options.c @@ -155,14 +155,14 @@ user_options_t* disk_options_register (fclaw_app_t * app, return user_opt; } -void disk_options_store (fclaw2d_global_t* glob, user_options_t* user_opt) +void disk_options_store (fclaw_global_t* glob, user_options_t* user_opt) { - fclaw2d_global_options_store(glob, "user", user_opt); + fclaw_global_options_store(glob, "user", user_opt); } -const user_options_t* disk_get_options(fclaw2d_global_t* glob) +const user_options_t* disk_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob,"user"); + return (user_options_t*) fclaw_global_get_options(glob,"user"); } #if 0 diff --git a/applications/clawpack/advection/2d/disk/disk_user.cpp b/applications/clawpack/advection/2d/disk/disk_user.cpp index eee3a165b..6864391aa 100644 --- a/applications/clawpack/advection/2d/disk/disk_user.cpp +++ b/applications/clawpack/advection/2d/disk/disk_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "disk_user.h" static -void disk_problem_setup(fclaw2d_global_t* glob) +void disk_problem_setup(fclaw_global_t* glob) { const user_options_t* user = disk_get_options(glob); if (glob->mpirank == 0) @@ -36,13 +36,13 @@ void disk_problem_setup(fclaw2d_global_t* glob) fprintf(f, "%-24.4f %s",user->alpha,"\% alpha\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } static -void disk_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void disk_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -52,12 +52,12 @@ void disk_patch_setup(fclaw2d_global_t *glob, } -void disk_link_solvers(fclaw2d_global_t *glob) +void disk_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = disk_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = disk_problem_setup; - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = disk_patch_setup; const user_options_t* user = disk_get_options(glob); diff --git a/applications/clawpack/advection/2d/disk/disk_user.h b/applications/clawpack/advection/2d/disk/disk_user.h index c73f031eb..05de1016b 100644 --- a/applications/clawpack/advection/2d/disk/disk_user.h +++ b/applications/clawpack/advection/2d/disk/disk_user.h @@ -52,14 +52,14 @@ typedef struct user_options user_options_t* disk_options_register (fclaw_app_t * app, const char *configfile); -void disk_options_store (fclaw2d_global_t* glob, user_options_t* user_opt); +void disk_options_store (fclaw_global_t* glob, user_options_t* user_opt); -const user_options_t* disk_get_options(fclaw2d_global_t* glob); +const user_options_t* disk_get_options(fclaw_global_t* glob); -void disk_link_solvers(fclaw2d_global_t *glob); +void disk_link_solvers(fclaw_global_t *glob); void disk_global_post_process(fclaw_options_t *fclaw_opt, - fclaw2d_clawpatch_options_t *clawpatch_opt, + fclaw_clawpatch_options_t *clawpatch_opt, user_options_t *user_opt); diff --git a/applications/clawpack/advection/2d/disk/fdisc.f b/applications/clawpack/advection/2d/disk/fdisc.f index 609e5add5..59c593154 100644 --- a/applications/clawpack/advection/2d/disk/fdisc.f +++ b/applications/clawpack/advection/2d/disk/fdisc.f @@ -9,7 +9,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) r = sqrt((xp-0.5d0)**2 + (yp-1.d0)**2) diff --git a/applications/clawpack/advection/2d/filament/fdisc.f b/applications/clawpack/advection/2d/filament/fdisc.f index a92d78365..9c656c230 100644 --- a/applications/clawpack/advection/2d/filament/fdisc.f +++ b/applications/clawpack/advection/2d/filament/fdisc.f @@ -9,7 +9,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) r = sqrt((xp-0.5d0)**2 + (yp-1.d0)**2) diff --git a/applications/clawpack/advection/2d/filament/filament.cpp b/applications/clawpack/advection/2d/filament/filament.cpp index 0dc4ceeb3..f7682bb11 100644 --- a/applications/clawpack/advection/2d/filament/filament.cpp +++ b/applications/clawpack/advection/2d/filament/filament.cpp @@ -28,33 +28,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../all/advection_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; int minlevel = fclaw_opt->minlevel; - fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; /* Assume non-periodic domain */ int a = 0; /* non-periodic */ int b = 0; - fclaw2d_map_context_t *cont = NULL, *brick = NULL; - fclaw2d_domain_t *domain = NULL; + fclaw_map_context_t *cont = NULL, *brick = NULL; + fclaw_domain_t *domain = NULL; user_options_t *user = (user_options_t*) filament_get_options(glob); switch (user->example) { case 1: /* Square brick domain */ domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick (domain, mi, mj, a, b); + brick = fclaw_map_new_2d_brick (domain, mi, mj, a, b); /* Square in [-1,1]x[-1,1], shifted by (1,1,0) */ cont = fclaw2d_map_new_cart(brick, @@ -70,7 +70,7 @@ void create_domain(fclaw2d_global_t *glob) } /* Five patch square domain */ domain = - fclaw2d_domain_new_disk (glob->mpicomm, 0, 0, + fclaw_domain_new_2d_disk (glob->mpicomm, 0, 0, fclaw_opt->minlevel); cont = fclaw2d_map_new_fivepatch (fclaw_opt->scale, fclaw_opt->shift, @@ -80,9 +80,9 @@ void create_domain(fclaw2d_global_t *glob) /* bilinear square domain : maps to [-1,1]x[-1,1] */ FCLAW_ASSERT (mi == 2 && mj == 2); domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick (domain, mi, mj, a, b); + brick = fclaw_map_new_2d_brick (domain, mi, mj, a, b); cont = fclaw2d_map_new_bilinear (brick, fclaw_opt->scale, fclaw_opt->shift, @@ -94,31 +94,25 @@ void create_domain(fclaw2d_global_t *glob) } /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store domain in glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* Print out some domain info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { user_options_t *user = (user_options_t*) filament_get_options(glob); - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - /* Create domain data */ - fclaw2d_domain_data_new(glob->domain); - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); if (user->claw_version == 4) { @@ -131,9 +125,9 @@ void run_program(fclaw2d_global_t* glob) filament_link_solvers(glob); - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -146,12 +140,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = filament_options_register(app, "fclaw_options.ini"); @@ -175,11 +169,11 @@ main (int argc, char **argv) /* Create glob */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store options in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); filament_options_store (glob, user_opt); @@ -189,7 +183,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/filament/filament_options.c b/applications/clawpack/advection/2d/filament/filament_options.c index 5a63e4a36..73c567aa7 100644 --- a/applications/clawpack/advection/2d/filament/filament_options.c +++ b/applications/clawpack/advection/2d/filament/filament_options.c @@ -162,12 +162,12 @@ user_options_t* filament_options_register (fclaw_app_t * app, return user; } -void filament_options_store (fclaw2d_global_t* glob, user_options_t* user) +void filament_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* filament_get_options(fclaw2d_global_t* glob) +const user_options_t* filament_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/filament/filament_user.cpp b/applications/clawpack/advection/2d/filament/filament_user.cpp index 7a1853b30..ad9aa0698 100644 --- a/applications/clawpack/advection/2d/filament/filament_user.cpp +++ b/applications/clawpack/advection/2d/filament/filament_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "filament_user.h" -void filament_problem_setup(fclaw2d_global_t *glob) +void filament_problem_setup(fclaw_global_t *glob) { const user_options_t* user = filament_get_options(glob); if (glob->mpirank == 0) @@ -38,13 +38,13 @@ void filament_problem_setup(fclaw2d_global_t *glob) fprintf(f, "%-24.4f %s",user->center[1],"\% center_y\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } static -void filament_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void filament_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -53,16 +53,16 @@ void filament_patch_setup(fclaw2d_global_t *glob, user->claw_version); } -void filament_link_solvers(fclaw2d_global_t *glob) +void filament_link_solvers(fclaw_global_t *glob) { /* All examples require manifold = T */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); FCLAW_ASSERT(fclaw_opt->manifold != 0); - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = filament_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = filament_problem_setup; - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = filament_patch_setup; const user_options_t* user = filament_get_options(glob); diff --git a/applications/clawpack/advection/2d/filament/filament_user.h b/applications/clawpack/advection/2d/filament/filament_user.h index 7f3697def..02fcce1fe 100644 --- a/applications/clawpack/advection/2d/filament/filament_user.h +++ b/applications/clawpack/advection/2d/filament/filament_user.h @@ -54,11 +54,11 @@ typedef struct user_options user_options_t* filament_options_register (fclaw_app_t * app, const char *configfile); -void filament_options_store (fclaw2d_global_t* glob, user_options_t* user); +void filament_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* filament_get_options(fclaw2d_global_t* glob); +const user_options_t* filament_get_options(fclaw_global_t* glob); -void filament_link_solvers(fclaw2d_global_t *glob); +void filament_link_solvers(fclaw_global_t *glob); #ifdef __cplusplus } diff --git a/applications/clawpack/advection/2d/filament_swirl/filament.cpp b/applications/clawpack/advection/2d/filament_swirl/filament.cpp index c75162b7c..d9fc29e07 100644 --- a/applications/clawpack/advection/2d/filament_swirl/filament.cpp +++ b/applications/clawpack/advection/2d/filament_swirl/filament.cpp @@ -32,11 +32,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "filament/filament_user.h" -void filament_create_domain(fclaw2d_global_t *glob) +void filament_create_domain(fclaw_global_t *glob) { - fclaw2d_set_global_context(glob); + fclaw_set_global_context(glob); - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -44,39 +44,34 @@ void filament_create_domain(fclaw2d_global_t *glob) int b = fclaw_opt->periodic_y; /* Square brick domain */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_t *domain = + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - fclaw2d_map_context_t* brick = - fclaw2d_map_new_brick (domain, mi, mj, a, b); + fclaw_map_context_t* brick = + fclaw_map_new_2d_brick (domain, mi, mj, a, b); /* Square in [-1,1]x[-1,1], shifted by (1,1,0) */ - fclaw2d_map_context_t *cont = + fclaw_map_context_t *cont = fclaw2d_map_new_cart(brick, fclaw_opt->scale, fclaw_opt->shift); /* Store domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } -void filament_initialize(fclaw2d_global_t* glob) +void filament_initialize(fclaw_global_t* glob) { - fclaw2d_set_global_context(glob); + fclaw_set_global_context(glob); const filament_options_t *user = filament_get_options(glob); - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); if (user->claw_version == 4) { @@ -88,18 +83,18 @@ void filament_initialize(fclaw2d_global_t* glob) } filament_link_solvers(glob); - fclaw2d_initialize(glob); + fclaw_initialize(glob); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } -void filament_finalize(fclaw2d_global_t* glob) +void filament_finalize(fclaw_global_t* glob) { - fclaw2d_set_global_context(glob); + fclaw_set_global_context(glob); - fclaw2d_problem_setup(glob); - fclaw2d_finalize(glob); + fclaw_problem_setup(glob); + fclaw_finalize(glob); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } diff --git a/applications/clawpack/advection/2d/filament_swirl/filament/fdisc.f b/applications/clawpack/advection/2d/filament_swirl/filament/fdisc.f index e171d08cc..8aa40e514 100644 --- a/applications/clawpack/advection/2d/filament_swirl/filament/fdisc.f +++ b/applications/clawpack/advection/2d/filament_swirl/filament/fdisc.f @@ -9,7 +9,7 @@ double precision function filament_fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) r = sqrt((xp-0.5d0)**2 + (yp-1.d0)**2) diff --git a/applications/clawpack/advection/2d/filament_swirl/filament/filament_options.c b/applications/clawpack/advection/2d/filament_swirl/filament/filament_options.c index 6be8c1fb5..f0afa6b25 100644 --- a/applications/clawpack/advection/2d/filament_swirl/filament/filament_options.c +++ b/applications/clawpack/advection/2d/filament_swirl/filament/filament_options.c @@ -137,12 +137,12 @@ filament_options_t* filament_options_register (fclaw_app_t * app, return user; } -void filament_options_store (fclaw2d_global_t* glob, filament_options_t* user) +void filament_options_store (fclaw_global_t* glob, filament_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const filament_options_t* filament_get_options(fclaw2d_global_t* glob) +const filament_options_t* filament_get_options(fclaw_global_t* glob) { - return (filament_options_t*) fclaw2d_global_get_options(glob, "user"); + return (filament_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/filament_swirl/filament/filament_user.cpp b/applications/clawpack/advection/2d/filament_swirl/filament/filament_user.cpp index a02d89b05..922734276 100644 --- a/applications/clawpack/advection/2d/filament_swirl/filament/filament_user.cpp +++ b/applications/clawpack/advection/2d/filament_swirl/filament/filament_user.cpp @@ -27,8 +27,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "filament_fort.h" static -void filament_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void filament_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -37,13 +37,13 @@ void filament_patch_setup(fclaw2d_global_t *glob, user->claw_version); } -void filament_link_solvers(fclaw2d_global_t *glob) +void filament_link_solvers(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (fclaw_opt->manifold) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = filament_patch_setup; } diff --git a/applications/clawpack/advection/2d/filament_swirl/filament/filament_user.h b/applications/clawpack/advection/2d/filament_swirl/filament/filament_user.h index 56d21a936..af491254c 100644 --- a/applications/clawpack/advection/2d/filament_swirl/filament/filament_user.h +++ b/applications/clawpack/advection/2d/filament_swirl/filament/filament_user.h @@ -56,16 +56,16 @@ filament_options_t* filament_options_register (fclaw_app_t * app, const char *section, const char *configfile); -void filament_options_store (fclaw2d_global_t* glob, filament_options_t* user); +void filament_options_store (fclaw_global_t* glob, filament_options_t* user); -const filament_options_t* filament_get_options(fclaw2d_global_t* glob); +const filament_options_t* filament_get_options(fclaw_global_t* glob); -void filament_link_solvers(fclaw2d_global_t *glob); +void filament_link_solvers(fclaw_global_t *glob); /* Filament */ -void filament_create_domain(fclaw2d_global_t *glob); -void filament_initialize(fclaw2d_global_t* glob); -void filament_finalize(fclaw2d_global_t* glob); +void filament_create_domain(fclaw_global_t *glob); +void filament_initialize(fclaw_global_t* glob); +void filament_finalize(fclaw_global_t* glob); #ifdef __cplusplus diff --git a/applications/clawpack/advection/2d/filament_swirl/filament_swirl.cpp b/applications/clawpack/advection/2d/filament_swirl/filament_swirl.cpp index a2d6a8c6e..35727328e 100644 --- a/applications/clawpack/advection/2d/filament_swirl/filament_swirl.cpp +++ b/applications/clawpack/advection/2d/filament_swirl/filament_swirl.cpp @@ -36,18 +36,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "overlap.h" -#include +#include static -void setup_overlap(fclaw2d_global_t *swirl_glob,\ - fclaw2d_global_t *filament_glob, +void setup_overlap(fclaw_global_t *swirl_glob,\ + fclaw_global_t *filament_glob, overlap_consumer_t *c) { /* -------------- setup overlap infomation -------------------*/ /* compute process-local query points on the consumer side */ - fclaw2d_clawpatch_options_t *swirl_clawpatch_opt = - fclaw2d_clawpatch_get_options(swirl_glob); + fclaw_clawpatch_options_t *swirl_clawpatch_opt = + fclaw_clawpatch_get_options(swirl_glob); //overlap_consumer_t consumer, *c = &consumer; c->glob = swirl_glob; @@ -59,14 +59,14 @@ void setup_overlap(fclaw2d_global_t *swirl_glob,\ /* initialize the filament geometry information that is needed for * mapping between the swirl and the filament domain */ - fclaw_options_t *filament_fclaw_opt = fclaw2d_get_options(filament_glob); + fclaw_options_t *filament_fclaw_opt = fclaw_get_options(filament_glob); overlap_geometry_t filament_geometry, *geo = &filament_geometry; geo->fclaw_opt = filament_fclaw_opt; geo->blocks = filament_glob->domain->blocks; /* obtain interpolation data of the points from the producer side */ - fclaw2d_overlap_exchange (filament_glob->domain, c->query_points, + fclaw_overlap_exchange (filament_glob->domain, c->query_points, overlap_interpolate, geo); /* output the interpolation data for all query points */ @@ -74,11 +74,11 @@ void setup_overlap(fclaw2d_global_t *swirl_glob,\ } static -void run_program(fclaw2d_global_t *swirl_glob,\ - fclaw2d_global_t *filament_glob) +void run_program(fclaw_global_t *swirl_glob,\ + fclaw_global_t *filament_glob) { /* run */ - fclaw2d_global_t *globs[2]; + fclaw_global_t *globs[2]; globs[0] = filament_glob; globs[1] = swirl_glob; user_run (globs, 2); @@ -102,14 +102,14 @@ main (int argc, char **argv) /* Filament options */ filament_options_t *filament_user_opt; fclaw_options_t *filament_fclaw_opt; - fclaw2d_clawpatch_options_t *filament_clawpatch_opt; + fclaw_clawpatch_options_t *filament_clawpatch_opt; fc2d_clawpack46_options_t *filament_claw46_opt; fc2d_clawpack5_options_t *filament_claw5_opt; filament_fclaw_opt = fclaw_options_register(app, "filament", "filament_options.ini"); filament_clawpatch_opt = - fclaw2d_clawpatch_options_register(app, "filament-clawpatch", "filament_options.ini"); + fclaw_clawpatch_2d_options_register(app, "filament-clawpatch", "filament_options.ini"); filament_claw46_opt = fc2d_clawpack46_options_register(app, "filament-clawpack46", "filament_options.ini"); filament_claw5_opt = @@ -120,14 +120,14 @@ main (int argc, char **argv) /* Swirl options */ swirl_options_t *swirl_user_opt; fclaw_options_t *swirl_fclaw_opt; - fclaw2d_clawpatch_options_t *swirl_clawpatch_opt; + fclaw_clawpatch_options_t *swirl_clawpatch_opt; fc2d_clawpack46_options_t *swirl_claw46_opt; fc2d_clawpack5_options_t *swirl_claw5_opt; swirl_fclaw_opt = fclaw_options_register(app, "swirl", "swirl_options.ini"); swirl_clawpatch_opt = - fclaw2d_clawpatch_options_register(app, "swirl-clawpatch", "swirl_options.ini"); + fclaw_clawpatch_2d_options_register(app, "swirl-clawpatch", "swirl_options.ini"); swirl_claw46_opt = fc2d_clawpack46_options_register(app, "swirl-clawpack46","swirl_options.ini"); swirl_claw5_opt = @@ -147,10 +147,10 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Filament setup */ - fclaw2d_global_t *filament_glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *filament_glob = fclaw_global_new_comm (mpicomm, size, rank); - fclaw2d_options_store (filament_glob, filament_fclaw_opt); - fclaw2d_clawpatch_options_store (filament_glob, filament_clawpatch_opt); + fclaw_options_store (filament_glob, filament_fclaw_opt); + fclaw_clawpatch_options_store (filament_glob, filament_clawpatch_opt); fc2d_clawpack46_options_store (filament_glob, filament_claw46_opt); fc2d_clawpack5_options_store (filament_glob, filament_claw5_opt); filament_options_store (filament_glob, filament_user_opt); @@ -158,10 +158,10 @@ main (int argc, char **argv) filament_create_domain(filament_glob); /* Swirl setup */ - fclaw2d_global_t *swirl_glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *swirl_glob = fclaw_global_new_comm (mpicomm, size, rank); - fclaw2d_options_store (swirl_glob, swirl_fclaw_opt); - fclaw2d_clawpatch_options_store (swirl_glob, swirl_clawpatch_opt); + fclaw_options_store (swirl_glob, swirl_fclaw_opt); + fclaw_clawpatch_options_store (swirl_glob, swirl_clawpatch_opt); fc2d_clawpack46_options_store (swirl_glob, swirl_claw46_opt); fc2d_clawpack5_options_store (swirl_glob, swirl_claw5_opt); swirl_options_store (swirl_glob, swirl_user_opt); @@ -183,8 +183,8 @@ main (int argc, char **argv) sc_array_destroy (c->query_points); /* Destroy apps */ - fclaw2d_global_destroy (filament_glob); - fclaw2d_global_destroy (swirl_glob); + fclaw_global_destroy (filament_glob); + fclaw_global_destroy (swirl_glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/filament_swirl/filament_swirl_split.cpp b/applications/clawpack/advection/2d/filament_swirl/filament_swirl_split.cpp index b494139b6..31202bf44 100644 --- a/applications/clawpack/advection/2d/filament_swirl/filament_swirl_split.cpp +++ b/applications/clawpack/advection/2d/filament_swirl/filament_swirl_split.cpp @@ -28,17 +28,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. static -void run_programs(fclaw2d_global_t* globs[], int nglobs) +void run_programs(fclaw_global_t* globs[], int nglobs) { for(int i = 0; i < nglobs; i++) { if(globs[i]->mpicomm != sc_MPI_COMM_NULL) { - fclaw2d_set_global_context(globs[i]); + fclaw_set_global_context(globs[i]); - fclaw2d_problem_setup(globs[i]); + fclaw_problem_setup(globs[i]); - fclaw2d_clear_global_context(globs[i]); + fclaw_clear_global_context(globs[i]); } } @@ -59,21 +59,21 @@ void run_programs(fclaw2d_global_t* globs[], int nglobs) if (split_comms) { - fclaw2d_set_global_context(globs[glob_index]); + fclaw_set_global_context(globs[glob_index]); - fclaw2d_run(globs[glob_index]); + fclaw_run(globs[glob_index]); - fclaw2d_clear_global_context(globs[glob_index]); + fclaw_clear_global_context(globs[glob_index]); } else { for(int i = 0; i < nglobs; i++) { - fclaw2d_set_global_context(globs[i]); + fclaw_set_global_context(globs[i]); - fclaw2d_run(globs[i]); + fclaw_run(globs[i]); - fclaw2d_clear_global_context(globs[i]); + fclaw_clear_global_context(globs[i]); } } } @@ -117,14 +117,14 @@ main (int argc, char **argv) /* Register packages */ filament_options_t *filament_user_opt; fclaw_options_t *filament_fclaw_opt; - fclaw2d_clawpatch_options_t *filament_clawpatch_opt; + fclaw_clawpatch_options_t *filament_clawpatch_opt; fc2d_clawpack46_options_t *filament_claw46_opt; fc2d_clawpack5_options_t *filament_claw5_opt; filament_fclaw_opt = fclaw_options_register(app, "filament", "fclaw_options.ini"); filament_clawpatch_opt = - fclaw2d_clawpatch_options_register(app, "filament-clawpatch", "fclaw_options.ini"); + fclaw_clawpatch_2d_options_register(app, "filament-clawpatch", "fclaw_options.ini"); filament_claw46_opt = fc2d_clawpack46_options_register(app, "filament-clawpack46", "fclaw_options.ini"); filament_claw5_opt = @@ -135,14 +135,14 @@ main (int argc, char **argv) swirl_options_t *swirl_user_opt; fclaw_options_t *swirl_fclaw_opt; - fclaw2d_clawpatch_options_t *swirl_clawpatch_opt; + fclaw_clawpatch_options_t *swirl_clawpatch_opt; fc2d_clawpack46_options_t *swirl_claw46_opt; fc2d_clawpack5_options_t *swirl_claw5_opt; swirl_fclaw_opt = fclaw_options_register(app, "swirl", "fclaw_options.ini"); swirl_clawpatch_opt = - fclaw2d_clawpatch_options_register(app, "swirl-clawpatch", "fclaw_options.ini"); + fclaw_clawpatch_2d_options_register(app, "swirl-clawpatch", "fclaw_options.ini"); swirl_claw46_opt = fc2d_clawpack46_options_register(app, "swirl-clawpack46", "fclaw_options.ini"); swirl_claw5_opt = @@ -164,19 +164,19 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Globs */ - fclaw2d_global_t *filament_glob = fclaw2d_global_new_comm (subcomm, size, rank); + fclaw_global_t *filament_glob = fclaw_global_new_comm (subcomm, size, rank); - fclaw2d_options_store (filament_glob, filament_fclaw_opt); - fclaw2d_clawpatch_options_store (filament_glob, filament_clawpatch_opt); + fclaw_options_store (filament_glob, filament_fclaw_opt); + fclaw_clawpatch_options_store (filament_glob, filament_clawpatch_opt); fc2d_clawpack46_options_store (filament_glob, filament_claw46_opt); fc2d_clawpack5_options_store (filament_glob, filament_claw5_opt); filament_options_store (filament_glob, filament_user_opt); - fclaw2d_global_t *swirl_glob = fclaw2d_global_new_comm (subcomm, size, rank); + fclaw_global_t *swirl_glob = fclaw_global_new_comm (subcomm, size, rank); - fclaw2d_options_store (swirl_glob, swirl_fclaw_opt); - fclaw2d_clawpatch_options_store (swirl_glob, swirl_clawpatch_opt); + fclaw_options_store (swirl_glob, swirl_fclaw_opt); + fclaw_clawpatch_options_store (swirl_glob, swirl_clawpatch_opt); fc2d_clawpack46_options_store (swirl_glob, swirl_claw46_opt); fc2d_clawpack5_options_store (swirl_glob, swirl_claw5_opt); swirl_options_store (swirl_glob, swirl_user_opt); @@ -217,8 +217,8 @@ main (int argc, char **argv) } /* destroy */ - fclaw2d_global_destroy(filament_glob); - fclaw2d_global_destroy(swirl_glob); + fclaw_global_destroy(filament_glob); + fclaw_global_destroy(swirl_glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/filament_swirl/overlap.c b/applications/clawpack/advection/2d/filament_swirl/overlap.c index 6a9cd4cfc..99b792148 100644 --- a/applications/clawpack/advection/2d/filament_swirl/overlap.c +++ b/applications/clawpack/advection/2d/filament_swirl/overlap.c @@ -29,10 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include // #include -#include -#include -#include -#include +#include +#include +#include +#include void apply_consumer_mapping (overlap_point_t * op) @@ -49,7 +49,7 @@ void apply_consumer_mapping (overlap_point_t * op) op->xy[2] = 0.5; /* swirl 2D is placed at z=0.5 in producer physical */ } -void add_cell_centers (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +void add_cell_centers (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user) { overlap_point_t *op; @@ -63,7 +63,7 @@ void add_cell_centers (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, FCLAW_ASSERT (c->query_points != NULL); /* create one query point for every cell in the patch */ - fclaw2d_clawpatch_grid_data (c->glob, patch, &mx, &my, &mbc, + fclaw_clawpatch_2d_grid_data (c->glob, patch, &mx, &my, &mbc, &xlower, &ylower, &dx, &dy); for (i = 0; i < mx; i++) { @@ -103,7 +103,7 @@ void create_query_points (overlap_consumer_t * c) c->domain->local_num_patches * c->num_cells_in_patch); c->cell_idx = 0; - fclaw2d_domain_iterate_patches (c->domain, add_cell_centers, c); + fclaw_domain_iterate_patches (c->domain, add_cell_centers, c); /* verify that we created as many query_points as expected */ FCLAW_ASSERT (c->cell_idx == @@ -160,7 +160,7 @@ int apply_inverse_producer_mapping (overlap_point_t * op, double xy[3], return 1; /* the point lies in the domain */ } -int overlap_interpolate (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +int overlap_interpolate (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *point, void *user) { overlap_point_t *op; @@ -194,7 +194,7 @@ int overlap_interpolate (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, } /* check, if we are on the consumer or the producer side (boolean) */ - consumer_side = fclaw2d_domain_is_meta (domain); + consumer_side = fclaw_domain_is_meta (domain); /* set tolerances */ if (consumer_side) diff --git a/applications/clawpack/advection/2d/filament_swirl/overlap.h b/applications/clawpack/advection/2d/filament_swirl/overlap.h index d52975483..979f170ef 100644 --- a/applications/clawpack/advection/2d/filament_swirl/overlap.h +++ b/applications/clawpack/advection/2d/filament_swirl/overlap.h @@ -27,11 +27,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef OVERLAP_H #define OVERLAP_H -#include +#include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" @@ -55,8 +55,8 @@ overlap_point_t; typedef struct overlap_consumer { - fclaw2d_global_t *glob; - fclaw2d_domain_t *domain; + fclaw_global_t *glob; + fclaw_domain_t *domain; sc_array_t *query_points; size_t cell_idx; int num_cells_in_patch; @@ -67,7 +67,7 @@ overlap_consumer_t; typedef struct overlap_geometry { fclaw_options_t *fclaw_opt; - fclaw2d_block_t *blocks; + fclaw_block_t *blocks; } overlap_geometry_t; @@ -79,13 +79,13 @@ void create_query_points (overlap_consumer_t * c); int apply_inverse_producer_mapping (overlap_point_t * op, double xy[3], int blockno, overlap_geometry_t * geo); -int overlap_interpolate (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +int overlap_interpolate (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *point, void *user); void output_query_points (overlap_consumer_t * c); -void add_cell_centers (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +void add_cell_centers (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user); diff --git a/applications/clawpack/advection/2d/filament_swirl/swirl.cpp b/applications/clawpack/advection/2d/filament_swirl/swirl.cpp index 9f63b339d..68232e06e 100644 --- a/applications/clawpack/advection/2d/filament_swirl/swirl.cpp +++ b/applications/clawpack/advection/2d/filament_swirl/swirl.cpp @@ -31,39 +31,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "swirl/swirl_user.h" -void swirl_create_domain(fclaw2d_global_t *glob) +void swirl_create_domain(fclaw_global_t *glob) { - fclaw2d_set_global_context(glob); + fclaw_set_global_context(glob); - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare(glob->mpicomm, + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); /* Create "empty" mapping */ - fclaw2d_map_context_t* cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t* cont = fclaw_map_new_nomap(); /* Store domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } -void swirl_initialize(fclaw2d_global_t* glob) +void swirl_initialize(fclaw_global_t* glob) { - fclaw2d_set_global_context(glob); - - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); + fclaw_set_global_context(glob); const swirl_options_t *swirl_opt = swirl_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (swirl_opt->claw_version == 4) @@ -80,19 +75,19 @@ void swirl_initialize(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); + fclaw_initialize(glob); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } -void swirl_finalize(fclaw2d_global_t* glob) +void swirl_finalize(fclaw_global_t* glob) { - fclaw2d_set_global_context(glob); + fclaw_set_global_context(glob); - fclaw2d_problem_setup(glob); - fclaw2d_finalize(glob); + fclaw_problem_setup(glob); + fclaw_finalize(glob); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } diff --git a/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_options.c b/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_options.c index a49673597..a8ac1eb12 100644 --- a/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_options.c +++ b/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_options.c @@ -151,12 +151,12 @@ swirl_options_t* swirl_options_register (fclaw_app_t * app, return user; } -void swirl_options_store (fclaw2d_global_t* glob, swirl_options_t* user) +void swirl_options_store (fclaw_global_t* glob, swirl_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const swirl_options_t* swirl_get_options(fclaw2d_global_t* glob) +const swirl_options_t* swirl_get_options(fclaw_global_t* glob) { - return (swirl_options_t*) fclaw2d_global_get_options(glob, "user"); + return (swirl_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_user.cpp b/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_user.cpp index fe3412b90..8729aafbc 100644 --- a/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_user.cpp +++ b/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_user.cpp @@ -28,7 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "swirl_fort.h" static -void swirl_problem_setup(fclaw2d_global_t* glob) +void swirl_problem_setup(fclaw_global_t* glob) { const swirl_options_t* user = swirl_get_options(glob); @@ -40,15 +40,15 @@ void swirl_problem_setup(fclaw2d_global_t* glob) } /* Make sure node 0 has written 'setprob.data' before proceeding */ - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SWIRL_SETPROB(); } -void swirl_link_solvers(fclaw2d_global_t *glob) +void swirl_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &swirl_problem_setup; /* Version-independent */ const swirl_options_t* user = swirl_get_options(glob); diff --git a/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_user.h b/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_user.h index bc9768586..451b58555 100644 --- a/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_user.h +++ b/applications/clawpack/advection/2d/filament_swirl/swirl/swirl_user.h @@ -41,21 +41,21 @@ typedef struct swirl_options } swirl_options_t; -void swirl_link_solvers(fclaw2d_global_t *glob); +void swirl_link_solvers(fclaw_global_t *glob); /* ------------------------------------- Options ---------------------------------------*/ swirl_options_t* swirl_options_register (fclaw_app_t * app, const char *section, const char *configfile); -void swirl_options_store (fclaw2d_global_t* glob, swirl_options_t* user); +void swirl_options_store (fclaw_global_t* glob, swirl_options_t* user); -const swirl_options_t* swirl_get_options(fclaw2d_global_t* glob); +const swirl_options_t* swirl_get_options(fclaw_global_t* glob); /* Swirl */ -void swirl_create_domain(fclaw2d_global_t *glob); -void swirl_initialize(fclaw2d_global_t* glob); -void swirl_finalize(fclaw2d_global_t* glob); +void swirl_create_domain(fclaw_global_t *glob); +void swirl_initialize(fclaw_global_t* glob); +void swirl_finalize(fclaw_global_t* glob); #ifdef __cplusplus diff --git a/applications/clawpack/advection/2d/filament_swirl/user.h b/applications/clawpack/advection/2d/filament_swirl/user.h index 959f8b4f7..90baabc16 100644 --- a/applications/clawpack/advection/2d/filament_swirl/user.h +++ b/applications/clawpack/advection/2d/filament_swirl/user.h @@ -31,8 +31,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include -#include +#include +#include #ifdef __cplusplus @@ -41,9 +41,9 @@ extern "C" #endif // Why is this here? -typedef struct fclaw2d_global fclaw2d_global_t; +typedef struct fclaw_global fclaw_global_t; -void user_run(fclaw2d_global_t *globs[],int nglobs); +void user_run(fclaw_global_t *globs[],int nglobs); #ifdef __cplusplus } diff --git a/applications/clawpack/advection/2d/filament_swirl/user_run.c b/applications/clawpack/advection/2d/filament_swirl/user_run.c index 7eb7e92e6..a43343f5e 100644 --- a/applications/clawpack/advection/2d/filament_swirl/user_run.c +++ b/applications/clawpack/advection/2d/filament_swirl/user_run.c @@ -23,16 +23,16 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "fclaw_math.h" #include "user.h" @@ -45,40 +45,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------- */ static -void cb_restore_time_step(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_restore_time_step(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_patch_restore_step(s->glob,this_patch); + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_patch_restore_step(s->glob,this_patch); } static -void restore_time_step(fclaw2d_global_t *glob) +void restore_time_step(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob,cb_restore_time_step,(void *) NULL); + fclaw_global_iterate_patches(glob,cb_restore_time_step,(void *) NULL); //fclaw_options_t *fopt = fclaw2d_get_options(glob); //fclaw2d_time_sync_reset(glob,fopt->minlevel,fopt->maxlevel,0); } static -void cb_save_time_step(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_save_time_step(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_patch_save_step(s->glob,this_patch); + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_patch_save_step(s->glob,this_patch); } static -void save_time_step(fclaw2d_global_t *glob) +void save_time_step(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob,cb_save_time_step,(void *) NULL); + fclaw_global_iterate_patches(glob,cb_save_time_step,(void *) NULL); } typedef struct outstyle_1_context { @@ -111,10 +111,10 @@ typedef struct outstyle_1_context { Output times are at times [0,dT, 2*dT, 3*dT,...,Tfinal], where dT = tfinal/nout -------------------------------------------------------------------------------- */ static -double outstyle_1(outstyle_1_context_t* ctx, double t_pause, fclaw2d_global_t *glob) +double outstyle_1(outstyle_1_context_t* ctx, double t_pause, fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_domain_t** domain = &glob->domain; + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); if(ctx->intialized){ goto AFTER_TIMESTEP; @@ -123,11 +123,11 @@ double outstyle_1(outstyle_1_context_t* ctx, double t_pause, fclaw2d_global_t *g /* Set error to 0 */ ctx->init_flag = 1; /* Store anything that needs to be stored */ - fclaw2d_diagnostics_gather(glob,ctx->init_flag); + fclaw_diagnostics_gather(glob,ctx->init_flag); ctx->init_flag = 0; ctx->iframe = 0; - fclaw2d_output_frame(glob,ctx->iframe); + fclaw_output_frame(glob,ctx->iframe); ctx->final_time = fclaw_opt->tfinal; @@ -194,15 +194,15 @@ double outstyle_1(outstyle_1_context_t* ctx, double t_pause, fclaw2d_global_t *g } } glob->curr_dt = ctx->dt_step; - ctx->maxcfl_step = fclaw2d_advance_all_levels(glob, ctx->t_curr,ctx->dt_step); + ctx->maxcfl_step = fclaw_advance_all_levels(glob, ctx->t_curr,ctx->dt_step); if (fclaw_opt->reduce_cfl) { /* If we are taking a variable time step, we have to reduce the maxcfl so that every processor takes the same size dt */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); - ctx->maxcfl_step = fclaw2d_domain_global_maximum (*domain, ctx->maxcfl_step); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_CFL_COMM]); + ctx->maxcfl_step = fclaw_domain_global_maximum (*domain, ctx->maxcfl_step); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_CFL_COMM]); } @@ -279,7 +279,7 @@ double outstyle_1(outstyle_1_context_t* ctx, double t_pause, fclaw2d_global_t *g if (fclaw_opt->advance_one_step) { - fclaw2d_diagnostics_gather(glob, ctx->init_flag); + fclaw_diagnostics_gather(glob, ctx->init_flag); } if (fclaw_opt->regrid_interval > 0) @@ -287,34 +287,34 @@ double outstyle_1(outstyle_1_context_t* ctx, double t_pause, fclaw2d_global_t *g if (ctx->n_inner % fclaw_opt->regrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",ctx->n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } } /* Output file at every outer loop iteration */ - fclaw2d_diagnostics_gather(glob, ctx->init_flag); + fclaw_diagnostics_gather(glob, ctx->init_flag); glob->curr_time = ctx->t_curr; ctx->iframe++; - fclaw2d_output_frame(glob,ctx->iframe); + fclaw_output_frame(glob,ctx->iframe); } return ctx->final_time; } static -void outstyle_3(fclaw2d_global_t *glob) +void outstyle_3(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; @@ -365,16 +365,16 @@ void outstyle_3(fclaw2d_global_t *glob) /* Get current domain data since it may change during regrid */ glob->curr_dt = dt_step; - double maxcfl_step = fclaw2d_advance_all_levels(glob, t_curr,dt_step); + double maxcfl_step = fclaw_advance_all_levels(glob, t_curr,dt_step); /* This is a collective communication - everybody needs to wait here. */ if (fclaw_opt->reduce_cfl) { /* If we are taking a variable time step, we have to reduce the maxcfl so that every processor takes the same size dt */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); - maxcfl_step = fclaw2d_domain_global_maximum (*domain, maxcfl_step); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_CFL_COMM]); + maxcfl_step = fclaw_domain_global_maximum (*domain, maxcfl_step); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_CFL_COMM]); } double tc = t_curr + dt_step; @@ -424,7 +424,7 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nregrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } @@ -436,26 +436,26 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { iframe++; - fclaw2d_diagnostics_gather(glob,init_flag); - fclaw2d_output_frame(glob,iframe); + fclaw_diagnostics_gather(glob,init_flag); + fclaw_output_frame(glob,iframe); } } } static -void outstyle_4(fclaw2d_global_t *glob) +void outstyle_4(fclaw_global_t *glob) { /* Write out an initial time file */ int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; int nstep_outer = fclaw_opt->nout; int nstep_inner = fclaw_opt->nstep; @@ -468,7 +468,7 @@ void outstyle_4(fclaw2d_global_t *glob) while (n < nstep_outer) { /* Get current domain data since it may change during regrid */ - fclaw2d_advance_all_levels(glob, t_curr, dt_minlevel); + fclaw_advance_all_levels(glob, t_curr, dt_minlevel); int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ? fclaw_opt->maxlevel : fclaw_opt->minlevel; @@ -488,7 +488,7 @@ void outstyle_4(fclaw2d_global_t *glob) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } else @@ -498,9 +498,9 @@ void outstyle_4(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -510,7 +510,7 @@ void outstyle_4(fclaw2d_global_t *glob) Public interface ---------------------------------------------------------------- */ -void user_run(fclaw2d_global_t * globs[],int nglobs) +void user_run(fclaw_global_t * globs[],int nglobs) { const fclaw_options_t* fclaw_opts[nglobs]; @@ -521,7 +521,7 @@ void user_run(fclaw2d_global_t * globs[],int nglobs) double tcurr[nglobs]; for(int i=0; i< nglobs; i++){ - fclaw_opts[i] = fclaw2d_get_options(globs[i]); + fclaw_opts[i] = fclaw_get_options(globs[i]); contexts[i].intialized = 0; @@ -535,14 +535,14 @@ void user_run(fclaw2d_global_t * globs[],int nglobs) while(!all_finished){ for(int i=0; i< nglobs; i++){ if(!finished[i]){ - fclaw2d_set_global_context(globs[i]); - fclaw2d_problem_setup(globs[i]); + fclaw_set_global_context(globs[i]); + fclaw_problem_setup(globs[i]); tcurr[i] = outstyle_1(&contexts[i], n*dt[i], globs[i]); finished[i] = tcurr[i] >= fclaw_opts[i]->tfinal; fclaw_global_productionf("Paused at time %12.4f\n\n\n",tcurr[i]); - fclaw2d_clear_global_context(globs[i]); + fclaw_clear_global_context(globs[i]); } } n++; diff --git a/applications/clawpack/advection/2d/gaussian/gaussian.cpp b/applications/clawpack/advection/2d/gaussian/gaussian.cpp index 84db9b6cf..7f3e595c5 100644 --- a/applications/clawpack/advection/2d/gaussian/gaussian.cpp +++ b/applications/clawpack/advection/2d/gaussian/gaussian.cpp @@ -26,9 +26,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "gaussian_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); /* Used locally */ double pi = M_PI; @@ -37,20 +37,20 @@ void create_domain(fclaw2d_global_t *glob) rotate[0] = pi*fclaw_opt->theta/180.0; rotate[1] = 0; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; const user_options_t *user_opt = gaussian_get_options(glob); switch (user_opt->mapping) { case 0: domain = - fclaw2d_domain_new_cubedsphere (glob->mpicomm, + fclaw_domain_new_2d_cubedsphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_cubedsphere (fclaw_opt->scale, rotate); break; case 1: domain = - fclaw2d_domain_new_twosphere (glob->mpicomm, fclaw_opt->minlevel); + fclaw_domain_new_2d_twosphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowsphere (fclaw_opt->scale, rotate); break; default: @@ -58,28 +58,22 @@ void create_domain(fclaw2d_global_t *glob) } /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ const user_options_t *user_opt = gaussian_get_options(glob); @@ -97,9 +91,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -111,13 +105,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = gaussian_options_register(app, "fclaw_options.ini"); @@ -132,11 +126,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); gaussian_options_store (glob, user_opt); @@ -147,7 +141,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/gaussian/gaussian_options.c b/applications/clawpack/advection/2d/gaussian/gaussian_options.c index b7e19a6e9..775b99802 100644 --- a/applications/clawpack/advection/2d/gaussian/gaussian_options.c +++ b/applications/clawpack/advection/2d/gaussian/gaussian_options.c @@ -154,14 +154,14 @@ user_options_t* gaussian_options_register (fclaw_app_t * app, return user; } -void gaussian_options_store (fclaw2d_global_t* glob, user_options_t* user) +void gaussian_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* gaussian_get_options(fclaw2d_global_t* glob) +const user_options_t* gaussian_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } /* ------------------------- ... and here ---------------------------- */ diff --git a/applications/clawpack/advection/2d/gaussian/gaussian_user.cpp b/applications/clawpack/advection/2d/gaussian/gaussian_user.cpp index 7c817da17..375abba13 100644 --- a/applications/clawpack/advection/2d/gaussian/gaussian_user.cpp +++ b/applications/clawpack/advection/2d/gaussian/gaussian_user.cpp @@ -26,14 +26,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "gaussian_user.h" static -void gaussian_problem_setup(fclaw2d_global_t* glob) +void gaussian_problem_setup(fclaw_global_t* glob) { SETPROB(); } static -void gaussian_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void gaussian_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -43,8 +43,8 @@ void gaussian_patch_setup_manifold(fclaw2d_global_t *glob, } static -void gaussian_b4step2_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void gaussian_b4step2_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -55,18 +55,18 @@ void gaussian_b4step2_manifold(fclaw2d_global_t *glob, user->claw_version); } -void gaussian_link_solvers(fclaw2d_global_t *glob) +void gaussian_link_solvers(fclaw_global_t *glob) { /* Custom setprob */ - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &gaussian_problem_setup; /* Version-independent */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &gaussian_patch_setup_manifold; const user_options_t* user = gaussian_get_options(glob); if (user->mapping == 1) - fclaw2d_clawpatch_use_pillowsphere(glob); + fclaw_clawpatch_use_pillowsphere(glob); if (user->claw_version == 4) diff --git a/applications/clawpack/advection/2d/gaussian/gaussian_user.h b/applications/clawpack/advection/2d/gaussian/gaussian_user.h index e72a56fb7..d82cb942d 100644 --- a/applications/clawpack/advection/2d/gaussian/gaussian_user.h +++ b/applications/clawpack/advection/2d/gaussian/gaussian_user.h @@ -44,15 +44,15 @@ typedef struct user_options } user_options_t; -void gaussian_link_solvers(struct fclaw2d_global *glob); +void gaussian_link_solvers(struct fclaw_global *glob); -const user_options_t* gaussian_get_options(fclaw2d_global_t* glob); +const user_options_t* gaussian_get_options(fclaw_global_t* glob); user_options_t* gaussian_options_register (fclaw_app_t * app, const char *configfile); -void gaussian_options_store (fclaw2d_global_t* glob, user_options_t* user); +void gaussian_options_store (fclaw_global_t* glob, user_options_t* user); #ifdef __cplusplus } diff --git a/applications/clawpack/advection/2d/gaussian/user_4.6/qinit.f b/applications/clawpack/advection/2d/gaussian/user_4.6/qinit.f index e36869ab9..04cabeaae 100644 --- a/applications/clawpack/advection/2d/gaussian/user_4.6/qinit.f +++ b/applications/clawpack/advection/2d/gaussian/user_4.6/qinit.f @@ -22,7 +22,7 @@ subroutine clawpack46_qinit(maxmx,maxmy,meqn,mbc, yc = ylower + (j-0.5d0)*dy do i = 1-mbc,mx+mbc xc = xlower + (i-0.5d0)*dx - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) q(i,j,1) = gaussian_sum(xp,yp,zp) enddo diff --git a/applications/clawpack/advection/2d/gaussian/user_5.0/qinit.f90 b/applications/clawpack/advection/2d/gaussian/user_5.0/qinit.f90 index e80de79f0..0a7a9f5a1 100644 --- a/applications/clawpack/advection/2d/gaussian/user_5.0/qinit.f90 +++ b/applications/clawpack/advection/2d/gaussian/user_5.0/qinit.f90 @@ -20,7 +20,7 @@ SUBROUTINE clawpack5_qinit(meqn,mbc,mx,my,xlower,ylower,dx,dy,q,maux,aux) yc = ylower + (j-0.5d0)*dy DO i = 1-mbc,mx+mbc xc = xlower + (i-0.5d0)*dx - CALL fclaw2d_map_c2m(cont, & + CALL fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) q(1,i,j) = gaussian_sum(xp,yp,zp) ENDDO diff --git a/applications/clawpack/advection/2d/hemisphere/fdisc.f b/applications/clawpack/advection/2d/hemisphere/fdisc.f index de7a534d0..7f94aa112 100644 --- a/applications/clawpack/advection/2d/hemisphere/fdisc.f +++ b/applications/clawpack/advection/2d/hemisphere/fdisc.f @@ -7,7 +7,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) diff --git a/applications/clawpack/advection/2d/hemisphere/hemisphere.cpp b/applications/clawpack/advection/2d/hemisphere/hemisphere.cpp index c3614f78b..6712b5359 100644 --- a/applications/clawpack/advection/2d/hemisphere/hemisphere.cpp +++ b/applications/clawpack/advection/2d/hemisphere/hemisphere.cpp @@ -27,11 +27,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ------------- Create the domain --------------------- */ static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* Used locally */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); double pi = M_PI; double rotate[2]; rotate[0] = pi*fclaw_opt->theta/180.0; @@ -47,8 +47,8 @@ void create_domain(fclaw2d_global_t *glob) #endif /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; user_options_t *user_opt = (user_options_t*) hemisphere_get_options(glob); switch (user_opt->example) { @@ -66,7 +66,7 @@ void create_domain(fclaw2d_global_t *glob) #endif /* Five patch square domain */ domain = - fclaw2d_domain_new_disk(glob->mpicomm, 0, 0, + fclaw_domain_new_2d_disk(glob->mpicomm, 0, 0, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowsphere5(fclaw_opt->scale, @@ -78,7 +78,7 @@ void create_domain(fclaw2d_global_t *glob) /* Map unit square to disk using mapc2m_disk.f */ /* Map unit square to the pillow disk using mapc2m_pillowdisk.f */ domain = - fclaw2d_domain_new_unitsquare (glob->mpicomm, + fclaw_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowsphere(fclaw_opt->scale, @@ -90,26 +90,21 @@ void create_domain(fclaw2d_global_t *glob) /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ const user_options_t *user_opt = hemisphere_get_options(glob); @@ -123,9 +118,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -137,13 +132,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = hemisphere_options_register(app, "fclaw_options.ini"); @@ -160,11 +155,11 @@ main (int argc, char **argv) /* Create glob */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); hemisphere_options_store (glob, user_opt); @@ -174,7 +169,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/hemisphere/hemisphere_options.c b/applications/clawpack/advection/2d/hemisphere/hemisphere_options.c index 2a7ba94bb..bf817ea71 100644 --- a/applications/clawpack/advection/2d/hemisphere/hemisphere_options.c +++ b/applications/clawpack/advection/2d/hemisphere/hemisphere_options.c @@ -130,13 +130,13 @@ user_options_t* hemisphere_options_register (fclaw_app_t * app, return user; } -void hemisphere_options_store (fclaw2d_global_t* glob, user_options_t* user) +void hemisphere_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* hemisphere_get_options(fclaw2d_global_t* glob) +const user_options_t* hemisphere_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/hemisphere/hemisphere_user.cpp b/applications/clawpack/advection/2d/hemisphere/hemisphere_user.cpp index 66bb2727f..54c1e1f9d 100644 --- a/applications/clawpack/advection/2d/hemisphere/hemisphere_user.cpp +++ b/applications/clawpack/advection/2d/hemisphere/hemisphere_user.cpp @@ -26,8 +26,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "hemisphere_user.h" static -void hemisphere_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void hemisphere_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -37,9 +37,9 @@ void hemisphere_patch_setup(fclaw2d_global_t *glob, } -void hemisphere_link_solvers(fclaw2d_global_t *glob) +void hemisphere_link_solvers(fclaw_global_t *glob) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &hemisphere_patch_setup; const user_options_t* user = hemisphere_get_options(glob); diff --git a/applications/clawpack/advection/2d/hemisphere/hemisphere_user.h b/applications/clawpack/advection/2d/hemisphere/hemisphere_user.h index 3ecf495a6..d4d254308 100644 --- a/applications/clawpack/advection/2d/hemisphere/hemisphere_user.h +++ b/applications/clawpack/advection/2d/hemisphere/hemisphere_user.h @@ -49,14 +49,14 @@ typedef struct user_options -void hemisphere_link_solvers(fclaw2d_global_t *glob); +void hemisphere_link_solvers(fclaw_global_t *glob); user_options_t* hemisphere_options_register (fclaw_app_t * app, const char *configfile); -const user_options_t* hemisphere_get_options(fclaw2d_global_t* glob); +const user_options_t* hemisphere_get_options(fclaw_global_t* glob); -void hemisphere_options_store (fclaw2d_global_t* glob, user_options_t* user); +void hemisphere_options_store (fclaw_global_t* glob, user_options_t* user); #ifdef __cplusplus diff --git a/applications/clawpack/advection/2d/latlong/fdisc.f b/applications/clawpack/advection/2d/latlong/fdisc.f index 9082e1eaf..d765a276b 100644 --- a/applications/clawpack/advection/2d/latlong/fdisc.f +++ b/applications/clawpack/advection/2d/latlong/fdisc.f @@ -11,7 +11,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) c # Torus or annulus diff --git a/applications/clawpack/advection/2d/latlong/latlong.cpp b/applications/clawpack/advection/2d/latlong/latlong.cpp index e47c45140..bd52541ca 100644 --- a/applications/clawpack/advection/2d/latlong/latlong.cpp +++ b/applications/clawpack/advection/2d/latlong/latlong.cpp @@ -28,12 +28,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../all/advection_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* --------------------------------------------------------------- Mapping geometry --------------------------------------------------------------- */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; int a = fclaw_opt->periodic_x; @@ -47,17 +47,17 @@ void create_domain(fclaw2d_global_t *glob) rotate[1] = pi*fclaw_opt->phi/180.0; /* Create brick domain with periodicity */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_t *domain = + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Create brick mapping */ - fclaw2d_map_context_t *brick = - fclaw2d_map_new_brick(domain, mi, mj, a, b); + fclaw_map_context_t *brick = + fclaw_map_new_2d_brick(domain, mi, mj, a, b); /* Create latlong mapping based on brick */ const user_options_t *user = latlong_get_options(glob); - fclaw2d_map_context_t *cont = + fclaw_map_context_t *cont = fclaw2d_map_new_latlong(brick,fclaw_opt->scale, rotate, user->latitude, @@ -66,28 +66,23 @@ void create_domain(fclaw2d_global_t *glob) /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = latlong_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -104,9 +99,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -118,13 +113,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Register packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = latlong_options_register(app, "fclaw_options.ini"); @@ -140,10 +135,10 @@ main (int argc, char **argv) int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); latlong_options_store (glob, user_opt); @@ -153,7 +148,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy (glob); + fclaw_global_destroy (glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/latlong/latlong_options.c b/applications/clawpack/advection/2d/latlong/latlong_options.c index 90aa43344..c9a749446 100644 --- a/applications/clawpack/advection/2d/latlong/latlong_options.c +++ b/applications/clawpack/advection/2d/latlong/latlong_options.c @@ -170,14 +170,14 @@ user_options_t* latlong_options_register (fclaw_app_t * app, return user; } -void latlong_options_store (fclaw2d_global_t* glob, user_options_t* user) +void latlong_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* latlong_get_options(fclaw2d_global_t* glob) +const user_options_t* latlong_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/latlong/latlong_user.cpp b/applications/clawpack/advection/2d/latlong/latlong_user.cpp index 5866e513f..032335828 100644 --- a/applications/clawpack/advection/2d/latlong/latlong_user.cpp +++ b/applications/clawpack/advection/2d/latlong/latlong_user.cpp @@ -25,10 +25,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "latlong_user.h" -void latlong_problem_setup(fclaw2d_global_t *glob) +void latlong_problem_setup(fclaw_global_t *glob) { const user_options_t* user = latlong_get_options(glob); - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (glob->mpirank == 0) { FILE *f = fopen("setprob.data","w"); @@ -41,14 +41,14 @@ void latlong_problem_setup(fclaw2d_global_t *glob) fprintf(f, "%-24.6f %s",user->latitude[1],"\% latitude[1]\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } static -void latlong_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void latlong_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -57,12 +57,12 @@ void latlong_patch_setup(fclaw2d_global_t *glob, user->claw_version); } -void latlong_link_solvers(fclaw2d_global_t *glob) +void latlong_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = latlong_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = latlong_problem_setup; - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &latlong_patch_setup; const user_options_t *user = latlong_get_options(glob); diff --git a/applications/clawpack/advection/2d/latlong/latlong_user.h b/applications/clawpack/advection/2d/latlong/latlong_user.h index 668986082..01d3ba4d4 100644 --- a/applications/clawpack/advection/2d/latlong/latlong_user.h +++ b/applications/clawpack/advection/2d/latlong/latlong_user.h @@ -53,14 +53,14 @@ typedef struct user_options } user_options_t; -void latlong_link_solvers(fclaw2d_global_t *glob); +void latlong_link_solvers(fclaw_global_t *glob); user_options_t* latlong_options_register (fclaw_app_t * app, const char *configfile);\ -void latlong_options_store (fclaw2d_global_t* glob, user_options_t* user); +void latlong_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* latlong_get_options(fclaw2d_global_t* glob); +const user_options_t* latlong_get_options(fclaw_global_t* glob); #ifdef __cplusplus #if 0 diff --git a/applications/clawpack/advection/2d/periodic/periodic.cpp b/applications/clawpack/advection/2d/periodic/periodic.cpp index bc319bd96..ac374f6dd 100644 --- a/applications/clawpack/advection/2d/periodic/periodic.cpp +++ b/applications/clawpack/advection/2d/periodic/periodic.cpp @@ -29,53 +29,48 @@ /* ------------- Create the domain --------------------- */ static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* --------------------------------------------------------------- Mapping geometry --------------------------------------------------------------- */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; /* Periodic : Mapped, multi-block domain */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_t *domain = + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Create mapping context (square periodic domain based on a brick) */ //const user_options_t *user = (user_options_t*) annulus_get_options(glob); - fclaw2d_map_context_t *brick = - fclaw2d_map_new_brick(domain, mi, mj, a, b); + fclaw_map_context_t *brick = + fclaw_map_new_2d_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = - fclaw2d_map_new_nomap_brick(brick); + fclaw_map_context_t *cont = + fclaw_map_new_nomap_brick(brick); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = periodic_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -92,9 +87,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -106,13 +101,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = periodic_options_register(app, "fclaw_options.ini"); @@ -130,11 +125,11 @@ main (int argc, char **argv) /* Create glob */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); periodic_options_store (glob, user_opt); @@ -144,7 +139,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/periodic/periodic_options.c b/applications/clawpack/advection/2d/periodic/periodic_options.c index 701563d68..7f86d50a5 100644 --- a/applications/clawpack/advection/2d/periodic/periodic_options.c +++ b/applications/clawpack/advection/2d/periodic/periodic_options.c @@ -153,12 +153,12 @@ user_options_t* periodic_options_register (fclaw_app_t * app, return user; } -void periodic_options_store (fclaw2d_global_t* glob, user_options_t* user) +void periodic_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* periodic_get_options(fclaw2d_global_t* glob) +const user_options_t* periodic_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/periodic/periodic_user.cpp b/applications/clawpack/advection/2d/periodic/periodic_user.cpp index 28531b453..a58c89393 100644 --- a/applications/clawpack/advection/2d/periodic/periodic_user.cpp +++ b/applications/clawpack/advection/2d/periodic/periodic_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "periodic_user.h" static -void periodic_problem_setup(fclaw2d_global_t* glob) +void periodic_problem_setup(fclaw_global_t* glob) { const user_options_t* user = periodic_get_options(glob); @@ -39,15 +39,15 @@ void periodic_problem_setup(fclaw2d_global_t* glob) } /* Make sure that node 0 has written 'setprob.data' before proceeding */ - fclaw2d_domain_barrier(glob->domain); + fclaw_domain_barrier(glob->domain); SETPROB(); /* Reads file created above */ } -void periodic_link_solvers(fclaw2d_global_t *glob) +void periodic_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &periodic_problem_setup; /* Version-independent */ const user_options_t* user = periodic_get_options(glob); diff --git a/applications/clawpack/advection/2d/periodic/periodic_user.h b/applications/clawpack/advection/2d/periodic/periodic_user.h index d5ae4d1b3..5a5f7f68d 100644 --- a/applications/clawpack/advection/2d/periodic/periodic_user.h +++ b/applications/clawpack/advection/2d/periodic/periodic_user.h @@ -46,15 +46,15 @@ typedef struct user_options } user_options_t; -void periodic_link_solvers(fclaw2d_global_t *glob); +void periodic_link_solvers(fclaw_global_t *glob); /* ------------------------------------- Options ---------------------------------------*/ user_options_t* periodic_options_register (fclaw_app_t * app, const char *configfile); -void periodic_options_store (fclaw2d_global_t* glob, user_options_t* user); +void periodic_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* periodic_get_options(fclaw2d_global_t* glob); +const user_options_t* periodic_get_options(fclaw_global_t* glob); diff --git a/applications/clawpack/advection/2d/replicated/qexact.f b/applications/clawpack/advection/2d/replicated/qexact.f index 283999279..13824fd55 100644 --- a/applications/clawpack/advection/2d/replicated/qexact.f +++ b/applications/clawpack/advection/2d/replicated/qexact.f @@ -29,7 +29,7 @@ double precision function q0(blockno,xc1,yc1) integer blockno integer*8 cont, get_context double precision r,r0 - logical fclaw2d_map_is_used + logical fclaw_map_is_used double precision Hsmooth,h1,h2 double precision xloc(0:4),yloc(0:4),zloc(0:4) diff --git a/applications/clawpack/advection/2d/replicated/replicated.cpp b/applications/clawpack/advection/2d/replicated/replicated.cpp index bd2c85a1e..d96ffe542 100644 --- a/applications/clawpack/advection/2d/replicated/replicated.cpp +++ b/applications/clawpack/advection/2d/replicated/replicated.cpp @@ -27,56 +27,51 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../all/advection_user.h" -#include +#include #include static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* Set up domain */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; /* replicated : Mapped, multi-block domain */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_t *domain = + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Create mapping context for replicated domain */ - fclaw2d_map_context_t *brick = - fclaw2d_map_new_brick(domain, mi, mj, a, b); + fclaw_map_context_t *brick = + fclaw_map_new_2d_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = - fclaw2d_map_new_nomap_brick(brick); + fclaw_map_context_t *cont = + fclaw_map_new_nomap_brick(brick); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = replicated_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -93,9 +88,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -107,13 +102,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = replicated_options_register(app, "fclaw_options.ini"); @@ -135,11 +130,11 @@ main (int argc, char **argv) /* Create glob */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); replicated_options_store (glob, user_opt); @@ -150,7 +145,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/replicated/replicated_options.c b/applications/clawpack/advection/2d/replicated/replicated_options.c index 4c77d0855..93e49b782 100644 --- a/applications/clawpack/advection/2d/replicated/replicated_options.c +++ b/applications/clawpack/advection/2d/replicated/replicated_options.c @@ -148,18 +148,18 @@ user_options_t* replicated_options_register (fclaw_app_t * app, return user; } -void replicated_options_store (fclaw2d_global_t* glob, user_options_t* user) +void replicated_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* replicated_get_options(fclaw2d_global_t* glob) +const user_options_t* replicated_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } void replicated_global_post_process(fclaw_options_t *fclaw_opt, - fclaw2d_clawpatch_options_t *clawpatch_opt, + fclaw_clawpatch_options_t *clawpatch_opt, user_options_t *user_opt) { /* This routine will be called to do any more global post-processing */ diff --git a/applications/clawpack/advection/2d/replicated/replicated_user.cpp b/applications/clawpack/advection/2d/replicated/replicated_user.cpp index c29c97da5..e11499e99 100644 --- a/applications/clawpack/advection/2d/replicated/replicated_user.cpp +++ b/applications/clawpack/advection/2d/replicated/replicated_user.cpp @@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "replicated_user.h" static -void replicated_problem_setup(fclaw2d_global_t* glob) +void replicated_problem_setup(fclaw_global_t* glob) { const user_options_t* user = replicated_get_options(glob); @@ -42,14 +42,14 @@ void replicated_problem_setup(fclaw2d_global_t* glob) } /* Make sure that node 0 has written `setprob.data` before proceeding */ - fclaw2d_domain_barrier(glob->domain); + fclaw_domain_barrier(glob->domain); SETPROB(); /* Reads file created above */ } -void replicated_link_solvers(fclaw2d_global_t *glob) +void replicated_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &replicated_problem_setup; const user_options_t* user = replicated_get_options(glob); diff --git a/applications/clawpack/advection/2d/replicated/replicated_user.h b/applications/clawpack/advection/2d/replicated/replicated_user.h index 6ecf6a12e..1574be980 100644 --- a/applications/clawpack/advection/2d/replicated/replicated_user.h +++ b/applications/clawpack/advection/2d/replicated/replicated_user.h @@ -52,18 +52,18 @@ typedef struct user_options } user_options_t; -void replicated_link_solvers(fclaw2d_global_t *glob); +void replicated_link_solvers(fclaw_global_t *glob); /* Options handling */ user_options_t* replicated_options_register (fclaw_app_t * app, const char *configfile); -void replicated_options_store (fclaw2d_global_t* glob, user_options_t* user); +void replicated_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* replicated_get_options(fclaw2d_global_t* glob); +const user_options_t* replicated_get_options(fclaw_global_t* glob); void replicated_global_post_process(fclaw_options_t *fclaw_opt, - fclaw2d_clawpatch_options_t *clawpatch_opt, + fclaw_clawpatch_options_t *clawpatch_opt, user_options_t *user_opt); diff --git a/applications/clawpack/advection/2d/slotted_disk/fdisc.f b/applications/clawpack/advection/2d/slotted_disk/fdisc.f index 65a515f6b..6f06ea464 100644 --- a/applications/clawpack/advection/2d/slotted_disk/fdisc.f +++ b/applications/clawpack/advection/2d/slotted_disk/fdisc.f @@ -14,7 +14,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont,blockno,xc,yc,xp,yp,zp) + call fclaw_map_2d_c2m(cont,blockno,xc,yc,xp,yp,zp) c call get_td_sdisk_parms(r,hmax,b,c) diff --git a/applications/clawpack/advection/2d/slotted_disk/slotted_disk.cpp b/applications/clawpack/advection/2d/slotted_disk/slotted_disk.cpp index 49eb74d89..8807e51a2 100644 --- a/applications/clawpack/advection/2d/slotted_disk/slotted_disk.cpp +++ b/applications/clawpack/advection/2d/slotted_disk/slotted_disk.cpp @@ -26,31 +26,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "slotted_disk_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* Used locally */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); double pi = M_PI; double rotate[2]; rotate[0] = pi*fclaw_opt->theta/180.0; rotate[1] = 0; /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; const user_options_t *user_opt = slotted_disk_get_options(glob); switch (user_opt->mapping) { case 0: domain = - fclaw2d_domain_new_cubedsphere(glob->mpicomm, + fclaw_domain_new_2d_cubedsphere(glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_cubedsphere(fclaw_opt->scale, rotate); break; case 1: domain = - fclaw2d_domain_new_twosphere(glob->mpicomm, + fclaw_domain_new_2d_twosphere(glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowsphere(fclaw_opt->scale, rotate); @@ -60,29 +60,24 @@ void create_domain(fclaw2d_global_t *glob) SC_ABORT_NOT_REACHED (); /* must be checked in torus_checkparms */ } /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = slotted_disk_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -99,9 +94,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } @@ -114,13 +109,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = slotted_disk_options_register(app, "fclaw_options.ini"); @@ -135,11 +130,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); slotted_disk_options_store (glob, user_opt); @@ -150,7 +145,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/slotted_disk/slotted_disk_options.c b/applications/clawpack/advection/2d/slotted_disk/slotted_disk_options.c index b7196d754..a7c9579b3 100644 --- a/applications/clawpack/advection/2d/slotted_disk/slotted_disk_options.c +++ b/applications/clawpack/advection/2d/slotted_disk/slotted_disk_options.c @@ -154,14 +154,14 @@ user_options_t* slotted_disk_options_register (fclaw_app_t * app, return user; } -void slotted_disk_options_store (fclaw2d_global_t* glob, user_options_t* user) +void slotted_disk_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* slotted_disk_get_options(fclaw2d_global_t* glob) +const user_options_t* slotted_disk_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } /* ------------------------- ... and here ---------------------------- */ diff --git a/applications/clawpack/advection/2d/slotted_disk/slotted_disk_user.cpp b/applications/clawpack/advection/2d/slotted_disk/slotted_disk_user.cpp index 958173eb2..98f2b3df0 100644 --- a/applications/clawpack/advection/2d/slotted_disk/slotted_disk_user.cpp +++ b/applications/clawpack/advection/2d/slotted_disk/slotted_disk_user.cpp @@ -26,14 +26,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "slotted_disk_user.h" static -void slotted_disk_problem_setup(fclaw2d_global_t* glob) +void slotted_disk_problem_setup(fclaw_global_t* glob) { SETPROB(); } static -void slotted_disk_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void slotted_disk_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -42,8 +42,8 @@ void slotted_disk_patch_setup_manifold(fclaw2d_global_t *glob, } static -void slotted_disk_b4step2_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void slotted_disk_b4step2_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -53,21 +53,21 @@ void slotted_disk_b4step2_manifold(fclaw2d_global_t *glob, advection_b4step2_manifold(glob,patch,blockno,patchno,t,dt,user->claw_version); } -void slotted_disk_link_solvers(fclaw2d_global_t *glob) +void slotted_disk_link_solvers(fclaw_global_t *glob) { /* Custom setprob */ - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &slotted_disk_problem_setup; /* Version-independent */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &slotted_disk_patch_setup_manifold; const user_options_t* user = slotted_disk_get_options(glob); if (user->mapping == 1) - fclaw2d_clawpatch_use_pillowsphere(glob); + fclaw_clawpatch_use_pillowsphere(glob); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - clawpatch_vt->fort_user_exceeds_threshold = &USER_EXCEEDS_THRESHOLD; + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + clawpatch_vt->d2->fort_user_exceeds_threshold = &USER_EXCEEDS_THRESHOLD; if (user->claw_version == 4) { diff --git a/applications/clawpack/advection/2d/slotted_disk/slotted_disk_user.h b/applications/clawpack/advection/2d/slotted_disk/slotted_disk_user.h index 871385937..6a1e5d627 100644 --- a/applications/clawpack/advection/2d/slotted_disk/slotted_disk_user.h +++ b/applications/clawpack/advection/2d/slotted_disk/slotted_disk_user.h @@ -44,15 +44,15 @@ typedef struct user_options } user_options_t; -const user_options_t* slotted_disk_get_options(fclaw2d_global_t* glob); +const user_options_t* slotted_disk_get_options(fclaw_global_t* glob); user_options_t* slotted_disk_options_register (fclaw_app_t * app, const char *configfile); -void slotted_disk_options_store (fclaw2d_global_t* glob, user_options_t* user); +void slotted_disk_options_store (fclaw_global_t* glob, user_options_t* user); -void slotted_disk_link_solvers(fclaw2d_global_t *glob); +void slotted_disk_link_solvers(fclaw_global_t *glob); #ifdef __cplusplus diff --git a/applications/clawpack/advection/2d/sphere/fdisc.f b/applications/clawpack/advection/2d/sphere/fdisc.f index e37f2f47c..07341b557 100644 --- a/applications/clawpack/advection/2d/sphere/fdisc.f +++ b/applications/clawpack/advection/2d/sphere/fdisc.f @@ -12,7 +12,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) !!c # Make a beach ball. diff --git a/applications/clawpack/advection/2d/sphere/sphere.cpp b/applications/clawpack/advection/2d/sphere/sphere.cpp index 79fe8d062..3c4f53e26 100644 --- a/applications/clawpack/advection/2d/sphere/sphere.cpp +++ b/applications/clawpack/advection/2d/sphere/sphere.cpp @@ -29,30 +29,30 @@ /* ------------- Create the domain --------------------- */ static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* Used locally */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); double pi = M_PI; double rotate[2]; rotate[0] = pi*fclaw_opt->theta/180.0; rotate[1] = pi*fclaw_opt->phi/180.0; /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; const user_options_t *user_opt = sphere_get_options(glob); switch (user_opt->example) { case 0: - domain = fclaw2d_domain_new_cubedsphere (glob->mpicomm, + domain = fclaw_domain_new_2d_cubedsphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_cubedsphere(fclaw_opt->scale, rotate); break; case 1: - domain = fclaw2d_domain_new_twosphere (glob->mpicomm, + domain = fclaw_domain_new_2d_twosphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowsphere(fclaw_opt->scale, @@ -63,28 +63,23 @@ void create_domain(fclaw2d_global_t *glob) } /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = sphere_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -101,9 +96,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -115,13 +110,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = sphere_options_register(app, "fclaw_options.ini"); @@ -136,11 +131,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); sphere_options_store (glob, user_opt); @@ -151,7 +146,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/sphere/sphere_options.c b/applications/clawpack/advection/2d/sphere/sphere_options.c index 3ad17d310..0d452471b 100644 --- a/applications/clawpack/advection/2d/sphere/sphere_options.c +++ b/applications/clawpack/advection/2d/sphere/sphere_options.c @@ -160,13 +160,13 @@ user_options_t* sphere_options_register (fclaw_app_t * app, return user; } -void sphere_options_store (fclaw2d_global_t* glob, user_options_t* user) +void sphere_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* sphere_get_options(fclaw2d_global_t* glob) +const user_options_t* sphere_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/sphere/sphere_user.cpp b/applications/clawpack/advection/2d/sphere/sphere_user.cpp index 598ada31d..441d4fefa 100644 --- a/applications/clawpack/advection/2d/sphere/sphere_user.cpp +++ b/applications/clawpack/advection/2d/sphere/sphere_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "sphere_user.h" static -void sphere_problem_setup(fclaw2d_global_t* glob) +void sphere_problem_setup(fclaw_global_t* glob) { const user_options_t *user = sphere_get_options(glob); @@ -37,13 +37,13 @@ void sphere_problem_setup(fclaw2d_global_t* glob) fclose(f); } - fclaw2d_domain_barrier(glob->domain); + fclaw_domain_barrier(glob->domain); SETPROB(); } static -void sphere_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void sphere_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -53,19 +53,19 @@ void sphere_patch_setup(fclaw2d_global_t *glob, } -void sphere_link_solvers(fclaw2d_global_t *glob) +void sphere_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &sphere_problem_setup; /* Version-independent */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &sphere_patch_setup; const user_options_t* user = sphere_get_options(glob); if (user->example == 1) { /* Needed to get correct handling of block corners */ - fclaw2d_clawpatch_use_pillowsphere(glob); + fclaw_clawpatch_use_pillowsphere(glob); } diff --git a/applications/clawpack/advection/2d/sphere/sphere_user.h b/applications/clawpack/advection/2d/sphere/sphere_user.h index 04560db94..5aa7fe88e 100644 --- a/applications/clawpack/advection/2d/sphere/sphere_user.h +++ b/applications/clawpack/advection/2d/sphere/sphere_user.h @@ -50,11 +50,11 @@ typedef struct user_options user_options_t* sphere_options_register (fclaw_app_t * app, const char *configfile); -void sphere_options_store (fclaw2d_global_t* glob, user_options_t* user); +void sphere_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* sphere_get_options(fclaw2d_global_t* glob); +const user_options_t* sphere_get_options(fclaw_global_t* glob); -void sphere_link_solvers(fclaw2d_global_t *glob); +void sphere_link_solvers(fclaw_global_t *glob); #ifdef __cplusplus diff --git a/applications/clawpack/advection/2d/swirl/swirl.cpp b/applications/clawpack/advection/2d/swirl/swirl.cpp index fe2cc18d3..fcbeb8394 100644 --- a/applications/clawpack/advection/2d/swirl/swirl.cpp +++ b/applications/clawpack/advection/2d/swirl/swirl.cpp @@ -28,30 +28,31 @@ #include "../all/advection_user.h" #include /* just temporary for testing */ +#include #define FCLAW_SWIRL_IO_DEMO 0 static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare(glob->mpicomm, + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); /* Create "empty" mapping */ - fclaw2d_map_context_t* cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t* cont = fclaw_map_new_nomap(); /* Store domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* Map unit square to disk using mapc2m_disk.f */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } #if FCLAW_SWIRL_IO_DEMO @@ -77,7 +78,7 @@ check_fclaw2d_file_error_code (int errcode, const char *str) #endif static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { #if FCLAW_SWIRL_IO_DEMO int i; @@ -90,13 +91,8 @@ void run_program(fclaw2d_global_t* glob) fclaw2d_domain_t *read_domain; #endif - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ const user_options_t *user_opt = swirl_get_options(glob); @@ -114,8 +110,8 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); + fclaw_initialize(glob); + fclaw_run(glob); #if FCLAW_SWIRL_IO_DEMO /* Example usage of forestclaw file functions. This is just for @@ -125,9 +121,8 @@ void run_program(fclaw2d_global_t* glob) */ /* create a file, which is open for further writing */ /* the passed domain is written to the file */ - /* The file extension is the user's choice. */ fc = fclaw2d_file_open_write ("swirl_io_test.f2d", "ForestClaw data file", - glob->domain, &errcode); + glob->domain->d2, &errcode); check_fclaw2d_file_error_code (errcode, "file open write"); /* Write the partition of domain to a separate partition file. */ @@ -135,7 +130,7 @@ void run_program(fclaw2d_global_t* glob) /* The file extension is the user's choice. */ retval = fclaw2d_file_write_partition ("swirl_io_test_partition.fp2d", "Test partition write", - glob->domain, &errcode); + glob->domain->d2, &errcode); check_fclaw2d_file_error_code (errcode, "file write partition"); FCLAW_EXECUTE_ASSERT_FALSE (retval); @@ -189,7 +184,7 @@ void run_program(fclaw2d_global_t* glob) /* read the partition file */ sc_array_init (&partition, sizeof (p4est_gloidx_t)); - retval = fclaw2d_file_read_partition ("swirl_io_test_partition", + retval = fclaw2d_file_read_partition ("swirl_io_test_partition.fp2d", read_user_string, glob->domain->mpicomm, &partition, &errcode); @@ -204,7 +199,7 @@ void run_program(fclaw2d_global_t* glob) * pass NULL instead of &partition to use the uniform partition with respect * to the patch count. */ - fc = fclaw2d_file_open_read ("swirl_io_test", read_user_string, + fc = fclaw2d_file_open_read ("swirl_io_test.f2d", read_user_string, glob->domain->mpicomm, &partition, &read_domain, &errcode); check_fclaw2d_file_error_code (errcode, "file open read"); @@ -257,7 +252,7 @@ void run_program(fclaw2d_global_t* glob) /* sanity check of read domain */ FCLAW_ASSERT (p4est_checksum (((p4est_wrap_t *) read_domain->pp)->p4est) == - p4est_checksum (((p4est_wrap_t *) glob->domain->pp)-> + p4est_checksum (((p4est_wrap_t *) glob->domain->d2->pp)-> p4est)); fclaw2d_domain_destroy (read_domain); @@ -267,7 +262,7 @@ void run_program(fclaw2d_global_t* glob) FCLAW_EXECUTE_ASSERT_FALSE (retval); #endif - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -279,13 +274,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = swirl_options_register(app, "fclaw_options.ini"); @@ -301,11 +296,11 @@ main (int argc, char **argv) /* Create global structure which stores the domain, timers, etc */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); swirl_options_store (glob, user_opt); @@ -320,7 +315,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); //fclaw2d_global_destroy(glob2); } diff --git a/applications/clawpack/advection/2d/swirl/swirl_options.c b/applications/clawpack/advection/2d/swirl/swirl_options.c index d4215474d..cecb029c8 100644 --- a/applications/clawpack/advection/2d/swirl/swirl_options.c +++ b/applications/clawpack/advection/2d/swirl/swirl_options.c @@ -194,12 +194,12 @@ user_options_t* swirl_options_register (fclaw_app_t * app, return user; } -void swirl_options_store (fclaw2d_global_t* glob, user_options_t* user) +void swirl_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* swirl_get_options(fclaw2d_global_t* glob) +const user_options_t* swirl_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/swirl/swirl_ray.c b/applications/clawpack/advection/2d/swirl/swirl_ray.c index 4ea507134..872b698cf 100644 --- a/applications/clawpack/advection/2d/swirl/swirl_ray.c +++ b/applications/clawpack/advection/2d/swirl/swirl_ray.c @@ -27,7 +27,7 @@ #include "../all/advection_user.h" -#include +#include #include @@ -137,8 +137,8 @@ int segment_intersect(point_t p0, point_t p1, } -int swirl_intersect_ray (fclaw2d_domain_t *domain, - fclaw2d_patch_t * patch, +int swirl_intersect_ray (fclaw_domain_t *domain, + fclaw_patch_t * patch, int blockno, int patchno, void *ray, @@ -146,13 +146,13 @@ int swirl_intersect_ray (fclaw2d_domain_t *domain, void* user) { - fclaw2d_global_t *glob = (fclaw2d_global_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) user; /* assert that ray is a valid swirl_ray_t */ - fclaw2d_ray_t *fclaw_ray = (fclaw2d_ray_t *) ray; + fclaw_ray_t *fclaw_ray = (fclaw_ray_t *) ray; int id; - swirl_ray_t *swirl_ray = (swirl_ray_t*) fclaw2d_ray_get_ray(fclaw_ray,&id); + swirl_ray_t *swirl_ray = (swirl_ray_t*) fclaw_ray_get_ray(fclaw_ray,&id); FCLAW_ASSERT(swirl_ray != NULL); FCLAW_ASSERT(swirl_ray->rtype == SWIRL_RAY_LINE); /* Circles not there yet. */ @@ -176,7 +176,7 @@ int swirl_intersect_ray (fclaw2d_domain_t *domain, /* Get data on current patch */ int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); if (swirl_ray->rtype == SWIRL_RAY_LINE) @@ -296,8 +296,8 @@ static int nlines = 3; /* Virtual function for setting rays */ static -void swirl_allocate_and_define_rays(fclaw2d_global_t *glob, - fclaw2d_ray_t** rays, +void swirl_allocate_and_define_rays(fclaw_global_t *glob, + fclaw_ray_t** rays, int* num_rays) { *num_rays = nlines; @@ -307,8 +307,8 @@ void swirl_allocate_and_define_rays(fclaw2d_global_t *glob, below. */ //*rays = (fclaw2d_ray_t*) FCLAW_ALLOC(fclaw2d_ray_t,*num_rays); - *rays = fclaw2d_ray_allocate_rays(*num_rays); - fclaw2d_ray_t *ray_vec = *rays; + *rays = fclaw_ray_allocate_rays(*num_rays); + fclaw_ray_t *ray_vec = *rays; for (int i = 0; i < nlines; ++i) { //fclaw_global_essentialf("ray_initialize : Setting up ray %d : \n",i); @@ -331,37 +331,37 @@ void swirl_allocate_and_define_rays(fclaw2d_global_t *glob, sr->r.line.vec[1] = R*sin ((i+0.5) * dth); #endif - fclaw2d_ray_t *ray = &ray_vec[i]; + fclaw_ray_t *ray = &ray_vec[i]; int id = i + 1; - fclaw2d_ray_set_ray(ray,id, sr); + fclaw_ray_set_ray(ray,id, sr); } } static -void swirl_deallocate_rays(fclaw2d_global_t *glob, - fclaw2d_ray_t** rays, +void swirl_deallocate_rays(fclaw_global_t *glob, + fclaw_ray_t** rays, int* num_rays) { - fclaw2d_ray_t *ray_vec = *rays; + fclaw_ray_t *ray_vec = *rays; for(int i = 0; i < *num_rays; i++) { /* Retrieve rays set above and deallocate them */ int id; - fclaw2d_ray_t *ray = &ray_vec[i]; - swirl_ray_t *rs = (swirl_ray_t*) fclaw2d_ray_get_ray(ray,&id); + fclaw_ray_t *ray = &ray_vec[i]; + swirl_ray_t *rs = (swirl_ray_t*) fclaw_ray_get_ray(ray,&id); FCLAW_ASSERT(rs != NULL); FCLAW_FREE(rs); rs = NULL; } /* Match FCLAW_ALLOC, above */ - *num_rays = fclaw2d_ray_deallocate_rays(rays); + *num_rays = fclaw_ray_deallocate_rays(rays); } -void swirl_initialize_rays(fclaw2d_global_t* glob) +void swirl_initialize_rays(fclaw_global_t* glob) { /* Set up rays */ - fclaw2d_ray_vtable_t* rays_vt = fclaw2d_ray_vt(glob); + fclaw_ray_vtable_t* rays_vt = fclaw_ray_vt(glob); rays_vt->allocate_and_define = swirl_allocate_and_define_rays; rays_vt->deallocate = swirl_deallocate_rays; diff --git a/applications/clawpack/advection/2d/swirl/swirl_user.cpp b/applications/clawpack/advection/2d/swirl/swirl_user.cpp index 8f2377e3a..e0379f623 100644 --- a/applications/clawpack/advection/2d/swirl/swirl_user.cpp +++ b/applications/clawpack/advection/2d/swirl/swirl_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "swirl_user.h" static -void swirl_problem_setup(fclaw2d_global_t* glob) +void swirl_problem_setup(fclaw_global_t* glob) { const user_options_t* user = swirl_get_options(glob); @@ -38,14 +38,14 @@ void swirl_problem_setup(fclaw2d_global_t* glob) } /* Make sure node 0 has written 'setprob.data' before proceeding */ - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } -void swirl_link_solvers(fclaw2d_global_t *glob) +void swirl_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &swirl_problem_setup; /* Version-independent */ swirl_initialize_rays(glob); diff --git a/applications/clawpack/advection/2d/swirl/swirl_user.h b/applications/clawpack/advection/2d/swirl/swirl_user.h index e8828d5a5..79551fbaa 100644 --- a/applications/clawpack/advection/2d/swirl/swirl_user.h +++ b/applications/clawpack/advection/2d/swirl/swirl_user.h @@ -45,15 +45,15 @@ typedef struct user_options } user_options_t; -void swirl_link_solvers(fclaw2d_global_t *glob); +void swirl_link_solvers(fclaw_global_t *glob); /* ------------------------------------- Options ---------------------------------------*/ user_options_t* swirl_options_register (fclaw_app_t * app, const char *configfile); -void swirl_options_store (fclaw2d_global_t* glob, user_options_t* user); +void swirl_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* swirl_get_options(fclaw2d_global_t* glob); +const user_options_t* swirl_get_options(fclaw_global_t* glob); /* ------------------------------------- Rays ---------------------------------------*/ @@ -82,8 +82,8 @@ typedef struct swirl_ray } swirl_ray_t; #endif -int swirl_intersect_ray(fclaw2d_domain_t *domain, - fclaw2d_patch_t * patch, +int swirl_intersect_ray(fclaw_domain_t *domain, + fclaw_patch_t * patch, int blockno, int patchno, void *ray, @@ -98,7 +98,7 @@ void swirl_define_ray(fclaw2d_global_t *glob, void swirl_destroy_ray(fclaw2d_global_t *glob,void* ray); #endif -void swirl_initialize_rays(fclaw2d_global_t* glob); +void swirl_initialize_rays(fclaw_global_t* glob); sc_array_t * swirl_integrals_new(void); diff --git a/applications/clawpack/advection/2d/swirl_rays/swirl.cpp b/applications/clawpack/advection/2d/swirl_rays/swirl.cpp index 37445d7bb..ea6792c52 100644 --- a/applications/clawpack/advection/2d/swirl_rays/swirl.cpp +++ b/applications/clawpack/advection/2d/swirl_rays/swirl.cpp @@ -24,7 +24,7 @@ */ #include "swirl_user.h" -#include +#include #include "../all/advection_user.h" @@ -77,8 +77,8 @@ const int swirl_nlines = 3; /* Virtual function for setting rays */ static void -swirl_allocate_and_define_rays (fclaw2d_global_t * glob, - fclaw2d_ray_t ** rays, int *num_rays) +swirl_allocate_and_define_rays (fclaw_global_t * glob, + fclaw_ray_t ** rays, int *num_rays) { int i; @@ -88,8 +88,8 @@ swirl_allocate_and_define_rays (fclaw2d_global_t * glob, generic ray type is left opaque. This is destroy in matching FREE, below. */ - *rays = fclaw2d_ray_allocate_rays(*num_rays); - fclaw2d_ray_t *ray_vec = *rays; + *rays = fclaw_ray_allocate_rays(*num_rays); + fclaw_ray_t *ray_vec = *rays; for (i = 0; i < swirl_nlines; ++i) { #ifndef STAR_OF_RAYS @@ -131,31 +131,31 @@ swirl_allocate_and_define_rays (fclaw2d_global_t * glob, sr->r.line.parallel == sr->r.line.dominant); /* Assign ray to diagnostics item */ - fclaw2d_ray_t *ray = &ray_vec[i]; - fclaw2d_ray_set_ray (ray, i + 1, sr); + fclaw_ray_t *ray = &ray_vec[i]; + fclaw_ray_set_ray (ray, i + 1, sr); } } static -void swirl_deallocate_rays(fclaw2d_global_t *glob, - fclaw2d_ray_t** rays, +void swirl_deallocate_rays(fclaw_global_t *glob, + fclaw_ray_t** rays, int* num_rays) { int i; - fclaw2d_ray_t *ray_vec = *rays; + fclaw_ray_t *ray_vec = *rays; for(i = 0; i < *num_rays; i++) { /* Retrieve rays set above and deallocate them */ int id; - fclaw2d_ray_t *ray = &ray_vec[i]; - swirl_ray_t *rs = (swirl_ray_t*) fclaw2d_ray_get_ray(ray, &id); + fclaw_ray_t *ray = &ray_vec[i]; + swirl_ray_t *rs = (swirl_ray_t*) fclaw_ray_get_ray(ray, &id); FCLAW_ASSERT (rs != NULL); FCLAW_FREE (rs); rs = NULL; } /* Match FCLAW_ALLOC, above */ - *num_rays = fclaw2d_ray_deallocate_rays(rays); + *num_rays = fclaw_ray_deallocate_rays(rays); } /** This function checks if a linear ray intersects a patch. @@ -166,7 +166,7 @@ void swirl_deallocate_rays(fclaw2d_global_t *glob, * the patch-boundary in the search dimension i. */ static int -intersect_patch (fclaw2d_patch_t *patch, swirl_ray_t *swirl_ray, +intersect_patch (fclaw_patch_t *patch, swirl_ray_t *swirl_ray, int i, int *untrustworthy, double *dt, double rayni[2]) { int ni, j, isleft, iscenter; @@ -233,7 +233,7 @@ intersect_patch (fclaw2d_patch_t *patch, swirl_ray_t *swirl_ray, } static int -swirl_intersect_ray (fclaw2d_domain_t *domain, fclaw2d_patch_t *patch, +swirl_intersect_ray (fclaw_domain_t *domain, fclaw_patch_t *patch, int blockno, int patchno, void *ray, double *integral, void *user) { @@ -241,9 +241,9 @@ swirl_intersect_ray (fclaw2d_domain_t *domain, fclaw2d_patch_t *patch, double dt, rayni[2]; /* assert that ray is a valid swirl_ray_t */ - fclaw2d_ray_t *fclaw_ray = (fclaw2d_ray_t *) ray; + fclaw_ray_t *fclaw_ray = (fclaw_ray_t *) ray; - swirl_ray_t *swirl_ray = (swirl_ray_t*) fclaw2d_ray_get_ray(fclaw_ray,&id); + swirl_ray_t *swirl_ray = (swirl_ray_t*) fclaw_ray_get_ray(fclaw_ray,&id); FCLAW_ASSERT(swirl_ray != NULL); FCLAW_ASSERT(swirl_ray->rtype == SWIRL_RAY_LINE); /* Circles not there yet. */ FCLAW_ASSERT (integral != NULL && *integral == 0.); /* documented precondition */ @@ -277,13 +277,13 @@ swirl_intersect_ray (fclaw2d_domain_t *domain, fclaw2d_patch_t *patch, int mx, my, mbc, meqn, sol_rows, j, k, klower, kupper, k_current; double xlower, ylower, dx, dy, *sol, tstep, nilower, niupper, raynilower, rayniupper; - fclaw2d_global_t *glob = (fclaw2d_global_t *) user; + fclaw_global_t *glob = (fclaw_global_t *) user; FCLAW_ASSERT(glob != NULL); /* Obtain cell indices of the hits. */ - fclaw2d_clawpatch_grid_data(glob, patch, &mx, &my, &mbc, + fclaw_clawpatch_2d_grid_data(glob, patch, &mx, &my, &mbc, &xlower, &ylower, &dx, &dy); - fclaw2d_clawpatch_soln_data(glob, patch, &sol, &meqn); + fclaw_clawpatch_soln_data(glob, patch, &sol, &meqn); sol_rows = mx + 2 * mbc; /* Make mx, my, dx, dy indexable. */ @@ -361,10 +361,10 @@ swirl_intersect_ray (fclaw2d_domain_t *domain, fclaw2d_patch_t *patch, } } -void swirl_initialize_rays(fclaw2d_global_t* glob) +void swirl_initialize_rays(fclaw_global_t* glob) { /* Set up rays */ - fclaw2d_ray_vtable_t* rays_vt = fclaw2d_ray_vt(glob); + fclaw_ray_vtable_t* rays_vt = fclaw_ray_vt(glob); rays_vt->allocate_and_define = swirl_allocate_and_define_rays; rays_vt->deallocate = swirl_deallocate_rays; @@ -373,37 +373,32 @@ void swirl_initialize_rays(fclaw2d_global_t* glob) } static -void create_domain(fclaw2d_global_t * glob) +void create_domain(fclaw_global_t * glob) { - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); fclaw_opt->manifold = 0; - fclaw2d_domain_t *domain = fclaw2d_domain_new_unitsquare(glob->mpicomm, + fclaw_domain_t *domain = fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t *cont = fclaw_map_new_nomap(); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { const user_options_t *user_opt; - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - user_opt = swirl_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -421,10 +416,10 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); + fclaw_initialize(glob); + fclaw_run(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -436,14 +431,14 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = swirl_options_register(app, "fclaw_options.ini"); @@ -461,11 +456,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); swirl_options_store (glob, user_opt); @@ -474,7 +469,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/swirl_rays/swirl_options.c b/applications/clawpack/advection/2d/swirl_rays/swirl_options.c index 913255d43..e8e3e91a6 100644 --- a/applications/clawpack/advection/2d/swirl_rays/swirl_options.c +++ b/applications/clawpack/advection/2d/swirl_rays/swirl_options.c @@ -150,12 +150,12 @@ user_options_t* swirl_options_register (fclaw_app_t * app, return user; } -void swirl_options_store (fclaw2d_global_t* glob, user_options_t* user) +void swirl_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* swirl_get_options(fclaw2d_global_t* glob) +const user_options_t* swirl_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/swirl_rays/swirl_user.cpp b/applications/clawpack/advection/2d/swirl_rays/swirl_user.cpp index 6c75fbe17..6bb670ffb 100644 --- a/applications/clawpack/advection/2d/swirl_rays/swirl_user.cpp +++ b/applications/clawpack/advection/2d/swirl_rays/swirl_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "swirl_user.h" static -void swirl_problem_setup(fclaw2d_global_t* glob) +void swirl_problem_setup(fclaw_global_t* glob) { const user_options_t* user = swirl_get_options(glob); @@ -38,15 +38,15 @@ void swirl_problem_setup(fclaw2d_global_t* glob) } /* Make sure node 0 has written 'setprob.data' before proceeding */ - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } -void swirl_link_solvers(fclaw2d_global_t *glob) +void swirl_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &swirl_problem_setup; /* Version-independent */ const user_options_t* user = swirl_get_options(glob); diff --git a/applications/clawpack/advection/2d/swirl_rays/swirl_user.h b/applications/clawpack/advection/2d/swirl_rays/swirl_user.h index cd5301dd7..7af338a90 100644 --- a/applications/clawpack/advection/2d/swirl_rays/swirl_user.h +++ b/applications/clawpack/advection/2d/swirl_rays/swirl_user.h @@ -44,15 +44,15 @@ typedef struct user_options } user_options_t; -void swirl_link_solvers(fclaw2d_global_t *glob); +void swirl_link_solvers(fclaw_global_t *glob); /* ------------------------------------- Options ---------------------------------------*/ user_options_t* swirl_options_register (fclaw_app_t * app, const char *configfile); -void swirl_options_store (fclaw2d_global_t* glob, user_options_t* user); +void swirl_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* swirl_get_options(fclaw2d_global_t* glob); +const user_options_t* swirl_get_options(fclaw_global_t* glob); #ifdef __cplusplus #if 0 diff --git a/applications/clawpack/advection/2d/torthem/torthem.c b/applications/clawpack/advection/2d/torthem/torthem.c index 56877df2b..af660269c 100644 --- a/applications/clawpack/advection/2d/torthem/torthem.c +++ b/applications/clawpack/advection/2d/torthem/torthem.c @@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include /******************************************************************* @@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. typedef struct torthem { - fclaw2d_global_t *global; + fclaw_global_t *global; #if 0 fc2d_clawpack46_options_t claw_opt; @@ -71,7 +71,7 @@ torthem_init (torthem_t * torthem) memset (torthem, 0, sizeof (*torthem)); #if 1 - torthem->global = fclaw2d_global_new (); + torthem->global = fclaw_global_new (); #endif #if 0 @@ -171,8 +171,8 @@ torthem_destroy (torthem_t * torthem) fclaw_options_destroy (&torthem->fclaw_opt); #if 1 - fclaw2d_finalize (torthem->global); - fclaw2d_global_destroy (torthem->global); + fclaw_finalize (torthem->global); + fclaw_global_destroy (torthem->global); #endif } diff --git a/applications/clawpack/advection/2d/torthem/torus_common.h b/applications/clawpack/advection/2d/torthem/torus_common.h index 466906906..8e62befe1 100644 --- a/applications/clawpack/advection/2d/torthem/torus_common.h +++ b/applications/clawpack/advection/2d/torthem/torus_common.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef TORUS_COMMON_H #define TORUS_COMMON_H -#include +#include #ifdef __cplusplus extern "C" diff --git a/applications/clawpack/advection/2d/torus/fdisc.f b/applications/clawpack/advection/2d/torus/fdisc.f index 4c3d24ee1..8043929ed 100644 --- a/applications/clawpack/advection/2d/torus/fdisc.f +++ b/applications/clawpack/advection/2d/torus/fdisc.f @@ -14,7 +14,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) thc = pi/2.0 diff --git a/applications/clawpack/advection/2d/torus/torus.cpp b/applications/clawpack/advection/2d/torus/torus.cpp index a5dba0537..ce3e2e994 100644 --- a/applications/clawpack/advection/2d/torus/torus.cpp +++ b/applications/clawpack/advection/2d/torus/torus.cpp @@ -26,12 +26,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "torus_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* --------------------------------------------------------------- Mapping geometry --------------------------------------------------------------- */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -46,17 +46,17 @@ void create_domain(fclaw2d_global_t *glob) rotate[1] = pi*fclaw_opt->phi/180.0; /* Torus : Mapped, multi-block domain */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_t *domain = + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Create a mapping context (torus based on a brick) */ const user_options_t *user = (user_options_t*) torus_get_options(glob); - fclaw2d_map_context_t *brick = - fclaw2d_map_new_brick(domain, mi, mj, a, b); + fclaw_map_context_t *brick = + fclaw_map_new_2d_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = + fclaw_map_context_t *cont = fclaw2d_map_new_torus(brick, fclaw_opt->scale, rotate, @@ -64,28 +64,23 @@ void create_domain(fclaw2d_global_t *glob) user->beta); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user = torus_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user->claw_version == 4) @@ -102,9 +97,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -116,13 +111,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user = torus_options_register(app, "fclaw_options.ini"); @@ -137,11 +132,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); torus_options_store (glob, user); @@ -152,7 +147,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/2d/torus/torus_options.c b/applications/clawpack/advection/2d/torus/torus_options.c index 6c19622f3..e28225c66 100644 --- a/applications/clawpack/advection/2d/torus/torus_options.c +++ b/applications/clawpack/advection/2d/torus/torus_options.c @@ -169,13 +169,13 @@ user_options_t* torus_options_register (fclaw_app_t * app, return user_opt; } -void torus_options_store (fclaw2d_global_t* glob, user_options_t* user) +void torus_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* torus_get_options(fclaw2d_global_t* glob) +const user_options_t* torus_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/2d/torus/torus_user.cpp b/applications/clawpack/advection/2d/torus/torus_user.cpp index 2bb2b8e3d..469ea0f84 100644 --- a/applications/clawpack/advection/2d/torus/torus_user.cpp +++ b/applications/clawpack/advection/2d/torus/torus_user.cpp @@ -28,7 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../all/advection_user.h" static -void torus_problem_setup(fclaw2d_global_t *glob) +void torus_problem_setup(fclaw_global_t *glob) { const user_options_t* user = torus_get_options(glob); @@ -42,14 +42,14 @@ void torus_problem_setup(fclaw2d_global_t *glob) fclose(f); } /* Make sure node 0 writes `setprob.data` before proceeding */ - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } static -void torus_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void torus_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -67,15 +67,15 @@ void torus_patch_setup(fclaw2d_global_t *glob, } -void torus_link_solvers(fclaw2d_global_t *glob) +void torus_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &torus_problem_setup; /* Version-independent */ /* Torus uses special patch setup (not advection_patch_setup), since the streamfunction depends on computational coordinates, not physical coordinates */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &torus_patch_setup; const user_options_t *user = torus_get_options(glob); diff --git a/applications/clawpack/advection/2d/torus/torus_user.h b/applications/clawpack/advection/2d/torus/torus_user.h index 70794f915..32f315863 100644 --- a/applications/clawpack/advection/2d/torus/torus_user.h +++ b/applications/clawpack/advection/2d/torus/torus_user.h @@ -53,14 +53,14 @@ typedef struct user_options } user_options_t; -void torus_link_solvers(fclaw2d_global_t *glob); +void torus_link_solvers(fclaw_global_t *glob); user_options_t* torus_options_register (fclaw_app_t * app, const char *configfile); -void torus_options_store (fclaw2d_global_t* glob, user_options_t* user); +void torus_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* torus_get_options(fclaw2d_global_t* glob); +const user_options_t* torus_get_options(fclaw_global_t* glob); /* Torus needs special setaux, since streamfunction psi is defined in terms of diff --git a/applications/clawpack/advection/2d/torus/user_4.6/torus46_setaux.f b/applications/clawpack/advection/2d/torus/user_4.6/torus46_setaux.f index 2443748c4..7da3bdab6 100644 --- a/applications/clawpack/advection/2d/torus/user_4.6/torus46_setaux.f +++ b/applications/clawpack/advection/2d/torus/user_4.6/torus46_setaux.f @@ -44,14 +44,14 @@ subroutine torus46_set_edge_velocities(mx,my,mbc, yc = ylower + j*dy c # Map the brick to a unit square - call fclaw2d_map_brick2c(cont, blockno,xc,yc,xc1,yc1,zc1) + call fclaw_map_2d_brick2c(cont, blockno,xc,yc,xc1,yc1,zc1) c # x-face - lower vertex xc = xlower + (i-1)*dx yc = ylower + (j-1)*dy c # Map the brick to a unit square - call fclaw2d_map_brick2c(cont, blockno,xc,yc,xc2,yc2,zc2) + call fclaw_map_2d_brick2c(cont, blockno,xc,yc,xc2,yc2,zc2) call torus_edge_velocity(xc1,yc1,xc2,yc2,dy,vn) aux(i,j,2) = vn @@ -66,12 +66,12 @@ subroutine torus46_set_edge_velocities(mx,my,mbc, c # y-face - right vertex xc = xlower + i*dx yc = ylower + (j-1)*dy - call fclaw2d_map_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) + call fclaw_map_2d_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) c # y-face - left vertex xc = xlower + (i-1)*dx yc = ylower + (j-1)*dy - call fclaw2d_map_brick2c(cont,blockno,xc,yc,xc2,yc2,zc2) + call fclaw_map_2d_brick2c(cont,blockno,xc,yc,xc2,yc2,zc2) call torus_edge_velocity(xc1,yc1,xc2,yc2,dx,vn) aux(i,j,3) = -vn diff --git a/applications/clawpack/advection/2d/torus/user_5.0/torus5_setaux.f90 b/applications/clawpack/advection/2d/torus/user_5.0/torus5_setaux.f90 index ec7edee16..153ef88ea 100644 --- a/applications/clawpack/advection/2d/torus/user_5.0/torus5_setaux.f90 +++ b/applications/clawpack/advection/2d/torus/user_5.0/torus5_setaux.f90 @@ -56,14 +56,14 @@ subroutine torus5_set_edge_velocities(mx,my,mbc, & yc = ylower + j*dy !! # Map the brick to a unit square - call fclaw2d_map_brick2c(cont, blockno,xc,yc,xc1,yc1,zc1) + call fclaw_map_2d_brick2c(cont, blockno,xc,yc,xc1,yc1,zc1) !! # x-face - lower vertex xc = xlower + (i-1)*dx yc = ylower + (j-1)*dy !! # Map the brick to a unit square - call fclaw2d_map_brick2c(cont, blockno,xc,yc,xc2,yc2,zc2) + call fclaw_map_2d_brick2c(cont, blockno,xc,yc,xc2,yc2,zc2) call torus_edge_velocity(xc1,yc1,xc2,yc2,dy,vn) aux(2,i,j) = vn @@ -78,12 +78,12 @@ subroutine torus5_set_edge_velocities(mx,my,mbc, & !! # y-face - right vertex xc = xlower + i*dx yc = ylower + (j-1)*dy - call fclaw2d_map_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) + call fclaw_map_2d_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) !! # y-face - left vertex xc = xlower + (i-1)*dx yc = ylower + (j-1)*dy - call fclaw2d_map_brick2c(cont,blockno,xc,yc,xc2,yc2,zc2) + call fclaw_map_2d_brick2c(cont,blockno,xc,yc,xc2,yc2,zc2) call torus_edge_velocity(xc1,yc1,xc2,yc2,dx,vn) aux(3,i,j) = -vn diff --git a/applications/clawpack/advection/3d/all/advection_patch_setup_manifold.c b/applications/clawpack/advection/3d/all/advection_patch_setup_manifold.c new file mode 100644 index 000000000..664b8edbc --- /dev/null +++ b/applications/clawpack/advection/3d/all/advection_patch_setup_manifold.c @@ -0,0 +1,65 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "advection_user.h" + +void claw3_advection_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, + int blockno, + int patchno, + int claw_version) +{ + int mx,my,mz, mbc; + double xlower,ylower,zlower, dx,dy, dz; + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, &mbc, + &xlower,&ylower,&zlower, &dx,&dy, &dz); + + double *xd,*yd,*zd,*volume,*faceareas; + double *xp,*yp,*zp; + fclaw_clawpatch_3d_mesh_data(glob,patch,&xp,&yp,&zp, + &xd,&yd,&zd,&volume,&faceareas); + + int maux; + double *aux; + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); + + if (claw_version == 4) + CLAW3_SETAUX_MANIFOLD(&mbc,&mx,&my,&mz, &xlower,&ylower,&zlower, + &dx,&dy,&dz,&maux,aux,&blockno, + xd,yd,zd,xp,yp,zp,volume,faceareas); + + else if (claw_version == 5) + fclaw_global_essentialf("claw3_patch_setup_manifold : claw 5 not implemented.\n"); +#if 0 + USER5_SETAUX_MANIFOLD(&mbc,&mx,&my,&xlower,&ylower, + &dx,&dy,&maux,aux,&blockno, + xd,yd,zd,area); +#endif +} + + + + + diff --git a/applications/clawpack/advection/p8/all/advection_user.h b/applications/clawpack/advection/3d/all/advection_user.h similarity index 80% rename from applications/clawpack/advection/p8/all/advection_user.h rename to applications/clawpack/advection/3d/all/advection_user.h index 004a6d805..554da6cde 100644 --- a/applications/clawpack/advection/p8/all/advection_user.h +++ b/applications/clawpack/advection/3d/all/advection_user.h @@ -23,19 +23,18 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ADVECTION_USER_P8_H -#define ADVECTION_USER_P8_H +#ifndef ADVECTION_USER_3D_H +#define ADVECTION_USER_3D_H -#include +#include -#ifdef P8HACK -#include +#include /* Headers for both Clawpack 4.6 and Clawpack 5.0 */ -#include -#include -#include +#include +#include +#include /* Clawpack 4.6 headers */ @@ -43,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include +#include #if 0 /* Clawpack 5.0 headers */ @@ -58,8 +57,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Headers for common FORTRAN files */ #include "advection_user_fort3.h" -#endif /* P8HACK */ - #ifdef __cplusplus extern "C" { @@ -69,18 +66,14 @@ extern "C" /* Fix syntax */ #endif -#ifdef P8HACK - -void claw3_advection_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void claw3_advection_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int block, int patchno, int claw_version); -#endif - #ifdef __cplusplus } #endif -#endif /* !ADVECTION_USER_P8_H */ +#endif /* !ADVECTION_USER_3D_H */ diff --git a/applications/clawpack/advection/3d/all/advection_user_fort3.h b/applications/clawpack/advection/3d/all/advection_user_fort3.h new file mode 100644 index 000000000..ad1872414 --- /dev/null +++ b/applications/clawpack/advection/3d/all/advection_user_fort3.h @@ -0,0 +1,181 @@ +/* +Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef ADVECTION_USER_FORT_H +#define ADVECTION_USER_FORT_H + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} +#endif +#endif + +#define CLAWPACK46_RPN2ADV FCLAW_F77_FUNC(clawpack46_rpn2adv,CLAWPACK46_RPN2ADV) +void CLAWPACK46_RPN2ADV(const int* ixy,const int* maxm, const int* meqn, + const int* mwaves, + const int* mbc,const int* mx, + double ql[], double qr[], + double auxl[], double auxr[], + double wave[], + double s[], double amdq[], double apdq[]); + +#define CLAWPACK46_RPT2ADV FCLAW_F77_FUNC(clawpack46_rpt2adv, CLAWPACK46_RPT2ADV) +void CLAWPACK46_RPT2ADV(const int* ixy, const int* maxm, const int* meqn, + const int* mwaves, + const int* mbc, const int* mx, + double ql[], double qr[], + double aux1[], double aux2[], + double aux3[], const int* imp, + double dsdq[], double bmasdq[], double bpasdq[]); + + +#define CLAWPACK46_RPN2ADV_MANIFOLD FCLAW_F77_FUNC(clawpack46_rpn2adv_manifold, \ + CLAWPACK46_RPN2ADV_MANIFOLD) +void CLAWPACK46_RPN2ADV_MANIFOLD(const int* ixy,const int* maxm, const int* meqn, + const int* mwaves, + const int* mbc,const int* mx, + double ql[], double qr[], + double auxl[], double auxr[], double wave[], + double s[], double amdq[], double apdq[]); + +#define CLAWPACK46_RPT2ADV_MANIFOLD FCLAW_F77_FUNC(clawpack46_rpt2adv_manifold, \ + CLAWPACK46_RPT2ADV_MANIFOLD) +void CLAWPACK46_RPT2ADV_MANIFOLD(const int* ixy, const int* maxm, const int* meqn, + const int* mwaves, + const int* mbc, const int* mx, + double ql[], double qr[], + double aux1[], double aux2[], double aux3[], + const int* imp, + double dsdq[], double bmasdq[], double bpasdq[]); + + +#define CLAWPACK5_RPN2ADV FCLAW_F77_FUNC(clawpack5_rpn2adv,CLAWPACK5_RPN2ADV) +void CLAWPACK5_RPN2ADV(const int* ixy,const int* maxm, const int* meqn, + const int* mwaves, const int* maux, + const int* mbc,const int* mx, + double ql[], double qr[], double auxl[], double auxr[], + double wave[], double s[],double amdq[], double apdq[]); + +#define CLAWPACK5_RPT2ADV FCLAW_F77_FUNC(clawpack5_rpt2adv, CLAWPACK5_RPT2ADV) +void CLAWPACK5_RPT2ADV(const int* ixy, const int* imp, + const int* maxm, const int* meqn, + const int* mwaves, const int* maux, + const int* mbc,const int* mx, + double ql[], double qr[], + double aux1[], double aux2[], + double aux3[], double asdq[], + double bmasdq[], double bpasdq[]); + +#define CLAWPACK5_RPN2ADV_MANIFOLD FCLAW_F77_FUNC(clawpack5_rpn2adv_manifold, \ + CLAWPACK5_RPN2ADV_MANIFOLD) +void CLAWPACK5_RPN2ADV_MANIFOLD(const int* ixy,const int* maxm, const int* meqn, + const int* mwaves, const int* maux, + const int* mbc,const int* mx, + double ql[], double qr[], + double auxl[], double auxr[], + double wave[], double s[], + double amdq[], double apdq[]); + +#define CLAWPACK5_RPT2ADV_MANIFOLD FCLAW_F77_FUNC(clawpack5_rpt2adv_manifold, \ + CLAWPACK5_RPT2ADV_MANIFOLD) +void CLAWPACK5_RPT2ADV_MANIFOLD(const int* ixy, const int* imp, + const int* maxm, const int* meqn, + const int* mwaves, const int* maux, + const int* mbc,const int* mx, + double ql[], double qr[], + double aux1[], double aux2[], + double aux3[], double asdq[], + double bmasdq[], double bpasdq[]); + +#define CLAW3_SETAUX_MANIFOLD FCLAW_F77_FUNC(claw3_setaux_manifold, \ + CLAW3_SETAUX_MANIFOLD) + +void CLAW3_SETAUX_MANIFOLD(const int* mbc, + const int* mx, const int* my, const int*mz, + const double* xlower, const double* ylower, + const double* zlower, + const double* dx, const double* dy, + const double *dz, + const int* maux, double aux[], + const int* blockno, + double xd[], double yd[], double zd[], + double xp[], double yp[], double zp[], + double volume[],double faceareas[]); + + +#define USER5_SETAUX_MANIFOLD FCLAW_F77_FUNC(user5_setaux_manifold, \ + USER5_SETAUX_MANIFOLD) + +void USER5_SETAUX_MANIFOLD(const int* mbc, + const int* mx, const int* my, + const double* xlower, const double* ylower, + const double* dx, const double* dy, + const int* maux, double aux[], + const int* blockno, + double xd[], double yd[], double zd[], + double area[]); + + +#define USER46_B4STEP2_MANIFOLD FCLAW_F77_FUNC(user46_b4step2_manifold,USER46_B4STEP2_MANIFOLD) +void USER46_B4STEP2_MANIFOLD(const int* mx, const int* my, const int* mbc, + const double* dx, const double* dy, + const double* t, const int* maux, double aux[], + const int* blockno, + double xd[], double yd[], double zd[]); + +#define USER5_B4STEP2_MANIFOLD FCLAW_F77_FUNC(user5_b4step2_manifold,USER5_B4STEP2_MANIFOLD) +void USER5_B4STEP2_MANIFOLD(const int* mx, const int* my, const int* mbc, + const double* dx, const double* dy, + const double* t, const int* maux, double aux[], + const int* blockno, + double xd[], double yd[], double zd[]); + +#define USER_EXCEEDS_THRESHOLD FCLAW_F77_FUNC(user_exceeds_threshold, \ + USER_EXCEEDS_THRESHOLD) + +int USER_EXCEEDS_THRESHOLD(const int* blockno, + const double qval[], + const double* qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *xc, + const double *yc, + const double* tag_threshold, + const int* init_flag, + const int* is_ghost); + + +#ifdef __cplusplus +#if 0 +{ +#endif +} +#endif + +#endif diff --git a/applications/clawpack/advection/3d/all/claw3_setaux_manifold.f90 b/applications/clawpack/advection/3d/all/claw3_setaux_manifold.f90 new file mode 100644 index 000000000..93663a9a2 --- /dev/null +++ b/applications/clawpack/advection/3d/all/claw3_setaux_manifold.f90 @@ -0,0 +1,231 @@ +subroutine claw3_setaux_manifold(mbc,mx,my,mz, & + xlower,ylower,zlower,dx,dy,dz,maux, & + aux,blockno, xd,yd,zd,xp, yp, zp, volume, & + faceareas) + implicit none + + integer mbc, mx, my, mz, maux + integer blockno + double precision dx,dy, dz, xlower, ylower, zlower + double precision aux(1-mbc:mx+mbc,1-mbc:my+mbc, 1-mbc:mz+mbc,maux) + + double precision xd(-mbc:mx+mbc+2,-mbc:my+mbc+2, -mbc:mx+mbc+2) + double precision yd(-mbc:mx+mbc+2,-mbc:my+mbc+2, -mbc:my+mbc+2) + double precision zd(-mbc:mx+mbc+2,-mbc:my+mbc+2, -mbc:mz+mbc+2) + + double precision xp(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + double precision yp(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + double precision zp(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + + double precision volume(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc) + double precision faceareas(-mbc:mx+mbc+1,-mbc:my+mbc+1, -mbc:mz+mbc+2,3) + + integer i,j, k + double precision dxdydz, t + + dxdydz = dx*dy*dz + + do i = 1-mbc,mx+mbc + do j = 1-mbc,my+mbc + do k = 1-mbc,mz+mbc + aux(i,j,k,1) = volume(i,j,k)/dxdydz + end do + end do + end do + + t = 0 + call claw3_set_velocity_manifold(mx,my,mz,mbc, & + dx,dy,dz,t,blockno,xd,yd,zd,xp, yp, zp, aux,maux, & + faceareas) + + return +end subroutine claw3_setaux_manifold + + +!! This routine relies on a streamfunction and so +!! assumes that the velocity does not vary in z +subroutine claw3_set_velocity_manifold(mx,my,mz,mbc, & + dx,dy,dz,t,blockno,xd,yd,zd,xp, yp, zp, aux,maux, & + faceareas) + implicit none + + integer mx,my,mz,mbc,maux, blockno + double precision dx,dy,dz,t + + double precision xd(-mbc:mx+mbc+2,-mbc:my+mbc+2, -mbc:mz+mbc+2) + double precision yd(-mbc:mx+mbc+2,-mbc:my+mbc+2, -mbc:mz+mbc+2) + double precision zd(-mbc:mx+mbc+2,-mbc:my+mbc+2, -mbc:mz+mbc+2) + + double precision xp(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + double precision yp(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + double precision zp(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + + double precision aux(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,maux) + double precision faceareas(-mbc:mx+mbc+1,-mbc:my+mbc+1, -mbc:mz+mbc+2,3) + + double precision,dimension(0:1,0:1) :: xd1,yd1,zd1 + + integer i,j, k,ii, jj,kk + double precision vn, g + logical ispillowsphere + + do k = 1-mbc,mz+mbc + do i = 1-mbc,mx+mbc + do j = 1-mbc,my+mbc + !! # Velocity at center of x-face + !! # although z values are at bottom of cell + do jj = 0,1 + do kk = 0,1 + xd1(jj,kk) = xd(i,j+jj,k+kk) + yd1(jj,kk) = yd(i,j+jj,k+kk) + zd1(jj,kk) = zd(i,j+jj,k+kk) + end do + end do + + call get_psi_vel(xd1,yd1,zd1,vn,t) + + !! Scale by gamma : facearea/(dy*dz) + g = faceareas(i,j,k,1)/(dy*dz) + !! g = 1.0/dz + vn = g*vn + + if (ispillowsphere()) then + if (blockno == 1) then + vn = -vn + endif + endif + aux(i,j,k,2) = vn + end do + end do + end do + + do k = 1-mbc,mz+mbc + do j = 1-mbc,my+mbc + do i = 1-mbc,mx+mbc + !!# y-faces + do ii = 0,1 + do kk = 0,1 + xd1(ii,kk) = xd(i+ii,j,k+kk) + yd1(ii,kk) = yd(i+ii,j,k+kk) + zd1(ii,kk) = zd(i+ii,j,k+kk) + end do + end do + + call get_psi_vel(xd1,yd1,zd1,vn,t) + + !! Scale by gamma : facearea/(dx*dz) + g = faceareas(i,j,k,2)/(dx*dz) + !! g = 1.d0/dz + + vn = g*vn + + if (ispillowsphere()) then + if (blockno == 1) then + vn = -vn + endif + endif + + aux(i,j,k,3) = -vn + end do + end do + end do + + + !! Assume zero velocity in z direction + do j = 1-mbc,my+mbc + do i = 1-mbc,mx+mbc + do k = 1-mbc,mz+mbc + aux(i,j,k,4) = 0 + end do + end do + end do + +end subroutine claw3_set_velocity_manifold + + +!! This takes a 2d psi and averages it in z to get +!! velocity field for the 3d extruded mesh. +subroutine get_psi_vel(xd1,yd1,zd1,vn,t) + implicit none + + double precision, dimension(0:1,0:1) :: xd1,yd1,zd1 + double precision vn,t + + double precision, dimension(0:1,0:1) :: xd1_com,yd1_com,zd1_com + double precision t_com + common /com_psi/ xd1_com, yd1_com, zd1_com, t_com + + double precision psi_integrate, p1, p2, p3 + + xd1_com = xd1 + yd1_com = yd1 + zd1_com = zd1 + t_com = t + + !! Quadrature points : ri = (0, 0.5, 1.0) in [0,1] + p1 = psi_integrate(0.d0) + p2 = psi_integrate(0.5d0) + p3 = psi_integrate(1.d0) + + !! Use Simpson's rule to integrate in r over [0,1] + !! Weights are dr/6, 4*dr/6, dr/6, with dr=1 + vn = (p1 + 4*p2 + p3)/6.0 + +end subroutine get_psi_vel + + +double precision function psi_integrate(r) + + implicit none + double precision r + + double precision, dimension(0:1,0:1) :: xd1,yd1,zd1 + double precision t + common /com_psi/ xd1, yd1, zd1,t + + double precision x0_low, x0_hi, x1_low, x1_hi + double precision y0_low, y0_hi, y1_low, y1_hi + double precision z0_low, z0_hi, z1_low, z1_hi + double precision x0, x1, y0, y1, z0, z1 + double precision psi, u, d + + x0_low = xd1(0,0) + x0_hi = xd1(0,1) + + x1_low = xd1(1,0) + x1_hi = xd1(1,1) + + y0_low = yd1(0,0) + y0_hi = yd1(0,1) + + y1_low = yd1(1,0) + y1_hi = yd1(1,1) + + z0_low = zd1(0,0) + z0_hi = zd1(0,1) + + z1_low = zd1(1,0) + z1_hi = zd1(1,1) + + !! Integrating with respect to r \in [0,1] + x0 = x0_low + r*(x0_hi - x0_low) + x1 = x1_low + r*(x1_hi - x1_low) + y0 = y0_low + r*(y0_hi - y0_low) + y1 = y1_low + r*(y1_hi - y1_low) + z0 = z0_low + r*(z0_hi - z0_low) + z1 = z1_low + r*(z1_hi - z1_low) + + d = sqrt((x1-x0)**2 + (y1-y0)**2 + (z1-z0)**2) + + !! Average velocity along 'ds' direction. + !! Note : Divide by physical distance between (x0,y0,z0) + !! (x1,y1,z1) rather than use 2d trick where we only + !! need to divide by dx or dy. + !! The final integral is scaled by facearea/(ds*dz) which + !! cancels d here. + + u = (psi(x1,y1,z1,t) - psi(x0,y0,z0,t))/d + + psi_integrate = u + +end function psi_integrate diff --git a/applications/clawpack/advection/3d/all/rpn3_vc_advection.f90 b/applications/clawpack/advection/3d/all/rpn3_vc_advection.f90 new file mode 100644 index 000000000..c22de8d1c --- /dev/null +++ b/applications/clawpack/advection/3d/all/rpn3_vc_advection.f90 @@ -0,0 +1,69 @@ +subroutine clawpack46_rpn3(ixyz,maxm,meqn,mwaves,maux,mbc,mx,ql,qr, & + auxl,auxr,wave,s,amdq,apdq) +! Riemann-solver for the advection equation +! q_t + u*q_x + v*q_y + w*q_z = 0 +! where u and v are a given velocity field. +! +! waves: 1 +! equations: 1 +! aux fields: 3 +! +! Conserved quantities: +! 1 q +! +! Auxiliary variables +! 1 x_velocity +! 2 y_velocity +! 3 z_velocity +! +! The velocities are specified at the left/bottom/back cell face centers. +! +! Solve Riemann problems along one slice of data. +! This data is along a slice in the x-direction if ixyz=1 +! the y-direction if ixyz=2. +! the z-direction if ixyz=3. +! +! On input, ql contains the state vector at the left edge of each cell +! qr contains the state vector at the right edge of each cell +! +! On output, wave contains the waves, s the speeds, +! and amdq, apdq the left-going and right-going flux differences, +! respectively. Note that in this advective form, the sum of +! amdq and apdq is not equal to a difference of fluxes except in the +! case of constant velocities. +! +! Note that the i'th Riemann problem has left state qr(i-1,:) +! and right state ql(i,:) +! From the basic clawpack routines, this routine is called with ql = qr + + implicit none + + integer :: ixyz, maxm, meqn, mwaves, mbc, mx, maux + + double precision :: wave(meqn,mwaves,1-mbc:maxm+mbc) + double precision :: s(mwaves,1-mbc:maxm+mbc) + double precision :: ql(meqn,1-mbc:maxm+mbc) + double precision :: qr(meqn,1-mbc:maxm+mbc) + double precision :: amdq(meqn,1-mbc:maxm+mbc) + double precision :: apdq(meqn,1-mbc:maxm+mbc) + double precision :: auxl(maux,1-mbc:maxm+mbc) + double precision :: auxr(maux,1-mbc:maxm+mbc) + + integer manifold + common /com_manifold/ manifold + + integer :: i, iface, mcapa + + ! Set wave, speed, and flux differences: + iface = ixyz + mcapa = manifold + do i = 2-mbc, mx+mbc + wave(1,1,i) = ql(1,i) - qr(1,i-1) + s(1,i) = auxl(iface+mcapa,i) + ! The flux difference df = s*wave all goes in the downwind direction: + amdq(1,i) = dmin1(s(1,i), 0.d0) * wave(1,1,i) + apdq(1,i) = dmax1(s(1,i), 0.d0) * wave(1,1,i) + end do + + return +end subroutine clawpack46_rpn3 diff --git a/applications/clawpack/advection/3d/all/rpt3_vc_advection.f90 b/applications/clawpack/advection/3d/all/rpt3_vc_advection.f90 new file mode 100644 index 000000000..057d0e54c --- /dev/null +++ b/applications/clawpack/advection/3d/all/rpt3_vc_advection.f90 @@ -0,0 +1,97 @@ +subroutine clawpack46_rpt3(ixyz,icoor,imp,maxm,meqn,mwaves,maux,mbc, & + mx,ql,qr,aux1,aux2,aux3,asdq,bmasdq,bpasdq) + ! Riemann solver in the transverse direction for the + ! advection equations. + ! + ! On input, + ! + ! ql,qr is the data along some one-dimensional slice, as in rpn3 + ! This slice is + ! in the x-direction if ixyz=1, + ! in the y-direction if ixyz=2, or + ! in the z-direction if ixyz=3. + ! asdq is an array of flux differences (A^*\Dq). + ! asdq(i,:) is the flux difference propagating away from + ! the interface between cells i-1 and i. + ! Note that asdq represents B^*\Dq if ixyz=2 or C^*\Dq if ixyz=3. + ! + ! ixyz indicates the direction of the original Riemann solve, + ! called the x-like direction in the table below: + ! + ! x-like direction y-like direction z-like direction + ! ixyz=1: x y z + ! ixyz=2: y z x + ! ixyz=3: z x y + ! + ! icoor indicates direction in which the transverse solve should + ! be performed. + ! icoor=2: split in the y-like direction. + ! icoor=3: split in the z-like direction. + ! + ! For example, + ! ixyz=1, icoor=2 means asdq=A^*\Dq, and should be split in y into + ! bmasdq = B^-A^*\Dq, + ! bpasdq = B^+A^*\Dq. + ! + ! ixyz=2, icoor=2 means asdq=B^*\Dq, and should be split in z into + ! bmasdq = C^-B^*\Dq, + ! bpasdq = C^+B^*\Dq. + ! + ! The parameter imp is generally needed only if aux + ! arrays are being used, in order to access the appropriate + ! variable coefficients: + ! + ! imp = 1 if asdq = A^- \Dq, the left-going flux difference + ! 2 if asdq = A^+ \Dq, the right-going flux difference + ! + ! aux2(:,:,2) is a 1d slice of the aux array along the row + ! where the data ql, qr lie. + ! aux1(:,:,2) and aux3(:,:,2) are neighboring rows in the + ! y-like direction + ! aux2(:,:,1) and aux2(:,:,3) are neighboring rows in the + ! z-like direction + + implicit none + + integer, intent(in) :: ixyz, icoor, maxm, meqn, mwaves, mbc, mx, maux, imp + double precision, intent(in) :: ql, qr, asdq, aux1, aux2, aux3 + double precision, intent(out) :: bmasdq, bpasdq + + dimension ql(meqn,1-mbc:maxm+mbc) + dimension qr(meqn,1-mbc:maxm+mbc) + dimension asdq(meqn,1-mbc:maxm+mbc) + dimension bmasdq(meqn,1-mbc:maxm+mbc) + dimension bpasdq(meqn,1-mbc:maxm+mbc) + dimension aux1(maux,1-mbc:maxm+mbc,3) + dimension aux2(maux,1-mbc:maxm+mbc,3) + dimension aux3(maux,1-mbc:maxm+mbc,3) + + integer manifold + common /com_manifold/ manifold + + integer :: iuvw, i, i1, mcapa + + ! set iuvw = 1 for u, 2 for v, 3 for w component of velocity + ! depending on transverse direction: + mcapa = manifold + iuvw = ixyz + icoor - 1 + if (iuvw.gt.3) iuvw = iuvw-3 + + do i=2-mbc,mx+mbc + i1 = i-2+imp !# = i-1 for amdq, i for apdq + if (icoor == 2) then !! transverse dir. is y-like direction + bmasdq(1,i) = dmin1(aux2(iuvw+mcapa,i1,2), 0.d0)*asdq(1,i) + bpasdq(1,i) = dmax1(aux3(iuvw+mcapa,i1,2), 0.d0)*asdq(1,i) + else !! icoor == 3 !! transverse dir. is z-like direction + !! quanities split into cmasdq and cpasdq + bmasdq(1,i) = dmin1(aux2(iuvw+mcapa,i1,2),0.d0)*asdq(1,i) + bpasdq(1,i) = dmax1(aux2(iuvw+mcapa,i1,3),0.d0)*asdq(1,i) + endif + if (icoor .eq. 3) then + !!write(6,*) aux2(iuvw+mcapa,i1,2),aux3(iuvw+mcapa,i1,2), aux2(iuvw+mcapa,i1,3) + endif + end do + + return +end subroutine clawpack46_rpt3 + diff --git a/applications/clawpack/advection/3d/all/rptt3_vc_advection.f90 b/applications/clawpack/advection/3d/all/rptt3_vc_advection.f90 new file mode 100644 index 000000000..f305c0d1d --- /dev/null +++ b/applications/clawpack/advection/3d/all/rptt3_vc_advection.f90 @@ -0,0 +1,115 @@ +subroutine clawpack46_rptt3(ixyz,icoor,imp,impt,maxm,meqn,mwaves,& + maux,mbc,mx,ql,qr,aux1,aux2,aux3,bsasdq,cmbsasdq,cpbsasdq) + ! Riemann solver in the transverse direction for the + ! advection equations. + ! + ! On input, + ! + ! ql,qr is the data along some one-dimensional slice, as in rpn3 + ! This slice is + ! in the x-direction if ixyz=1, + ! in the y-direction if ixyz=2, or + ! in the z-direction if ixyz=3. + ! + ! bsasdq is an array of flux differences that result from a + ! transverse splitting (a previous call to rpt3). + ! This stands for B^* A^* \Dq but could represent any of + ! 6 possibilities, e.g. C^* B^* \Dq, as specified by ixyz + ! and icoor (see below). + ! Moreover, each * represents either + or -, as specified by + ! imp and impt. + ! + ! ixyz indicates the direction of the original Riemann solve, + ! called the x-like direction in the table below: + ! + ! x-like direction y-like direction z-like direction + ! ixyz=1: x y z + ! ixyz=2: y z x + ! ixyz=3: z x y + ! + ! icoor indicates direction in which the transverse solve should + ! be performed. + ! icoor=2: split in the y-like direction. + ! icoor=3: split in the z-like direction. + ! + ! For example, + ! ixyz=1, icoor=3 means bsasdq=B^*A^*\Dq, and should be + ! split in z into + ! cmbsasdq = C^-B^*A^*\Dq, + ! cpbsasdq = C^+B^*A^*\Dq. + ! + ! ixyz=2, icoor=3 means bsasdq=C^*B^*\Dq, and should be + ! split in x into + ! cmbsasdq = A^-C^*B^*\Dq, + ! cpbsasdq = A^+C^*B^*\Dq. + ! + ! The parameters imp and impt are generally needed only if aux + ! arrays are being used, in order to access the appropriate + ! variable coefficients: + ! + ! imp = 1 if bsasdq = B^*A^- \Dq, a left-going flux difference + ! 2 if bsasdq = B^*A^+ \Dq, a right-going flux difference + ! impt = 1 if bsasdq = B^-A^* \Dq, a down-going flux difference + ! 2 if bsasdq = B^+A^* \Dq, an up-going flux difference + ! + ! aux2(:,:,2) is a 1d slice of the aux array along the row + ! where the data ql, qr lie. + ! aux1(:,:,2) and aux3(:,:,2) are neighboring rows in the + ! y-like direction + ! aux2(:,:,1) and aux2(:,:,3) are neighboring rows in the + ! z-like direction + + implicit none + + integer, intent(in) :: ixyz, icoor, maxm, meqn, mwaves, mbc, mx, maux, imp, impt + double precision, intent(in) :: ql, qr, bsasdq, aux1, aux2, aux3 + double precision, intent(out) :: cmbsasdq, cpbsasdq + + dimension ql(meqn,1-mbc:maxm+mbc) + dimension qr(meqn,1-mbc:maxm+mbc) + dimension bsasdq(meqn,1-mbc:maxm+mbc) + dimension cmbsasdq(meqn,1-mbc:maxm+mbc) + dimension cpbsasdq(meqn,1-mbc:maxm+mbc) + dimension aux1(maux,1-mbc:maxm+mbc,3) + dimension aux2(maux,1-mbc:maxm+mbc,3) + dimension aux3(maux,1-mbc:maxm+mbc,3) + + integer manifold + common /com_manifold/ manifold + + integer :: i, i1, iuvw, mcapa + + ! set iuvw = 1 for u, 2 for v, 3 for w component of velocity + ! depending on transverse direction: + mcapa = manifold + iuvw = ixyz + icoor - 1 + + if (iuvw.gt.3) iuvw = iuvw-3 + + do i=2-mbc,mx+mbc + i1 = i-2+imp !# = i-1 for amdq, i for apdq + if (icoor == 2) then + !! double-transverse dir. is the y-like direction + if (impt == 1) then + cmbsasdq(1,i) = dmin1(aux2(iuvw + mcapa,i1,1),0.d0)*bsasdq(1,i) + cpbsasdq(1,i) = dmax1(aux3(iuvw + mcapa,i1,1),0.d0)*bsasdq(1,i) + elseif (impt == 2) then + cmbsasdq(1,i) = dmin1(aux2(iuvw + mcapa,i1,3),0.d0)*bsasdq(1,i) + cpbsasdq(1,i) = dmax1(aux3(iuvw + mcapa,i1,3),0.d0)*bsasdq(1,i) + endif + else + !! double-transverse dir. is the z-like direction + if (impt == 1) then + !! bmasdq is split into cmbmasdq and cpbmasdq + cmbsasdq(1,i) = dmin1(aux1(iuvw + mcapa,i1,2),0.d0)*bsasdq(1,i) + cpbsasdq(1,i) = dmax1(aux1(iuvw + mcapa,i1,3),0.d0)*bsasdq(1,i) + elseif (impt == 2) then + !! bpasdq is split into cmbpasdq and cpbpasdq + cmbsasdq(1,i) = dmin1(aux3(iuvw + mcapa,i1,2),0.d0)*bsasdq(1,i) + cpbsasdq(1,i) = dmax1(aux3(iuvw + mcapa,i1,3),0.d0)*bsasdq(1,i) + endif + endif + end do + + return +end subroutine clawpack46_rptt3 diff --git a/applications/clawpack/advection/3d/swirl/CMakeLists.txt b/applications/clawpack/advection/3d/swirl/CMakeLists.txt new file mode 100644 index 000000000..d4dc55521 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/CMakeLists.txt @@ -0,0 +1,51 @@ +set(all ${PROJECT_SOURCE_DIR}/clawpack/advection/3d/all) +set(all2d ${PROJECT_SOURCE_DIR}/clawpack/advection/2d/all) + + +add_library(swirl3d_f OBJECT + setprob.f90 + fdisc.f + user_exceeds_th.f90 + user_4.6/qinit.f90 + user_4.6/swirl_setaux.f90 + user_4.6/swirl_setaux_manifold.f90 + ${all}/rpn3_vc_advection.f90 + ${all}/rpt3_vc_advection.f90 + ${all}/rptt3_vc_advection.f90 +) + +add_executable(swirl3d + swirl_user.cpp + swirl.cpp + swirl_options.c + swirl_map_extrude.c + ${all2d}/fclaw2d_map_cart.c + ${all2d}/fclaw2d_map_fivepatch.c + ${all2d}/fclaw2d_map_bilinear.c + $ +) + +set_target_properties(swirl3d PROPERTIES OUTPUT_NAME swirl) + +target_include_directories(swirl3d PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${all} +) + +target_link_libraries(swirl3d PRIVATE + FORESTCLAW::CLAWPACK3_46 +) + +add_test(NAME clawpack_advection_3d_swirl COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/regressions.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(clawpack_advection_3d_swirl PROPERTIES ENVIRONMENT "${FCLAW_TEST_ENVIRONMENT}") + + + + + + + + + + + diff --git a/applications/clawpack/advection/3d/swirl/Makefile.am b/applications/clawpack/advection/3d/swirl/Makefile.am new file mode 100644 index 000000000..47ea7cfcd --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/Makefile.am @@ -0,0 +1,49 @@ +## Makefile.am in applications/clawpack/advection/3d/swirl + +bin_PROGRAMS += applications/clawpack/advection/3d/swirl/swirl + +TESTS += applications/clawpack/advection/3d/swirl/regressions.sh + +applications_clawpack_advection_3d_swirl_swirl_SOURCES = \ + applications/clawpack/advection/3d/swirl/swirl.cpp \ + applications/clawpack/advection/3d/swirl/swirl_user.cpp \ + applications/clawpack/advection/3d/swirl/swirl_user.h \ + applications/clawpack/advection/3d/swirl/swirl_map_extrude.c \ + applications/clawpack/advection/2d/all/fclaw2d_map_cart.c \ + applications/clawpack/advection/2d/all/fclaw2d_map_fivepatch.c \ + applications/clawpack/advection/2d/all/fclaw2d_map_bilinear.c \ + applications/clawpack/advection/3d/swirl/swirl_options.c \ + applications/clawpack/advection/3d/swirl/setprob.f90 \ + applications/clawpack/advection/3d/swirl/fdisc.f \ + applications/clawpack/advection/3d/swirl/user_exceeds_th.f90 \ + applications/clawpack/advection/3d/all/rpn3_vc_advection.f90 \ + applications/clawpack/advection/3d/all/rpt3_vc_advection.f90 \ + applications/clawpack/advection/3d/all/rptt3_vc_advection.f90 \ + applications/clawpack/advection/3d/swirl/user_4.6/qinit.f90 \ + applications/clawpack/advection/3d/swirl/user_4.6/swirl_setaux.f90 \ + applications/clawpack/advection/3d/swirl/user_4.6/swirl_setaux_manifold.f90 + +EXTRA_DIST += \ + applications/clawpack/advection/3d/swirl/fclaw_options.ini \ + applications/clawpack/advection/3d/swirl/mappings.ini \ + applications/clawpack/advection/3d/swirl/regression.ini \ + applications/clawpack/advection/3d/swirl/regression_map.ini \ + applications/clawpack/advection/3d/swirl/afterframe.m \ + applications/clawpack/advection/3d/swirl/read_vars.m \ + applications/clawpack/advection/3d/swirl/mapc2p.m \ + applications/clawpack/advection/3d/swirl/setplot3.m + +## Include headers and libraries needed to build this application +## -- Only really need AM_CPPFLAGS and LDADD (since these include all the other +## variables). But others are included here for completeness +applications_clawpack_advection_3d_swirl_swirl_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(FCLAW_CLAWPACK3_46_CPPFLAGS) \ + $(FCLAW_CLAWPATCH_CPPFLAGS) + + +applications_clawpack_advection_3d_swirl_swirl_LDADD = \ + $(LDADD) \ + $(FCLAW_CLAWPACK3_46_LDADD) \ + $(FCLAW_CLAWPATCH_LDADD) \ + $(FCLAW_LDADD) diff --git a/applications/clawpack/advection/3d/swirl/afterframe.m b/applications/clawpack/advection/3d/swirl/afterframe.m new file mode 100644 index 000000000..fe542bc3f --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/afterframe.m @@ -0,0 +1,31 @@ +yrbcolormap +axis([0 1 0 1 0 1]) +daspect([1 1 1]); + + +fprintf('qmin = %24.16e\n',qmin); +fprintf('qmax = %24.16e\n',qmax); + + +showpatchborders; +setpatchborderprops('linewidth',1); +setpatchbordercolor('k'); + +% showcubes; +parms = read_vars(); +showslices; +if parms.example > 0 + hideslices('x'); + hideslices('y'); +end + +showsurfs(); + +caxis([0,1]); + +set(gca,'box','on'); + +%axis off; +axis on; + +shg; \ No newline at end of file diff --git a/applications/clawpack/advection/p8/swirl/fclaw_options.ini b/applications/clawpack/advection/3d/swirl/fclaw_options.ini similarity index 98% rename from applications/clawpack/advection/p8/swirl/fclaw_options.ini rename to applications/clawpack/advection/3d/swirl/fclaw_options.ini index 3edc74de4..d0f03cca5 100644 --- a/applications/clawpack/advection/p8/swirl/fclaw_options.ini +++ b/applications/clawpack/advection/3d/swirl/fclaw_options.ini @@ -18,7 +18,7 @@ # Grid dimensions mx = 16 # mx_leaf my = 16 # my_leaf - mz = 128 # Doesn't change + mz = 16 # mz_leaf mbc = 2 # Number of ghost cells maux = 4 diff --git a/applications/clawpack/advection/3d/swirl/fdisc.f b/applications/clawpack/advection/3d/swirl/fdisc.f new file mode 100644 index 000000000..f4389dfe3 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/fdisc.f @@ -0,0 +1,25 @@ + double precision function fdisc(blockno,xc,yc,zc) + implicit none + + integer blockno + double precision xc,yc, zc + + integer*8 cont, fclaw_map_get_context + integer fclaw_map_is_used + + double precision xp, yp, zp + + cont = fclaw_map_get_context() + + if (fclaw_map_is_used(cont) .ne. 0) then + call fclaw_map_3d_c2m(cont, + & blockno,xc,yc,zc,xp,yp,zp) + else + xp = xc + yp = yc + zp = zc + endif + + fdisc = xp - 0.5 + + end diff --git a/applications/clawpack/advection/3d/swirl/mapc2p.m b/applications/clawpack/advection/3d/swirl/mapc2p.m new file mode 100644 index 000000000..80aa8de88 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/mapc2p.m @@ -0,0 +1,56 @@ +function [xp,yp,zp] = mapc2p(xc,yc,zc) + +parms = read_vars(); +if parms.example == 0 + map = 'nomap'; +elseif parms.example == 1 + map = 'cart'; % brick +elseif parms.example == 2 + map = 'fivepatch'; +elseif parms.example == 3 + map = 'bilinear'; +end + +% This domain should be in [0,1],[0,1] + +alpha = parms.alpha; + +scale = [0.5,0.5,1]; +shift = [0.5,0.5,0]; + +switch map + case 'nomap' + xp = xc; + yp = yc; + zp = zc; + case 'cart' + % (xc,yc) in [0,1]x[0,1] + s = 0; + [xc1,yc1,~] = mapc2m_brick(xc,yc,s); + [xp,yp,~] = mapc2m_cart(xc1,yc1); + + xp = scale(1)*xp + shift(1); + yp = scale(2)*yp + shift(2); + zp = zc; + + case 'fivepatch' + [xp,yp,~] = mapc2m_fivepatch(xc,yc,alpha); + + xp = scale(1)*xp + shift(1); + yp = scale(2)*yp + shift(2); + zp = zc; + + case 'bilinear' + center = parms.center; + [xp,yp,~] = mapc2m_bilinear(xc,yc,center); + + xp = scale(1)*xp + shift(1); + yp = scale(2)*yp + shift(2); + zp = zc; + +end + + + + +end \ No newline at end of file diff --git a/applications/clawpack/advection/3d/swirl/mapping.ini b/applications/clawpack/advection/3d/swirl/mapping.ini new file mode 100644 index 000000000..57b7e2c0f --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/mapping.ini @@ -0,0 +1,119 @@ +[user] + + # 0 - No mapping + # 1 - Cartesian mapping + # 2 - Five patch mapping + # 3 - Bilinear mapping + example = 1 + + alpha = 0.5 + + center = 0.2 0.3 + + max-elevation = 1 + + claw-version = 4 + + +[clawpatch] + # Grid dimensions + mx = 16 # mx_leaf + my = 16 # my_leaf + mz = 128 # Doesn't change + + mbc = 2 # Number of ghost cells + maux = 4 + + # Equations and boundary conditions + meqn = 1 # Number of equations + + # Clawpatch tagging criteria + # value : value exceeds threshold + # minmax : qmax-qmin exceeds threshold + # difference : difference (e.g. dqx = q(i+1,j)-q(i-1,j)) exceeds threshold + # gradient : gradient exceeds threshold + # user : User defined criteria + refinement-criteria = minmax + +[Options] + # --------------------------- + # Dynamic gridding parameters + # --------------------------- + + minlevel = 0 # Minimum level + maxlevel = 3 # Maximum levels of refinement + + regrid_interval = 1 # Regrid every 'regrid_interval' time steps. + refine_threshold = 0.25 + coarsen_threshold = 0.05 + + smooth-refine = F + refine-level = 5 + + # -------------- + # Time stepping + # -------------- + tfinal = 4.0 # Final time + + use_fixed_dt = F # Take a fixed time step + initial_dt = 5e-3 # Initial time step for 'minlevel' + max_cfl = 1.0 # maximum cfl + desired_cfl = 0.9 # desired cfl + + outstyle = 1 # OutputStyle = 1,2,3 + + nout = 16 # Used for all three out styles; has different meaning, though. + nstep = 1 # Only used if outstyle is 3 + + subcycle = T # subcycle in time ( = T or F). + + # ------------------- + # File and console IO + # ------------------- + verbosity = production + output = T + + # ----------- + # Tikz output + # ----------- + tikz-out = F + tikz-figsize = 4 4 + tikz-plot-prefix = 'plot' + tikz-plot-suffix = 'png' + + # ------------------------- + # Diagnostics and debugging + # ------------------------- + trapfpe = F # Trap floating point errors. + mpi_debug = F # Attach mpi processes in gdb + conservation-check = F + run-user-diagnostics = F + compute-error = F + report-timing=T + report-timing-verbosity=wall + + # ------- + # Mapping + # ------- + manifold = T # Manifold + + mi = 2 + mj = 2 + + scale = 0.5 0.5 1 + shift = 0.5 0.5 0 + +[claw3] + order = 2 2 2 # normal and transverse order + mcapa = 1 # mcapa + src_term = 0 # src_term + + mwaves = 1 # mwaves + mthlim = 4 # 4=MC limiter + mthbc = 1 1 1 1 1 1 # mthbc (=left,right,bottom,top) + + # output + ascii-out = T + vtk-out = F + + diff --git a/applications/clawpack/advection/3d/swirl/read_vars.m b/applications/clawpack/advection/3d/swirl/read_vars.m new file mode 100644 index 000000000..2db24d446 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/read_vars.m @@ -0,0 +1,10 @@ +function parms = read_vars() + +data = load('setprob.data'); + +parms.example = data(1); +parms.manifold = data(2); +parms.alpha = data(3); +parms.center = data(4:5); + +end \ No newline at end of file diff --git a/applications/clawpack/advection/3d/swirl/regression.ini b/applications/clawpack/advection/3d/swirl/regression.ini new file mode 100644 index 000000000..a4feb8def --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/regression.ini @@ -0,0 +1,123 @@ +[user] + # 0 - No mapping + # 1 - Cartesian mapping + # 2 - Five patch mapping + # 3 - Bilinear mapping + example = 0 + + alpha = 0.5 + + center = 0.2 0.3 + + max-elevation = 1 + + + claw-version = 4 + + +[clawpatch] + # Grid dimensions + mx = 8 # mx_leaf + my = 8 # my_leaf + mz = 8 + + mbc = 2 # Number of ghost cells + maux = 3 + + # Equations and boundary conditions + meqn = 1 # Number of equations + + # Clawpatch tagging criteria + # value : value exceeds threshold + # minmax : qmax-qmin exceeds threshold + # difference : difference (e.g. dqx = q(i+1,j)-q(i-1,j)) exceeds threshold + # gradient : gradient exceeds threshold + # user : User defined criteria + refinement-criteria = minmax + + +[Options] + # --------------------------- + # Dynamic gridding parameters + # --------------------------- + + minlevel = 1 # Minimum level + maxlevel = 4 # Maximum levels of refinement + + regrid_interval = 1 # Regrid every 'regrid_interval' time steps. + refine_threshold = 0.25 + coarsen_threshold = 0.05 + + smooth-refine = F + refine-level = 5 + + # -------------- + # Time stepping + # -------------- + tfinal = 0.1 # Final time + + use_fixed_dt = F # Take a fixed time step + initial_dt = 2e-3 # Initial time step for 'minlevel' + max_cfl = 1.0 # maximum cfl + desired_cfl = 0.9 # desired cfl + + outstyle = 1 # OutputStyle = 1,2,3 + + nout = 1 # Used for all three out styles; has different meaning, though. + nstep = 1 # Only used if outstyle is 3 + + subcycle = F # subcycle in time ( = T or F). + + # ------------------- + # File and console IO + # ------------------- + verbosity = production + output = F + + # ----------- + # Tikz output + # ----------- + tikz-out = F + tikz-figsize = 4 4 + tikz-plot-prefix = 'plot' + tikz-plot-suffix = 'png' + + # ------------------------- + # Diagnostics and debugging + # ------------------------- + trapfpe = T # Trap floating point errors. + mpi_debug = F # Attach mpi processes in gdb + conservation-check = F + run-user-diagnostics = F + compute-error = F + report-timing=T + report-timing-verbosity=wall + + # ------- + # Mapping + # ------- + manifold = F # Manifold + + # Domain dimensions - used only if manifold = F + ax = 0 + bx = 1 + ay = 0 + by = 1 + az = 0 + bz = 1 + + +[claw3] + order = 1 1 1 # normal and transverse order + mcapa = 0 # mcapa + src_term = 0 # src_term + + mwaves = 1 # mwaves + mthlim = 0 # mthlim (is a vector in general, with 'mwaves' entries) + mthbc = 1 1 1 1 1 1 # mthbc (=left,right,bottom,top) + + # output + ascii-out = T + vtk-out = F + + diff --git a/applications/clawpack/advection/3d/swirl/regression_map.ini b/applications/clawpack/advection/3d/swirl/regression_map.ini new file mode 100644 index 000000000..f46e63727 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/regression_map.ini @@ -0,0 +1,118 @@ +[user] + # 0 - No mapping + # 1 - Cartesian mapping + # 2 - Five patch mapping + # 3 - Bilinear mapping + example = 1 + + alpha = 0.5 + + center = 0.2 0.3 + + max-elevation = 1 + + + claw-version = 4 + + +[clawpatch] + # Grid dimensions + mx = 8 # mx_leaf + my = 8 # my_leaf + mz = 128 + + mbc = 2 # Number of ghost cells + maux = 4 + + # Equations and boundary conditions + meqn = 1 # Number of equations + + # Clawpatch tagging criteria + # value : value exceeds threshold + # minmax : qmax-qmin exceeds threshold + # difference : difference (e.g. dqx = q(i+1,j)-q(i-1,j)) exceeds threshold + # gradient : gradient exceeds threshold + # user : User defined criteria + refinement-criteria = minmax + + +[Options] + # --------------------------- + # Dynamic gridding parameters + # --------------------------- + + minlevel = 1 # Minimum level + maxlevel = 4 # Maximum levels of refinement + + regrid_interval = 1 # Regrid every 'regrid_interval' time steps. + refine_threshold = 0.25 + coarsen_threshold = 0.05 + + smooth-refine = F + refine-level = 5 + + # -------------- + # Time stepping + # -------------- + tfinal = 0.05 # Final time + + use_fixed_dt = F # Take a fixed time step + initial_dt = 2e-3 # Initial time step for 'minlevel' + max_cfl = 1.0 # maximum cfl + desired_cfl = 0.9 # desired cfl + + outstyle = 1 # OutputStyle = 1,2,3 + + nout = 1 # Used for all three out styles; has different meaning, though. + nstep = 1 # Only used if outstyle is 3 + + subcycle = F # subcycle in time ( = T or F). + + # ------------------- + # File and console IO + # ------------------- + verbosity = production + output = F + + # ----------- + # Tikz output + # ----------- + tikz-out = F + tikz-figsize = 4 4 + tikz-plot-prefix = 'plot' + tikz-plot-suffix = 'png' + + # ------------------------- + # Diagnostics and debugging + # ------------------------- + trapfpe = T # Trap floating point errors. + mpi_debug = F # Attach mpi processes in gdb + conservation-check = F + run-user-diagnostics = F + compute-error = F + report-timing=T + report-timing-verbosity=wall + + # ------- + # Mapping + # ------- + manifold = T # Manifold + + mi = 2 + mj = 2 + + +[claw3] + order = 2 2 2 # normal and transverse order + mcapa = 1 # mcapa + src_term = 0 # src_term + + mwaves = 1 # mwaves + mthlim = 4 # mthlim (is a vector in general, with 'mwaves' entries) + mthbc = 1 1 1 1 1 1 # mthbc (=left,right,bottom,top) + + # output + ascii-out = T + vtk-out = F + + diff --git a/applications/clawpack/advection/3d/swirl/regression_values_0.csv b/applications/clawpack/advection/3d/swirl/regression_values_0.csv new file mode 100644 index 000000000..2ad38adc4 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/regression_values_0.csv @@ -0,0 +1,3 @@ +count_amr_advance,5 +global_num_patches,1716 +count_amr_new_domain,3 diff --git a/applications/clawpack/advection/3d/swirl/regression_values_1.csv b/applications/clawpack/advection/3d/swirl/regression_values_1.csv new file mode 100644 index 000000000..77e3f14c0 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/regression_values_1.csv @@ -0,0 +1,3 @@ +count_amr_advance,3 +global_num_patches,292 +count_amr_new_domain,1 diff --git a/applications/clawpack/advection/3d/swirl/regression_values_3.csv b/applications/clawpack/advection/3d/swirl/regression_values_3.csv new file mode 100644 index 000000000..53d1aa75e --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/regression_values_3.csv @@ -0,0 +1,3 @@ +count_amr_advance,4 +global_num_patches,271 +count_amr_new_domain,4 diff --git a/applications/clawpack/advection/3d/swirl/regressions.sh b/applications/clawpack/advection/3d/swirl/regressions.sh new file mode 100755 index 000000000..215cc9e36 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/regressions.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# absolute path to application we are testing +application=$FCLAW_APPLICATIONS_BUILD_DIR/clawpack/advection/3d/swirl/swirl + +# change to source dir for working directory +cd $FCLAW_APPLICATIONS_SRC_DIR/clawpack/advection/3d/swirl/ + +# run programs, exit script with nonzero on failure (or else script will exit with value of last program run) +$FCLAW_MPIRUN $FCLAW_MPI_TEST_FLAGS $application -F regression.ini --user:example=0 --regression-check=regression_values_0.csv || exit 1 + +#$FCLAW_MPIRUN $FCLAW_MPI_TEST_FLAGS $application -F regression_map.ini --user:example=1 --regression-check=regression_values_1.csv || exit 1 + +# Crashes latest CI on Linux +# $FCLAW_MPIRUN $FCLAW_MPI_TEST_FLAGS $application -F regression_map.ini --user:example=2 --regression-check=regression_values_2.csv || exit 1 + +#$FCLAW_MPIRUN $FCLAW_MPI_TEST_FLAGS $application -F regression_map.ini --user:example=3 --regression-check=regression_values_3.csv || exit 1 diff --git a/applications/clawpack/advection/3d/swirl/setplot3.m b/applications/clawpack/advection/3d/swirl/setplot3.m new file mode 100644 index 000000000..61d474057 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/setplot3.m @@ -0,0 +1,61 @@ +% setplot3.m +% called in plotclaw3 before plotting to set various parameters + +OutputDir = './'; +setviews % set viewpoints so that view(xSlice), for example, can be used. +setopengl; + +OutputFlag = 'forestclaw'; + +ForestClaw = 1; + +PlotType = 1; % type of plot to produce: + % 1 = pcolor on slices (with optional contours) + % 2 = contour lines in 3d on transparent slices + % 3 = Schlieren plot on slices + % 4 = scatter plot of q vs. r + % 5 = isosurface plot (at given levels) + +mq = 1; % which component of q to plot +UserVariable = 0; % set to 1 to specify a user-defined variable +UserVariableFile = ' '; % name of m-file mapping data to q +MappedGrid = 1; % set to 1 if mapc2p.m exists for nonuniform grid +Manifold = 0; +MaxFrames = 1000; % max number of frames to loop over +MaxLevels = 30; % max number of AMR levels +ReadBlockNumber = 1; + +PlotData = ones(1,MaxLevels); % Data on refinement level k is plotted only + % if k'th component is nonzero +PlotGrid = ones(1,MaxLevels); % Plot grid lines on each level? +PlotGridEdges = zeros(1,MaxLevels); % Plot edges of patches of each grid at + % this level on slices? +PlotCubeEdges = zeros(1,MaxLevels); % Plot edges of cube of refinement patch at + % this level? + + +% ContourValues is a vector of contour lines that can be used with +% PlotType = 1,2,3. Empty ==> no contour lines drawn + +ContourValues = []; % draw contour lines from 'afterframe.m' + +% The next three parameters are vectors of x,y,z coordinates of 2d slices +% to be displayed for PlotType = 1,2,3. + +xSliceCoords = [0.5]; +ySliceCoords = [0.5]; +zSliceCoords = [0.5]; + +IsosurfValues = [0.5]; % Plot surfaces at q = surfValue(i). + + IsosurfAlphas = [1]; % Transparency of each surface + % (0=clear; 1=opaque) + % NOTE: Your system must be able to + % use the OpenGL Renderer. + + IsosurfColors = 'w'; % Colors for each surface. + + +PlotBlockColors = 0; +PlotParallelPartitions = 0; + diff --git a/applications/clawpack/advection/3d/swirl/setprob.f90 b/applications/clawpack/advection/3d/swirl/setprob.f90 new file mode 100644 index 000000000..97f10b6ad --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/setprob.f90 @@ -0,0 +1,23 @@ + subroutine setprob + implicit none + + double precision pi, pi2 + common /compi/ pi, pi2 + + integer manifold + common /com_manifold/ manifold + + integer example + common /com_swirl/ example + + pi = 4.d0*atan(1.d0) + pi2 = 2*pi + + open(10,file='setprob.data') + read(10,*) example + read(10,*) manifold + !! Other values in setprob.data aren't needed by fortran routines + close(10) + + + end diff --git a/applications/clawpack/advection/p8/swirl/swirl.cpp b/applications/clawpack/advection/3d/swirl/swirl.cpp similarity index 57% rename from applications/clawpack/advection/p8/swirl/swirl.cpp rename to applications/clawpack/advection/3d/swirl/swirl.cpp index cc7eeabc8..e9ac481f8 100644 --- a/applications/clawpack/advection/p8/swirl/swirl.cpp +++ b/applications/clawpack/advection/3d/swirl/swirl.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton + Copyright (c) 2012-2023 Carsten Burstedde, Donna Calhoun, Scott Aiton All rights reserved. Redistribution and use in source and binary forms, with or without @@ -25,69 +25,70 @@ #include "swirl_user.h" -#include +#include static -fclaw3d_domain_t* create_domain(sc_MPI_Comm mpicomm, - fclaw_options_t* fclaw_opt, - user_options_t *user, - void *clawpatch_opt, - void *claw3_opt) +void create_domain(fclaw_global_t *glob) { - /* Mapped, multi-block domain */ - p8est_connectivity_t *conn = NULL; - fclaw3d_domain_t *domain = NULL; - -#ifdef P8HACK - fclaw2d_map_context_t *cont = NULL, *brick = NULL; -#endif + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); + /* Mapped, multi-block domain */ int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; - int mk = 1; + int mk = fclaw_opt->mk; int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; - int c = 0; + int c = fclaw_opt->periodic_z; - int minlevel = fclaw_opt->minlevel; - -#ifdef P8HACK + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; + int minlevel = fclaw_opt->minlevel; int check = mi*mx*pow_int(2,minlevel); -#endif - switch (user->example) + fclaw_map_context_t *cont, *brick; + fclaw_domain_t *domain = NULL; + + fc3d_clawpack46_options_t *claw3_opt = fc3d_clawpack46_get_options(glob); + const user_options_t *user = swirl_get_options(glob); + switch (user->example) { case 0: -#ifdef P8HACK FCLAW_ASSERT(claw3_opt->mcapa == 0); FCLAW_ASSERT(fclaw_opt->manifold == 0); -#endif + + /* Mapped, multi-block domain */ + domain = fclaw_domain_new_unitcube(glob->mpicomm, + fclaw_opt->minlevel); + /* Size is set by [ax,bx] x [ay, by], set in .ini file */ - conn = p8est_connectivity_new_unitcube(); -#ifdef P8HACK - cont = fclaw2d_map_new_nomap(); -#endif + cont = fclaw_map_new_nomap(); break; case 1: /* Square brick domain */ -#ifdef P8HACK FCLAW_ASSERT(claw3_opt->mcapa != 0); FCLAW_ASSERT(fclaw_opt->manifold != 0); FCLAW_ASSERT(clawpatch_opt->maux == 4); -#endif - conn = p8est_connectivity_new_brick(mi,mj,mk,a,b,c); -#ifdef P8HACK - brick = fclaw2d_map_new_brick_conn (conn,mi,mj); + + /* Cartesian square domain */ + domain = + fclaw_domain_new_3d_brick (glob->mpicomm, + mi, mj, mk, a, b, c, + fclaw_opt->minlevel); + + brick = fclaw_map_new_3d_brick(domain,mi,mj,mk,a,b,c); + + cont = fclaw_map_new_nomap_brick(brick); /* Square in [-1,1]x[-1,1], scaled/shifted to [0,1]x[0,1] */ +#if 0 cont = fclaw2d_map_new_cart(brick, fclaw_opt->scale, fclaw_opt->shift); #endif break; -#ifdef P8HACK case 2: + fclaw_abortf("Not implemented\n"); FCLAW_ASSERT(fclaw_opt->manifold != 0); FCLAW_ASSERT(claw3_opt->mcapa != 0); FCLAW_ASSERT(clawpatch_opt->maux == 4); @@ -99,60 +100,63 @@ fclaw3d_domain_t* create_domain(sc_MPI_Comm mpicomm, } /* Five patch square domain */ - conn = p4est_connectivity_new_disk (0, 0); - cont = fclaw2d_map_new_fivepatch (fclaw_opt->scale, - fclaw_opt->shift, - user->alpha); + domain = + fclaw_domain_new_2d_disk(glob->mpicomm, 0,0, + fclaw_opt->minlevel); + + cont = fclaw2d_map_new_fivepatch(fclaw_opt->scale, + fclaw_opt->shift, + user->alpha); break; case 3: + fclaw_abortf("Not implemented\n"); /* bilinear square domain : maps to [-1,1]x[-1,1] */ FCLAW_ASSERT(fclaw_opt->manifold != 0); FCLAW_ASSERT(claw3_opt->mcapa != 0); FCLAW_ASSERT(clawpatch_opt->maux == 4); FCLAW_ASSERT(mi == 2 && mj == 2); - conn = p4est_connectivity_new_brick(mi,mj,a,b); - brick = fclaw2d_map_new_brick_conn (conn,mi,mj); - cont = fclaw2d_map_new_bilinear (brick, - fclaw_opt->scale, - fclaw_opt->shift, - user->center); + + domain = + fclaw_domain_new_3d_brick(glob->mpicomm, + mi, mj, mk, a, b, c, + fclaw_opt->minlevel); + + brick = fclaw_map_new_2d_brick (domain, mi, mj, a, b); + + cont = fclaw2d_map_new_bilinear(brick, + fclaw_opt->scale, + fclaw_opt->shift, + user->center); + break; -#endif /* P8HACK */ + default: SC_ABORT_NOT_REACHED (); } -#ifdef P8HACK if (user->example > 0) - { - swirl_map_extrude(cont,user->maxelev); - } -#endif /* P8HACK */ + swirl_map_extrude(cont,user->maxelev); - domain = fclaw3d_domain_new_conn (mpicomm, fclaw_opt->minlevel, conn); - fclaw3d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw3d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + /* Store mapping in the glob */ + fclaw_map_store (glob, cont); - return domain; + /* Store the domain in the glob */ + fclaw_global_store_domain(glob, domain); + + /* print out some info */ + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw3d_global_t* glob) +void run_program(fclaw_global_t* glob) { - const user_options_t *user_opt; - - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw3d_domain_data_new(glob->domain); - - user_opt = swirl_get_options(glob); + const user_options_t *user_opt = swirl_get_options(glob); -#ifdef P8HACK /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); if (user_opt->claw_version == 4) { @@ -169,82 +173,56 @@ void run_program(fclaw3d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); - -#endif /* P8HACK */ + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int main (int argc, char **argv) { - fclaw_app_t *app; + /* Initialize application */ + fclaw_app_t *app = fclaw_app_new (&argc, &argv, NULL); /* Options */ user_options_t *user_opt; -#if 0 - fclaw3dx_clawpatch_options_t *clawpatch_opt = NULL; - fc3d_clawpack46_options_t *claw46_opt = NULL; -#endif - void *clawpatch_opt = NULL; - void *claw46_opt = NULL; fclaw_options_t *fclaw_opt; - sc_options_t *options; - - int first_arg; - fclaw_exit_type_t vexit; - - fclaw3d_global_t *glob; - fclaw3d_domain_t *domain; - - int retval; - sc_MPI_Comm mpicomm; - - /* Initialize application */ - app = fclaw_app_new (&argc, &argv, NULL); + fclaw_clawpatch_options_t *clawpatch_opt; + fc3d_clawpack46_options_t *claw46_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - -#ifdef P8HACK - clawpatch_opt = fclaw3dx_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_3d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc3d_clawpack46_options_register(app, "claw3", "fclaw_options.ini"); -#endif /* P8HACK */ - - user_opt = swirl_options_register(app, "fclaw_options.ini"); + user_opt = swirl_options_register(app, "fclaw_options.ini"); /* Read configuration file(s) and command line, and process options */ - options = fclaw_app_get_options (app); - retval = fclaw_options_read_from_file(options); + int first_arg; + fclaw_exit_type_t vexit; vexit = fclaw_app_options_parse (app, &first_arg,"fclaw_options.ini.used"); /* Run the program */ - if (!retval & !vexit) + if (!vexit) { /* Options have been checked and are valid */ - mpicomm = fclaw_app_get_mpi_size_rank (app, NULL, NULL); - domain = create_domain(mpicomm, fclaw_opt, user_opt, clawpatch_opt, - claw46_opt); - - /* Create global structure which stores the domain, timers, etc */ - glob = fclaw3d_global_new(); - fclaw3d_global_store_domain(glob, domain); + int size, rank; + sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw3d_options_store (glob, fclaw_opt); - -#ifdef P8HACK - fclaw3dx_clawpatch_options_store(glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store(glob, clawpatch_opt); fc3d_clawpack46_options_store (glob, claw46_opt); -#endif /* P8HACK */ swirl_options_store (glob, user_opt); + /* Create domain and store domain in glob */ + create_domain(glob); + run_program(glob); - fclaw3d_global_destroy(glob); + fclaw_global_destroy(glob); } - + fclaw_app_destroy (app); return 0; diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.h.TEST.cpp b/applications/clawpack/advection/3d/swirl/swirl_map_extrude.c similarity index 61% rename from src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.h.TEST.cpp rename to applications/clawpack/advection/3d/swirl/swirl_map_extrude.c index 51e583599..39500e07d 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.h.TEST.cpp +++ b/applications/clawpack/advection/3d/swirl/swirl_map_extrude.c @@ -23,27 +23,41 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#ifdef FCLAW_ENABLE_DEBUG +#include "swirl_user.h" -TEST_CASE("fclaw2d_clawpatch_diagnostics_vtable_initialize fails if fclaw2d_diagnostics_vtable_initialize is not called first") +/* User defined extruded mesh mapping */ +static void +swirl_map_3dx(fclaw_map_context_t * cont, int blockno, + double xc, double yc, double zc, + double *xp, double *yp, double *zp) { - fclaw2d_global_t* glob = fclaw2d_global_new(); - CHECK_SC_ABORTED(fclaw2d_clawpatch_diagnostics_vtable_initialize(glob)); - fclaw2d_global_destroy(glob); + /* Call 2d mapping to get surface. 2d mapping is not scaled in the + extruded case. */ + cont->mapc2m(cont,blockno,xc,yc,xp,yp,zp); + + /* Extrude in z direction to constant height maxelev. */ + double maxelev = cont->user_double_3d[0]; + *zp = maxelev*zc; + + scale_map(cont,xp,yp,zp); + shift_map(cont,xp,yp,zp); } -TEST_CASE("fclaw3dx_clawpatch_diagnostics_vtable_initialize fails if fclaw2d_diagnostics_vtable_initialize is not called first") + +void swirl_map_extrude(fclaw_map_context_t* cont, + const double maxelev) + { - fclaw2d_global_t* glob = fclaw2d_global_new(); - CHECK_SC_ABORTED(fclaw3dx_clawpatch_diagnostics_vtable_initialize(glob)); - fclaw2d_global_destroy(glob); + /* May be needed to get more general mappings */ + cont->mapc2m_3d = swirl_map_3dx; + + cont->user_double_3d[0] = maxelev; + + cont->is_extruded = 1; + + return; } -#endif \ No newline at end of file + + diff --git a/applications/clawpack/advection/p8/swirl/swirl_options.c b/applications/clawpack/advection/3d/swirl/swirl_options.c similarity index 95% rename from applications/clawpack/advection/p8/swirl/swirl_options.c rename to applications/clawpack/advection/3d/swirl/swirl_options.c index e80fdac5f..e34fe24c2 100644 --- a/applications/clawpack/advection/p8/swirl/swirl_options.c +++ b/applications/clawpack/advection/3d/swirl/swirl_options.c @@ -166,12 +166,12 @@ user_options_t* swirl_options_register (fclaw_app_t * app, return user; } -void swirl_options_store (fclaw3d_global_t* glob, user_options_t* user) +void swirl_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw3d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* swirl_get_options(fclaw3d_global_t* glob) +const user_options_t* swirl_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw3d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/3d/swirl/swirl_user.cpp b/applications/clawpack/advection/3d/swirl/swirl_user.cpp new file mode 100644 index 000000000..3f51d9799 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/swirl_user.cpp @@ -0,0 +1,124 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "swirl_user.h" + +#include + +void swirl_problem_setup(fclaw_global_t *glob) +{ + const user_options_t* user = swirl_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); + if (glob->mpirank == 0) + { + FILE *f = fopen("setprob.data","w"); + fprintf(f, "%-24d %s",user->example,"\% example\n"); + fprintf(f, "%-24d %s",fclaw_opt->manifold,"\% manifold\n"); + + /* For five-patch mapping */ + fprintf(f, "%-24.4f %s",user->alpha,"\% alpha\n"); + + /* For Bilinear mapping */ + fprintf(f, "%-24.4f %s",user->center[0],"\% center_x\n"); + fprintf(f, "%-24.4f %s",user->center[1],"\% center_y\n"); + fclose(f); + } + fclaw_domain_barrier (glob->domain); + SETPROB(); +} + +static +void swirl_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, + int blockno, + int patchno) +{ + int mx,my,mz, mbc; + double xlower,ylower,zlower, dx,dy, dz; + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, &mbc, + &xlower,&ylower,&zlower, &dx,&dy, &dz); + + double *xd,*yd,*zd,*volume,*faceareas; + double *xp,*yp,*zp; + fclaw_clawpatch_3d_mesh_data(glob,patch,&xp,&yp,&zp, + &xd,&yd,&zd,&volume,&faceareas); + + double *xrot, *yrot, *zrot; + fclaw3d_metric_patch_basis(glob,patch,&xrot,&yrot,&zrot); + + int maux; + double *aux; + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); + + SWIRL_SETAUX_MANIFOLD(&mbc,&mx,&my,&mz, &xlower,&ylower,&zlower, + &dx,&dy,&dz,&maux,aux,&blockno, + xrot,yrot,zrot,volume,faceareas); +} + + +void swirl_link_solvers(fclaw_global_t *glob) +{ + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = swirl_problem_setup; + + /* example of how to set up a user defined criteria */ + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + clawpatch_vt->d3->fort_user_exceeds_threshold = &FCLAW3D_USER_EXCEEDS_TH; + + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); + + const user_options_t* user = swirl_get_options(glob); + if (user->claw_version == 4) + { + fc3d_clawpack46_vtable_t *clawpack46_vt = fc3d_clawpack46_vt(glob); + + if (fclaw_opt->manifold) + { + /* This calls a manifold version of setaux */ + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); + patch_vt->setup = swirl_patch_setup; + } + else + { + /* This calls a setaux routine */ + clawpack46_vt->fort_setaux = &CLAWPACK46_SETAUX; + } + + clawpack46_vt->fort_qinit = &CLAWPACK46_QINIT; + clawpack46_vt->fort_rpn3 = &CLAWPACK46_RPN3; + clawpack46_vt->fort_rpt3 = &CLAWPACK46_RPT3; + clawpack46_vt->fort_rptt3 = &CLAWPACK46_RPTT3; + } + else if (user->claw_version == 5) + { + printf("swirl_user.cpp : Example not implemented for Claw version 5.\n"); + exit(0); + } +} + + + + + diff --git a/applications/clawpack/advection/p8/swirl/swirl_user.h b/applications/clawpack/advection/3d/swirl/swirl_user.h similarity index 91% rename from applications/clawpack/advection/p8/swirl/swirl_user.h rename to applications/clawpack/advection/3d/swirl/swirl_user.h index 026d20413..785e449ba 100644 --- a/applications/clawpack/advection/p8/swirl/swirl_user.h +++ b/applications/clawpack/advection/3d/swirl/swirl_user.h @@ -33,6 +33,7 @@ extern "C" { #endif + typedef struct user_options { int example; @@ -50,22 +51,17 @@ typedef struct user_options } user_options_t; -#ifdef P8HACK - -void swirl_link_solvers(fclaw2d_global_t *glob); - -#endif /* P8HACK */ +void swirl_link_solvers(fclaw_global_t *glob); /* ------------------------------------- Options ---------------------------------------*/ user_options_t* swirl_options_register (fclaw_app_t * app, const char *configfile); -void swirl_options_store (fclaw3d_global_t* glob, user_options_t* user); +void swirl_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* swirl_get_options(fclaw3d_global_t* glob); +const user_options_t* swirl_get_options(fclaw_global_t* glob); -#ifdef P8HACK #define SWIRL_SETAUX_MANIFOLD FCLAW_F77_FUNC(swirl_setaux_manifold, \ SWIRL_SETAUX_MANIFOLD) @@ -98,9 +94,7 @@ void SWIRL_SET_VELOCITY_MANIFOLD(const int* mx, const int* my, const int*mz, double faceareas[], double aux[], const int* maux); -void swirl_map_extrude(fclaw2d_map_context_t *cont, double maxelev); - -#endif /* P8HACK */ +void swirl_map_extrude(fclaw_map_context_t *cont, double maxelev); #ifdef __cplusplus } diff --git a/applications/clawpack/advection/3d/swirl/user_4.6/qinit.f90 b/applications/clawpack/advection/3d/swirl/user_4.6/qinit.f90 new file mode 100644 index 000000000..ff2b52169 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/user_4.6/qinit.f90 @@ -0,0 +1,44 @@ +subroutine clawpack46_qinit(meqn,mbc, mx,my,mz, & + xlower,ylower,zlower, dx,dy,dz, q,maux,aux) + implicit none + + integer :: meqn, mbc, mx, my, mz, maux + double precision :: xlower, ylower, zlower, dx, dy, dz + double precision :: q(1-mbc:mx+mbc, 1-mbc:my+mbc, 1-mbc:mz+mbc,meqn) + double precision :: aux(1-mbc:mx+mbc, 1-mbc:my+mbc, 1-mbc:mz+mbc,maux) + + integer example + common /com_swirl/ example + + integer :: i, j, k, mq + double precision :: xc, xlow, ylow, zlow,w + + integer :: blockno, fc3d_clawpack46_get_block + + blockno = fc3d_clawpack46_get_block() + + do mq = 1,meqn + do i = 1-mbc,mx+mbc + do j = 1-mbc,my+mbc + do k = 1-mbc, mz + mbc + xc = xlower + (i-0.5d0)*dx + if (example .eq. 0) then + if (xc .lt. 0.5d0) then + q(i,j,k,mq) = 1.d0 + else + q(i,j,k,mq) = 0 + endif + else + xlow = xlower + (i-1)*dx + ylow = ylower + (j-1)*dy + zlow = zlower + (k-1)*dz + CALL cellave3(blockno,xlow,ylow,zlow,dx,dy,dz,w) + q(i,j,k,1) = w + endif + end do + end do + end do + end do + + return +end subroutine clawpack46_qinit diff --git a/applications/clawpack/advection/3d/swirl/user_4.6/swirl_setaux.f90 b/applications/clawpack/advection/3d/swirl/user_4.6/swirl_setaux.f90 new file mode 100644 index 000000000..5cff9145c --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/user_4.6/swirl_setaux.f90 @@ -0,0 +1,85 @@ +!! ================================================================== +subroutine clawpack46_setaux(mbc,mx,my,mz,xlower,ylower,zlower, & + dx,dy,dz,maux,aux) +!! ================================================================== + + !! + !! # set auxiliary arrays + !! + !! # advection + !! # aux(i,j,k,1) is u velocity on left face of cell + !! # aux(i,j,k,2) is v velocity on bottom face of cell + !! # aux(i,j,k,3) is w velocity on back face of cell + !! + + implicit none + + integer :: mx, my, mz, mbc, maux + double precision :: xlower, ylower, zlower, dx, dy, dz + double precision :: aux(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,maux) + + double precision :: xc(1-mbc:mx+mbc) + double precision :: yc(1-mbc:my+mbc) + double precision :: zc(1-mbc:mz+mbc) + + integer :: i,j,k + double precision :: dx2, dy2, dz2, compute_u, compute_v, compute_w + + do i = 1-mbc,mx+mbc + xc(i) = xlower + (i-0.5d0)*dx + enddo + + do j = 1-mbc,my+mbc + yc(j) = ylower + (j-0.5d0)*dy + end do + + do k = 1-mbc,mz+mbc + zc(k) = zlower + (k-0.5d0)*dz + end do + + dx2 = 0.5d0*dx + dy2 = 0.5d0*dy + dz2 = 0.5d0*dz + + do k = 1-mbc,mz+mbc + do j = 1-mbc,my+mbc + do i = 1-mbc,mx+mbc + aux(i,j,k,1) = compute_u(xc(i)-dx2, yc(j),zc(k)) + aux(i,j,k,2) = compute_v(xc(i),yc(j)-dy2, zc(k)) + aux(i,j,k,3) = compute_w(xc(i),yc(j), zc(k)-dz2) + enddo + enddo + enddo + + return +end subroutine clawpack46_setaux + +double precision function compute_u(x,y,z) + implicit none + double precision :: x,y,z + + double precision pi, pi2 + common /compi/ pi, pi2 + + compute_u = 2.d0 * dsin(pi*x)**2 * dsin(pi2*y) * dsin(pi2*z) +end function compute_u + +double precision function compute_v(x,y,z) + implicit none + double precision :: x,y,z + + double precision pi, pi2 + common /compi/ pi, pi2 + + compute_v = -dsin(pi2*x) * dsin(pi*y)**2 * dsin(pi2*z) +end function compute_v + +double precision function compute_w(x,y,z) + implicit none + double precision :: x,y,z + + double precision pi, pi2 + common /compi/ pi, pi2 + + compute_w = -dsin(pi2*x) * dsin(pi2*y) * dsin(pi*z)**2 +end function compute_w diff --git a/applications/clawpack/advection/3d/swirl/user_4.6/swirl_setaux_manifold.f90 b/applications/clawpack/advection/3d/swirl/user_4.6/swirl_setaux_manifold.f90 new file mode 100644 index 000000000..13f4da25c --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/user_4.6/swirl_setaux_manifold.f90 @@ -0,0 +1,152 @@ +subroutine swirl_setaux_manifold(mbc,mx,my,mz, & + xlower,ylower,zlower,dx,dy,dz,maux, & + aux,blockno, xrot, yrot, zrot, volume, & + faceareas) + implicit none + + integer mbc, mx, my, mz, maux + integer blockno + double precision dx,dy, dz, xlower, ylower, zlower + double precision aux(1-mbc:mx+mbc,1-mbc:my+mbc, 1-mbc:mz+mbc,maux) + + double precision xrot(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+2,3,3) + double precision yrot(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+2,3,3) + double precision zrot(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+2,3,3) + + double precision volume(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc) + double precision faceareas(-mbc:mx+mbc+1,-mbc:my+mbc+1, -mbc:mz+mbc+2,3) + + integer i,j, k + double precision dxdydz, t + + dxdydz = dx*dy*dz + + do i = 1-mbc,mx+mbc + do j = 1-mbc,my+mbc + do k = 1-mbc,mz+mbc + aux(i,j,k,1) = volume(i,j,k)/dxdydz + end do + end do + end do + + t = 0 + call swirl_set_velocity_manifold(mx,my,mz,mbc, & + dx,dy,dz,t,blockno,xlower,ylower,zlower, & + xrot, yrot, zrot, faceareas,aux,maux) + + return +end subroutine swirl_setaux_manifold + + +!! ================================================================== +subroutine swirl_set_velocity_manifold(mx,my,mz,mbc, & + dx,dy,dz,t,blockno,xlower,ylower,zlower, & + xrot, yrot, zrot, faceareas,aux, maux) +!! ================================================================== + + !! + !! # set auxiliary arrays + !! + !! # advection + !! # aux(i,j,k,1) is u velocity on left face of cell + !! # aux(i,j,k,2) is v velocity on bottom face of cell + !! # aux(i,j,k,3) is w velocity on back face of cell + !! + + implicit none + + integer :: mx, my, mz, mbc, maux, blockno + double precision :: xlower, ylower, zlower, dx, dy, dz, t + double precision :: aux(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,maux) + double precision faceareas(-mbc:mx+mbc+1,-mbc:my+mbc+1, -mbc:mz+mbc+2,3) + + double precision xrot(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+2,3,3) + double precision yrot(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+2,3,3) + double precision zrot(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+2,3,3) + + double precision :: xc(1-mbc:mx+mbc) + double precision :: yc(1-mbc:my+mbc) + double precision :: zc(1-mbc:mz+mbc) + + integer*8 cont, fclaw_map_get_context + + integer :: i,j,k, mcapa + double precision :: dx2, dy2, dz2, compute_u, compute_v, compute_w + double precision :: dxdy, dxdz, dydz, u,v,w,g, xp,yp,zp + double precision :: nv(3), un_scaled, vn_scaled, wn_scaled + + integer jj + + cont = fclaw_map_get_context() + + do i = 1-mbc,mx+mbc + xc(i) = xlower + (i-0.5d0)*dx + enddo + + do j = 1-mbc,my+mbc + yc(j) = ylower + (j-0.5d0)*dy + end do + + do k = 1-mbc,mz+mbc + zc(k) = zlower + (k-0.5d0)*dz + end do + + dx2 = 0.5d0*dx + dy2 = 0.5d0*dy + dz2 = 0.5d0*dz + + dxdy = dx*dy + dxdz = dx*dz + dydz = dy*dz + + mcapa = 1 !! Offset into aux array + do k = 1-mbc,mz+mbc + do j = 1-mbc,my+mbc + do i = 1-mbc,mx+mbc + + !! Get velocity normal to x-face + call fclaw_map_3d_c2m(cont,blockno,xc(i)-dx2,yc(j),zc(k),xp,yp,zp) + g = faceareas(i,j,k,1)/dydz + u = compute_u(xp,yp,zp) + v = compute_v(xp,yp,zp) + w = compute_w(xp,yp,zp) + + do jj = 1,3 + nv(jj) = xrot(i,j,k,1,jj) + end do + un_scaled = g*(nv(1)*u + nv(2)*v + nv(3)*w) + + !! Get velocity normal to y-face + call fclaw_map_3d_c2m(cont,blockno,xc(i),yc(j)-dy2,zc(k),xp,yp,zp) + g = faceareas(i,j,k,2)/dxdz + u = compute_u(xp,yp,zp) + v = compute_v(xp,yp,zp) + w = compute_w(xp,yp,zp) + + do jj = 1,3 + nv(jj) = yrot(i,j,k,1,jj) + end do + vn_scaled = g*(nv(1)*u + nv(2)*v + nv(3)*w) + + !! Get velocity normal to z-face + call fclaw_map_3d_c2m(cont,blockno,xc(i),yc(j),zc(k)-dz2,xp,yp,zp) + g = faceareas(i,j,k,3)/dxdy + u = compute_u(xp,yp,zp) + v = compute_v(xp,yp,zp) + w = compute_w(xp,yp,zp) + + do jj = 1,3 + nv(jj) = zrot(i,j,k,1,jj) + end do + wn_scaled = g*(nv(1)*u + nv(2)*v + nv(3)*w) + + aux(i,j,k,mcapa + 1) = un_scaled + aux(i,j,k,mcapa + 2) = vn_scaled + aux(i,j,k,mcapa + 3) = wn_scaled + enddo + enddo + enddo + + return +end subroutine swirl_set_velocity_manifold + diff --git a/applications/clawpack/advection/3d/swirl/user_5.0/b4step2.f90 b/applications/clawpack/advection/3d/swirl/user_5.0/b4step2.f90 new file mode 100644 index 000000000..3a1a32f62 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/user_5.0/b4step2.f90 @@ -0,0 +1,41 @@ +SUBROUTINE clawpack5_b4step2(mbc,mx,my,meqn,q, & + xlower,ylower,dx,dy,time,dt,maux,aux) + IMPLICIT NONE + + INTEGER mbc,mx,my,maux,meqn + DOUBLE PRECISION xlower,ylower,dx,dy,time,dt + + DOUBLE PRECISION q(meqn,1-mbc:mx+mbc,1-mbc:my+mbc) + DOUBLE PRECISION aux(maux,1-mbc:mx+mbc,1-mbc:my+mbc) + + DOUBLE PRECISION tperiod, pi2 + COMMON /comvt/ tperiod,pi2 + + INTEGER i,j + DOUBLE PRECISION xll,yll, psi, vt + + IF (tperiod .EQ. 0.d0) THEN + !! # special case --- indication that velocities specified in + !! # setaux should be used for all time. + RETURN + ENDIF + + vt = dcos(pi2*(time+dt/2.d0)/tperiod) + + DO j=1-mbc,my+mbc + DO i=1-mbc,mx+mbc + !! # coordinates of lower left corner of grid cell: + xll = xlower + (i-1)*dx + yll = ylower + (j-1)*dy + + !! # difference stream function psi to get normal velocities: + aux(1,i,j) = -(psi(xll, yll+dy) - psi(xll,yll)) / dy + aux(2,i,j) = (psi(xll+dx, yll) - psi(xll,yll)) / dx + + !! # multiply by time-factor: + aux(1,i,j) = vt * aux(1,i,j) + aux(2,i,j) = vt * aux(2,i,j) + ENDDO + ENDDO + RETURN +END SUBROUTINE clawpack5_b4step2 diff --git a/applications/clawpack/advection/3d/swirl/user_5.0/qinit.f90 b/applications/clawpack/advection/3d/swirl/user_5.0/qinit.f90 new file mode 100644 index 000000000..5ae37da23 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/user_5.0/qinit.f90 @@ -0,0 +1,26 @@ +SUBROUTINE clawpack5_qinit(meqn,mbc,mx,my,xlower,ylower,dx,dy,q,maux,aux) + IMPLICIT NONE + + INTEGER meqn,mbc,mx,my,maux + DOUBLE PRECISION xlower,ylower,dx,dy + DOUBLE PRECISION q(meqn,1-mbc:mx+mbc, 1-mbc:my+mbc) + DOUBLE PRECISION aux(maux,1-mbc:mx+mbc, 1-mbc:my+mbc) + + INTEGER i,j,mq + DOUBLE PRECISION xi,yj + + do mq = 1,meqn + DO i = 1-mbc,mx+mbc + xi = xlower + (i-0.5d0)*dx + DO j = 1-mbc,my+mbc + yj = ylower + (j-0.5d0)*dy + IF (xi .LT. 0.5d0) THEN + q(mq,i,j) = 1.d0 + ELSE + q(mq,i,j) = 0.d0 + ENDIF + ENDDO + END DO + end do + +END SUBROUTINE clawpack5_qinit diff --git a/applications/clawpack/advection/3d/swirl/user_exceeds_th.f90 b/applications/clawpack/advection/3d/swirl/user_exceeds_th.f90 new file mode 100644 index 000000000..ae1e19c90 --- /dev/null +++ b/applications/clawpack/advection/3d/swirl/user_exceeds_th.f90 @@ -0,0 +1,33 @@ +!! # check to see if value exceeds threshold + +integer function fclaw3d_user_exceeds_th(blockno,& + qval,qmin,qmax,quad, & + dx,dy,dz,xc,yc,zc,threshold, & + init_flag, is_ghost) + implicit none + + double precision :: qval,qmin,qmax,threshold + double precision :: quad(-1:1,-1:1,-1:1) + double precision :: dx,dy, dz, xc, yc, zc + integer :: blockno, init_flag + logical(kind=4) :: is_ghost + integer :: refine + + !! Ghost cells from patch in right half are in region x < 0.5, and so + !! would fail tagging criteria + if (is_ghost) then + !! Don't use this result + fclaw3d_user_exceeds_th = -1 + return + endif + + !! Only refine in right half of domain + if (xc .gt. 0.5) then + refine = 1 + else + refine = 0 + endif + + fclaw3d_user_exceeds_th = refine + +end function fclaw3d_user_exceeds_th diff --git a/applications/clawpack/advection/3dx/all/advection_patch_setup_manifold.c b/applications/clawpack/advection/3dx/all/advection_patch_setup_manifold.c index 8ee9f473a..664b8edbc 100644 --- a/applications/clawpack/advection/3dx/all/advection_patch_setup_manifold.c +++ b/applications/clawpack/advection/3dx/all/advection_patch_setup_manifold.c @@ -25,25 +25,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "advection_user.h" -void claw3_advection_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void claw3_advection_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, int claw_version) { int mx,my,mz, mbc; double xlower,ylower,zlower, dx,dy, dz; - fclaw3dx_clawpatch_grid_data(glob,patch,&mx,&my,&mz, &mbc, + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, &mbc, &xlower,&ylower,&zlower, &dx,&dy, &dz); double *xd,*yd,*zd,*volume,*faceareas; double *xp,*yp,*zp; - fclaw3d_clawpatch_mesh_data(glob,patch,&xp,&yp,&zp, + fclaw_clawpatch_3d_mesh_data(glob,patch,&xp,&yp,&zp, &xd,&yd,&zd,&volume,&faceareas); int maux; double *aux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); if (claw_version == 4) CLAW3_SETAUX_MANIFOLD(&mbc,&mx,&my,&mz, &xlower,&ylower,&zlower, diff --git a/applications/clawpack/advection/3dx/all/advection_user.h b/applications/clawpack/advection/3dx/all/advection_user.h index a9050fabd..554da6cde 100644 --- a/applications/clawpack/advection/3dx/all/advection_user.h +++ b/applications/clawpack/advection/3dx/all/advection_user.h @@ -26,15 +26,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ADVECTION_USER_3D_H #define ADVECTION_USER_3D_H -#include +#include -#include +#include /* Headers for both Clawpack 4.6 and Clawpack 5.0 */ -#include -#include -#include +#include +#include +#include /* Clawpack 4.6 headers */ @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include +#include #if 0 /* Clawpack 5.0 headers */ @@ -66,8 +66,8 @@ extern "C" /* Fix syntax */ #endif -void claw3_advection_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void claw3_advection_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int block, int patchno, int claw_version); diff --git a/applications/clawpack/advection/3dx/disk/disk.cpp b/applications/clawpack/advection/3dx/disk/disk.cpp index f6346a0f0..a3baed3c6 100644 --- a/applications/clawpack/advection/3dx/disk/disk.cpp +++ b/applications/clawpack/advection/3dx/disk/disk.cpp @@ -27,17 +27,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../all/advection_user.h" -#include +#include static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* Check that we are running a manifold example */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); FCLAW_ASSERT(fclaw_opt->manifold != 0); /* Four aux array values required for this simulation */ - fclaw3dx_clawpatch_options_t *claw_opt = fclaw3dx_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *claw_opt = fclaw_clawpatch_get_options(glob); FCLAW_ASSERT(claw_opt->maux == 4); /* Used locally */ @@ -49,8 +49,8 @@ void create_domain(fclaw2d_global_t *glob) /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; /* Get 2d mapping */ const user_options_t *user_opt = disk_get_options(glob); @@ -59,7 +59,7 @@ void create_domain(fclaw2d_global_t *glob) case 1: /* Map unit square to the pillow disk using mapc2m_pillowdisk.f */ domain = - fclaw2d_domain_new_unitsquare (glob->mpicomm, + fclaw_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowdisk (fclaw_opt->scale, @@ -76,7 +76,7 @@ void create_domain(fclaw2d_global_t *glob) /* Map five-patch square to pillow disk. */ domain = - fclaw2d_domain_new_disk (glob->mpicomm, 0, 0, + fclaw_domain_new_2d_disk (glob->mpicomm, 0, 0, fclaw_opt->minlevel); cont = @@ -94,28 +94,23 @@ void create_domain(fclaw2d_global_t *glob) disk_map_extrude(cont,user_opt->maxelev); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = disk_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -133,9 +128,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -146,12 +141,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw3dx_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc3d_clawpack46_options_t *claw46_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app,NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw3dx_clawpatch_options_register(app,"clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_3d_options_register(app,"clawpatch", "fclaw_options.ini"); claw46_opt = fc3d_clawpack46_options_register(app,"claw3", "fclaw_options.ini"); user_opt = disk_options_register(app,"fclaw_options.ini"); @@ -168,11 +163,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw3dx_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc3d_clawpack46_options_store (glob, claw46_opt); disk_options_store (glob, user_opt); @@ -182,7 +177,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/3dx/disk/disk_map_extrude.c b/applications/clawpack/advection/3dx/disk/disk_map_extrude.c index 4838c5138..2bdc0a93d 100644 --- a/applications/clawpack/advection/3dx/disk/disk_map_extrude.c +++ b/applications/clawpack/advection/3dx/disk/disk_map_extrude.c @@ -4,7 +4,7 @@ #include "../all/advection_user.h" static void -disk_map_3dx(fclaw2d_map_context_t * cont, +disk_map_3dx(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) @@ -14,7 +14,7 @@ disk_map_3dx(fclaw2d_map_context_t * cont, shifted or rotated. */ cont->mapc2m(cont,blockno,xc,yc,xp,yp,zp); - double maxelev = cont->user_double_3dx[0]; + double maxelev = cont->user_double_3d[0]; /* Extrude surface map in z direction */ *zp = maxelev*zc; @@ -23,12 +23,12 @@ disk_map_3dx(fclaw2d_map_context_t * cont, shift_map(cont,xp,yp,zp); } -void disk_map_extrude(fclaw2d_map_context_t *cont, +void disk_map_extrude(fclaw_map_context_t *cont, const double maxelev) { /* Modify the 2d mapping to included extruded details */ - cont->mapc2m_3dx = disk_map_3dx; - cont->user_double_3dx[0] = maxelev; + cont->mapc2m_3d = disk_map_3dx; + cont->user_double_3d[0] = maxelev; cont->is_extruded = 1; } diff --git a/applications/clawpack/advection/3dx/disk/disk_options.c b/applications/clawpack/advection/3dx/disk/disk_options.c index c0b86bc1d..906ecc487 100644 --- a/applications/clawpack/advection/3dx/disk/disk_options.c +++ b/applications/clawpack/advection/3dx/disk/disk_options.c @@ -161,18 +161,18 @@ user_options_t* disk_options_register (fclaw_app_t * app, return user_opt; } -void disk_options_store (fclaw2d_global_t* glob, user_options_t* user_opt) +void disk_options_store (fclaw_global_t* glob, user_options_t* user_opt) { - fclaw2d_global_options_store(glob, "user", user_opt); + fclaw_global_options_store(glob, "user", user_opt); } -const user_options_t* disk_get_options(fclaw2d_global_t* glob) +const user_options_t* disk_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } void disk_global_post_process(fclaw_options_t *fclaw_opt, - fclaw3dx_clawpatch_options_t *clawpatch_opt, + fclaw_clawpatch_options_t *clawpatch_opt, user_options_t *user_opt) { /* Check that we have enough resolution to handle cubed sphere corners */ diff --git a/applications/clawpack/advection/3dx/disk/disk_user.cpp b/applications/clawpack/advection/3dx/disk/disk_user.cpp index 6b421e7d4..54b66b2f9 100644 --- a/applications/clawpack/advection/3dx/disk/disk_user.cpp +++ b/applications/clawpack/advection/3dx/disk/disk_user.cpp @@ -26,10 +26,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "disk_user.h" static -void disk_problem_setup(fclaw2d_global_t* glob) +void disk_problem_setup(fclaw_global_t* glob) { const user_options_t* user = disk_get_options(glob); - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (glob->mpirank == 0) { FILE *f = fopen("setprob.data","w"); @@ -38,13 +38,13 @@ void disk_problem_setup(fclaw2d_global_t* glob) fprintf(f, "%-24.4f %s",user->alpha,"\% alpha\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } static -void disk_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void disk_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -54,12 +54,12 @@ void disk_patch_setup(fclaw2d_global_t *glob, } -void disk_link_solvers(fclaw2d_global_t *glob) +void disk_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = disk_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = disk_problem_setup; - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = disk_patch_setup; /* Check that mcapa is set */ diff --git a/applications/clawpack/advection/3dx/disk/disk_user.h b/applications/clawpack/advection/3dx/disk/disk_user.h index 4c33d87ef..8b6a475bc 100644 --- a/applications/clawpack/advection/3dx/disk/disk_user.h +++ b/applications/clawpack/advection/3dx/disk/disk_user.h @@ -50,17 +50,17 @@ typedef struct user_options user_options_t* disk_options_register (fclaw_app_t * app, const char *configfile); -void disk_options_store (fclaw2d_global_t* glob, user_options_t* user_opt); +void disk_options_store (fclaw_global_t* glob, user_options_t* user_opt); -const user_options_t* disk_get_options(fclaw2d_global_t* glob); +const user_options_t* disk_get_options(fclaw_global_t* glob); -void disk_link_solvers(fclaw2d_global_t *glob); +void disk_link_solvers(fclaw_global_t *glob); void disk_global_post_process(fclaw_options_t *fclaw_opt, - fclaw3dx_clawpatch_options_t *clawpatch_opt, + fclaw_clawpatch_options_t *clawpatch_opt, user_options_t *user_opt); -void disk_map_extrude(fclaw2d_map_context_t *cont, +void disk_map_extrude(fclaw_map_context_t *cont, const double maxelev); diff --git a/applications/clawpack/advection/3dx/disk/fdisc.f90 b/applications/clawpack/advection/3dx/disk/fdisc.f90 index d9f700fa5..0b8a86ffa 100644 --- a/applications/clawpack/advection/3dx/disk/fdisc.f90 +++ b/applications/clawpack/advection/3dx/disk/fdisc.f90 @@ -9,7 +9,7 @@ double precision function fdisc(blockno,xc,yc,zc) cont = fclaw_map_get_context() - call fclaw3d_map_c2m(cont,blockno,xc,yc,zc,xp,yp,zp) + call fclaw_map_3d_c2m(cont,blockno,xc,yc,zc,xp,yp,zp) r = sqrt((xp-0.5d0)**2 + (yp-1.d0)**2) diff --git a/applications/clawpack/advection/3dx/filament/fclaw2d_map_cart.c b/applications/clawpack/advection/3dx/filament/fclaw2d_map_cart.c index 0197988ad..50e990019 100644 --- a/applications/clawpack/advection/3dx/filament/fclaw2d_map_cart.c +++ b/applications/clawpack/advection/3dx/filament/fclaw2d_map_cart.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -11,41 +11,41 @@ extern "C" #endif static int -fclaw2d_map_query_cart (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_cart (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -60,24 +60,24 @@ fclaw2d_map_query_cart (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_cart(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_cart(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* Brick mapping to computational coordinates [0,1]x[0,1] */ double xc1, yc1, zc1; - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); /* Unit square in [-1,1] x [-1,1] */ - MAPC2M_CART(&blockno,&xc1,&yc1,xp,yp,zp); + FCLAW_MAP_2D_C2M_CART(&blockno,&xc1,&yc1,xp,yp,zp); scale_map(cont, xp,yp,zp); shift_map(cont, xp,yp,zp); } static void -fclaw3dx_map_c2m_cart(fclaw2d_map_context_t * cont, int blockno, +fclaw3dx_map_c2m_cart(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) { @@ -85,7 +85,7 @@ fclaw3dx_map_c2m_cart(fclaw2d_map_context_t * cont, int blockno, For 3dx version, zc1 will be returned as 0. */ double xc1, yc1, zc_zero; - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc_zero); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc_zero); /* Unit cube in [-1,1] x [-1,1] x [-1,1] */ @@ -99,16 +99,16 @@ fclaw3dx_map_c2m_cart(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_cart(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_cart(fclaw_map_context_t *brick, const double scale[], const double shift[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_cart; cont->mapc2m = fclaw2d_map_c2m_cart; - cont->mapc2m_3dx = fclaw2d_map_c2m_cart_3dx; + cont->mapc2m_3d = fclaw2d_map_c2m_cart_3dx; cont->brick = brick; set_scale(cont,scale); diff --git a/applications/clawpack/advection/3dx/filament/fdisc.f b/applications/clawpack/advection/3dx/filament/fdisc.f index 9fa3d033e..553e79111 100644 --- a/applications/clawpack/advection/3dx/filament/fdisc.f +++ b/applications/clawpack/advection/3dx/filament/fdisc.f @@ -5,14 +5,14 @@ double precision function fdisc(blockno,xc,yc,zc) double precision xc,yc, zc integer*8 cont, fclaw_map_get_context - integer fclaw2d_map_is_used + integer fclaw_map_is_used double precision r, xp, yp, zp cont = fclaw_map_get_context() - if (fclaw2d_map_is_used(cont) .ne. 0) then - call fclaw3d_map_c2m(cont, + if (fclaw_map_is_used(cont) .ne. 0) then + call fclaw_map_3d_c2m(cont, & blockno,xc,yc,zc,xp,yp,zp) else xp = xc diff --git a/applications/clawpack/advection/3dx/filament/filament.cpp b/applications/clawpack/advection/3dx/filament/filament.cpp index 29267198a..553b8e8da 100644 --- a/applications/clawpack/advection/3dx/filament/filament.cpp +++ b/applications/clawpack/advection/3dx/filament/filament.cpp @@ -28,22 +28,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../all/advection_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; int a = 0; /* non-periodic */ int b = 0; - fclaw3dx_clawpatch_options_t *clawpatch_opt = - fclaw3dx_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; int minlevel = fclaw_opt->minlevel; int check = mi*mx*pow_int(2,minlevel); - fclaw2d_map_context_t *cont, *brick; - fclaw2d_domain_t *domain = NULL; + fclaw_map_context_t *cont, *brick; + fclaw_domain_t *domain = NULL; fc3d_clawpack46_options_t *claw3_opt = fc3d_clawpack46_get_options(glob); const user_options_t *user = filament_get_options(glob); @@ -56,13 +56,13 @@ void create_domain(fclaw2d_global_t *glob) /* Size is set by [ax,bx] x [ay, by], set in .ini file */ /* Mapped, multi-block domain */ domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Size is set by [ax,bx] x [ay, by], set in .ini file */ - brick = fclaw2d_map_new_brick(domain,mi,mj,a,b); + brick = fclaw_map_new_2d_brick(domain,mi,mj,a,b); - cont = fclaw2d_map_new_nomap_brick(brick); + cont = fclaw_map_new_nomap_brick(brick); break; case 1: @@ -72,10 +72,10 @@ void create_domain(fclaw2d_global_t *glob) /* Cartesian square domain */ domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick(domain,mi,mj,a,b); + brick = fclaw_map_new_2d_brick(domain,mi,mj,a,b); /* Square in [-1,1]x[-1,1], scaled/shifted to [0,1]x[0,1] */ cont = fclaw2d_map_new_cart(brick, @@ -93,7 +93,7 @@ void create_domain(fclaw2d_global_t *glob) } /* Five patch square domain */ domain = - fclaw2d_domain_new_disk(glob->mpicomm, 0,0, + fclaw_domain_new_2d_disk(glob->mpicomm, 0,0, fclaw_opt->minlevel); cont = fclaw2d_map_new_fivepatch(fclaw_opt->scale, @@ -106,10 +106,10 @@ void create_domain(fclaw2d_global_t *glob) FCLAW_ASSERT(mi == 2 && mj == 2); FCLAW_ASSERT(fclaw_opt->manifold != 0); domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick (domain, mi, mj, a, b); + brick = fclaw_map_new_2d_brick (domain, mi, mj, a, b); cont = fclaw2d_map_new_bilinear(brick, fclaw_opt->scale, @@ -125,29 +125,23 @@ void create_domain(fclaw2d_global_t *glob) filament_map_extrude(cont,user->maxelev); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { user_options_t *user = (user_options_t*) filament_get_options(glob); - - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); if (user->claw_version == 4) { @@ -161,9 +155,9 @@ void run_program(fclaw2d_global_t* glob) filament_link_solvers(glob); - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } @@ -177,12 +171,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw3dx_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc3d_clawpack46_options_t *claw46_opt; /* Register packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw3dx_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_3d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc3d_clawpack46_options_register(app, "claw3", "fclaw_options.ini"); user_opt = filament_options_register(app, "fclaw_options.ini"); @@ -196,10 +190,10 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); - fclaw2d_options_store (glob, fclaw_opt); - fclaw3dx_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc3d_clawpack46_options_store (glob, claw46_opt); filament_options_store (glob, user_opt); @@ -208,7 +202,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/3dx/filament/filament_map_extrude.c b/applications/clawpack/advection/3dx/filament/filament_map_extrude.c index cb7cfae3a..73d5c892a 100644 --- a/applications/clawpack/advection/3dx/filament/filament_map_extrude.c +++ b/applications/clawpack/advection/3dx/filament/filament_map_extrude.c @@ -28,7 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* User defined extruded mesh mapping */ static void -filament_map_3dx(fclaw2d_map_context_t * cont, int blockno, +filament_map_3dx(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) { @@ -37,7 +37,7 @@ filament_map_3dx(fclaw2d_map_context_t * cont, int blockno, cont->mapc2m(cont,blockno,xc,yc,xp,yp,zp); /* Extrude in z direction to constant height maxelev. */ - double maxelev = cont->user_double_3dx[0]; + double maxelev = cont->user_double_3d[0]; *zp = maxelev*zc; /* Whether it makes sense to scale/shift this mapping is up to the user */ @@ -46,14 +46,14 @@ filament_map_3dx(fclaw2d_map_context_t * cont, int blockno, } -void filament_map_extrude(fclaw2d_map_context_t* cont, +void filament_map_extrude(fclaw_map_context_t* cont, const double maxelev) { /* May be needed to get more general mappings */ - cont->mapc2m_3dx = filament_map_3dx; + cont->mapc2m_3d = filament_map_3dx; - cont->user_double_3dx[0] = maxelev; + cont->user_double_3d[0] = maxelev; cont->is_extruded = 1; diff --git a/applications/clawpack/advection/3dx/filament/filament_options.c b/applications/clawpack/advection/3dx/filament/filament_options.c index 866800fa1..f7f5750ea 100644 --- a/applications/clawpack/advection/3dx/filament/filament_options.c +++ b/applications/clawpack/advection/3dx/filament/filament_options.c @@ -168,12 +168,12 @@ user_options_t* filament_options_register (fclaw_app_t * app, return user; } -void filament_options_store (fclaw2d_global_t* glob, user_options_t* user) +void filament_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* filament_get_options(fclaw2d_global_t* glob) +const user_options_t* filament_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/3dx/filament/filament_user.cpp b/applications/clawpack/advection/3dx/filament/filament_user.cpp index 04ceab7aa..7ffa16db8 100644 --- a/applications/clawpack/advection/3dx/filament/filament_user.cpp +++ b/applications/clawpack/advection/3dx/filament/filament_user.cpp @@ -26,10 +26,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "filament_user.h" -void filament_problem_setup(fclaw2d_global_t *glob) +void filament_problem_setup(fclaw_global_t *glob) { const user_options_t* user = filament_get_options(glob); - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (glob->mpirank == 0) { FILE *f = fopen("setprob.data","w"); @@ -41,13 +41,13 @@ void filament_problem_setup(fclaw2d_global_t *glob) fprintf(f, "%-24.4f %s",user->maxelev,"\% max_elevation\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } static -void filament_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void filament_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -57,17 +57,17 @@ void filament_patch_setup(fclaw2d_global_t *glob, } -void filament_link_solvers(fclaw2d_global_t *glob) +void filament_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = filament_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = filament_problem_setup; - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); const user_options_t* user = filament_get_options(glob); /* example of how to set up a user defined criteria */ - fclaw3dx_clawpatch_vtable_t *clawpatch_vt = fclaw3dx_clawpatch_vt(glob); - clawpatch_vt->fort_user_exceeds_threshold = &FCLAW3DX_USER_EXCEEDS_TH; + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + clawpatch_vt->d3->fort_user_exceeds_threshold = &FCLAW3D_USER_EXCEEDS_TH; if (user->claw_version == 4) { @@ -86,7 +86,7 @@ void filament_link_solvers(fclaw2d_global_t *glob) { /* This calls a manifold version of setaux */ FCLAW_ASSERT(clawopt->mcapa != 0); - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = filament_patch_setup; } else diff --git a/applications/clawpack/advection/3dx/filament/filament_user.h b/applications/clawpack/advection/3dx/filament/filament_user.h index 6ee3d15d6..3c528e501 100644 --- a/applications/clawpack/advection/3dx/filament/filament_user.h +++ b/applications/clawpack/advection/3dx/filament/filament_user.h @@ -59,13 +59,13 @@ typedef struct user_options user_options_t* filament_options_register (fclaw_app_t * app, const char *configfile); -void filament_options_store (fclaw2d_global_t* glob, user_options_t* user); +void filament_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* filament_get_options(fclaw2d_global_t* glob); +const user_options_t* filament_get_options(fclaw_global_t* glob); -void filament_link_solvers(fclaw2d_global_t *glob); +void filament_link_solvers(fclaw_global_t *glob); -void filament_map_extrude(fclaw2d_map_context_t* cont, +void filament_map_extrude(fclaw_map_context_t* cont, const double maxelev); diff --git a/applications/clawpack/advection/3dx/filament/user_exceeds_th.f90 b/applications/clawpack/advection/3dx/filament/user_exceeds_th.f90 index ebb96bebe..0d9c395f7 100644 --- a/applications/clawpack/advection/3dx/filament/user_exceeds_th.f90 +++ b/applications/clawpack/advection/3dx/filament/user_exceeds_th.f90 @@ -1,6 +1,6 @@ !! # check to see if value exceeds threshold -integer function fclaw3dx_user_exceeds_th(blockno,& +integer function fclaw3d_user_exceeds_th(blockno,& qval,qmin,qmax,quad, & dx,dy,dz,xc,yc,zc,threshold, & init_flag, is_ghost) @@ -14,14 +14,14 @@ integer function fclaw3dx_user_exceeds_th(blockno,& integer :: refine integer*8 cont, fclaw_map_get_context - integer fclaw2d_map_is_used + integer fclaw_map_is_used double precision xp, yp, zp cont = fclaw_map_get_context() - if (fclaw2d_map_is_used(cont) .ne. 0) then - call fclaw3d_map_c2m(cont,blockno,xc,yc,zc,xp,yp,zp) + if (fclaw_map_is_used(cont) .ne. 0) then + call fclaw_map_3d_c2m(cont,blockno,xc,yc,zc,xp,yp,zp) else xp = xc yp = yc @@ -33,7 +33,7 @@ integer function fclaw3dx_user_exceeds_th(blockno,& !! would fail tagging criteria if (is_ghost) then !! Don't use this result - fclaw3dx_user_exceeds_th = -1 + fclaw3d_user_exceeds_th = -1 return endif @@ -44,6 +44,6 @@ integer function fclaw3dx_user_exceeds_th(blockno,& refine = 0 endif - fclaw3dx_user_exceeds_th = refine + fclaw3d_user_exceeds_th = refine -end function fclaw3dx_user_exceeds_th +end function fclaw3d_user_exceeds_th diff --git a/applications/clawpack/advection/3dx/latlong/fdisc.f b/applications/clawpack/advection/3dx/latlong/fdisc.f index 9082e1eaf..d765a276b 100644 --- a/applications/clawpack/advection/3dx/latlong/fdisc.f +++ b/applications/clawpack/advection/3dx/latlong/fdisc.f @@ -11,7 +11,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) c # Torus or annulus diff --git a/applications/clawpack/advection/3dx/latlong/latlong.cpp b/applications/clawpack/advection/3dx/latlong/latlong.cpp index 09aacc415..78232fd7f 100644 --- a/applications/clawpack/advection/3dx/latlong/latlong.cpp +++ b/applications/clawpack/advection/3dx/latlong/latlong.cpp @@ -24,19 +24,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Needed for 2d mappings */ -#include +#include #include "latlong_user.h" #include "../all/advection_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* --------------------------------------------------------------- Mapping geometry --------------------------------------------------------------- */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); FCLAW_ASSERT(fclaw_opt->manifold != 0); /* Used locally */ @@ -52,17 +52,17 @@ void create_domain(fclaw2d_global_t *glob) /* Create brick domain with periodicity */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_t *domain = + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Create brick mapping */ - fclaw2d_map_context_t *brick = - fclaw2d_map_new_brick(domain, mi, mj, a, b); + fclaw_map_context_t *brick = + fclaw_map_new_2d_brick(domain, mi, mj, a, b); /* Create latlong mapping based on brick */ const user_options_t *user = latlong_get_options(glob); - fclaw2d_map_context_t *cont = + fclaw_map_context_t *cont = fclaw2d_map_new_latlong(brick,fclaw_opt->scale, rotate, user->latitude, @@ -72,28 +72,23 @@ void create_domain(fclaw2d_global_t *glob) latlong_map_extrude(cont,user->maxelev); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = latlong_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -111,9 +106,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -125,12 +120,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw3dx_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc3d_clawpack46_options_t *claw46_opt; /* Register packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw3dx_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_3d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc3d_clawpack46_options_register(app, "claw3", "fclaw_options.ini"); user_opt = latlong_options_register(app, "fclaw_options.ini"); @@ -144,10 +139,10 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); - fclaw2d_options_store (glob, fclaw_opt); - fclaw3dx_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc3d_clawpack46_options_store (glob, claw46_opt); latlong_options_store (glob, user_opt); @@ -156,7 +151,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy (glob); + fclaw_global_destroy (glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/3dx/latlong/latlong_map_extrude.c b/applications/clawpack/advection/3dx/latlong/latlong_map_extrude.c index c01e34430..80b5b2cd7 100644 --- a/applications/clawpack/advection/3dx/latlong/latlong_map_extrude.c +++ b/applications/clawpack/advection/3dx/latlong/latlong_map_extrude.c @@ -29,12 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* For 2d mappings */ #include "../all/advection_user.h" -#include +#include /* User defined extruded mesh mapping */ static void -latlong_map_3dx(fclaw2d_map_context_t * cont, int blockno, +latlong_map_3dx(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) { @@ -56,7 +56,7 @@ latlong_map_3dx(fclaw2d_map_context_t * cont, int blockno, double rp = sqrt(pow(xp1,2) + pow(yp1,2) + pow(zp1,2)); /* Extrude in z direction to constant height maxelev. */ - double maxelev = cont->user_double_3dx[0]; + double maxelev = cont->user_double_3d[0]; double R = rp + maxelev*zc; *xp = R*cos(phi)*cos(theta); *yp = R*cos(phi)*sin(theta); @@ -64,14 +64,14 @@ latlong_map_3dx(fclaw2d_map_context_t * cont, int blockno, } -void latlong_map_extrude(fclaw2d_map_context_t* cont, +void latlong_map_extrude(fclaw_map_context_t* cont, const double maxelev) { /* May be needed to get more general mappings */ - cont->mapc2m_3dx = latlong_map_3dx; + cont->mapc2m_3d = latlong_map_3dx; - cont->user_double_3dx[0] = maxelev; + cont->user_double_3d[0] = maxelev; cont->is_extruded = 1; diff --git a/applications/clawpack/advection/3dx/latlong/latlong_options.c b/applications/clawpack/advection/3dx/latlong/latlong_options.c index 7270e7bf0..532a9be57 100644 --- a/applications/clawpack/advection/3dx/latlong/latlong_options.c +++ b/applications/clawpack/advection/3dx/latlong/latlong_options.c @@ -172,14 +172,14 @@ user_options_t* latlong_options_register (fclaw_app_t * app, return user; } -void latlong_options_store (fclaw2d_global_t* glob, user_options_t* user) +void latlong_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* latlong_get_options(fclaw2d_global_t* glob) +const user_options_t* latlong_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/3dx/latlong/latlong_user.cpp b/applications/clawpack/advection/3dx/latlong/latlong_user.cpp index 1788dbb7f..5ec00f4df 100644 --- a/applications/clawpack/advection/3dx/latlong/latlong_user.cpp +++ b/applications/clawpack/advection/3dx/latlong/latlong_user.cpp @@ -26,10 +26,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "latlong_user.h" -void latlong_problem_setup(fclaw2d_global_t *glob) +void latlong_problem_setup(fclaw_global_t *glob) { const user_options_t* user = latlong_get_options(glob); - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (glob->mpirank == 0) { FILE *f = fopen("setprob.data","w"); @@ -43,13 +43,13 @@ void latlong_problem_setup(fclaw2d_global_t *glob) fprintf(f, "%-24.6f %s",user->maxelev,"\% max_elevation\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } static -void latlong_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void latlong_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -58,16 +58,16 @@ void latlong_patch_setup(fclaw2d_global_t *glob, user->claw_version); } -void latlong_link_solvers(fclaw2d_global_t *glob) +void latlong_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); + fclaw_vtable_t *fc_vt = fclaw_vt(glob); - fclaw_vt->problem_setup = latlong_problem_setup; + fc_vt->problem_setup = latlong_problem_setup; - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &latlong_patch_setup; - fclaw3dx_clawpatch_options_t *clawpatch_opt = fclaw3dx_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); FCLAW_ASSERT(clawpatch_opt->maux == 4); const user_options_t *user = latlong_get_options(glob); @@ -80,7 +80,7 @@ void latlong_link_solvers(fclaw2d_global_t *glob) FCLAW_ASSERT(clawopt->mcapa != 0); /* This calls a manifold version of setaux */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = latlong_patch_setup; clawpack46_vt->fort_qinit = &CLAWPACK46_QINIT; diff --git a/applications/clawpack/advection/3dx/latlong/latlong_user.h b/applications/clawpack/advection/3dx/latlong/latlong_user.h index 27bd7d28c..5d820a257 100644 --- a/applications/clawpack/advection/3dx/latlong/latlong_user.h +++ b/applications/clawpack/advection/3dx/latlong/latlong_user.h @@ -55,17 +55,17 @@ typedef struct user_options } user_options_t; -void latlong_link_solvers(fclaw2d_global_t *glob); +void latlong_link_solvers(fclaw_global_t *glob); user_options_t* latlong_options_register (fclaw_app_t * app, const char *configfile);\ -void latlong_options_store (fclaw2d_global_t* glob, user_options_t* user); +void latlong_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* latlong_get_options(fclaw2d_global_t* glob); +const user_options_t* latlong_get_options(fclaw_global_t* glob); /* Local mapping that is user defined. */ -void latlong_map_extrude (fclaw2d_map_context_t* cont, +void latlong_map_extrude (fclaw_map_context_t* cont, const double maxelev); diff --git a/applications/clawpack/advection/3dx/sphere/fdisc.f b/applications/clawpack/advection/3dx/sphere/fdisc.f index 6bcf345bc..b4d9d62ad 100644 --- a/applications/clawpack/advection/3dx/sphere/fdisc.f +++ b/applications/clawpack/advection/3dx/sphere/fdisc.f @@ -12,7 +12,7 @@ double precision function fdisc(blockno,xc,yc,zc) cont = fclaw_map_get_context() - call fclaw3d_map_c2m(cont, + call fclaw_map_3d_c2m(cont, & blockno,xc,yc,zc,xp,yp,zp) rp = sqrt(xp**2 + yp**2 + zp**2) diff --git a/applications/clawpack/advection/3dx/sphere/sphere.cpp b/applications/clawpack/advection/3dx/sphere/sphere.cpp index 2d1fb5e81..d169f2419 100644 --- a/applications/clawpack/advection/3dx/sphere/sphere.cpp +++ b/applications/clawpack/advection/3dx/sphere/sphere.cpp @@ -26,12 +26,12 @@ #include "sphere_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); FCLAW_ASSERT(fclaw_opt->manifold != 0); - fclaw3dx_clawpatch_options_t *claw_opt = fclaw3dx_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *claw_opt = fclaw_clawpatch_get_options(glob); FCLAW_ASSERT(claw_opt->maux == 4); @@ -42,20 +42,20 @@ void create_domain(fclaw2d_global_t *glob) rotate[1] = pi*fclaw_opt->phi/180.0; /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; const user_options_t *user_opt = sphere_get_options(glob); switch (user_opt->example) { case 1: domain = - fclaw2d_domain_new_cubedsphere (glob->mpicomm, + fclaw_domain_new_2d_cubedsphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_cubedsphere (fclaw_opt->scale, rotate); break; case 2: domain = - fclaw2d_domain_new_twosphere (glob->mpicomm, fclaw_opt->minlevel); + fclaw_domain_new_2d_twosphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowsphere (fclaw_opt->scale, rotate); break; @@ -66,28 +66,23 @@ void create_domain(fclaw2d_global_t *glob) sphere_map_extrude(cont,user_opt->maxelev); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = sphere_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -105,9 +100,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -119,12 +114,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw3dx_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc3d_clawpack46_options_t *claw46_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app,NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw3dx_clawpatch_options_register(app,"clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_3d_options_register(app,"clawpatch", "fclaw_options.ini"); claw46_opt = fc3d_clawpack46_options_register(app,"claw3", "fclaw_options.ini"); user_opt = sphere_options_register(app,"fclaw_options.ini"); @@ -138,11 +133,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw3dx_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc3d_clawpack46_options_store (glob, claw46_opt); sphere_options_store (glob, user_opt); @@ -152,7 +147,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/3dx/sphere/sphere_map_extrude.c b/applications/clawpack/advection/3dx/sphere/sphere_map_extrude.c index 61b1ff40f..3f0c6442c 100644 --- a/applications/clawpack/advection/3dx/sphere/sphere_map_extrude.c +++ b/applications/clawpack/advection/3dx/sphere/sphere_map_extrude.c @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* User defined extruded mesh mapping */ static void -sphere_map_3dx(fclaw2d_map_context_t * cont, int blockno, +sphere_map_3dx(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) { @@ -53,7 +53,7 @@ sphere_map_3dx(fclaw2d_map_context_t * cont, int blockno, double rp = sqrt(pow(xp1,2) + pow(yp1,2) + pow(zp1,2)); /* Extrude in z direction to constant height maxelev. */ - double maxelev = cont->user_double_3dx[0]; + double maxelev = cont->user_double_3d[0]; double R = rp + maxelev*zc; *xp = R*cos(phi)*cos(theta); *yp = R*cos(phi)*sin(theta); @@ -63,14 +63,14 @@ sphere_map_3dx(fclaw2d_map_context_t * cont, int blockno, } -void sphere_map_extrude(fclaw2d_map_context_t* cont, +void sphere_map_extrude(fclaw_map_context_t* cont, const double maxelev) { /* May be needed to get more general mappings */ - cont->mapc2m_3dx = sphere_map_3dx; + cont->mapc2m_3d = sphere_map_3dx; - cont->user_double_3dx[0] = maxelev; + cont->user_double_3d[0] = maxelev; cont->is_extruded = 1; diff --git a/applications/clawpack/advection/3dx/sphere/sphere_options.c b/applications/clawpack/advection/3dx/sphere/sphere_options.c index e1a0e06ba..d8e5ee2c1 100644 --- a/applications/clawpack/advection/3dx/sphere/sphere_options.c +++ b/applications/clawpack/advection/3dx/sphere/sphere_options.c @@ -158,13 +158,13 @@ user_options_t* sphere_options_register (fclaw_app_t * app, return user; } -void sphere_options_store (fclaw2d_global_t* glob, user_options_t* user) +void sphere_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* sphere_get_options(fclaw2d_global_t* glob) +const user_options_t* sphere_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/3dx/sphere/sphere_user.cpp b/applications/clawpack/advection/3dx/sphere/sphere_user.cpp index a7f29b9e7..adb4f0662 100644 --- a/applications/clawpack/advection/3dx/sphere/sphere_user.cpp +++ b/applications/clawpack/advection/3dx/sphere/sphere_user.cpp @@ -25,13 +25,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "sphere_user.h" -#include +#include static -void sphere_problem_setup(fclaw2d_global_t* glob) +void sphere_problem_setup(fclaw_global_t* glob) { const user_options_t *user = sphere_get_options(glob); - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (glob->mpirank == 0) { @@ -43,13 +43,13 @@ void sphere_problem_setup(fclaw2d_global_t* glob) fclose(f); } - fclaw2d_domain_barrier(glob->domain); + fclaw_domain_barrier(glob->domain); SETPROB(); } static -void sphere_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void sphere_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -59,19 +59,19 @@ void sphere_patch_setup(fclaw2d_global_t *glob, } -void sphere_link_solvers(fclaw2d_global_t *glob) +void sphere_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &sphere_problem_setup; /* Version-independent */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &sphere_patch_setup; const user_options_t* user = sphere_get_options(glob); if (user->example == 2) { /* Needed to get correct handling of block corners */ - fclaw3dx_clawpatch_use_pillowsphere(glob); + fclaw_clawpatch_use_pillowsphere(glob); } diff --git a/applications/clawpack/advection/3dx/sphere/sphere_user.h b/applications/clawpack/advection/3dx/sphere/sphere_user.h index c775cccaa..01715fccf 100644 --- a/applications/clawpack/advection/3dx/sphere/sphere_user.h +++ b/applications/clawpack/advection/3dx/sphere/sphere_user.h @@ -50,13 +50,13 @@ typedef struct user_options user_options_t* sphere_options_register (fclaw_app_t * app, const char *configfile); -void sphere_options_store (fclaw2d_global_t* glob, user_options_t* user); +void sphere_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* sphere_get_options(fclaw2d_global_t* glob); +const user_options_t* sphere_get_options(fclaw_global_t* glob); -void sphere_link_solvers(fclaw2d_global_t *glob); +void sphere_link_solvers(fclaw_global_t *glob); -void sphere_map_extrude(fclaw2d_map_context_t* cont, +void sphere_map_extrude(fclaw_map_context_t* cont, const double maxelev); diff --git a/applications/clawpack/advection/3dx/swirl/fdisc.f b/applications/clawpack/advection/3dx/swirl/fdisc.f index a571e84a5..f4389dfe3 100644 --- a/applications/clawpack/advection/3dx/swirl/fdisc.f +++ b/applications/clawpack/advection/3dx/swirl/fdisc.f @@ -5,14 +5,14 @@ double precision function fdisc(blockno,xc,yc,zc) double precision xc,yc, zc integer*8 cont, fclaw_map_get_context - integer fclaw2d_map_is_used + integer fclaw_map_is_used double precision xp, yp, zp cont = fclaw_map_get_context() - if (fclaw2d_map_is_used(cont) .ne. 0) then - call fclaw3d_map_c2m(cont, + if (fclaw_map_is_used(cont) .ne. 0) then + call fclaw_map_3d_c2m(cont, & blockno,xc,yc,zc,xp,yp,zp) else xp = xc diff --git a/applications/clawpack/advection/3dx/swirl/swirl.cpp b/applications/clawpack/advection/3dx/swirl/swirl.cpp index 4bb793542..3162f1c0f 100644 --- a/applications/clawpack/advection/3dx/swirl/swirl.cpp +++ b/applications/clawpack/advection/3dx/swirl/swirl.cpp @@ -28,9 +28,9 @@ #include static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); /* Mapped, multi-block domain */ int mi = fclaw_opt->mi; @@ -38,14 +38,14 @@ void create_domain(fclaw2d_global_t *glob) int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; - fclaw3dx_clawpatch_options_t *clawpatch_opt = - fclaw3dx_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; int minlevel = fclaw_opt->minlevel; int check = mi*mx*pow_int(2,minlevel); - fclaw2d_map_context_t *cont, *brick; - fclaw2d_domain_t *domain = NULL; + fclaw_map_context_t *cont, *brick; + fclaw_domain_t *domain = NULL; fc3d_clawpack46_options_t *claw3_opt = fc3d_clawpack46_get_options(glob); const user_options_t *user = swirl_get_options(glob); @@ -56,11 +56,11 @@ void create_domain(fclaw2d_global_t *glob) FCLAW_ASSERT(fclaw_opt->manifold == 0); /* Mapped, multi-block domain */ - domain = fclaw2d_domain_new_unitsquare(glob->mpicomm, + domain = fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); /* Size is set by [ax,bx] x [ay, by], set in .ini file */ - cont = fclaw2d_map_new_nomap(); + cont = fclaw_map_new_nomap(); break; case 1: @@ -71,10 +71,10 @@ void create_domain(fclaw2d_global_t *glob) /* Cartesian square domain */ domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick(domain,mi,mj,a,b); + brick = fclaw_map_new_2d_brick(domain,mi,mj,a,b); /* Square in [-1,1]x[-1,1], scaled/shifted to [0,1]x[0,1] */ cont = fclaw2d_map_new_cart(brick, @@ -95,7 +95,7 @@ void create_domain(fclaw2d_global_t *glob) } /* Five patch square domain */ domain = - fclaw2d_domain_new_disk(glob->mpicomm, 0,0, + fclaw_domain_new_2d_disk(glob->mpicomm, 0,0, fclaw_opt->minlevel); cont = fclaw2d_map_new_fivepatch(fclaw_opt->scale, @@ -112,10 +112,10 @@ void create_domain(fclaw2d_global_t *glob) FCLAW_ASSERT(mi == 2 && mj == 2); domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick (domain, mi, mj, a, b); + brick = fclaw_map_new_2d_brick (domain, mi, mj, a, b); cont = fclaw2d_map_new_bilinear(brick, fclaw_opt->scale, @@ -132,28 +132,23 @@ void create_domain(fclaw2d_global_t *glob) swirl_map_extrude(cont,user->maxelev); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = swirl_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); if (user_opt->claw_version == 4) { @@ -170,9 +165,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -184,12 +179,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw3dx_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc3d_clawpack46_options_t *claw46_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw3dx_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_3d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc3d_clawpack46_options_register(app, "claw3", "fclaw_options.ini"); user_opt = swirl_options_register(app, "fclaw_options.ini"); @@ -204,11 +199,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw3dx_clawpatch_options_store(glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store(glob, clawpatch_opt); fc3d_clawpack46_options_store (glob, claw46_opt); swirl_options_store (glob, user_opt); @@ -217,7 +212,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/advection/3dx/swirl/swirl_map_extrude.c b/applications/clawpack/advection/3dx/swirl/swirl_map_extrude.c index b77155b43..39500e07d 100644 --- a/applications/clawpack/advection/3dx/swirl/swirl_map_extrude.c +++ b/applications/clawpack/advection/3dx/swirl/swirl_map_extrude.c @@ -28,7 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* User defined extruded mesh mapping */ static void -swirl_map_3dx(fclaw2d_map_context_t * cont, int blockno, +swirl_map_3dx(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) { @@ -37,7 +37,7 @@ swirl_map_3dx(fclaw2d_map_context_t * cont, int blockno, cont->mapc2m(cont,blockno,xc,yc,xp,yp,zp); /* Extrude in z direction to constant height maxelev. */ - double maxelev = cont->user_double_3dx[0]; + double maxelev = cont->user_double_3d[0]; *zp = maxelev*zc; scale_map(cont,xp,yp,zp); @@ -45,14 +45,14 @@ swirl_map_3dx(fclaw2d_map_context_t * cont, int blockno, } -void swirl_map_extrude(fclaw2d_map_context_t* cont, +void swirl_map_extrude(fclaw_map_context_t* cont, const double maxelev) { /* May be needed to get more general mappings */ - cont->mapc2m_3dx = swirl_map_3dx; + cont->mapc2m_3d = swirl_map_3dx; - cont->user_double_3dx[0] = maxelev; + cont->user_double_3d[0] = maxelev; cont->is_extruded = 1; diff --git a/applications/clawpack/advection/3dx/swirl/swirl_options.c b/applications/clawpack/advection/3dx/swirl/swirl_options.c index 585ea2857..e34fe24c2 100644 --- a/applications/clawpack/advection/3dx/swirl/swirl_options.c +++ b/applications/clawpack/advection/3dx/swirl/swirl_options.c @@ -166,12 +166,12 @@ user_options_t* swirl_options_register (fclaw_app_t * app, return user; } -void swirl_options_store (fclaw2d_global_t* glob, user_options_t* user) +void swirl_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* swirl_get_options(fclaw2d_global_t* glob) +const user_options_t* swirl_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/advection/3dx/swirl/swirl_user.cpp b/applications/clawpack/advection/3dx/swirl/swirl_user.cpp index b8f778979..3f51d9799 100644 --- a/applications/clawpack/advection/3dx/swirl/swirl_user.cpp +++ b/applications/clawpack/advection/3dx/swirl/swirl_user.cpp @@ -27,10 +27,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -void swirl_problem_setup(fclaw2d_global_t *glob) +void swirl_problem_setup(fclaw_global_t *glob) { const user_options_t* user = swirl_get_options(glob); - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (glob->mpirank == 0) { FILE *f = fopen("setprob.data","w"); @@ -45,24 +45,24 @@ void swirl_problem_setup(fclaw2d_global_t *glob) fprintf(f, "%-24.4f %s",user->center[1],"\% center_y\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } static -void swirl_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void swirl_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mz, mbc; double xlower,ylower,zlower, dx,dy, dz; - fclaw3dx_clawpatch_grid_data(glob,patch,&mx,&my,&mz, &mbc, + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, &mbc, &xlower,&ylower,&zlower, &dx,&dy, &dz); double *xd,*yd,*zd,*volume,*faceareas; double *xp,*yp,*zp; - fclaw3d_clawpatch_mesh_data(glob,patch,&xp,&yp,&zp, + fclaw_clawpatch_3d_mesh_data(glob,patch,&xp,&yp,&zp, &xd,&yd,&zd,&volume,&faceareas); double *xrot, *yrot, *zrot; @@ -70,7 +70,7 @@ void swirl_patch_setup(fclaw2d_global_t *glob, int maux; double *aux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); SWIRL_SETAUX_MANIFOLD(&mbc,&mx,&my,&mz, &xlower,&ylower,&zlower, &dx,&dy,&dz,&maux,aux,&blockno, @@ -78,16 +78,16 @@ void swirl_patch_setup(fclaw2d_global_t *glob, } -void swirl_link_solvers(fclaw2d_global_t *glob) +void swirl_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = swirl_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = swirl_problem_setup; /* example of how to set up a user defined criteria */ - fclaw3dx_clawpatch_vtable_t *clawpatch_vt = fclaw3dx_clawpatch_vt(glob); - clawpatch_vt->fort_user_exceeds_threshold = &FCLAW3DX_USER_EXCEEDS_TH; + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + clawpatch_vt->d3->fort_user_exceeds_threshold = &FCLAW3D_USER_EXCEEDS_TH; - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); const user_options_t* user = swirl_get_options(glob); if (user->claw_version == 4) @@ -97,7 +97,7 @@ void swirl_link_solvers(fclaw2d_global_t *glob) if (fclaw_opt->manifold) { /* This calls a manifold version of setaux */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = swirl_patch_setup; } else diff --git a/applications/clawpack/advection/3dx/swirl/swirl_user.h b/applications/clawpack/advection/3dx/swirl/swirl_user.h index d838eb765..785e449ba 100644 --- a/applications/clawpack/advection/3dx/swirl/swirl_user.h +++ b/applications/clawpack/advection/3dx/swirl/swirl_user.h @@ -51,16 +51,16 @@ typedef struct user_options } user_options_t; -void swirl_link_solvers(fclaw2d_global_t *glob); +void swirl_link_solvers(fclaw_global_t *glob); /* ------------------------------------- Options ---------------------------------------*/ user_options_t* swirl_options_register (fclaw_app_t * app, const char *configfile); -void swirl_options_store (fclaw2d_global_t* glob, user_options_t* user); +void swirl_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* swirl_get_options(fclaw2d_global_t* glob); +const user_options_t* swirl_get_options(fclaw_global_t* glob); #define SWIRL_SETAUX_MANIFOLD FCLAW_F77_FUNC(swirl_setaux_manifold, \ @@ -94,7 +94,7 @@ void SWIRL_SET_VELOCITY_MANIFOLD(const int* mx, const int* my, const int*mz, double faceareas[], double aux[], const int* maux); -void swirl_map_extrude(fclaw2d_map_context_t *cont, double maxelev); +void swirl_map_extrude(fclaw_map_context_t *cont, double maxelev); #ifdef __cplusplus } diff --git a/applications/clawpack/advection/3dx/swirl/user_4.6/swirl_setaux_manifold.f90 b/applications/clawpack/advection/3dx/swirl/user_4.6/swirl_setaux_manifold.f90 index ce2237780..13f4da25c 100644 --- a/applications/clawpack/advection/3dx/swirl/user_4.6/swirl_setaux_manifold.f90 +++ b/applications/clawpack/advection/3dx/swirl/user_4.6/swirl_setaux_manifold.f90 @@ -105,7 +105,7 @@ subroutine swirl_set_velocity_manifold(mx,my,mz,mbc, & do i = 1-mbc,mx+mbc !! Get velocity normal to x-face - call fclaw3d_map_c2m(cont,blockno,xc(i)-dx2,yc(j),zc(k),xp,yp,zp) + call fclaw_map_3d_c2m(cont,blockno,xc(i)-dx2,yc(j),zc(k),xp,yp,zp) g = faceareas(i,j,k,1)/dydz u = compute_u(xp,yp,zp) v = compute_v(xp,yp,zp) @@ -117,7 +117,7 @@ subroutine swirl_set_velocity_manifold(mx,my,mz,mbc, & un_scaled = g*(nv(1)*u + nv(2)*v + nv(3)*w) !! Get velocity normal to y-face - call fclaw3d_map_c2m(cont,blockno,xc(i),yc(j)-dy2,zc(k),xp,yp,zp) + call fclaw_map_3d_c2m(cont,blockno,xc(i),yc(j)-dy2,zc(k),xp,yp,zp) g = faceareas(i,j,k,2)/dxdz u = compute_u(xp,yp,zp) v = compute_v(xp,yp,zp) @@ -129,7 +129,7 @@ subroutine swirl_set_velocity_manifold(mx,my,mz,mbc, & vn_scaled = g*(nv(1)*u + nv(2)*v + nv(3)*w) !! Get velocity normal to z-face - call fclaw3d_map_c2m(cont,blockno,xc(i),yc(j),zc(k)-dz2,xp,yp,zp) + call fclaw_map_3d_c2m(cont,blockno,xc(i),yc(j),zc(k)-dz2,xp,yp,zp) g = faceareas(i,j,k,3)/dxdy u = compute_u(xp,yp,zp) v = compute_v(xp,yp,zp) diff --git a/applications/clawpack/advection/3dx/swirl/user_exceeds_th.f90 b/applications/clawpack/advection/3dx/swirl/user_exceeds_th.f90 index e9b380047..ae1e19c90 100644 --- a/applications/clawpack/advection/3dx/swirl/user_exceeds_th.f90 +++ b/applications/clawpack/advection/3dx/swirl/user_exceeds_th.f90 @@ -1,6 +1,6 @@ !! # check to see if value exceeds threshold -integer function fclaw3dx_user_exceeds_th(blockno,& +integer function fclaw3d_user_exceeds_th(blockno,& qval,qmin,qmax,quad, & dx,dy,dz,xc,yc,zc,threshold, & init_flag, is_ghost) @@ -17,7 +17,7 @@ integer function fclaw3dx_user_exceeds_th(blockno,& !! would fail tagging criteria if (is_ghost) then !! Don't use this result - fclaw3dx_user_exceeds_th = -1 + fclaw3d_user_exceeds_th = -1 return endif @@ -28,6 +28,6 @@ integer function fclaw3dx_user_exceeds_th(blockno,& refine = 0 endif - fclaw3dx_user_exceeds_th = refine + fclaw3d_user_exceeds_th = refine -end function fclaw3dx_user_exceeds_th +end function fclaw3d_user_exceeds_th diff --git a/applications/clawpack/advection/p8/swirl/CMakeLists.txt b/applications/clawpack/advection/p8/swirl/CMakeLists.txt deleted file mode 100644 index 9873f8c51..000000000 --- a/applications/clawpack/advection/p8/swirl/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -set(all ${PROJECT_SOURCE_DIR}/clawpack/advection/p8/all) -set(all2d ${PROJECT_SOURCE_DIR}/clawpack/advection/2d/all) - -add_executable(swirlp8 - swirl.cpp - swirl_options.c - ${all2d}/fclaw2d_map_cart.c - ${all2d}/fclaw2d_map_fivepatch.c - ${all2d}/fclaw2d_map_bilinear.c -) - -set_target_properties(swirlp8 PROPERTIES OUTPUT_NAME swirl) - -target_include_directories(swirlp8 PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${all} -) - -target_link_libraries(swirlp8 PRIVATE - FORESTCLAW::CLAWPACK3_46 -) - - - - - - - - - - diff --git a/applications/clawpack/advection/p8/swirl/Makefile.am b/applications/clawpack/advection/p8/swirl/Makefile.am deleted file mode 100644 index 45cca95d9..000000000 --- a/applications/clawpack/advection/p8/swirl/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -## Makefile.am in applications/clawpack/advection/p8/swirl - -bin_PROGRAMS += applications/clawpack/advection/p8/swirl/swirl - -#TESTS += applications/clawpack/advection/p8/swirl/regressions.sh - -applications_clawpack_advection_p8_swirl_swirl_SOURCES = \ - applications/clawpack/advection/p8/swirl/swirl.cpp \ - applications/clawpack/advection/p8/swirl/swirl_options.c \ - applications/clawpack/advection/p8/swirl/swirl_user.h - -## applications/clawpack/advection/p8/swirl/swirl_user.cpp \ -## applications/clawpack/advection/p8/swirl/swirl_map_extrude.c \ -## applications/clawpack/advection/2d/all/fclaw2d_map_cart.c \ -## applications/clawpack/advection/2d/all/fclaw2d_map_fivepatch.c \ -## applications/clawpack/advection/2d/all/fclaw2d_map_bilinear.c \ -## applications/clawpack/advection/p8/swirl/setprob.f90 \ -## applications/clawpack/advection/p8/swirl/fdisc.f \ -## applications/clawpack/advection/p8/swirl/user_exceeds_th.f90 \ -## applications/clawpack/advection/p8/all/rpn3_vc_advection.f90 \ -## applications/clawpack/advection/p8/all/rpt3_vc_advection.f90 \ -## applications/clawpack/advection/p8/all/rptt3_vc_advection.f90 \ -## applications/clawpack/advection/p8/swirl/user_4.6/qinit.f90 \ -## applications/clawpack/advection/p8/swirl/user_4.6/swirl_setaux.f90 \ -## applications/clawpack/advection/p8/swirl/user_4.6/swirl_setaux_manifold.f90 - -EXTRA_DIST += \ - applications/clawpack/advection/p8/swirl/fclaw_options.ini \ - applications/clawpack/advection/p8/swirl/mappings.ini \ - applications/clawpack/advection/p8/swirl/regression.ini \ - applications/clawpack/advection/p8/swirl/regression_map.ini \ - applications/clawpack/advection/p8/swirl/afterframe.m \ - applications/clawpack/advection/p8/swirl/read_vars.m \ - applications/clawpack/advection/p8/swirl/mapc2p.m \ - applications/clawpack/advection/p8/swirl/setplot3.m - -## Include headers and libraries needed to build this application -## -- Only really need AM_CPPFLAGS and LDADD (since these include all the other -## variables). But others are included here for completeness - -## applications_clawpack_advection_p8_swirl_swirl_CPPFLAGS = \ -## $(AM_CPPFLAGS) \ -## $(FCLAW_CLAWPACK3_46_CPPFLAGS) \ -## $(FCLAW_CLAWPATCH_CPPFLAGS) -## -## applications_clawpack_advection_p8_swirl_swirl_LDADD = \ -## $(LDADD) \ -## $(FCLAW_CLAWPACK3_46_LDADD) \ -## $(FCLAW_CLAWPATCH_LDADD) \ -## $(FCLAW_LDADD) diff --git a/applications/clawpack/burgers/2d/burgers_order3/burgers.cpp b/applications/clawpack/burgers/2d/burgers_order3/burgers.cpp index 9d30cdf2d..2de30eb0f 100644 --- a/applications/clawpack/burgers/2d/burgers_order3/burgers.cpp +++ b/applications/clawpack/burgers/2d/burgers_order3/burgers.cpp @@ -25,10 +25,10 @@ #include "burgers_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -37,12 +37,12 @@ #include static -fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt) +fclaw_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt) { /* Mapped, multi-block domain */ p4est_connectivity_t *conn = NULL; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL, *brick = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL, *brick = NULL; int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -52,29 +52,29 @@ fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt) /* Map unit square to disk using mapc2m_disk.f */ conn = p4est_connectivity_new_brick(mi,mj,a,b); brick = fclaw2d_map_new_brick_conn (conn,mi,mj); - cont = fclaw2d_map_new_nomap_brick(brick); + cont = fclaw_map_new_nomap_brick(brick); domain = fclaw2d_domain_new_conn_map (mpicomm, fclaw_opt->minlevel, conn, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); return domain; } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { const user_options_t *user_opt; /* --------------------------------------------------------------- Set domain data. --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); + you_can_safely_remove_this_call(glob->domain); user_opt = burgers_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -91,9 +91,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -106,12 +106,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; - fclaw2d_global_t *glob; - fclaw2d_domain_t *domain; + fclaw_global_t *glob; + fclaw_domain_t *domain; sc_MPI_Comm mpicomm; /* Initialize application */ @@ -119,7 +119,7 @@ main (int argc, char **argv) /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = burgers_options_register(app, "fclaw_options.ini"); @@ -136,19 +136,19 @@ main (int argc, char **argv) domain = create_domain(mpicomm, fclaw_opt); /* Create global structure which stores the domain, timers, etc */ - glob = fclaw2d_global_new(); - fclaw2d_global_store_domain(glob, domain); + glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); burgers_options_store (glob, user_opt); run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/burgers/2d/burgers_order3/burgers_options.c b/applications/clawpack/burgers/2d/burgers_order3/burgers_options.c index 58d20d7c6..6b5275709 100644 --- a/applications/clawpack/burgers/2d/burgers_order3/burgers_options.c +++ b/applications/clawpack/burgers/2d/burgers_order3/burgers_options.c @@ -152,13 +152,13 @@ user_options_t* burgers_options_register (fclaw_app_t * app, return user; } -void burgers_options_store (fclaw2d_global_t* glob, user_options_t* user) +void burgers_options_store (fclaw_global_t* glob, user_options_t* user) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"user") == NULL); fclaw_pointer_map_insert(glob->options, "user", user, NULL); } -const user_options_t* burgers_get_options(fclaw2d_global_t* glob) +const user_options_t* burgers_get_options(fclaw_global_t* glob) { user_options_t* user = (user_options_t*) fclaw_pointer_map_get(glob->options, "user"); diff --git a/applications/clawpack/burgers/2d/burgers_order3/burgers_user.cpp b/applications/clawpack/burgers/2d/burgers_order3/burgers_user.cpp index 53821d30f..c072c2650 100644 --- a/applications/clawpack/burgers/2d/burgers_order3/burgers_user.cpp +++ b/applications/clawpack/burgers/2d/burgers_order3/burgers_user.cpp @@ -25,19 +25,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "burgers_user.h" -#include +#include /* Two versions of Clawpack */ #include #include -#include +#include #include #include -void burgers_link_solvers(fclaw2d_global_t *glob) +void burgers_link_solvers(fclaw_global_t *glob) { const user_options_t* user = burgers_get_options(glob); if (user->claw_version == 4) @@ -46,7 +46,7 @@ void burgers_link_solvers(fclaw2d_global_t *glob) clawpack46_vt->fort_qinit = &CLAWPACK46_QINIT; - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); clawpatch_vt->fort_tag4coarsening = &TAG4COARSENING; clawpatch_vt->fort_tag4refinement = &TAG4REFINEMENT; diff --git a/applications/clawpack/burgers/2d/burgers_order3/burgers_user.h b/applications/clawpack/burgers/2d/burgers_order3/burgers_user.h index 95884729c..881c965b3 100644 --- a/applications/clawpack/burgers/2d/burgers_order3/burgers_user.h +++ b/applications/clawpack/burgers/2d/burgers_order3/burgers_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef BURGERS_USER_H #define BURGERS_USER_H -#include +#include #include @@ -47,15 +47,15 @@ typedef struct user_options } user_options_t; -void burgers_link_solvers(fclaw2d_global_t *glob); +void burgers_link_solvers(fclaw_global_t *glob); /* ------------------------------------- Options ---------------------------------------*/ user_options_t* burgers_options_register (fclaw_app_t * app, const char *configfile); -void burgers_options_store (fclaw2d_global_t* glob, user_options_t* user); +void burgers_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* burgers_get_options(fclaw2d_global_t* glob); +const user_options_t* burgers_get_options(fclaw_global_t* glob); /* ------------------------------------ Fortran ----------------------------------------*/ #define BURGERS_FLUX2 FCLAW_F77_FUNC(burgers_flux2,BURGERS_FLUX2) @@ -89,7 +89,7 @@ void PERIODIC_FORT_INTERPOLATE_FACE(const int* mx, const int* my, const int* idir, const int* iside, const int* num_neighbors, const int* refratio, const int* igrid, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); #define PERIODIC_FORT_INTERPOLATE_CORNER \ @@ -100,7 +100,7 @@ void PERIODIC_FORT_INTERPOLATE_CORNER(const int* mx, const int* my, const int* mbc,const int* meqn, const int* a_refratio, double this_q[], double neighbor_q[], const int* a_corner, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); #define RPN2CONS_UPDATE FCLAW_F77_FUNC(rpn2cons_update,RPN2CONS_UPDATE) diff --git a/applications/clawpack/burgers/2d/burgers_order3/user_4.6/tag4refinement.f b/applications/clawpack/burgers/2d/burgers_order3/user_4.6/tag4refinement.f index 2888b5487..dfe0daae3 100644 --- a/applications/clawpack/burgers/2d/burgers_order3/user_4.6/tag4refinement.f +++ b/applications/clawpack/burgers/2d/burgers_order3/user_4.6/tag4refinement.f @@ -11,7 +11,7 @@ subroutine tag4refinement(mx,my,mbc, double precision xp,yp,zp integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used integer example common /example_comm/ example diff --git a/applications/clawpack/burgers/2d/pwconst/pwconst.cpp b/applications/clawpack/burgers/2d/pwconst/pwconst.cpp index aa52c0599..b7e71fee9 100644 --- a/applications/clawpack/burgers/2d/pwconst/pwconst.cpp +++ b/applications/clawpack/burgers/2d/pwconst/pwconst.cpp @@ -25,10 +25,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pwconst_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -37,39 +37,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); /* Create "empty" mapping */ - fclaw2d_map_context_t* cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t* cont = fclaw_map_new_nomap(); /* Store the domain in the glob struct */ - fclaw2d_global_store_domain (glob, domain); + fclaw_global_store_domain (glob, domain); /* Store the mapping context in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* List some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = pwconst_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -86,9 +81,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -100,13 +95,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = pwconst_options_register(app, "fclaw_options.ini"); @@ -122,11 +117,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); pwconst_options_store (glob, user_opt); @@ -136,7 +131,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/burgers/2d/pwconst/pwconst_options.c b/applications/clawpack/burgers/2d/pwconst/pwconst_options.c index 947b52f35..76d4a04a2 100644 --- a/applications/clawpack/burgers/2d/pwconst/pwconst_options.c +++ b/applications/clawpack/burgers/2d/pwconst/pwconst_options.c @@ -98,13 +98,13 @@ user_options_t* pwconst_options_register (fclaw_app_t * app, return user; } -void pwconst_options_store (fclaw2d_global_t* glob, user_options_t* user) +void pwconst_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* pwconst_get_options(fclaw2d_global_t* glob) +const user_options_t* pwconst_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/burgers/2d/pwconst/pwconst_user.cpp b/applications/clawpack/burgers/2d/pwconst/pwconst_user.cpp index 53e8e1c50..482f2febd 100644 --- a/applications/clawpack/burgers/2d/pwconst/pwconst_user.cpp +++ b/applications/clawpack/burgers/2d/pwconst/pwconst_user.cpp @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pwconst_user.h" -#include +#include #include #include /* Headers for user defined fortran files */ @@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -void pwconst_link_solvers(fclaw2d_global_t *glob) +void pwconst_link_solvers(fclaw_global_t *glob) { const user_options_t* user = pwconst_get_options(glob); diff --git a/applications/clawpack/burgers/2d/pwconst/pwconst_user.h b/applications/clawpack/burgers/2d/pwconst/pwconst_user.h index 4f1ed32ef..99e699212 100644 --- a/applications/clawpack/burgers/2d/pwconst/pwconst_user.h +++ b/applications/clawpack/burgers/2d/pwconst/pwconst_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef PWCONST_USER_H #define PWCONST_USER_H -#include +#include #ifdef __cplusplus extern "C" @@ -46,13 +46,13 @@ typedef struct user_options user_options_t* pwconst_options_register (fclaw_app_t * app, const char *configfile); -void pwconst_options_store (fclaw2d_global_t* glob, user_options_t* user); +void pwconst_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* pwconst_get_options(fclaw2d_global_t* glob); +const user_options_t* pwconst_get_options(fclaw_global_t* glob); -void pwconst_link_solvers(fclaw2d_global_t *glob); +void pwconst_link_solvers(fclaw_global_t *glob); -fclaw2d_map_context_t* fclaw2d_map_new_nomap(); +fclaw_map_context_t* fclaw_map_new_nomap(); #ifdef __cplusplus #if 0 diff --git a/applications/clawpack/claw3.apps b/applications/clawpack/claw3.apps index c86d71de2..7216a2fb6 100644 --- a/applications/clawpack/claw3.apps +++ b/applications/clawpack/claw3.apps @@ -9,7 +9,7 @@ # Swirl : Scalar advection include applications/clawpack/advection/3dx/swirl/Makefile.am -include applications/clawpack/advection/p8/swirl/Makefile.am +include applications/clawpack/advection/3d/swirl/Makefile.am # Filament : sphere in rotating flow field include applications/clawpack/advection/3dx/filament/Makefile.am diff --git a/applications/clawpack/claw3.cmake b/applications/clawpack/claw3.cmake index f301fa205..a43967d7b 100644 --- a/applications/clawpack/claw3.cmake +++ b/applications/clawpack/claw3.cmake @@ -5,7 +5,7 @@ # Scalar advection add_subdirectory(clawpack/advection/3dx/swirl) -add_subdirectory(clawpack/advection/p8/swirl) +add_subdirectory(clawpack/advection/3d/swirl) add_subdirectory(clawpack/advection/3dx/filament) add_subdirectory(clawpack/advection/3dx/sphere) add_subdirectory(clawpack/advection/3dx/disk) diff --git a/applications/clawpack/euler/2d/quadrants/quadrants.cpp b/applications/clawpack/euler/2d/quadrants/quadrants.cpp index 0abdc7b45..f9f44abcc 100644 --- a/applications/clawpack/euler/2d/quadrants/quadrants.cpp +++ b/applications/clawpack/euler/2d/quadrants/quadrants.cpp @@ -25,10 +25,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "quadrants_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -37,42 +37,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* --------------------------------------------------------------- Mapping geometry --------------------------------------------------------------- */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare(glob->mpicomm, + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t *cont = fclaw_map_new_nomap(); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = quadrants_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -89,9 +84,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -102,13 +97,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = quadrants_options_register(app, "fclaw_options.ini"); @@ -125,11 +120,11 @@ main (int argc, char **argv) /* Create global structure which stores the domain, timers, etc */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t * glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t * glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); quadrants_options_store (glob, user_opt); @@ -139,7 +134,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/euler/2d/quadrants/quadrants_options.c b/applications/clawpack/euler/2d/quadrants/quadrants_options.c index f3d18ee29..9a6bfc9eb 100644 --- a/applications/clawpack/euler/2d/quadrants/quadrants_options.c +++ b/applications/clawpack/euler/2d/quadrants/quadrants_options.c @@ -99,13 +99,13 @@ user_options_t* quadrants_options_register (fclaw_app_t * app, return user; } -void quadrants_options_store (fclaw2d_global_t* glob, user_options_t* user) +void quadrants_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -user_options_t* quadrants_get_options(fclaw2d_global_t* glob) +user_options_t* quadrants_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/euler/2d/quadrants/quadrants_user.cpp b/applications/clawpack/euler/2d/quadrants/quadrants_user.cpp index eccd77363..2f7b85a2b 100644 --- a/applications/clawpack/euler/2d/quadrants/quadrants_user.cpp +++ b/applications/clawpack/euler/2d/quadrants/quadrants_user.cpp @@ -25,9 +25,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "quadrants_user.h" -#include +#include -#include +#include #include #include @@ -37,7 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../rp/euler_user_fort.h" static -void quadrants_problem_setup(fclaw2d_global_t* glob) +void quadrants_problem_setup(fclaw_global_t* glob) { const user_options_t* user = quadrants_get_options(glob); @@ -49,16 +49,16 @@ void quadrants_problem_setup(fclaw2d_global_t* glob) } /* We want to make sure node 0 gets here before proceeding */ - fclaw2d_domain_barrier (glob->domain); /* redundant? */ + fclaw_domain_barrier (glob->domain); /* redundant? */ SETPROB(); } -void quadrants_link_solvers(fclaw2d_global_t *glob) +void quadrants_link_solvers(fclaw_global_t *glob) { user_options_t *user = quadrants_get_options(glob); - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); + fclaw_vtable_t *fc_vt = fclaw_vt(glob); - fclaw_vt->problem_setup = &quadrants_problem_setup; + fc_vt->problem_setup = &quadrants_problem_setup; if (user->claw_version == 4) { diff --git a/applications/clawpack/euler/2d/quadrants/quadrants_user.h b/applications/clawpack/euler/2d/quadrants/quadrants_user.h index 58f7e6eda..a0bbc2c94 100644 --- a/applications/clawpack/euler/2d/quadrants/quadrants_user.h +++ b/applications/clawpack/euler/2d/quadrants/quadrants_user.h @@ -26,7 +26,7 @@ #ifndef QUADRANTS_USER_H #define QUADRANTS_USER_H -#include +#include #ifdef __cplusplus extern "C" @@ -48,13 +48,13 @@ typedef struct user_options user_options_t* quadrants_options_register (fclaw_app_t * app, const char *configfile); -void quadrants_options_store (fclaw2d_global_t* glob, user_options_t* user); +void quadrants_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* quadrants_get_options(fclaw2d_global_t* glob); +user_options_t* quadrants_get_options(fclaw_global_t* glob); -void quadrants_link_solvers(fclaw2d_global_t *glob); +void quadrants_link_solvers(fclaw_global_t *glob); -fclaw2d_map_context_t* fclaw2d_map_new_nomap(); +fclaw_map_context_t* fclaw_map_new_nomap(); #ifdef __cplusplus #if 0 diff --git a/applications/clawpack/euler/2d/shockbubble/shockbubble.cpp b/applications/clawpack/euler/2d/shockbubble/shockbubble.cpp index 5991ee095..9d6cb3be0 100644 --- a/applications/clawpack/euler/2d/shockbubble/shockbubble.cpp +++ b/applications/clawpack/euler/2d/shockbubble/shockbubble.cpp @@ -25,10 +25,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "shockbubble_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -37,52 +37,47 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { /* --------------------------------------------------------------- Mapping geometry --------------------------------------------------------------- */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; /* Construct and store domain */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_t *domain = + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Construct brick mapping */ - fclaw2d_map_context_t *brick = - fclaw2d_map_new_brick(domain, mi, mj, a, b); + fclaw_map_context_t *brick = + fclaw_map_new_2d_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = - fclaw2d_map_new_nomap_brick (brick); + fclaw_map_context_t *cont = + fclaw_map_new_nomap_brick (brick); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = shockbubble_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -99,9 +94,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -113,13 +108,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = shockbubble_options_register(app, "fclaw_options.ini"); @@ -134,11 +129,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t * glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t * glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); shockbubble_options_store (glob, user_opt); @@ -149,7 +144,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/euler/2d/shockbubble/shockbubble_options.c b/applications/clawpack/euler/2d/shockbubble/shockbubble_options.c index 33a7cee8b..d0c63ab4c 100644 --- a/applications/clawpack/euler/2d/shockbubble/shockbubble_options.c +++ b/applications/clawpack/euler/2d/shockbubble/shockbubble_options.c @@ -109,14 +109,14 @@ user_options_t* shockbubble_options_register (fclaw_app_t * app, return user; } -void shockbubble_options_store (fclaw2d_global_t* glob, user_options_t* user) +void shockbubble_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -user_options_t* shockbubble_get_options(fclaw2d_global_t* glob) +user_options_t* shockbubble_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/euler/2d/shockbubble/shockbubble_user.cpp b/applications/clawpack/euler/2d/shockbubble/shockbubble_user.cpp index b184cedba..c2d3e1f8f 100644 --- a/applications/clawpack/euler/2d/shockbubble/shockbubble_user.cpp +++ b/applications/clawpack/euler/2d/shockbubble/shockbubble_user.cpp @@ -25,9 +25,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "shockbubble_user.h" -#include +#include -#include +#include #include #include @@ -38,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../rp/euler_user_fort.h" -void shockbubble_problem_setup(fclaw2d_global_t* glob) +void shockbubble_problem_setup(fclaw_global_t* glob) { const user_options_t* user = shockbubble_get_options(glob); @@ -56,16 +56,16 @@ void shockbubble_problem_setup(fclaw2d_global_t* glob) } /* We want to make sure node 0 gets here before proceeding */ - fclaw2d_domain_barrier (glob->domain); /* redundant? */ + fclaw_domain_barrier (glob->domain); /* redundant? */ SETPROB(); } -void shockbubble_link_solvers(fclaw2d_global_t *glob) +void shockbubble_link_solvers(fclaw_global_t *glob) { const user_options_t* user = shockbubble_get_options(glob); - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); + fclaw_vtable_t *fc_vt = fclaw_vt(glob); - fclaw_vt->problem_setup = &shockbubble_problem_setup; + fc_vt->problem_setup = &shockbubble_problem_setup; if (user->claw_version == 4) { diff --git a/applications/clawpack/euler/2d/shockbubble/shockbubble_user.h b/applications/clawpack/euler/2d/shockbubble/shockbubble_user.h index 8d391c759..3e80364d6 100644 --- a/applications/clawpack/euler/2d/shockbubble/shockbubble_user.h +++ b/applications/clawpack/euler/2d/shockbubble/shockbubble_user.h @@ -26,7 +26,7 @@ #ifndef SHOCKBUBBLE_USER_HPP #define SHOCKBUBBLE_USER_HPP -#include +#include #ifdef __cplusplus extern "C" @@ -52,14 +52,14 @@ typedef struct user_options } user_options_t; -void shockbubble_link_solvers(fclaw2d_global_t *glob); +void shockbubble_link_solvers(fclaw_global_t *glob); user_options_t* shockbubble_options_register (fclaw_app_t * app, const char *configfile); -void shockbubble_options_store (fclaw2d_global_t* glob, user_options_t* user); +void shockbubble_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* shockbubble_get_options(fclaw2d_global_t* glob); +user_options_t* shockbubble_get_options(fclaw_global_t* glob); #ifdef __cplusplus #if 0 diff --git a/applications/clawpack/euler/3dx/all/euler3d_user.h b/applications/clawpack/euler/3dx/all/euler3d_user.h index 20faf9732..75b20100c 100644 --- a/applications/clawpack/euler/3dx/all/euler3d_user.h +++ b/applications/clawpack/euler/3dx/all/euler3d_user.h @@ -26,13 +26,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef EULER3D_USER_H #define EULER3D_USER_H -#include +#include /* Headers for both Clawpack 4.6 and Clawpack 5.0 */ -#include -#include -#include +#include +#include +#include /* Clawpack 4.6 headers */ @@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include +#include #if 0 /* Clawpack 5.0 headers */ diff --git a/applications/clawpack/euler/3dx/overpressure/fdisc.f90 b/applications/clawpack/euler/3dx/overpressure/fdisc.f90 index 9411421d9..2874a2f67 100644 --- a/applications/clawpack/euler/3dx/overpressure/fdisc.f90 +++ b/applications/clawpack/euler/3dx/overpressure/fdisc.f90 @@ -10,12 +10,12 @@ double precision function fdisc(blockno,xc,yc,zc) double precision r_sphere_2d integer*8 cont, fclaw_map_get_context - integer fclaw2d_map_is_used + integer fclaw_map_is_used cont = fclaw_map_get_context() - if (fclaw2d_map_is_used(cont) .ne. 0) then - call fclaw3d_map_c2m(cont,blockno,xc,yc,zc,xp,yp,zp) + if (fclaw_map_is_used(cont) .ne. 0) then + call fclaw_map_3d_c2m(cont,blockno,xc,yc,zc,xp,yp,zp) else xp = xc yp = yc diff --git a/applications/clawpack/euler/3dx/overpressure/overpressure.cpp b/applications/clawpack/euler/3dx/overpressure/overpressure.cpp index bf616657d..3f215c264 100644 --- a/applications/clawpack/euler/3dx/overpressure/overpressure.cpp +++ b/applications/clawpack/euler/3dx/overpressure/overpressure.cpp @@ -28,9 +28,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../all/euler3d_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi,mj,a,b; mi = fclaw_opt->mi; @@ -46,10 +46,10 @@ void create_domain(fclaw2d_global_t *glob) rotate[1] = pi*fclaw_opt->phi/180.0; /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL, *brick = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL, *brick = NULL; - fclaw3dx_clawpatch_options_t *clawpatch_opt = fclaw3dx_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); fc3d_clawpack46_options_t *claw3_opt = fc3d_clawpack46_get_options(glob); /* Use [ax,bx]x[ay,by] */ @@ -61,12 +61,12 @@ void create_domain(fclaw2d_global_t *glob) FCLAW_ASSERT(claw3_opt->mcapa == 0); FCLAW_ASSERT(fclaw_opt->manifold == 0); domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Size is set by [ax,bx] x [ay, by], set in .ini file */ - brick = fclaw2d_map_new_brick(domain,mi,mj,a,b); - cont = fclaw2d_map_new_nomap_brick(brick); + brick = fclaw_map_new_2d_brick(domain,mi,mj,a,b); + cont = fclaw_map_new_nomap_brick(brick); break; case 1: @@ -76,10 +76,10 @@ void create_domain(fclaw2d_global_t *glob) FCLAW_ASSERT(clawpatch_opt->maux == 31); domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick(domain,mi,mj,a,b); + brick = fclaw_map_new_2d_brick(domain,mi,mj,a,b); /* Square in [-1,1]x[-1,1], scaled/shifted to [0,1]x[0,1] */ cont = fclaw2d_map_new_cart(brick, @@ -90,11 +90,11 @@ void create_domain(fclaw2d_global_t *glob) case 2: /* Latlong */ /* Create brick domain with periodicity */ - domain = fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + domain = fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Create brick mapping */ - brick = fclaw2d_map_new_brick(domain, mi, mj, a, b); + brick = fclaw_map_new_2d_brick(domain, mi, mj, a, b); cont = fclaw2d_map_new_latlong(brick,fclaw_opt->scale, rotate, @@ -105,14 +105,14 @@ void create_domain(fclaw2d_global_t *glob) break; case 3: domain = - fclaw2d_domain_new_cubedsphere (glob->mpicomm, + fclaw_domain_new_2d_cubedsphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_cubedsphere (fclaw_opt->scale, rotate); break; case 4: domain = - fclaw2d_domain_new_twosphere (glob->mpicomm, fclaw_opt->minlevel); + fclaw_domain_new_2d_twosphere (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowsphere (fclaw_opt->scale, rotate); break; default: @@ -131,28 +131,23 @@ void create_domain(fclaw2d_global_t *glob) /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = overpressure_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -170,9 +165,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -183,13 +178,13 @@ main (int argc, char **argv) /* Options */ fclaw_options_t *fclaw_opt; - fclaw3dx_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc3d_clawpack46_options_t *claw46_opt; user_options_t *user_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw3dx_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_3d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc3d_clawpack46_options_register(app, "claw3", "fclaw_options.ini"); user_opt = overpressure_options_register(app,"fclaw_options.ini"); @@ -203,11 +198,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw3dx_clawpatch_options_store(glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store(glob, clawpatch_opt); fc3d_clawpack46_options_store (glob, claw46_opt); overpressure_options_store (glob, user_opt); @@ -217,7 +212,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/euler/3dx/overpressure/overpressure_map_extrude.c b/applications/clawpack/euler/3dx/overpressure/overpressure_map_extrude.c index 5a05a665f..89c3466ca 100644 --- a/applications/clawpack/euler/3dx/overpressure/overpressure_map_extrude.c +++ b/applications/clawpack/euler/3dx/overpressure/overpressure_map_extrude.c @@ -29,12 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* For 2d mappings */ #include "../all/euler3d_user.h" -#include +#include /* User defined extruded mesh mapping */ static void -overpressure_map_3dx(fclaw2d_map_context_t * cont, int blockno, +overpressure_map_3dx(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) { @@ -44,13 +44,13 @@ overpressure_map_3dx(fclaw2d_map_context_t * cont, int blockno, cont->mapc2m(cont,blockno,xc,yc,&xp1,&yp1,&zp1); /* In extruded case, no transformations are applied to the 2d mapping */ - int mapping = cont->user_int_3dx[0]; + int mapping = cont->user_int_3d[0]; - double maxelev = cont->user_double_3dx[0]; - double minz = cont->user_double_3dx[1]; - double maxz = cont->user_double_3dx[2]; - double midz = cont->user_double_3dx[3]; - double scale_bump = cont->user_double_3dx[4]; + double maxelev = cont->user_double_3d[0]; + double minz = cont->user_double_3d[1]; + double maxz = cont->user_double_3d[2]; + double midz = cont->user_double_3d[3]; + double scale_bump = cont->user_double_3d[4]; if (mapping == 1) { @@ -111,7 +111,7 @@ overpressure_map_3dx(fclaw2d_map_context_t * cont, int blockno, } -void overpressure_map_extrude(fclaw2d_map_context_t* cont, +void overpressure_map_extrude(fclaw_map_context_t* cont, const double maxelev, const int mapping, const double minz, @@ -121,16 +121,16 @@ void overpressure_map_extrude(fclaw2d_map_context_t* cont, { /* May be needed to get more general mappings */ - cont->mapc2m_3dx = overpressure_map_3dx; + cont->mapc2m_3d = overpressure_map_3dx; /* Store parameters for use in routine above */ - cont->user_double_3dx[0] = maxelev; - cont->user_double_3dx[1] = minz; - cont->user_double_3dx[2] = maxz; - cont->user_double_3dx[3] = midz; - cont->user_double_3dx[4] = scale_bump; + cont->user_double_3d[0] = maxelev; + cont->user_double_3d[1] = minz; + cont->user_double_3d[2] = maxz; + cont->user_double_3d[3] = midz; + cont->user_double_3d[4] = scale_bump; - cont->user_int_3dx[0] = mapping; + cont->user_int_3d[0] = mapping; /* This is checked in 2d mappings. If `is_extruded=1`, then the 2d mapping will not be scaled, shifted or rotated diff --git a/applications/clawpack/euler/3dx/overpressure/overpressure_options.c b/applications/clawpack/euler/3dx/overpressure/overpressure_options.c index c3f7b2661..a885f7266 100644 --- a/applications/clawpack/euler/3dx/overpressure/overpressure_options.c +++ b/applications/clawpack/euler/3dx/overpressure/overpressure_options.c @@ -195,14 +195,14 @@ user_options_t* overpressure_options_register (fclaw_app_t * app, return user; } -void overpressure_options_store (fclaw2d_global_t* glob, user_options_t* user) +void overpressure_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -user_options_t* overpressure_get_options(fclaw2d_global_t* glob) +user_options_t* overpressure_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/euler/3dx/overpressure/overpressure_user.cpp b/applications/clawpack/euler/3dx/overpressure/overpressure_user.cpp index 867d688b4..d318e6b75 100644 --- a/applications/clawpack/euler/3dx/overpressure/overpressure_user.cpp +++ b/applications/clawpack/euler/3dx/overpressure/overpressure_user.cpp @@ -27,10 +27,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../all/euler3d_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -39,10 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -void overpressure_problem_setup(fclaw2d_global_t* glob) +void overpressure_problem_setup(fclaw_global_t* glob) { const user_options_t* user = overpressure_get_options(glob); - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); fc3d_clawpack46_options_t *clawopt = fc3d_clawpack46_get_options(glob); if (glob->mpirank == 0) @@ -83,24 +83,24 @@ void overpressure_problem_setup(fclaw2d_global_t* glob) } /* We want to make sure node 0 gets here before proceeding */ - fclaw2d_domain_barrier (glob->domain); /* redundant? */ + fclaw_domain_barrier (glob->domain); /* redundant? */ SETPROB(); } static -void overpressure_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void overpressure_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mz, mbc; double xlower,ylower,zlower, dx,dy, dz; - fclaw3dx_clawpatch_grid_data(glob,patch,&mx,&my,&mz, &mbc, + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, &mbc, &xlower,&ylower,&zlower, &dx,&dy, &dz); double *xd,*yd,*zd,*volume,*faceareas; double *xp,*yp,*zp; - fclaw3d_clawpatch_mesh_data(glob,patch,&xp,&yp,&zp, + fclaw_clawpatch_3d_mesh_data(glob,patch,&xp,&yp,&zp, &xd,&yd,&zd,&volume,&faceareas); double *xrot, *yrot, *zrot; @@ -108,7 +108,7 @@ void overpressure_patch_setup(fclaw2d_global_t *glob, int maux; double *aux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); fc3d_clawpack46_options_t *clawopt = fc3d_clawpack46_get_options(glob); @@ -123,14 +123,14 @@ void overpressure_patch_setup(fclaw2d_global_t *glob, -void overpressure_link_solvers(fclaw2d_global_t *glob) +void overpressure_link_solvers(fclaw_global_t *glob) { const user_options_t* user = overpressure_get_options(glob); - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); + fclaw_vtable_t *fc_vt = fclaw_vt(glob); - fclaw_vt->problem_setup = &overpressure_problem_setup; + fc_vt->problem_setup = &overpressure_problem_setup; - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); if (user->claw_version == 4) { @@ -141,10 +141,10 @@ void overpressure_link_solvers(fclaw2d_global_t *glob) claw46_vt->fort_qinit = &CLAWPACK46_QINIT; /* Refine based on pressure */ - fclaw3dx_clawpatch_vtable_t *clawpatch_vt = fclaw3dx_clawpatch_vt(glob); - clawpatch_vt->fort_user_exceeds_threshold = &EULER3D_PRESSURE_EXCEEDS_TH; + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + clawpatch_vt->d3->fort_user_exceeds_threshold = &EULER3D_PRESSURE_EXCEEDS_TH; - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); if (fclaw_opt->manifold) { /* This calls a manifold version of setaux */ diff --git a/applications/clawpack/euler/3dx/overpressure/overpressure_user.h b/applications/clawpack/euler/3dx/overpressure/overpressure_user.h index cb1e5bdcd..9d92d2471 100644 --- a/applications/clawpack/euler/3dx/overpressure/overpressure_user.h +++ b/applications/clawpack/euler/3dx/overpressure/overpressure_user.h @@ -26,10 +26,10 @@ #ifndef OVERPRESSURE_USER_H #define OVERPRESSURE_USER_H -#include +#include -#include -#include +#include +#include #include #include @@ -77,16 +77,16 @@ typedef struct user_options } user_options_t; -void overpressure_link_solvers(fclaw2d_global_t *glob); +void overpressure_link_solvers(fclaw_global_t *glob); user_options_t* overpressure_options_register (fclaw_app_t * app, const char *configfile); -void overpressure_options_store (fclaw2d_global_t* glob, user_options_t* user); +void overpressure_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* overpressure_get_options(fclaw2d_global_t* glob); +user_options_t* overpressure_get_options(fclaw_global_t* glob); -void overpressure_map_extrude(fclaw2d_map_context_t* cont, +void overpressure_map_extrude(fclaw_map_context_t* cont, const double maxelev, const int mapping, const double minz, diff --git a/applications/clawpack/shallow/2d/bump/bump.cpp b/applications/clawpack/shallow/2d/bump/bump.cpp index e6ef0d6e8..74235663a 100644 --- a/applications/clawpack/shallow/2d/bump/bump.cpp +++ b/applications/clawpack/shallow/2d/bump/bump.cpp @@ -25,10 +25,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "bump_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -37,39 +37,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare (glob->mpicomm, + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t *cont = fclaw_map_new_nomap(); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - user_options_t* user_opt = bump_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -86,9 +81,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } @@ -101,14 +96,14 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = bump_options_register(app, "fclaw_options.ini"); @@ -126,11 +121,11 @@ main (int argc, char **argv) /* Create global structure which stores the domain, timers, etc */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); bump_options_store (glob, user_opt); @@ -140,7 +135,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/shallow/2d/bump/bump_options.c b/applications/clawpack/shallow/2d/bump/bump_options.c index bde66bdbb..f7c43ce6e 100644 --- a/applications/clawpack/shallow/2d/bump/bump_options.c +++ b/applications/clawpack/shallow/2d/bump/bump_options.c @@ -125,13 +125,13 @@ user_options_t* bump_options_register (fclaw_app_t * app, return user; } -void bump_options_store (fclaw2d_global_t* glob, user_options_t* user) +void bump_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -user_options_t* bump_get_options(fclaw2d_global_t* glob) +user_options_t* bump_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/shallow/2d/bump/bump_user.cpp b/applications/clawpack/shallow/2d/bump/bump_user.cpp index f1703aafc..eeede52c6 100644 --- a/applications/clawpack/shallow/2d/bump/bump_user.cpp +++ b/applications/clawpack/shallow/2d/bump/bump_user.cpp @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "bump_user.h" -#include +#include #include #include @@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../rp/shallow_user_fort.h" -void bump_problem_setup(fclaw2d_global_t* glob) +void bump_problem_setup(fclaw_global_t* glob) { const user_options_t* user = bump_get_options(glob); @@ -46,13 +46,13 @@ void bump_problem_setup(fclaw2d_global_t* glob) } /* We want to make sure node 0 gets here before proceeding */ - fclaw2d_domain_barrier (glob->domain); /* redundant? */ + fclaw_domain_barrier (glob->domain); /* redundant? */ SETPROB(); } -void bump_link_solvers(fclaw2d_global_t *glob) +void bump_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &bump_problem_setup; /* Version-independent */ diff --git a/applications/clawpack/shallow/2d/bump/bump_user.h b/applications/clawpack/shallow/2d/bump/bump_user.h index fab6e7a61..8506ee0a5 100644 --- a/applications/clawpack/shallow/2d/bump/bump_user.h +++ b/applications/clawpack/shallow/2d/bump/bump_user.h @@ -26,7 +26,7 @@ #ifndef BUMP_USER_H #define BUMP_USER_H -#include +#include #ifdef __cplusplus extern "C" @@ -51,16 +51,16 @@ typedef struct user_options } user_options_t; -void bump_link_solvers(fclaw2d_global_t *glob); +void bump_link_solvers(fclaw_global_t *glob); user_options_t* bump_options_register (fclaw_app_t * app, const char *configfile); -void bump_options_store (fclaw2d_global_t* glob, user_options_t* user); +void bump_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* bump_get_options(fclaw2d_global_t* glob); +user_options_t* bump_get_options(fclaw_global_t* glob); -fclaw2d_map_context_t* fclaw2d_map_new_nomap(); +fclaw_map_context_t* fclaw_map_new_nomap(); /* ----------------------------- Conservative update ---------------------------------- */ diff --git a/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_fivepatch.c b/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_fivepatch.c index bc8b34ddb..935c71672 100644 --- a/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_fivepatch.c +++ b/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_fivepatch.c @@ -1,6 +1,6 @@ /* Five bilinear patches */ -#include +#include #ifdef __cplusplus extern "C" @@ -21,41 +21,41 @@ void SQUARE_BASIS_COMPLETE(const double* x, const double *y, static int -fclaw2d_map_query_fivepatch(fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_fivepatch(fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -83,14 +83,14 @@ fclaw2d_map_c2m_basis_fivepatch(fclaw2d_map_context_t * cont, static void -fclaw2d_map_c2m_fivepatch(fclaw2d_map_context_t* cont, int blockno, +fclaw2d_map_c2m_fivepatch(fclaw_map_context_t* cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { double alpha = cont->user_double[0]; /* Maps to [-1,1]x[-1,1] */ - MAPC2M_FIVEPATCH(&blockno,&xc,&yc,xp,yp,zp,&alpha); + FCLAW_MAP_2D_C2M_FIVEPATCH(&blockno,&xc,&yc,xp,yp,zp,&alpha); /* Scale to [-0.5,-0.5]x[0.5,0.5] */ scale_map(cont, xp,yp,zp); @@ -100,13 +100,13 @@ fclaw2d_map_c2m_fivepatch(fclaw2d_map_context_t* cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], const double shift[], const double alpha) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_fivepatch; cont->mapc2m = fclaw2d_map_c2m_fivepatch; // cont->basis = fclaw2d_map_c2m_basis_fivepatch; diff --git a/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_pillowdisk.c b/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_pillowdisk.c index 6e4eb3847..376ab0d77 100644 --- a/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_pillowdisk.c +++ b/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_pillowdisk.c @@ -1,6 +1,6 @@ /* Spherical disk in xy plane. Matches p4est_connectivity_new_disk (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -12,39 +12,39 @@ extern "C" static int -fclaw2d_map_query_pillowdisk (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowdisk (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -59,11 +59,11 @@ fclaw2d_map_query_pillowdisk (fclaw2d_map_context_t * cont, int query_identifier static void -fclaw2d_map_c2m_pillowdisk(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowdisk(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { - MAPC2M_PILLOWDISK(&blockno,&xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_C2M_PILLOWDISK(&blockno,&xc,&yc,xp,yp,zp); /* These can probably be replaced by C functions at some point. */ scale_map(cont, xp,yp,zp); @@ -73,13 +73,13 @@ fclaw2d_map_c2m_pillowdisk(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], const double shift[], const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowdisk; cont->mapc2m = fclaw2d_map_c2m_pillowdisk; diff --git a/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_pillowdisk5.c b/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_pillowdisk5.c index e19d45b64..56044bb23 100644 --- a/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_pillowdisk5.c +++ b/applications/clawpack/shallow/2d/radialdam/fclaw2d_map_pillowdisk5.c @@ -1,6 +1,6 @@ /* Spherical disk in xy plane. Matches p4est_connectivity_new_disk (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -12,39 +12,39 @@ extern "C" static int -fclaw2d_map_query_pillowdisk5 (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowdisk5 (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -59,12 +59,12 @@ fclaw2d_map_query_pillowdisk5 (fclaw2d_map_context_t * cont, int query_identifie static void -fclaw2d_map_c2m_pillowdisk5(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowdisk5(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { double alpha = cont->user_double[0]; - MAPC2M_PILLOWDISK5(&blockno,&xc,&yc,xp,yp,zp,&alpha); + FCLAW_MAP_2D_C2M_PILLOWDISK5(&blockno,&xc,&yc,xp,yp,zp,&alpha); scale_map(cont, xp,yp,zp); @@ -72,14 +72,14 @@ fclaw2d_map_c2m_pillowdisk5(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], const double shift[], const double rotate[], const double alpha) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowdisk5; cont->mapc2m = fclaw2d_map_c2m_pillowdisk5; diff --git a/applications/clawpack/shallow/2d/radialdam/fdisc.f b/applications/clawpack/shallow/2d/radialdam/fdisc.f index 38c255988..2025e369b 100644 --- a/applications/clawpack/shallow/2d/radialdam/fdisc.f +++ b/applications/clawpack/shallow/2d/radialdam/fdisc.f @@ -5,7 +5,7 @@ double precision function fdisc(blockno, x,y) double precision x,y integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used double precision x0,y0,r0 common /cdisc/ x0,y0,r0 @@ -14,8 +14,8 @@ double precision function fdisc(blockno, x,y) cont = fclaw_map_get_context() - IF (fclaw2d_map_is_used(cont)) THEN - CALL fclaw2d_map_c2m(cont,blockno,x,y,xp,yp,zp) + IF (fclaw_map_is_used(cont)) THEN + CALL fclaw_map_2d_c2m(cont,blockno,x,y,xp,yp,zp) r2 = (xp-x0)**2 + (yp-y0)**2 ELSE r2 = (x-x0)**2 + (y-y0)**2 diff --git a/applications/clawpack/shallow/2d/radialdam/radialdam.cpp b/applications/clawpack/shallow/2d/radialdam/radialdam.cpp index b6d24568a..ffe3b6c2b 100644 --- a/applications/clawpack/shallow/2d/radialdam/radialdam.cpp +++ b/applications/clawpack/shallow/2d/radialdam/radialdam.cpp @@ -26,9 +26,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "radialdam_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); /* Local variables */ double rotate[2]; @@ -36,34 +36,34 @@ void create_domain(fclaw2d_global_t *glob) rotate[1] = fclaw_opt->theta; /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain = NULL; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain = NULL; + fclaw_map_context_t *cont = NULL; const user_options_t *user = radialdam_get_options(glob); switch (user->example) { case 0: /* Use [ax,bx]x[ay,by] */ - domain = fclaw2d_domain_new_unitsquare(glob->mpicomm, + domain = fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); - cont = fclaw2d_map_new_nomap(); + cont = fclaw_map_new_nomap(); break; case 1: /* Five patch square : maps to [-1,1]x[-1,1] */ - domain = fclaw2d_domain_new_disk(glob->mpicomm, 0, 0, + domain = fclaw_domain_new_2d_disk(glob->mpicomm, 0, 0, fclaw_opt->minlevel); cont = fclaw2d_map_new_fivepatch (fclaw_opt->scale, fclaw_opt->shift, user->alpha); break; case 2: /* Pillow disk (single block) */ - domain = fclaw2d_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); + domain = fclaw_domain_new_unitsquare (glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowdisk (fclaw_opt->scale, fclaw_opt->shift,rotate); break; case 3: /* Pillow disk mapping of the five patch square */ - domain = fclaw2d_domain_new_disk (glob->mpicomm, 0, 0, fclaw_opt->minlevel); + domain = fclaw_domain_new_2d_disk (glob->mpicomm, 0, 0, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowdisk5 (fclaw_opt->scale, fclaw_opt->shift, rotate,user->alpha); break; @@ -72,28 +72,23 @@ void create_domain(fclaw2d_global_t *glob) } /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = radialdam_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user_opt->claw_version == 4) @@ -111,9 +106,9 @@ void run_program(fclaw2d_global_t* glob) Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } @@ -125,13 +120,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = radialdam_options_register(app, "fclaw_options.ini"); @@ -152,11 +147,11 @@ main (int argc, char **argv) /* Create global structure which stores the domain, timers, etc */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); radialdam_options_store (glob, user_opt); @@ -166,7 +161,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/shallow/2d/radialdam/radialdam_options.c b/applications/clawpack/shallow/2d/radialdam/radialdam_options.c index 624b8df0a..7f0a57e1c 100644 --- a/applications/clawpack/shallow/2d/radialdam/radialdam_options.c +++ b/applications/clawpack/shallow/2d/radialdam/radialdam_options.c @@ -135,18 +135,18 @@ user_options_t* radialdam_options_register (fclaw_app_t * app, return user; } -void radialdam_options_store (fclaw2d_global_t* glob, user_options_t* user) +void radialdam_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -user_options_t* radialdam_get_options(fclaw2d_global_t* glob) +user_options_t* radialdam_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } void radialdam_global_post_process(fclaw_options_t *fclaw_opt, - fclaw2d_clawpatch_options_t *clawpatch_opt, + fclaw_clawpatch_options_t *clawpatch_opt, user_options_t *user_opt) { if (user_opt->example == 2) diff --git a/applications/clawpack/shallow/2d/radialdam/radialdam_user.cpp b/applications/clawpack/shallow/2d/radialdam/radialdam_user.cpp index 28063aabb..6e94d9722 100644 --- a/applications/clawpack/shallow/2d/radialdam/radialdam_user.cpp +++ b/applications/clawpack/shallow/2d/radialdam/radialdam_user.cpp @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "radialdam_user.h" -#include +#include #include #include @@ -36,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. static -void radialdam_problem_setup(fclaw2d_global_t* glob) +void radialdam_problem_setup(fclaw_global_t* glob) { const user_options_t* user = radialdam_get_options(glob); @@ -54,17 +54,17 @@ void radialdam_problem_setup(fclaw2d_global_t* glob) } /* We want to make sure node 0 gets here before proceeding */ - fclaw2d_domain_barrier (glob->domain); /* redundant? */ + fclaw_domain_barrier (glob->domain); /* redundant? */ SETPROB(); } static -void radialdam_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void radialdam_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { - if (fclaw2d_patch_is_ghost(patch)) + if (fclaw_patch_is_ghost(patch)) { /* Mapped info is needed only for an update */ return; @@ -72,17 +72,17 @@ void radialdam_patch_setup(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *xd,*yd,*zd; double *xp,*yp,*zp, *area; - fclaw2d_clawpatch_metric_data(glob,patch,&xp,&yp,&zp, + fclaw_clawpatch_2d_metric_data(glob,patch,&xp,&yp,&zp, &xd,&yd,&zd,&area); double *xnormals,*ynormals,*xtangents,*ytangents; double *surfnormals,*edgelengths,*curvature; - fclaw2d_clawpatch_metric_data2(glob,patch, + fclaw_clawpatch_2d_metric_data2(glob,patch, &xnormals,&ynormals, &xtangents,&ytangents, &surfnormals,&edgelengths, @@ -90,7 +90,7 @@ void radialdam_patch_setup(fclaw2d_global_t *glob, double *aux; int maux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); const user_options_t* user = radialdam_get_options(glob); @@ -110,9 +110,9 @@ void radialdam_patch_setup(fclaw2d_global_t *glob, } -void radialdam_link_solvers(fclaw2d_global_t *glob) +void radialdam_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &radialdam_problem_setup; /* Version-independent */ @@ -130,7 +130,7 @@ void radialdam_link_solvers(fclaw2d_global_t *glob) } else if (user->example >= 1 && user->example <= 3) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &radialdam_patch_setup; claw46_vt->fort_rpn2 = &CLAWPACK46_RPN2_MANIFOLD; @@ -152,7 +152,7 @@ void radialdam_link_solvers(fclaw2d_global_t *glob) } else if (user->example >= 1 && user->example <= 3) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &radialdam_patch_setup; claw5_vt->fort_rpn2 = &CLAWPACK5_RPN2_MANIFOLD; diff --git a/applications/clawpack/shallow/2d/radialdam/radialdam_user.h b/applications/clawpack/shallow/2d/radialdam/radialdam_user.h index 65835cc95..b4b884c3e 100644 --- a/applications/clawpack/shallow/2d/radialdam/radialdam_user.h +++ b/applications/clawpack/shallow/2d/radialdam/radialdam_user.h @@ -26,12 +26,12 @@ #ifndef RADIALDAM_USER_H #define RADIALDAM_USER_H -#include +#include -#include +#include -#include -#include +#include +#include #include #include @@ -66,35 +66,35 @@ typedef struct user_options } user_options_t; -void radialdam_link_solvers(fclaw2d_global_t *glob); +void radialdam_link_solvers(fclaw_global_t *glob); user_options_t* radialdam_options_register (fclaw_app_t * app, const char *configfile); -void radialdam_options_store (fclaw2d_global_t* glob, user_options_t* user); +void radialdam_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* radialdam_get_options(fclaw2d_global_t* glob); +user_options_t* radialdam_get_options(fclaw_global_t* glob); void radialdam_global_post_process(fclaw_options_t *fclaw_opt, - fclaw2d_clawpatch_options_t *clawpatch_opt, + fclaw_clawpatch_options_t *clawpatch_opt, user_options_t *user_opt); /* ------------------------------- Mapping functions ---------------------------------- */ -fclaw2d_map_context_t* fclaw2d_map_new_nomap(); +fclaw_map_context_t* fclaw_map_new_nomap(); -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], const double shift[], const double rotate[]); -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], const double shift[], const double rotate[], const double alpha); -fclaw2d_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], const double shift[], const double alpha); /* ----------------------------- Conservative update ---------------------------------- */ diff --git a/applications/clawpack/shallow/2d/radialdam_cuda/fclaw2d_map_pillowdisk.c b/applications/clawpack/shallow/2d/radialdam_cuda/fclaw2d_map_pillowdisk.c index 3568d94da..fbc626f2c 100644 --- a/applications/clawpack/shallow/2d/radialdam_cuda/fclaw2d_map_pillowdisk.c +++ b/applications/clawpack/shallow/2d/radialdam_cuda/fclaw2d_map_pillowdisk.c @@ -1,6 +1,6 @@ /* Spherical disk in xy plane. Matches p4est_connectivity_new_disk (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -12,39 +12,39 @@ extern "C" static int -fclaw2d_map_query_pillowdisk (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowdisk (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 1; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -59,11 +59,11 @@ fclaw2d_map_query_pillowdisk (fclaw2d_map_context_t * cont, int query_identifier static void -fclaw2d_map_c2m_pillowdisk(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowdisk(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { - MAPC2M_PILLOWDISK(&blockno,&xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_C2M_PILLOWDISK(&blockno,&xc,&yc,xp,yp,zp); /* These can probably be replaced by C functions at some point. */ scale_map(cont, xp,yp,zp); @@ -73,13 +73,13 @@ fclaw2d_map_c2m_pillowdisk(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], const double shift[], const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowdisk; cont->mapc2m = fclaw2d_map_c2m_pillowdisk; diff --git a/applications/clawpack/shallow/2d/radialdam_cuda/fdisc.f b/applications/clawpack/shallow/2d/radialdam_cuda/fdisc.f index 93e6d2c16..a60b21632 100644 --- a/applications/clawpack/shallow/2d/radialdam_cuda/fdisc.f +++ b/applications/clawpack/shallow/2d/radialdam_cuda/fdisc.f @@ -5,7 +5,7 @@ double precision function fdisc(blockno, x,y) double precision x,y integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used double precision x0,y0,r0 integer idisc @@ -16,8 +16,8 @@ double precision function fdisc(blockno, x,y) cont = get_context() - IF (fclaw2d_map_is_used(cont)) THEN - CALL fclaw2d_map_c2m(cont,blockno,x,y,xp,yp,zp) + IF (fclaw_map_is_used(cont)) THEN + CALL fclaw_map_2d_c2m(cont,blockno,x,y,xp,yp,zp) r2 = (xp-x0)**2 + (yp-y0)**2 ELSE r2 = (x-x0)**2 + (y-y0)**2 diff --git a/applications/clawpack/shallow/2d/radialdam_cuda/radialdam.cpp b/applications/clawpack/shallow/2d/radialdam_cuda/radialdam.cpp index 6b3dacf2d..22c262487 100644 --- a/applications/clawpack/shallow/2d/radialdam_cuda/radialdam.cpp +++ b/applications/clawpack/shallow/2d/radialdam_cuda/radialdam.cpp @@ -25,10 +25,10 @@ #include "radialdam_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -41,14 +41,14 @@ #include static -fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, +fclaw_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt, user_options_t* user) { /* Mapped, multi-block domain */ p4est_connectivity_t *conn = NULL; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; /* Local variables */ double rotate[2]; @@ -61,7 +61,7 @@ fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, case 0: /* Use [ax,bx]x[ay,by] */ conn = p4est_connectivity_new_unitsquare(); - cont = fclaw2d_map_new_nomap(); + cont = fclaw_map_new_nomap(); break; case 1: conn = p4est_connectivity_new_unitsquare(); @@ -72,25 +72,25 @@ fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, } domain = fclaw2d_domain_new_conn_map (mpicomm, fclaw_opt->minlevel, conn, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); return domain; } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { const user_options_t *user_opt; /* --------------------------------------------------------------- Set domain data. --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); + you_can_safely_remove_this_call(glob->domain); user_opt = radialdam_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if(user_opt->cuda) @@ -127,8 +127,8 @@ void run_program(fclaw2d_global_t* glob) fc2d_cudaclaw_allocate_buffers(glob); } - fclaw2d_initialize(glob); - fclaw2d_run(glob); + fclaw_initialize(glob); + fclaw_run(glob); if (user_opt->cuda == 1) { @@ -136,7 +136,7 @@ void run_program(fclaw2d_global_t* glob) fc2d_cudaclaw_deallocate_buffers(glob); } - fclaw2d_finalize(glob); + fclaw_finalize(glob); } @@ -150,13 +150,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; fc2d_cudaclaw_options_t *cuclaw5_opt; - fclaw2d_global_t *glob; - fclaw2d_domain_t *domain; + fclaw_global_t *glob; + fclaw_domain_t *domain; sc_MPI_Comm mpicomm; /* Initialize application */ @@ -164,7 +164,7 @@ main (int argc, char **argv) /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); cuclaw5_opt = fc2d_cudaclaw_options_register(app, "fclaw_options.ini"); @@ -182,12 +182,12 @@ main (int argc, char **argv) domain = create_domain(mpicomm, fclaw_opt,user_opt); /* Create global structure which stores the domain, timers, etc */ - glob = fclaw2d_global_new(); - fclaw2d_global_store_domain(glob, domain); + glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); fc2d_cudaclaw_options_store (glob, cuclaw5_opt); @@ -195,7 +195,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_options.c b/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_options.c index 1865aa545..694c92b39 100644 --- a/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_options.c +++ b/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_options.c @@ -145,13 +145,13 @@ user_options_t* radialdam_options_register (fclaw_app_t * app, return user; } -void radialdam_options_store (fclaw2d_global_t* glob, user_options_t* user) +void radialdam_options_store (fclaw_global_t* glob, user_options_t* user) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"user") == NULL); fclaw_pointer_map_insert(glob->options, "user", user, NULL); } -user_options_t* radialdam_get_options(fclaw2d_global_t* glob) +user_options_t* radialdam_get_options(fclaw_global_t* glob) { user_options_t* user = (user_options_t*) fclaw_pointer_map_get(glob->options, "user"); diff --git a/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_user.cpp b/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_user.cpp index ab7ae5124..5cebb2a33 100644 --- a/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_user.cpp +++ b/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_user.cpp @@ -25,7 +25,7 @@ #include "radialdam_user.h" -#include +#include #include #include @@ -33,9 +33,9 @@ #include "../rp/shallow_user_fort.h" -void radialdam_link_solvers(fclaw2d_global_t *glob) +void radialdam_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &radialdam_problem_setup; /* Version-independent */ @@ -77,8 +77,8 @@ void radialdam_link_solvers(fclaw2d_global_t *glob) } else if (user->example == 1) { - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &radialdam_patch_setup; @@ -94,7 +94,7 @@ void radialdam_link_solvers(fclaw2d_global_t *glob) } -void radialdam_problem_setup(fclaw2d_global_t* glob) +void radialdam_problem_setup(fclaw_global_t* glob) { const user_options_t* user = radialdam_get_options(glob); @@ -107,8 +107,8 @@ void radialdam_problem_setup(fclaw2d_global_t* glob) } -void radialdam_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void radialdam_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -119,25 +119,25 @@ void radialdam_patch_setup(fclaw2d_global_t *glob, double *xnormals,*ynormals,*xtangents,*ytangents; double *surfnormals,*edgelengths,*curvature; - if (fclaw2d_patch_is_ghost(this_patch)) + if (fclaw_patch_is_ghost(this_patch)) { /* Mapped info is needed only for an update */ return; } - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_metric_data(glob,this_patch,&xp,&yp,&zp, + fclaw_clawpatch_2d_metric_data(glob,this_patch,&xp,&yp,&zp, &xd,&yd,&zd,&area); - fclaw2d_clawpatch_metric_data2(glob,this_patch, + fclaw_clawpatch_2d_metric_data2(glob,this_patch, &xnormals,&ynormals, &xtangents,&ytangents, &surfnormals,&edgelengths, &curvature); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); USER5_SETAUX_MANIFOLD(&mbc,&mx,&my,&xlower,&ylower, &dx,&dy,&maux,aux, diff --git a/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_user.h b/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_user.h index 809bebf84..3c3d7649c 100644 --- a/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_user.h +++ b/applications/clawpack/shallow/2d/radialdam_cuda/radialdam_user.h @@ -28,7 +28,7 @@ #include -#include +#include #ifdef __cplusplus extern "C" @@ -56,17 +56,17 @@ typedef struct user_options int is_registered; } user_options_t; -void radialdam_problem_setup(fclaw2d_global_t *glob); +void radialdam_problem_setup(fclaw_global_t *glob); -void radialdam_link_solvers(fclaw2d_global_t *glob); +void radialdam_link_solvers(fclaw_global_t *glob); /* ------------------------------------- Options ---------------------------------------*/ user_options_t* radialdam_options_register (fclaw_app_t * app, const char *configfile); -void radialdam_options_store (fclaw2d_global_t* glob, user_options_t* user); +void radialdam_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* radialdam_get_options(fclaw2d_global_t* glob); +user_options_t* radialdam_get_options(fclaw_global_t* glob); /* --------------------------------------- Cuda ----------------------------------------*/ @@ -97,19 +97,19 @@ void USER5_SETAUX_MANIFOLD(const int* mbc, double area[]); -void radialdam_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void radialdam_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx); -fclaw2d_map_context_t* fclaw2d_map_new_nomap(); +fclaw_map_context_t* fclaw_map_new_nomap(); -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], const double shift[], const double rotate[], const double alpha); -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], const double shift[], const double rotate[]); diff --git a/applications/clawpack/shallow/2d/sphere/fclaw2d_map_cubedsphere.c b/applications/clawpack/shallow/2d/sphere/fclaw2d_map_cubedsphere.c index 57ef5cb7d..a24a58a72 100644 --- a/applications/clawpack/shallow/2d/sphere/fclaw2d_map_cubedsphere.c +++ b/applications/clawpack/shallow/2d/sphere/fclaw2d_map_cubedsphere.c @@ -1,6 +1,6 @@ /* Cubed sphere surface. Matches p4est_connectivity_new_cubed (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -12,40 +12,40 @@ extern "C" static int -fclaw2d_map_query_cubedsphere (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_cubedsphere (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 1; default: printf("\n"); @@ -60,25 +60,25 @@ fclaw2d_map_query_cubedsphere (fclaw2d_map_context_t * cont, int query_identifie static void -fclaw2d_map_c2m_cubedsphere (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_cubedsphere (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { - MAPC2M_CUBEDSPHERE(&blockno, &xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_C2M_CUBEDSPHERE(&blockno, &xc,&yc,xp,yp,zp); /* These can probably be replaced by C functions at some point. */ /* scale_map(cont,xp,yp,zp); */ rotate_map(cont,xp,yp,zp); } -fclaw2d_map_context_t * +fclaw_map_context_t * fclaw2d_map_new_cubedsphere(const double scale[], const double shift[], const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_cubedsphere; cont->mapc2m = fclaw2d_map_c2m_cubedsphere; diff --git a/applications/clawpack/shallow/2d/sphere/fclaw2d_map_latlong.c b/applications/clawpack/shallow/2d/sphere/fclaw2d_map_latlong.c index eef381482..80cf64760 100644 --- a/applications/clawpack/shallow/2d/sphere/fclaw2d_map_latlong.c +++ b/applications/clawpack/shallow/2d/sphere/fclaw2d_map_latlong.c @@ -1,6 +1,6 @@ /* Pillow grid surface. Matches p4est_connectivity_new_pillow (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -14,40 +14,40 @@ extern "C" void WRITE_LATLONG_DATA(const double lat[], const double longitude[]); static int -fclaw2d_map_query_latlong (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_latlong (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; default: printf("\n"); @@ -62,7 +62,7 @@ fclaw2d_map_query_latlong (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_latlong (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_latlong (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { @@ -72,7 +72,7 @@ fclaw2d_map_c2m_latlong (fclaw2d_map_context_t * cont, int blockno, /* fclaw2d_map_context_t *brick_map = (fclaw2d_map_context_t*) cont->user_data; */ /* Scale's brick mapping to [0,1]x[0,1] */ - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); /* Scale into lat/long box */ lat[0] = cont->user_double[0]; @@ -84,22 +84,22 @@ fclaw2d_map_c2m_latlong (fclaw2d_map_context_t * cont, int blockno, /* blockno is ignored in the current latlong mapping; it just assumes a single "logical" block in [0,1]x[0,1] */ - MAPC2M_LATLONG(&blockno,&xc2,&yc2,xp,yp,zp); + FCLAW_MAP_2D_C2M_LATLONG(&blockno,&xc2,&yc2,xp,yp,zp); scale_map(cont,xp,yp,zp); } -fclaw2d_map_context_t * - fclaw2d_map_new_latlong (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_latlong (fclaw_map_context_t* brick, const double scale[], const double lat[], const double longitude[], const int a, const int b) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; double lng[2]; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_latlong; cont->mapc2m = fclaw2d_map_c2m_latlong; diff --git a/applications/clawpack/shallow/2d/sphere/sphere.cpp b/applications/clawpack/shallow/2d/sphere/sphere.cpp index 96d53c3cb..5ae665228 100644 --- a/applications/clawpack/shallow/2d/sphere/sphere.cpp +++ b/applications/clawpack/shallow/2d/sphere/sphere.cpp @@ -25,11 +25,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "sphere_user.h" -#include -#include +#include +#include -#include -#include +#include +#include #include #include @@ -136,8 +136,8 @@ void run_program(fclaw_app_t* app) /* Mapped, multi-block domain */ p4est_connectivity_t *conn = NULL; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL, *brick = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL, *brick = NULL; fclaw_options_t *gparms; user_options_t *user; @@ -183,21 +183,21 @@ void run_program(fclaw_app_t* app) domain = fclaw2d_domain_new_conn_map (mpicomm, gparms->minlevel, conn, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); /* --------------------------------------------------------------- Set domain data. --------------------------------------------------------------- */ fclaw2d_domain_set_app (domain,app); - fclaw2d_domain_data_new(domain); + you_can_safely_remove_this_call(domain); sphere_link_solvers(domain); - fclaw2d_initialize(&domain); - fclaw2d_run(&domain); - fclaw2d_finalize(&domain); + fclaw_initialize(&domain); + fclaw_run(&domain); + fclaw_finalize(&domain); } int diff --git a/applications/clawpack/shallow/2d/sphere/sphere_user.cpp b/applications/clawpack/shallow/2d/sphere/sphere_user.cpp index 6d378ca13..05ee10f14 100644 --- a/applications/clawpack/shallow/2d/sphere/sphere_user.cpp +++ b/applications/clawpack/shallow/2d/sphere/sphere_user.cpp @@ -24,16 +24,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "sphere_user.h" -#include +#include #include static fc2d_clawpack46_vtable_t classic_claw; -static fclaw2d_vtable_t vt; +static fclaw_vtable_t vt; -void sphere_link_solvers(fclaw2d_domain_t *domain) +void sphere_link_solvers(fclaw_domain_t *domain) { fclaw2d_init_vtable(&vt); fc2d_clawpack46_init_vtable(&classic_claw); @@ -62,8 +62,8 @@ void sphere_link_solvers(fclaw2d_domain_t *domain) } -void sphere_patch_manifold_setup(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void sphere_patch_manifold_setup(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -76,11 +76,11 @@ void sphere_patch_manifold_setup(fclaw2d_domain_t *domain, fc2d_clawpack46_define_auxarray(domain,this_patch); - fclaw2d_clawpatch_grid_data(domain,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(domain,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); fc2d_clawpack46_aux_data(domain,this_patch,&aux,&maux); - fclaw2d_clawpatch_metric_data2(domain,this_patch,&xnormals,&ynormals, + fclaw_clawpatch_2d_metric_data2(domain,this_patch,&xnormals,&ynormals, &xtangents,&ytangents,&surfnormals, &edgelengths,&curvature); diff --git a/applications/clawpack/shallow/2d/sphere/sphere_user.h b/applications/clawpack/shallow/2d/sphere/sphere_user.h index 6394ad0fe..a79529433 100644 --- a/applications/clawpack/shallow/2d/sphere/sphere_user.h +++ b/applications/clawpack/shallow/2d/sphere/sphere_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef SPHERE_USER_H #define SPHERE_USER_H -#include +#include #ifdef __cplusplus extern "C" @@ -45,28 +45,28 @@ void SETAUX_SPHERE(const int* mx, const int* my,const int* mbc, double xtangents[], double ytangents[], double surnormals[]); -void sphere_link_solvers(fclaw2d_domain_t *domain); +void sphere_link_solvers(fclaw_domain_t *domain); -void sphere_patch_manifold_setup(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void sphere_patch_manifold_setup(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx); -double sphere_patch_update(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +double sphere_patch_update(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -fclaw2d_map_context_t * - fclaw2d_map_new_latlong (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_latlong (fclaw_map_context_t* brick, const double scale[], const double lat[], const double longitude[], const int a, const int b); -fclaw2d_map_context_t * fclaw2d_map_new_cubedsphere (const double scale[], +fclaw_map_context_t * fclaw2d_map_new_cubedsphere (const double scale[], const double shift[], const double rotate[]); diff --git a/applications/clawpack/shallow/2d/sphere/user_4.6/qinit.f b/applications/clawpack/shallow/2d/sphere/user_4.6/qinit.f index 9f2380a09..185ee84da 100644 --- a/applications/clawpack/shallow/2d/sphere/user_4.6/qinit.f +++ b/applications/clawpack/shallow/2d/sphere/user_4.6/qinit.f @@ -22,7 +22,7 @@ subroutine qinit(maxmx,maxmy,meqn,mbc,mx,my, do i = 1-mbc,mx+mbc x = xlower + (i-1)*dx y = ylower + (j-1)*dy - call fclaw2d_map_c2m(cont,blockno,x,y,xp,yp,zp) + call fclaw_map_2d_c2m(cont,blockno,x,y,xp,yp,zp) q(i,j,1) = gaussian_sum(xp,yp,zp) + 0.2d0 q(i,j,2) = 0 q(i,j,3) = 0 diff --git a/applications/clawpack/shallow/2d/tsunami/tsunami.cpp b/applications/clawpack/shallow/2d/tsunami/tsunami.cpp index 9ec6074c7..fa1906a17 100644 --- a/applications/clawpack/shallow/2d/tsunami/tsunami.cpp +++ b/applications/clawpack/shallow/2d/tsunami/tsunami.cpp @@ -25,24 +25,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tsunami_user.h" -#include +#include -#include -#include +#include +#include #include #include static -fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, +fclaw_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt, user_options_t* user) { /* Mapped, multi-block domain */ p4est_connectivity_t *conn = NULL; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL, *brick= NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL, *brick= NULL; int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -53,31 +53,31 @@ fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, conn = p4est_connectivity_new_brick(mi,mj,a,b); brick = fclaw2d_map_new_brick_conn (conn,mi,mj); - cont = fclaw2d_map_new_nomap_brick(brick); + cont = fclaw_map_new_nomap_brick(brick); domain = fclaw2d_domain_new_conn_map (mpicomm, fclaw_opt->minlevel, conn, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); return domain; } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { /* --------------------------------------------------------------- Set domain data. --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); + you_can_safely_remove_this_call(glob->domain); /* Set domain dimensions so that we have square grid cells */ - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double ax = fclaw_opt->ax; double bx = fclaw_opt->bx; int mi = fclaw_opt->mi; - fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; double dx = (bx-ax)/(mi*mx); @@ -86,7 +86,7 @@ void run_program(fclaw2d_global_t* glob) /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_clawpack46_solver_initialize(glob); @@ -95,9 +95,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } @@ -111,10 +111,10 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; - fclaw2d_global_t *glob; - fclaw2d_domain_t *domain; + fclaw_global_t *glob; + fclaw_domain_t *domain; sc_MPI_Comm mpicomm; /* Initialize application */ @@ -122,7 +122,7 @@ main (int argc, char **argv) /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); user_opt = tsunami_options_register(app, "fclaw_options.ini"); @@ -138,18 +138,18 @@ main (int argc, char **argv) domain = create_domain(mpicomm, fclaw_opt,user_opt); /* Create global structure which stores the domain, timers, etc */ - glob = fclaw2d_global_new(); - fclaw2d_global_store_domain(glob, domain); + glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); tsunami_options_store (glob, user_opt); run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/shallow/2d/tsunami/tsunami_options.c b/applications/clawpack/shallow/2d/tsunami/tsunami_options.c index 46a5d4bd1..079d35418 100644 --- a/applications/clawpack/shallow/2d/tsunami/tsunami_options.c +++ b/applications/clawpack/shallow/2d/tsunami/tsunami_options.c @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tsunami_user.h" -#include +#include #include @@ -139,13 +139,13 @@ user_options_t* tsunami_options_register (fclaw_app_t * app, return user; } -void tsunami_options_store (fclaw2d_global_t* glob, user_options_t* user) +void tsunami_options_store (fclaw_global_t* glob, user_options_t* user) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"user") == NULL); fclaw_pointer_map_insert(glob->options, "user", user, NULL); } -user_options_t* tsunami_get_options(fclaw2d_global_t* glob) +user_options_t* tsunami_get_options(fclaw_global_t* glob) { user_options_t* user = (user_options_t*) fclaw_pointer_map_get(glob->options, "user"); diff --git a/applications/clawpack/shallow/2d/tsunami/tsunami_user.cpp b/applications/clawpack/shallow/2d/tsunami/tsunami_user.cpp index e2d8dc09f..c984fc47d 100644 --- a/applications/clawpack/shallow/2d/tsunami/tsunami_user.cpp +++ b/applications/clawpack/shallow/2d/tsunami/tsunami_user.cpp @@ -25,15 +25,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tsunami_user.h" -#include +#include #include #include -void tsunami_link_solvers(fclaw2d_global_t *glob) +void tsunami_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &tsunami_problem_setup; /* Version-independent */ //fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); @@ -46,7 +46,7 @@ void tsunami_link_solvers(fclaw2d_global_t *glob) } -void tsunami_problem_setup(fclaw2d_global_t* glob) +void tsunami_problem_setup(fclaw_global_t* glob) { const user_options_t* user = tsunami_get_options(glob); diff --git a/applications/clawpack/shallow/2d/tsunami/tsunami_user.h b/applications/clawpack/shallow/2d/tsunami/tsunami_user.h index 1dd8d9070..77c042708 100644 --- a/applications/clawpack/shallow/2d/tsunami/tsunami_user.h +++ b/applications/clawpack/shallow/2d/tsunami/tsunami_user.h @@ -26,7 +26,7 @@ #ifndef TSUNAMI_USER_H #define TSUNAMI_USER_H -#include +#include #ifdef __cplusplus extern "C" @@ -59,17 +59,17 @@ typedef struct user_options void TSUNAMI_SETPROB(); -void tsunami_problem_setup(fclaw2d_global_t *glob); -void tsunami_link_solvers(fclaw2d_global_t *glob); +void tsunami_problem_setup(fclaw_global_t *glob); +void tsunami_link_solvers(fclaw_global_t *glob); user_options_t* tsunami_options_register (fclaw_app_t * app, const char *configfile); -void tsunami_options_store (fclaw2d_global_t* glob, user_options_t* user); +void tsunami_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* tsunami_get_options(fclaw2d_global_t* glob); +user_options_t* tsunami_get_options(fclaw_global_t* glob); -fclaw2d_map_context_t* fclaw2d_map_new_nomap(); +fclaw_map_context_t* fclaw_map_new_nomap(); #ifdef __cplusplus #if 0 diff --git a/applications/clawpack/shallow/2d/tsunami/user_4.6/tag4refinement.f b/applications/clawpack/shallow/2d/tsunami/user_4.6/tag4refinement.f index d7134ca58..120afb475 100644 --- a/applications/clawpack/shallow/2d/tsunami/user_4.6/tag4refinement.f +++ b/applications/clawpack/shallow/2d/tsunami/user_4.6/tag4refinement.f @@ -11,7 +11,7 @@ subroutine tag4refinement(mx,my,mbc, double precision xp,yp,zp integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used integer i,j, mq double precision qmin, qmax, xc, yc diff --git a/applications/clawpack/shallow/2d/tsunami_cuda/tsunami.cpp b/applications/clawpack/shallow/2d/tsunami_cuda/tsunami.cpp index 6e7a5ad97..417b1fddf 100644 --- a/applications/clawpack/shallow/2d/tsunami_cuda/tsunami.cpp +++ b/applications/clawpack/shallow/2d/tsunami_cuda/tsunami.cpp @@ -25,10 +25,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tsunami_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -38,14 +38,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static -fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, +fclaw_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt, user_options_t* user) { /* Mapped, multi-block domain */ p4est_connectivity_t *conn = NULL; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL, *brick= NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL, *brick= NULL; int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -56,35 +56,35 @@ fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, conn = p4est_connectivity_new_brick(mi,mj,a,b); brick = fclaw2d_map_new_brick_conn (conn,mi,mj); - cont = fclaw2d_map_new_nomap_brick(brick); + cont = fclaw_map_new_nomap_brick(brick); domain = fclaw2d_domain_new_conn_map (mpicomm, fclaw_opt->minlevel, conn, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); return domain; } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { /* --------------------------------------------------------------- Set domain data. --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); + you_can_safely_remove_this_call(glob->domain); /* Set domain dimensions so that we have square grid cells */ - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); user_options_t* user_opt = tsunami_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); double ax = fclaw_opt->ax; double bx = fclaw_opt->bx; int mi = fclaw_opt->mi; - fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; double dx = (bx-ax)/(mi*mx); @@ -123,8 +123,8 @@ void run_program(fclaw2d_global_t* glob) fc2d_cudaclaw_allocate_buffers(glob); } - fclaw2d_initialize(glob); - fclaw2d_run(glob); + fclaw_initialize(glob); + fclaw_run(glob); if (user_opt->cuda == 1) { @@ -132,7 +132,7 @@ void run_program(fclaw2d_global_t* glob) fc2d_cudaclaw_deallocate_buffers(glob); } - fclaw2d_finalize(glob); + fclaw_finalize(glob); } @@ -146,12 +146,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_cudaclaw_options_t *cuclaw_opt; - fclaw2d_global_t *glob; - fclaw2d_domain_t *domain; + fclaw_global_t *glob; + fclaw_domain_t *domain; sc_MPI_Comm mpicomm; /* Initialize application */ @@ -159,7 +159,7 @@ main (int argc, char **argv) /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); cuclaw_opt = fc2d_cudaclaw_options_register(app, "fclaw_options.ini"); user_opt = tsunami_options_register(app, "fclaw_options.ini"); @@ -176,19 +176,19 @@ main (int argc, char **argv) domain = create_domain(mpicomm, fclaw_opt,user_opt); /* Create global structure which stores the domain, timers, etc */ - glob = fclaw2d_global_new(); - fclaw2d_global_store_domain(glob, domain); + glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_cudaclaw_options_store (glob, cuclaw_opt); tsunami_options_store (glob, user_opt); run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_options.c b/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_options.c index 6171e4e7b..9adc66fa7 100644 --- a/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_options.c +++ b/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_options.c @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tsunami_user.h" -#include +#include #include @@ -141,13 +141,13 @@ user_options_t* tsunami_options_register (fclaw_app_t * app, return user; } -void tsunami_options_store (fclaw2d_global_t* glob, user_options_t* user) +void tsunami_options_store (fclaw_global_t* glob, user_options_t* user) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"user") == NULL); fclaw_pointer_map_insert(glob->options, "user", user, NULL); } -user_options_t* tsunami_get_options(fclaw2d_global_t* glob) +user_options_t* tsunami_get_options(fclaw_global_t* glob) { user_options_t* user = (user_options_t*) fclaw_pointer_map_get(glob->options, "user"); diff --git a/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_user.cpp b/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_user.cpp index b6c66c07e..390c99bb5 100644 --- a/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_user.cpp +++ b/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_user.cpp @@ -25,16 +25,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "tsunami_user.h" -#include +#include #include #include #include -void tsunami_link_solvers(fclaw2d_global_t *glob) +void tsunami_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &geoclaw_problem_setup; /* Version-independent */ user_options_t* user = tsunami_get_options(glob); @@ -64,7 +64,7 @@ void tsunami_link_solvers(fclaw2d_global_t *glob) } -void geoclaw_problem_setup(fclaw2d_global_t* glob) +void geoclaw_problem_setup(fclaw_global_t* glob) { const user_options_t* user = tsunami_get_options(glob); diff --git a/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_user.h b/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_user.h index 91f9fa345..e2aef38c8 100644 --- a/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_user.h +++ b/applications/clawpack/shallow/2d/tsunami_cuda/tsunami_user.h @@ -26,7 +26,7 @@ #ifndef TSUNAMI_USER_H #define TSUNAMI_USER_H -#include +#include #include #ifdef __cplusplus @@ -71,17 +71,17 @@ void geoclaw_setprob_cuda(double grav, double dry_tolerance, double sea_level); /* --------------------------------------- Cuda ----------------------------------------*/ -void geoclaw_problem_setup(fclaw2d_global_t *glob); -void tsunami_link_solvers(fclaw2d_global_t *glob); +void geoclaw_problem_setup(fclaw_global_t *glob); +void tsunami_link_solvers(fclaw_global_t *glob); user_options_t* tsunami_options_register (fclaw_app_t * app, const char *configfile); -void tsunami_options_store (fclaw2d_global_t* glob, user_options_t* user); +void tsunami_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* tsunami_get_options(fclaw2d_global_t* glob); +user_options_t* tsunami_get_options(fclaw_global_t* glob); -fclaw2d_map_context_t* fclaw2d_map_new_nomap(); +fclaw_map_context_t* fclaw_map_new_nomap(); #ifdef __cplusplus #if 0 diff --git a/applications/clawpack/shallow/2d/tsunami_cuda/user_4.6/tag4refinement.f b/applications/clawpack/shallow/2d/tsunami_cuda/user_4.6/tag4refinement.f index d7134ca58..120afb475 100644 --- a/applications/clawpack/shallow/2d/tsunami_cuda/user_4.6/tag4refinement.f +++ b/applications/clawpack/shallow/2d/tsunami_cuda/user_4.6/tag4refinement.f @@ -11,7 +11,7 @@ subroutine tag4refinement(mx,my,mbc, double precision xp,yp,zp integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used integer i,j, mq double precision qmin, qmax, xc, yc diff --git a/applications/clawpack/transport/2d/all/fclaw2d_map_bilinear.c b/applications/clawpack/transport/2d/all/fclaw2d_map_bilinear.c index 6d3560651..c9e59dc91 100644 --- a/applications/clawpack/transport/2d/all/fclaw2d_map_bilinear.c +++ b/applications/clawpack/transport/2d/all/fclaw2d_map_bilinear.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -24,43 +24,43 @@ void SQUARE_BASIS_COMPLETE(const double* x, const double *y, const int* flag); static int -fclaw2d_map_query_bilinear (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_bilinear (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BILINEAR: + case FCLAW_MAP_QUERY_IS_BILINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -75,7 +75,7 @@ fclaw2d_map_query_bilinear (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_basis_bilinear(fclaw2d_map_context_t * cont, +fclaw2d_map_c2m_basis_bilinear(fclaw_map_context_t * cont, double xc, double yc, double *t, double *tinv, double *tderivs, int flag) @@ -87,7 +87,7 @@ fclaw2d_map_c2m_basis_bilinear(fclaw2d_map_context_t * cont, static void -fclaw2d_map_c2m_bilinear(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_bilinear(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { @@ -105,14 +105,14 @@ fclaw2d_map_c2m_bilinear(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_bilinear(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_bilinear(fclaw_map_context_t *brick, const double scale[], const double shift[], const double center[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO(fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO(fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_bilinear; cont->mapc2m = fclaw2d_map_c2m_bilinear; cont->basis = fclaw2d_map_c2m_basis_bilinear; diff --git a/applications/clawpack/transport/2d/all/fclaw2d_map_cart.c b/applications/clawpack/transport/2d/all/fclaw2d_map_cart.c index 813a84b0b..2e736cd27 100644 --- a/applications/clawpack/transport/2d/all/fclaw2d_map_cart.c +++ b/applications/clawpack/transport/2d/all/fclaw2d_map_cart.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -18,41 +18,41 @@ void SQUARE_BASIS_COMPLETE(const double* x, const double *y, const int* flag); static int -fclaw2d_map_query_cart (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_cart (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -67,7 +67,7 @@ fclaw2d_map_query_cart (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_basis_cart(fclaw2d_map_context_t * cont, +fclaw2d_map_c2m_basis_cart(fclaw_map_context_t * cont, double xc, double yc, double *t, double *tinv, double *tderivs, int flag) @@ -79,29 +79,29 @@ fclaw2d_map_c2m_basis_cart(fclaw2d_map_context_t * cont, static void -fclaw2d_map_c2m_cart(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_cart(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* Brick mapping to computational coordinates [0,1]x[0,1] */ double xc1, yc1, zc1; - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); /* Unit square in [-1,1] x [-1,1] */ - MAPC2M_CART(&blockno,&xc1,&yc1,xp,yp,zp); + FCLAW_MAP_2D_C2M_CART(&blockno,&xc1,&yc1,xp,yp,zp); scale_map(cont, xp,yp,zp); shift_map(cont, xp,yp,zp); } -fclaw2d_map_context_t* fclaw2d_map_new_cart(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_cart(fclaw_map_context_t *brick, const double scale[], const double shift[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_cart; cont->mapc2m = fclaw2d_map_c2m_cart; cont->basis = fclaw2d_map_c2m_basis_cart; diff --git a/applications/clawpack/transport/2d/all/fclaw2d_map_cubedsphere.c b/applications/clawpack/transport/2d/all/fclaw2d_map_cubedsphere.c index 6055581d3..0b1ce6cf2 100644 --- a/applications/clawpack/transport/2d/all/fclaw2d_map_cubedsphere.c +++ b/applications/clawpack/transport/2d/all/fclaw2d_map_cubedsphere.c @@ -1,6 +1,6 @@ /* Cubed sphere surface. Matches p4est_connectivity_new_cubed (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -25,42 +25,42 @@ void MAP2COMP(double* xp, double* yp, double* zp, double* xc1, double* yc1); static int -fclaw2d_map_query_cubedsphere (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_cubedsphere (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -75,7 +75,7 @@ fclaw2d_map_query_cubedsphere (fclaw2d_map_context_t * cont, int query_identifie static void -fclaw2d_map_c2m_basis_cubedsphere(fclaw2d_map_context_t * cont, +fclaw2d_map_c2m_basis_cubedsphere(fclaw_map_context_t * cont, double xc, double yc, double *t, double *tinv, double *tderivs, int flag) @@ -88,11 +88,11 @@ fclaw2d_map_c2m_basis_cubedsphere(fclaw2d_map_context_t * cont, static void -fclaw2d_map_c2m_cubedsphere (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_cubedsphere (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { - MAPC2M_CUBEDSPHERE(&blockno, &xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_C2M_CUBEDSPHERE(&blockno, &xc,&yc,xp,yp,zp); #if 0 rotate_map(cont,xp,yp,zp); @@ -100,12 +100,12 @@ fclaw2d_map_c2m_cubedsphere (fclaw2d_map_context_t * cont, int blockno, #endif } -fclaw2d_map_context_t * fclaw2d_map_new_cubedsphere(const double scale[], +fclaw_map_context_t * fclaw2d_map_new_cubedsphere(const double scale[], const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_cubedsphere; cont->mapc2m = fclaw2d_map_c2m_cubedsphere; cont->basis = fclaw2d_map_c2m_basis_cubedsphere; diff --git a/applications/clawpack/transport/2d/all/fclaw2d_map_fivepatch.c b/applications/clawpack/transport/2d/all/fclaw2d_map_fivepatch.c index 5f710f364..326cd15db 100644 --- a/applications/clawpack/transport/2d/all/fclaw2d_map_fivepatch.c +++ b/applications/clawpack/transport/2d/all/fclaw2d_map_fivepatch.c @@ -1,6 +1,6 @@ /* Five bilinear patches */ -#include +#include #ifdef __cplusplus extern "C" @@ -19,41 +19,41 @@ void SQUARE_BASIS_COMPLETE(const double* x, const double *y, static int -fclaw2d_map_query_fivepatch(fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_fivepatch(fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -67,7 +67,7 @@ fclaw2d_map_query_fivepatch(fclaw2d_map_context_t * cont, int query_identifier) } static void -fclaw2d_map_c2m_basis_fivepatch(fclaw2d_map_context_t * cont, +fclaw2d_map_c2m_basis_fivepatch(fclaw_map_context_t * cont, double xc, double yc, double *t, double *tinv, double *tderivs, int flag) @@ -80,14 +80,14 @@ fclaw2d_map_c2m_basis_fivepatch(fclaw2d_map_context_t * cont, static void -fclaw2d_map_c2m_fivepatch(fclaw2d_map_context_t* cont, int blockno, +fclaw2d_map_c2m_fivepatch(fclaw_map_context_t* cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { double alpha = cont->user_double[0]; /* Maps to [-1,1]x[-1,1] */ - MAPC2M_FIVEPATCH(&blockno,&xc,&yc,xp,yp,zp,&alpha); + FCLAW_MAP_2D_C2M_FIVEPATCH(&blockno,&xc,&yc,xp,yp,zp,&alpha); /* Scale to [-0.5,-0.5]x[0.5,0.5] */ scale_map(cont, xp,yp,zp); @@ -97,13 +97,13 @@ fclaw2d_map_c2m_fivepatch(fclaw2d_map_context_t* cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], const double shift[], const double alpha) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_fivepatch; cont->mapc2m = fclaw2d_map_c2m_fivepatch; cont->basis = fclaw2d_map_c2m_basis_fivepatch; diff --git a/applications/clawpack/transport/2d/all/fclaw2d_map_identity.c b/applications/clawpack/transport/2d/all/fclaw2d_map_identity.c index b5f1f4eda..66505e1a1 100644 --- a/applications/clawpack/transport/2d/all/fclaw2d_map_identity.c +++ b/applications/clawpack/transport/2d/all/fclaw2d_map_identity.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -17,41 +17,41 @@ void SQUARE_BASIS_COMPLETE(const double* x, const double *y, const int* flag); static int -fclaw2d_map_query_identity (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_identity (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 0; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -65,7 +65,7 @@ fclaw2d_map_query_identity (fclaw2d_map_context_t * cont, int query_identifier) } static void -fclaw2d_map_c2m_basis_identity(fclaw2d_map_context_t * cont, +fclaw2d_map_c2m_basis_identity(fclaw_map_context_t * cont, double xc, double yc, double *t, double *tinv, double *tderivs, int flag) @@ -75,14 +75,14 @@ fclaw2d_map_c2m_basis_identity(fclaw2d_map_context_t * cont, static void - fclaw2d_map_c2m_identity(fclaw2d_map_context_t * cont, int blockno, + fclaw2d_map_c2m_identity(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* Brick mapping to computational coordinates [0,1]x[0,1] */ double xc1, yc1, zc1; - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); *xp = xc1; *yp = yc1; @@ -90,10 +90,10 @@ static void } -fclaw2d_map_context_t* fclaw2d_map_new_identity(fclaw2d_map_context_t *brick) +fclaw_map_context_t* fclaw2d_map_new_identity(fclaw_map_context_t *brick) { - fclaw2d_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + fclaw_map_context_t *cont; + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_identity; cont->mapc2m = fclaw2d_map_c2m_identity; cont->basis = fclaw2d_map_c2m_basis_identity; diff --git a/applications/clawpack/transport/2d/all/fclaw2d_map_pillowsphere.c b/applications/clawpack/transport/2d/all/fclaw2d_map_pillowsphere.c index cf5e85038..fdfd793a1 100644 --- a/applications/clawpack/transport/2d/all/fclaw2d_map_pillowsphere.c +++ b/applications/clawpack/transport/2d/all/fclaw2d_map_pillowsphere.c @@ -1,6 +1,6 @@ /* Pillow grid surface. Matches p4est_connectivity_new_pillow (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -24,42 +24,42 @@ void MAP2COMP(double* xp, double* yp, double* zp, double* xc1, double* yc1); static int -fclaw2d_map_query_pillowsphere (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_pillowsphere (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 1; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -75,7 +75,7 @@ fclaw2d_map_query_pillowsphere (fclaw2d_map_context_t * cont, int query_identifi static void -fclaw2d_map_c2m_basis_pillowsphere(fclaw2d_map_context_t * cont, +fclaw2d_map_c2m_basis_pillowsphere(fclaw_map_context_t * cont, double xc, double yc, double *t, double *tinv, double *tderivs, int flag) @@ -85,11 +85,11 @@ fclaw2d_map_c2m_basis_pillowsphere(fclaw2d_map_context_t * cont, static void -fclaw2d_map_c2m_pillowsphere (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_pillowsphere (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { - MAPC2M_PILLOWSPHERE(&blockno,&xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_C2M_PILLOWSPHERE(&blockno,&xc,&yc,xp,yp,zp); #if 0 scale_map(cont,xp,yp,zp); @@ -97,12 +97,12 @@ fclaw2d_map_c2m_pillowsphere (fclaw2d_map_context_t * cont, int blockno, #endif } -fclaw2d_map_context_t * +fclaw_map_context_t * fclaw2d_map_new_pillowsphere(const double scale[],const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_pillowsphere; cont->mapc2m = fclaw2d_map_c2m_pillowsphere; cont->basis = fclaw2d_map_c2m_basis_pillowsphere; diff --git a/applications/clawpack/transport/2d/all/transport_b4step2_manifold.c b/applications/clawpack/transport/2d/all/transport_b4step2_manifold.c index 3c3de8653..bc7d8838f 100644 --- a/applications/clawpack/transport/2d/all/transport_b4step2_manifold.c +++ b/applications/clawpack/transport/2d/all/transport_b4step2_manifold.c @@ -25,8 +25,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "transport_user.h" -void transport_b4step2_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void transport_b4step2_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, double dt, @@ -35,22 +35,22 @@ void transport_b4step2_manifold(fclaw2d_global_t *glob, { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *xnormals,*ynormals,*xtangents,*ytangents,*surfnormals; - fclaw2d_clawpatch_metric_vector(glob,patch, + fclaw_clawpatch_2d_metric_vector(glob,patch, &xnormals, &ynormals, &xtangents, &ytangents, &surfnormals); double *xp, *yp, *zp, *xd, *yd, *zd, *area; - fclaw2d_clawpatch_metric_data(glob,patch,&xp,&yp,&zp, + fclaw_clawpatch_2d_metric_data(glob,patch,&xp,&yp,&zp, &xd,&yd,&zd,&area); double *aux; int maux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); // const user_options_t* user_opt = sphere_get_options(glob); if (claw_version == 4) diff --git a/applications/clawpack/transport/2d/all/transport_patch_setup_manifold.c b/applications/clawpack/transport/2d/all/transport_patch_setup_manifold.c index d89c9fcfc..7303e8003 100644 --- a/applications/clawpack/transport/2d/all/transport_patch_setup_manifold.c +++ b/applications/clawpack/transport/2d/all/transport_patch_setup_manifold.c @@ -26,23 +26,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "transport_user.h" -void transport_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void transport_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, int claw_version) { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *area, *edgelengths,*curvature; - fclaw2d_clawpatch_metric_scalar(glob, patch,&area,&edgelengths, + fclaw_clawpatch_2d_metric_scalar(glob, patch,&area,&edgelengths, &curvature); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); //const user_options_t* user_opt = sphere_get_options(glob); FCLAW_ASSERT(maux == 7); diff --git a/applications/clawpack/transport/2d/all/transport_user.cpp b/applications/clawpack/transport/2d/all/transport_user.cpp index 2ff26dacb..d4321bf19 100644 --- a/applications/clawpack/transport/2d/all/transport_user.cpp +++ b/applications/clawpack/transport/2d/all/transport_user.cpp @@ -25,32 +25,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "transport_user.h" -void transport_problem_setup(fclaw2d_global_t* glob) +void transport_problem_setup(fclaw_global_t* glob) { SETPROB(); } -void transport_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void transport_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, int claw_version) { - if (fclaw2d_patch_is_ghost(patch)) + if (fclaw_patch_is_ghost(patch)) return; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *xd, *yd, *zd,*xp,*yp, *zp, *area; - fclaw2d_clawpatch_metric_data(glob,patch,&xp,&yp,&zp, + fclaw_clawpatch_2d_metric_data(glob,patch,&xp,&yp,&zp, &xd,&yd,&zd,&area); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); if (claw_version == 4) USER46_SETAUX_MANIFOLD(&mbc,&mx,&my,&xlower,&ylower,&dx,&dy, @@ -60,8 +60,8 @@ void transport_patch_setup_manifold(fclaw2d_global_t *glob, &maux,aux,&blockno,xd,yd,zd,area); } -void transport_b4step2_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void transport_b4step2_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -70,16 +70,16 @@ void transport_b4step2_manifold(fclaw2d_global_t *glob, { int mx, my, mbc; double xlower,ylower, dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *xp,*yp,*zp,*xd,*yd,*zd; double *area; - fclaw2d_clawpatch_metric_data(glob,patch,&xp,&yp,&zp,&xd,&yd,&zd,&area); + fclaw_clawpatch_2d_metric_data(glob,patch,&xp,&yp,&zp,&xd,&yd,&zd,&area); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); if (claw_version == 4) USER46_B4STEP2_MANIFOLD(&mx,&my,&mbc,&dx,&dy,&t,&maux,aux,&blockno,xd,yd,zd); diff --git a/applications/clawpack/transport/2d/all/transport_user.h b/applications/clawpack/transport/2d/all/transport_user.h index 2f377de47..f3f9d4dba 100644 --- a/applications/clawpack/transport/2d/all/transport_user.h +++ b/applications/clawpack/transport/2d/all/transport_user.h @@ -26,13 +26,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef TRANSPORT_USER_H #define TRANSPORT_USER_H -#include +#include -#include +#include /* Headers for both Clawpack 4.6 and Clawpack 5.0 */ -#include -#include +#include +#include #include /* Clawpack 4.6 headers */ @@ -63,18 +63,18 @@ extern "C" struct fclaw_options; struct user_options; -struct fclaw2d_patch; -struct fclaw2d_domain; +struct fclaw_patch; +struct fclaw_domain; -void transport_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void transport_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, int claw_version); -void transport_b4step2_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void transport_b4step2_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -83,33 +83,33 @@ void transport_b4step2_manifold(fclaw2d_global_t *glob, /* --------------------------------- Square mappings ---------------------------------- */ -fclaw2d_map_context_t* fclaw2d_map_new_identity(fclaw2d_map_context_t *brick); +fclaw_map_context_t* fclaw2d_map_new_identity(fclaw_map_context_t *brick); -fclaw2d_map_context_t* fclaw2d_map_new_cart(fclaw2d_map_context_t* brick, +fclaw_map_context_t* fclaw2d_map_new_cart(fclaw_map_context_t* brick, const double scale[], const double shift[]); -fclaw2d_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], const double shift[], const double alpha); -fclaw2d_map_context_t* fclaw2d_map_new_bilinear(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_bilinear(fclaw_map_context_t *brick, const double scale[], const double shift[], const double center[]); /* --------------------------------- Sphere mappings ---------------------------------- */ -fclaw2d_map_context_t * fclaw2d_map_new_cubedsphere (const double scale[], +fclaw_map_context_t * fclaw2d_map_new_cubedsphere (const double scale[], const double rotate[]); -fclaw2d_map_context_t * fclaw2d_map_new_pillowsphere (const double scale[], +fclaw_map_context_t * fclaw2d_map_new_pillowsphere (const double scale[], const double rotate[]); /* ----------------------------------- Torus mapping ---------------------------------- */ -fclaw2d_map_context_t * - fclaw2d_map_new_torus (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_torus (fclaw_map_context_t* brick, const double scale[], const double rotate[], const double alpha, diff --git a/applications/clawpack/transport/2d/sonic/fclaw2d_map_bilinear.c b/applications/clawpack/transport/2d/sonic/fclaw2d_map_bilinear.c index de4973683..0b0fd87bc 100644 --- a/applications/clawpack/transport/2d/sonic/fclaw2d_map_bilinear.c +++ b/applications/clawpack/transport/2d/sonic/fclaw2d_map_bilinear.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -18,43 +18,43 @@ void MAPC2M_BILINEAR(int* blockno, double* xc, double *yc, static int -fclaw2d_map_query_bilinear (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_bilinear (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BILINEAR: + case FCLAW_MAP_QUERY_IS_BILINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -69,7 +69,7 @@ fclaw2d_map_query_bilinear (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_bilinear(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_bilinear(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { @@ -99,15 +99,15 @@ fclaw2d_map_c2m_bilinear(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_bilinear(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_bilinear(fclaw_map_context_t *brick, const double scale[], const double shift[], const double rotate[], const double center[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO(fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO(fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_bilinear; cont->mapc2m = fclaw2d_map_c2m_bilinear; cont->brick = brick; diff --git a/applications/clawpack/transport/2d/sonic/fclaw2d_map_cart.c b/applications/clawpack/transport/2d/sonic/fclaw2d_map_cart.c index 8eaaf50b5..87e3167e3 100644 --- a/applications/clawpack/transport/2d/sonic/fclaw2d_map_cart.c +++ b/applications/clawpack/transport/2d/sonic/fclaw2d_map_cart.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -11,41 +11,41 @@ extern "C" #endif static int -fclaw2d_map_query_cart (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_cart (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -60,17 +60,17 @@ fclaw2d_map_query_cart (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_cart(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_cart(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* Brick mapping to computational coordinates [0,1]x[0,1] */ double xc1, yc1, zc1; - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); /* Unit square in [-1,1] x [-1,1] */ - MAPC2M_CART(&blockno,&xc1,&yc1,xp,yp,zp); + FCLAW_MAP_2D_C2M_CART(&blockno,&xc1,&yc1,xp,yp,zp); scale_map(cont, xp,yp,zp); /* rotate_map(cont, xp,yp,zp); */ @@ -78,14 +78,14 @@ fclaw2d_map_c2m_cart(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_cart(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_cart(fclaw_map_context_t *brick, const double scale[], const double shift[], const double rotate[]) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_cart; cont->mapc2m = fclaw2d_map_c2m_cart; cont->brick = brick; diff --git a/applications/clawpack/transport/2d/sonic/fclaw2d_map_fivepatch.c b/applications/clawpack/transport/2d/sonic/fclaw2d_map_fivepatch.c index a8614f952..58ac3252f 100644 --- a/applications/clawpack/transport/2d/sonic/fclaw2d_map_fivepatch.c +++ b/applications/clawpack/transport/2d/sonic/fclaw2d_map_fivepatch.c @@ -1,6 +1,6 @@ /* Five bilinear patches */ -#include +#include #ifdef __cplusplus extern "C" @@ -17,41 +17,41 @@ void mapc2m(int* blockno, double* xc, double *yc, #endif static int -fclaw2d_map_query_fivepatch(fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_fivepatch(fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -66,12 +66,12 @@ fclaw2d_map_query_fivepatch(fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_fivepatch(fclaw2d_map_context_t* cont, int blockno, +fclaw2d_map_c2m_fivepatch(fclaw_map_context_t* cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { double alpha = cont->user_double[0]; - MAPC2M_FIVEPATCH(&blockno,&xc,&yc,xp,yp,zp,&alpha); + FCLAW_MAP_2D_C2M_FIVEPATCH(&blockno,&xc,&yc,xp,yp,zp,&alpha); scale_map(cont, xp,yp,zp); shift_map(cont, xp,yp,zp); @@ -81,14 +81,14 @@ fclaw2d_map_c2m_fivepatch(fclaw2d_map_context_t* cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], const double shift[], const double rotate[], const double alpha) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_fivepatch; cont->mapc2m = fclaw2d_map_c2m_fivepatch; diff --git a/applications/clawpack/transport/2d/sonic/fdisc.f b/applications/clawpack/transport/2d/sonic/fdisc.f index 53de5fa7d..e62b916d6 100644 --- a/applications/clawpack/transport/2d/sonic/fdisc.f +++ b/applications/clawpack/transport/2d/sonic/fdisc.f @@ -4,7 +4,7 @@ double precision function fdisc(blockno,xc,yc) double precision xc,yc, xp, yp, zp integer blockno integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used double precision dxc, xm, ym, w, wx, wy @@ -19,8 +19,8 @@ double precision function fdisc(blockno,xc,yc) cont = get_context() - if (fclaw2d_map_is_used(cont)) then - call fclaw2d_map_c2m(cont, + if (fclaw_map_is_used(cont)) then + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) else xp = xc diff --git a/applications/clawpack/transport/2d/sonic/qexact.f b/applications/clawpack/transport/2d/sonic/qexact.f index da26a5b8d..c2abbde5b 100644 --- a/applications/clawpack/transport/2d/sonic/qexact.f +++ b/applications/clawpack/transport/2d/sonic/qexact.f @@ -105,7 +105,7 @@ double precision function qexact(blockno, x,y,tfinal) yc0 = sigma(2) c # Map to [-1,1]x[-1,1] - call mapc2m_cart(blockno,xc0,yc0,xc1,yc1,zp) + call fclaw_map_2d_c2m_cart(blockno,xc0,yc0,xc1,yc1,zp) c # Map to [0,1]x[0,1] c xp = (1 + xc0)/2.d0 diff --git a/applications/clawpack/transport/2d/sonic/swirlcons.cpp b/applications/clawpack/transport/2d/sonic/swirlcons.cpp index fe395d9fd..b85e4cc0c 100644 --- a/applications/clawpack/transport/2d/sonic/swirlcons.cpp +++ b/applications/clawpack/transport/2d/sonic/swirlcons.cpp @@ -25,21 +25,21 @@ #include "swirlcons_user.h" -#include +#include -#include -#include +#include +#include #include #include static -fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt, +fclaw_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt, user_options_t *user) { /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain = NULL; - fclaw2d_map_context_t *cont = NULL, *brick = NULL; + fclaw_domain_t *domain = NULL; + fclaw_map_context_t *cont = NULL, *brick = NULL; int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -54,16 +54,16 @@ fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt, case 0: /* Square brick domain */ - domain = fclaw2d_domain_new_brick (mpicomm, mi, mj, a, b, + domain = fclaw_domain_new_2d_brick (mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick (domain, mi, mj, a, b); - cont = fclaw2d_map_new_nomap_brick (brick); + brick = fclaw_map_new_2d_brick (domain, mi, mj, a, b); + cont = fclaw_map_new_nomap_brick (brick); break; case 1: - domain = fclaw2d_domain_new_brick (mpicomm, mi, mj, a, b, + domain = fclaw_domain_new_2d_brick (mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick (domain, mi, mj, a, b); + brick = fclaw_map_new_2d_brick (domain, mi, mj, a, b); cont = fclaw2d_map_new_cart (brick, fclaw_opt->scale, fclaw_opt->shift, rotate); @@ -71,16 +71,16 @@ fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt, case 2: /* Five patch square domain */ - domain = fclaw2d_domain_new_disk (mpicomm, 1, 1, fclaw_opt->minlevel); + domain = fclaw_domain_new_2d_disk (mpicomm, 1, 1, fclaw_opt->minlevel); cont = fclaw2d_map_new_fivepatch (fclaw_opt->scale, fclaw_opt->shift, rotate, user->alpha); break; case 3: /* bilinear square domain */ - domain = fclaw2d_domain_new_brick (mpicomm, mi, mj, a, b, + domain = fclaw_domain_new_2d_brick (mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick (domain, mi, mj, a, b); + brick = fclaw_map_new_2d_brick (domain, mi, mj, a, b); cont = fclaw2d_map_new_bilinear (brick, fclaw_opt->scale, fclaw_opt->shift, rotate, user->center); break; @@ -89,22 +89,22 @@ fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt, SC_ABORT_NOT_REACHED (); } - fclaw2d_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); - fclaw2d_global_store_domain (glob, domain); - fclaw2d_global_store_map (glob, cont); + fclaw_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); + fclaw_global_store_domain (glob, domain); + fclaw_map_store (glob, cont); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { /* --------------------------------------------------------------- Set domain data. --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); + you_can_safely_remove_this_call(glob->domain); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ fc2d_clawpack46_solver_initialize(glob); @@ -114,9 +114,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -129,11 +129,11 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; - fclaw2d_global_t *glob; - fclaw2d_domain_t *domain; + fclaw_global_t *glob; + fclaw_domain_t *domain; sc_MPI_Comm mpicomm; /* Initialize application */ @@ -141,7 +141,7 @@ main (int argc, char **argv) /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); user_opt = swirlcons_options_register(app, "fclaw_options.ini"); @@ -157,18 +157,18 @@ main (int argc, char **argv) domain = create_domain(mpicomm, fclaw_opt,user_opt); /* Create global structure which stores the domain, timers, etc */ - glob = fclaw2d_global_new(); - fclaw2d_global_store_domain(glob, domain); + glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); swirlcons_options_store (glob, user_opt); run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/transport/2d/sonic/swirlcons_options.c b/applications/clawpack/transport/2d/sonic/swirlcons_options.c index 6cac6dd7c..0b89cd89e 100644 --- a/applications/clawpack/transport/2d/sonic/swirlcons_options.c +++ b/applications/clawpack/transport/2d/sonic/swirlcons_options.c @@ -175,13 +175,13 @@ user_options_t* swirlcons_options_register (fclaw_app_t * app, return user; } -void swirlcons_options_store (fclaw2d_global_t* glob, user_options_t* user) +void swirlcons_options_store (fclaw_global_t* glob, user_options_t* user) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"user") == NULL); fclaw_pointer_map_insert(glob->options, "user", user, NULL); } -const user_options_t* swirlcons_get_options(fclaw2d_global_t* glob) +const user_options_t* swirlcons_get_options(fclaw_global_t* glob) { user_options_t* user = (user_options_t*) fclaw_pointer_map_get(glob->options, "user"); diff --git a/applications/clawpack/transport/2d/sonic/swirlcons_user.cpp b/applications/clawpack/transport/2d/sonic/swirlcons_user.cpp index aae958737..d9b5feead 100644 --- a/applications/clawpack/transport/2d/sonic/swirlcons_user.cpp +++ b/applications/clawpack/transport/2d/sonic/swirlcons_user.cpp @@ -25,35 +25,35 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "swirlcons_user.h" -#include +#include #include #include #include /* Headers for user defined fortran files */ -#include +#include #include /* headers for tag2refinement, tag4coarsening */ #include "../all/advection_user_fort.h" static -void cb_swirl_output_ascii (fclaw2d_domain_t * domain, - fclaw2d_patch_t * this_patch, +void cb_swirl_output_ascii (fclaw_domain_t * domain, + fclaw_patch_t * this_patch, int this_block_idx, int this_patch_idx, void *user); -void swirlcons_link_solvers(fclaw2d_global_t *glob) +void swirlcons_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); fc2d_clawpack46_vtable_t *clawpack46_vt = fc2d_clawpack46_vt(glob); fc2d_clawpack46_options_t *clawopt = fc2d_clawpack46_get_options(glob); const user_options_t* user = swirlcons_get_options(glob); - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); /* ForestClaw functions */ vt->problem_setup = &swirlcons_problem_setup; /* Version-independent */ @@ -130,7 +130,7 @@ void swirlcons_link_solvers(fclaw2d_global_t *glob) clawpack46_vt->fort_qinit = CLAWPACK46_QINIT; } -void swirlcons_problem_setup(fclaw2d_global_t* glob) +void swirlcons_problem_setup(fclaw_global_t* glob) { const user_options_t* user = swirlcons_get_options(glob); @@ -151,7 +151,7 @@ void swirlcons_problem_setup(fclaw2d_global_t* glob) MPI_Barrier(MPI_COMM_WORLD); #endif - fclaw2d_domain_barrier (glob->domain); /* redundant? */ + fclaw_domain_barrier (glob->domain); /* redundant? */ SWIRLCONS_SETPROB(); #if 0 @@ -162,8 +162,8 @@ void swirlcons_problem_setup(fclaw2d_global_t* glob) } -void swirlcons_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void swirlcons_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -172,27 +172,27 @@ void swirlcons_patch_setup_manifold(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *xp, *yp, *zp, *xd, *yd, *zd, *area; - fclaw2d_clawpatch_metric_data(glob,patch,&xp,&yp,&zp, + fclaw_clawpatch_2d_metric_data(glob,patch,&xp,&yp,&zp, &xd,&yd,&zd,&area); double *edgelengths, *curvature; - fclaw2d_clawpatch_metric_scalar(glob, patch, &area,&edgelengths, + fclaw_clawpatch_2d_metric_scalar(glob, patch, &area,&edgelengths, &curvature); double *xnormals,*ynormals,*xtangents,*ytangents,*surfnormals; - fclaw2d_clawpatch_metric_vector(glob,patch, + fclaw_clawpatch_2d_metric_vector(glob,patch, &xnormals, &ynormals, &xtangents, &ytangents, &surfnormals); double *aux; int maux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); switch(user->mapping) { @@ -217,13 +217,13 @@ void swirlcons_patch_setup_manifold(fclaw2d_global_t *glob, } static -void cb_swirl_output_ascii (fclaw2d_domain_t * domain, - fclaw2d_patch_t * patch, +void cb_swirl_output_ascii (fclaw_domain_t * domain, + fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) s->glob; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) s->glob; int iframe = *((int *) s->user); double time = glob->curr_time; @@ -231,25 +231,25 @@ void cb_swirl_output_ascii (fclaw2d_domain_t * domain, /* Get info not readily available to user */ int local_patch_num, global_num, level; - fclaw2d_patch_get_info(glob->domain,patch, + fclaw_patch_get_info(glob->domain,patch, blockno,patchno, &global_num, &local_patch_num,&level); int mx,my,mbc; double xlower, ylower, dx, dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); - double* error = fclaw2d_clawpatch_get_error(glob,patch); - double* soln = fclaw2d_clawpatch_get_exactsoln(glob,patch); + double* error = fclaw_clawpatch_get_error(glob,patch); + double* soln = fclaw_clawpatch_get_exactsoln(glob,patch); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); char fname[BUFSIZ]; snprintf (fname, BUFSIZ, "%s.q%04d", fclaw_opt->prefix, iframe); diff --git a/applications/clawpack/transport/2d/sonic/swirlcons_user.h b/applications/clawpack/transport/2d/sonic/swirlcons_user.h index 5589e502d..1b1706cee 100644 --- a/applications/clawpack/transport/2d/sonic/swirlcons_user.h +++ b/applications/clawpack/transport/2d/sonic/swirlcons_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef SWIRLCONS_USER_H #define SWIRLCONS_USER_H -#include +#include #ifdef __cplusplus extern "C" @@ -55,52 +55,52 @@ typedef struct user_options } user_options_t; -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; #define SWIRLCONS_SETPROB FCLAW_F77_FUNC(swirlcons_setprob, SWIRLCONS_SETPROB) void SWIRLCONS_SETPROB(); -void swirlcons_link_solvers(struct fclaw2d_global *glob); +void swirlcons_link_solvers(struct fclaw_global *glob); -void swirlcons_problem_setup(struct fclaw2d_global* glob); +void swirlcons_problem_setup(struct fclaw_global* glob); /* ---------------------------------- Options ----------------------------------------- */ -const user_options_t* swirlcons_get_options(struct fclaw2d_global* glob); +const user_options_t* swirlcons_get_options(struct fclaw_global* glob); -void swirlcons_options_store (fclaw2d_global_t* glob, user_options_t* user); +void swirlcons_options_store (fclaw_global_t* glob, user_options_t* user); user_options_t* swirlcons_options_register (fclaw_app_t * app, const char *configfile); /* --------------------------------- Mappings ----------------------------------------- */ -fclaw2d_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], const double shift[], const double rotate[], const double alpha); -fclaw2d_map_context_t* fclaw2d_map_new_cart (fclaw2d_map_context_t* brick, +fclaw_map_context_t* fclaw2d_map_new_cart (fclaw_map_context_t* brick, const double scale[], const double shift[], const double rotate[]); -fclaw2d_map_context_t* fclaw2d_map_new_bilinear(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_bilinear(fclaw_map_context_t *brick, const double scale[], const double shift[], const double rotate[], const double center[]); -void swirlcons_patch_setup_manifold(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void swirlcons_patch_setup_manifold(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); /* --------------------------------- Riemann Problems --------------------------------- */ -void swirlcons_options_store (fclaw2d_global_t* glob, user_options_t* user); +void swirlcons_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* swirlcons_get_options(fclaw2d_global_t* glob); +const user_options_t* swirlcons_get_options(fclaw_global_t* glob); /* ---------------------------- Fortran headers --------------------------------------- */ diff --git a/applications/clawpack/transport/2d/sonic/user_4.6/compute_error.f b/applications/clawpack/transport/2d/sonic/user_4.6/compute_error.f index b9ad1e26a..6e4d7781e 100644 --- a/applications/clawpack/transport/2d/sonic/user_4.6/compute_error.f +++ b/applications/clawpack/transport/2d/sonic/user_4.6/compute_error.f @@ -28,7 +28,7 @@ subroutine swirl46_compute_error(blockno, mx,my,mbc,meqn, if (t .eq. 0) then soln(i,j,1) = q(i,j,1) else - call fclaw2d_map_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) + call fclaw_map_2d_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) call swirl_transform_coordinates(xc1,yc1,x,y,mapping) soln(i,j,1) = qexact(blockno,x,y,t) endif diff --git a/applications/clawpack/transport/2d/sonic/user_4.6/qinit.f b/applications/clawpack/transport/2d/sonic/user_4.6/qinit.f index df84c5dc2..6cc62d3ec 100644 --- a/applications/clawpack/transport/2d/sonic/user_4.6/qinit.f +++ b/applications/clawpack/transport/2d/sonic/user_4.6/qinit.f @@ -14,7 +14,7 @@ subroutine clawpack46_qinit(maxmx,maxmy, meqn,mbc,mx,my, double precision q0_physical integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used integer ii,jj @@ -37,13 +37,13 @@ subroutine clawpack46_qinit(maxmx,maxmy, meqn,mbc,mx,my, call cellave2(blockno,xlow,ylow,dx,dy,w) q(i,j,1) = w elseif (initchoice .eq. 1) then - call fclaw2d_map_c2m(cont,blockno,xc,yc,xp,yp,zp) + call fclaw_map_2d_c2m(cont,blockno,xc,yc,xp,yp,zp) q(i,j,1) = q0_physical(xp,yp,zp) elseif (initchoice .eq. 2) then q(i,j,1) = 1.d0 elseif (initchoice .eq. 3) then - if (fclaw2d_map_is_used(cont)) then - call fclaw2d_map_c2m(cont, + if (fclaw_map_is_used(cont)) then + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) else xp = xc diff --git a/applications/clawpack/transport/2d/sonic/user_4.6/swirl46_setaux.f b/applications/clawpack/transport/2d/sonic/user_4.6/swirl46_setaux.f index 08e88752b..c71bf7567 100644 --- a/applications/clawpack/transport/2d/sonic/user_4.6/swirl46_setaux.f +++ b/applications/clawpack/transport/2d/sonic/user_4.6/swirl46_setaux.f @@ -101,14 +101,14 @@ subroutine swirl46_set_edge_velocities(mx,my,mbc, yc = ylower + j*dy c # Map the brick to a unit square - call fclaw2d_map_brick2c(cont, blockno,xc,yc,xc1,yc1,zc1) + call fclaw_map_2d_brick2c(cont, blockno,xc,yc,xc1,yc1,zc1) c # x-face - lower vertex xc = xlower + (i-1)*dx yc = ylower + (j-1)*dy c # Map the brick to a unit square - call fclaw2d_map_brick2c(cont, blockno,xc,yc,xc2,yc2,zc2) + call fclaw_map_2d_brick2c(cont, blockno,xc,yc,xc2,yc2,zc2) c # [x;y] = a*e1 + b*e1 = L*[a;b] call swirl_transform_coordinates(xc1,yc1,x1,y1,mapping) @@ -127,12 +127,12 @@ subroutine swirl46_set_edge_velocities(mx,my,mbc, c # y-face - right vertex xc = xlower + i*dx yc = ylower + (j-1)*dy - call fclaw2d_map_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) + call fclaw_map_2d_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) c # y-face - left vertex xc = xlower + (i-1)*dx yc = ylower + (j-1)*dy - call fclaw2d_map_brick2c(cont,blockno,xc,yc,xc2,yc2,zc2) + call fclaw_map_2d_brick2c(cont,blockno,xc,yc,xc2,yc2,zc2) call swirl_transform_coordinates(xc1,yc1,x1,y1,mapping) call swirl_transform_coordinates(xc2,yc2,x2,y2,mapping) @@ -186,7 +186,7 @@ subroutine swirl46_set_center_velocities(mx,my,mbc, c # This is not the swirl mapping, but rather maps the brick to c # a unit square - call fclaw2d_map_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) + call fclaw_map_2d_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) call swirl_transform_coordinates(xc1,yc1,x,y,mapping) call swirl_center_velocity(x,y,vel) diff --git a/applications/clawpack/transport/2d/sonic/user_4.6/tag4refinement.f b/applications/clawpack/transport/2d/sonic/user_4.6/tag4refinement.f index cc9ea2ebb..d04c5a8a7 100644 --- a/applications/clawpack/transport/2d/sonic/user_4.6/tag4refinement.f +++ b/applications/clawpack/transport/2d/sonic/user_4.6/tag4refinement.f @@ -11,7 +11,7 @@ subroutine clawpack46_tag4refinement(mx,my,mbc, double precision xp,yp,zp integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used integer i,j, mq double precision qmin, qmax, xc, yc diff --git a/applications/clawpack/transport/2d/sphere/fdisc.f b/applications/clawpack/transport/2d/sphere/fdisc.f index 72e9bcd4c..f75bbe4ed 100644 --- a/applications/clawpack/transport/2d/sphere/fdisc.f +++ b/applications/clawpack/transport/2d/sphere/fdisc.f @@ -18,7 +18,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) call map2spherical(xp,yp,zp,theta,phi) diff --git a/applications/clawpack/transport/2d/sphere/mapping_terms.f b/applications/clawpack/transport/2d/sphere/mapping_terms.f index beb095c39..5f1c60bc7 100644 --- a/applications/clawpack/transport/2d/sphere/mapping_terms.f +++ b/applications/clawpack/transport/2d/sphere/mapping_terms.f @@ -29,7 +29,7 @@ subroutine map_covariant_basis(x,y,t1,t2) c # Compute covariant derivatives only flag = 1 - call fclaw2d_map_c2m_basis(cont, + call fclaw_map_2d_c2m_basis(cont, & x,y, t, tinv, tderivs, flag) do k = 1,3 @@ -53,7 +53,7 @@ subroutine map_contravariant_basis(x,y,t1inv,t2inv) cont = fclaw_map_get_context() flag = 3 - call fclaw2d_map_c2m_basis(cont, x,y, t, tinv,tderivs, flag) + call fclaw_map_2d_c2m_basis(cont, x,y, t, tinv,tderivs, flag) do k = 1,3 @@ -86,7 +86,7 @@ subroutine map_christoffel_sym(x,y,g) c # Compute covariant and derivatives flag = 7 - call fclaw2d_map_c2m_basis(cont, x,y, t,tinv,tderivs,flag) + call fclaw_map_2d_c2m_basis(cont, x,y, t,tinv,tderivs,flag) do k = 1,3 @@ -194,7 +194,7 @@ subroutine map_diff_normalized(x,y,u, uderivs, cont = fclaw_map_get_context() flag = 7 - call fclaw2d_map_c2m_basis(cont,x,y,t,tinv, tderivs,flag) + call fclaw_map_2d_c2m_basis(cont,x,y,t,tinv, tderivs,flag) do k = 1,3 t1(k) = t(k,1) diff --git a/applications/clawpack/transport/2d/sphere/sphere.cpp b/applications/clawpack/transport/2d/sphere/sphere.cpp index 14dc57f28..5791335af 100644 --- a/applications/clawpack/transport/2d/sphere/sphere.cpp +++ b/applications/clawpack/transport/2d/sphere/sphere.cpp @@ -26,29 +26,29 @@ #include "sphere_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); double rotate[2]; rotate[0] = fclaw_opt->phi; rotate[1] = fclaw_opt->theta; /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; const user_options_t *user_opt = sphere_get_options(glob); switch (user_opt->mapping) { case 0: domain = - fclaw2d_domain_new_cubedsphere(glob->mpicomm, + fclaw_domain_new_2d_cubedsphere(glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_cubedsphere(fclaw_opt->scale, rotate); break; case 1: domain = - fclaw2d_domain_new_twosphere(glob->mpicomm, + fclaw_domain_new_2d_twosphere(glob->mpicomm, fclaw_opt->minlevel); cont = fclaw2d_map_new_pillowsphere (fclaw_opt->scale, rotate); @@ -58,26 +58,21 @@ void create_domain(fclaw2d_global_t *glob) } /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); user_options_t *user_opt = (user_options_t*) sphere_get_options(glob); if (user_opt->claw_version == 4) @@ -95,9 +90,9 @@ void run_program(fclaw2d_global_t* glob) Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -109,13 +104,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = sphere_options_register(app, "fclaw_options.ini"); @@ -131,11 +126,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); sphere_options_store (glob, user_opt); @@ -145,7 +140,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/transport/2d/sphere/sphere_options.c b/applications/clawpack/transport/2d/sphere/sphere_options.c index 482c1e05d..354bfb4d6 100644 --- a/applications/clawpack/transport/2d/sphere/sphere_options.c +++ b/applications/clawpack/transport/2d/sphere/sphere_options.c @@ -158,12 +158,12 @@ user_options_t* sphere_options_register (fclaw_app_t * app, return user; } -void sphere_options_store (fclaw2d_global_t* glob, user_options_t* user) +void sphere_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* sphere_get_options(fclaw2d_global_t* glob) +const user_options_t* sphere_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/transport/2d/sphere/sphere_user.cpp b/applications/clawpack/transport/2d/sphere/sphere_user.cpp index 2ca58cab0..f344b66d7 100644 --- a/applications/clawpack/transport/2d/sphere/sphere_user.cpp +++ b/applications/clawpack/transport/2d/sphere/sphere_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "sphere_user.h" static -void sphere_problem_setup(fclaw2d_global_t* glob) +void sphere_problem_setup(fclaw_global_t* glob) { const user_options_t* user = sphere_get_options(glob); @@ -42,12 +42,12 @@ void sphere_problem_setup(fclaw2d_global_t* glob) fprintf(f, "%-24d %s",user->refine_pattern,"\% refinement_pattern\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } -void sphere_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void sphere_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -58,8 +58,8 @@ void sphere_patch_setup_manifold(fclaw2d_global_t *glob, static -void sphere_b4step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void sphere_b4step2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, double dt) @@ -72,13 +72,13 @@ void sphere_b4step2(fclaw2d_global_t *glob, static -void cb_sphere_output_ascii (fclaw2d_domain_t * domain, - fclaw2d_patch_t * patch, +void cb_sphere_output_ascii (fclaw_domain_t * domain, + fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) s->glob; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) s->glob; //fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); @@ -86,23 +86,23 @@ void cb_sphere_output_ascii (fclaw2d_domain_t * domain, /* Get info not readily available to user */ int global_patch_num, local_patch_num, level; - fclaw2d_patch_get_info(glob->domain,patch, + fclaw_patch_get_info(glob->domain,patch, blockno,patchno, &global_patch_num,&local_patch_num,&level); int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); - double* error = fclaw2d_clawpatch_get_error(glob,patch); - double* soln = fclaw2d_clawpatch_get_exactsoln(glob,patch); + double* error = fclaw_clawpatch_get_error(glob,patch); + double* soln = fclaw_clawpatch_get_exactsoln(glob,patch); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); char fname[BUFSIZ]; snprintf (fname, BUFSIZ, "%s.q%04d", fclaw_opt->prefix, iframe); @@ -131,19 +131,19 @@ void cb_sphere_output_ascii (fclaw2d_domain_t * domain, -void sphere_link_solvers(fclaw2d_global_t *glob) +void sphere_link_solvers(fclaw_global_t *glob) { /* ForestClaw core functions */ - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &sphere_problem_setup; /* Version-independent */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &sphere_patch_setup_manifold; const user_options_t* user_opt = sphere_get_options(glob); if (user_opt->mapping == 1) - fclaw2d_clawpatch_use_pillowsphere(glob); + fclaw_clawpatch_use_pillowsphere(glob); if (user_opt->claw_version == 4) { @@ -155,13 +155,13 @@ void sphere_link_solvers(fclaw2d_global_t *glob) clawpack46_vt->fort_rpn2_cons = &RPN2CONS_UPDATE_MANIFOLD; /* Clawpatch functions */ - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); /* Include error in output files */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (fclaw_opt->compute_error) { - clawpatch_vt->fort_compute_patch_error = &SPHERE46_COMPUTE_ERROR; + clawpatch_vt->d2->fort_compute_patch_error = &SPHERE46_COMPUTE_ERROR; clawpatch_vt->fort_header_ascii = &SPHERE46_FORT_HEADER_ASCII; clawpatch_vt->cb_output_ascii = &cb_sphere_output_ascii; } @@ -176,13 +176,13 @@ void sphere_link_solvers(fclaw2d_global_t *glob) clawpack5_vt->fort_rpn2_cons = &RPN2CONS_UPDATE_MANIFOLD; /* Clawpatch functions */ - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); /* Include error in output files */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (fclaw_opt->compute_error) { - clawpatch_vt->fort_compute_patch_error = &SPHERE5_COMPUTE_ERROR; + clawpatch_vt->d2->fort_compute_patch_error = &SPHERE5_COMPUTE_ERROR; clawpatch_vt->fort_header_ascii = &SPHERE5_FORT_HEADER_ASCII; clawpatch_vt->cb_output_ascii = &cb_sphere_output_ascii; } diff --git a/applications/clawpack/transport/2d/sphere/sphere_user.h b/applications/clawpack/transport/2d/sphere/sphere_user.h index 9da3c8108..fbd1ac946 100644 --- a/applications/clawpack/transport/2d/sphere/sphere_user.h +++ b/applications/clawpack/transport/2d/sphere/sphere_user.h @@ -52,20 +52,20 @@ typedef struct user_options } user_options_t; -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; #if 0 /* So syntax highlighting works */ #endif -void sphere_link_solvers(struct fclaw2d_global *glob); +void sphere_link_solvers(struct fclaw_global *glob); /* ---------------------------------- Options ----------------------------------------- */ -const user_options_t* sphere_get_options(struct fclaw2d_global* glob); +const user_options_t* sphere_get_options(struct fclaw_global* glob); -void sphere_options_store (fclaw2d_global_t* glob, user_options_t* user); +void sphere_options_store (fclaw_global_t* glob, user_options_t* user); user_options_t* sphere_options_register (fclaw_app_t * app, const char *configfile); diff --git a/applications/clawpack/transport/2d/sphere/user_4.6/sphere46_compute_error.f b/applications/clawpack/transport/2d/sphere/user_4.6/sphere46_compute_error.f index fb914157b..b4956e9a8 100644 --- a/applications/clawpack/transport/2d/sphere/user_4.6/sphere46_compute_error.f +++ b/applications/clawpack/transport/2d/sphere/user_4.6/sphere46_compute_error.f @@ -40,7 +40,7 @@ subroutine sphere46_compute_error(blockno, mx,my,mbc,meqn, soln(i,j,1) = q(i,j,1) else c # Map computational coordinates to unit square - call fclaw2d_map_c2m(cont,blockno,xc,yc,xp, yp, zp) + call fclaw_map_2d_c2m(cont,blockno,xc,yc,xp, yp, zp) call user_map2comp(blockno,xc,yc,xp,yp,zp,xc1,yc1) soln(i,j,1) = qexact(xc1,yc1,t,flow_flag) endif diff --git a/applications/clawpack/transport/2d/sphere/user_4.6/sphere46_qinit.f b/applications/clawpack/transport/2d/sphere/user_4.6/sphere46_qinit.f index 63247a44f..c84ef4463 100644 --- a/applications/clawpack/transport/2d/sphere/user_4.6/sphere46_qinit.f +++ b/applications/clawpack/transport/2d/sphere/user_4.6/sphere46_qinit.f @@ -35,7 +35,7 @@ subroutine clawpack46_qinit(maxmx,maxmy, meqn,mbc,mx,my, elseif (initchoice .eq. 1) then q(i,j,1) = 1.d0 else - call fclaw2d_map_c2m(cont,blockno,xc,yc,xp,yp,zp) + call fclaw_map_2d_c2m(cont,blockno,xc,yc,xp,yp,zp) q(i,j,1) = q0_physical(xp,yp,zp) endif enddo diff --git a/applications/clawpack/transport/2d/sphere/user_5.0/sphere5_compute_error.f b/applications/clawpack/transport/2d/sphere/user_5.0/sphere5_compute_error.f index 3eba7f7d1..a85334dd2 100644 --- a/applications/clawpack/transport/2d/sphere/user_5.0/sphere5_compute_error.f +++ b/applications/clawpack/transport/2d/sphere/user_5.0/sphere5_compute_error.f @@ -40,7 +40,7 @@ subroutine sphere5_compute_error(blockno, mx,my,mbc,meqn, soln(1,i,j) = q(1,i,j) else c # Map computational coordinates to unit square - call fclaw2d_map_c2m(cont,blockno,xc,yc,xp, yp, zp) + call fclaw_map_2d_c2m(cont,blockno,xc,yc,xp, yp, zp) call user_map2comp(blockno,xc,yc,xp,yp,zp,xc1,yc1) soln(1,i,j) = qexact(xc1,yc1,t,flow_flag) endif diff --git a/applications/clawpack/transport/2d/sphere/user_5.0/sphere5_qinit.f b/applications/clawpack/transport/2d/sphere/user_5.0/sphere5_qinit.f index 907258652..7b2fd8507 100644 --- a/applications/clawpack/transport/2d/sphere/user_5.0/sphere5_qinit.f +++ b/applications/clawpack/transport/2d/sphere/user_5.0/sphere5_qinit.f @@ -35,7 +35,7 @@ subroutine clawpack5_qinit(meqn,mbc,mx,my, elseif (initchoice .eq. 1) then q(1,i,j) = 1.d0 else - call fclaw2d_map_c2m(cont,blockno,xc,yc,xp,yp,zp) + call fclaw_map_2d_c2m(cont,blockno,xc,yc,xp,yp,zp) q(1,i,j) = q0_physical(xp,yp,zp) endif enddo diff --git a/applications/clawpack/transport/2d/square/fdisc.f b/applications/clawpack/transport/2d/square/fdisc.f index 3f589b51b..01bbd9818 100644 --- a/applications/clawpack/transport/2d/square/fdisc.f +++ b/applications/clawpack/transport/2d/square/fdisc.f @@ -8,7 +8,7 @@ double precision function fdisc(blockno,xc,yc) common /example_comm/ example integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used double precision xp, yp, zp @@ -17,8 +17,8 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - if (fclaw2d_map_is_used(cont)) then - call fclaw2d_map_c2m(cont, + if (fclaw_map_is_used(cont)) then + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) else xp = xc diff --git a/applications/clawpack/transport/2d/square/mapping_terms.f b/applications/clawpack/transport/2d/square/mapping_terms.f index fcd1ca3d6..220be3738 100644 --- a/applications/clawpack/transport/2d/square/mapping_terms.f +++ b/applications/clawpack/transport/2d/square/mapping_terms.f @@ -29,7 +29,7 @@ subroutine map_covariant_basis(x,y,t1,t2) c # Compute covariant derivatives only flag = 1 - call fclaw2d_map_c2m_basis(cont, + call fclaw_map_2d_c2m_basis(cont, & x,y, t, tinv, tderivs, flag) do k = 1,3 @@ -53,7 +53,7 @@ subroutine map_contravariant_basis(x,y,t1inv,t2inv) cont = fclaw_map_get_context() flag = 3 - call fclaw2d_map_c2m_basis(cont, x,y, t, tinv,tderivs, flag) + call fclaw_map_2d_c2m_basis(cont, x,y, t, tinv,tderivs, flag) do k = 1,3 @@ -86,7 +86,7 @@ subroutine map_christoffel_sym(x,y,g) c # Compute covariant and derivatives flag = 7 - call fclaw2d_map_c2m_basis(cont, x,y, t,tinv,tderivs,flag) + call fclaw_map_2d_c2m_basis(cont, x,y, t,tinv,tderivs,flag) do k = 1,3 @@ -223,7 +223,7 @@ subroutine map_diff_normalized(x,y,u, uderivs, cont = fclaw_map_get_context() flag = 7 - call fclaw2d_map_c2m_basis(cont,x,y,t,tinv, tderivs,flag) + call fclaw_map_2d_c2m_basis(cont,x,y,t,tinv, tderivs,flag) do k = 1,3 t1(k) = t(k,1) diff --git a/applications/clawpack/transport/2d/square/square.cpp b/applications/clawpack/transport/2d/square/square.cpp index baf7eac13..56ad6b155 100644 --- a/applications/clawpack/transport/2d/square/square.cpp +++ b/applications/clawpack/transport/2d/square/square.cpp @@ -26,22 +26,22 @@ #include "square_user.h" static -void create_domain(fclaw2d_global_t *glob) +void create_domain(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; - fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; int minlevel=fclaw_opt->minlevel; /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL, *brick = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL, *brick = NULL; const user_options_t *user_opt = square_get_options(glob); @@ -49,19 +49,19 @@ void create_domain(fclaw2d_global_t *glob) case 0: /* Unit square brick domain */ domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick(domain,mi,mj,a,b); + brick = fclaw_map_new_2d_brick(domain,mi,mj,a,b); cont = fclaw2d_map_new_identity(brick); break; case 1: /* Cart : Maps to [-1,1]x[-1,1] */ domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick(domain,mi,mj,a,b); + brick = fclaw_map_new_2d_brick(domain,mi,mj,a,b); cont = fclaw2d_map_new_cart(brick, fclaw_opt->scale, @@ -78,7 +78,7 @@ void create_domain(fclaw2d_global_t *glob) } /* Five patch square domain */ domain = - fclaw2d_domain_new_disk(glob->mpicomm, 0, 0, + fclaw_domain_new_2d_disk(glob->mpicomm, 0, 0, fclaw_opt->minlevel); cont = fclaw2d_map_new_fivepatch (fclaw_opt->scale, @@ -90,10 +90,10 @@ void create_domain(fclaw2d_global_t *glob) /* bilinear square domain : maps to [-1,1]x[-1,1] */ FCLAW_ASSERT(mi == 2 && mj == 2); domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); - brick = fclaw2d_map_new_brick(domain,mi,mj,a,b); + brick = fclaw_map_new_2d_brick(domain,mi,mj,a,b); cont = fclaw2d_map_new_bilinear(brick, fclaw_opt->scale, @@ -106,26 +106,21 @@ void create_domain(fclaw2d_global_t *glob) } /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* print out some info */ - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ const user_options_t *user_opt = square_get_options(glob); @@ -144,9 +139,9 @@ void run_program(fclaw2d_global_t* glob) Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -158,13 +153,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user_opt = square_options_register(app, "fclaw_options.ini"); @@ -180,11 +175,11 @@ main (int argc, char **argv) /* Options have been checked and are valid */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); square_options_store (glob, user_opt); @@ -194,7 +189,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/transport/2d/square/square_options.c b/applications/clawpack/transport/2d/square/square_options.c index b4a43deda..5e8479031 100644 --- a/applications/clawpack/transport/2d/square/square_options.c +++ b/applications/clawpack/transport/2d/square/square_options.c @@ -171,12 +171,12 @@ user_options_t* square_options_register (fclaw_app_t * app, return user; } -void square_options_store (fclaw2d_global_t* glob, user_options_t* user) +void square_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* square_get_options(fclaw2d_global_t* glob) +const user_options_t* square_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/transport/2d/square/square_user.cpp b/applications/clawpack/transport/2d/square/square_user.cpp index b206294e8..194bcb13c 100644 --- a/applications/clawpack/transport/2d/square/square_user.cpp +++ b/applications/clawpack/transport/2d/square/square_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "square_user.h" static -void square_problem_setup(fclaw2d_global_t* glob) +void square_problem_setup(fclaw_global_t* glob) { const user_options_t* user = square_get_options(glob); @@ -43,14 +43,14 @@ void square_problem_setup(fclaw2d_global_t* glob) fprintf(f, "%-24.6f %s",user->velocity[1],"\% v\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } -void square_patch_setup_manifold(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void square_patch_setup_manifold(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -68,34 +68,34 @@ void square_patch_setup_manifold(fclaw2d_global_t *glob, } static -void cb_square_output_ascii (fclaw2d_domain_t * domain, - fclaw2d_patch_t * patch, +void cb_square_output_ascii (fclaw_domain_t * domain, + fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) s->glob; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) s->glob; + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int iframe = *((int *) s->user); double time = glob->curr_time; /* Get info not readily available to user */ int level, patch_num, global_num; - fclaw2d_patch_get_info(glob->domain,patch, + fclaw_patch_get_info(glob->domain,patch, blockno,patchno, &global_num, &patch_num,&level); int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); - double* error = fclaw2d_clawpatch_get_error(glob,patch); - double* soln = fclaw2d_clawpatch_get_exactsoln(glob,patch); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); + double* error = fclaw_clawpatch_get_error(glob,patch); + double* soln = fclaw_clawpatch_get_exactsoln(glob,patch); char fname[BUFSIZ]; snprintf (fname, BUFSIZ, "%s.q%04d", fclaw_opt->prefix, iframe); @@ -119,16 +119,16 @@ void cb_square_output_ascii (fclaw2d_domain_t * domain, -void square_link_solvers(fclaw2d_global_t *glob) +void square_link_solvers(fclaw_global_t *glob) { /* ForestClaw core functions */ - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &square_problem_setup; /* Version-independent */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &square_patch_setup_manifold; - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); const user_options_t* user = square_get_options(glob); if (user->claw_version == 4) @@ -154,17 +154,17 @@ void square_link_solvers(fclaw2d_global_t *glob) } /* Include error in output files */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (fclaw_opt->compute_error) { if (user->claw_version == 4) { - clawpatch_vt->fort_compute_patch_error = &SQUARE46_COMPUTE_ERROR; + clawpatch_vt->d2->fort_compute_patch_error = &SQUARE46_COMPUTE_ERROR; clawpatch_vt->fort_header_ascii = &SQUARE46_FORT_HEADER_ASCII; } else if (user->claw_version == 5) { - clawpatch_vt->fort_compute_patch_error = &SQUARE5_COMPUTE_ERROR; + clawpatch_vt->d2->fort_compute_patch_error = &SQUARE5_COMPUTE_ERROR; clawpatch_vt->fort_header_ascii = &SQUARE5_FORT_HEADER_ASCII; } clawpatch_vt->cb_output_ascii = &cb_square_output_ascii; diff --git a/applications/clawpack/transport/2d/square/square_user.h b/applications/clawpack/transport/2d/square/square_user.h index 836617649..36764893b 100644 --- a/applications/clawpack/transport/2d/square/square_user.h +++ b/applications/clawpack/transport/2d/square/square_user.h @@ -59,16 +59,16 @@ typedef struct user_options } user_options_t; -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; -void square_link_solvers(struct fclaw2d_global *glob); +void square_link_solvers(struct fclaw_global *glob); /* ---------------------------------- Options ----------------------------------------- */ -const user_options_t* square_get_options(struct fclaw2d_global* glob); +const user_options_t* square_get_options(struct fclaw_global* glob); -void square_options_store (fclaw2d_global_t* glob, user_options_t* user); +void square_options_store (fclaw_global_t* glob, user_options_t* user); user_options_t* square_options_register (fclaw_app_t * app, diff --git a/applications/clawpack/transport/2d/square/user_4.6/square46_compute_error.f b/applications/clawpack/transport/2d/square/user_4.6/square46_compute_error.f index 828292bb5..e4955664f 100644 --- a/applications/clawpack/transport/2d/square/user_4.6/square46_compute_error.f +++ b/applications/clawpack/transport/2d/square/user_4.6/square46_compute_error.f @@ -39,7 +39,7 @@ subroutine square46_compute_error(blockno, mx,my,mbc,meqn, else c # Map computational coordinates to physical coordinates c # In this case, physical and computational are the same. - call fclaw2d_map_c2m(cont,blockno,xc,yc, + call fclaw_map_2d_c2m(cont,blockno,xc,yc, & xc1,yc1,zc1) soln(i,j,1) = qexact(xc1,yc1,t,flow_flag) endif diff --git a/applications/clawpack/transport/2d/square/user_4.6/square46_qinit.f b/applications/clawpack/transport/2d/square/user_4.6/square46_qinit.f index 19cff1330..d0e080cd8 100644 --- a/applications/clawpack/transport/2d/square/user_4.6/square46_qinit.f +++ b/applications/clawpack/transport/2d/square/user_4.6/square46_qinit.f @@ -14,7 +14,7 @@ subroutine clawpack46_qinit(maxmx,maxmy, meqn,mbc,mx,my, double precision q0_physical integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used integer ii,jj @@ -37,14 +37,14 @@ subroutine clawpack46_qinit(maxmx,maxmy, meqn,mbc,mx,my, call cellave2(blockno,xlow,ylow,dx,dy,w) q(i,j,1) = w elseif (initial_condition .eq. 1) then - call fclaw2d_map_c2m(cont,blockno,xc,yc,xp,yp,zp) + call fclaw_map_2d_c2m(cont,blockno,xc,yc,xp,yp,zp) q(i,j,1) = q0_physical(xp,yp,zp) elseif (initial_condition .eq. 2) then q(i,j,1) = 1.d0 elseif (initial_condition .eq. 3) then c # Not sure what this one is about - if (fclaw2d_map_is_used(cont)) then - call fclaw2d_map_c2m(cont, + if (fclaw_map_is_used(cont)) then + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) else xp = xc diff --git a/applications/clawpack/transport/2d/square/user_5.0/square5_compute_error.f b/applications/clawpack/transport/2d/square/user_5.0/square5_compute_error.f index aa0a338b8..8e390d7a4 100644 --- a/applications/clawpack/transport/2d/square/user_5.0/square5_compute_error.f +++ b/applications/clawpack/transport/2d/square/user_5.0/square5_compute_error.f @@ -39,7 +39,7 @@ subroutine square5_compute_error(blockno, mx,my,mbc,meqn, else c # Map computational coordinates to physical coordinates c # In this case, physical and computational are the same. - call fclaw2d_map_c2m(cont,blockno,xc,yc, + call fclaw_map_2d_c2m(cont,blockno,xc,yc, & xc1,yc1,zc1) soln(1,i,j) = qexact(xc1,yc1,t,flow_flag) endif diff --git a/applications/clawpack/transport/2d/square/user_5.0/square5_qinit.f b/applications/clawpack/transport/2d/square/user_5.0/square5_qinit.f index 739a990c0..e0bca613f 100644 --- a/applications/clawpack/transport/2d/square/user_5.0/square5_qinit.f +++ b/applications/clawpack/transport/2d/square/user_5.0/square5_qinit.f @@ -14,7 +14,7 @@ SUBROUTINE clawpack5_qinit(meqn,mbc,mx,my,xlower,ylower, double precision q0_physical integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used integer ii,jj @@ -37,14 +37,14 @@ SUBROUTINE clawpack5_qinit(meqn,mbc,mx,my,xlower,ylower, call cellave2(blockno,xlow,ylow,dx,dy,w) q(1,i,j) = w elseif (initchoice .eq. 1) then - call fclaw2d_map_c2m(cont,blockno,xc,yc,xp,yp,zp) + call fclaw_map_2d_c2m(cont,blockno,xc,yc,xp,yp,zp) q(1,i,j) = q0_physical(xp,yp,zp) elseif (initchoice .eq. 2) then q(1,i,j) = 1.d0 elseif (initchoice .eq. 3) then c # Not sure what this one is about - if (fclaw2d_map_is_used(cont)) then - call fclaw2d_map_c2m(cont, + if (fclaw_map_is_used(cont)) then + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) else xp = xc diff --git a/applications/clawpack/transport/2d/torus/fclaw2d_map_torus.c b/applications/clawpack/transport/2d/torus/fclaw2d_map_torus.c index ae19d746d..1770480c2 100644 --- a/applications/clawpack/transport/2d/torus/fclaw2d_map_torus.c +++ b/applications/clawpack/transport/2d/torus/fclaw2d_map_torus.c @@ -1,6 +1,6 @@ /* Pillow grid surface. Matches p4est_connectivity_new_pillow (). */ -#include +#include #ifdef __cplusplus extern "C" @@ -11,42 +11,42 @@ extern "C" #endif static int -fclaw2d_map_query_torus (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_torus (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 1; /* no break necessary after return statement */ - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 0; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 0; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 1; - case FCLAW2D_MAP_QUERY_IS_CART: + case FCLAW_MAP_QUERY_IS_CART: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 0; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 0; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -61,35 +61,35 @@ fclaw2d_map_query_torus (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_torus (fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_torus (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { /* Data is not already in brick domain */ double xc1,yc1,zc1; - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,&xc1,&yc1,&zc1); double alpha = cont->user_double[0]; double beta = cont->user_double[1]; /* Don't pass in block number */ - MAPC2M_TORUS(&xc1,&yc1,xp,yp,zp,&alpha,&beta); + FCLAW_MAP_2D_C2M_TORUS(&xc1,&yc1,xp,yp,zp,&alpha,&beta); scale_map(cont,xp,yp,zp); rotate_map(cont,xp,yp,zp); } -fclaw2d_map_context_t * - fclaw2d_map_new_torus (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_torus (fclaw_map_context_t* brick, const double scale[], const double rotate[], const double alpha, const double beta) { - fclaw2d_map_context_t *cont; + fclaw_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_torus; cont->mapc2m = fclaw2d_map_c2m_torus; diff --git a/applications/clawpack/transport/2d/torus/fdisc.f b/applications/clawpack/transport/2d/torus/fdisc.f index 4c3d24ee1..8043929ed 100644 --- a/applications/clawpack/transport/2d/torus/fdisc.f +++ b/applications/clawpack/transport/2d/torus/fdisc.f @@ -14,7 +14,7 @@ double precision function fdisc(blockno,xc,yc) cont = fclaw_map_get_context() - call fclaw2d_map_c2m(cont, + call fclaw_map_2d_c2m(cont, & blockno,xc,yc,xp,yp,zp) thc = pi/2.0 diff --git a/applications/clawpack/transport/2d/torus/torus.cpp b/applications/clawpack/transport/2d/torus/torus.cpp index 6f1a48f6c..0285430c3 100644 --- a/applications/clawpack/transport/2d/torus/torus.cpp +++ b/applications/clawpack/transport/2d/torus/torus.cpp @@ -26,9 +26,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "torus_user.h" static -void create_domain (fclaw2d_global_t * glob) +void create_domain (fclaw_global_t * glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); /* --------------------------------------------------------------- Mapping geometry @@ -47,15 +47,15 @@ void create_domain (fclaw2d_global_t * glob) rotate[1] = pi*fclaw_opt->phi/180.0; /* Mapped, multi-block domain */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_brick (glob->mpicomm, mi, mj, a, b, + fclaw_domain_t *domain = + fclaw_domain_new_2d_brick (glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Create brick mapping */ - fclaw2d_map_context_t *brick = - fclaw2d_map_new_brick(domain, mi, mj, a, b); + fclaw_map_context_t *brick = + fclaw_map_new_2d_brick(domain, mi, mj, a, b); const user_options_t *user = torus_get_options(glob); - fclaw2d_map_context *cont = + fclaw_map_context *cont = fclaw2d_map_new_torus(brick, fclaw_opt->scale, rotate, @@ -63,28 +63,23 @@ void create_domain (fclaw2d_global_t * glob) user->beta); /* Store mapping in the glob */ - fclaw2d_global_store_map (glob, cont); + fclaw_map_store (glob, cont); /* Store the domain in the glob */ - fclaw2d_global_store_domain(glob, domain); + fclaw_global_store_domain(glob, domain); /* print out some info */ - fclaw2d_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels (domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors (domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user = torus_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ if (user->claw_version == 4) @@ -93,7 +88,7 @@ void run_program(fclaw2d_global_t* glob) } else if (user->claw_version == 5) { - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); if (fclaw_opt->time_sync != 0) { fclaw_global_essentialf("Conservation correction not yet implemented in " \ @@ -108,9 +103,9 @@ void run_program(fclaw2d_global_t* glob) /* --------------------------------------------------------------- Run --------------------------------------------------------------- */ - fclaw2d_initialize(glob); - fclaw2d_run(glob); - fclaw2d_finalize(glob); + fclaw_initialize(glob); + fclaw_run(glob); + fclaw_finalize(glob); } int @@ -122,14 +117,14 @@ main (int argc, char **argv) /* Options */ user_options_t *user; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_clawpack46_options_t *claw46_opt; fc2d_clawpack5_options_t *claw5_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); claw46_opt = fc2d_clawpack46_options_register(app, "clawpack46", "fclaw_options.ini"); claw5_opt = fc2d_clawpack5_options_register(app, "clawpack5", "fclaw_options.ini"); user = torus_options_register(app, "fclaw_options.ini"); @@ -146,11 +141,11 @@ main (int argc, char **argv) /* Create global structure which stores the domain, timers, etc */ int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm (mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm (mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_clawpack46_options_store (glob, claw46_opt); fc2d_clawpack5_options_store (glob, claw5_opt); torus_options_store (glob, user); @@ -161,7 +156,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/clawpack/transport/2d/torus/torus_options.c b/applications/clawpack/transport/2d/torus/torus_options.c index 6c19622f3..e28225c66 100644 --- a/applications/clawpack/transport/2d/torus/torus_options.c +++ b/applications/clawpack/transport/2d/torus/torus_options.c @@ -169,13 +169,13 @@ user_options_t* torus_options_register (fclaw_app_t * app, return user_opt; } -void torus_options_store (fclaw2d_global_t* glob, user_options_t* user) +void torus_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const user_options_t* torus_get_options(fclaw2d_global_t* glob) +const user_options_t* torus_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/clawpack/transport/2d/torus/torus_user.cpp b/applications/clawpack/transport/2d/torus/torus_user.cpp index 46ae54099..fbbd2bc39 100644 --- a/applications/clawpack/transport/2d/torus/torus_user.cpp +++ b/applications/clawpack/transport/2d/torus/torus_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "torus_user.h" static -void torus_problem_setup(fclaw2d_global_t *glob) +void torus_problem_setup(fclaw_global_t *glob) { const user_options_t* user = torus_get_options(glob); @@ -39,13 +39,13 @@ void torus_problem_setup(fclaw2d_global_t *glob) fprintf(f, "%-24.6f %s",user->revs_per_s,"\% revs_per_second\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); SETPROB(); } static -void torus_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void torus_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -64,12 +64,12 @@ void torus_patch_setup(fclaw2d_global_t *glob, } -void torus_link_solvers(fclaw2d_global_t *glob) +void torus_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &torus_problem_setup; /* Version-independent */ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); patch_vt->setup = &torus_patch_setup; const user_options_t *user = torus_get_options(glob); diff --git a/applications/clawpack/transport/2d/torus/torus_user.h b/applications/clawpack/transport/2d/torus/torus_user.h index 8583c07ac..819ab0608 100644 --- a/applications/clawpack/transport/2d/torus/torus_user.h +++ b/applications/clawpack/transport/2d/torus/torus_user.h @@ -53,16 +53,16 @@ typedef struct user_options } user_options_t; -void torus_link_solvers(fclaw2d_global_t *glob); +void torus_link_solvers(fclaw_global_t *glob); /* ---------------------------------- Options ----------------------------------------- */ user_options_t* torus_options_register (fclaw_app_t * app, const char *configfile); -void torus_options_store (fclaw2d_global_t* glob, user_options_t* user); +void torus_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* torus_get_options(fclaw2d_global_t* glob); +const user_options_t* torus_get_options(fclaw_global_t* glob); #ifdef __cplusplus diff --git a/applications/clawpack/transport/2d/torus/torus_velocity.f b/applications/clawpack/transport/2d/torus/torus_velocity.f index 97f13d751..6e257c36d 100644 --- a/applications/clawpack/transport/2d/torus/torus_velocity.f +++ b/applications/clawpack/transport/2d/torus/torus_velocity.f @@ -165,7 +165,7 @@ subroutine user_map2comp(blockno,xc,yc,xp,yp,zp,xc1,yc1) cont = fclaw_map_get_context() - call fclaw2d_map_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) + call fclaw_map_2d_brick2c(cont,blockno,xc,yc,xc1,yc1,zc1) end diff --git a/applications/cudaclaw/acoustics/2d/radial/radial.cpp b/applications/cudaclaw/acoustics/2d/radial/radial.cpp index 7e952b33e..6f18c64ea 100644 --- a/applications/cudaclaw/acoustics/2d/radial/radial.cpp +++ b/applications/cudaclaw/acoustics/2d/radial/radial.cpp @@ -31,36 +31,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ------------------------- Start of program ---------------------------- */ static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); fclaw_opt->manifold = 0; - fclaw2d_domain_t *domain = fclaw2d_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); + fclaw_domain_t *domain = fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t *cont = fclaw_map_new_nomap(); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { const user_options_t *user_opt; - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - user_opt = radial_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_cudaclaw_options_t *clawopt = fc2d_cudaclaw_get_options(glob); @@ -79,13 +74,13 @@ void run_program(fclaw2d_global_t* glob) PROFILE_CUDA_GROUP("Allocate GPU and GPU buffers",1); fc2d_cudaclaw_allocate_buffers(glob); - fclaw2d_initialize(glob); - fclaw2d_run(glob); + fclaw_initialize(glob); + fclaw_run(glob); PROFILE_CUDA_GROUP("De-allocate GPU and GPU buffers",1); fc2d_cudaclaw_deallocate_buffers(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); } @@ -98,12 +93,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_cudaclaw_options_t *cuclaw_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); cuclaw_opt = fc2d_cudaclaw_options_register(app, "cudaclaw", "fclaw_options.ini"); user_opt = radial_options_register(app, "fclaw_options.ini"); @@ -120,11 +115,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_cudaclaw_options_store (glob, cuclaw_opt); radial_options_store (glob, user_opt); @@ -132,7 +127,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/cudaclaw/acoustics/2d/radial/radial_options.c b/applications/cudaclaw/acoustics/2d/radial/radial_options.c index 8a99067ee..a3061d70e 100644 --- a/applications/cudaclaw/acoustics/2d/radial/radial_options.c +++ b/applications/cudaclaw/acoustics/2d/radial/radial_options.c @@ -159,13 +159,13 @@ user_options_t* radial_options_register (fclaw_app_t * app, return user; } -void radial_options_store (fclaw2d_global_t* glob, user_options_t* user) +void radial_options_store (fclaw_global_t* glob, user_options_t* user) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"user") == NULL); fclaw_pointer_map_insert(glob->options, "user", user, NULL); } -user_options_t* radial_get_options(fclaw2d_global_t* glob) +user_options_t* radial_get_options(fclaw_global_t* glob) { user_options_t* user = (user_options_t*) fclaw_pointer_map_get(glob->options, "user"); diff --git a/applications/cudaclaw/acoustics/2d/radial/radial_user.cpp b/applications/cudaclaw/acoustics/2d/radial/radial_user.cpp index 8f2bf4066..2dfbce5b7 100644 --- a/applications/cudaclaw/acoustics/2d/radial/radial_user.cpp +++ b/applications/cudaclaw/acoustics/2d/radial/radial_user.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "radial_user.h" static -void radial_problem_setup(fclaw2d_global_t* glob) +void radial_problem_setup(fclaw_global_t* glob) { user_options_t* user = radial_get_options(glob); if (glob->mpirank == 0) @@ -37,7 +37,7 @@ void radial_problem_setup(fclaw2d_global_t* glob) fclose(f); } /* We want to make sure node 0 gets here before proceeding */ - fclaw2d_domain_barrier (glob->domain); /* redundant? */ + fclaw_domain_barrier (glob->domain); /* redundant? */ setprob_cuda(); @@ -45,11 +45,11 @@ void radial_problem_setup(fclaw2d_global_t* glob) } -void radial_link_solvers(fclaw2d_global_t *glob) +void radial_link_solvers(fclaw_global_t *glob) { //fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &radial_problem_setup; /* Version-independent */ //const user_options_t* user = radial_get_options(glob); diff --git a/applications/cudaclaw/acoustics/2d/radial/radial_user.h b/applications/cudaclaw/acoustics/2d/radial/radial_user.h index d1e70cd74..1511718b2 100644 --- a/applications/cudaclaw/acoustics/2d/radial/radial_user.h +++ b/applications/cudaclaw/acoustics/2d/radial/radial_user.h @@ -28,10 +28,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include +#include -#include -#include +#include +#include #include #include @@ -58,15 +58,15 @@ typedef struct user_options } user_options_t; -void radial_link_solvers(fclaw2d_global_t *glob); +void radial_link_solvers(fclaw_global_t *glob); /* --------------------------------------- Options ----------------------------------------*/ user_options_t* radial_options_register (fclaw_app_t * app, const char *configfile); -void radial_options_store (fclaw2d_global_t* glob, user_options_t* user); +void radial_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* radial_get_options(fclaw2d_global_t* glob); +user_options_t* radial_get_options(fclaw_global_t* glob); /* --------------------------------------- Cuda ----------------------------------------*/ diff --git a/applications/cudaclaw/advection/2d/swirl/swirl.cpp b/applications/cudaclaw/advection/2d/swirl/swirl.cpp index 8cd555de8..cde1e6f99 100644 --- a/applications/cudaclaw/advection/2d/swirl/swirl.cpp +++ b/applications/cudaclaw/advection/2d/swirl/swirl.cpp @@ -28,34 +28,29 @@ #include static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); fclaw_opt->manifold = 0; - fclaw2d_domain_t *domain = fclaw2d_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); + fclaw_domain_t *domain = fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t *cont = fclaw_map_new_nomap(); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - const user_options_t *user_opt = swirl_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_cudaclaw_options_t *clawopt = fc2d_cudaclaw_get_options(glob); @@ -75,13 +70,13 @@ void run_program(fclaw2d_global_t* glob) PROFILE_CUDA_GROUP("Allocate GPU and GPU buffers",1); fc2d_cudaclaw_allocate_buffers(glob); - fclaw2d_initialize(glob); - fclaw2d_run(glob); + fclaw_initialize(glob); + fclaw_run(glob); PROFILE_CUDA_GROUP("De-allocate GPU and GPU buffers",1); fc2d_cudaclaw_deallocate_buffers(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -96,12 +91,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_cudaclaw_options_t *cuclaw_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); cuclaw_opt = fc2d_cudaclaw_options_register(app, "cudaclaw", "fclaw_options.ini"); user_opt = swirl_options_register(app, "fclaw_options.ini"); @@ -118,11 +113,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_cudaclaw_options_store (glob, cuclaw_opt); swirl_options_store (glob, user_opt); @@ -130,7 +125,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/cudaclaw/advection/2d/swirl/swirl_options.c b/applications/cudaclaw/advection/2d/swirl/swirl_options.c index e2da69e3c..61abb5973 100644 --- a/applications/cudaclaw/advection/2d/swirl/swirl_options.c +++ b/applications/cudaclaw/advection/2d/swirl/swirl_options.c @@ -155,13 +155,13 @@ user_options_t* swirl_options_register (fclaw_app_t * app, return user; } -void swirl_options_store (fclaw2d_global_t* glob, user_options_t* user) +void swirl_options_store (fclaw_global_t* glob, user_options_t* user) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"user") == NULL); fclaw_pointer_map_insert(glob->options, "user", user, NULL); } -const user_options_t* swirl_get_options(fclaw2d_global_t* glob) +const user_options_t* swirl_get_options(fclaw_global_t* glob) { user_options_t* user = (user_options_t*) fclaw_pointer_map_get(glob->options, "user"); diff --git a/applications/cudaclaw/advection/2d/swirl/swirl_user.cpp b/applications/cudaclaw/advection/2d/swirl/swirl_user.cpp index beb46c084..b42290539 100644 --- a/applications/cudaclaw/advection/2d/swirl/swirl_user.cpp +++ b/applications/cudaclaw/advection/2d/swirl/swirl_user.cpp @@ -26,7 +26,7 @@ #include "swirl_user.h" static -void swirl_problem_setup(fclaw2d_global_t* glob) +void swirl_problem_setup(fclaw_global_t* glob) { const user_options_t* user = swirl_get_options(glob); @@ -38,16 +38,16 @@ void swirl_problem_setup(fclaw2d_global_t* glob) } /* Make sure node 0 has written 'setprob.data' before proceeding */ - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); setprob(); } -void swirl_link_solvers(fclaw2d_global_t *glob) +void swirl_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); vt->problem_setup = &swirl_problem_setup; /* Version-independent */ diff --git a/applications/cudaclaw/advection/2d/swirl/swirl_user.h b/applications/cudaclaw/advection/2d/swirl/swirl_user.h index 0b5338cc1..3bdc87735 100644 --- a/applications/cudaclaw/advection/2d/swirl/swirl_user.h +++ b/applications/cudaclaw/advection/2d/swirl/swirl_user.h @@ -26,15 +26,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef SWIRL_USER_H #define SWIRL_USER_H -#include +#include #include #include #include -#include -#include +#include +#include #include @@ -56,15 +56,15 @@ typedef struct user_options } user_options_t; -void swirl_link_solvers(fclaw2d_global_t *glob); +void swirl_link_solvers(fclaw_global_t *glob); /* ------------------------------------- Options ---------------------------------------*/ user_options_t* swirl_options_register (fclaw_app_t * app, const char *configfile); -void swirl_options_store (fclaw2d_global_t* glob, user_options_t* user); +void swirl_options_store (fclaw_global_t* glob, user_options_t* user); -const user_options_t* swirl_get_options(fclaw2d_global_t* glob); +const user_options_t* swirl_get_options(fclaw_global_t* glob); /* --------------------------------------- Cuda ----------------------------------------*/ diff --git a/applications/cudaclaw/euler/2d/shockbubble/shockbubble.cpp b/applications/cudaclaw/euler/2d/shockbubble/shockbubble.cpp index d29a59f87..c90dde423 100644 --- a/applications/cudaclaw/euler/2d/shockbubble/shockbubble.cpp +++ b/applications/cudaclaw/euler/2d/shockbubble/shockbubble.cpp @@ -28,10 +28,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { /* Mapped, multi-block domain */ - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int mi,mj,a,b; mi = fclaw_opt->mi; @@ -39,35 +39,30 @@ void create_domain(fclaw2d_global_t* glob) a = fclaw_opt->periodic_x; b = fclaw_opt->periodic_y; - fclaw2d_domain_t* domain = - fclaw2d_domain_new_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); + fclaw_domain_t* domain = + fclaw_domain_new_2d_brick(glob->mpicomm, mi, mj, a, b, fclaw_opt->minlevel); /* Use [ax,bx]x[ay,by] */ - fclaw2d_map_context_t *cont = NULL, *brick = NULL; - brick = fclaw2d_map_new_brick (domain, mi, mj, a, b); - cont = fclaw2d_map_new_nomap_brick(brick); + fclaw_map_context_t *cont = NULL, *brick = NULL; + brick = fclaw_map_new_2d_brick (domain, mi, mj, a, b); + cont = fclaw_map_new_nomap_brick(brick); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { const user_options_t *user_opt; - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - user_opt = shockbubble_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_cudaclaw_options_t *clawopt = fc2d_cudaclaw_get_options(glob); @@ -86,13 +81,13 @@ void run_program(fclaw2d_global_t* glob) PROFILE_CUDA_GROUP("Allocate GPU and GPU buffers",1); fc2d_cudaclaw_allocate_buffers(glob); - fclaw2d_initialize(glob); - fclaw2d_run(glob); + fclaw_initialize(glob); + fclaw_run(glob); PROFILE_CUDA_GROUP("De-allocate GPU and GPU buffers",1); fc2d_cudaclaw_deallocate_buffers(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -104,12 +99,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_cudaclaw_options_t *cuclaw_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); cuclaw_opt = fc2d_cudaclaw_options_register(app, "cudaclaw", "fclaw_options.ini"); user_opt = shockbubble_options_register(app, "fclaw_options.ini"); @@ -125,11 +120,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_cudaclaw_options_store (glob, cuclaw_opt); shockbubble_options_store (glob, user_opt); @@ -138,7 +133,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/cudaclaw/euler/2d/shockbubble/shockbubble_options.c b/applications/cudaclaw/euler/2d/shockbubble/shockbubble_options.c index 4210d14d8..f5c586aa2 100644 --- a/applications/cudaclaw/euler/2d/shockbubble/shockbubble_options.c +++ b/applications/cudaclaw/euler/2d/shockbubble/shockbubble_options.c @@ -114,13 +114,13 @@ user_options_t* shockbubble_options_register (fclaw_app_t * app, return user; } -void shockbubble_options_store (fclaw2d_global_t* glob, user_options_t* user) +void shockbubble_options_store (fclaw_global_t* glob, user_options_t* user) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"user") == NULL); fclaw_pointer_map_insert(glob->options, "user", user, NULL); } -user_options_t* shockbubble_get_options(fclaw2d_global_t* glob) +user_options_t* shockbubble_get_options(fclaw_global_t* glob) { user_options_t* user = (user_options_t*) fclaw_pointer_map_get(glob->options, "user"); diff --git a/applications/cudaclaw/euler/2d/shockbubble/shockbubble_user.cpp b/applications/cudaclaw/euler/2d/shockbubble/shockbubble_user.cpp index 380b49c08..478c13a28 100644 --- a/applications/cudaclaw/euler/2d/shockbubble/shockbubble_user.cpp +++ b/applications/cudaclaw/euler/2d/shockbubble/shockbubble_user.cpp @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "shockbubble_user.h" -void shockbubble_problem_setup(fclaw2d_global_t* glob) +void shockbubble_problem_setup(fclaw_global_t* glob) { const user_options_t* user = shockbubble_get_options(glob); @@ -43,7 +43,7 @@ void shockbubble_problem_setup(fclaw2d_global_t* glob) } /* We want to make sure node 0 gets here before proceeding */ - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); /* Call CUDA setprob to set parameters needed for Riemann solvers */ setprob_cuda(); @@ -74,15 +74,15 @@ void shockbubble_problem_setup(fclaw2d_global_t* glob) } #endif -void shockbubble_link_solvers(fclaw2d_global_t *glob) +void shockbubble_link_solvers(fclaw_global_t *glob) { // const user_options_t* user = shockbubble_get_options(glob); // fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); // fc2d_clawpack46_options_t *clawopt = fc2d_clawpack46_get_options(glob); - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = &shockbubble_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = &shockbubble_problem_setup; //fc2d_clawpack46_vtable_t *claw46_vt = fc2d_clawpack46_vt(glob); fc2d_cudaclaw_vtable_t *cuclaw_vt = fc2d_cudaclaw_vt(glob); diff --git a/applications/cudaclaw/euler/2d/shockbubble/shockbubble_user.h b/applications/cudaclaw/euler/2d/shockbubble/shockbubble_user.h index f160d7fb6..a7ae54672 100644 --- a/applications/cudaclaw/euler/2d/shockbubble/shockbubble_user.h +++ b/applications/cudaclaw/euler/2d/shockbubble/shockbubble_user.h @@ -26,10 +26,10 @@ #ifndef SHOCKBUBBLE_USER_H #define SHOCKBUBBLE_USER_H -#include +#include -#include +#include #include #include @@ -37,8 +37,8 @@ #include #include -#include -#include +#include +#include #include @@ -64,14 +64,14 @@ typedef struct user_options } user_options_t; -void shockbubble_link_solvers(fclaw2d_global_t *glob); +void shockbubble_link_solvers(fclaw_global_t *glob); user_options_t* shockbubble_options_register (fclaw_app_t * app, const char *configfile); -void shockbubble_options_store (fclaw2d_global_t* glob, user_options_t* user); +void shockbubble_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* shockbubble_get_options(fclaw2d_global_t* glob); +user_options_t* shockbubble_get_options(fclaw_global_t* glob); /* ------------------------------- Fortran code --------------------------------------- */ diff --git a/applications/cudaclaw/shallow/2d/bump/bump.cpp b/applications/cudaclaw/shallow/2d/bump/bump.cpp index dcecadc6f..bc3f3fdb9 100644 --- a/applications/cudaclaw/shallow/2d/bump/bump.cpp +++ b/applications/cudaclaw/shallow/2d/bump/bump.cpp @@ -28,34 +28,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); fclaw_opt->manifold = 0; - fclaw2d_domain_t *domain = fclaw2d_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); + fclaw_domain_t *domain = fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opt->minlevel); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap(); + fclaw_map_context_t *cont = fclaw_map_new_nomap(); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - user_options_t* user_opt = bump_get_options(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Initialize virtual tables for solvers */ fc2d_cudaclaw_options_t *clawopt = fc2d_cudaclaw_get_options(glob); @@ -79,13 +74,13 @@ void run_program(fclaw2d_global_t* glob) PROFILE_CUDA_GROUP("Allocate GPU and GPU buffers",1); fc2d_cudaclaw_allocate_buffers(glob); - fclaw2d_initialize(glob); - fclaw2d_run(glob); + fclaw_initialize(glob); + fclaw_run(glob); PROFILE_CUDA_GROUP("De-allocate GPU and GPU buffers",1); fc2d_cudaclaw_deallocate_buffers(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); } @@ -98,13 +93,13 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_cudaclaw_options_t *cuclaw_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); cuclaw_opt = fc2d_cudaclaw_options_register(app, "cudaclaw", "fclaw_options.ini"); user_opt = bump_options_register(app, "fclaw_options.ini"); @@ -121,11 +116,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_cudaclaw_options_store (glob, cuclaw_opt); bump_options_store (glob, user_opt); @@ -133,7 +128,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/cudaclaw/shallow/2d/bump/bump_options.c b/applications/cudaclaw/shallow/2d/bump/bump_options.c index ec73c2159..437ff4f38 100644 --- a/applications/cudaclaw/shallow/2d/bump/bump_options.c +++ b/applications/cudaclaw/shallow/2d/bump/bump_options.c @@ -131,13 +131,13 @@ user_options_t* bump_options_register (fclaw_app_t * app, return user; } -void bump_options_store (fclaw2d_global_t* glob, user_options_t* user) +void bump_options_store (fclaw_global_t* glob, user_options_t* user) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"user") == NULL); fclaw_pointer_map_insert(glob->options, "user", user, NULL); } -user_options_t* bump_get_options(fclaw2d_global_t* glob) +user_options_t* bump_get_options(fclaw_global_t* glob) { user_options_t* user = (user_options_t*) fclaw_pointer_map_get(glob->options, "user"); diff --git a/applications/cudaclaw/shallow/2d/bump/bump_user.cpp b/applications/cudaclaw/shallow/2d/bump/bump_user.cpp index ae2b991ca..69c3cb1ac 100644 --- a/applications/cudaclaw/shallow/2d/bump/bump_user.cpp +++ b/applications/cudaclaw/shallow/2d/bump/bump_user.cpp @@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. static -void bump_problem_setup(fclaw2d_global_t* glob) +void bump_problem_setup(fclaw_global_t* glob) { const user_options_t* user = bump_get_options(glob); @@ -37,15 +37,15 @@ void bump_problem_setup(fclaw2d_global_t* glob) fprintf(f, "%-24.16f %s",user->gravity,"\% gravity\n"); fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); setprob_cuda(); } -void bump_link_solvers(fclaw2d_global_t *glob) +void bump_link_solvers(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); vt->problem_setup = &bump_problem_setup; /* Version-independent */ //const user_options_t* user = bump_get_options(glob); diff --git a/applications/cudaclaw/shallow/2d/bump/bump_user.h b/applications/cudaclaw/shallow/2d/bump/bump_user.h index 1b07b7b82..727d16da1 100644 --- a/applications/cudaclaw/shallow/2d/bump/bump_user.h +++ b/applications/cudaclaw/shallow/2d/bump/bump_user.h @@ -30,10 +30,10 @@ #include #include -#include +#include -#include -#include +#include +#include #ifdef __cplusplus extern "C" @@ -68,14 +68,14 @@ void bump_assign_speeds(cudaclaw_cuda_speeds_t *speeds); void setprob_cuda(); -void bump_link_solvers(fclaw2d_global_t *glob); +void bump_link_solvers(fclaw_global_t *glob); user_options_t* bump_options_register (fclaw_app_t * app, const char *configfile); -void bump_options_store (fclaw2d_global_t* glob, user_options_t* user); +void bump_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* bump_get_options(fclaw2d_global_t* glob); +user_options_t* bump_get_options(fclaw_global_t* glob); /* --------------------------------------- non-Cuda ----------------------------------------*/ diff --git a/applications/elliptic/allencahn/allencahn.cpp b/applications/elliptic/allencahn/allencahn.cpp index 401294815..4681fa9ce 100644 --- a/applications/elliptic/allencahn/allencahn.cpp +++ b/applications/elliptic/allencahn/allencahn.cpp @@ -25,25 +25,25 @@ #include "allencahn_user.h" -#include +#include -#include -#include +#include +#include -#include +#include -#include -#include +#include +#include #include #include static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { /* Mapped, multi-block domain */ - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -51,34 +51,28 @@ void create_domain(fclaw2d_global_t* glob) int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; - fclaw2d_domain_t *domain = fclaw2d_domain_new_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); + fclaw_domain_t *domain = fclaw_domain_new_2d_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); /* Map unit square to disk using mapc2m_disk.f */ - fclaw2d_map_context_t *brick = fclaw2d_map_new_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap_brick(brick); + fclaw_map_context_t *brick = fclaw_map_new_2d_brick(domain, mi, mj, a, b); + fclaw_map_context_t *cont = fclaw_map_new_nomap_brick(brick); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { // const allencahn_options_t *user_opt; // user_opt = allencahn_get_options(glob); - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Test thunderegg solver */ fc2d_thunderegg_solver_initialize(glob); @@ -91,14 +85,14 @@ void run_program(fclaw2d_global_t* glob) --------------------------------------------------------------- */ /* Set up grid and RHS */ - fclaw2d_initialize(glob); + fclaw_initialize(glob); allencahn_run(glob); /* --------------------------------------------------------------- Finalize --------------------------------------------------------------- */ - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -109,13 +103,13 @@ main (int argc, char **argv) /* Options */ fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_thunderegg_options_t *mg_opt; allencahn_options_t *user_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); mg_opt = fc2d_thunderegg_options_register(app, "thunderegg", "fclaw_options.ini"); user_opt = allencahn_options_register(app, "fclaw_options.ini"); @@ -132,11 +126,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_thunderegg_options_store (glob, mg_opt); allencahn_options_store (glob, user_opt); @@ -144,7 +138,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/elliptic/allencahn/allencahn_options.c b/applications/elliptic/allencahn/allencahn_options.c index 15ecfd3bf..8ff440e53 100644 --- a/applications/elliptic/allencahn/allencahn_options.c +++ b/applications/elliptic/allencahn/allencahn_options.c @@ -204,12 +204,12 @@ allencahn_options_t* allencahn_options_register (fclaw_app_t * app, return user; } -void allencahn_options_store (fclaw2d_global_t* glob, allencahn_options_t* user) +void allencahn_options_store (fclaw_global_t* glob, allencahn_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const allencahn_options_t* allencahn_get_options(fclaw2d_global_t* glob) +const allencahn_options_t* allencahn_get_options(fclaw_global_t* glob) { - return (allencahn_options_t*) fclaw2d_global_get_options(glob, "user"); + return (allencahn_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/elliptic/allencahn/allencahn_options.h b/applications/elliptic/allencahn/allencahn_options.h index c7690d7f9..2d09efb4c 100644 --- a/applications/elliptic/allencahn/allencahn_options.h +++ b/applications/elliptic/allencahn/allencahn_options.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ALLENCAHN_OPTIONS_H #define ALLENCAHN_OPTIONS_H -#include +#include #ifdef __cplusplus extern "C" @@ -91,9 +91,9 @@ typedef struct allencahn_options allencahn_options_t* allencahn_options_register (fclaw_app_t * app, const char *configfile); -void allencahn_options_store(fclaw2d_global_t* glob, allencahn_options_t* user); +void allencahn_options_store(fclaw_global_t* glob, allencahn_options_t* user); -const allencahn_options_t* allencahn_get_options(fclaw2d_global_t* glob); +const allencahn_options_t* allencahn_get_options(fclaw_global_t* glob); #ifdef __cplusplus diff --git a/applications/elliptic/allencahn/allencahn_run.c b/applications/elliptic/allencahn/allencahn_run.c index ce6716e81..d2b73196d 100644 --- a/applications/elliptic/allencahn/allencahn_run.c +++ b/applications/elliptic/allencahn/allencahn_run.c @@ -25,20 +25,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "allencahn_user.h" -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include #include "fclaw_math.h" @@ -90,25 +90,25 @@ void save_time_step(fclaw2d_global_t *glob) #endif static -void update_q(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void update_q(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t *) user; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(g->glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(g->glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double* rhs; int mfields; - fclaw2d_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); + fclaw_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); double* q; int meqn; - fclaw2d_clawpatch_soln_data(g->glob, patch, &q, &meqn); + fclaw_clawpatch_soln_data(g->glob, patch, &q, &meqn); FCLAW_ASSERT(mfields==meqn); @@ -118,9 +118,9 @@ void update_q(fclaw2d_domain_t *domain, static -void allencahn_run_update_q(fclaw2d_global_t *glob) +void allencahn_run_update_q(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob, update_q, NULL); + fclaw_global_iterate_patches(glob, update_q, NULL); } @@ -129,15 +129,15 @@ void allencahn_run_update_q(fclaw2d_global_t *glob) Output times are at times [0,dT, 2*dT, 3*dT,...,Tfinal], where dT = tfinal/nout -------------------------------------------------------------------------------- */ static -void outstyle_1(fclaw2d_global_t *glob) +void outstyle_1(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double final_time = fclaw_opt->tfinal; int nout = fclaw_opt->nout; @@ -147,7 +147,7 @@ void outstyle_1(fclaw2d_global_t *glob) int init_flag = 1; /* Store anything that needs to be stored */ - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; double t0 = 0; @@ -195,7 +195,7 @@ void outstyle_1(fclaw2d_global_t *glob) fc2d_thunderegg_heat_set_lambda(lambda); /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ allencahn_run_update_q(glob); @@ -214,21 +214,21 @@ void outstyle_1(fclaw2d_global_t *glob) glob->curr_time = t_curr; - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); if (fclaw_opt->regrid_interval > 0) if (n_inner % fclaw_opt->regrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } /* Output file at every outer loop iteration */ - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); glob->curr_time = t_curr; iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } @@ -241,19 +241,19 @@ static void outstyle_2(fclaw2d_global_t *glob) #endif static -void outstyle_3(fclaw2d_global_t *glob) +void outstyle_3(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; @@ -304,14 +304,14 @@ void outstyle_3(fclaw2d_global_t *glob) /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ allencahn_run_update_q(glob); int time_interp = 0; - fclaw2d_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, - time_interp,FCLAW2D_TIMER_NONE); + fclaw_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, + time_interp,FCLAW_TIMER_NONE); double tc = t_curr + dt_step; @@ -335,37 +335,37 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nregrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } if (fclaw_opt->advance_one_step) - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); if (n % nstep_inner == 0) { iframe++; //fclaw2d_diagnostics_gather(glob,init_flag); - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } static -void outstyle_4(fclaw2d_global_t *glob) +void outstyle_4(fclaw_global_t *glob) { /* Write out an initial time file */ int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; int nstep_outer = fclaw_opt->nout; int nstep_inner = fclaw_opt->nstep; @@ -378,7 +378,7 @@ void outstyle_4(fclaw2d_global_t *glob) while (n < nstep_outer) { /* Get current domain data since it may change during regrid */ - fclaw2d_advance_all_levels(glob, t_curr, dt_minlevel); + fclaw_advance_all_levels(glob, t_curr, dt_minlevel); int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ? fclaw_opt->maxlevel : fclaw_opt->minlevel; @@ -398,7 +398,7 @@ void outstyle_4(fclaw2d_global_t *glob) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } else @@ -408,9 +408,9 @@ void outstyle_4(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -420,10 +420,10 @@ void outstyle_4(fclaw2d_global_t *glob) Public interface ---------------------------------------------------------------- */ -void allencahn_run(fclaw2d_global_t *glob) +void allencahn_run(fclaw_global_t *glob) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); switch (fclaw_opt->outstyle) { diff --git a/applications/elliptic/allencahn/allencahn_user.cpp b/applications/elliptic/allencahn/allencahn_user.cpp index 337322711..10457fded 100644 --- a/applications/elliptic/allencahn/allencahn_user.cpp +++ b/applications/elliptic/allencahn/allencahn_user.cpp @@ -27,10 +27,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "allencahn_user.h" #include "allencahn_options.h" -#include +#include -#include -#include +#include +#include #include #include @@ -40,14 +40,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include -#include +#include static -void allencahn_problem_setup(fclaw2d_global_t *glob) +void allencahn_problem_setup(fclaw_global_t *glob) { if (glob->mpirank == 0) { @@ -87,25 +87,25 @@ void allencahn_problem_setup(fclaw2d_global_t *glob) fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); ALLENCAHN_SETPROB(); /* This file reads the file just created above */ } static -void allencahn_initialize(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void allencahn_initialize(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); /* This function supplies an analytic right hand side. */ @@ -115,24 +115,24 @@ void allencahn_initialize(fclaw2d_global_t *glob, static -void allencahn_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void allencahn_rhs(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int mfields; double *rhs; - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); /* This function supplies an analytic right hand side. */ int method = 1; @@ -231,14 +231,14 @@ void cb_allencahn_output_ascii(fclaw2d_domain_t * domain, #endif -int allencahn_tag4refinement(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +int allencahn_tag4refinement(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, int patchno, int initflag) { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int tag_patch; double refine_threshold; @@ -247,56 +247,56 @@ int allencahn_tag4refinement(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); tag_patch = 0; - clawpatch_vt->fort_tag4refinement(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, - &blockno, q,&refine_threshold, - &initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4refinement(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, + &blockno, q,&refine_threshold, + &initflag,&tag_patch); return tag_patch; } static -int allencahn_tag4coarsening(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, +int allencahn_tag4coarsening(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, int blockno, int patchno, int initflag) { - fclaw2d_patch_t *patch0 = &fine_patches[0]; + fclaw_patch_t *patch0 = &fine_patches[0]; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double coarsen_threshold = fclaw_opt->coarsen_threshold; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch0,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch0,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q[4]; int meqn; for (int igrid = 0; igrid < 4; igrid++) { - fclaw2d_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); + fclaw_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); } - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); int tag_patch = 0; - clawpatch_vt->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, - &blockno, q[0],q[1],q[2],q[3], - &coarsen_threshold,&initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, + &blockno, q[0],q[1],q[2],q[3], + &coarsen_threshold,&initflag,&tag_patch); return tag_patch == 1; } static -void allencahn_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void allencahn_bc2(fclaw_global_t *glob, + fclaw_patch_t *patch, int block_idx, int patch_idx, double t, @@ -308,19 +308,19 @@ void allencahn_bc2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); ALLENCAHN_FORT_BC2(&meqn,&mbc,&mx,&my,&xlower,&ylower, &dx,&dy,q,&t,&dt,intersects_bc); } -void allencahn_link_solvers(fclaw2d_global_t *glob) +void allencahn_link_solvers(fclaw_global_t *glob) { #if 0 /* These are listed here for reference */ @@ -330,11 +330,11 @@ void allencahn_link_solvers(fclaw2d_global_t *glob) fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); #endif /* ForestClaw vtable */ - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = &allencahn_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = &allencahn_problem_setup; /* Patch : RHS function */ - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); patch_vt->physical_bc = allencahn_bc2; /* Doesn't do anything */ patch_vt->rhs = allencahn_rhs; /* Overwrites default */ patch_vt->initialize = allencahn_initialize; /* Get an initial refinement */ @@ -352,9 +352,9 @@ void allencahn_link_solvers(fclaw2d_global_t *glob) patch_vt->tag4refinement = allencahn_tag4refinement; patch_vt->tag4coarsening = allencahn_tag4coarsening; - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - clawpatch_vt->fort_tag4refinement = &TAG4REFINEMENT; - clawpatch_vt->fort_tag4coarsening = &TAG4COARSENING; + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + clawpatch_vt->d2->fort_tag4refinement = &TAG4REFINEMENT; + clawpatch_vt->d2->fort_tag4coarsening = &TAG4COARSENING; } diff --git a/applications/elliptic/allencahn/allencahn_user.h b/applications/elliptic/allencahn/allencahn_user.h index 13dc1df60..53c701e57 100644 --- a/applications/elliptic/allencahn/allencahn_user.h +++ b/applications/elliptic/allencahn/allencahn_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ALLENCAHN_USER_H #define ALLENCAHN_USER_H -#include +#include #include @@ -44,9 +44,9 @@ extern "C" /* --------------------------- Problem dependent functions -----------------------------*/ -void allencahn_link_solvers(fclaw2d_global_t *glob); +void allencahn_link_solvers(fclaw_global_t *glob); -void allencahn_run(fclaw2d_global_t *glob); +void allencahn_run(fclaw_global_t *glob); /* --------------------------- Fortran functions ---------------------------------------*/ diff --git a/applications/elliptic/heat/heat.cpp b/applications/elliptic/heat/heat.cpp index 36a7783cf..315f63f91 100644 --- a/applications/elliptic/heat/heat.cpp +++ b/applications/elliptic/heat/heat.cpp @@ -25,25 +25,25 @@ #include "heat_user.h" -#include +#include -#include -#include +#include +#include -#include +#include -#include -#include +#include +#include #include #include static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { /* Mapped, multi-block domain */ - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -51,34 +51,28 @@ void create_domain(fclaw2d_global_t* glob) int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; - fclaw2d_domain_t *domain = fclaw2d_domain_new_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); + fclaw_domain_t *domain = fclaw_domain_new_2d_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); /* Map unit square to disk using mapc2m_disk.f */ - fclaw2d_map_context_t *brick = fclaw2d_map_new_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap_brick(brick); + fclaw_map_context_t *brick = fclaw_map_new_2d_brick(domain, mi, mj, a, b); + fclaw_map_context_t *cont = fclaw_map_new_nomap_brick(brick); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { // const heat_options_t *user_opt; // user_opt = heat_get_options(glob); - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Test thunderegg solver */ fc2d_thunderegg_solver_initialize(glob); @@ -91,14 +85,14 @@ void run_program(fclaw2d_global_t* glob) --------------------------------------------------------------- */ /* Set up initial conditions */ - fclaw2d_initialize(glob); + fclaw_initialize(glob); heat_run(glob); /* --------------------------------------------------------------- Finalize --------------------------------------------------------------- */ - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -109,13 +103,13 @@ main (int argc, char **argv) /* Options */ fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_thunderegg_options_t *mg_opt; heat_options_t *user_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); mg_opt = fc2d_thunderegg_options_register(app, "thunderegg", "fclaw_options.ini"); user_opt = heat_options_register(app, "fclaw_options.ini"); @@ -132,11 +126,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_thunderegg_options_store (glob, mg_opt); heat_options_store (glob, user_opt); @@ -144,7 +138,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/elliptic/heat/heat_diagnostics.c b/applications/elliptic/heat/heat_diagnostics.c index 24a2345c5..af1d87846 100644 --- a/applications/elliptic/heat/heat_diagnostics.c +++ b/applications/elliptic/heat/heat_diagnostics.c @@ -25,20 +25,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "heat_diagnostics.h" -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -void heat_diagnostics_initialize(fclaw2d_global_t *glob, +void heat_diagnostics_initialize(fclaw_global_t *glob, void **acc_patch) { - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); heat_error_info_t *error_data; @@ -60,11 +60,11 @@ void heat_diagnostics_initialize(fclaw2d_global_t *glob, } -void heat_diagnostics_reset(fclaw2d_global_t *glob, +void heat_diagnostics_reset(fclaw_global_t *glob, void* patch_acc) { heat_error_info_t *error_data = (heat_error_info_t*) patch_acc; - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int mfields = clawpatch_opt->rhs_fields; @@ -86,27 +86,27 @@ void heat_diagnostics_reset(fclaw2d_global_t *glob, } static -void heat_compute(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void heat_compute(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void* user) //void *patch_acc) { - fclaw2d_global_iterate_t *s = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *s = (fclaw_global_iterate_t *) user; heat_error_info_t *error_data = (heat_error_info_t*) s->user; /* Accumulate area for final computation of error */ int mx, my, mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(s->glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); + fclaw_clawpatch_2d_grid_data(s->glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(s->glob); - double *area = fclaw2d_clawpatch_get_area(s->glob,patch); - FCLAW_ASSERT(clawpatch_vt->fort_compute_patch_area != NULL); - error_data->area += clawpatch_vt->fort_compute_patch_area(&mx,&my,&mbc,&dx,&dy,area); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(s->glob); + double *area = fclaw_clawpatch_get_2d_area(s->glob,patch); + FCLAW_ASSERT(clawpatch_vt->d2->fort_compute_patch_area != NULL); + error_data->area += clawpatch_vt->d2->fort_compute_patch_area(&mx,&my,&mbc,&dx,&dy,area); /* Compute error */ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(s->glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(s->glob); if (fclaw_opt->compute_error) { clawpatch_vt->compute_error(s->glob, patch, blockno, patchno, error_data); @@ -118,34 +118,34 @@ void heat_compute(fclaw2d_domain_t *domain, } } -void heat_diagnostics_compute(fclaw2d_global_t* glob, +void heat_diagnostics_compute(fclaw_global_t* glob, void* patch_acc) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int check = fclaw_opt->compute_error || fclaw_opt->conservation_check; if (!check) return; - fclaw2d_global_iterate_patches(glob, heat_compute, patch_acc); + fclaw_global_iterate_patches(glob, heat_compute, patch_acc); } /* Accumulate the errors computed above */ -void heat_diagnostics_gather(fclaw2d_global_t *glob, +void heat_diagnostics_gather(fclaw_global_t *glob, void* patch_acc, int init_flag) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; heat_error_info_t *error_data = (heat_error_info_t*) patch_acc; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int mfields = clawpatch_opt->rhs_fields; /* clawpatch->meqn */ if (fclaw_opt->compute_error != 0) { - double total_area = fclaw2d_domain_global_sum(domain, error_data->area); + double total_area = fclaw_domain_global_sum(domain, error_data->area); FCLAW_ASSERT(total_area != 0); double *error_norm = FCLAW_ALLOC_ZERO(double,3*mfields); @@ -155,14 +155,14 @@ void heat_diagnostics_gather(fclaw2d_global_t *glob, int i2 = mfields + m; /* 2-norm */ int i3 = 2*mfields + m; /* inf-norm */ - error_norm[i1] = fclaw2d_domain_global_sum(domain, error_data->local_error[i1]); + error_norm[i1] = fclaw_domain_global_sum(domain, error_data->local_error[i1]); error_norm[i1] /= total_area; - error_norm[i2] = fclaw2d_domain_global_sum(domain, error_data->local_error[i2]); + error_norm[i2] = fclaw_domain_global_sum(domain, error_data->local_error[i2]); error_norm[i2] /= total_area; error_norm[i2] = sqrt(error_norm[i2]); - error_norm[i3] = fclaw2d_domain_global_maximum(domain, + error_norm[i3] = fclaw_domain_global_maximum(domain, error_data->local_error[i3]); error_data->global_error[i1] = error_norm[i1]; @@ -184,12 +184,12 @@ void heat_diagnostics_gather(fclaw2d_global_t *glob, /* Store mass for future checks */ if (init_flag) { - total_mass[m] = fclaw2d_domain_global_sum(domain, error_data->rhs[m]); + total_mass[m] = fclaw_domain_global_sum(domain, error_data->rhs[m]); error_data->mass0[m] = total_mass[m]; } else { - total_mass[m] = fclaw2d_domain_global_sum(domain, error_data->boundary[m]); + total_mass[m] = fclaw_domain_global_sum(domain, error_data->boundary[m]); } fclaw_global_essentialf("sum[%d] = %24.16e %24.16e\n",m,total_mass[m], fabs(total_mass[m]-error_data->mass0[m])); @@ -199,7 +199,7 @@ void heat_diagnostics_gather(fclaw2d_global_t *glob, } -void heat_diagnostics_finalize(fclaw2d_global_t *glob, +void heat_diagnostics_finalize(fclaw_global_t *glob, void** patch_acc) { heat_error_info_t *error_data = *((heat_error_info_t**) patch_acc); diff --git a/applications/elliptic/heat/heat_diagnostics.h b/applications/elliptic/heat/heat_diagnostics.h index e99efbb7e..a211b2a85 100644 --- a/applications/elliptic/heat/heat_diagnostics.h +++ b/applications/elliptic/heat/heat_diagnostics.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef HEAT_DIAGNOSTICS_H #define HEAT_DIAGNOSTICS_H -#include +#include #include @@ -51,21 +51,21 @@ typedef struct { /* --------------------------- Problem dependent functions -----------------------------*/ -void heat_diagnostics_initialize(fclaw2d_global_t *glob, void **acc_patch); +void heat_diagnostics_initialize(fclaw_global_t *glob, void **acc_patch); -void heat_diagnostics_reset(fclaw2d_global_t *glob, void* patch_acc); +void heat_diagnostics_reset(fclaw_global_t *glob, void* patch_acc); -void heat_diagnostics_compute(fclaw2d_global_t* glob, +void heat_diagnostics_compute(fclaw_global_t* glob, void* patch_acc); -void heat_diagnostics_gather(fclaw2d_global_t *glob, void* patch_acc, +void heat_diagnostics_gather(fclaw_global_t *glob, void* patch_acc, int init_flag); -void heat_diagnostics_finalize(fclaw2d_global_t *glob, void** patch_acc); +void heat_diagnostics_finalize(fclaw_global_t *glob, void** patch_acc); -void heat_compute_diagnostics(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void heat_compute_diagnostics(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void* user); diff --git a/applications/elliptic/heat/heat_options.c b/applications/elliptic/heat/heat_options.c index e3d0d5da0..53d57c351 100644 --- a/applications/elliptic/heat/heat_options.c +++ b/applications/elliptic/heat/heat_options.c @@ -214,12 +214,12 @@ heat_options_t* heat_options_register (fclaw_app_t * app, return user; } -void heat_options_store (fclaw2d_global_t* glob, heat_options_t* user) +void heat_options_store (fclaw_global_t* glob, heat_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const heat_options_t* heat_get_options(fclaw2d_global_t* glob) +const heat_options_t* heat_get_options(fclaw_global_t* glob) { - return (heat_options_t*) fclaw2d_global_get_options(glob, "user"); + return (heat_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/elliptic/heat/heat_options.h b/applications/elliptic/heat/heat_options.h index f8f5c124c..eab976b64 100644 --- a/applications/elliptic/heat/heat_options.h +++ b/applications/elliptic/heat/heat_options.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef HEAT_OPTIONS_H #define HEAT_OPTIONS_H -#include +#include #ifdef __cplusplus extern "C" @@ -91,9 +91,9 @@ typedef struct heat_options heat_options_t* heat_options_register (fclaw_app_t * app, const char *configfile); -void heat_options_store(fclaw2d_global_t* glob, heat_options_t* user); +void heat_options_store(fclaw_global_t* glob, heat_options_t* user); -const heat_options_t* heat_get_options(fclaw2d_global_t* glob); +const heat_options_t* heat_get_options(fclaw_global_t* glob); #ifdef __cplusplus diff --git a/applications/elliptic/heat/heat_run.c b/applications/elliptic/heat/heat_run.c index 031b4e435..576f9672a 100644 --- a/applications/elliptic/heat/heat_run.c +++ b/applications/elliptic/heat/heat_run.c @@ -25,20 +25,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "heat_user.h" -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include #include "fclaw_math.h" @@ -90,25 +90,25 @@ void save_time_step(fclaw2d_global_t *glob) #endif static -void update_q(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void update_q(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t *) user; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(g->glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(g->glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double* rhs; int mfields; - fclaw2d_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); + fclaw_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); double* q; int meqn; - fclaw2d_clawpatch_soln_data(g->glob, patch, &q, &meqn); + fclaw_clawpatch_soln_data(g->glob, patch, &q, &meqn); FCLAW_ASSERT(mfields==meqn); @@ -118,9 +118,9 @@ void update_q(fclaw2d_domain_t *domain, static -void heat_run_update_q(fclaw2d_global_t *glob) +void heat_run_update_q(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob, update_q, NULL); + fclaw_global_iterate_patches(glob, update_q, NULL); } @@ -129,15 +129,15 @@ void heat_run_update_q(fclaw2d_global_t *glob) Output times are at times [0,dT, 2*dT, 3*dT,...,Tfinal], where dT = tfinal/nout -------------------------------------------------------------------------------- */ static -void outstyle_1(fclaw2d_global_t *glob) +void outstyle_1(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double final_time = fclaw_opt->tfinal; int nout = fclaw_opt->nout; @@ -147,7 +147,7 @@ void outstyle_1(fclaw2d_global_t *glob) int init_flag = 1; /* Store anything that needs to be stored */ - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; double t0 = 0; @@ -197,7 +197,7 @@ void outstyle_1(fclaw2d_global_t *glob) fc2d_thunderegg_heat_set_lambda(lambda); /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ heat_run_update_q(glob); @@ -216,21 +216,21 @@ void outstyle_1(fclaw2d_global_t *glob) glob->curr_time = t_curr; - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); if (fclaw_opt->regrid_interval > 0) if (n_inner % fclaw_opt->regrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } /* Output file at every outer loop iteration */ - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); glob->curr_time = t_curr; iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } @@ -243,19 +243,19 @@ static void outstyle_2(fclaw2d_global_t *glob) #endif static -void outstyle_3(fclaw2d_global_t *glob) +void outstyle_3(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; @@ -306,14 +306,14 @@ void outstyle_3(fclaw2d_global_t *glob) /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ heat_run_update_q(glob); int time_interp = 0; - fclaw2d_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, - time_interp,FCLAW2D_TIMER_NONE); + fclaw_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, + time_interp,FCLAW_TIMER_NONE); double tc = t_curr + dt_step; @@ -337,19 +337,19 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nregrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } if (fclaw_opt->advance_one_step) - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); if (n % nstep_inner == 0) { iframe++; //fclaw2d_diagnostics_gather(glob,init_flag); - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -358,18 +358,18 @@ void outstyle_3(fclaw2d_global_t *glob) static -void outstyle_4(fclaw2d_global_t *glob) +void outstyle_4(fclaw_global_t *glob) { /* Write out an initial time file */ int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; int nstep_outer = fclaw_opt->nout; int nstep_inner = fclaw_opt->nstep; @@ -382,7 +382,7 @@ void outstyle_4(fclaw2d_global_t *glob) while (n < nstep_outer) { /* Get current domain data since it may change during regrid */ - fclaw2d_advance_all_levels(glob, t_curr, dt_minlevel); + fclaw_advance_all_levels(glob, t_curr, dt_minlevel); int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ? fclaw_opt->maxlevel : fclaw_opt->minlevel; @@ -402,7 +402,7 @@ void outstyle_4(fclaw2d_global_t *glob) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } else @@ -412,9 +412,9 @@ void outstyle_4(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -424,10 +424,10 @@ void outstyle_4(fclaw2d_global_t *glob) Public interface ---------------------------------------------------------------- */ -void heat_run(fclaw2d_global_t *glob) +void heat_run(fclaw_global_t *glob) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); switch (fclaw_opt->outstyle) { diff --git a/applications/elliptic/heat/heat_user.cpp b/applications/elliptic/heat/heat_user.cpp index 9bb7702c5..8cc5a0719 100644 --- a/applications/elliptic/heat/heat_user.cpp +++ b/applications/elliptic/heat/heat_user.cpp @@ -28,10 +28,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "heat_options.h" #include "heat_diagnostics.h" -#include +#include -#include -#include +#include +#include #include #include @@ -41,14 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include -#include +#include static -void heat_problem_setup(fclaw2d_global_t *glob) +void heat_problem_setup(fclaw_global_t *glob) { if (glob->mpirank == 0) { @@ -88,25 +88,25 @@ void heat_problem_setup(fclaw2d_global_t *glob) fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); HEAT_SETPROB(); /* This file reads the file just created above */ } static -void heat_initialize(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void heat_initialize(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); /* This function supplies an analytic right hand side. */ HEAT_INIT(&blockno, &mbc, &mx, &my, &meqn, @@ -116,24 +116,24 @@ void heat_initialize(fclaw2d_global_t *glob, static -void heat_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void heat_rhs(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int mfields; double *rhs; - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); /* This function supplies an analytic right hand side. */ int method = 1; @@ -152,8 +152,8 @@ void heat_rhs(fclaw2d_global_t *glob, static -void heat_compute_error(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void heat_compute_error(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, void *user) @@ -161,24 +161,24 @@ void heat_compute_error(fclaw2d_global_t *glob, heat_error_info_t* error_data = (heat_error_info_t*) user; //const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); - if (clawpatch_vt->fort_compute_patch_error != NULL) + if (clawpatch_vt->d2->fort_compute_patch_error != NULL) { int mx, my, mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc,&xlower, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc,&xlower, &ylower,&dx,&dy); - double *area = fclaw2d_clawpatch_get_area(glob,patch); /* Might be null */ + double *area = fclaw_clawpatch_get_2d_area(glob,patch); /* Might be null */ /* Solution is stored in the RHS */ double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); - double *err = fclaw2d_clawpatch_get_error(glob,patch); - double *soln = fclaw2d_clawpatch_get_exactsoln(glob,patch); + double *err = fclaw_clawpatch_get_error(glob,patch); + double *soln = fclaw_clawpatch_get_exactsoln(glob,patch); #if 0 fclaw2d_clawpatch_elliptic_error_data(glob,patch,&err,&mfields); @@ -187,16 +187,16 @@ void heat_compute_error(fclaw2d_global_t *glob, double t = glob->curr_time; - clawpatch_vt->fort_compute_patch_error(&blockno, &mx,&my,&mbc, - &meqn,&dx,&dy, - &xlower,&ylower, &t, q, err, soln); + clawpatch_vt->d2->fort_compute_patch_error(&blockno, &mx,&my,&mbc, + &meqn,&dx,&dy, + &xlower,&ylower, &t, q, err, soln); /* Accumulate sums and maximums needed to compute error norms */ - FCLAW_ASSERT(clawpatch_vt->fort_compute_error_norm != NULL); - clawpatch_vt->fort_compute_error_norm(&blockno, &mx, &my, &mbc, &meqn, - &dx,&dy, area, err, - error_data->local_error); + FCLAW_ASSERT(clawpatch_vt->d2->fort_compute_error_norm != NULL); + clawpatch_vt->d2->fort_compute_error_norm(&blockno, &mx, &my, &mbc, &meqn, + &dx,&dy, area, err, + error_data->local_error); } } @@ -204,10 +204,10 @@ void heat_compute_error(fclaw2d_global_t *glob, static -void heat_time_header_ascii(fclaw2d_global_t* glob, int iframe) +void heat_time_header_ascii(fclaw_global_t* glob, int iframe) { - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); char matname1[20]; sprintf(matname1,"fort.q%04d",iframe); @@ -244,36 +244,36 @@ void heat_time_header_ascii(fclaw2d_global_t* glob, int iframe) static -void cb_heat_output_ascii(fclaw2d_domain_t * domain, - fclaw2d_patch_t * patch, +void cb_heat_output_ascii(fclaw_domain_t * domain, + fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) s->glob; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) s->glob; int iframe = *((int *) s->user); /* Get info not readily available to user */ int global_num, local_num; int level; - fclaw2d_patch_get_info(glob->domain,patch, + fclaw_patch_get_info(glob->domain,patch, blockno,patchno, &global_num,&local_num, &level); int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); - double *error = fclaw2d_clawpatch_get_error(glob,patch); - double *soln = fclaw2d_clawpatch_get_exactsoln(glob,patch); + double *error = fclaw_clawpatch_get_error(glob,patch); + double *soln = fclaw_clawpatch_get_exactsoln(glob,patch); char fname[BUFSIZ]; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); snprintf (fname, BUFSIZ, "%s.q%04d", fclaw_opt->prefix, iframe); /* The fort routine is defined by a clawpack solver and handles @@ -289,14 +289,14 @@ void cb_heat_output_ascii(fclaw2d_domain_t * domain, } -int heat_tag4refinement(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +int heat_tag4refinement(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, int patchno, int initflag) { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int tag_patch; double refine_threshold; @@ -305,57 +305,57 @@ int heat_tag4refinement(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); tag_patch = 0; - clawpatch_vt->fort_tag4refinement(&mx,&my,&mbc,&meqn, - &xlower,&ylower,&dx,&dy, - &blockno, q,&refine_threshold, - &initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4refinement(&mx,&my,&mbc,&meqn, + &xlower,&ylower,&dx,&dy, + &blockno, q,&refine_threshold, + &initflag,&tag_patch); return tag_patch; } static -int heat_tag4coarsening(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, +int heat_tag4coarsening(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, int blockno, int patchno, int initflag) { - fclaw2d_patch_t *patch0 = &fine_patches[0]; + fclaw_patch_t *patch0 = &fine_patches[0]; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double coarsen_threshold = fclaw_opt->coarsen_threshold; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch0,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch0,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q[4]; int meqn; for (int igrid = 0; igrid < 4; igrid++) { - fclaw2d_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); + fclaw_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); } - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); int tag_patch = 0; - clawpatch_vt->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, - &blockno, q[0],q[1],q[2],q[3], - &coarsen_threshold,&initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, + &blockno, q[0],q[1],q[2],q[3], + &coarsen_threshold,&initflag,&tag_patch); return tag_patch == 1; } static -void heat_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void heat_bc2(fclaw_global_t *glob, + fclaw_patch_t *patch, int block_idx, int patch_idx, double t, @@ -367,19 +367,19 @@ void heat_bc2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); HEAT_FORT_BC2(&meqn,&mbc,&mx,&my,&xlower,&ylower, &dx,&dy,q,&t,&dt,intersects_bc); } -void heat_link_solvers(fclaw2d_global_t *glob) +void heat_link_solvers(fclaw_global_t *glob) { #if 0 /* These are listed here for reference */ @@ -388,11 +388,11 @@ void heat_link_solvers(fclaw2d_global_t *glob) fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); #endif /* ForestClaw vtable */ - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = &heat_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = &heat_problem_setup; /* Patch : RHS function */ - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); patch_vt->physical_bc = heat_bc2; patch_vt->rhs = heat_rhs; /* Overwrites default */ patch_vt->initialize = heat_initialize; /* Get an initial refinement */ @@ -406,15 +406,15 @@ void heat_link_solvers(fclaw2d_global_t *glob) mg_vt->fort_eval_bc = &HEAT_NEUMANN; // For non-homogeneous BCs /* Clawpatch : Compute the error */ - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); clawpatch_vt->compute_error = heat_compute_error; - clawpatch_vt->fort_compute_patch_error = &HEAT_COMPUTE_ERROR; + clawpatch_vt->d2->fort_compute_patch_error = &HEAT_COMPUTE_ERROR; // tagging routines patch_vt->tag4refinement = heat_tag4refinement; patch_vt->tag4coarsening = heat_tag4coarsening; - clawpatch_vt->fort_tag4refinement = &TAG4REFINEMENT; - clawpatch_vt->fort_tag4coarsening = &TAG4COARSENING; + clawpatch_vt->d2->fort_tag4refinement = &TAG4REFINEMENT; + clawpatch_vt->d2->fort_tag4coarsening = &TAG4COARSENING; // Output routines clawpatch_vt->time_header_ascii = heat_time_header_ascii; diff --git a/applications/elliptic/heat/heat_user.h b/applications/elliptic/heat/heat_user.h index d36a81825..3fdc1f667 100644 --- a/applications/elliptic/heat/heat_user.h +++ b/applications/elliptic/heat/heat_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef HEAT_USER_H #define HEAT_USER_H -#include +#include #include @@ -44,9 +44,9 @@ extern "C" /* --------------------------- Problem dependent functions -----------------------------*/ -void heat_link_solvers(fclaw2d_global_t *glob); +void heat_link_solvers(fclaw_global_t *glob); -void heat_run(fclaw2d_global_t *glob); +void heat_run(fclaw_global_t *glob); /* --------------------------- Fortran functions ---------------------------------------*/ diff --git a/applications/elliptic/heat_phasefield/heat/heat.cpp b/applications/elliptic/heat_phasefield/heat/heat.cpp index 3e97af4d5..433c417b1 100644 --- a/applications/elliptic/heat_phasefield/heat/heat.cpp +++ b/applications/elliptic/heat_phasefield/heat/heat.cpp @@ -27,25 +27,25 @@ #include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include +#include +#include #include #include -void heat_create_domain(fclaw2d_global_t* glob) +void heat_create_domain(fclaw_global_t* glob) { /* Mapped, multi-block domain */ - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -53,31 +53,25 @@ void heat_create_domain(fclaw2d_global_t* glob) int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; - fclaw2d_domain_t *domain = fclaw2d_domain_new_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); + fclaw_domain_t *domain = fclaw_domain_new_2d_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); /* Map unit square to disk using mapc2m_disk.f */ - fclaw2d_map_context_t *brick = fclaw2d_map_new_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap_brick(brick); + fclaw_map_context_t *brick = fclaw_map_new_2d_brick(domain, mi, mj, a, b); + fclaw_map_context_t *cont = fclaw_map_new_nomap_brick(brick); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } -void heat_run_program(fclaw2d_global_t* glob) +void heat_run_program(fclaw_global_t* glob) { - fclaw2d_set_global_context(glob); - - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - + fclaw_set_global_context(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Test thunderegg solver */ fc2d_thunderegg_solver_initialize(glob); @@ -90,14 +84,14 @@ void heat_run_program(fclaw2d_global_t* glob) --------------------------------------------------------------- */ /* Set up initial conditions */ - fclaw2d_initialize(glob); + fclaw_initialize(glob); heat_run(glob); /* --------------------------------------------------------------- Finalize --------------------------------------------------------------- */ - fclaw2d_finalize(glob); + fclaw_finalize(glob); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } \ No newline at end of file diff --git a/applications/elliptic/heat_phasefield/heat/heat_diagnostics.c b/applications/elliptic/heat_phasefield/heat/heat_diagnostics.c index 24a2345c5..af1d87846 100644 --- a/applications/elliptic/heat_phasefield/heat/heat_diagnostics.c +++ b/applications/elliptic/heat_phasefield/heat/heat_diagnostics.c @@ -25,20 +25,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "heat_diagnostics.h" -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -void heat_diagnostics_initialize(fclaw2d_global_t *glob, +void heat_diagnostics_initialize(fclaw_global_t *glob, void **acc_patch) { - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); heat_error_info_t *error_data; @@ -60,11 +60,11 @@ void heat_diagnostics_initialize(fclaw2d_global_t *glob, } -void heat_diagnostics_reset(fclaw2d_global_t *glob, +void heat_diagnostics_reset(fclaw_global_t *glob, void* patch_acc) { heat_error_info_t *error_data = (heat_error_info_t*) patch_acc; - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int mfields = clawpatch_opt->rhs_fields; @@ -86,27 +86,27 @@ void heat_diagnostics_reset(fclaw2d_global_t *glob, } static -void heat_compute(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void heat_compute(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void* user) //void *patch_acc) { - fclaw2d_global_iterate_t *s = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *s = (fclaw_global_iterate_t *) user; heat_error_info_t *error_data = (heat_error_info_t*) s->user; /* Accumulate area for final computation of error */ int mx, my, mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(s->glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); + fclaw_clawpatch_2d_grid_data(s->glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(s->glob); - double *area = fclaw2d_clawpatch_get_area(s->glob,patch); - FCLAW_ASSERT(clawpatch_vt->fort_compute_patch_area != NULL); - error_data->area += clawpatch_vt->fort_compute_patch_area(&mx,&my,&mbc,&dx,&dy,area); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(s->glob); + double *area = fclaw_clawpatch_get_2d_area(s->glob,patch); + FCLAW_ASSERT(clawpatch_vt->d2->fort_compute_patch_area != NULL); + error_data->area += clawpatch_vt->d2->fort_compute_patch_area(&mx,&my,&mbc,&dx,&dy,area); /* Compute error */ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(s->glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(s->glob); if (fclaw_opt->compute_error) { clawpatch_vt->compute_error(s->glob, patch, blockno, patchno, error_data); @@ -118,34 +118,34 @@ void heat_compute(fclaw2d_domain_t *domain, } } -void heat_diagnostics_compute(fclaw2d_global_t* glob, +void heat_diagnostics_compute(fclaw_global_t* glob, void* patch_acc) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int check = fclaw_opt->compute_error || fclaw_opt->conservation_check; if (!check) return; - fclaw2d_global_iterate_patches(glob, heat_compute, patch_acc); + fclaw_global_iterate_patches(glob, heat_compute, patch_acc); } /* Accumulate the errors computed above */ -void heat_diagnostics_gather(fclaw2d_global_t *glob, +void heat_diagnostics_gather(fclaw_global_t *glob, void* patch_acc, int init_flag) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; heat_error_info_t *error_data = (heat_error_info_t*) patch_acc; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int mfields = clawpatch_opt->rhs_fields; /* clawpatch->meqn */ if (fclaw_opt->compute_error != 0) { - double total_area = fclaw2d_domain_global_sum(domain, error_data->area); + double total_area = fclaw_domain_global_sum(domain, error_data->area); FCLAW_ASSERT(total_area != 0); double *error_norm = FCLAW_ALLOC_ZERO(double,3*mfields); @@ -155,14 +155,14 @@ void heat_diagnostics_gather(fclaw2d_global_t *glob, int i2 = mfields + m; /* 2-norm */ int i3 = 2*mfields + m; /* inf-norm */ - error_norm[i1] = fclaw2d_domain_global_sum(domain, error_data->local_error[i1]); + error_norm[i1] = fclaw_domain_global_sum(domain, error_data->local_error[i1]); error_norm[i1] /= total_area; - error_norm[i2] = fclaw2d_domain_global_sum(domain, error_data->local_error[i2]); + error_norm[i2] = fclaw_domain_global_sum(domain, error_data->local_error[i2]); error_norm[i2] /= total_area; error_norm[i2] = sqrt(error_norm[i2]); - error_norm[i3] = fclaw2d_domain_global_maximum(domain, + error_norm[i3] = fclaw_domain_global_maximum(domain, error_data->local_error[i3]); error_data->global_error[i1] = error_norm[i1]; @@ -184,12 +184,12 @@ void heat_diagnostics_gather(fclaw2d_global_t *glob, /* Store mass for future checks */ if (init_flag) { - total_mass[m] = fclaw2d_domain_global_sum(domain, error_data->rhs[m]); + total_mass[m] = fclaw_domain_global_sum(domain, error_data->rhs[m]); error_data->mass0[m] = total_mass[m]; } else { - total_mass[m] = fclaw2d_domain_global_sum(domain, error_data->boundary[m]); + total_mass[m] = fclaw_domain_global_sum(domain, error_data->boundary[m]); } fclaw_global_essentialf("sum[%d] = %24.16e %24.16e\n",m,total_mass[m], fabs(total_mass[m]-error_data->mass0[m])); @@ -199,7 +199,7 @@ void heat_diagnostics_gather(fclaw2d_global_t *glob, } -void heat_diagnostics_finalize(fclaw2d_global_t *glob, +void heat_diagnostics_finalize(fclaw_global_t *glob, void** patch_acc) { heat_error_info_t *error_data = *((heat_error_info_t**) patch_acc); diff --git a/applications/elliptic/heat_phasefield/heat/heat_diagnostics.h b/applications/elliptic/heat_phasefield/heat/heat_diagnostics.h index 66639a918..2ce767875 100644 --- a/applications/elliptic/heat_phasefield/heat/heat_diagnostics.h +++ b/applications/elliptic/heat_phasefield/heat/heat_diagnostics.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef HEAT_DIAGNOSTICS_H #define HEAT_DIAGNOSTICS_H -#include +#include #include @@ -51,21 +51,21 @@ typedef struct { /* --------------------------- Problem dependent functions -----------------------------*/ -void heat_diagnostics_initialize(fclaw2d_global_t *glob, void **acc_patch); +void heat_diagnostics_initialize(fclaw_global_t *glob, void **acc_patch); -void heat_diagnostics_reset(fclaw2d_global_t *glob, void* patch_acc); +void heat_diagnostics_reset(fclaw_global_t *glob, void* patch_acc); -void heat_diagnostics_compute(fclaw2d_global_t* glob, +void heat_diagnostics_compute(fclaw_global_t* glob, void* patch_acc); -void heat_diagnostics_gather(fclaw2d_global_t *glob, void* patch_acc, +void heat_diagnostics_gather(fclaw_global_t *glob, void* patch_acc, int init_flag); -void heat_diagnostics_finalize(fclaw2d_global_t *glob, void** patch_acc); +void heat_diagnostics_finalize(fclaw_global_t *glob, void** patch_acc); -void heat_compute_diagnostics(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void heat_compute_diagnostics(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void* user); diff --git a/applications/elliptic/heat_phasefield/heat/heat_options.c b/applications/elliptic/heat_phasefield/heat/heat_options.c index a7b407e2d..25f923efd 100644 --- a/applications/elliptic/heat_phasefield/heat/heat_options.c +++ b/applications/elliptic/heat_phasefield/heat/heat_options.c @@ -214,12 +214,12 @@ heat_options_t* heat_options_register (fclaw_app_t * app, return user; } -void heat_options_store (fclaw2d_global_t* glob, heat_options_t* user) +void heat_options_store (fclaw_global_t* glob, heat_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const heat_options_t* heat_get_options(fclaw2d_global_t* glob) +const heat_options_t* heat_get_options(fclaw_global_t* glob) { - return (heat_options_t*) fclaw2d_global_get_options(glob, "user"); + return (heat_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/elliptic/heat_phasefield/heat/heat_options.h b/applications/elliptic/heat_phasefield/heat/heat_options.h index ff10bce51..488bdbabe 100644 --- a/applications/elliptic/heat_phasefield/heat/heat_options.h +++ b/applications/elliptic/heat_phasefield/heat/heat_options.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef HEAT_OPTIONS_H #define HEAT_OPTIONS_H -#include +#include #ifdef __cplusplus extern "C" @@ -92,9 +92,9 @@ heat_options_t* heat_options_register (fclaw_app_t * app, const char *section, const char *configfile); -void heat_options_store(fclaw2d_global_t* glob, heat_options_t* user); +void heat_options_store(fclaw_global_t* glob, heat_options_t* user); -const heat_options_t* heat_get_options(fclaw2d_global_t* glob); +const heat_options_t* heat_get_options(fclaw_global_t* glob); #ifdef __cplusplus diff --git a/applications/elliptic/heat_phasefield/heat/heat_run.c b/applications/elliptic/heat_phasefield/heat/heat_run.c index 20d182726..93f979aa1 100644 --- a/applications/elliptic/heat_phasefield/heat/heat_run.c +++ b/applications/elliptic/heat_phasefield/heat/heat_run.c @@ -25,20 +25,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "heat_user.h" -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include #include "fclaw_math.h" @@ -90,25 +90,25 @@ void save_time_step(fclaw2d_global_t *glob) #endif static -void update_q(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void update_q(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t *) user; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(g->glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(g->glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double* rhs; int mfields; - fclaw2d_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); + fclaw_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); double* q; int meqn; - fclaw2d_clawpatch_soln_data(g->glob, patch, &q, &meqn); + fclaw_clawpatch_soln_data(g->glob, patch, &q, &meqn); FCLAW_ASSERT(mfields==meqn); @@ -118,9 +118,9 @@ void update_q(fclaw2d_domain_t *domain, static -void heat_run_update_q(fclaw2d_global_t *glob) +void heat_run_update_q(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob, update_q, NULL); + fclaw_global_iterate_patches(glob, update_q, NULL); } @@ -129,15 +129,15 @@ void heat_run_update_q(fclaw2d_global_t *glob) Output times are at times [0,dT, 2*dT, 3*dT,...,Tfinal], where dT = tfinal/nout -------------------------------------------------------------------------------- */ static -void outstyle_1(fclaw2d_global_t *glob) +void outstyle_1(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double final_time = fclaw_opt->tfinal; int nout = fclaw_opt->nout; @@ -147,7 +147,7 @@ void outstyle_1(fclaw2d_global_t *glob) int init_flag = 1; /* Store anything that needs to be stored */ - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; double t0 = 0; @@ -197,7 +197,7 @@ void outstyle_1(fclaw2d_global_t *glob) fc2d_thunderegg_heat_set_lambda(lambda); /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ heat_run_update_q(glob); @@ -216,21 +216,21 @@ void outstyle_1(fclaw2d_global_t *glob) glob->curr_time = t_curr; - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); if (fclaw_opt->regrid_interval > 0) if (n_inner % fclaw_opt->regrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } /* Output file at every outer loop iteration */ - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); glob->curr_time = t_curr; iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } @@ -243,19 +243,19 @@ static void outstyle_2(fclaw2d_global_t *glob) #endif static -void outstyle_3(fclaw2d_global_t *glob) +void outstyle_3(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; @@ -306,14 +306,14 @@ void outstyle_3(fclaw2d_global_t *glob) /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ heat_run_update_q(glob); int time_interp = 0; - fclaw2d_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, - time_interp,FCLAW2D_TIMER_NONE); + fclaw_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, + time_interp,FCLAW_TIMER_NONE); double tc = t_curr + dt_step; @@ -337,19 +337,19 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nregrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } if (fclaw_opt->advance_one_step) - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); if (n % nstep_inner == 0) { iframe++; //fclaw2d_diagnostics_gather(glob,init_flag); - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -358,18 +358,18 @@ void outstyle_3(fclaw2d_global_t *glob) static -void outstyle_4(fclaw2d_global_t *glob) +void outstyle_4(fclaw_global_t *glob) { /* Write out an initial time file */ int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; int nstep_outer = fclaw_opt->nout; int nstep_inner = fclaw_opt->nstep; @@ -382,7 +382,7 @@ void outstyle_4(fclaw2d_global_t *glob) while (n < nstep_outer) { /* Get current domain data since it may change during regrid */ - fclaw2d_advance_all_levels(glob, t_curr, dt_minlevel); + fclaw_advance_all_levels(glob, t_curr, dt_minlevel); int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ? fclaw_opt->maxlevel : fclaw_opt->minlevel; @@ -402,7 +402,7 @@ void outstyle_4(fclaw2d_global_t *glob) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } else @@ -412,9 +412,9 @@ void outstyle_4(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -424,10 +424,10 @@ void outstyle_4(fclaw2d_global_t *glob) Public interface ---------------------------------------------------------------- */ -void heat_run(fclaw2d_global_t *glob) +void heat_run(fclaw_global_t *glob) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); switch (fclaw_opt->outstyle) { diff --git a/applications/elliptic/heat_phasefield/heat/heat_user.cpp b/applications/elliptic/heat_phasefield/heat/heat_user.cpp index e06d33bbf..7438bfd17 100644 --- a/applications/elliptic/heat_phasefield/heat/heat_user.cpp +++ b/applications/elliptic/heat_phasefield/heat/heat_user.cpp @@ -28,10 +28,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "heat_options.h" #include "heat_diagnostics.h" -#include +#include -#include -#include +#include +#include #include #include @@ -41,14 +41,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include +#include -#include +#include static -void heat_problem_setup(fclaw2d_global_t *glob) +void heat_problem_setup(fclaw_global_t *glob) { if (glob->mpirank == 0) { @@ -88,25 +89,25 @@ void heat_problem_setup(fclaw2d_global_t *glob) fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); HEAT_SETPROB(); /* This file reads the file just created above */ } static -void heat_initialize(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void heat_initialize(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); /* This function supplies an analytic right hand side. */ HEAT_INIT(&blockno, &mbc, &mx, &my, &meqn, @@ -116,24 +117,24 @@ void heat_initialize(fclaw2d_global_t *glob, static -void heat_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void heat_rhs(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int mfields; double *rhs; - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); /* This function supplies an analytic right hand side. */ int method = 1; @@ -152,8 +153,8 @@ void heat_rhs(fclaw2d_global_t *glob, static -void heat_compute_error(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void heat_compute_error(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, void *user) @@ -161,24 +162,24 @@ void heat_compute_error(fclaw2d_global_t *glob, heat_error_info_t* error_data = (heat_error_info_t*) user; //const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); - if (clawpatch_vt->fort_compute_patch_error != NULL) + if (clawpatch_vt->d2->fort_compute_patch_error != NULL) { int mx, my, mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc,&xlower, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc,&xlower, &ylower,&dx,&dy); - double *area = fclaw2d_clawpatch_get_area(glob,patch); /* Might be null */ + double *area = fclaw_clawpatch_get_2d_area(glob,patch); /* Might be null */ /* Solution is stored in the RHS */ double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); - double *err = fclaw2d_clawpatch_get_error(glob,patch); - double *soln = fclaw2d_clawpatch_get_exactsoln(glob,patch); + double *err = fclaw_clawpatch_get_error(glob,patch); + double *soln = fclaw_clawpatch_get_exactsoln(glob,patch); #if 0 fclaw2d_clawpatch_elliptic_error_data(glob,patch,&err,&mfields); @@ -187,16 +188,16 @@ void heat_compute_error(fclaw2d_global_t *glob, double t = glob->curr_time; - clawpatch_vt->fort_compute_patch_error(&blockno, &mx,&my,&mbc, - &meqn,&dx,&dy, - &xlower,&ylower, &t, q, err, soln); + clawpatch_vt->d2->fort_compute_patch_error(&blockno, &mx,&my,&mbc, + &meqn,&dx,&dy, + &xlower,&ylower, &t, q, err, soln); /* Accumulate sums and maximums needed to compute error norms */ - FCLAW_ASSERT(clawpatch_vt->fort_compute_error_norm != NULL); - clawpatch_vt->fort_compute_error_norm(&blockno, &mx, &my, &mbc, &meqn, - &dx,&dy, area, err, - error_data->local_error); + FCLAW_ASSERT(clawpatch_vt->d2->fort_compute_error_norm != NULL); + clawpatch_vt->d2->fort_compute_error_norm(&blockno, &mx, &my, &mbc, &meqn, + &dx,&dy, area, err, + error_data->local_error); } } @@ -204,10 +205,10 @@ void heat_compute_error(fclaw2d_global_t *glob, static -void heat_time_header_ascii(fclaw2d_global_t* glob, int iframe) +void heat_time_header_ascii(fclaw_global_t* glob, int iframe) { - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); char matname1[20]; sprintf(matname1,"fort.q%04d",iframe); @@ -244,36 +245,36 @@ void heat_time_header_ascii(fclaw2d_global_t* glob, int iframe) static -void cb_heat_output_ascii(fclaw2d_domain_t * domain, - fclaw2d_patch_t * patch, +void cb_heat_output_ascii(fclaw_domain_t * domain, + fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) s->glob; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) s->glob; int iframe = *((int *) s->user); /* Get info not readily available to user */ int global_num, local_num; int level; - fclaw2d_patch_get_info(glob->domain,patch, + fclaw_patch_get_info(glob->domain,patch, blockno,patchno, &global_num,&local_num, &level); int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); - double *error = fclaw2d_clawpatch_get_error(glob,patch); - double *soln = fclaw2d_clawpatch_get_exactsoln(glob,patch); + double *error = fclaw_clawpatch_get_error(glob,patch); + double *soln = fclaw_clawpatch_get_exactsoln(glob,patch); char fname[BUFSIZ]; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); snprintf (fname, BUFSIZ, "%s.q%04d", fclaw_opt->prefix, iframe); /* The fort routine is defined by a clawpack solver and handles @@ -289,14 +290,14 @@ void cb_heat_output_ascii(fclaw2d_domain_t * domain, } -int heat_tag4refinement(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +int heat_tag4refinement(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, int patchno, int initflag) { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int tag_patch; double refine_threshold; @@ -305,57 +306,57 @@ int heat_tag4refinement(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); tag_patch = 0; - clawpatch_vt->fort_tag4refinement(&mx,&my,&mbc,&meqn, - &xlower,&ylower,&dx,&dy, - &blockno, q,&refine_threshold, - &initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4refinement(&mx,&my,&mbc,&meqn, + &xlower,&ylower,&dx,&dy, + &blockno, q,&refine_threshold, + &initflag,&tag_patch); return tag_patch; } static -int heat_tag4coarsening(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, +int heat_tag4coarsening(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, int blockno, int patchno, int initflag) { - fclaw2d_patch_t *patch0 = &fine_patches[0]; + fclaw_patch_t *patch0 = &fine_patches[0]; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double coarsen_threshold = fclaw_opt->coarsen_threshold; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch0,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch0,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q[4]; int meqn; for (int igrid = 0; igrid < 4; igrid++) { - fclaw2d_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); + fclaw_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); } - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); int tag_patch = 0; - clawpatch_vt->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, - &blockno, q[0],q[1],q[2],q[3], - &coarsen_threshold,&initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, + &blockno, q[0],q[1],q[2],q[3], + &coarsen_threshold,&initflag,&tag_patch); return tag_patch == 1; } static -void heat_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void heat_bc2(fclaw_global_t *glob, + fclaw_patch_t *patch, int block_idx, int patch_idx, double t, @@ -367,19 +368,19 @@ void heat_bc2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); HEAT_FORT_BC2(&meqn,&mbc,&mx,&my,&xlower,&ylower, &dx,&dy,q,&t,&dt,intersects_bc); } -void heat_link_solvers(fclaw2d_global_t *glob) +void heat_link_solvers(fclaw_global_t *glob) { #if 0 /* These are listed here for reference */ @@ -388,11 +389,11 @@ void heat_link_solvers(fclaw2d_global_t *glob) fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); #endif /* ForestClaw vtable */ - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = &heat_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = &heat_problem_setup; /* Patch : RHS function */ - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); patch_vt->physical_bc = heat_bc2; patch_vt->rhs = heat_rhs; /* Overwrites default */ patch_vt->initialize = heat_initialize; /* Get an initial refinement */ @@ -406,15 +407,15 @@ void heat_link_solvers(fclaw2d_global_t *glob) mg_vt->fort_eval_bc = &HEAT_NEUMANN; // For non-homogeneous BCs /* Clawpatch : Compute the error */ - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); clawpatch_vt->compute_error = heat_compute_error; - clawpatch_vt->fort_compute_patch_error = &HEAT_COMPUTE_ERROR; + clawpatch_vt->d2->fort_compute_patch_error = &HEAT_COMPUTE_ERROR; // tagging routines patch_vt->tag4refinement = heat_tag4refinement; patch_vt->tag4coarsening = heat_tag4coarsening; - clawpatch_vt->fort_tag4refinement = &HEAT_TAG4REFINEMENT; - clawpatch_vt->fort_tag4coarsening = &HEAT_TAG4COARSENING; + clawpatch_vt->d2->fort_tag4refinement = &HEAT_TAG4REFINEMENT; + clawpatch_vt->d2->fort_tag4coarsening = &HEAT_TAG4COARSENING; // Output routines clawpatch_vt->time_header_ascii = heat_time_header_ascii; diff --git a/applications/elliptic/heat_phasefield/heat/heat_user.h b/applications/elliptic/heat_phasefield/heat/heat_user.h index 6036777a5..1015597f1 100644 --- a/applications/elliptic/heat_phasefield/heat/heat_user.h +++ b/applications/elliptic/heat_phasefield/heat/heat_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef HEAT_USER_H #define HEAT_USER_H -#include +#include #include @@ -44,9 +44,9 @@ extern "C" /* --------------------------- Problem dependent functions -----------------------------*/ -void heat_link_solvers(fclaw2d_global_t *glob); +void heat_link_solvers(fclaw_global_t *glob); -void heat_run(fclaw2d_global_t *glob); +void heat_run(fclaw_global_t *glob); /* --------------------------- Fortran functions ---------------------------------------*/ @@ -177,9 +177,9 @@ void HEAT_FORT_BC2(const int* meqn, const int* mbc, double q[], double* t, double *dt, int intersects_bc[]); -void heat_create_domain(fclaw2d_global_t* glob); +void heat_create_domain(fclaw_global_t* glob); -void heat_run_program(fclaw2d_global_t* glob); +void heat_run_program(fclaw_global_t* glob); #ifdef __cplusplus #if 0 diff --git a/applications/elliptic/heat_phasefield/heat_phasefield.cpp b/applications/elliptic/heat_phasefield/heat_phasefield.cpp index 01396a224..009129d63 100644 --- a/applications/elliptic/heat_phasefield/heat_phasefield.cpp +++ b/applications/elliptic/heat_phasefield/heat_phasefield.cpp @@ -26,15 +26,15 @@ #include "heat/heat_user.h" #include "phasefield/phasefield_user.h" -#include +#include -#include -#include +#include +#include -#include +#include -#include -#include +#include +#include #include #include @@ -48,22 +48,22 @@ main (int argc, char **argv) /* Create new options packages */ fclaw_options_t *heat_fclaw_opt; - fclaw2d_clawpatch_options_t *heat_clawpatch_opt; + fclaw_clawpatch_options_t *heat_clawpatch_opt; fc2d_thunderegg_options_t *heat_mg_opt; heat_options_t *heat_user_opt; heat_fclaw_opt = fclaw_options_register(app, "heat", "fclaw_options.ini"); - heat_clawpatch_opt = fclaw2d_clawpatch_options_register(app, "heat-clawpatch", "fclaw_options.ini"); + heat_clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "heat-clawpatch", "fclaw_options.ini"); heat_mg_opt = fc2d_thunderegg_options_register(app, "heat-thunderegg", "fclaw_options.ini"); heat_user_opt = heat_options_register(app, "heat-user", "fclaw_options.ini"); fclaw_options_t *phasefield_fclaw_opt; - fclaw2d_clawpatch_options_t *phasefield_clawpatch_opt; + fclaw_clawpatch_options_t *phasefield_clawpatch_opt; fc2d_thunderegg_options_t *phasefield_mg_opt; phasefield_options_t *phasefield_user_opt; phasefield_fclaw_opt = fclaw_options_register(app, "phasefield", "fclaw_options.ini"); - phasefield_clawpatch_opt = fclaw2d_clawpatch_options_register(app, "phasefield-clawpatch", "fclaw_options.ini"); + phasefield_clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "phasefield-clawpatch", "fclaw_options.ini"); phasefield_mg_opt = fc2d_thunderegg_options_register(app, "phasefield-thunderegg", "fclaw_options.ini"); phasefield_user_opt = phasefield_options_register(app, "phasefield-user", "fclaw_options.ini"); @@ -80,11 +80,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *heat_glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *heat_glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (heat_glob, heat_fclaw_opt); - fclaw2d_clawpatch_options_store (heat_glob, heat_clawpatch_opt); + fclaw_options_store (heat_glob, heat_fclaw_opt); + fclaw_clawpatch_options_store (heat_glob, heat_clawpatch_opt); fc2d_thunderegg_options_store (heat_glob, heat_mg_opt); heat_options_store (heat_glob, heat_user_opt); @@ -92,15 +92,15 @@ main (int argc, char **argv) heat_run_program(heat_glob); - fclaw2d_global_destroy(heat_glob); + fclaw_global_destroy(heat_glob); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *phasefield_glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *phasefield_glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (phasefield_glob, phasefield_fclaw_opt); - fclaw2d_clawpatch_options_store (phasefield_glob, phasefield_clawpatch_opt); + fclaw_options_store (phasefield_glob, phasefield_fclaw_opt); + fclaw_clawpatch_options_store (phasefield_glob, phasefield_clawpatch_opt); fc2d_thunderegg_options_store (phasefield_glob, phasefield_mg_opt); phasefield_options_store (phasefield_glob, phasefield_user_opt); @@ -108,7 +108,7 @@ main (int argc, char **argv) phasefield_run_program(phasefield_glob); - fclaw2d_global_destroy(phasefield_glob); + fclaw_global_destroy(phasefield_glob); } fclaw_app_destroy (app); diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield.cpp b/applications/elliptic/heat_phasefield/phasefield/phasefield.cpp index da33a04b4..8b2749de5 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield.cpp +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield.cpp @@ -28,24 +28,24 @@ #include -#include +#include -#include -#include -#include +#include +#include +#include -#include +#include -#include -#include +#include +#include #include #include -void phasefield_create_domain(fclaw2d_global_t* glob) +void phasefield_create_domain(fclaw_global_t* glob) { /* Mapped, multi-block domain */ - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -53,31 +53,25 @@ void phasefield_create_domain(fclaw2d_global_t* glob) int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; - fclaw2d_domain_t *domain = fclaw2d_domain_new_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); + fclaw_domain_t *domain = fclaw_domain_new_2d_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); /* Map unit square to disk using mapc2m_disk.f */ - fclaw2d_map_context_t *brick = fclaw2d_map_new_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap_brick(brick); + fclaw_map_context_t *brick = fclaw_map_new_2d_brick(domain, mi, mj, a, b); + fclaw_map_context_t *cont = fclaw_map_new_nomap_brick(brick); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } -void phasefield_run_program(fclaw2d_global_t* glob) +void phasefield_run_program(fclaw_global_t* glob) { - fclaw2d_set_global_context(glob); - - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - + fclaw_set_global_context(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Test thunderegg solver */ fc2d_thunderegg_solver_initialize(glob); @@ -90,14 +84,14 @@ void phasefield_run_program(fclaw2d_global_t* glob) --------------------------------------------------------------- */ /* Set up grid and RHS */ - fclaw2d_initialize(glob); + fclaw_initialize(glob); phasefield_run(glob); /* --------------------------------------------------------------- Finalize --------------------------------------------------------------- */ - fclaw2d_finalize(glob); + fclaw_finalize(glob); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } \ No newline at end of file diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield_operator.cpp b/applications/elliptic/heat_phasefield/phasefield/phasefield_operator.cpp index 1fb904ea3..b46a0d16d 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield_operator.cpp +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield_operator.cpp @@ -32,19 +32,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + +#include #include #include @@ -72,12 +74,12 @@ Vector<2> restrict_phi_n_vec(const Vector<2>& prev_beta_vec, return restrictor.restrict(prev_beta_vec); } -void phasefield_solve(fclaw2d_global_t *glob) +void phasefield_solve(fclaw_global_t *glob) { // get needed options - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); const fc2d_thunderegg_options_t *mg_opt = fc2d_thunderegg_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); GhostFillingType fill_type = GhostFillingType::Faces; #if 0 @@ -91,15 +93,15 @@ void phasefield_solve(fclaw2d_global_t *glob) array ns = {clawpatch_opt->mx, clawpatch_opt->my}; // get p4est structure - fclaw2d_domain_t *domain = glob->domain; - p4est_wrap_t *wrap = (p4est_wrap_t *)domain->pp; + fclaw_domain_t *domain = glob->domain; + p4est_wrap_t *wrap = (p4est_wrap_t *)domain->d2->pp; // create map function P4estDomainGenerator::BlockMapFunc bmf = [&](int block_no, double unit_x, double unit_y, double &x, double &y) { double x1,y1,z1; - FCLAW2D_MAP_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); + FCLAW_MAP_2D_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); x = fclaw_opt->ax + (fclaw_opt->bx - fclaw_opt->ax) * x1; y = fclaw_opt->ay + (fclaw_opt->by - fclaw_opt->ay) * y1; }; diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield_operator.h b/applications/elliptic/heat_phasefield/phasefield/phasefield_operator.h index 7b54ea889..51796436d 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield_operator.h +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield_operator.h @@ -38,10 +38,10 @@ extern "C" /* fix syntax highlighting */ #endif -struct fclaw2d_global; +struct fclaw_global; -void phasefield_solve(struct fclaw2d_global *glob); +void phasefield_solve(struct fclaw_global *glob); void phasefield_set_lambda(double lambda); diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield_options.c b/applications/elliptic/heat_phasefield/phasefield/phasefield_options.c index f29dd18b4..9ddf94b64 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield_options.c +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield_options.c @@ -186,12 +186,12 @@ phasefield_options_t* phasefield_options_register (fclaw_app_t * app, return user; } -void phasefield_options_store (fclaw2d_global_t* glob, phasefield_options_t* user) +void phasefield_options_store (fclaw_global_t* glob, phasefield_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const phasefield_options_t* phasefield_get_options(fclaw2d_global_t* glob) +const phasefield_options_t* phasefield_get_options(fclaw_global_t* glob) { - return (phasefield_options_t*) fclaw2d_global_get_options(glob, "user"); + return (phasefield_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield_options.h b/applications/elliptic/heat_phasefield/phasefield/phasefield_options.h index d9c47f136..f2d600b7d 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield_options.h +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield_options.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef PHASEFIELD_OPTIONS_H #define PHASEFIELD_OPTIONS_H -#include +#include #ifdef __cplusplus extern "C" @@ -73,9 +73,9 @@ phasefield_options_t* phasefield_options_register (fclaw_app_t * app, const char *section, const char *configfile); -void phasefield_options_store(fclaw2d_global_t* glob, phasefield_options_t* user); +void phasefield_options_store(fclaw_global_t* glob, phasefield_options_t* user); -const phasefield_options_t* phasefield_get_options(fclaw2d_global_t* glob); +const phasefield_options_t* phasefield_get_options(fclaw_global_t* glob); #ifdef __cplusplus diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield_patch_operator.cpp b/applications/elliptic/heat_phasefield/phasefield/phasefield_patch_operator.cpp index 51f57c1a2..88722304b 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield_patch_operator.cpp +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield_patch_operator.cpp @@ -11,7 +11,7 @@ double phasefield::getLambda(){ return lambda; } -phasefield::phasefield(fclaw2d_global_t *glob, +phasefield::phasefield(fclaw_global_t *glob, const Vector<2>& phi_n, const Domain<2>& domain, const GhostFiller<2>& ghost_filler) diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield_patch_operator.h b/applications/elliptic/heat_phasefield/phasefield/phasefield_patch_operator.h index 19b64889a..006664256 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield_patch_operator.h +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield_patch_operator.h @@ -12,7 +12,7 @@ class phasefield : public ThunderEgg::PatchOperator<2> const phasefield_options_t *phase_opt; - phasefield(fclaw2d_global_t *glob, + phasefield(fclaw_global_t *glob, const ThunderEgg::Vector<2>& phi_n_in, const ThunderEgg::Domain<2>& domain, const ThunderEgg::GhostFiller<2>& ghost_filler); diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield_run.c b/applications/elliptic/heat_phasefield/phasefield/phasefield_run.c index 691c3b5df..9cd17d67a 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield_run.c +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield_run.c @@ -26,20 +26,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "phasefield_user.h" #include "phasefield_operator.h" -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include #include "fclaw_math.h" @@ -52,25 +52,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------- */ static -void update_q(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void update_q(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t *) user; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(g->glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(g->glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double* rhs; int mfields; - fclaw2d_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); + fclaw_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); double* q; int meqn; - fclaw2d_clawpatch_soln_data(g->glob, patch, &q, &meqn); + fclaw_clawpatch_soln_data(g->glob, patch, &q, &meqn); FCLAW_ASSERT(mfields==meqn); @@ -78,9 +78,9 @@ void update_q(fclaw2d_domain_t *domain, } static -void phasefield_run_update_q(fclaw2d_global_t *glob) +void phasefield_run_update_q(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob, update_q, NULL); + fclaw_global_iterate_patches(glob, update_q, NULL); } @@ -89,15 +89,15 @@ void phasefield_run_update_q(fclaw2d_global_t *glob) Output times are at times [0,dT, 2*dT, 3*dT,...,Tfinal], where dT = tfinal/nout -------------------------------------------------------------------------------- */ static -void outstyle_1(fclaw2d_global_t *glob) +void outstyle_1(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double final_time = fclaw_opt->tfinal; int nout = fclaw_opt->nout; @@ -107,7 +107,7 @@ void outstyle_1(fclaw2d_global_t *glob) int init_flag = 1; /* Store anything that needs to be stored */ - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; double t0 = 0; @@ -155,7 +155,7 @@ void outstyle_1(fclaw2d_global_t *glob) phasefield_set_lambda(lambda); /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ phasefield_run_update_q(glob); @@ -174,21 +174,21 @@ void outstyle_1(fclaw2d_global_t *glob) glob->curr_time = t_curr; - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); if (fclaw_opt->regrid_interval > 0) if (n_inner % fclaw_opt->regrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } /* Output file at every outer loop iteration */ - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); glob->curr_time = t_curr; iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } @@ -201,19 +201,19 @@ static void outstyle_2(fclaw2d_global_t *glob) #endif static -void outstyle_3(fclaw2d_global_t *glob) +void outstyle_3(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; @@ -264,14 +264,14 @@ void outstyle_3(fclaw2d_global_t *glob) /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ phasefield_run_update_q(glob); int time_interp = 0; - fclaw2d_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, - time_interp,FCLAW2D_TIMER_NONE); + fclaw_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, + time_interp,FCLAW_TIMER_NONE); double tc = t_curr + dt_step; @@ -295,37 +295,37 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nregrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } if (fclaw_opt->advance_one_step) - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); if (n % nstep_inner == 0) { iframe++; //fclaw2d_diagnostics_gather(glob,init_flag); - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } static -void outstyle_4(fclaw2d_global_t *glob) +void outstyle_4(fclaw_global_t *glob) { /* Write out an initial time file */ int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; int nstep_outer = fclaw_opt->nout; int nstep_inner = fclaw_opt->nstep; @@ -338,7 +338,7 @@ void outstyle_4(fclaw2d_global_t *glob) while (n < nstep_outer) { /* Get current domain data since it may change during regrid */ - fclaw2d_advance_all_levels(glob, t_curr, dt_minlevel); + fclaw_advance_all_levels(glob, t_curr, dt_minlevel); int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ? fclaw_opt->maxlevel : fclaw_opt->minlevel; @@ -358,7 +358,7 @@ void outstyle_4(fclaw2d_global_t *glob) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } else @@ -368,9 +368,9 @@ void outstyle_4(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -380,10 +380,10 @@ void outstyle_4(fclaw2d_global_t *glob) Public interface ---------------------------------------------------------------- */ -void phasefield_run(fclaw2d_global_t *glob) +void phasefield_run(fclaw_global_t *glob) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); switch (fclaw_opt->outstyle) { diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield_user.cpp b/applications/elliptic/heat_phasefield/phasefield/phasefield_user.cpp index 60f4605b5..70234096a 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield_user.cpp +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield_user.cpp @@ -29,10 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "phasefield_operator.h" -#include +#include -#include -#include +#include +#include #include #include @@ -42,14 +42,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include -#include +#include static -void phasefield_problem_setup(fclaw2d_global_t *glob) +void phasefield_problem_setup(fclaw_global_t *glob) { if (glob->mpirank == 0) { @@ -85,49 +85,49 @@ void phasefield_problem_setup(fclaw2d_global_t *glob) fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); PHASEFIELD_SETPROB(); /* This file reads the file just created above */ } static -void phasefield_initialize(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void phasefield_initialize(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); PHASEFIELD_INIT(&meqn, &mbc, &mx, &my, &xlower, &ylower, &dx, &dy,q); } static -void phasefield_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void phasefield_rhs(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int mfields; double *rhs; - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); /* This function supplies an analytic right hand side. */ int method = 1; @@ -225,14 +225,14 @@ void cb_phasefield_output_ascii(fclaw2d_domain_t * domain, #endif -int phasefield_tag4refinement(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +int phasefield_tag4refinement(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, int patchno, int initflag) { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int tag_patch; double refine_threshold; @@ -241,56 +241,56 @@ int phasefield_tag4refinement(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); tag_patch = 0; - clawpatch_vt->fort_tag4refinement(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, - &blockno, q,&refine_threshold, - &initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4refinement(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, + &blockno, q,&refine_threshold, + &initflag,&tag_patch); return tag_patch; } static -int phasefield_tag4coarsening(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, +int phasefield_tag4coarsening(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, int blockno, int patchno, int initflag) { - fclaw2d_patch_t *patch0 = &fine_patches[0]; + fclaw_patch_t *patch0 = &fine_patches[0]; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double coarsen_threshold = fclaw_opt->coarsen_threshold; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch0,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch0,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q[4]; int meqn; for (int igrid = 0; igrid < 4; igrid++) { - fclaw2d_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); + fclaw_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); } - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); int tag_patch = 0; - clawpatch_vt->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, - &blockno, q[0],q[1],q[2],q[3], - &coarsen_threshold,&initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, + &blockno, q[0],q[1],q[2],q[3], + &coarsen_threshold,&initflag,&tag_patch); return tag_patch == 1; } static -void phasefield_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void phasefield_bc2(fclaw_global_t *glob, + fclaw_patch_t *patch, int block_idx, int patch_idx, double t, @@ -302,19 +302,19 @@ void phasefield_bc2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); PHASEFIELD_FORT_BC2(&meqn,&mbc,&mx,&my,&xlower,&ylower, &dx,&dy,q,&t,&dt,intersects_bc); } -void phasefield_link_solvers(fclaw2d_global_t *glob) +void phasefield_link_solvers(fclaw_global_t *glob) { #if 0 /* These are listed here for reference */ @@ -324,11 +324,11 @@ void phasefield_link_solvers(fclaw2d_global_t *glob) fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); #endif /* ForestClaw vtable */ - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = &phasefield_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = &phasefield_problem_setup; /* Patch : RHS function */ - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); patch_vt->physical_bc = phasefield_bc2; /* Doesn't do anything */ patch_vt->rhs = phasefield_rhs; /* Overwrites default */ patch_vt->initialize = phasefield_initialize; /* Get an initial refinement */ @@ -344,9 +344,9 @@ void phasefield_link_solvers(fclaw2d_global_t *glob) patch_vt->tag4refinement = phasefield_tag4refinement; patch_vt->tag4coarsening = phasefield_tag4coarsening; - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - clawpatch_vt->fort_tag4refinement = &PHASEFIELD_TAG4REFINEMENT; - clawpatch_vt->fort_tag4coarsening = &PHASEFIELD_TAG4COARSENING; + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + clawpatch_vt->d2->fort_tag4refinement = &PHASEFIELD_TAG4REFINEMENT; + clawpatch_vt->d2->fort_tag4coarsening = &PHASEFIELD_TAG4COARSENING; } diff --git a/applications/elliptic/heat_phasefield/phasefield/phasefield_user.h b/applications/elliptic/heat_phasefield/phasefield/phasefield_user.h index 95b5d6f20..0e2075ce0 100644 --- a/applications/elliptic/heat_phasefield/phasefield/phasefield_user.h +++ b/applications/elliptic/heat_phasefield/phasefield/phasefield_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef PHASEFIELD_USER_H #define PHASEFIELD_USER_H -#include +#include #include @@ -44,13 +44,13 @@ extern "C" /* --------------------------- Problem dependent functions -----------------------------*/ -void phasefield_link_solvers(fclaw2d_global_t *glob); +void phasefield_link_solvers(fclaw_global_t *glob); -void phasefield_run(fclaw2d_global_t *glob); +void phasefield_run(fclaw_global_t *glob); -void phasefield_create_domain(fclaw2d_global_t* glob); +void phasefield_create_domain(fclaw_global_t* glob); -void phasefield_run_program(fclaw2d_global_t* glob); +void phasefield_run_program(fclaw_global_t* glob); /* --------------------------- Fortran functions ---------------------------------------*/ diff --git a/applications/elliptic/phasefield/phasefield.cpp b/applications/elliptic/phasefield/phasefield.cpp index 9cf8855bd..af7423053 100644 --- a/applications/elliptic/phasefield/phasefield.cpp +++ b/applications/elliptic/phasefield/phasefield.cpp @@ -25,24 +25,24 @@ #include "phasefield_user.h" -#include +#include -#include -#include +#include +#include -#include +#include -#include -#include +#include +#include #include #include static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { /* Mapped, multi-block domain */ - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -50,34 +50,28 @@ void create_domain(fclaw2d_global_t* glob) int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; - fclaw2d_domain_t *domain = fclaw2d_domain_new_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); + fclaw_domain_t *domain = fclaw_domain_new_2d_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); /* Map unit square to disk using mapc2m_disk.f */ - fclaw2d_map_context_t *brick = fclaw2d_map_new_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap_brick(brick); + fclaw_map_context_t *brick = fclaw_map_new_2d_brick(domain, mi, mj, a, b); + fclaw_map_context_t *cont = fclaw_map_new_nomap_brick(brick); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { // const phasefield_options_t *user_opt; // user_opt = phasefield_get_options(glob); - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Test thunderegg solver */ fc2d_thunderegg_solver_initialize(glob); @@ -90,14 +84,14 @@ void run_program(fclaw2d_global_t* glob) --------------------------------------------------------------- */ /* Set up grid and RHS */ - fclaw2d_initialize(glob); + fclaw_initialize(glob); phasefield_run(glob); /* --------------------------------------------------------------- Finalize --------------------------------------------------------------- */ - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -108,13 +102,13 @@ main (int argc, char **argv) /* Options */ fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_thunderegg_options_t *mg_opt; phasefield_options_t *user_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); mg_opt = fc2d_thunderegg_options_register(app, "thunderegg", "fclaw_options.ini"); user_opt = phasefield_options_register(app, "fclaw_options.ini"); @@ -131,11 +125,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_thunderegg_options_store (glob, mg_opt); phasefield_options_store (glob, user_opt); @@ -143,7 +137,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/elliptic/phasefield/phasefield_operator.cpp b/applications/elliptic/phasefield/phasefield_operator.cpp index 1fb904ea3..b46a0d16d 100644 --- a/applications/elliptic/phasefield/phasefield_operator.cpp +++ b/applications/elliptic/phasefield/phasefield_operator.cpp @@ -32,19 +32,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + +#include #include #include @@ -72,12 +74,12 @@ Vector<2> restrict_phi_n_vec(const Vector<2>& prev_beta_vec, return restrictor.restrict(prev_beta_vec); } -void phasefield_solve(fclaw2d_global_t *glob) +void phasefield_solve(fclaw_global_t *glob) { // get needed options - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); const fc2d_thunderegg_options_t *mg_opt = fc2d_thunderegg_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); GhostFillingType fill_type = GhostFillingType::Faces; #if 0 @@ -91,15 +93,15 @@ void phasefield_solve(fclaw2d_global_t *glob) array ns = {clawpatch_opt->mx, clawpatch_opt->my}; // get p4est structure - fclaw2d_domain_t *domain = glob->domain; - p4est_wrap_t *wrap = (p4est_wrap_t *)domain->pp; + fclaw_domain_t *domain = glob->domain; + p4est_wrap_t *wrap = (p4est_wrap_t *)domain->d2->pp; // create map function P4estDomainGenerator::BlockMapFunc bmf = [&](int block_no, double unit_x, double unit_y, double &x, double &y) { double x1,y1,z1; - FCLAW2D_MAP_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); + FCLAW_MAP_2D_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); x = fclaw_opt->ax + (fclaw_opt->bx - fclaw_opt->ax) * x1; y = fclaw_opt->ay + (fclaw_opt->by - fclaw_opt->ay) * y1; }; diff --git a/applications/elliptic/phasefield/phasefield_operator.h b/applications/elliptic/phasefield/phasefield_operator.h index ea9ed815a..593ae8538 100644 --- a/applications/elliptic/phasefield/phasefield_operator.h +++ b/applications/elliptic/phasefield/phasefield_operator.h @@ -38,10 +38,10 @@ extern "C" /* fix syntax highlighting */ #endif -struct fclaw2d_global; +struct fclaw_global; -void phasefield_solve(struct fclaw2d_global *glob); +void phasefield_solve(struct fclaw_global *glob); void phasefield_set_lambda(double lambda); diff --git a/applications/elliptic/phasefield/phasefield_options.c b/applications/elliptic/phasefield/phasefield_options.c index d6c3a673c..a7d10ba9f 100644 --- a/applications/elliptic/phasefield/phasefield_options.c +++ b/applications/elliptic/phasefield/phasefield_options.c @@ -186,12 +186,12 @@ phasefield_options_t* phasefield_options_register (fclaw_app_t * app, return user; } -void phasefield_options_store (fclaw2d_global_t* glob, phasefield_options_t* user) +void phasefield_options_store (fclaw_global_t* glob, phasefield_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const phasefield_options_t* phasefield_get_options(fclaw2d_global_t* glob) +const phasefield_options_t* phasefield_get_options(fclaw_global_t* glob) { - return (phasefield_options_t*) fclaw2d_global_get_options(glob, "user"); + return (phasefield_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/elliptic/phasefield/phasefield_options.h b/applications/elliptic/phasefield/phasefield_options.h index 9b1a4a416..924cc0ee1 100644 --- a/applications/elliptic/phasefield/phasefield_options.h +++ b/applications/elliptic/phasefield/phasefield_options.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef PHASEFIELD_OPTIONS_H #define PHASEFIELD_OPTIONS_H -#include +#include #ifdef __cplusplus extern "C" @@ -72,9 +72,9 @@ typedef struct phasefield_options phasefield_options_t* phasefield_options_register (fclaw_app_t * app, const char *configfile); -void phasefield_options_store(fclaw2d_global_t* glob, phasefield_options_t* user); +void phasefield_options_store(fclaw_global_t* glob, phasefield_options_t* user); -const phasefield_options_t* phasefield_get_options(fclaw2d_global_t* glob); +const phasefield_options_t* phasefield_get_options(fclaw_global_t* glob); #ifdef __cplusplus diff --git a/applications/elliptic/phasefield/phasefield_patch_operator.cpp b/applications/elliptic/phasefield/phasefield_patch_operator.cpp index 51f57c1a2..88722304b 100644 --- a/applications/elliptic/phasefield/phasefield_patch_operator.cpp +++ b/applications/elliptic/phasefield/phasefield_patch_operator.cpp @@ -11,7 +11,7 @@ double phasefield::getLambda(){ return lambda; } -phasefield::phasefield(fclaw2d_global_t *glob, +phasefield::phasefield(fclaw_global_t *glob, const Vector<2>& phi_n, const Domain<2>& domain, const GhostFiller<2>& ghost_filler) diff --git a/applications/elliptic/phasefield/phasefield_patch_operator.h b/applications/elliptic/phasefield/phasefield_patch_operator.h index 19b64889a..006664256 100644 --- a/applications/elliptic/phasefield/phasefield_patch_operator.h +++ b/applications/elliptic/phasefield/phasefield_patch_operator.h @@ -12,7 +12,7 @@ class phasefield : public ThunderEgg::PatchOperator<2> const phasefield_options_t *phase_opt; - phasefield(fclaw2d_global_t *glob, + phasefield(fclaw_global_t *glob, const ThunderEgg::Vector<2>& phi_n_in, const ThunderEgg::Domain<2>& domain, const ThunderEgg::GhostFiller<2>& ghost_filler); diff --git a/applications/elliptic/phasefield/phasefield_run.c b/applications/elliptic/phasefield/phasefield_run.c index e9f07d940..464abc364 100644 --- a/applications/elliptic/phasefield/phasefield_run.c +++ b/applications/elliptic/phasefield/phasefield_run.c @@ -26,20 +26,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "phasefield_user.h" #include "phasefield_operator.h" -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include #include "fclaw_math.h" @@ -52,25 +52,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------- */ static -void update_q(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void update_q(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t *) user; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(g->glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(g->glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double* rhs; int mfields; - fclaw2d_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); + fclaw_clawpatch_rhs_data(g->glob, patch, &rhs, &mfields); double* q; int meqn; - fclaw2d_clawpatch_soln_data(g->glob, patch, &q, &meqn); + fclaw_clawpatch_soln_data(g->glob, patch, &q, &meqn); FCLAW_ASSERT(mfields==meqn); @@ -78,9 +78,9 @@ void update_q(fclaw2d_domain_t *domain, } static -void phasefield_run_update_q(fclaw2d_global_t *glob) +void phasefield_run_update_q(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob, update_q, NULL); + fclaw_global_iterate_patches(glob, update_q, NULL); } @@ -89,15 +89,15 @@ void phasefield_run_update_q(fclaw2d_global_t *glob) Output times are at times [0,dT, 2*dT, 3*dT,...,Tfinal], where dT = tfinal/nout -------------------------------------------------------------------------------- */ static -void outstyle_1(fclaw2d_global_t *glob) +void outstyle_1(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double final_time = fclaw_opt->tfinal; int nout = fclaw_opt->nout; @@ -107,7 +107,7 @@ void outstyle_1(fclaw2d_global_t *glob) int init_flag = 1; /* Store anything that needs to be stored */ - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; double t0 = 0; @@ -155,7 +155,7 @@ void outstyle_1(fclaw2d_global_t *glob) phasefield_set_lambda(lambda); /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ phasefield_run_update_q(glob); @@ -174,21 +174,21 @@ void outstyle_1(fclaw2d_global_t *glob) glob->curr_time = t_curr; - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); if (fclaw_opt->regrid_interval > 0) if (n_inner % fclaw_opt->regrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } /* Output file at every outer loop iteration */ - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); glob->curr_time = t_curr; iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } @@ -201,19 +201,19 @@ static void outstyle_2(fclaw2d_global_t *glob) #endif static -void outstyle_3(fclaw2d_global_t *glob) +void outstyle_3(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; @@ -264,14 +264,14 @@ void outstyle_3(fclaw2d_global_t *glob) /* Solve the elliptic problem; RHS is set here */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Update solution stored in RHS */ phasefield_run_update_q(glob); int time_interp = 0; - fclaw2d_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, - time_interp,FCLAW2D_TIMER_NONE); + fclaw_ghost_update(glob,fclaw_opt->minlevel,fclaw_opt->maxlevel,t_curr, + time_interp,FCLAW_TIMER_NONE); double tc = t_curr + dt_step; @@ -295,37 +295,37 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nregrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } if (fclaw_opt->advance_one_step) - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); if (n % nstep_inner == 0) { iframe++; //fclaw2d_diagnostics_gather(glob,init_flag); - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } static -void outstyle_4(fclaw2d_global_t *glob) +void outstyle_4(fclaw_global_t *glob) { /* Write out an initial time file */ int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; int nstep_outer = fclaw_opt->nout; int nstep_inner = fclaw_opt->nstep; @@ -338,7 +338,7 @@ void outstyle_4(fclaw2d_global_t *glob) while (n < nstep_outer) { /* Get current domain data since it may change during regrid */ - fclaw2d_advance_all_levels(glob, t_curr, dt_minlevel); + fclaw_advance_all_levels(glob, t_curr, dt_minlevel); int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ? fclaw_opt->maxlevel : fclaw_opt->minlevel; @@ -358,7 +358,7 @@ void outstyle_4(fclaw2d_global_t *glob) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } else @@ -368,9 +368,9 @@ void outstyle_4(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -380,10 +380,10 @@ void outstyle_4(fclaw2d_global_t *glob) Public interface ---------------------------------------------------------------- */ -void phasefield_run(fclaw2d_global_t *glob) +void phasefield_run(fclaw_global_t *glob) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); switch (fclaw_opt->outstyle) { diff --git a/applications/elliptic/phasefield/phasefield_user.cpp b/applications/elliptic/phasefield/phasefield_user.cpp index f6e07f03f..d7bda9dea 100644 --- a/applications/elliptic/phasefield/phasefield_user.cpp +++ b/applications/elliptic/phasefield/phasefield_user.cpp @@ -29,10 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "phasefield_operator.h" -#include +#include -#include -#include +#include +#include #include #include @@ -42,14 +42,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include -#include +#include static -void phasefield_problem_setup(fclaw2d_global_t *glob) +void phasefield_problem_setup(fclaw_global_t *glob) { if (glob->mpirank == 0) { @@ -85,49 +85,49 @@ void phasefield_problem_setup(fclaw2d_global_t *glob) fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); PHASEFIELD_SETPROB(); /* This file reads the file just created above */ } static -void phasefield_initialize(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void phasefield_initialize(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); PHASEFIELD_INIT(&meqn, &mbc, &mx, &my, &xlower, &ylower, &dx, &dy,q); } static -void phasefield_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void phasefield_rhs(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int mfields; double *rhs; - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); /* This function supplies an analytic right hand side. */ int method = 1; @@ -225,14 +225,14 @@ void cb_phasefield_output_ascii(fclaw2d_domain_t * domain, #endif -int phasefield_tag4refinement(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +int phasefield_tag4refinement(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, int patchno, int initflag) { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int tag_patch; double refine_threshold; @@ -241,56 +241,56 @@ int phasefield_tag4refinement(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); tag_patch = 0; - clawpatch_vt->fort_tag4refinement(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, - &blockno, q,&refine_threshold, - &initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4refinement(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, + &blockno, q,&refine_threshold, + &initflag,&tag_patch); return tag_patch; } static -int phasefield_tag4coarsening(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, +int phasefield_tag4coarsening(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, int blockno, int patchno, int initflag) { - fclaw2d_patch_t *patch0 = &fine_patches[0]; + fclaw_patch_t *patch0 = &fine_patches[0]; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double coarsen_threshold = fclaw_opt->coarsen_threshold; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch0,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch0,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q[4]; int meqn; for (int igrid = 0; igrid < 4; igrid++) { - fclaw2d_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); + fclaw_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); } - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); int tag_patch = 0; - clawpatch_vt->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, - &blockno, q[0],q[1],q[2],q[3], - &coarsen_threshold,&initflag,&tag_patch); + clawpatch_vt->d2->fort_tag4coarsening(&mx,&my,&mbc,&meqn,&xlower,&ylower,&dx,&dy, + &blockno, q[0],q[1],q[2],q[3], + &coarsen_threshold,&initflag,&tag_patch); return tag_patch == 1; } static -void phasefield_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void phasefield_bc2(fclaw_global_t *glob, + fclaw_patch_t *patch, int block_idx, int patch_idx, double t, @@ -302,19 +302,19 @@ void phasefield_bc2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); PHASEFIELD_FORT_BC2(&meqn,&mbc,&mx,&my,&xlower,&ylower, &dx,&dy,q,&t,&dt,intersects_bc); } -void phasefield_link_solvers(fclaw2d_global_t *glob) +void phasefield_link_solvers(fclaw_global_t *glob) { #if 0 /* These are listed here for reference */ @@ -324,11 +324,11 @@ void phasefield_link_solvers(fclaw2d_global_t *glob) fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); #endif /* ForestClaw vtable */ - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = &phasefield_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = &phasefield_problem_setup; /* Patch : RHS function */ - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); patch_vt->physical_bc = phasefield_bc2; /* Doesn't do anything */ patch_vt->rhs = phasefield_rhs; /* Overwrites default */ patch_vt->initialize = phasefield_initialize; /* Get an initial refinement */ @@ -344,9 +344,9 @@ void phasefield_link_solvers(fclaw2d_global_t *glob) patch_vt->tag4refinement = phasefield_tag4refinement; patch_vt->tag4coarsening = phasefield_tag4coarsening; - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - clawpatch_vt->fort_tag4refinement = &TAG4REFINEMENT; - clawpatch_vt->fort_tag4coarsening = &TAG4COARSENING; + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + clawpatch_vt->d2->fort_tag4refinement = &TAG4REFINEMENT; + clawpatch_vt->d2->fort_tag4coarsening = &TAG4COARSENING; } diff --git a/applications/elliptic/phasefield/phasefield_user.h b/applications/elliptic/phasefield/phasefield_user.h index 22921f15b..7f74b9354 100644 --- a/applications/elliptic/phasefield/phasefield_user.h +++ b/applications/elliptic/phasefield/phasefield_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef PHASEFIELD_USER_H #define PHASEFIELD_USER_H -#include +#include #include @@ -44,9 +44,9 @@ extern "C" /* --------------------------- Problem dependent functions -----------------------------*/ -void phasefield_link_solvers(fclaw2d_global_t *glob); +void phasefield_link_solvers(fclaw_global_t *glob); -void phasefield_run(fclaw2d_global_t *glob); +void phasefield_run(fclaw_global_t *glob); /* --------------------------- Fortran functions ---------------------------------------*/ diff --git a/applications/elliptic/poisson/fortran/tag4refinement.f b/applications/elliptic/poisson/fortran/tag4refinement.f index d7134ca58..120afb475 100644 --- a/applications/elliptic/poisson/fortran/tag4refinement.f +++ b/applications/elliptic/poisson/fortran/tag4refinement.f @@ -11,7 +11,7 @@ subroutine tag4refinement(mx,my,mbc, double precision xp,yp,zp integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used integer i,j, mq double precision qmin, qmax, xc, yc diff --git a/applications/elliptic/poisson/poisson.cpp b/applications/elliptic/poisson/poisson.cpp index 9a8192d6d..738fcfe24 100644 --- a/applications/elliptic/poisson/poisson.cpp +++ b/applications/elliptic/poisson/poisson.cpp @@ -25,25 +25,25 @@ #include "poisson_user.h" -#include +#include -#include -#include +#include +#include -#include +#include -#include -#include +#include +#include #include #include static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { /* Mapped, multi-block domain */ - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; @@ -51,34 +51,28 @@ void create_domain(fclaw2d_global_t* glob) int a = fclaw_opt->periodic_x; int b = fclaw_opt->periodic_y; - fclaw2d_domain_t *domain = fclaw2d_domain_new_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); + fclaw_domain_t *domain = fclaw_domain_new_2d_brick(glob->mpicomm, mi,mj,a,b, fclaw_opt->minlevel); /* Map unit square to disk using mapc2m_disk.f */ - fclaw2d_map_context_t *brick = fclaw2d_map_new_brick(domain, mi, mj, a, b); - fclaw2d_map_context_t *cont = fclaw2d_map_new_nomap_brick(brick); + fclaw_map_context_t *brick = fclaw_map_new_2d_brick(domain, mi, mj, a, b); + fclaw_map_context_t *cont = fclaw_map_new_nomap_brick(brick); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { // const poisson_options_t *user_opt; // user_opt = poisson_get_options(glob); - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); /* Test thunderegg solver */ fc2d_thunderegg_solver_initialize(glob); @@ -91,31 +85,31 @@ void run_program(fclaw2d_global_t* glob) --------------------------------------------------------------- */ /* Set up grid and RHS */ - fclaw2d_initialize(glob); + fclaw_initialize(glob); /* Compute sum of RHS; reset error accumulators */ int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; /* Output rhs */ int Frame = 0; - fclaw2d_output_frame(glob,Frame); + fclaw_output_frame(glob,Frame); /* Solve the elliptic problem */ - fclaw2d_elliptic_solve(glob); + fclaw_elliptic_solve(glob); /* Compute error, compute conservation */ - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); /* Output solution */ Frame = 1; - fclaw2d_output_frame(glob,Frame); + fclaw_output_frame(glob,Frame); /* --------------------------------------------------------------- Finalize --------------------------------------------------------------- */ - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -126,13 +120,13 @@ main (int argc, char **argv) /* Options */ fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_thunderegg_options_t *mg_opt; poisson_options_t *user_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); mg_opt = fc2d_thunderegg_options_register(app, "thunderegg", "fclaw_options.ini"); user_opt = poisson_options_register(app, "fclaw_options.ini"); @@ -149,11 +143,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_thunderegg_options_store (glob, mg_opt); poisson_options_store (glob, user_opt); @@ -161,7 +155,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/elliptic/poisson/poisson_diagnostics.c b/applications/elliptic/poisson/poisson_diagnostics.c index 43f1b4f5e..60ca61146 100644 --- a/applications/elliptic/poisson/poisson_diagnostics.c +++ b/applications/elliptic/poisson/poisson_diagnostics.c @@ -25,20 +25,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "poisson_diagnostics.h" -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -void poisson_diagnostics_initialize(fclaw2d_global_t *glob, +void poisson_diagnostics_initialize(fclaw_global_t *glob, void **acc_patch) { - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); poisson_error_info_t *error_data; @@ -60,11 +60,11 @@ void poisson_diagnostics_initialize(fclaw2d_global_t *glob, } -void poisson_diagnostics_reset(fclaw2d_global_t *glob, +void poisson_diagnostics_reset(fclaw_global_t *glob, void* patch_acc) { poisson_error_info_t *error_data = (poisson_error_info_t*) patch_acc; - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int mfields = clawpatch_opt->rhs_fields; @@ -86,27 +86,27 @@ void poisson_diagnostics_reset(fclaw2d_global_t *glob, } static -void poisson_compute(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void poisson_compute(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void* user) //void *patch_acc) { - fclaw2d_global_iterate_t *s = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *s = (fclaw_global_iterate_t *) user; poisson_error_info_t *error_data = (poisson_error_info_t*) s->user; /* Accumulate area for final computation of error */ int mx, my, mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(s->glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); + fclaw_clawpatch_2d_grid_data(s->glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(s->glob); - double *area = fclaw2d_clawpatch_get_area(s->glob,patch); - FCLAW_ASSERT(clawpatch_vt->fort_compute_patch_area != NULL); - error_data->area += clawpatch_vt->fort_compute_patch_area(&mx,&my,&mbc,&dx,&dy,area); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(s->glob); + double *area = fclaw_clawpatch_get_2d_area(s->glob,patch); + FCLAW_ASSERT(clawpatch_vt->d2->fort_compute_patch_area != NULL); + error_data->area += clawpatch_vt->d2->fort_compute_patch_area(&mx,&my,&mbc,&dx,&dy,area); /* Compute error */ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(s->glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(s->glob); if (fclaw_opt->compute_error) { clawpatch_vt->compute_error(s->glob, patch, blockno, patchno, error_data); @@ -118,34 +118,34 @@ void poisson_compute(fclaw2d_domain_t *domain, } } -void poisson_diagnostics_compute(fclaw2d_global_t* glob, +void poisson_diagnostics_compute(fclaw_global_t* glob, void* patch_acc) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int check = fclaw_opt->compute_error || fclaw_opt->conservation_check; if (!check) return; - fclaw2d_global_iterate_patches(glob, poisson_compute, patch_acc); + fclaw_global_iterate_patches(glob, poisson_compute, patch_acc); } /* Accumulate the errors computed above */ -void poisson_diagnostics_gather(fclaw2d_global_t *glob, +void poisson_diagnostics_gather(fclaw_global_t *glob, void* patch_acc, int init_flag) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; poisson_error_info_t *error_data = (poisson_error_info_t*) patch_acc; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int mfields = clawpatch_opt->rhs_fields; /* clawpatch->meqn */ if (fclaw_opt->compute_error != 0) { - double total_area = fclaw2d_domain_global_sum(domain, error_data->area); + double total_area = fclaw_domain_global_sum(domain, error_data->area); FCLAW_ASSERT(total_area != 0); double *error_norm = FCLAW_ALLOC_ZERO(double,3*mfields); @@ -155,14 +155,14 @@ void poisson_diagnostics_gather(fclaw2d_global_t *glob, int i2 = mfields + m; /* 2-norm */ int i3 = 2*mfields + m; /* inf-norm */ - error_norm[i1] = fclaw2d_domain_global_sum(domain, error_data->local_error[i1]); + error_norm[i1] = fclaw_domain_global_sum(domain, error_data->local_error[i1]); error_norm[i1] /= total_area; - error_norm[i2] = fclaw2d_domain_global_sum(domain, error_data->local_error[i2]); + error_norm[i2] = fclaw_domain_global_sum(domain, error_data->local_error[i2]); error_norm[i2] /= total_area; error_norm[i2] = sqrt(error_norm[i2]); - error_norm[i3] = fclaw2d_domain_global_maximum(domain, + error_norm[i3] = fclaw_domain_global_maximum(domain, error_data->local_error[i3]); error_data->global_error[i1] = error_norm[i1]; @@ -184,12 +184,12 @@ void poisson_diagnostics_gather(fclaw2d_global_t *glob, /* Store mass for future checks */ if (init_flag) { - total_mass[m] = fclaw2d_domain_global_sum(domain, error_data->rhs[m]); + total_mass[m] = fclaw_domain_global_sum(domain, error_data->rhs[m]); error_data->mass0[m] = total_mass[m]; } else { - total_mass[m] = fclaw2d_domain_global_sum(domain, error_data->boundary[m]); + total_mass[m] = fclaw_domain_global_sum(domain, error_data->boundary[m]); } fclaw_global_essentialf("sum[%d] = %24.16e %24.16e\n",m,total_mass[m], fabs(total_mass[m]-error_data->mass0[m])); @@ -199,7 +199,7 @@ void poisson_diagnostics_gather(fclaw2d_global_t *glob, } -void poisson_diagnostics_finalize(fclaw2d_global_t *glob, +void poisson_diagnostics_finalize(fclaw_global_t *glob, void** patch_acc) { poisson_error_info_t *error_data = *((poisson_error_info_t**) patch_acc); diff --git a/applications/elliptic/poisson/poisson_diagnostics.h b/applications/elliptic/poisson/poisson_diagnostics.h index a5b798f16..3375457e4 100644 --- a/applications/elliptic/poisson/poisson_diagnostics.h +++ b/applications/elliptic/poisson/poisson_diagnostics.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef poisson_DIAGNOSTICS_H #define poisson_DIAGNOSTICS_H -#include +#include #include @@ -51,21 +51,21 @@ typedef struct { /* --------------------------- Problem dependent functions -----------------------------*/ -void poisson_diagnostics_initialize(fclaw2d_global_t *glob, void **acc_patch); +void poisson_diagnostics_initialize(fclaw_global_t *glob, void **acc_patch); -void poisson_diagnostics_reset(fclaw2d_global_t *glob, void* patch_acc); +void poisson_diagnostics_reset(fclaw_global_t *glob, void* patch_acc); -void poisson_diagnostics_compute(fclaw2d_global_t* glob, +void poisson_diagnostics_compute(fclaw_global_t* glob, void* patch_acc); -void poisson_diagnostics_gather(fclaw2d_global_t *glob, void* patch_acc, +void poisson_diagnostics_gather(fclaw_global_t *glob, void* patch_acc, int init_flag); -void poisson_diagnostics_finalize(fclaw2d_global_t *glob, void** patch_acc); +void poisson_diagnostics_finalize(fclaw_global_t *glob, void** patch_acc); -void poisson_compute_diagnostics(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void poisson_compute_diagnostics(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void* user); diff --git a/applications/elliptic/poisson/poisson_options.c b/applications/elliptic/poisson/poisson_options.c index e5800b0f9..a9ab2deba 100644 --- a/applications/elliptic/poisson/poisson_options.c +++ b/applications/elliptic/poisson/poisson_options.c @@ -214,12 +214,12 @@ poisson_options_t* poisson_options_register (fclaw_app_t * app, return user; } -void poisson_options_store (fclaw2d_global_t* glob, poisson_options_t* user) +void poisson_options_store (fclaw_global_t* glob, poisson_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -const poisson_options_t* poisson_get_options(fclaw2d_global_t* glob) +const poisson_options_t* poisson_get_options(fclaw_global_t* glob) { - return (poisson_options_t*) fclaw2d_global_get_options(glob, "user"); + return (poisson_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/elliptic/poisson/poisson_options.h b/applications/elliptic/poisson/poisson_options.h index f2c4d1409..42c57a63b 100644 --- a/applications/elliptic/poisson/poisson_options.h +++ b/applications/elliptic/poisson/poisson_options.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef POISSON_OPTIONS_H #define POISSON_OPTIONS_H -#include +#include #ifdef __cplusplus extern "C" @@ -91,9 +91,9 @@ typedef struct poisson_options poisson_options_t* poisson_options_register (fclaw_app_t * app, const char *configfile); -void poisson_options_store(fclaw2d_global_t* glob, poisson_options_t* user); +void poisson_options_store(fclaw_global_t* glob, poisson_options_t* user); -const poisson_options_t* poisson_get_options(fclaw2d_global_t* glob); +const poisson_options_t* poisson_get_options(fclaw_global_t* glob); #ifdef __cplusplus diff --git a/applications/elliptic/poisson/poisson_user.cpp b/applications/elliptic/poisson/poisson_user.cpp index 5f3f6f5bf..a372513bb 100644 --- a/applications/elliptic/poisson/poisson_user.cpp +++ b/applications/elliptic/poisson/poisson_user.cpp @@ -28,7 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. static -void poisson_problem_setup(fclaw2d_global_t *glob) +void poisson_problem_setup(fclaw_global_t *glob) { if (glob->mpirank == 0) { @@ -68,26 +68,26 @@ void poisson_problem_setup(fclaw2d_global_t *glob) fclose(f); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); POISSON_SETPROB(); /* This file reads the file just created above */ } static -void poisson_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void poisson_rhs(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int mfields; double *rhs; - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); /* Compute right hand side */ fc2d_thunderegg_vtable_t* mg_vt = fc2d_thunderegg_vt(glob); @@ -97,8 +97,8 @@ void poisson_rhs(fclaw2d_global_t *glob, mg_vt->fort_rhs(&blockno,&mbc,&mx,&my,&mfields, &xlower,&ylower,&dx,&dy,rhs); } -static void poisson_patch_setup(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +static void poisson_patch_setup(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno) { @@ -106,8 +106,8 @@ static void poisson_patch_setup(struct fclaw2d_global *glob, } static -void poisson_compute_error(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void poisson_compute_error(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, void *user) @@ -115,44 +115,44 @@ void poisson_compute_error(fclaw2d_global_t *glob, poisson_error_info_t* error_data = (poisson_error_info_t*) user; //const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); - if (clawpatch_vt->fort_compute_patch_error != NULL) + if (clawpatch_vt->d2->fort_compute_patch_error != NULL) { int mx, my, mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc,&xlower, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc,&xlower, &ylower,&dx,&dy); - double *area = fclaw2d_clawpatch_get_area(glob,patch); /* Might be null */ + double *area = fclaw_clawpatch_get_2d_area(glob,patch); /* Might be null */ /* Solution is stored in the RHS */ double *rhs, *err, *soln; int mfields; - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); - fclaw2d_clawpatch_elliptic_error_data(glob,patch,&err,&mfields); - fclaw2d_clawpatch_elliptic_soln_data(glob,patch,&soln,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_elliptic_error_data(glob,patch,&err,&mfields); + fclaw_clawpatch_elliptic_soln_data(glob,patch,&soln,&mfields); double t = glob->curr_time; - clawpatch_vt->fort_compute_patch_error(&blockno, &mx,&my,&mbc, - &mfields,&dx,&dy, - &xlower,&ylower, &t, rhs, err, soln); + clawpatch_vt->d2->fort_compute_patch_error(&blockno, &mx,&my,&mbc, + &mfields,&dx,&dy, + &xlower,&ylower, &t, rhs, err, soln); /* Accumulate sums and maximums needed to compute error norms */ - FCLAW_ASSERT(clawpatch_vt->fort_compute_error_norm != NULL); - clawpatch_vt->fort_compute_error_norm(&blockno, &mx, &my, &mbc, &mfields, - &dx,&dy, area, err, - error_data->local_error); + FCLAW_ASSERT(clawpatch_vt->d2->fort_compute_error_norm != NULL); + clawpatch_vt->d2->fort_compute_error_norm(&blockno, &mx, &my, &mbc, &mfields, + &dx,&dy, area, err, + error_data->local_error); } } static -void poisson_conservation_check(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void poisson_conservation_check(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, void *user) @@ -160,28 +160,28 @@ void poisson_conservation_check(fclaw2d_global_t *glob, poisson_error_info_t* error_data = (poisson_error_info_t*) user; int mx, my, mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int mfields; double *rhs; /* Solution is stored in the right hand side */ - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - FCLAW_ASSERT(clawpatch_vt->fort_conservation_check != NULL); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + FCLAW_ASSERT(clawpatch_vt->d2->fort_conservation_check != NULL); /* Need a better way to determine which diagnostic to do */ - double* area = fclaw2d_clawpatch_get_area(glob,patch); - clawpatch_vt->fort_conservation_check(&mx, &my, &mbc, &mfields, &dx,&dy, - area, rhs, error_data->rhs, - error_data->c_kahan); + double* area = fclaw_clawpatch_get_2d_area(glob,patch); + clawpatch_vt->d2->fort_conservation_check(&mx, &my, &mbc, &mfields, &dx,&dy, + area, rhs, error_data->rhs, + error_data->c_kahan); fc2d_thunderegg_options_t *mg_opt = fc2d_thunderegg_get_options(glob); fc2d_thunderegg_vtable_t* mg_vt = fc2d_thunderegg_vt(glob); int intersects_bc[4]; - fclaw2d_physical_get_bc(glob,blockno,patchno,intersects_bc); + fclaw_physical_get_bc(glob,blockno,patchno,intersects_bc); double t = glob->curr_time; int cons_check = 1; @@ -195,10 +195,10 @@ void poisson_conservation_check(fclaw2d_global_t *glob, static -void poisson_time_header_ascii(fclaw2d_global_t* glob, int iframe) +void poisson_time_header_ascii(fclaw_global_t* glob, int iframe) { - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); char matname1[20]; sprintf(matname1,"fort.q%04d",iframe); @@ -234,39 +234,39 @@ void poisson_time_header_ascii(fclaw2d_global_t* glob, int iframe) static -void cb_poisson_output_ascii(fclaw2d_domain_t * domain, - fclaw2d_patch_t * patch, +void cb_poisson_output_ascii(fclaw_domain_t * domain, + fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) s->glob; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) s->glob; int iframe = *((int *) s->user); /* Get info not readily available to user */ int global_num, local_num; int level; - fclaw2d_patch_get_info(glob->domain,patch, + fclaw_patch_get_info(glob->domain,patch, blockno,patchno, &global_num,&local_num, &level); int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *rhs; int mfields; - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); double *err; - fclaw2d_clawpatch_elliptic_error_data(glob,patch,&err,&mfields); + fclaw_clawpatch_elliptic_error_data(glob,patch,&err,&mfields); double *soln; - fclaw2d_clawpatch_elliptic_soln_data(glob,patch,&soln,&mfields); + fclaw_clawpatch_elliptic_soln_data(glob,patch,&soln,&mfields); char fname[BUFSIZ]; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); snprintf (fname, BUFSIZ, "%s.q%04d", fclaw_opt->prefix, iframe); /* The fort routine is defined by a clawpack solver and handles @@ -282,14 +282,14 @@ void cb_poisson_output_ascii(fclaw2d_domain_t * domain, } -int poisson_tag4refinement(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +int poisson_tag4refinement(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, int patchno, int initflag) { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int tag_patch; double refine_threshold; @@ -298,66 +298,66 @@ int poisson_tag4refinement(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *rhs; int mfields; - fclaw2d_clawpatch_rhs_data(glob,this_patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,this_patch,&rhs,&mfields); tag_patch = 0; - fclaw2d_global_set_global(glob); - clawpatch_vt->fort_tag4refinement(&mx,&my,&mbc,&mfields,&xlower,&ylower,&dx,&dy, - &blockno, rhs,&refine_threshold, - &initflag,&tag_patch); - fclaw2d_global_unset_global(); + fclaw_global_set_static(glob); + clawpatch_vt->d2->fort_tag4refinement(&mx,&my,&mbc,&mfields,&xlower,&ylower,&dx,&dy, + &blockno, rhs,&refine_threshold, + &initflag,&tag_patch); + fclaw_global_clear_static(); return tag_patch; } static -int poisson_tag4coarsening(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, +int poisson_tag4coarsening(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, int blockno, int patchno, int initflag) { - fclaw2d_patch_t *patch0 = &fine_patches[0]; + fclaw_patch_t *patch0 = &fine_patches[0]; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double coarsen_threshold = fclaw_opt->coarsen_threshold; int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch0,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch0,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *rhs[4]; int mfields; for (int igrid = 0; igrid < 4; igrid++) { - fclaw2d_clawpatch_rhs_data(glob,&fine_patches[igrid],&rhs[igrid],&mfields); + fclaw_clawpatch_rhs_data(glob,&fine_patches[igrid],&rhs[igrid],&mfields); } - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); int tag_patch = 0; - fclaw2d_global_set_global(glob); - clawpatch_vt->fort_tag4coarsening(&mx,&my,&mbc,&mfields,&xlower,&ylower,&dx,&dy, - &blockno, rhs[0],rhs[1],rhs[2],rhs[3], - &coarsen_threshold,&initflag,&tag_patch); - fclaw2d_global_unset_global(); + fclaw_global_set_static(glob); + clawpatch_vt->d2->fort_tag4coarsening(&mx,&my,&mbc,&mfields,&xlower,&ylower,&dx,&dy, + &blockno, rhs[0],rhs[1],rhs[2],rhs[3], + &coarsen_threshold,&initflag,&tag_patch); + fclaw_global_clear_static(); return tag_patch == 1; } -void poisson_link_solvers(fclaw2d_global_t *glob) +void poisson_link_solvers(fclaw_global_t *glob) { /* ForestClaw vtable */ - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->problem_setup = &poisson_problem_setup; + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + fc_vt->problem_setup = &poisson_problem_setup; /* Patch : RHS function */ - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); patch_vt->rhs = poisson_rhs; /* Overwrites default */ patch_vt->initialize = poisson_rhs; /* Get an initial refinement */ @@ -371,9 +371,9 @@ void poisson_link_solvers(fclaw2d_global_t *glob) mg_vt->fort_eval_bc = &POISSON_FORT_EVAL_BC; // For non-homogeneous BCs /* Clawpatch : Compute the error */ - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); clawpatch_vt->compute_error = poisson_compute_error; - clawpatch_vt->fort_compute_patch_error = &POISSON_COMPUTE_ERROR; + clawpatch_vt->d2->fort_compute_patch_error = &POISSON_COMPUTE_ERROR; // tagging routines patch_vt->tag4refinement = poisson_tag4refinement; @@ -388,7 +388,7 @@ void poisson_link_solvers(fclaw2d_global_t *glob) // Output routines - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); if (fclaw_opt->compute_error) { clawpatch_vt->time_header_ascii = poisson_time_header_ascii; @@ -407,7 +407,7 @@ void poisson_link_solvers(fclaw2d_global_t *glob) used for the elliptic problem then for the hyperbolic problem */ clawpatch_vt->conservation_check = poisson_conservation_check; - fclaw2d_diagnostics_vtable_t *diag_vt = fclaw2d_diagnostics_vt(glob); + fclaw_diagnostics_vtable_t *diag_vt = fclaw_diagnostics_vt(glob); diag_vt->patch_init_diagnostics = poisson_diagnostics_initialize; diag_vt->patch_reset_diagnostics = poisson_diagnostics_reset; diag_vt->patch_compute_diagnostics = poisson_diagnostics_compute; diff --git a/applications/elliptic/poisson/poisson_user.h b/applications/elliptic/poisson/poisson_user.h index 64ecec75b..4ff872cb3 100644 --- a/applications/elliptic/poisson/poisson_user.h +++ b/applications/elliptic/poisson/poisson_user.h @@ -26,13 +26,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef POISSON_USER_H #define POISSON_USER_H -#include +#include #include "poisson_options.h" #include "poisson_diagnostics.h" -#include -#include +#include +#include #include #include @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include //#include @@ -59,7 +59,7 @@ extern "C" /* --------------------------- Problem dependent functions -----------------------------*/ -void poisson_link_solvers(fclaw2d_global_t *glob); +void poisson_link_solvers(fclaw_global_t *glob); /* --------------------------- Fortran functions ---------------------------------------*/ diff --git a/applications/geoclaw/bowl_radial/bowl.cpp b/applications/geoclaw/bowl_radial/bowl.cpp index ef9e33f0e..139cd4ecf 100644 --- a/applications/geoclaw/bowl_radial/bowl.cpp +++ b/applications/geoclaw/bowl_radial/bowl.cpp @@ -25,40 +25,36 @@ #include "bowl_user.h" -#include +#include -#include -#include +#include +#include #include #include static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { - fclaw_options_t *fclaw_opts = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opts = fclaw_get_options(glob); /* Size is set by [ax,bx] x [ay, by], set in .ini file */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare(glob->mpicomm, fclaw_opts->minlevel); - fclaw2d_map_context_t* cont = fclaw2d_map_new_nomap(); + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opts->minlevel); + fclaw_map_context_t* cont = fclaw_map_new_nomap(); /* store domain and map in glob */ - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - fclaw2d_domain_t **domain = &glob->domain; - - fclaw2d_domain_data_new(*domain); - - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_geoclaw_solver_initialize(glob); @@ -69,9 +65,9 @@ void run_program(fclaw2d_global_t* glob) --------------------------------------------------------------- */ fc2d_geoclaw_module_setup(glob); - fclaw2d_initialize(glob); + fclaw_initialize(glob); fc2d_geoclaw_run(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -82,11 +78,11 @@ main (int argc, char **argv) /* Options */ fclaw_options_t *gparms; - fclaw2d_clawpatch_options_t *clawpatchopt; + fclaw_clawpatch_options_t *clawpatchopt; fc2d_geoclaw_options_t *geoclawopt; gparms = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatchopt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatchopt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); geoclawopt = fc2d_geoclaw_options_register(app, "geoclaw", "fclaw_options.ini"); /* Read configuration file(s) and command line, and process options */ @@ -99,10 +95,10 @@ main (int argc, char **argv) int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); - fclaw2d_options_store (glob, gparms); - fclaw2d_clawpatch_options_store (glob, clawpatchopt); + fclaw_options_store (glob, gparms); + fclaw_clawpatch_options_store (glob, clawpatchopt); fc2d_geoclaw_options_store (glob, geoclawopt); create_domain(glob); @@ -110,7 +106,7 @@ main (int argc, char **argv) /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/geoclaw/bowl_radial/bowl_user.cpp b/applications/geoclaw/bowl_radial/bowl_user.cpp index 3a23adf20..ec7160a69 100644 --- a/applications/geoclaw/bowl_radial/bowl_user.cpp +++ b/applications/geoclaw/bowl_radial/bowl_user.cpp @@ -25,13 +25,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "bowl_user.h" -#include +#include -#include +#include #include -void bowl_link_solvers(fclaw2d_global_t *glob) +void bowl_link_solvers(fclaw_global_t *glob) { /* User customizations ... */ diff --git a/applications/geoclaw/bowl_radial/bowl_user.h b/applications/geoclaw/bowl_radial/bowl_user.h index 48f156eaf..ea460d742 100644 --- a/applications/geoclaw/bowl_radial/bowl_user.h +++ b/applications/geoclaw/bowl_radial/bowl_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef BOWL_USER_H #define BOWL_USER_H -#include +#include #ifdef __cplusplus extern "C" @@ -36,7 +36,7 @@ extern "C" #endif #endif -void bowl_link_solvers(fclaw2d_global_t *glob); +void bowl_link_solvers(fclaw_global_t *glob); #ifdef __cplusplus #if 0 diff --git a/applications/geoclaw/bowl_radial_slosh/bowl.cpp b/applications/geoclaw/bowl_radial_slosh/bowl.cpp index b18ccbb53..96d5f36c7 100644 --- a/applications/geoclaw/bowl_radial_slosh/bowl.cpp +++ b/applications/geoclaw/bowl_radial_slosh/bowl.cpp @@ -26,10 +26,10 @@ #include "radial/radial_user.h" #include "slosh/slosh_user.h" -#include +#include -#include -#include +#include +#include #include #include @@ -44,22 +44,22 @@ main (int argc, char **argv) radial_user_options_t *radial_user_opt; fclaw_options_t *radial_gparms; - fclaw2d_clawpatch_options_t *radial_clawpatchopt; + fclaw_clawpatch_options_t *radial_clawpatchopt; fc2d_geoclaw_options_t *radial_geoclawopt; slosh_user_options_t *slosh_user_opt; fclaw_options_t *slosh_fclaw_opt; - fclaw2d_clawpatch_options_t *sloshclawpatch_opt; + fclaw_clawpatch_options_t *sloshclawpatch_opt; fc2d_geoclaw_options_t *slosh_geo_opt; radial_gparms = fclaw_options_register(app, "radial", "fclaw_options.ini"); - radial_clawpatchopt = fclaw2d_clawpatch_options_register(app, "radial-clawpatch", "fclaw_options.ini"); + radial_clawpatchopt = fclaw_clawpatch_2d_options_register(app, "radial-clawpatch", "fclaw_options.ini"); radial_geoclawopt = fc2d_geoclaw_options_register(app, "radial-geoclaw", "fclaw_options.ini"); radial_user_opt = radial_options_register(app, "radial-user", "fclaw_options.ini"); slosh_fclaw_opt = fclaw_options_register(app, "slosh", "fclaw_options.ini"); - sloshclawpatch_opt = fclaw2d_clawpatch_options_register(app, "slosh-clawpatch", "fclaw_options.ini"); + sloshclawpatch_opt = fclaw_clawpatch_2d_options_register(app, "slosh-clawpatch", "fclaw_options.ini"); slosh_geo_opt = fc2d_geoclaw_options_register(app, "slosh-geoclaw", "fclaw_options.ini"); slosh_user_opt = slosh_options_register(app, "slosh-user", "fclaw_options.ini"); @@ -73,10 +73,10 @@ main (int argc, char **argv) int size, rank; sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); - fclaw2d_global_t *radial_glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *radial_glob = fclaw_global_new_comm(mpicomm, size, rank); - fclaw2d_options_store (radial_glob, radial_gparms); - fclaw2d_clawpatch_options_store (radial_glob, radial_clawpatchopt); + fclaw_options_store (radial_glob, radial_gparms); + fclaw_clawpatch_options_store (radial_glob, radial_clawpatchopt); fc2d_geoclaw_options_store (radial_glob, radial_geoclawopt); radial_options_store (radial_glob, radial_user_opt); @@ -85,15 +85,15 @@ main (int argc, char **argv) /* Run the program */ radial_run_program(radial_glob); - fclaw2d_global_destroy(radial_glob); + fclaw_global_destroy(radial_glob); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *slosh_glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *slosh_glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (slosh_glob, slosh_fclaw_opt); - fclaw2d_clawpatch_options_store (slosh_glob, sloshclawpatch_opt); + fclaw_options_store (slosh_glob, slosh_fclaw_opt); + fclaw_clawpatch_options_store (slosh_glob, sloshclawpatch_opt); fc2d_geoclaw_options_store (slosh_glob, slosh_geo_opt); slosh_options_store (slosh_glob, slosh_user_opt); @@ -101,7 +101,7 @@ main (int argc, char **argv) slosh_run_program(slosh_glob); - fclaw2d_global_destroy(slosh_glob); + fclaw_global_destroy(slosh_glob); } diff --git a/applications/geoclaw/bowl_radial_slosh/radial/radial_options.c b/applications/geoclaw/bowl_radial_slosh/radial/radial_options.c index 99a999107..8e7dee558 100644 --- a/applications/geoclaw/bowl_radial_slosh/radial/radial_options.c +++ b/applications/geoclaw/bowl_radial_slosh/radial/radial_options.c @@ -93,13 +93,13 @@ radial_user_options_t* radial_options_register (fclaw_app_t * app, return user; } -void radial_options_store (fclaw2d_global_t* glob, radial_user_options_t* user) +void radial_options_store (fclaw_global_t* glob, radial_user_options_t* user) { - fclaw2d_global_options_store(glob, "radial-user", user); + fclaw_global_options_store(glob, "radial-user", user); } -radial_user_options_t* radial_get_options(fclaw2d_global_t* glob) +radial_user_options_t* radial_get_options(fclaw_global_t* glob) { - return (radial_user_options_t*) fclaw2d_global_get_options(glob, "radial-user"); + return (radial_user_options_t*) fclaw_global_get_options(glob, "radial-user"); } diff --git a/applications/geoclaw/bowl_radial_slosh/radial/radial_user.cpp b/applications/geoclaw/bowl_radial_slosh/radial/radial_user.cpp index 4ff63ed7d..c4386e322 100644 --- a/applications/geoclaw/bowl_radial_slosh/radial/radial_user.cpp +++ b/applications/geoclaw/bowl_radial_slosh/radial/radial_user.cpp @@ -24,48 +24,44 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "radial_user.h" -#include "fclaw2d_global.h" +#include -#include +#include -#include +#include #include #include -void radial_link_solvers(fclaw2d_global_t *glob) +void radial_link_solvers(fclaw_global_t *glob) { /* User customizations ... */ } -void radial_create_domain(fclaw2d_global_t* glob) +void radial_create_domain(fclaw_global_t* glob) { - fclaw_options_t *fclaw_opts = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opts = fclaw_get_options(glob); /* Size is set by [ax,bx] x [ay, by], set in .ini file */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare(glob->mpicomm, fclaw_opts->minlevel); - fclaw2d_map_context_t* cont = fclaw2d_map_new_nomap(); + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opts->minlevel); + fclaw_map_context_t* cont = fclaw_map_new_nomap(); /* store domain and map in glob */ - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } -void radial_run_program(fclaw2d_global_t* glob) +void radial_run_program(fclaw_global_t* glob) { - fclaw2d_set_global_context(glob); + fclaw_set_global_context(glob); - fclaw2d_domain_t **domain = &glob->domain; - - fclaw2d_domain_data_new(*domain); - - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_geoclaw_solver_initialize(glob); @@ -80,9 +76,9 @@ void radial_run_program(fclaw2d_global_t* glob) fc2d_geoclaw_module_setup(glob); - fclaw2d_initialize(glob); + fclaw_initialize(glob); fc2d_geoclaw_run(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } \ No newline at end of file diff --git a/applications/geoclaw/bowl_radial_slosh/radial/radial_user.h b/applications/geoclaw/bowl_radial_slosh/radial/radial_user.h index fb38fba4e..c32a4b41e 100644 --- a/applications/geoclaw/bowl_radial_slosh/radial/radial_user.h +++ b/applications/geoclaw/bowl_radial_slosh/radial/radial_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef BOWL_USER_H #define BOWL_USER_H -#include +#include #ifdef __cplusplus extern "C" @@ -41,19 +41,19 @@ typedef struct radial_user_options int is_registered; } radial_user_options_t; -void radial_link_solvers(fclaw2d_global_t *glob); +void radial_link_solvers(fclaw_global_t *glob); radial_user_options_t* radial_options_register (fclaw_app_t * app, const char *section, const char *configfile); -void radial_options_store (fclaw2d_global_t* glob, radial_user_options_t* user); +void radial_options_store (fclaw_global_t* glob, radial_user_options_t* user); -radial_user_options_t* radial_get_options(fclaw2d_global_t* glob); +radial_user_options_t* radial_get_options(fclaw_global_t* glob); -void radial_create_domain(fclaw2d_global_t* glob); +void radial_create_domain(fclaw_global_t* glob); -void radial_run_program(fclaw2d_global_t* glob); +void radial_run_program(fclaw_global_t* glob); #ifdef __cplusplus #if 0 diff --git a/applications/geoclaw/bowl_radial_slosh/slosh/slosh_options.c b/applications/geoclaw/bowl_radial_slosh/slosh/slosh_options.c index 8df89da48..5d0ec0218 100644 --- a/applications/geoclaw/bowl_radial_slosh/slosh/slosh_options.c +++ b/applications/geoclaw/bowl_radial_slosh/slosh/slosh_options.c @@ -93,13 +93,13 @@ slosh_user_options_t* slosh_options_register (fclaw_app_t * app, return user; } -void slosh_options_store (fclaw2d_global_t* glob, slosh_user_options_t* user) +void slosh_options_store (fclaw_global_t* glob, slosh_user_options_t* user) { - fclaw2d_global_options_store(glob, "slosh-user", user); + fclaw_global_options_store(glob, "slosh-user", user); } -slosh_user_options_t* slosh_get_options(fclaw2d_global_t* glob) +slosh_user_options_t* slosh_get_options(fclaw_global_t* glob) { - return (slosh_user_options_t*) fclaw2d_global_get_options(glob, "slosh-user"); + return (slosh_user_options_t*) fclaw_global_get_options(glob, "slosh-user"); } diff --git a/applications/geoclaw/bowl_radial_slosh/slosh/slosh_user.cpp b/applications/geoclaw/bowl_radial_slosh/slosh/slosh_user.cpp index 3a1cbd00f..aeea795dd 100644 --- a/applications/geoclaw/bowl_radial_slosh/slosh/slosh_user.cpp +++ b/applications/geoclaw/bowl_radial_slosh/slosh/slosh_user.cpp @@ -24,43 +24,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "slosh_user.h" -#include "fclaw2d_global.h" +#include #include -void slosh_link_solvers(fclaw2d_global_t *glob) +void slosh_link_solvers(fclaw_global_t *glob) { fc2d_geoclaw_vtable_t* geoclaw_vt = fc2d_geoclaw_vt(glob); geoclaw_vt->qinit = &FC2D_GEOCLAW_QINIT; } -void slosh_create_domain(fclaw2d_global_t* glob) +void slosh_create_domain(fclaw_global_t* glob) { - fclaw_options_t *fclaw_opts = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opts = fclaw_get_options(glob); /* Size is set by [ax,bx] x [ay, by], set in .ini file */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare(glob->mpicomm, fclaw_opts->minlevel); - fclaw2d_map_context_t* cont = fclaw2d_map_new_nomap(); + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opts->minlevel); + fclaw_map_context_t* cont = fclaw_map_new_nomap(); /* store domain and map in glob */ - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } -void slosh_run_program(fclaw2d_global_t* glob) +void slosh_run_program(fclaw_global_t* glob) { - fclaw2d_set_global_context(glob); - - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); + fclaw_set_global_context(glob); /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_geoclaw_solver_initialize(glob); @@ -72,10 +67,10 @@ void slosh_run_program(fclaw2d_global_t* glob) fc2d_geoclaw_module_setup(glob); - fclaw2d_initialize(glob); + fclaw_initialize(glob); fc2d_geoclaw_run(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); - fclaw2d_clear_global_context(glob); + fclaw_clear_global_context(glob); } \ No newline at end of file diff --git a/applications/geoclaw/bowl_radial_slosh/slosh/slosh_user.h b/applications/geoclaw/bowl_radial_slosh/slosh/slosh_user.h index dcf3676dc..76a17f3fe 100644 --- a/applications/geoclaw/bowl_radial_slosh/slosh/slosh_user.h +++ b/applications/geoclaw/bowl_radial_slosh/slosh/slosh_user.h @@ -26,10 +26,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef SLOSH_USER_H #define SLOSH_USER_H -#include +#include -#include -#include +#include +#include #include #include @@ -50,19 +50,19 @@ typedef struct slosh_user_options int is_registered; } slosh_user_options_t; -void slosh_link_solvers(fclaw2d_global_t *glob); +void slosh_link_solvers(fclaw_global_t *glob); slosh_user_options_t* slosh_options_register (fclaw_app_t * app, const char *section, const char *configfile); -void slosh_options_store (fclaw2d_global_t* glob, slosh_user_options_t* user); +void slosh_options_store (fclaw_global_t* glob, slosh_user_options_t* user); -slosh_user_options_t* slosh_get_options(fclaw2d_global_t* glob); +slosh_user_options_t* slosh_get_options(fclaw_global_t* glob); -void slosh_create_domain(fclaw2d_global_t* glob); +void slosh_create_domain(fclaw_global_t* glob); -void slosh_run_program(fclaw2d_global_t* glob); +void slosh_run_program(fclaw_global_t* glob); #ifdef __cplusplus } diff --git a/applications/geoclaw/bowl_slosh/slosh.cpp b/applications/geoclaw/bowl_slosh/slosh.cpp index 32fa32810..0c3b443db 100644 --- a/applications/geoclaw/bowl_slosh/slosh.cpp +++ b/applications/geoclaw/bowl_slosh/slosh.cpp @@ -26,34 +26,28 @@ #include "slosh_user.h" static -void create_domain(fclaw2d_global_t* glob) +void create_domain(fclaw_global_t* glob) { - fclaw_options_t *fclaw_opts = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opts = fclaw_get_options(glob); /* Size is set by [ax,bx] x [ay, by], set in .ini file */ - fclaw2d_domain_t *domain = - fclaw2d_domain_new_unitsquare(glob->mpicomm, fclaw_opts->minlevel); - fclaw2d_map_context_t* cont = fclaw2d_map_new_nomap(); + fclaw_domain_t *domain = + fclaw_domain_new_unitsquare(glob->mpicomm, fclaw_opts->minlevel); + fclaw_map_context_t* cont = fclaw_map_new_nomap(); /* store domain and map in glob */ - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, cont); + fclaw_global_store_domain(glob, domain); + fclaw_map_store(glob, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - - /* --------------------------------------------------------------- - Set domain data. - --------------------------------------------------------------- */ - fclaw2d_domain_data_new(glob->domain); - /* Initialize virtual table for ForestClaw */ - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_geoclaw_solver_initialize(glob); @@ -65,10 +59,10 @@ void run_program(fclaw2d_global_t* glob) fc2d_geoclaw_module_setup(glob); - fclaw2d_initialize(glob); + fclaw_initialize(glob); fc2d_geoclaw_run(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -80,12 +74,12 @@ main (int argc, char **argv) /* Options */ user_options_t *user_opt; fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; fc2d_geoclaw_options_t *geo_opt; /* Create new options packages */ fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatch_opt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatch_opt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); geo_opt = fc2d_geoclaw_options_register(app, "geoclaw", "fclaw_options.ini"); user_opt = slosh_options_register(app, "fclaw_options.ini"); @@ -101,11 +95,11 @@ main (int argc, char **argv) sc_MPI_Comm mpicomm = fclaw_app_get_mpi_size_rank (app, &size, &rank); /* Create global structure which stores the domain, timers, etc */ - fclaw2d_global_t *glob = fclaw2d_global_new_comm(mpicomm, size, rank); + fclaw_global_t *glob = fclaw_global_new_comm(mpicomm, size, rank); /* Store option packages in glob */ - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatch_opt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatch_opt); fc2d_geoclaw_options_store (glob, geo_opt); slosh_options_store (glob, user_opt); @@ -113,7 +107,7 @@ main (int argc, char **argv) run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/geoclaw/bowl_slosh/slosh_options.c b/applications/geoclaw/bowl_slosh/slosh_options.c index c1f65da05..cd71db81a 100644 --- a/applications/geoclaw/bowl_slosh/slosh_options.c +++ b/applications/geoclaw/bowl_slosh/slosh_options.c @@ -95,13 +95,13 @@ user_options_t* slosh_options_register (fclaw_app_t * app, return user; } -void slosh_options_store (fclaw2d_global_t* glob, user_options_t* user) +void slosh_options_store (fclaw_global_t* glob, user_options_t* user) { - fclaw2d_global_options_store(glob, "user", user); + fclaw_global_options_store(glob, "user", user); } -user_options_t* slosh_get_options(fclaw2d_global_t* glob) +user_options_t* slosh_get_options(fclaw_global_t* glob) { - return (user_options_t*) fclaw2d_global_get_options(glob, "user"); + return (user_options_t*) fclaw_global_get_options(glob, "user"); } diff --git a/applications/geoclaw/bowl_slosh/slosh_user.cpp b/applications/geoclaw/bowl_slosh/slosh_user.cpp index 03fdd3b1b..0e620dd2c 100644 --- a/applications/geoclaw/bowl_slosh/slosh_user.cpp +++ b/applications/geoclaw/bowl_slosh/slosh_user.cpp @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "slosh_user.h" -void slosh_link_solvers(fclaw2d_global_t *glob) +void slosh_link_solvers(fclaw_global_t *glob) { fc2d_geoclaw_vtable_t* geoclaw_vt = fc2d_geoclaw_vt(glob); geoclaw_vt->qinit = &FC2D_GEOCLAW_QINIT; diff --git a/applications/geoclaw/bowl_slosh/slosh_user.h b/applications/geoclaw/bowl_slosh/slosh_user.h index 90d74b4b0..2494e0a1e 100644 --- a/applications/geoclaw/bowl_slosh/slosh_user.h +++ b/applications/geoclaw/bowl_slosh/slosh_user.h @@ -26,10 +26,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef SLOSH_USER_H #define SLOSH_USER_H -#include +#include -#include -#include +#include +#include #include #include @@ -52,14 +52,14 @@ typedef struct user_options } user_options_t; -void slosh_link_solvers(fclaw2d_global_t *glob); +void slosh_link_solvers(fclaw_global_t *glob); user_options_t* slosh_options_register (fclaw_app_t * app, const char *configfile); -void slosh_options_store (fclaw2d_global_t* glob, user_options_t* user); +void slosh_options_store (fclaw_global_t* glob, user_options_t* user); -user_options_t* slosh_get_options(fclaw2d_global_t* glob); +user_options_t* slosh_get_options(fclaw_global_t* glob); diff --git a/applications/geoclaw/chile2010/chile2010.cpp b/applications/geoclaw/chile2010/chile2010.cpp index e19344dbc..48bf7f9d1 100644 --- a/applications/geoclaw/chile2010/chile2010.cpp +++ b/applications/geoclaw/chile2010/chile2010.cpp @@ -25,43 +25,43 @@ #include "chile2010_user.h" -#include +#include -#include -#include +#include +#include #include #include static -fclaw2d_domain_t* create_domain(sc_MPI_Comm mpicomm, +fclaw_domain_t* create_domain(sc_MPI_Comm mpicomm, fclaw_options_t* fclaw_opt) { /* Mapped, multi-block domain */ p4est_connectivity_t *conn = NULL; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *cont = NULL; + fclaw_domain_t *domain; + fclaw_map_context_t *cont = NULL; /* Size is set by [ax,bx] x [ay, by], set in .ini file */ conn = p4est_connectivity_new_unitsquare(); - cont = fclaw2d_map_new_nomap(); + cont = fclaw_map_new_nomap(); domain = fclaw2d_domain_new_conn_map (mpicomm, fclaw_opt->minlevel, conn, cont); - fclaw2d_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); - fclaw2d_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); + fclaw_domain_list_levels(domain, FCLAW_VERBOSITY_ESSENTIAL); + fclaw_domain_list_neighbors(domain, FCLAW_VERBOSITY_DEBUG); return domain; } static -void run_program(fclaw2d_global_t* glob) +void run_program(fclaw_global_t* glob) { - fclaw2d_domain_t **domain = &glob->domain; + fclaw_domain_t **domain = &glob->domain; - fclaw2d_domain_data_new(*domain); + you_can_safely_remove_this_call(*domain); - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_geoclaw_solver_initialize(glob); @@ -70,10 +70,10 @@ void run_program(fclaw2d_global_t* glob) --------------------------------------------------------------- */ fc2d_geoclaw_module_setup(glob); - fclaw2d_initialize(glob); + fclaw_initialize(glob); fc2d_geoclaw_run(glob); - fclaw2d_finalize(glob); + fclaw_finalize(glob); } int @@ -85,18 +85,18 @@ main (int argc, char **argv) /* Options */ fclaw_options_t *fclaw_opt; - fclaw2d_clawpatch_options_t *clawpatchopt; + fclaw_clawpatch_options_t *clawpatchopt; fc2d_geoclaw_options_t *geoclawopt; sc_MPI_Comm mpicomm; - fclaw2d_domain_t* domain; - fclaw2d_global_t* glob; + fclaw_domain_t* domain; + fclaw_global_t* glob; /* Initialize application */ app = fclaw_app_new (&argc, &argv, NULL); fclaw_opt = fclaw_options_register(app, NULL, "fclaw_options.ini"); - clawpatchopt = fclaw2d_clawpatch_options_register(app, "clawpatch", "fclaw_options.ini"); + clawpatchopt = fclaw_clawpatch_2d_options_register(app, "clawpatch", "fclaw_options.ini"); geoclawopt = fc2d_geoclaw_options_register(app, "geoclaw", "fclaw_options.ini"); /* Read configuration file(s) and command line, and process options */ @@ -107,17 +107,17 @@ main (int argc, char **argv) mpicomm = fclaw_app_get_mpi_size_rank (app, NULL, NULL); domain = create_domain(mpicomm, fclaw_opt); - glob = fclaw2d_global_new(); - fclaw2d_global_store_domain(glob, domain); + glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); - fclaw2d_options_store (glob, fclaw_opt); - fclaw2d_clawpatch_options_store (glob, clawpatchopt); + fclaw_options_store (glob, fclaw_opt); + fclaw_clawpatch_options_store (glob, clawpatchopt); fc2d_geoclaw_options_store (glob, geoclawopt); /* Run the program */ run_program(glob); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } fclaw_app_destroy (app); diff --git a/applications/geoclaw/chile2010/chile2010_user.h b/applications/geoclaw/chile2010/chile2010_user.h index 3865df4a4..9cec7880c 100644 --- a/applications/geoclaw/chile2010/chile2010_user.h +++ b/applications/geoclaw/chile2010/chile2010_user.h @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef CHILE2010_USER_H #define CHILE2010_USER_H -#include +#include #ifdef __cplusplus extern "C" diff --git a/cmake/GitSubmodule.cmake b/cmake/GitSubmodule.cmake index 9e98b0c29..7791a9a83 100644 --- a/cmake/GitSubmodule.cmake +++ b/cmake/GitSubmodule.cmake @@ -1,16 +1,17 @@ +find_package(Git REQUIRED) + + function(git_submodule dir) # get/update Git submodule directory to CMake, assuming the # Git submodule directory is a CMake project. -find_package(Git REQUIRED) - if(NOT EXISTS ${dir}/CMakeLists.txt) execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE _err) if(NOT _err EQUAL 0) - message(SEND_ERROR "Could not retrieve Git submodule ${dir}.") + message(FATAL_ERROR "Could not retrieve Git submodule ${dir}.") endif() endif() diff --git a/cmake/GitVersionGen.cmake b/cmake/GitVersionGen.cmake index 41b372fb0..8eed1e8b0 100644 --- a/cmake/GitVersionGen.cmake +++ b/cmake/GitVersionGen.cmake @@ -9,24 +9,24 @@ # This script is intended for use with CMake and shallow copies of repositories. # Check if the .tarball-version file exists -if(EXISTS "${CMAKE_SOURCE_DIR}/.tarball-version") +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../.tarball-version") # If .tarball-version exists, read the version from it and remove the leading character - file(READ "${CMAKE_SOURCE_DIR}/.tarball-version" FORESTCLAW_FULL_VERSION) + file(READ "${CMAKE_CURRENT_LIST_DIR}/../.tarball-version" FORESTCLAW_FULL_VERSION) string(STRIP "${FORESTCLAW_FULL_VERSION}" FORESTCLAW_FULL_VERSION) -else() +elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../.repository-version") # If .tarball-version does not exist, read the version number from the .repository-version file and remove the leading character - file(READ "${CMAKE_SOURCE_DIR}/.repository-version" FORESTCLAW_FULL_VERSION) + file(READ "${CMAKE_CURRENT_LIST_DIR}/../.repository-version" FORESTCLAW_FULL_VERSION) string(STRIP "${FORESTCLAW_FULL_VERSION}" FORESTCLAW_FULL_VERSION) # Get the current commit hash (short version) and check if the current commit is tagged with the version number find_package(Git) if(GIT_FOUND) - execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD - OUTPUT_VARIABLE current_commit + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + OUTPUT_VARIABLE current_commit ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --abbrev-commit -n 1 "refs/tags/${FORESTCLAW_FULL_VERSION}" - OUTPUT_VARIABLE tagged_commit + execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --abbrev-commit -n 1 "refs/tags/${FORESTCLAW_FULL_VERSION}" + OUTPUT_VARIABLE tagged_commit ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -36,7 +36,7 @@ else() endif() # Check if the repository is dirty - execute_process(COMMAND ${GIT_EXECUTABLE} status --porcelain -uno -z + execute_process(COMMAND ${GIT_EXECUTABLE} status --porcelain -uno -z OUTPUT_VARIABLE git_status ERROR_QUIET) @@ -65,4 +65,4 @@ list(GET FORESTCLAW_VERSION_PARTS 2 FORESTCLAW_VERSION_PATCH) set(FORESTCLAW_VERSION "${FORESTCLAW_VERSION_MAJOR}.${FORESTCLAW_VERSION_MINOR}.${FORESTCLAW_VERSION_PATCH}") -message (STATUS "ForestClaw version: ${FORESTCLAW_FULL_VERSION}") +message(STATUS "ForestClaw version: ${FORESTCLAW_FULL_VERSION}") diff --git a/cmake/config.cmake b/cmake/config.cmake index e4e33b7e0..392cef667 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -67,7 +67,7 @@ set(FCLAW_PACKAGE \"${PROJECT_NAME}\") configure_file(${CMAKE_CURRENT_LIST_DIR}/fclaw_config.h.in ${PROJECT_BINARY_DIR}/include/fclaw_config.h) -install(FILES ${PROJECT_BINARY_DIR}/include/fclaw_config.h DESTINATION include) +install(FILES ${PROJECT_BINARY_DIR}/include/fclaw_config.h TYPE INCLUDE) configure_file(${CMAKE_CURRENT_LIST_DIR}/test_config.h.in ${PROJECT_BINARY_DIR}/test/test_config.h) set(top_builddir ${PROJECT_BINARY_DIR}) diff --git a/cmake/options.cmake b/cmake/options.cmake index 3024df3cd..5fb2a8254 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -12,11 +12,11 @@ option(thunderegg_external "force build of ThunderEgg") option(p4est_external "force build of p4est") option(sc_external "force build of libsc") -set(CMAKE_TLS_VERIFY on) +option(CMAKE_TLS_VERIFY "verify HTTPS certs" on) # --- default install directory under build/local # users can specify like "cmake -B build -DCMAKE_INSTALL_PREFIX=~/mydir" -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND PROJECT_IS_TOP_LEVEL) # will not take effect without FORCE set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/local" CACHE PATH "Install top-level directory" FORCE) endif() @@ -45,15 +45,5 @@ if(thunderegg) set(clawpack4.6 ON) endif(thunderegg) -# Rpath options necessary for shared library install to work correctly in user projects -set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib) -set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true) - # Necessary for shared library with Visual Studio / Windows oneAPI set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS true) - -# --- auto-ignore build directory -if(NOT EXISTS ${PROJECT_BINARY_DIR}/.gitignore) - file(WRITE ${PROJECT_BINARY_DIR}/.gitignore "*") -endif() diff --git a/p4est b/p4est index 56b264ffb..fa0bc331c 160000 --- a/p4est +++ b/p4est @@ -1 +1 @@ -Subproject commit 56b264ffb3a16563ec2e5c2e9076bfc24ca9be96 +Subproject commit fa0bc331cdf6e02c905cef8745ca1ff9a57d4bde diff --git a/sc b/sc index 26c31a08b..a007593f8 160000 --- a/sc +++ b/sc @@ -1 +1 @@ -Subproject commit 26c31a08b1dfb89927769179bf810a7adb8c5856 +Subproject commit a007593f8adab93bca82da017f37b67cf1fdd4b9 diff --git a/scripts/convert_to_v2.py b/scripts/convert_to_v2.py new file mode 100755 index 000000000..e0b116e17 --- /dev/null +++ b/scripts/convert_to_v2.py @@ -0,0 +1,925 @@ +#!/usr/bin/env python3 + +fclaw_1to2 = { + + #===== ./src/forestclaw2d.h ===== + "" : "", + "fclaw2d_domain_t" : "fclaw_domain_t", + "fclaw2d_block_t" : "fclaw_block_t", + "fclaw2d_patch_t" : "fclaw_patch_t", + "fclaw2d_patch" : "fclaw_patch", + + "fclaw2d_block" : "fclaw_block", + + "fclaw2d_domain_persist" : "fclaw_domain_persist", + "fclaw2d_domain_persist_t" : "fclaw_domain_persist_t", + + "fclaw2d_domain" : "fclaw_domain", + + "fclaw2d_domain_attribute_add" : "fclaw_domain_attribute_add", + "fclaw2d_domain_attribute_access" : "fclaw_domain_attribute_access", + "fclaw2d_domain_attribute_remove" : "fclaw_domain_attribute_remove", + + "fclaw2d_domain_dimension" : "fclaw_domain_dimension", + "fclaw2d_domain_num_faces" : "fclaw_domain_num_faces", + "fclaw2d_domain_num_corners" : "fclaw_domain_num_corners", + "fclaw2d_domain_num_face_corners" : "fclaw_domain_num_face_corners", + "fclaw2d_domain_num_orientations" : "fclaw_domain_num_orientations", + "fclaw2d_domain_corner_faces" : "fclaw_domain_corner_faces", + "fclaw2d_patch_corner_dimension" : "fclaw_patch_corner_dimension", + + "fclaw2d_patch_childid" : "fclaw_patch_childid", + "fclaw2d_patch_is_first_sibling" : "fclaw_patch_is_first_sibling", + "fclaw2d_patch_is_ghost" : "fclaw_patch_is_ghost", + "fclaw2d_patch_callback_t" : "fclaw_patch_callback_t", + "fclaw2d_domain_iterate_level" : "fclaw_domain_iterate_level", + "fclaw2d_domain_iterate_patches" : "fclaw_domain_iterate_patches", + "fclaw2d_domain_iterate_families" : "fclaw_domain_iterate_families", + "fclaw2d_patch_boundary_type" : "fclaw_patch_boundary_type", + "fclaw2d_patch_normal_match" : "fclaw_patch_normal_match", + + "fclaw2d_face_neighbor" : "fclaw_face_neighbor", + "FCLAW2D_PATCH_BOUNDARY" : "FCLAW_PATCH_BOUNDARY", + "FCLAW2D_PATCH_HALFSIZE" : "FCLAW_PATCH_HALFSIZE", + "FCLAW2D_PATCH_SAMESIZE" : "FCLAW_PATCH_SAMESIZE", + "FCLAW2D_PATCH_DOUBLESIZE" : "FCLAW_PATCH_DOUBLESIZE", + "fclaw2d_patch_relation_t" : "fclaw_patch_relation_t", + + "fclaw2d_patch_face_neighbors" : "fclaw_patch_face_neighbors", + "fclaw2d_patch_face_swap" : "fclaw_patch_face_swap", + "fclaw2d_patch_face_transformation" : "fclaw_patch_face_transformation", + "fclaw2d_patch_face_transformation_block" : "fclaw_patch_face_transformation_block", + "fclaw2d_patch_face_transformation_intra" : "fclaw_patch_face_transformation_intra", + "fclaw2d_patch_face_transformation_valid" : "fclaw_patch_face_transformation_valid", + "fclaw2d_patch_transform_face" : "fclaw_patch_2d_transform_face", + "fclaw2d_patch_transform_face2" : "fclaw_patch_2d_transform_face2", + "fclaw2d_patch_corner_neighbors" : "fclaw_patch_corner_neighbors", + "fclaw2d_patch_corner_swap" : "fclaw_patch_corner_swap", + "fclaw2d_patch_transform_corner" : "fclaw_patch_2d_transform_corner", + "fclaw2d_patch_transform_corner2" : "fclaw_patch_2d_transform_corner2", + + "fclaw2d_domain_set_refinement" : "fclaw_domain_set_refinement", + "fclaw2d_patch_mark_refine" : "fclaw_patch_mark_refine", + "fclaw2d_patch_mark_coarsen" : "fclaw_patch_mark_coarsen", + "fclaw2d_match_callback_t" : "fclaw_match_callback_t", + "fclaw2d_domain_iterate_adapted" : "fclaw_domain_iterate_adapted", + + "fclaw2d_domain_allocate_before_partition": "fclaw_domain_allocate_before_partition", + "fclaw2d_domain_retrieve_after_partition" : "fclaw_domain_retrieve_after_partition", + "fclaw2d_transfer_callback_t" : "fclaw_transfer_callback_t", + "fclaw2d_domain_iterate_partitioned" : "fclaw_domain_iterate_partitioned", + "fclaw2d_domain_free_after_partition" : "fclaw_domain_free_after_partition", + + "fclaw2d_domain_exchange" : "fclaw_domain_exchange", + "fclaw2d_domain_exchange_t" : "fclaw_domain_exchange_t", + + "fclaw2d_domain_allocate_before_exchange" : "fclaw_domain_allocate_before_exchange", + "fclaw2d_domain_ghost_exchange" : "fclaw_domain_ghost_exchange", + "fclaw2d_domain_ghost_exchange_begin" : "fclaw_domain_ghost_exchange_begin", + "fclaw2d_domain_ghost_exchange_end" : "fclaw_domain_ghost_exchange_end", + "fclaw2d_domain_free_after_exchange" : "fclaw_domain_free_after_exchange", + "fclaw2d_domain_indirect_t" : "fclaw_domain_indirect_t", + "fclaw2d_domain_indirect_begin" : "fclaw_domain_indirect_begin", + "fclaw2d_domain_indirect_end" : "fclaw_domain_indirect_end", + "fclaw2d_domain_indirect_face_neighbors" : "fclaw_domain_indirect_face_neighbors", + "fclaw2d_domain_indirect_destroy" : "fclaw_domain_indirect_destroy", + "fclaw2d_domain_global_maximum" : "fclaw_domain_global_maximum", + "fclaw2d_domain_global_sum" : "fclaw_domain_global_sum", + "fclaw2d_domain_barrier" : "fclaw_domain_barrier", + "fclaw2d_domain_serialization_enter" : "fclaw_domain_serialization_enter", + "fclaw2d_domain_serialization_leave" : "fclaw_domain_serialization_leave", + + "fclaw2d_domain_is_meta" : "fclaw_domain_is_meta", + + #===== ./src/forestclaw2d_convenience.h ===== + "" : "", + "fclaw2d_domain_new_unitsquare" : "fclaw_domain_new_unitsquare", + "fclaw2d_domain_new_torus" : "fclaw_domain_new_2d_torus", + "fclaw2d_domain_new_twosphere" : "fclaw_domain_new_2d_twosphere", + "fclaw2d_domain_new_cubedsphere": "fclaw_domain_new_2d_cubedsphere", + "fclaw2d_domain_new_disk" : "fclaw_domain_new_2d_disk", + "fclaw2d_domain_new_brick" : "fclaw_domain_new_2d_brick", + "fclaw2d_domain_destroy" : "fclaw_domain_destroy", + + "fclaw2d_domain_adapt" : "fclaw_domain_adapt", + "fclaw2d_domain_partition" : "fclaw_domain_partition", + "fclaw2d_domain_partition_unchanged" : "fclaw_domain_partition_unchanged", + "fclaw2d_domain_complete" : "fclaw_domain_complete", + "fclaw2d_domain_write_vtk" : "fclaw_domain_write_vtk", + "fclaw2d_domain_list_levels" : "fclaw_domain_list_levels", + "fclaw2d_domain_list_neighbors" : "fclaw_domain_list_neighbors", + "fclaw2d_domain_list_adapted" : "fclaw_domain_list_adapted", + "fclaw2d_domain_search_points" : "fclaw_domain_search_points", + + "fclaw2d_integrate_ray_t" : "fclaw_integrate_ray_t", + "fclaw2d_domain_integrate_rays" : "fclaw_domain_integrate_rays", + "fclaw2d_interpolate_point_t" : "fclaw_interpolate_point_t", + "fclaw2d_overlap_exchange" : "fclaw_overlap_exchange", + + #===== ./src/fclaw2d_advance.h ===== + "" : "", + "fclaw2d_advance_all_levels" : "fclaw_advance_all_levels", + + #===== ./src/fclaw2d_block.h ===== + "" : "", + "fclaw2d_block_get_block_boundary" : "fclaw_block_get_block_boundary", + + #===== ./src/fclaw2d_corner_neighbors.h ===== + "fclaw2d_corner_neighbors.h" : "fclaw_corner_neighbors.h", + + #===== ./src/fclaw2d_diagnostics.h ===== + "" : "", + "fclaw2d_diagnostics_vtable" : "fclaw_diagnostics_vtable", + "fclaw2d_diagnostics_vtable_t" : "fclaw_diagnostics_vtable_t", + "fclaw2d_diagnostics_accumulator" : "fclaw_diagnostics_accumulator", + "fclaw2d_diagnostics_accumulator_t" : "fclaw_diagnostics_accumulator_t", + "fclaw2d_diagnostics_initialize_t" : "fclaw_diagnostics_initialize_t", + "fclaw2d_diagnostics_compute_t" : "fclaw_diagnostics_compute_t", + "fclaw2d_diagnostics_gather_t" : "fclaw_diagnostics_gather_t", + "fclaw2d_diagnostics_reset_t" : "fclaw_diagnostics_reset_t", + "fclaw2d_diagnostics_finalize_t" : "fclaw_diagnostics_finalize_t", + "fclaw2d_diagnostics_vt" : "fclaw_diagnostics_vt", + "fclaw2d_diagnostics_vtable_initialize" : "fclaw_diagnostics_vtable_initialize", + "fclaw2d_domain_global_minimum" : "fclaw_domain_global_minimum", + "fclaw2d_diagnostics_initialize" : "fclaw_diagnostics_initialize", + "fclaw2d_diagnostics_gather" : "fclaw_diagnostics_gather", + "fclaw2d_diagnostics_reset" : "fclaw_diagnostics_reset", + "fclaw2d_diagnostics_finalize" : "fclaw_diagnostics_finalize", + + #===== ./src/fclaw2d_domain.h ===== + "" : "", + "fclaw2d_domain_data" : "fclaw_domain_data", + "fclaw2d_domain_data_t" : "fclaw_domain_data_t", + "fclaw2d_domain_data_new" : "you_can_safely_remove_this_call", + "fclaw2d_domain_data_delete" : "you_can_safely_remove_this_call", + "fclaw2d_domain_setup" : "fclaw_domain_setup", + "fclaw2d_domain_reset" : "fclaw_domain_reset", + "fclaw2d_domain_get_data" : "fclaw_domain_get_data", + "fclaw2d_domain_iterate_level_mthread" : "fclaw_domain_iterate_level_mthread", + + #===== ./src/fclaw2d_elliptic_solver.h ===== + "" : "", + "fclaw2d_elliptic_setup_t" : "fclaw_elliptic_setup_t", + "fclaw2d_elliptic_rhs_t" : "fclaw_elliptic_rhs_t", + "fclaw2d_elliptic_solve_t" : "fclaw_elliptic_solve_t", + "fclaw2d_elliptic_physical_bc_t" : "fclaw_elliptic_physical_bc_t", + "fclaw2d_elliptic_vtable" : "fclaw_elliptic_vtable", + "fclaw2d_elliptic_vtable_t" : "fclaw_elliptic_vtable_t", + "fclaw2d_elliptic_vtable_initialize" : "fclaw_elliptic_vtable_initialize", + "fclaw2d_elliptic_solve" : "fclaw_elliptic_solve", + "fclaw2d_elliptic_vt" : "fclaw_elliptic_vt", + + #===== ./src/fclaw2d_exchange.h ===== + "" : "", + "fclaw2d_exchange_setup" : "fclaw_exchange_setup", + "fclaw2d_exchange_delete" : "fclaw_exchange_delete", + "fclaw2d_exchange_ghost_patches_begin" : "fclaw_exchange_ghost_patches_begin", + "fclaw2d_exchange_ghost_patches_end" : "fclaw_exchange_ghost_patches_end", + + #===== ./src/fclaw2d_face_neighbors.h ===== + "" : "", + "fclaw2d_face_neighbor_ghost" : "fclaw_face_neighbor_ghost", + + #===== ./src/fclaw2d_farraybox.hpp ===== + "" : "", + "fclaw2d_farraybox_set_to_nan" : "fclaw_farraybox_set_to_nan", + + #===== ./src/fclaw2d_forestclaw.h ===== + "" : "", + "fclaw2d_problem_setup" : "fclaw_problem_setup", + "fclaw2d_vtables_initialize" : "fclaw_vtables_initialize", + "fclaw2d_initialize" : "fclaw_initialize", + "fclaw2d_run" : "fclaw_run", + "fclaw2d_finalize" : "fclaw_finalize", + + #===== ./src/fclaw2d_ghost_fill.h ===== + "" : "", + "fclaw2d_ghost_fill_parallel_mode" : "fclaw_ghost_fill_parallel_mode", + "FCLAW2D_BOUNDARY_INTERIOR_ONLY" : "FCLAW_BOUNDARY_INTERIOR_ONLY", + "FCLAW2D_BOUNDARY_GHOST_ONLY" : "FCLAW_BOUNDARY_GHOST_ONLY", + "FCLAW2D_BOUNDARY_ALL" : "FCLAW_BOUNDARY_ALL", + "FCLAW2D_BOUNDARY_LOCAL_ALL" : "FCLAW_BOUNDARY_LOCAL_ALL", + "fclaw2d_ghost_fill_parallel_mode_t" : "fclaw_ghost_fill_parallel_mode_t", + "fclaw2d_exchange_type" : "fclaw_exchange_type", + "FCLAW2D_COPY" : "FCLAW_COPY", + "FCLAW2D_AVERAGE" : "FCLAW_AVERAGE", + "FCLAW2D_INTERPOLATE" : "FCLAW_INTERPOLATE", + "FCLAW2D_TIME_SYNC_F2C" : "FCLAW_TIME_SYNC_F2C", + "FCLAW2D_TIME_SYNC_SAMESIZE" : "FCLAW_TIME_SYNC_SAMESIZE", + "fclaw2d_exchange_type_t" : "fclaw_exchange_type_t", + "fclaw2d_grid_type" : "fclaw_grid_type", + "FCLAW2D_IS_COARSE" : "FCLAW_IS_COARSE", + "FCLAW2D_IS_FINE" : "FCLAW_IS_FINE", + "fclaw2d_grid_type_t" : "fclaw_grid_type_t", + "fclaw2d_exchange_info" : "fclaw_exchange_info", + "fclaw2d_exchange_info_t" : "fclaw_exchange_info_t", + "fclaw2d_ghost_update" : "fclaw_ghost_update", + "fclaw2d_ghost_update_async" : "fclaw_ghost_update_async", + "fclaw2d_ghost_update_nonasync" : "fclaw_ghost_update_nonasync", + "fclaw2d_face_neighbor_ghost" : "fclaw_face_neighbor_ghost", + + #===== ./src/fclaw2d_global.h ===== + "" : "", + "fclaw2d_iterate_patch_cb" : "fclaw_iterate_patch_cb", + "fclaw2d_iterate_family_cb" : "fclaw_iterate_family_cb", + "fclaw2d_global_t" : "fclaw_global_t", + "fclaw2d_global_iterate_t" : "fclaw_global_iterate_t", + "fclaw2d_global" : "fclaw_global", + "fclaw2d_global_iterate" : "fclaw_global_iterate", + "fclaw2d_global_new" : "fclaw_global_new", + "fclaw2d_global_new_comm" : "fclaw_global_new_comm", + "fclaw2d_global_destroy" : "fclaw_global_destroy", + "fclaw2d_global_store_domain" : "fclaw_global_store_domain", + "fclaw2d_global_store_map" : "fclaw_map_store", + "fclaw2d_global_iterate_level" : "fclaw_global_iterate_level", + "fclaw2d_global_iterate_patches" : "fclaw_global_iterate_patches", + "fclaw2d_global_iterate_families" : "fclaw_global_iterate_families", + "fclaw2d_global_iterate_adapted" : "fclaw_global_iterate_adapted", + "fclaw2d_global_iterate_level_mthread" : "fclaw_global_iterate_level_mthread", + "fclaw2d_global_iterate_partitioned" : "fclaw_global_iterate_partitioned", + "fclaw2d_global_options_store" : "fclaw_global_options_store", + "fclaw2d_global_get_options" : "fclaw_global_get_options", + "fclaw2d_global_set_global" : "fclaw_global_set_static", + "fclaw2d_global_unset_global" : "fclaw_global_clear_static", + "fclaw2d_global_get_global" : "fclaw_global_get_static_global", + "fclaw2d_set_global_context" : "fclaw_set_global_context", + "fclaw2d_clear_global_context" : "fclaw_clear_global_context", + + #===== ./src/fclaw2d_include_all.h ===== + "" : "", + + #===== ./src/fclaw2d_options.h ===== + "" : "", + "fclaw2d_options_store" : "fclaw_options_store", + "fclaw2d_get_options" : "fclaw_get_options", + + #===== ./src/fclaw2d_output.h ===== + "" : "", + "fclaw2d_output_frame" : "fclaw_output_frame", + + #===== ./src/fclaw2d_partition.h ===== + "" : "", + "fclaw2d_partition_domain" : "fclaw_partition_domain", + + #===== ./src/fclaw2d_patch.h ===== + "" : "", + + "fclaw2d_patch_vtable_t" : "fclaw_patch_vtable_t", + "fclaw2d_patch_data_t" : "fclaw_patch_data_t", + "fclaw2d_patch_transform_data_t" : "fclaw_patch_transform_data_t", + "FCLAW2D_BUILD_FOR_GHOST_AREA_COMPUTED" : "FCLAW_BUILD_FOR_GHOST_AREA_COMPUTED", + "FCLAW2D_BUILD_FOR_GHOST_AREA_PACKED" : "FCLAW_BUILD_FOR_GHOST_AREA_PACKED", + "FCLAW2D_BUILD_FOR_UPDATE" : "FCLAW_BUILD_FOR_UPDATE", + "FCLAW2D_BUILD_CUSTOM" : "FCLAW_BUILD_CUSTOM", + "fclaw2d_build_mode_t" : "fclaw_build_mode_t", + "fclaw2d_patch_data" : "fclaw_patch_data", + "fclaw2d_patch_transform_data" : "fclaw_patch_transform_data", + + "fclaw2d_patch_reset_data" : "fclaw_patch_reset_data", + "fclaw2d_patch_data_delete" : "fclaw_patch_data_delete", + "fclaw2d_patch_build" : "fclaw_patch_build", + "fclaw2d_patch_build_from_fine" : "fclaw_patch_build_from_fine", + "fclaw2d_patch_initialize" : "fclaw_patch_initialize", + "fclaw2d_patch_physical_bc" : "fclaw_patch_physical_bc", + "fclaw2d_patch_single_step_update" : "fclaw_patch_single_step_update", + "fclaw2d_patch_set_rhs" : "fclaw_patch_set_rhs", + "fclaw2d_patch_restore_step" : "fclaw_patch_restore_step", + "fclaw2d_patch_save_step" : "fclaw_patch_save_step", + "fclaw2d_patch_setup_timeinterp" : "fclaw_patch_setup_timeinterp", + "fclaw2d_patch_copy_face" : "fclaw_patch_copy_face", + "fclaw2d_patch_average_face" : "fclaw_patch_average_face", + "fclaw2d_patch_interpolate_face" : "fclaw_patch_interpolate_face", + "fclaw2d_patch_copy_corner" : "fclaw_patch_copy_corner", + "fclaw2d_patch_average_corner" : "fclaw_patch_average_corner", + "fclaw2d_patch_interpolate_corner" : "fclaw_patch_interpolate_corner", + "fclaw2d_patch_create_user_data" : "fclaw_patch_create_user_data", + "fclaw2d_patch_destroy_user_data" : "fclaw_patch_destroy_user_data", + "fclaw2d_patch_transform_init_data" : "fclaw_patch_transform_init_data", + "fclaw2d_patch_transform_blockface" : "fclaw_patch_transform_blockface", + "fclaw2d_patch_transform_blockface_intra" : "fclaw_patch_transform_blockface_intra", + "fclaw2d_patch_tag4refinement" : "fclaw_patch_tag4refinement", + "fclaw2d_patch_tag4coarsening" : "fclaw_patch_tag4coarsening", + "fclaw2d_patch_interpolate2fine" : "fclaw_patch_interpolate2fine", + "fclaw2d_patch_average2coarse" : "fclaw_patch_average2coarse", + "fclaw2d_patch_ghost_packsize" : "fclaw_patch_ghost_packsize", + "fclaw2d_patch_local_ghost_alloc" : "fclaw_patch_local_ghost_alloc", + "fclaw2d_patch_local_ghost_free" : "fclaw_patch_local_ghost_free", + "fclaw2d_patch_local_ghost_pack" : "fclaw_patch_local_ghost_pack", + "fclaw2d_patch_remote_ghost_build" : "fclaw_patch_remote_ghost_build", + "fclaw2d_patch_remote_ghost_unpack" : "fclaw_patch_remote_ghost_unpack", + "fclaw2d_patch_remote_ghost_delete" : "fclaw_patch_remote_ghost_delete", + "fclaw2d_patch_partition_pack" : "fclaw_patch_partition_pack", + "fclaw2d_patch_partition_unpack" : "fclaw_patch_partition_unpack", + "fclaw2d_patch_partition_packsize" : "fclaw_patch_partition_packsize", + "fclaw2d_patch_time_sync_f2c" : "fclaw_patch_time_sync_f2c", + "fclaw2d_patch_time_sync_samesize" : "fclaw_patch_time_sync_samesize", + "fclaw2d_patch_time_sync_reset" : "fclaw_patch_time_sync_reset", + + "fclaw2d_patch_new_t" : "fclaw_patch_new_t", + "fclaw2d_patch_delete_t" : "fclaw_patch_delete_t", + "fclaw2d_patch_build_t" : "fclaw_patch_build_t", + "fclaw2d_patch_build_from_fine_t" : "fclaw_patch_build_from_fine_t", + "fclaw2d_patch_setup_t" : "fclaw_patch_setup_t", + "fclaw2d_patch_initialize_t" : "fclaw_patch_initialize_t", + "fclaw2d_patch_physical_bc_t" : "fclaw_patch_physical_bc_t", + "fclaw2d_patch_single_step_update_t" : "fclaw_patch_single_step_update_t", + "fclaw2d_patch_rhs_t" : "fclaw_patch_rhs_t", + "fclaw2d_patch_setup_timeinterp_t" : "fclaw_patch_setup_timeinterp_t", + "fclaw2d_patch_restore_step_t" : "fclaw_patch_restore_step_t", + "fclaw2d_patch_save_step_t" : "fclaw_patch_save_step_t", + "fclaw2d_patch_copy_face_t" : "fclaw_patch_copy_face_t", + "fclaw2d_patch_average_face_t" : "fclaw_patch_average_face_t", + "fclaw2d_patch_interpolate_face_t" : "fclaw_patch_interpolate_face_t", + "fclaw2d_patch_copy_corner_t" : "fclaw_patch_copy_corner_t", + "fclaw2d_patch_average_corner_t" : "fclaw_patch_average_corner_t", + "fclaw2d_patch_interpolate_corner_t" : "fclaw_patch_interpolate_corner_t", + "fclaw2d_patch_transform_init_data_t" : "fclaw_patch_transform_init_data_t", + "fclaw2d_patch_transform_blockface_t" : "fclaw_patch_transform_blockface_t", + "fclaw2d_patch_transform_blockface_intra_t" : "fclaw_patch_transform_blockface_intra_t", + "fclaw2d_patch_tag4refinement_t" : "fclaw_patch_tag4refinement_t", + "fclaw2d_patch_tag4coarsening_t" : "fclaw_patch_tag4coarsening_t", + "fclaw2d_patch_interpolate2fine_t" : "fclaw_patch_interpolate2fine_t", + "fclaw2d_patch_average2coarse_t" : "fclaw_patch_average2coarse_t", + "fclaw2d_patch_ghost_packsize_t" : "fclaw_patch_ghost_packsize_t", + "fclaw2d_patch_local_ghost_pack_t" : "fclaw_patch_local_ghost_pack_t", + "fclaw2d_patch_local_ghost_alloc_t" : "fclaw_patch_local_ghost_alloc_t", + "fclaw2d_patch_local_ghost_free_t" : "fclaw_patch_local_ghost_free_t", + "fclaw2d_patch_remote_ghost_build_t" : "fclaw_patch_remote_ghost_build_t", + "fclaw2d_patch_remote_ghost_setup_t" : "fclaw_patch_remote_ghost_setup_t", + "fclaw2d_patch_remote_ghost_unpack_t" : "fclaw_patch_remote_ghost_unpack_t", + "fclaw2d_patch_remote_ghost_delete_t" : "fclaw_patch_remote_ghost_delete_t", + "fclaw2d_patch_partition_packsize_t" : "fclaw_patch_partition_packsize_t", + "fclaw2d_patch_partition_pack_t" : "fclaw_patch_partition_pack_t", + "fclaw2d_patch_partition_unpack_t" : "fclaw_patch_partition_unpack_t", + "fclaw2d_patch_time_sync_f2c_t" : "fclaw_patch_time_sync_f2c_t", + "fclaw2d_patch_time_sync_samesize_t" : "fclaw_patch_time_sync_samesize_t", + "fclaw2d_patch_time_sync_reset_t" : "fclaw_patch_time_sync_reset_t", + "fclaw2d_patch_create_user_data_t" : "fclaw_patch_create_user_data_t", + "fclaw2d_patch_destroy_user_data_t" : "fclaw_patch_destroy_user_data_t", + "fclaw2d_patch_metric_patch_t" : "fclaw_patch_metric_patch_t", + + "fclaw2d_patch_vtable" : "fclaw_patch_vtable", + "fclaw2d_patch_vt" : "fclaw_patch_vt", + "fclaw2d_patch_vtable_initialize" : "fclaw_patch_vtable_initialize", + + "fclaw2d_patch_get_info" : "fclaw_patch_get_info", + "fclaw2d_patch_get_info2" : "fclaw_patch_get_info2", + "fclaw2d_patch_get_user_patch" : "fclaw_patch_get_user_patch", + "fclaw2d_patch_get_patch_data" : "fclaw_patch_get_patch_data", + "fclaw2d_patch_get_user_data" : "fclaw_patch_get_user_data", + "fclaw2d_patch_metric_patch" : "fclaw_patch_metric_patch", + "fclaw2d_patch_get_blockno" : "fclaw_patch_get_blockno", + "fclaw2d_patch_get_patchno" : "fclaw_patch_get_patchno", + "fclaw2d_patch_user_data" : "fclaw_patch_user_data", + "fclaw2d_patch_set_user_data" : "fclaw_patch_set_user_data", + + "fclaw2d_patch_on_parallel_boundary" : "fclaw_patch_on_parallel_boundary", + "fclaw2d_patch_set_face_type" : "fclaw_patch_set_face_type", + "fclaw2d_patch_set_corner_type" : "fclaw_patch_set_corner_type", + "fclaw2d_patch_set_missing_corner" : "fclaw_patch_set_missing_corner", + "fclaw2d_patch_get_face_type" : "fclaw_patch_get_face_type", + "fclaw2d_patch_get_corner_type" : "fclaw_patch_get_corner_type", + "fclaw2d_patch_corner_is_missing" : "fclaw_patch_corner_is_missing", + "fclaw2d_patch_neighbors_set" : "fclaw_patch_neighbors_set", + "fclaw2d_patch_neighbors_reset" : "fclaw_patch_neighbors_reset", + "fclaw2d_patch_neighbor_type_set" : "fclaw_patch_neighbor_type_set", + "fclaw2d_patch_has_finegrid_neighbors" : "fclaw_patch_has_finegrid_neighbors", + "fclaw2d_patch_on_coarsefine_interface" : "fclaw_patch_on_coarsefine_interface", + "fclaw2d_patch_block_corner_count" : "fclaw_patch_block_corner_count", + "fclaw2d_patch_set_block_corner_count" : "fclaw_patch_set_block_corner_count", + + #===== ./src/fclaw2d_physical_bc.h ===== + "" : "", + + "fclaw2d_physical_time_info" : "fclaw_physical_time_info", + "fclaw2d_physical_time_info_t" : "fclaw_physical_time_info_t", + "cb_fclaw2d_physical_set_bc" : "cb_fclaw_physical_set_bc", + "fclaw2d_physical_get_bc" : "fclaw_physical_get_bc", + "fclaw2d_physical_set_bc" : "fclaw_physical_set_bc", + "fclaw2d_physical_bc_default" : "fclaw_physical_bc_default", + + #===== ./src/fclaw2d_regrid.h ===== + "" : "", + "cb_fclaw2d_regrid_tag4refinement" : "cb_fclaw_regrid_tag4refinement", + "cb_fclaw2d_regrid_repopulate" : "cb_fclaw_regrid_repopulate", + "fclaw2d_regrid_set_neighbor_types" : "fclaw_regrid_set_neighbor_types", + "fclaw2d_regrid" : "fclaw_regrid", + "fclaw2d_after_regrid" : "fclaw_after_regrid", + "fclaw2d_regrid_set_neighbor_types" : "fclaw_regrid_set_neighbor_types", + + #===== ./src/fclaw2d_time_sync.h ===== + "" : "", + "fclaw2d_time_sync_type" : "fclaw_time_sync_type", + "FCLAW2D_TIME_SYNC_RESET_F2C" : "FCLAW_TIME_SYNC_RESET_F2C", + "FCLAW2D_TIME_SYNC_RESET_SAMESIZE" : "FCLAW_TIME_SYNC_RESET_SAMESIZE", + "FCLAW2D_TIME_SYNC_RESET_PHYS" : "FCLAW_TIME_SYNC_RESET_PHYS", + "fclaw2d_time_sync_type_t" : "fclaw_time_sync_type_t", + "fclaw2d_time_sync" : "fclaw_time_sync", + + #===== ./src/fclaw2d_timeinterp.h ===== + "" : "", + "fclaw2d_timeinterp" : "fclaw_timeinterp", + + #===== ./src/fclaw_timer.h ===== + "FCLAW2D_TIMER_NONE" : "FCLAW_TIMER_NONE", + "FCLAW2D_TIMER_INIT" : "FCLAW_TIMER_INIT", + "FCLAW2D_TIMER_ADVANCE" : "FCLAW_TIMER_ADVANCE", + "FCLAW2D_TIMER_ELLIPTIC_SOLVE" : "FCLAW_TIMER_ELLIPTIC_SOLVE", + "FCLAW2D_TIMER_GHOSTFILL" : "FCLAW_TIMER_GHOSTFILL", + "FCLAW2D_TIMER_REGRID" : "FCLAW_TIMER_REGRID", + "FCLAW2D_TIMER_DIAGNOSTICS" : "FCLAW_TIMER_DIAGNOSTICS", + "FCLAW2D_TIMER_OUTPUT" : "FCLAW_TIMER_OUTPUT", + "FCLAW2D_TIMER_GHOSTPATCH_COMM" : "FCLAW_TIMER_GHOSTPATCH_COMM", + "FCLAW2D_TIMER_ADAPT_COMM" : "FCLAW_TIMER_ADAPT_COMM", + "FCLAW2D_TIMER_PARTITION_COMM" : "FCLAW_TIMER_PARTITION_COMM", + "FCLAW2D_TIMER_DIAGNOSTICS_COMM" : "FCLAW_TIMER_DIAGNOSTICS_COMM", + "FCLAW2D_TIMER_CFL_COMM" : "FCLAW_TIMER_CFL_COMM", + "FCLAW2D_TIMER_WALLTIME" : "FCLAW_TIMER_WALLTIME", + "FCLAW2D_TIMER_UNACCOUNTED" : "FCLAW_TIMER_UNACCOUNTED", + "FCLAW2D_TIMER_ADVANCE_STEPS_COUNTER" : "FCLAW_TIMER_ADVANCE_STEPS_COUNTER", + "FCLAW2D_TIMER_ELLIPTIC_GRIDS_COUNTER" : "FCLAW_TIMER_ELLIPTIC_GRIDS_COUNTER", + "FCLAW2D_TIMER_GRIDS_PER_PROC" : "FCLAW_TIMER_GRIDS_PER_PROC", + "FCLAW2D_TIMER_GRIDS_INTERIOR" : "FCLAW_TIMER_GRIDS_INTERIOR", + "FCLAW2D_TIMER_GRIDS_LOCAL_BOUNDARY" : "FCLAW_TIMER_GRIDS_LOCAL_BOUNDARY", + "FCLAW2D_TIMER_GRIDS_REMOTE_BOUNDARY" : "FCLAW_TIMER_GRIDS_REMOTE_BOUNDARY", + "FCLAW2D_TIMER_REGRID_BUILD" : "FCLAW_TIMER_REGRID_BUILD", + "FCLAW2D_TIMER_REGRID_TAGGING" : "FCLAW_TIMER_REGRID_TAGGING", + "FCLAW2D_TIMER_TIMESYNC" : "FCLAW_TIMER_TIMESYNC", + "FCLAW2D_TIMER_GHOSTPATCH_BUILD" : "FCLAW_TIMER_GHOSTPATCH_BUILD", + "FCLAW2D_TIMER_PARTITION" : "FCLAW_TIMER_PARTITION", + "FCLAW2D_TIMER_PARTITION_BUILD" : "FCLAW_TIMER_PARTITION_BUILD", + "FCLAW2D_TIMER_ADVANCE_STEP2" : "FCLAW_TIMER_ADVANCE_STEP2", + "FCLAW2D_TIMER_ADVANCE_B4STEP2" : "FCLAW_TIMER_ADVANCE_B4STEP2", + "FCLAW2D_TIMER_GHOSTFILL_COPY" : "FCLAW_TIMER_GHOSTFILL_COPY", + "FCLAW2D_TIMER_GHOSTFILL_AVERAGE" : "FCLAW_TIMER_GHOSTFILL_AVERAGE", + "FCLAW2D_TIMER_GHOSTFILL_INTERP" : "FCLAW_TIMER_GHOSTFILL_INTERP", + "FCLAW2D_TIMER_GHOSTFILL_PHYSBC" : "FCLAW_TIMER_GHOSTFILL_PHYSBC", + "FCLAW2D_TIMER_GHOSTFILL_STEP1" : "FCLAW_TIMER_GHOSTFILL_STEP1", + "FCLAW2D_TIMER_GHOSTFILL_STEP2" : "FCLAW_TIMER_GHOSTFILL_STEP2", + "FCLAW2D_TIMER_GHOSTFILL_STEP3" : "FCLAW_TIMER_GHOSTFILL_STEP3", + "FCLAW2D_TIMER_NEIGHBOR_SEARCH" : "FCLAW_TIMER_NEIGHBOR_SEARCH", + "FCLAW2D_TIMER_LOCAL_COMM" : "FCLAW_TIMER_LOCAL_COMM", + "FCLAW2D_TIMER_GLOBAL_COMM" : "FCLAW_TIMER_GLOBAL_COMM", + "FCLAW2D_TIMER_CUDA_ALLOCATE" : "FCLAW_TIMER_CUDA_ALLOCATE", + "FCLAW2D_TIMER_CUDA_MEMCOPY_H2H" : "FCLAW_TIMER_CUDA_MEMCOPY_H2H", + "FCLAW2D_TIMER_CUDA_MEMCOPY_H2D" : "FCLAW_TIMER_CUDA_MEMCOPY_H2D", + "FCLAW2D_TIMER_CUDA_MEMCOPY_D2H" : "FCLAW_TIMER_CUDA_MEMCOPY_D2H", + "FCLAW2D_TIMER_EXTRA1" : "FCLAW_TIMER_EXTRA1", + "FCLAW2D_TIMER_EXTRA2" : "FCLAW_TIMER_EXTRA2", + "FCLAW2D_TIMER_EXTRA3" : "FCLAW_TIMER_EXTRA3", + "FCLAW2D_TIMER_EXTRA4" : "FCLAW_TIMER_EXTRA4", + "FCLAW2D_TIMER_COUNT" : "FCLAW_TIMER_COUNT", + "fclaw2d_timer_names_t" : "fclaw_timer_names_t", + "fclaw2d_timer_t" : "fclaw_timer_t", + "fclaw2d_timer_wtime" : "fclaw_timer_wtime", + "fclaw2d_timer_init" : "fclaw_timer_init", + "fclaw2d_timer_start" : "fclaw_timer_start", + "fclaw2d_timer_stop" : "fclaw_timer_stop", + "fclaw2d_timer_start_threadsafe" : "fclaw_timer_start_threadsafe", + "fclaw2d_timer_stop_threadsafe" : "fclaw_timer_stop_threadsafe", + + #===== ./src/fclaw2d_update_single_step.h ===== + "" : "", + "fclaw2d_single_step_buffer_data" : "fclaw_single_step_buffer_data", + "fclaw2d_single_step_buffer_data_t" : "fclaw_single_step_buffer_data_t", + "fclaw2d_single_step_data" : "fclaw_single_step_data", + "fclaw2d_single_step_data_t" : "fclaw_single_step_data_t", + "fclaw2d_update_single_step" : "fclaw_update_single_step", + + #===== ./src/fclaw2d_vtable.h ===== + "" : "", + "fclaw2d_problem_setup_t" : "fclaw_problem_setup_t", + "fclaw2d_output_frame_t" : "fclaw_output_frame_t", + "fclaw2d_after_regrid_t" : "fclaw_after_regrid_t", + "fclaw2d_vtable" : "fclaw_vtable", + "fclaw2d_vtable_t" : "fclaw_vtable_t", + "fclaw2d_vt" : "fclaw_vt", + "fclaw2d_vtable_initialize" : "fclaw_vtable_initialize", + "fclaw2d_after_regrid" : "fclaw_after_regrid", + + #===== ./src/patches/clawpatch/fclaw2d_clawpatch.h ===== + "" : "", + "fclaw2d_clawpatch_vtable_t" : "fclaw_clawpatch_vtable_t", + "fclaw2d_clawpatch_vtable_initialize" : "fclaw_clawpatch_vtable_initialize", + "fclaw2d_clawpatch_vt" : "fclaw_clawpatch_vt", + "fclaw2d_clawpatch_vtable" : "fclaw_clawpatch_vtable", + "fclaw2d_clawpatch_save_current_step" : "fclaw_clawpatch_save_current_step", + "fclaw2d_clawpatch_grid_data" : "fclaw_clawpatch_2d_grid_data", + "fclaw2d_clawpatch_metric_scalar" : "fclaw_clawpatch_2d_metric_scalar", + "fclaw2d_clawpatch_metric_vector" : "fclaw_clawpatch_2d_metric_vector", + "fclaw2d_clawpatch_metric_data" : "fclaw_clawpatch_2d_metric_data", + "fclaw2d_clawpatch_metric_data2" : "fclaw_clawpatch_2d_metric_data2", + "fclaw2d_clawpatch_get_area" : "fclaw_clawpatch_get_2d_area", + "fclaw2d_clawpatch_soln_data" : "fclaw_clawpatch_soln_data", + "fclaw2d_clawpatch_aux_data" : "fclaw_clawpatch_aux_data", + "fclaw2d_clawpatch_rhs_data" : "fclaw_clawpatch_rhs_data", + "fclaw2d_clawpatch_elliptic_error_data" : "fclaw_clawpatch_elliptic_error_data", + "fclaw2d_clawpatch_elliptic_soln_data" : "fclaw_clawpatch_elliptic_soln_data", + "fclaw2d_clawpatch_get_q" : "fclaw_clawpatch_get_q", + "fclaw2d_clawpatch_get_error" : "fclaw_clawpatch_get_error", + "fclaw2d_clawpatch_get_exactsoln" : "fclaw_clawpatch_get_exactsoln", + "fclaw2d_clawpatch_size" : "fclaw_clawpatch_size", + "fclaw2d_clawpatch_get_user_data" : "fclaw_clawpatch_get_user_data", + "fclaw2d_clawpatch_set_user_data" : "fclaw_clawpatch_set_user_data", + "fclaw2d_clawpatch_get_solver_data" : "fclaw_clawpatch_get_solver_data", + "fclaw2d_clawpatch_set_solver_data" : "fclaw_clawpatch_set_solver_data", + "fclaw2d_clawpatch_timesync_data" : "fclaw_clawpatch_timesync_data", + "fclaw2d_clawpatch_get_q_timesync" : "fclaw_clawpatch_get_q_timesync", + "fclaw2d_clawpatch_get_registers" : "fclaw_clawpatch_get_2d_registers", + + #===== ./src/patches/clawpatch/fclaw2d_clawpatch.hpp ===== + "" : "", + "fclaw2d_clawpatch_t" : "fclaw_clawpatch_t", + "fclaw2d_clawpatch_get_clawpatch" : "fclaw_clawpatch_get_clawpatch", + "fclaw2d_clawpatch_get_metric_patch" : "fclaw_clawpatch_get_2d_metric_patch", + + #===== ./src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.h ===== + "" : "", + "fclaw2d_clawpatch_diagnostics_initialize" : "fclaw_clawpatch_diagnostics_initialize", + "fclaw2d_clawpatch_diagnostics_compute" : "fclaw_clawpatch_diagnostics_compute", + "fclaw2d_clawpatch_diagnostics_gather" : "fclaw_clawpatch_diagnostics_gather", + "fclaw2d_clawpatch_diagnostics_reset" : "fclaw_clawpatch_diagnostics_reset", + "fclaw2d_clawpatch_diagnostics_finalize" : "fclaw_clawpatch_diagnostics_finalize", + "fclaw2d_clawpatch_diagnostics_vtable_initialize" : "fclaw_clawpatch_diagnostics_vtable_initialize", + "fclaw2d_clawpatch_diagnostics_cons_default" : "fclaw_clawpatch_diagnostics_cons_default", + "fclaw2d_clawpatch_diagnostics_error_default" : "fclaw_clawpatch_diagnostics_error_default", + + #===== ./src/patches/clawpatch/fclaw2d_clawpatch_options.h ===== + "" : "", + "fclaw2d_clawpatch_options_t" : "fclaw_clawpatch_options_t", + "fclaw2d_clawpatch_options" : "fclaw_clawpatch_options", + "fclaw2d_clawpatch_options_register" : "fclaw_clawpatch_2d_options_register", + "fclaw2d_clawpatch_options_store" : "fclaw_clawpatch_options_store", + "fclaw2d_clawpatch_get_options" : "fclaw_clawpatch_get_options", + + #===== ./src/patches/clawpatch/fclaw2d_clawpatch_output_ascii.h ===== + "" : "", + "fclaw2d_clawpatch_output_ascii" : "fclaw_clawpatch_output_ascii", + "fclaw2d_clawpatch_time_header_ascii" : "fclaw_clawpatch_time_header_ascii", + + #===== ./src/patches/clawpatch/fclaw2d_clawpatch_output_vtk.h ===== + "" : "", + "fclaw2d_vtk_patch_data_t" : "fclaw_vtk_patch_data_t", + "fclaw2d_vtk_write_file" : "fclaw_vtk_write_2d_file", + "fclaw2d_clawpatch_output_vtk" : "fclaw_clawpatch_output_vtk", + + #===== ./src/patches/clawpatch/fclaw2d_clawpatch_pillow.h ===== + "" : "", + + "fclaw2d_clawpatch_pillow_vtable_t" : "fclaw_clawpatch_pillow_vtable_t", + "fclaw2d_clawpatch_use_pillowsphere" : "fclaw_clawpatch_use_pillowsphere", + "fclaw2d_clawpatch_pillow_vtable_initialize" : "fclaw_clawpatch_pillow_vtable_initialize", + "fclaw2d_clawpatch_pillow_vtable" : "fclaw_clawpatch_pillow_vtable", + "fclaw2d_clawpatch_pillow_vt" : "fclaw_clawpatch_pillow_vt", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch.h ===== + "" : "", + "fclaw3dx_clawpatch_vtable_t" : "fclaw_clawpatch_vtable_t", + "fclaw3dx_clawpatch_vtable_initialize" : "fclaw_clawpatch_vtable_initialize", + "fclaw3dx_clawpatch_vt" : "fclaw_clawpatch_vt", + "fclaw3dx_clawpatch_vtable" : "fclaw_clawpatch_vtable", + "fclaw3dx_clawpatch_save_current_step" : "fclaw_clawpatch_save_current_step", + "fclaw3dx_clawpatch_grid_data" : "fclaw_clawpatch_3d_grid_data", + "fclaw3d_clawpatch_grid_data" : "fclaw_clawpatch_3d_grid_data", + "fclaw3d_clawpatch_get_volume" : "fclaw_clawpatch_get_3d_volume", + "fclaw3d_clawpatch_metric_scalar" : "fclaw_clawpatch_3d_metric_scalar", + "fclaw3d_clawpatch_metric_basis" : "fclaw_clawpatch_3d_metric_basis", + "fclaw3d_clawpatch_mesh_data" : "fclaw_clawpatch_3d_mesh_data", + "fclaw3dx_clawpatch_soln_data" : "fclaw_clawpatch_soln_data", + "fclaw3dx_clawpatch_aux_data" : "fclaw_clawpatch_aux_data", + "fclaw3dx_clawpatch_rhs_data" : "fclaw_clawpatch_rhs_data", + "fclaw3dx_clawpatch_elliptic_error_data" : "fclaw_clawpatch_elliptic_error_data", + "fclaw3dx_clawpatch_elliptic_soln_data" : "fclaw_clawpatch_elliptic_soln_data", + "fclaw3dx_clawpatch_get_q" : "fclaw_clawpatch_get_q", + "fclaw3dx_clawpatch_get_error" : "fclaw_clawpatch_get_error", + "fclaw3dx_clawpatch_get_exactsoln" : "fclaw_clawpatch_get_exactsoln", + "fclaw3dx_clawpatch_size" : "fclaw_clawpatch_size", + "fclaw3dx_clawpatch_get_user_data" : "fclaw_clawpatch_get_user_data", + "fclaw3dx_clawpatch_set_user_data" : "fclaw_clawpatch_set_user_data", + "fclaw3dx_clawpatch_get_solver_data" : "fclaw_clawpatch_get_solver_data", + "fclaw3dx_clawpatch_set_solver_data" : "fclaw_clawpatch_set_solver_data", + "fclaw3dx_clawpatch_timesync_data" : "fclaw_clawpatch_timesync_data", + "fclaw3dx_clawpatch_get_q_timesync" : "fclaw_clawpatch_get_q_timesync", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch.hpp ===== + "" : "", + "fclaw3dx_clawpatch_t" : "fclaw_clawpatch_t", + "fclaw3dx_clawpatch_get_clawpatch" : "fclaw_clawpatch_get_clawpatch", + "fclaw3dx_clawpatch_get_metric_patch" : "fclaw_clawpatch_get_3d_metric_patch", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics.h ===== + "" : "", + "fclaw3dx_clawpatch_error_info_t" : "error_info_t", + "fclaw3dx_clawpatch_diagnostics_initialize" : "fclaw_clawpatch_diagnostics_initialize", + "fclaw3dx_clawpatch_diagnostics_compute" : "fclaw_clawpatch_diagnostics_compute", + "fclaw3dx_clawpatch_diagnostics_gather" : "fclaw_clawpatch_diagnostics_gather", + "fclaw3dx_clawpatch_diagnostics_reset" : "fclaw_clawpatch_diagnostics_reset", + "fclaw3dx_clawpatch_diagnostics_finalize" : "fclaw_clawpatch_diagnostics_finalize", + "fclaw3dx_clawpatch_diagnostics_vtable_initialize" : "fclaw_clawpatch_diagnostics_vtable_initialize", + "fclaw3dx_clawpatch_diagnostics_cons_default" : "fclaw_clawpatch_diagnostics_cons_default", + "fclaw3dx_clawpatch_diagnostics_error_default" : "fclaw_clawpatch_diagnostics_error_default", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch_options.h ===== + "" : "", + "fclaw3dx_clawpatch_options_t" : "fclaw_clawpatch_options_t", + "fclaw3dx_clawpatch_options" : "fclaw_clawpatch_options", + "fclaw3dx_clawpatch_options_t" : "fclaw_clawpatch_options_t", + "fclaw3dx_clawpatch_options_register" : "fclaw_clawpatch_3d_options_register", + "fclaw3dx_clawpatch_options_store" : "fclaw_clawpatch_options_store", + "fclaw3dx_clawpatch_get_options" : "fclaw_clawpatch_get_options", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch_output_ascii.h ===== + "" : "", + "fclaw3dx_clawpatch_output_ascii_cb" : "fclaw_clawpatch_output_ascii_cb", + "fclaw3dx_clawpatch_output_ascii" : "fclaw_clawpatch_output_ascii", + "fclaw3dx_clawpatch_time_header_ascii" : "fclaw_clawpatch_time_header_ascii", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch_output_vtk.h ===== + "" : "", + "fclaw3dx_vtk_patch_data_t" : "fclaw_vtk_patch_data_t", + "fclaw3dx_vtk_write_file" : "fclaw_vtk_write_3d_file", + "fclaw3dx_clawpatch_output_vtk" : "fclaw_clawpatch_output_vtk", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch_pillow.h ===== + "" : "", + "fclaw3dx_clawpatch_pillow_vtable_t" : "fclaw_clawpatch_pillow_vtable_t", + "fclaw3dx_clawpatch_use_pillowsphere" : "fclaw_clawpatch_use_pillowsphere", + "fclaw3dx_clawpatch_pillow_vtable_initialize" : "fclaw_clawpatch_pillow_vtable_initialize", + "fclaw3dx_clawpatch_pillow_vtable" : "fclaw_clawpatch_pillow_vtable", + "fclaw3dx_clawpatch_pillow_vt" : "fclaw_clawpatch_pillow_vt", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch_fort.h ===== + "FCLAW3DX_CLAWPATCH_GET_REFINEMENT_CRITERIA" : "FCLAW3D_CLAWPATCH_GET_REFINEMENT_CRITERIA", + "FCLAW3DX_CLAWPATCH_TAG_CRITERIA" : "FCLAW3D_CLAWPATCH_TAG_CRITERIA", + "FCLAW3DX_CLAWPATCH_EXCEEDS_THRESHOLD" : "FCLAW3D_CLAWPATCH_EXCEEDS_THRESHOLD", + "FCLAW3DX_CLAWPATCH_VALUE_EXCEEDS_TH" : "FCLAW3D_CLAWPATCH_VALUE_EXCEEDS_TH", + "FCLAW3DX_CLAWPATCH_DIFFERENCE_EXCEEDS_TH" : "FCLAW3D_CLAWPATCH_DIFFERENCE_EXCEEDS_TH", + "FCLAW3DX_CLAWPATCH_MINMAX_EXCEEDS_TH" : "FCLAW3D_CLAWPATCH_MINMAX_EXCEEDS_TH", + "FCLAW3DX_CLAWPATCH_GRADIENT_EXCEEDS_TH" : "FCLAW3D_CLAWPATCH_GRADIENT_EXCEEDS_TH", + "FCLAW3DX_USER_EXCEEDS_TH" : "FCLAW3D_USER_EXCEEDS_TH", + "FCLAW3DX_USER_TAG4REFINEMENT" : "FCLAW3D_USER_TAG4REFINEMENT", + "FCLAW3DX_USER_TAG4COARSENING" : "FCLAW3D_USER_TAG4COARSENING", + "FCLAW3DX_USER_INTERPOLATE2FINE" : "FCLAW3D_USER_INTERPOLATE2FINE", + "FCLAW3DX_USER_AVERAGE2COARSE" : "FCLAW3D_USER_AVERAGE2COARSE", + "fclaw3dx_clawpatch_get_refinement_criteria" : "fclaw3d_clawpatch_get_refinement_criteria", + "fclaw3dx_clawpatch_tag_criteria" : "fclaw3d_clawpatch_tag_criteria", + "fclaw3dx_clawpatch_exceeds_threshold" : "fclaw3d_clawpatch_exceeds_threshold", + "fclaw3dx_clawpatch_value_exceeds_th" : "fclaw3d_clawpatch_value_exceeds_th", + "fclaw3dx_clawpatch_difference_exceeds_th" : "fclaw3d_clawpatch_difference_exceeds_th", + "fclaw3dx_clawpatch_minmax_exceeds_th" : "fclaw3d_clawpatch_minmax_exceeds_th", + "fclaw3dx_clawpatch_gradient_exceeds_th" : "fclaw3d_clawpatch_gradient_exceeds_th", + "fclaw3dx_user_exceeds_th" : "fclaw3d_user_exceeds_th", + "fclaw3dx_user_tag4refinement" : "fclaw3d_user_tag4refinement", + "fclaw3dx_user_tag4coarsening" : "fclaw3d_user_tag4coarsening", + "fclaw3dx_user_interpolate2fine" : "fclaw3d_user_interpolate2fine", + "fclaw3dx_user_average2coarse" : "fclaw3d_user_average2coarse", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch_transform.h ===== + "" : "", + "fclaw3dx_clawpatch_transform_init_data" : "fclaw2d_clawpatch_transform_init_data", + "fclaw3dx_clawpatch_face_transformation" : "fclaw2d_clawpatch_face_transformation", + "fclaw3dx_clawpatch_face_transformation_intra" : "fclaw2d_clawpatch_face_transformation_intra", + "FCLAW3DX_CLAWPATCH_TRANSFORM_FACE" : "FCLAW2D_CLAWPATCH_TRANSFORM_FACE", + "FCLAW3DX_CLAWPATCH_TRANSFORM_FACE_HALF" : "FCLAW2D_CLAWPATCH_TRANSFORM_FACE_HALF", + "FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER" : "FCLAW2D_CLAWPATCH_TRANSFORM_CORNER", + "FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER_HALF" : "FCLAW2D_CLAWPATCH_TRANSFORM_CORNER_HALF", + "fclaw3dx_clawpatch_transform_face" : "fclaw2d_clawpatch_transform_face", + "fclaw3dx_clawpatch_transform_face_half" : "fclaw2d_clawpatch_transform_face_half", + "fclaw3dx_clawpatch_transform_corner" : "fclaw2d_clawpatch_transform_corner", + "fclaw3dx_clawpatch_transform_corner_half" : "fclaw2d_clawpatch_transform_corner_half", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch_fort.h ===== + "" : "", + + #===== ./src/patches/clawpatch/fclaw3dx_clawpatch46_fort.h ===== + "" : "", + + #===== ./src/fclaw2d_rays.h ===== + "" : "", + "fclaw2d_ray_vtable" : "fclaw_ray_vtable", + "fclaw2d_ray_vtable_t" : "fclaw_ray_vtable_t", + "fclaw2d_ray" : "fclaw_ray", + "fclaw2d_ray_t" : "fclaw_ray_t", + "fclaw2d_ray_allocate_and_define_t" : "fclaw_ray_allocate_and_define_t", + "fclaw2d_ray_deallocate_t" : "fclaw_ray_deallocate_t", + "fclaw2d_ray_create_files_t" : "fclaw_ray_create_files_t", + "fclaw2d_ray_normalize_t" : "fclaw_ray_normalize_t", + "fclaw2d_ray_update_t" : "fclaw_ray_update_t", + "fclaw2d_ray_print_t" : "fclaw_ray_print_t", + "fclaw2d_ray_destroy_buffer_data_t" : "fclaw_ray_destroy_buffer_data_t", + "fclaw2d_ray_vtable" : "fclaw_ray_vtable", + "fclaw2d_ray_vtable_t" : "fclaw_ray_vtable_t", + "fclaw2d_ray_allocate_and_define" : "fclaw_ray_allocate_and_define", + "fclaw2d_ray_deallocate" : "fclaw_ray_deallocate", + "fclaw2d_ray_set_ray" : "fclaw_ray_set_ray", + "fclaw2d_ray_get_ray" : "fclaw_ray_get_ray", + "fclaw2d_ray_vt" : "fclaw_ray_vt", + "fclaw2d_ray_vtable_initialize" : "fclaw_ray_vtable_initialize", + "fclaw2d_ray_allocate_rays" : "fclaw_ray_allocate_rays", + "fclaw2d_ray_deallocate_rays" : "fclaw_ray_deallocate_rays", + + #===== ./src/fclaw2d_map.h ===== + "" : "", + "fclaw2d_map_context" : "fclaw_map_context", + "fclaw2d_map_context_t" : "fclaw_map_context_t", + "fclaw2d_map_store_t" : "fclaw_map_store_t", + "fclaw2d_get_map" : "fclaw_get_map", + "fclaw2d_map_query_t" : "fclaw_map_query_t", + "fclaw2d_map_c2m_t" : "fclaw_map_2d_c2m_t", + "fclaw2d_map_c2m_basis_t" : "fclaw_map_2d_c2m_basis_t", + "fclaw3dx_map_c2m_t" : "fclaw_map_3d_c2m_t", + "fclaw3dx_map_c2m_basis_t" : "fclaw_map_3d_c2m_basis_t", + "fclaw2d_map_destroy_t" : "fclaw_map_destroy_t", + "FCLAW2D_MAP_QUERY" : "FCLAW_MAP_QUERY", + "fclaw2d_map_query" : "fclaw_map_query", + "FCLAW2D_MAP_C2M" : "FCLAW_MAP_2D_C2M", + "fclaw2d_map_c2m" : "fclaw_map_2d_c2m", + "FCLAW2D_MAP_C2M_BASIS" : "FCLAW_MAP_2D_C2M_BASIS", + "fclaw2d_map_c2m_basis" : "fclaw_map_2d_c2m_basis", + "FCLAW3D_MAP_C2M" : "FCLAW_MAP_3D_C2M", + "fclaw3d_map_c2m" : "fclaw_map_3d_c2m", + "FCLAW3D_MAP_C2M_BASIS" : "FCLAW_MAP_3D_C2M_BASIS", + "fclaw3d_map_c2m_basis" : "fclaw_map_3d_c2m_basis", + "FCLAW2D_MAP_BRICK2C" : "FCLAW_MAP_2D_BRICK2C", + "fclaw2d_map_brick2c" : "fclaw_map_2d_brick2c", + "fclaw2d_map_destroy" : "fclaw_map_destroy", + "fclaw2d_map_new_nomap_brick" : "fclaw_map_new_nomap_brick", + "fclaw2d_map_pillowphere" : "fclaw_map_pillowsphere", + "fclaw2d_map_new_nomap" : "fclaw_map_new_nomap", + + #===== ./src/fclaw2d_map_query_defs.h ===== + "" : "", + "FCLAW2D_MAP_QUERY_IS_USED" : "FCLAW_MAP_QUERY_IS_USED", + "FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT" : "FCLAW_MAP_QUERY_IS_SCALEDSHIFT", + "FCLAW2D_MAP_QUERY_IS_AFFINE" : "FCLAW_MAP_QUERY_IS_AFFINE", + "FCLAW2D_MAP_QUERY_IS_NONLINEAR" : "FCLAW_MAP_QUERY_IS_NONLINEAR", + "FCLAW2D_MAP_QUERY_IS_CART" : "FCLAW_MAP_QUERY_IS_CART", + "FCLAW2D_MAP_QUERY_IS_GRAPH" : "FCLAW_MAP_QUERY_IS_GRAPH", + "FCLAW2D_MAP_QUERY_IS_PLANAR" : "FCLAW_MAP_QUERY_IS_PLANAR", + "FCLAW2D_MAP_QUERY_IS_ALIGNED" : "FCLAW_MAP_QUERY_IS_ALIGNED", + "FCLAW2D_MAP_QUERY_IS_FLAT" : "FCLAW_MAP_QUERY_IS_FLAT", + "FCLAW2D_MAP_QUERY_IS_SPHERE" : "FCLAW_MAP_QUERY_IS_SPHERE", + "FCLAW2D_MAP_QUERY_IS_DISK" : "FCLAW_MAP_QUERY_IS_DISK", + "FCLAW2D_MAP_QUERY_IS_PILLOWDISK" : "FCLAW_MAP_QUERY_IS_PILLOWDISK", + "FCLAW2D_MAP_QUERY_IS_SQUAREDDISK" : "FCLAW_MAP_QUERY_IS_SQUAREDDISK", + "FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE" : "FCLAW_MAP_QUERY_IS_PILLOWSPHERE", + "FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE" : "FCLAW_MAP_QUERY_IS_CUBEDSPHERE", + "FCLAW2D_MAP_QUERY_IS_FIVEPATCH" : "FCLAW_MAP_QUERY_IS_FIVEPATCH", + "FCLAW2D_MAP_QUERY_IS_BILINEAR" : "FCLAW_MAP_QUERY_IS_BILINEAR", + "FCLAW2D_MAP_QUERY_IS_HEMISPHERE" : "FCLAW_MAP_QUERY_IS_HEMISPHERE", + "FCLAW2D_MAP_QUERY_IS_TORUS" : "FCLAW_MAP_QUERY_IS_TORUS", + "FCLAW2D_MAP_QUERY_IS_BRICK" : "FCLAW_MAP_QUERY_IS_BRICK", + "FCLAW2D_MAP_QUERY_LAST" : "FCLAW_MAP_QUERY_LAST", + + #===== ./src/fclaw2d_map_query.h ===== + "" : "", + "FCLAW2D_MAP_IS_USED" : "FCLAW_MAP_IS_USED", + "FCLAW2D_MAP_IS_CART" : "FCLAW_MAP_IS_CART", + "FCLAW2D_MAP_IS_AFFINE" : "FCLAW_MAP_IS_AFFINE", + "FCLAW2D_MAP_IS_DISK" : "FCLAW_MAP_IS_DISK", + "FCLAW2D_MAP_IS_PILLOWDISK" : "FCLAW_MAP_IS_PILLOWDISK", + "FCLAW2D_MAP_IS_SQUAREDDISK" : "FCLAW_MAP_IS_SQUAREDDISK", + "FCLAW2D_MAP_IS_PILLOWSPHERE" : "FCLAW_MAP_IS_PILLOWSPHERE", + "FCLAW2D_MAP_IS_CUBEDSPHERE" : "FCLAW_MAP_IS_CUBEDSPHERE", + "FCLAW2D_MAP_IS_FLAT" : "FCLAW_MAP_IS_FLAT", + "FCLAW2D_MAP_IS_SPHERE" : "FCLAW_MAP_IS_SPHERE", + "FCLAW2D_MAP_IS_HEMISPHERE" : "FCLAW_MAP_IS_HEMISPHERE", + "FCLAW2D_MAP_IS_TORUS" : "FCLAW_MAP_IS_TORUS", + "FCLAW2D_MAP_IS_BRICK" : "FCLAW_MAP_IS_BRICK", + "fclaw2d_map_query_last" : "fclaw_map_query_last", + "fclaw2d_map_is_used" : "fclaw_map_is_used", + "fclaw2d_map_is_cart" : "fclaw_map_is_cart", + "fclaw2d_map_is_affine" : "fclaw_map_is_affine", + "fclaw2d_map_is_disk" : "fclaw_map_is_disk", + "fclaw2d_map_is_pillowdisk" : "fclaw_map_is_pillowdisk", + "fclaw2d_map_is_squareddisk" : "fclaw_map_is_squareddisk", + "fclaw2d_map_is_pillowsphere" : "fclaw_map_is_pillowsphere", + "fclaw2d_map_is_cubedsphere" : "fclaw_map_is_cubedsphere", + "fclaw2d_map_is_flat" : "fclaw_map_is_flat", + "fclaw2d_map_is_sphere" : "fclaw_map_is_sphere", + "fclaw2d_map_is_hemisphere" : "fclaw_map_is_hemisphere", + "fclaw2d_map_is_torus" : "fclaw_map_is_torus", + "fclaw2d_map_is_brick" : "fclaw_map_is_brick", + + "MAPC2M_IDENTITY" : "FCLAW_MAP_2D_C2M_IDENTITY", + "MAPC2M_CART" : "FCLAW_MAP_2D_C2M_CART", + "MAPC2M_PILLOWDISK" : "FCLAW_MAP_2D_C2M_PILLOWDISK", + "MAPC2M_PILLOWDISK5" : "FCLAW_MAP_2D_C2M_PILLOWDISK5", + "MAPC2M_SQUAREDDISK" : "FCLAW_MAP_2D_C2M_SQUAREDDISK", + "MAPC2M_FIVEPATCH" : "FCLAW_MAP_2D_C2M_FIVEPATCH", + "MAPC2M_CUBEDSPHERE" : "FCLAW_MAP_2D_C2M_CUBEDSPHERE", + "MAPC2M_PILLOWSPHERE" : "FCLAW_MAP_2D_C2M_PILLOWSPHERE", + "MAPC2M_TORUS" : "FCLAW_MAP_2D_C2M_TORUS", + "MAPC2M_TWISTED_TORUS" : "FCLAW_MAP_2D_C2M_TWISTED_TORUS", + "MAPC2M_BRICK" : "FCLAW_MAP_2D_C2M_BRICK", + "MAPC2M_LATLONG" : "FCLAW_MAP_2D_C2M_LATLONG", + "MAPC2M_ANNULUS" : "FCLAW_MAP_2D_C2M_ANNULUS", + + "mapc2m_identity" : "fclaw_map_2d_c2m_identity", + "mapc2m_cart" : "fclaw_map_2d_c2m_cart", + "mapc2m_pillowdisk" : "fclaw_map_2d_c2m_pillowdisk", + "mapc2m_pillowdisk5" : "fclaw_map_2d_c2m_pillowdisk5", + "mapc2m_squareddisk" : "fclaw_map_2d_c2m_squareddisk", + "mapc2m_fivepatch" : "fclaw_map_2d_c2m_fivepatch", + "mapc2m_cubedsphere" : "fclaw_map_2d_c2m_cubedsphere", + "mapc2m_pillowsphere" : "fclaw_map_2d_c2m_pillowsphere", + "mapc2m_torus" : "fclaw_map_2d_c2m_torus", + "mapc2m_twisted_torus" : "fclaw_map_2d_c2m_twisted_torus", + "mapc2m_brick" : "fclaw_map_2d_c2m_brick", + "mapc2m_latlong" : "fclaw_map_2d_c2m_latlong", + "mapc2m_annulus" : "fclaw_map_2d_c2m_annulus", + + #===== ./src/fclaw2d_map_brick.h ===== + "" : "", + "fclaw2d_map_brick_get_dim" : "fclaw_map_brick_get_2d_dim", + "FCLAW2D_MAP_BRICK_GET_DIM" : "FCLAW_MAP_BRICK_GET_2D_DIM", + "fclaw2d_block_ll" : "fclaw_block_ll", + "fclaw2d_block_ll_t" : "fclaw_block_ll_t", + "fclaw2d_map_new_brick" : "fclaw_map_new_2d_brick", + "fclaw2d_map_destroy_brick" : "fclaw_map_destroy_brick", + +} + +import glob +import argparse +import re +try: + import pygments +except ModuleNotFoundError: + print("The 'pygments' module is not installed.") + print("This is needed for tokenizing the source code.") + print("You can install it by running 'pip install pygments' or 'pip3 install pygments'.") + exit(1) # Exit the script with an error code +import pygments.lexers +from pygments.token import Token + +def replace_preproc_identifiers(token, identifier_map): + # Function to replace each match + def replace_match(match): + identifier = match.group(0) + new_identifier = identifier_map.get(identifier, identifier) + return new_identifier + + # Replace the identifiers based on the replacement map + new_token = re.sub(r'\b[A-Za-z_][A-Za-z0-9_]*\b', replace_match, token) + return new_token + +def replace_identifiers_and_includes(filepath, code, identifier_map): + lexer = pygments.lexers.get_lexer_for_filename(filepath, stripnl=False, ensurenl=False) + tokens = lexer.get_tokens(code) + new_code = '' + + changes = False + + for ttype, value in tokens: + if ttype in Token.Comment.Preproc: + new_value = replace_preproc_identifiers(value, identifier_map) + changes = changes or (new_value != value) + new_code += new_value + elif ttype in Token.Comment.PreprocFile: + new_value = identifier_map.get(value, value) + changes = changes or (new_value != value) + new_code += new_value + elif ttype in Token.Name: + new_value = identifier_map.get(value, value) + changes = changes or (new_value != value) + new_code += new_value + else: + new_code += value + + return new_code, changes + +def process_file(filepath, identifier_map): + # Read the existing code from the file + with open(filepath, 'r') as f: + old_code = f.read() + + # Replace the identifiers + new_code, changes = replace_identifiers_and_includes(filepath, old_code, identifier_map) + + if changes: + print(f"Upadated {filepath}...") + # Write the new code back to the file + with open(filepath, 'w') as f: + f.write(new_code) + + +def process_directory(root_dir, identifier_map, excluded_files=[]): + # Use glob to find all C++ files recursively. + for filepath in [f for f in glob.glob(f"{root_dir}/**/*", recursive=True) if f.lower().endswith(('.c', '.h', '.cpp', '.hpp', '.f', '.f90', '.cu')) and f not in excluded_files]: + process_file(filepath, identifier_map) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="A simple script to demonstrate argparse.") + parser.add_argument("-d", "--directory", help="directory to recursively update files in") + parser.add_argument("-f", "--files", nargs="+", help="files to convert") + + args = parser.parse_args() + print("Processing files...") + if(args.directory is not None): + process_directory(args.directory, fclaw_1to2) + if(args.files is not None): + for file in args.files: + process_file(file, fclaw_1to2) + + print("Done!") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 793790e70..ea7dd71c4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,63 +2,59 @@ # -- c library add_library(forestclaw_c OBJECT + forestclaw.c + fclaw_convenience.c fclaw_base.c fclaw_options.c fclaw_filesystem.cpp - fclaw_gauges.c - fclaw_package.c + fclaw_gauges.c + fclaw_package.c fclaw_packing.c fclaw_pointer_map.c fclaw_math.c fclaw_timer.c fclaw_mpi.c - fclaw2d_block.c - fclaw2d_options.c - fclaw2d_global.c - fclaw2d_forestclaw.c - fclaw2d_vtable.c - fclaw2d_map.c - fclaw2d_map_query.c - fclaw2d_map_brick.c + fclaw_block.c + fclaw_global.c + fclaw_forestclaw.c + fclaw_vtable.c + fclaw_map.c + fclaw_map_query.c + fclaw_map_brick.c + fclaw_exchange.c + fclaw_advance.c + fclaw_elliptic_solver.c + fclaw_physical_bc.c + fclaw_ghost_fill.c + fclaw_output.c + fclaw_run.c + fclaw_diagnostics.c + fclaw_rays.c + fclaw_update_single_step.c + fclaw_domain.c + fclaw_regrid.c + fclaw_patch.c + fclaw_partition.c + fclaw_timeinterp.c + fclaw_initialize.c + fclaw_finalize.c + fclaw_time_sync.c + fclaw_corner_neighbors.c + fclaw_edge_neighbors.c + fclaw_face_neighbors.c + fclaw_farraybox.cpp fclaw2d_convenience.c - fclaw2d_exchange.c - fclaw2d_advance.c - fclaw2d_elliptic_solver.c - fclaw2d_physical_bc.c - fclaw2d_ghost_fill.c - fclaw2d_output.c - fclaw2d_run.c - fclaw2d_diagnostics.c - fclaw2d_rays.c - fclaw2d_update_single_step.c - fclaw2d_domain.c - fclaw2d_regrid.c - fclaw2d_patch.c - fclaw2d_partition.c - fclaw2d_timeinterp.c - fclaw2d_initialize.c - fclaw2d_finalize.c - fclaw2d_time_sync.c - fclaw2d_corner_neighbors.c - fclaw2d_face_neighbors.c - fclaw2d_farraybox.cpp fclaw2d_output_tikz.c fclaw2d_file.c + fclaw2d_wrap.c forestclaw2d.c forestclaw3d.c fclaw3d_convenience.c - fclaw3d_domain.c - fclaw3d_global.c - fclaw3d_map.c - fclaw3d_patch.c - fclaw3d_exchange.c - fclaw3d_options.c fclaw3d_file.c - fclaw_domain.c - fclaw_global.c + fclaw3d_wrap.c fp_exception_glibc_extension.c - mappings/fclaw2d_map_nomap.c - mappings/fclaw2d_map_nomap_brick.c + mappings/fclaw_map_nomap.c + mappings/fclaw_map_nomap_brick.c ) target_include_directories(forestclaw_c PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include patches/clawpatch) target_link_libraries(forestclaw_c PRIVATE P4EST::P4EST SC::SC) @@ -115,6 +111,8 @@ add_library(FORESTCLAW::FORESTCLAW INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::FORESTCLAW INTERFACE forestclaw) install(FILES + forestclaw.h + fclaw_convenience.h fclaw_base.h fclaw_timer.h fclaw_package.h @@ -125,74 +123,64 @@ install(FILES fclaw_gauges.h fclaw_mpi.h fclaw_math.h + fclaw_wrap.h + fclaw_include_all.h + fclaw_advance.h + fclaw_elliptic_solver.h + fclaw_farraybox.hpp + fclaw_global.h + fclaw_forestclaw.h + fclaw_domain.h + fclaw_block.h + fclaw_patch.h + fclaw_vtable.h + fclaw_output.h + fclaw_time_sync.h + fclaw_update_single_step.h + fclaw_physical_bc.h + fclaw_rays.h + fclaw_ghost_fill.h + fclaw_corner_neighbors.h + fclaw_edge_neighbors.h + fclaw_face_neighbors.h + fclaw_map.h + fclaw_timeinterp.h + fclaw_regrid.h + fclaw_map_brick.h + fclaw_partition.h + fclaw_exchange.h + fclaw_map_query.h + fclaw_map_query_defs.h + fclaw_diagnostics.h forestclaw2d.h fp_exception_glibc_extension.h - fclaw2d_include_all.h + fclaw2d_convenience.h fclaw2d_defs.h - fclaw2d_options.h - fclaw2d_advance.h - fclaw2d_elliptic_solver.h - fclaw2d_farraybox.hpp - fclaw2d_global.h - fclaw2d_forestclaw.h - fclaw2d_domain.h - fclaw2d_block.h - fclaw2d_patch.h - fclaw2d_vtable.h - fclaw2d_output.h - fclaw2d_time_sync.h - fclaw2d_update_single_step.h - fclaw2d_physical_bc.h - fclaw2d_rays.h - fclaw2d_ghost_fill.h - fclaw2d_corner_neighbors.h - fclaw2d_face_neighbors.h - fclaw2d_map.h - fclaw2d_timeinterp.h - fclaw2d_regrid.h - fclaw2d_map_brick.h - fclaw2d_partition.h - fclaw2d_exchange.h - fclaw2d_convenience.h - fclaw2d_map_query.h - fclaw2d_map_query_defs.h - fclaw2d_diagnostics.h fclaw2d_file.h + fclaw2d_wrap.h fclaw2d_to_3d.h forestclaw3d.h fclaw3d_convenience.h fclaw3d_defs.h - fclaw3d_domain.h - fclaw3d_global.h - fclaw3d_map.h - fclaw3d_patch.h - fclaw3d_exchange.h - fclaw3d_options.h - fclaw3d_include_all.h fclaw3d_file.h - fclaw_patch.h - fclaw_domain.h - fclaw_global.h + fclaw3d_wrap.h DESTINATION include ) install(TARGETS forestclaw - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) if(BUILD_TESTING) add_executable(forestclaw.TEST fclaw_gauges.h.TEST.cpp fclaw_packing.h.TEST.cpp fclaw_pointer_map.h.TEST.cpp - fclaw2d_elliptic_solver.h.TEST.cpp - fclaw2d_diagnostics.h.TEST.cpp - fclaw2d_global.h.TEST.cpp - fclaw2d_options.h.TEST.cpp - fclaw2d_patch.h.TEST.cpp - fclaw2d_vtable.h.TEST.cpp + fclaw_elliptic_solver.h.TEST.cpp + fclaw_diagnostics.h.TEST.cpp + fclaw_global.h.TEST.cpp + fclaw_options.h.TEST.cpp + fclaw_patch.h.TEST.cpp + fclaw_vtable.h.TEST.cpp ) target_link_libraries(forestclaw.TEST testutils forestclaw) diff --git a/src/Makefile.am b/src/Makefile.am index e40180d43..41c34e2b3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,9 @@ libforestclaw_generated_headers = src/fclaw_config.h libforestclaw_installed_headers = \ + src/forestclaw.h \ + src/fclaw_convenience.h \ + src/fclaw_wrap.h \ src/fclaw_base.h \ src/fclaw_timer.h \ src/fclaw_package.h \ @@ -15,54 +18,46 @@ libforestclaw_installed_headers = \ src/fclaw_gauges.h \ src/fclaw_mpi.h \ src/fclaw_math.h \ - src/forestclaw2d.h \ - src/fp_exception_glibc_extension.h \ - src/fclaw2d_include_all.h \ src/fclaw2d_defs.h \ - src/fclaw2d_options.h \ - src/fclaw2d_advance.h \ - src/fclaw2d_elliptic_solver.h \ - src/fclaw2d_farraybox.hpp \ - src/fclaw2d_global.h \ - src/fclaw2d_forestclaw.h \ - src/fclaw2d_domain.h \ - src/fclaw2d_block.h \ - src/fclaw2d_patch.h \ - src/fclaw2d_vtable.h \ - src/fclaw2d_output.h \ - src/fclaw2d_time_sync.h \ - src/fclaw2d_update_single_step.h \ - src/fclaw2d_physical_bc.h \ - src/fclaw2d_rays.h \ - src/fclaw2d_ghost_fill.h \ - src/fclaw2d_corner_neighbors.h \ - src/fclaw2d_face_neighbors.h \ - src/fclaw2d_map.h \ - src/fclaw2d_timeinterp.h \ - src/fclaw2d_regrid.h \ - src/fclaw2d_map_brick.h \ - src/fclaw2d_partition.h \ - src/fclaw2d_exchange.h \ + src/fclaw_include_all.h \ + src/fclaw_advance.h \ + src/fclaw_elliptic_solver.h \ + src/fclaw_farraybox.hpp \ + src/fclaw_global.h \ + src/fclaw_forestclaw.h \ + src/fclaw_domain.h \ + src/fclaw_block.h \ + src/fclaw_patch.h \ + src/fclaw_vtable.h \ + src/fclaw_output.h \ + src/fclaw_time_sync.h \ + src/fclaw_update_single_step.h \ + src/fclaw_physical_bc.h \ + src/fclaw_rays.h \ + src/fclaw_ghost_fill.h \ + src/fclaw_corner_neighbors.h \ + src/fclaw_edge_neighbors.h \ + src/fclaw_face_neighbors.h \ + src/fclaw_map.h \ + src/fclaw_timeinterp.h \ + src/fclaw_regrid.h \ + src/fclaw_map_brick.h \ + src/fclaw_partition.h \ + src/fclaw_exchange.h \ + src/fclaw_map_query.h \ + src/fclaw_map_query_defs.h \ + src/fclaw_diagnostics.h \ + src/forestclaw2d.h \ src/fclaw2d_convenience.h \ - src/fclaw2d_map_query.h \ - src/fclaw2d_map_query_defs.h \ - src/fclaw2d_diagnostics.h \ + src/fp_exception_glibc_extension.h \ src/fclaw2d_file.h \ + src/fclaw2d_wrap.h \ src/fclaw2d_to_3d.h \ src/forestclaw3d.h \ - src/fclaw3d_include_all.h \ src/fclaw3d_defs.h \ - src/fclaw3d_exchange.h \ - src/fclaw3d_options.h \ - src/fclaw3d_patch.h \ - src/fclaw3d_domain.h \ - src/fclaw3d_global.h \ src/fclaw3d_convenience.h \ - src/fclaw3d_map.h \ src/fclaw3d_file.h \ - src/fclaw_patch.h \ - src/fclaw_domain.h \ - src/fclaw_global.h + src/fclaw3d_wrap.h libforestclaw_internal_headers = @@ -71,6 +66,8 @@ libforestclaw_internal_headers = # ------------------------------------------------------------------- libforestclaw_compiled_sources = \ + src/forestclaw.c \ + src/fclaw_convenience.c \ src/fclaw_base.c \ src/fclaw_options.c \ src/fclaw_gauges.c \ @@ -81,50 +78,44 @@ libforestclaw_compiled_sources = \ src/fclaw_math.c \ src/fclaw_timer.c \ src/fclaw_mpi.c \ - src/fclaw2d_block.c \ - src/fclaw2d_options.c \ - src/fclaw2d_global.c \ - src/fclaw2d_forestclaw.c \ - src/fclaw2d_vtable.c \ - src/fclaw2d_map.c \ - src/fclaw2d_map_query.c \ - src/fclaw2d_map_brick.c \ + src/fclaw_block.c \ + src/fclaw_global.c \ + src/fclaw_forestclaw.c \ + src/fclaw_vtable.c \ + src/fclaw_map.c \ + src/fclaw_map_query.c \ + src/fclaw_map_brick.c \ + src/fclaw_exchange.c \ + src/fclaw_advance.c \ + src/fclaw_elliptic_solver.c \ + src/fclaw_physical_bc.c \ + src/fclaw_rays.c \ + src/fclaw_ghost_fill.c \ + src/fclaw_output.c \ + src/fclaw_run.c \ + src/fclaw_diagnostics.c \ + src/fclaw_update_single_step.c \ + src/fclaw_domain.c \ + src/fclaw_regrid.c \ + src/fclaw_patch.c \ + src/fclaw_partition.c \ + src/fclaw_timeinterp.c \ + src/fclaw_initialize.c \ + src/fclaw_finalize.c \ + src/fclaw_time_sync.c \ + src/fclaw_corner_neighbors.c \ + src/fclaw_edge_neighbors.c \ + src/fclaw_face_neighbors.c \ + src/fclaw_farraybox.cpp \ src/fclaw2d_convenience.c \ - src/fclaw2d_exchange.c \ - src/fclaw2d_advance.c \ - src/fclaw2d_elliptic_solver.c \ - src/fclaw2d_physical_bc.c \ - src/fclaw2d_rays.c \ - src/fclaw2d_ghost_fill.c \ - src/fclaw2d_output.c \ - src/fclaw2d_run.c \ - src/fclaw2d_diagnostics.c \ - src/fclaw2d_update_single_step.c \ - src/fclaw2d_domain.c \ - src/fclaw2d_regrid.c \ - src/fclaw2d_patch.c \ - src/fclaw2d_partition.c \ - src/fclaw2d_timeinterp.c \ - src/fclaw2d_initialize.c \ - src/fclaw2d_finalize.c \ - src/fclaw2d_time_sync.c \ - src/fclaw2d_corner_neighbors.c \ - src/fclaw2d_face_neighbors.c \ - src/fclaw2d_farraybox.cpp \ src/fclaw2d_output_tikz.c \ src/fclaw2d_file.c \ + src/fclaw2d_wrap.c \ src/forestclaw2d.c \ src/forestclaw3d.c \ src/fclaw3d_convenience.c \ - src/fclaw3d_domain.c \ - src/fclaw3d_exchange.c \ - src/fclaw3d_options.c \ - src/fclaw3d_patch.c \ - src/fclaw3d_global.c \ - src/fclaw3d_map.c \ src/fclaw3d_file.c \ - src/fclaw_domain.c \ - src/fclaw_global.c \ + src/fclaw3d_wrap.c \ src/fp_exception_glibc_extension.c \ src/mappings/context.f \ src/mappings/scale_rot_map.f \ @@ -142,8 +133,8 @@ libforestclaw_compiled_sources = \ src/mappings/torus/mapc2m_torus.f \ src/mappings/torus/mapc2m_twisted_torus.f \ src/mappings/latlong/mapc2m_latlong.f \ - src/mappings/fclaw2d_map_nomap.c \ - src/mappings/fclaw2d_map_nomap_brick.c \ + src/mappings/fclaw_map_nomap.c \ + src/mappings/fclaw_map_nomap_brick.c \ src/fortran_source2d/fclaw_dopri5.f \ src/fortran_source2d/cellave2.f \ src/fortran_source2d/cellave3.f \ @@ -198,12 +189,12 @@ TESTS += src/forestclaw.TEST src_forestclaw_TEST_SOURCES = \ src/fclaw_gauges.h.TEST.cpp \ src/fclaw_pointer_map.h.TEST.cpp \ - src/fclaw2d_elliptic_solver.h.TEST.cpp \ - src/fclaw2d_diagnostics.h.TEST.cpp \ - src/fclaw2d_global.h.TEST.cpp \ - src/fclaw2d_options.h.TEST.cpp \ - src/fclaw2d_patch.h.TEST.cpp \ - src/fclaw2d_vtable.h.TEST.cpp + src/fclaw_elliptic_solver.h.TEST.cpp \ + src/fclaw_diagnostics.h.TEST.cpp \ + src/fclaw_global.h.TEST.cpp \ + src/fclaw_options.h.TEST.cpp \ + src/fclaw_patch.h.TEST.cpp \ + src/fclaw_vtable.h.TEST.cpp src_forestclaw_TEST_CPPFLAGS = \ $(test_libtestutils_la_CPPFLAGS) \ diff --git a/src/_fclaw2d_to_fclaw3d.h b/src/_fclaw2d_to_fclaw3d.h deleted file mode 100644 index 729b8d5a7..000000000 --- a/src/_fclaw2d_to_fclaw3d.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -//Metric terms -#define fclaw2d_metric_vtable_t fclaw3d_metric_vtable_t -#define fclaw2d_metric_vt fclaw3d_metric_vt -#define fclaw2d_metric_patch_scalar fclaw3d_metric_patch_scalar -#define fclaw2d_metric_patch_new fclaw3d_metric_patch_new -#define fclaw2d_metric_patch_delete fclaw3d_metric_patch_delete -#define fclaw2d_metric_patch_build fclaw3d_metric_patch_build -#define fclaw2d_metric_patch_build_from_fine fclaw3d_metric_patch_build_from_fine -#define fclaw2d_metric_vtable_initialize fclaw3d_metric_vtable_initialize -#define fclaw2d_metric_patch_get_area fclaw3d_metric_patch_get_volume -#define fclaw2d_metric_get_metric_patch fclaw3d_metric_get_metric_patch -#define fclaw2d_metric_patch_compute_area fclaw3d_metric_patch_compute_volume -#define fclaw2d_metric_vtable_initialize fclaw3d_metric_vtable_initialize -#define fclaw2d_metric_patch_nodes_size fclaw3d_metric_patch_nodes_size - -// static names -#define metric_average_area_from_fine metric_average_volume_from_fine - -// fclaw3d_metric.hpp -#define fclaw2d_metric_patch_t fclaw3d_metric_patch_t - -//For Clawpatch -#define fclaw2d_clawpatch_get_metric_patch fclaw3d_clawpatch_get_metric_patch -#define fclaw2d_clawpatch_metric_scalar fclaw3d_clawpatch_metric_scalar -#define fclaw2d_clawpatch_metric_vector fclaw3d_clawpatch_metric_basis -#define fclaw2d_clawpatch_metric_data fclaw3d_clawpatch_metric_data -#define fclaw2d_clawpatch_get_area fclaw3d_clawpatch_get_volume -#define clawpatch_get_area clawpatch_get_volume - - -#if 0 -// ForestClaw files -#define fclaw2d_map_context_t fclaw2d_map_context_t -#define fclaw2d_map_destroy fclaw2d_map_destroy -#define fclaw2d_map_query fclaw2d_map_query -#endif - - - - - diff --git a/src/_fclaw2d_to_fclaw3dx.h b/src/_fclaw2d_to_fclaw3dx.h deleted file mode 100644 index 4ad9e416f..000000000 --- a/src/_fclaw2d_to_fclaw3dx.h +++ /dev/null @@ -1,162 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -//fclaw2d_clawpatch_conservation.h -#define fclaw2d_clawpatch_registers_t fclaw3dx_clawpatch_registers_t -#define fclaw2d_clawpatch_registers fclaw3dx_clawpatch_registers -#define fclaw2d_clawpatch_packmode fclaw3dx_clawpatch_packmode -#define fclaw2d_clawpatch_fort_time_sync_f2c_t fclaw3dx_clawpatch_fort_time_sync_f2c_t -#define fclaw2d_clawpatch_fort_time_sync_samesize_t fclaw3dx_clawpatch_fort_time_sync_samesize_t -#define fclaw2d_clawpatch_time_sync_new fclaw3dx_clawpatch_time_sync_new -#define fclaw2d_clawpatch_time_sync_delete fclaw3dx_clawpatch_time_sync_delete -#define fclaw2d_clawpatch_time_sync_setup fclaw3dx_clawpatch_time_sync_setup -#define fclaw2d_clawpatch_time_sync_f2c fclaw3dx_clawpatch_time_sync_f2c -#define fclaw2d_clawpatch_time_sync_samesize fclaw3dx_clawpatch_time_sync_samesize -#define fclaw2d_clawpatch_time_sync_reset fclaw3dx_clawpatch_time_sync_reset -#define fclaw2d_clawpatch_time_sync_pack_registers fclaw3dx_clawpatch_time_sync_pack_registers - -//fclaw2d_clawpatch_diagnostics.h -#define error_info_t fclaw3dx_clawpatch_error_info_t -#define fclaw2d_clawpatch_diagnostics_initialize fclaw3dx_clawpatch_diagnostics_initialize -#define fclaw2d_clawpatch_diagnostics_compute fclaw3dx_clawpatch_diagnostics_compute -#define fclaw2d_clawpatch_diagnostics_gather fclaw3dx_clawpatch_diagnostics_gather -#define fclaw2d_clawpatch_diagnostics_reset fclaw3dx_clawpatch_diagnostics_reset -#define fclaw2d_clawpatch_diagnostics_finalize fclaw3dx_clawpatch_diagnostics_finalize -#define fclaw2d_clawpatch_diagnostics_vtable_initialize fclaw3dx_clawpatch_diagnostics_vtable_initialize -#define fclaw2d_clawpatch_diagnostics_cons_default fclaw3dx_clawpatch_diagnostics_cons_default -#define fclaw2d_clawpatch_diagnostics_error_default fclaw3dx_clawpatch_diagnostics_error_default - -//fclaw2d_clawpatch_fort.h -#define clawpatch_fort_copy_face_t fclaw3dx_clawpatch_fort_copy_face_t -#define clawpatch_fort_average_face_t fclaw3dx_clawpatch_fort_average_face_t -#define clawpatch_fort_interpolate_face_t fclaw3dx_clawpatch_fort_interpolate_face_t -#define clawpatch_fort_copy_corner_t fclaw3dx_clawpatch_fort_copy_corner_t -#define clawpatch_fort_average_corner_t fclaw3dx_clawpatch_fort_average_corner_t -#define clawpatch_fort_interpolate_corner_t fclaw3dx_clawpatch_fort_interpolate_corner_t -#define clawpatch_fort_tag4refinement_t fclaw3dx_clawpatch_fort_tag4refinement_t -#define clawpatch_fort_tag4coarsening_t fclaw3dx_clawpatch_fort_tag4coarsening_t -#define clawpatch_fort_exceeds_threshold_t fclaw3dx_clawpatch_fort_exceeds_threshold_t -#define clawpatch_fort_interpolate2fine_t fclaw3dx_clawpatch_fort_interpolate2fine_t -#define clawpatch_fort_average2coarse_t fclaw3dx_clawpatch_fort_average2coarse_t -#define clawpatch_fort_timeinterp_t fclaw3dx_clawpatch_fort_timeinterp_t -#define clawpatch_fort_local_ghost_pack_t fclaw3dx_clawpatch_fort_local_ghost_pack_t -#define clawpatch_fort_header_ascii_t fclaw3dx_clawpatch_fort_header_ascii_t -#define clawpatch_fort_output_ascii_t fclaw3dx_clawpatch_fort_output_ascii_t -#define clawpatch_fort_error_t fclaw3dx_clawpatch_fort_error_t -#define clawpatch_fort_conscheck_t fclaw3dx_clawpatch_fort_conscheck_t -//#define clawpatch_fort_area_t fclaw3dx_clawpatch_fort_area_t -#define clawpatch_fort_norm_t fclaw3dx_clawpatch_fort_norm_t -#define FCLAW2D_CLAWPATCH_GET_REFINEMENT_CRITERIA FCLAW3DX_CLAWPATCH_GET_REFINEMENT_CRITERIA -#define FCLAW2D_CLAWPATCH_EXCEEDS_THRESHOLD FCLAW3DX_CLAWPATCH_EXCEEDS_THRESHOLD - -//fclaw2d_clawpatch_options.h -#define fclaw2d_clawpatch_options_t fclaw3dx_clawpatch_options_t -#define fclaw2d_clawpatch_options fclaw3dx_clawpatch_options -#define fclaw2d_clawpatch_options_register fclaw3dx_clawpatch_options_register -#define fclaw2d_clawpatch_options_store fclaw3dx_clawpatch_options_store -#define fclaw2d_clawpatch_get_options fclaw3dx_clawpatch_get_options -#define fclaw2d_clawpatch_set_refinement_criteria fclaw3dx_clawpatch_set_refinement_criteria -#define fclaw2d_clawpatch_get_refinement_criteria fclaw3dx_clawpatch_get_refinement_criteria -#define fclaw2d_clawpatch_options_get_packing_vtable fclaw3dx_clawpatch_options_get_packing_vtable - -//fclaw2d_clawpatch_output_ascii.h -#define cb_clawpatch_output_ascii fclaw3dx_clawpatch_output_ascii_cb -#define fclaw2d_clawpatch_output_ascii fclaw3dx_clawpatch_output_ascii -#define fclaw2d_clawpatch_time_header_ascii fclaw3dx_clawpatch_time_header_ascii - -//fclaw2d_clawpatch_output_vtk.h -#define fclaw2d_vtk_patch_data_t fclaw3dx_vtk_patch_data_t -#define fclaw2d_vtk_write_file fclaw3dx_vtk_write_file -#define fclaw2d_clawpatch_output_vtk fclaw3dx_clawpatch_output_vtk - -//fclaw2d_clawpatch_pillow.h -#define fclaw2d_clawpatch_pillow_vtable_t fclaw3dx_clawpatch_pillow_vtable_t -#if 0 -#define pillow_fort_copy_block_corner_t fclaw3dx_clawpatch_pillow_fort_copy_block_corner_t -#define pillow_fort_average_block_corner_t fclaw3dx_clawpatch_pillow_fort_average_block_corner_t -#define pillow_fort_interpolate_block_corner_t fclaw3dx_clawpatch_pillow_fort_interpolate_block_corner_t -#endif -#define fclaw2d_clawpatch_use_pillowsphere fclaw3dx_clawpatch_use_pillowsphere -#define fclaw2d_clawpatch_pillow_vtable_initialize fclaw3dx_clawpatch_pillow_vtable_initialize -#define fclaw2d_clawpatch_pillow_vtable fclaw3dx_clawpatch_pillow_vtable -#define fclaw2d_clawpatch_pillow_vt fclaw3dx_clawpatch_pillow_vt - -//fclaw2d_clawpatch_transform.h -#define fclaw2d_clawpatch_transform_init_data fclaw3dx_clawpatch_transform_init_data -#define fclaw2d_clawpatch_face_transformation fclaw3dx_clawpatch_face_transformation -#define fclaw2d_clawpatch_face_transformation_intra fclaw3dx_clawpatch_face_transformation_intra -#define FCLAW2D_CLAWPATCH_TRANSFORM_FACE FCLAW3DX_CLAWPATCH_TRANSFORM_FACE -#define FCLAW2D_CLAWPATCH_TRANSFORM_FACE_HALF FCLAW3DX_CLAWPATCH_TRANSFORM_FACE_HALF -#define FCLAW2D_CLAWPATCH_TRANSFORM_CORNER FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER -#define FCLAW2D_CLAWPATCH_TRANSFORM_CORNER_HALF FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER_HALF - -//fclaw2d_clawpatch.h -#define fclaw2d_clawpatch_vtable_t fclaw3dx_clawpatch_vtable_t -#define fclaw2d_clawpatch_set_user_data_t fclaw3dx_clawpatch_set_user_data_t -#define fclaw2d_clawpatch_time_sync_pack_registers_t fclaw3dx_clawpatch_time_sync_pack_registers_t -#define fclaw2d_clawpatch_local_ghost_pack_aux_t fclaw3dx_clawpatch_local_ghost_pack_aux_t -#define fclaw2d_clawpatch_fort_local_ghost_pack_registers_t fclaw3dx_clawpatch_fort_local_ghost_pack_registers_t -#define fclaw2d_clawpatch_time_header_t fclaw3dx_clawpatch_time_header_t -#define fclaw2d_clawpatch_diagnostics_cons_t fclaw3dx_clawpatch_diagnostics_cons_t -#define fclaw2d_clawpatch_diagnostics_error_t fclaw3dx_clawpatch_diagnostics_error_t -#define fclaw2d_clawpatch_vtable_initialize fclaw3dx_clawpatch_vtable_initialize -#define fclaw2d_clawpatch_vt fclaw3dx_clawpatch_vt -#define fclaw2d_clawpatch_vtable fclaw3dx_clawpatch_vtable -#define fclaw2d_clawpatch_save_current_step fclaw3dx_clawpatch_save_current_step -#define fclaw2d_clawpatch_grid_data fclaw3dx_clawpatch_grid_data - -#if 0 -/* These are included in 3d files */ -#define fclaw2d_clawpatch_metric_scalar fclaw3dx_clawpatch_metric_scalar -#define fclaw2d_clawpatch_metric_vector fclaw3dx_clawpatch_metric_vector -#define fclaw2d_clawpatch_metric_data fclaw3dx_clawpatch_metric_data -#define fclaw2d_clawpatch_metric_data2 fclaw3dx_clawpatch_metric_data2 -#endif - -//#define fclaw2d_clawpatch_get_area fclaw3dx_clawpatch_get_area -#define fclaw2d_clawpatch_soln_data fclaw3dx_clawpatch_soln_data -#define fclaw2d_clawpatch_aux_data fclaw3dx_clawpatch_aux_data -#define fclaw2d_clawpatch_rhs_data fclaw3dx_clawpatch_rhs_data -#define fclaw2d_clawpatch_elliptic_error_data fclaw3dx_clawpatch_elliptic_error_data -#define fclaw2d_clawpatch_elliptic_soln_data fclaw3dx_clawpatch_elliptic_soln_data -#define fclaw2d_clawpatch_get_q fclaw3dx_clawpatch_get_q -#define fclaw2d_clawpatch_get_error fclaw3dx_clawpatch_get_error -#define fclaw2d_clawpatch_get_exactsoln fclaw3dx_clawpatch_get_exactsoln -#define fclaw2d_clawpatch_size fclaw3dx_clawpatch_size -#define fclaw2d_clawpatch_get_user_data fclaw3dx_clawpatch_get_user_data -#define fclaw2d_clawpatch_set_user_data fclaw3dx_clawpatch_set_user_data -#define fclaw2d_clawpatch_get_solver_data fclaw3dx_clawpatch_get_solver_data -#define fclaw2d_clawpatch_set_solver_data fclaw3dx_clawpatch_set_solver_data -#define fclaw2d_clawpatch_timesync_data fclaw3dx_clawpatch_timesync_data -#define fclaw2d_clawpatch_get_q_timesync fclaw3dx_clawpatch_get_q_timesync -#define fclaw2d_clawpatch_get_registers fclaw3dx_clawpatch_get_registers - -//fclaw2d_clawpatch.hpp -#define fclaw2d_clawpatch_t fclaw3dx_clawpatch_t -#define fclaw2d_clawpatch_get_clawpatch fclaw3dx_clawpatch_get_clawpatch - -#if 0 -#define fclaw2d_clawpatch_get_metric_patch fclaw3dx_clawpatch_get_metric_patch -#endif \ No newline at end of file diff --git a/src/fclaw2d_convenience.c b/src/fclaw2d_convenience.c index cfc75e36a..9c174e2bf 100644 --- a/src/fclaw2d_convenience.c +++ b/src/fclaw2d_convenience.c @@ -324,16 +324,24 @@ fclaw2d_domain_new (p4est_wrap_t * wrap, sc_keyvalue_t * attributes) } fclaw2d_domain_t * -fclaw2d_domain_new_p4est (p4est_t *p4est) +fclaw2d_domain_new_p4est (p4est_t * p4est) { FCLAW_ASSERT (p4est != NULL); FCLAW_ASSERT (p4est->user_pointer == NULL); p4est_wrap_t *wrap; - - /* create p4est_wrap from the given p4est */ - wrap = p4est_wrap_new_p4est (p4est, 0, P4EST_CONNECT_FULL, NULL, NULL); - + p4est_wrap_params_t params; + + /* wrap the p4est with edgehanging corners neighbors enabled in the mesh */ + p4est_wrap_params_init (¶ms); + params.hollow = 0; + params.mesh_params.btype = P4EST_CONNECT_FULL; + params.mesh_params.compute_level_lists = 1; + params.mesh_params.compute_tree_index = 1; +#ifdef P4_TO_P8 + params.mesh_params.edgehanging_corners = 1; +#endif + wrap = p4est_wrap_new_p4est_params (p4est, ¶ms); FCLAW_ASSERT (wrap->p4est->data_size == 0); /* attributes of the created domain is initialized by sc_keyvalue_new */ @@ -352,41 +360,33 @@ fclaw2d_check_initial_level (sc_MPI_Comm mpicomm, int initial_level) "Initial level %d too fine for p4est", initial_level); } +#ifndef P4_TO_P8 fclaw2d_domain_t * fclaw2d_domain_new_unitsquare (sc_MPI_Comm mpicomm, int initial_level) { - fclaw2d_check_initial_level (mpicomm, initial_level); - return fclaw2d_domain_new (p4est_wrap_new_unitsquare (mpicomm, - initial_level), - NULL); + return fclaw2d_domain_new_conn (mpicomm, initial_level, + p4est_connectivity_new_unitsquare ()); } -#ifndef P4_TO_P8 - fclaw2d_domain_t * fclaw2d_domain_new_torus (sc_MPI_Comm mpicomm, int initial_level) { - fclaw2d_check_initial_level (mpicomm, initial_level); - return - fclaw2d_domain_new (p4est_wrap_new_periodic (mpicomm, initial_level), - NULL); + return fclaw2d_domain_new_conn (mpicomm, initial_level, + p4est_connectivity_new_periodic ()); } fclaw2d_domain_t * fclaw2d_domain_new_twosphere (sc_MPI_Comm mpicomm, int initial_level) { - fclaw2d_check_initial_level (mpicomm, initial_level); - return - fclaw2d_domain_new (p4est_wrap_new_pillow (mpicomm, initial_level), - NULL); + return fclaw2d_domain_new_conn (mpicomm, initial_level, + p4est_connectivity_new_pillow ()); } fclaw2d_domain_t * fclaw2d_domain_new_cubedsphere (sc_MPI_Comm mpicomm, int initial_level) { - fclaw2d_check_initial_level (mpicomm, initial_level); - return fclaw2d_domain_new (p4est_wrap_new_cubed (mpicomm, initial_level), - NULL); + return fclaw2d_domain_new_conn (mpicomm, initial_level, + p4est_connectivity_new_cubed ()); } fclaw2d_domain_t * @@ -394,10 +394,9 @@ fclaw2d_domain_new_disk (sc_MPI_Comm mpicomm, int periodic_in_x, int periodic_in_y, int initial_level) { - fclaw2d_check_initial_level (mpicomm, initial_level); - return fclaw2d_domain_new - (p4est_wrap_new_disk (mpicomm, periodic_in_x, periodic_in_y, - initial_level), NULL); + return fclaw2d_domain_new_conn (mpicomm, initial_level, + p4est_connectivity_new_disk (periodic_in_x, + periodic_in_y)); } #endif /* P4_TO_P8 */ @@ -414,19 +413,19 @@ fclaw2d_domain_new_brick (sc_MPI_Comm mpicomm, #endif int initial_level) { - p4est_wrap_t *wrap; - - fclaw2d_check_initial_level (mpicomm, initial_level); - wrap = p4est_wrap_new_brick (mpicomm, blocks_in_x, blocks_in_y, + return fclaw2d_domain_new_conn (mpicomm, initial_level, + p4est_connectivity_new_brick (blocks_in_x, + blocks_in_y, #ifdef P4_TO_P8 - blocks_in_z, + blocks_in_z, #endif - periodic_in_x, periodic_in_y, + periodic_in_x, + periodic_in_y #ifdef P4_TO_P8 - periodic_in_z, + , + periodic_in_z #endif - initial_level); - return fclaw2d_domain_new (wrap, NULL); + )); } fclaw2d_domain_t * @@ -434,13 +433,23 @@ fclaw2d_domain_new_conn (sc_MPI_Comm mpicomm, int initial_level, p4est_connectivity_t * conn) { p4est_wrap_t *wrap; - fclaw2d_domain_t *domain; + p4est_wrap_params_t params; fclaw2d_check_initial_level (mpicomm, initial_level); - wrap = p4est_wrap_new_conn (mpicomm, conn, initial_level); - domain = fclaw2d_domain_new (wrap, NULL); - return domain; + /* Wrap the connectivity. This does the same as p4est_wrap_new_conn, + * except for setting edgehanging_corners to 1. */ + p4est_wrap_params_init (¶ms); + params.hollow = 0; + params.mesh_params.btype = P4EST_CONNECT_FULL; + params.mesh_params.compute_level_lists = 1; + params.mesh_params.compute_tree_index = 1; +#ifdef P4_TO_P8 + params.mesh_params.edgehanging_corners = 1; +#endif + wrap = p4est_wrap_new_params (mpicomm, conn, initial_level, ¶ms); + + return fclaw2d_domain_new (wrap, NULL); } void diff --git a/src/fclaw2d_corner_neighbors.c b/src/fclaw2d_corner_neighbors.c deleted file mode 100644 index f4e2e72cb..000000000 --- a/src/fclaw2d_corner_neighbors.c +++ /dev/null @@ -1,535 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - - -/* This is used to determine neighbor patch relative level (finer, coarser or samesize) - This enum is defined both here and in fclaw2d_face_neighbors.cpp. Is that okay? */ -enum -{ - COARSER_GRID = -1, - SAMESIZE_GRID, - FINER_GRID -}; - - -static -void get_corner_type(fclaw2d_global_t* glob, - int icorner, - int intersects_bdry[], - int intersects_block[], - int *interior_corner, - int *is_block_corner, - int *block_iface) -{ - fclaw2d_domain_t *domain = glob->domain; - - // p4est has tons of lookup table like this, can be exposed similarly - int corner_faces[FCLAW2D_SPACEDIM]; - fclaw2d_domain_corner_faces(domain, icorner, corner_faces); - - /* Both faces are at a physical boundary */ - int is_phys_corner = - intersects_bdry[corner_faces[0]] && intersects_bdry[corner_faces[1]]; - - /* Corner lies in interior of physical boundary edge. */ - int corner_on_phys_face = !is_phys_corner && - (intersects_bdry[corner_faces[0]] || intersects_bdry[corner_faces[1]]); - - /* Either a corner is at a block boundary (but not a physical boundary), - or internal to a block. L-shaped domains are excluded for now - (i.e. no reentrant corners). */ - *interior_corner = !corner_on_phys_face && !is_phys_corner; - - /* Both faces are at a block boundary, physical or not */ - *is_block_corner = - intersects_block[corner_faces[0]] && intersects_block[corner_faces[1]]; - - *block_iface = -1; - if (!*is_block_corner) - { - /* At most one of these is true if corner is not a block corner */ - if (intersects_block[corner_faces[0]]) - { - /* Corner is on a block face. */ - *block_iface = corner_faces[0]; - } - else if (intersects_block[corner_faces[1]]) - { - /* Corner is on a block face. */ - *block_iface = corner_faces[1]; - } - } -} - - -/* -------------------------------------------------------- - Four cases to consider. The 'has_corner_neighbor' - value is returned from p4est. The assumption going - into this routine is that we have found a valid - interior corner (not a corner on a physical boundary). - The corner than satisfies one of the following four - cases. - - Case No. | has_corner_neighbor | is_block_corner - -------------------------------------------------------- - 1 | T | T - 2 | F | F - 3 | T | F - 4 | F | T - - Case 1 : In this case, 4 or more patches meet at a block - corner. No transforms are yet available, so we - assume that at block corners, the patches all - have the same orientation. - Case 2 : Corner is at a hanging node and has no valid - adjacent corner. - Case 3 : Corner is either interior to a block, or on a - block edge. In each case, the transform is - well-defined. - Case 4 : Either 3 patches meet at a corner, in which - case we don't have an adjacent corner, or we are - on a pillow grid, in which case we have a - corner, but one which we nonetheless treat - as a special case. - ------------------------------------------------------ */ - -static -void get_corner_neighbor(fclaw2d_global_t *glob, - int this_block_idx, - int this_patch_idx, - fclaw2d_patch_t* this_patch, - int icorner, - int block_iface, - int is_block_corner, - int *corner_block_idx, - fclaw2d_patch_t** corner_patch, - int *rcornerno, - int **ref_flag_ptr, - int *block_corner_count, - int ftransform[], - fclaw2d_patch_transform_data_t* ftransform_finegrid) -{ - fclaw2d_domain_t *domain = glob->domain; - /* See what p4est thinks we have for corners, and consider four cases */ - int rproc_corner; - int corner_patch_idx; - fclaw2d_patch_relation_t neighbor_type; - - /* Note : Pillowsphere case does not return a block corner neighbor */ - int ispillowsphere = fclaw2d_map_pillowsphere(glob); - - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_NEIGHBOR_SEARCH]); - int has_corner_neighbor = - fclaw2d_patch_corner_neighbors(domain, - this_block_idx, - this_patch_idx, - icorner, - &rproc_corner, - corner_block_idx, - &corner_patch_idx, - rcornerno, - &neighbor_type); - - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_NEIGHBOR_SEARCH]); - - *block_corner_count = 0; /* Assume we are not at a block corner */ - if (has_corner_neighbor && is_block_corner) - { - /* Case 1 : 4 or more patches meet at a block corner. - This case does NOT include the pillowgrid. */ - *block_corner_count = 4; /* assume four for now */ - - /* No block corner transforms yet, so we use the - interior 'default' transforms. */ - fclaw2d_patch_transform_blockface_intra (glob, ftransform); - fclaw2d_patch_transform_blockface_intra - (glob, ftransform_finegrid->transform); - } - else if (!has_corner_neighbor && !is_block_corner) - { - /* Case 2 : 'icorner' is a hanging node */ - /* We do not return valid transformation objects! */ - *ref_flag_ptr = NULL; - *corner_patch = NULL; - return; - } - else if (has_corner_neighbor && !is_block_corner) - { - /* Case 3 : 'icorner' is an interior corner, at a block edge, - or we are on a periodic block. Need to return a valid - transform in 'ftransform' */ - /* block_iface is the block number at the of the neighbor? */ - if (block_iface >= 0) - { - /* The corner is on a block edge (but is not a block corner). - Compute a transform between blocks. First, get the - remote face number. The remote face number encodes the - orientation, so we have 0 <= rfaceno < 8 */ - int rfaceno; - int rproc[FCLAW2D_REFINEFACTOR]; - int rpatchno[FCLAW2D_REFINEFACTOR]; - int rblockno; /* Should equal *corner_block_idx, above. */ - fclaw2d_patch_face_neighbors(domain, - this_block_idx, - this_patch_idx, - block_iface, - rproc, - &rblockno, - rpatchno, - &rfaceno); - - FCLAW_ASSERT(rblockno == *corner_block_idx); - - /* Get encoding of transforming a neighbor coordinate across a face */ - fclaw2d_patch_transform_blockface (glob, block_iface, rfaceno, ftransform); - - /* Get transform needed to swap parallel ghost patch with fine - grid on-proc patch. This is done so that averaging and - interpolation routines can be re-used. */ - int iface1 = block_iface; - int rface1 = rfaceno; - fclaw2d_patch_face_swap(&iface1,&rface1); - fclaw2d_patch_transform_blockface(glob, iface1, rface1, - ftransform_finegrid->transform); - ftransform_finegrid->block_iface = iface1; - } - else if (this_block_idx == *corner_block_idx) - { - /* Both patches are in the same block, so we set the transform to - a default transform. This could be the case for periodic boundaries. */ - *block_corner_count = 4; /* assume four for now */ - fclaw2d_patch_transform_blockface_intra (glob, ftransform); - fclaw2d_patch_transform_blockface_intra - (glob, ftransform_finegrid->transform); - - } - else - { - fclaw_global_essentialf("WARNING : this_block_idx = %d\n",this_block_idx); - fclaw_global_essentialf("WARNING : corner_block_idx = %d\n",*corner_block_idx); - fclaw_global_essentialf("get_corner_neighbors " \ - "(fclaw2d_corner_neighbors.c : " \ - "We should not be here\n"); - exit(0); - } - } - else if (!has_corner_neighbor && is_block_corner) - { - /* Case 4 : Pillow sphere case or cubed sphere */ - if (!ispillowsphere) - { - *block_corner_count = 3; - /* Exactly 3 patches meet at a corner, e.g. the cubed sphere. - In this case, 'this_patch' has no corner-adjacent only - neighbors, and so there is nothing to do. */ - *ref_flag_ptr = NULL; - *corner_patch = NULL; - return; - } - else - { - *block_corner_count = 2; - has_corner_neighbor = 1; - int rpatchno[FCLAW2D_REFINEFACTOR]; - int rproc[FCLAW2D_REFINEFACTOR]; - int rfaceno; - - /* Use only faces 0 or 1 to get block data. */ - int iface = icorner % 2; - neighbor_type = - fclaw2d_patch_face_neighbors(domain, - this_block_idx, - this_patch_idx, - iface, - rproc, - corner_block_idx, - rpatchno, - &rfaceno); - - int igrid; - if (neighbor_type == FCLAW2D_PATCH_HALFSIZE) - { - /* igrid = 0 at corners 0,1 and (R-1) at corners 2,3, - where R = refinement factor */ - igrid = (icorner/2)*(FCLAW2D_REFINEFACTOR - 1); - } - else - { - /* Same size or double size grids. */ - igrid = 0; - } - - *rcornerno = icorner; /* This wasn't being set! */ - corner_patch_idx = rpatchno[igrid]; - rproc_corner = rproc[igrid]; - } - } - - /* --------------------------------------------------------------------- - We have a valid neighbor and possibly a transform. We just now need - to get a pointer to the neighbor patch (which may be a parallel patch) - and the relative level (-1,0,1). - --------------------------------------------------------------------- */ - - if (domain->mpirank != rproc_corner) - { - *corner_patch = &domain->ghost_patches[corner_patch_idx]; - } - else - { - fclaw2d_block_t *neighbor_block = &domain->blocks[*corner_block_idx]; - *corner_patch = &neighbor_block->patches[corner_patch_idx]; - } - - if (neighbor_type == FCLAW2D_PATCH_HALFSIZE) - { - **ref_flag_ptr = 1; - } - else if (neighbor_type == FCLAW2D_PATCH_SAMESIZE) - { - **ref_flag_ptr = 0; - } - else /* FCLAW2D_PATCH_DOUBLESIZE */ - { - **ref_flag_ptr = -1; - } -} - - - -void cb_corner_fill(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, - int this_block_idx, - int this_patch_idx, - void *user) -{ - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - - fclaw2d_exchange_info_t *filltype = (fclaw2d_exchange_info_t*) s->user; - int time_interp = filltype->time_interp; - int is_coarse = filltype->grid_type == FCLAW2D_IS_COARSE; - int is_fine = filltype->grid_type == FCLAW2D_IS_FINE; - - int read_parallel_patches = filltype->read_parallel_patches; - - int copy_from_neighbor = filltype->exchange_type == FCLAW2D_COPY; - int average_from_neighbor = filltype->exchange_type == FCLAW2D_AVERAGE; - int interpolate_to_neighbor = filltype->exchange_type == FCLAW2D_INTERPOLATE; - - int intersects_bdry[FCLAW2D_NUMFACES]; - int intersects_block[FCLAW2D_NUMFACES]; - int is_block_corner; - int is_interior_corner; - int block_corner_count; - - int icorner; - - fclaw2d_physical_get_bc(s->glob,this_block_idx,this_patch_idx, - intersects_bdry); - - fclaw2d_block_get_block_boundary(s->glob, this_patch, intersects_block); - - /* Transform data needed at multi-block boundaries */ - fclaw2d_patch_transform_data_t transform_data; - transform_data.glob = s->glob; - transform_data.based = 1; // cell-centered data in this routine. - transform_data.this_patch = this_patch; - transform_data.neighbor_patch = NULL; // gets filled in below. - - fclaw2d_patch_transform_init_data(s->glob,this_patch, - this_block_idx, - this_patch_idx, - &transform_data); - - - fclaw2d_patch_transform_data_t transform_data_finegrid; - transform_data_finegrid.glob = s->glob; - transform_data_finegrid.based = 1; // cell-centered data in this routine. - - fclaw2d_patch_transform_init_data(s->glob,this_patch, - this_block_idx, - this_patch_idx, - &transform_data_finegrid); - - - for (icorner = 0; icorner < FCLAW2D_NUMCORNERS; icorner++) - { - block_corner_count = 0; - get_corner_type(s->glob,icorner, - intersects_bdry, - intersects_block, - &is_interior_corner, - &is_block_corner, - &transform_data.block_iface); - - transform_data_finegrid.block_iface = -1; - - /* Sets block_corner_count to 0 */ - fclaw2d_patch_set_block_corner_count(s->glob, this_patch, - icorner,block_corner_count); - - if (is_interior_corner) - { - /* Is an interior patch corner; may also be a block corner */ - - int corner_block_idx; - int neighbor_level; - int *ref_flag_ptr = &neighbor_level; - fclaw2d_patch_t *corner_patch; - int rcornerno; - - transform_data.icorner = icorner; - corner_block_idx = -1; - get_corner_neighbor(s->glob, - this_block_idx, - this_patch_idx, - this_patch, - icorner, - transform_data.block_iface, - is_block_corner, - &corner_block_idx, - &corner_patch, - &rcornerno, - &ref_flag_ptr, - &block_corner_count, - transform_data.transform, - &transform_data_finegrid); - - /* This sets value in block_corner_count_array */ - fclaw2d_patch_set_block_corner_count(s->glob, this_patch, - icorner,block_corner_count); - transform_data.is_block_corner = is_block_corner; - - /* Needed for switching the context */ - transform_data_finegrid.is_block_corner = is_block_corner; - transform_data_finegrid.icorner = rcornerno; - transform_data_finegrid.this_patch = corner_patch; - transform_data_finegrid.neighbor_patch = this_patch; - - - if (ref_flag_ptr == NULL) - { - /* No corner neighbor. Either : - -- Hanging node - -- Cubed sphere - */ - continue; - } - - int remote_neighbor = fclaw2d_patch_is_ghost(corner_patch); - if (is_coarse && ((read_parallel_patches && remote_neighbor) || !remote_neighbor)) - { - transform_data.neighbor_patch = corner_patch; - if (neighbor_level == FINER_GRID) - { - fclaw2d_patch_t* coarse_patch = this_patch; - fclaw2d_patch_t* fine_patch = corner_patch; - int coarse_blockno = this_block_idx; - int fine_blockno = corner_block_idx; - if (interpolate_to_neighbor && !remote_neighbor) - { - /* No need to interpolate to remote ghost patches. */ - fclaw2d_patch_interpolate_corner(s->glob, - coarse_patch, - fine_patch, - coarse_blockno, - fine_blockno, - is_block_corner, - icorner,time_interp, - &transform_data); - } - else if (average_from_neighbor) - { - /* Average even if neighbor is a remote neighbor */ - fclaw2d_patch_t* coarse_patch = this_patch; - fclaw2d_patch_t* fine_patch = corner_patch; - fclaw2d_patch_average_corner(s->glob, - coarse_patch, - fine_patch, - coarse_blockno, - fine_blockno, - is_block_corner, - icorner,time_interp, - &transform_data); - } - } - else if (neighbor_level == SAMESIZE_GRID && copy_from_neighbor) - { - fclaw2d_patch_copy_corner(s->glob, - this_patch, - corner_patch, - this_block_idx, - corner_block_idx, - is_block_corner, - icorner, time_interp, - &transform_data); - } - - } /* End of non-parallel patch case */ - else if (is_fine && neighbor_level == COARSER_GRID && - remote_neighbor && read_parallel_patches) - { - /* The coarse grid is now the remote patch; swap contexts and - call same routines above, but with remote patch as the "coarse" - grid */ - - fclaw2d_patch_t* coarse_patch = corner_patch; - fclaw2d_patch_t* fine_patch = this_patch; - int coarse_blockno = corner_block_idx; - int fine_blockno = this_patch_idx; - - if (interpolate_to_neighbor) - { - /* Interpolate from remote coarse grid patch (coarse grid) to - local fine grid patch. We do not need to average to the - remote patch corners unless corners are used in the - interpolation stencil. */ - int coarse_icorner = transform_data_finegrid.icorner; - fclaw2d_patch_interpolate_corner(s->glob, - coarse_patch, - fine_patch, - coarse_blockno, - fine_blockno, - is_block_corner, - coarse_icorner,time_interp, - &transform_data_finegrid); - - } - } /* End of parallel case */ - } /* End of 'interior_corner' */ - } /* End of icorner loop */ -} diff --git a/src/fclaw2d_diagnostics.h b/src/fclaw2d_diagnostics.h deleted file mode 100644 index a9db9a43b..000000000 --- a/src/fclaw2d_diagnostics.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW2D_DIAGNOSTICS_H -#define FCLAW2D_DIAGNOSTICS_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct fclaw2d_global; -struct fclaw2d_domain; - -typedef struct fclaw2d_diagnostics_vtable fclaw2d_diagnostics_vtable_t; - -typedef struct fclaw2d_diagnostics_accumulator fclaw2d_diagnostics_accumulator_t; - -struct fclaw2d_diagnostics_accumulator -{ - void* patch_accumulator; - void* solver_accumulator; - void* user_accumulator; - void* gauge_accumulator; - void* ray_accumulator; -}; - -/* Diagnostic information */ -typedef void (*fclaw2d_diagnostics_initialize_t)(struct fclaw2d_global *glob, - void** acc); - -typedef void (*fclaw2d_diagnostics_compute_t)(struct fclaw2d_global *glob, - void* acc); - -typedef void (*fclaw2d_diagnostics_gather_t)(struct fclaw2d_global *glob, - void* acc, - int init_flag); - -typedef void (*fclaw2d_diagnostics_reset_t)(struct fclaw2d_global *glob, - void* acc); - -typedef void (*fclaw2d_diagnostics_finalize_t)(struct fclaw2d_global *glob, - void** acc); - -struct fclaw2d_diagnostics_vtable -{ - /* patch diagnostic functions (error, conservation, area, etc) */ - fclaw2d_diagnostics_initialize_t patch_init_diagnostics; - fclaw2d_diagnostics_compute_t patch_compute_diagnostics; - fclaw2d_diagnostics_gather_t patch_gather_diagnostics; - fclaw2d_diagnostics_reset_t patch_reset_diagnostics; - fclaw2d_diagnostics_finalize_t patch_finalize_diagnostics; - - /* gauge diagnostic functions */ - fclaw2d_diagnostics_initialize_t solver_init_diagnostics; - fclaw2d_diagnostics_compute_t solver_compute_diagnostics; - fclaw2d_diagnostics_gather_t solver_gather_diagnostics; - fclaw2d_diagnostics_reset_t solver_reset_diagnostics; - fclaw2d_diagnostics_finalize_t solver_finalize_diagnostics; - - /* solver diagnostic functions (other solver functions) */ - fclaw2d_diagnostics_initialize_t gauges_init_diagnostics; - fclaw2d_diagnostics_compute_t gauges_compute_diagnostics; - fclaw2d_diagnostics_gather_t gauges_gather_diagnostics; - fclaw2d_diagnostics_reset_t gauges_reset_diagnostics; - fclaw2d_diagnostics_finalize_t gauges_finalize_diagnostics; - - /* ray defined diagnostics */ - fclaw2d_diagnostics_initialize_t ray_init_diagnostics; - fclaw2d_diagnostics_compute_t ray_compute_diagnostics; - fclaw2d_diagnostics_gather_t ray_gather_diagnostics; - fclaw2d_diagnostics_reset_t ray_reset_diagnostics; - fclaw2d_diagnostics_finalize_t ray_finalize_diagnostics; - - /* user defined diagnostics */ - fclaw2d_diagnostics_initialize_t user_init_diagnostics; - fclaw2d_diagnostics_compute_t user_compute_diagnostics; - fclaw2d_diagnostics_gather_t user_gather_diagnostics; - fclaw2d_diagnostics_reset_t user_reset_diagnostics; - fclaw2d_diagnostics_finalize_t user_finalize_diagnostics; - - int is_set; -}; - -fclaw2d_diagnostics_vtable_t* fclaw2d_diagnostics_vt(struct fclaw2d_global* glob); - -void fclaw2d_diagnostics_vtable_initialize(struct fclaw2d_global* glob); - -double fclaw2d_domain_global_minimum (struct fclaw2d_domain* domain, double d); - -void fclaw2d_diagnostics_initialize(struct fclaw2d_global *glob); - -void fclaw2d_diagnostics_gather(struct fclaw2d_global *glob, int init_flag); - -void fclaw2d_diagnostics_reset(struct fclaw2d_global *glob); - -void fclaw2d_diagnostics_finalize(struct fclaw2d_global *glob); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/fclaw2d_diagnostics.h.TEST.cpp b/src/fclaw2d_diagnostics.h.TEST.cpp deleted file mode 100644 index ba6d9df0b..000000000 --- a/src/fclaw2d_diagnostics.h.TEST.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include - -TEST_CASE("fclaw2d_diagnostics_vtable_initialize stores two seperate vtables in two seperate globs") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - fclaw2d_diagnostics_vtable_initialize(glob1); - fclaw2d_diagnostics_vtable_initialize(glob2); - - CHECK_NE(fclaw2d_diagnostics_vt(glob1), fclaw2d_diagnostics_vt(glob2)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw2d_diagnostics_vtable_initialize sets is_set flag") -{ - fclaw2d_global_t* glob = fclaw2d_global_new(); - - fclaw2d_diagnostics_vtable_initialize(glob); - - CHECK_UNARY(fclaw2d_diagnostics_vt(glob)->is_set); - - fclaw2d_global_destroy(glob); -} - -#ifdef FCLAW_ENABLE_DEBUG - -TEST_CASE("fclaw2d_diagnostics_vtable_initialize fails if called twice on a glob") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - fclaw2d_diagnostics_vtable_initialize(glob1); - CHECK_SC_ABORTED(fclaw2d_diagnostics_vtable_initialize(glob1)); - fclaw2d_diagnostics_vtable_initialize(glob2); - CHECK_SC_ABORTED(fclaw2d_diagnostics_vtable_initialize(glob2)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -#endif \ No newline at end of file diff --git a/src/fclaw2d_domain.c b/src/fclaw2d_domain.c deleted file mode 100644 index 21a6eae93..000000000 --- a/src/fclaw2d_domain.c +++ /dev/null @@ -1,289 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#ifndef P4_TO_P8 -#include -#include /* Contains domain_destroy and others */ -#include -#include -#include -#else -#include -#include /* Contains domain_destroy and others */ -#include -#include -#include -#endif - -/* dimension-independent helper functions first */ - -#if 0 - -static fclaw2d_domain_t * -fclaw_domain_get_domain (fclaw_domain_t *d) -{ -#ifndef P4_TO_P8 - return d->d.d2.domain2; -#else - return d->d.d3.domain3; -#endif -} - -#endif - -void -fclaw2d_domain_iterate_cb - (fclaw2d_domain_t * d2, fclaw2d_patch_t * patch, - int blockno, int patchno, void *user) -{ - fclaw_domain_iterate_t *di = (fclaw_domain_iterate_t *) user; - di->iter (di->d, (fclaw_patch_t *) patch->user, blockno, patchno, - di->user); -} - -typedef struct fcd_allocated_patch -{ -#ifndef P4_TO_P8 - fclaw2d_patch_data_t pd; -#else - fclaw3d_patch_data_t pd; -#endif - fclaw_patch_t p; -} -fcd_allocated_patch_t; - -fclaw_domain_t * -fclaw_domain_new2d (fclaw2d_domain_t * domain, - fclaw_domain_callback_t init, void *user) -{ - int i, j; - fclaw2d_block_t *block; - fclaw2d_patch_t *patch; - fclaw_domain_t *d; - fclaw_patch_t *p; - fcd_allocated_patch_t *ap; - - FCLAW_ASSERT (domain != NULL && domain->mpisize > 0); - - /* allocate and set domain itself */ - d = FCLAW_ALLOC_ZERO (fclaw_domain_t, 1); - d->dim = P4EST_DIM; -#ifndef P4_TO_P8 - d->d.d2.dmagic2 = FCLAW2D_DOMAIN_MAGIC; - d->d.d2.domain2 = domain; -#else - d->d.d3.dmagic3 = FCLAW3D_DOMAIN_MAGIC; - d->d.d3.domain3 = domain; -#endif - sc_mstamp_init (&d->pstamp, 4096 - 3 * sizeof (size_t), - sizeof (fcd_allocated_patch_t)); - - /* iterate over all patches to initialize */ - for (i = 0; i < domain->num_blocks; ++i) - { - block = domain->blocks + i; - for (j = 0; j < block->num_patches; ++j) - { - /* hook the new dimension-independent patch into storage */ - ap = (fcd_allocated_patch_t *) sc_mstamp_alloc (&d->pstamp); - patch = block->patches + j; - patch->user = p = &ap->p; -#ifndef P4_TO_P8 - p->pd.pd2 = &ap->pd; - p->pd.pd2->real_patch = patch; -#else - p->pd.pd3 = &ap->pd; - p->pd.pd3->real_patch = patch; -#endif - if (init != NULL) { - init (d, p, i, j, user); - } - } - } - - /* domain fully constructed */ - FCLAW_ASSERT (fclaw_domain_is_valid (d)); - return d; -} - -void -fclaw_domain_destroy2d (fclaw_domain_t * d, - fclaw_domain_callback_t dele, void *user) -{ - int i, j; - fclaw2d_domain_t *domain; - fclaw2d_block_t *block; - fclaw2d_patch_t *patch; - fclaw_patch_t *p; - - FCLAW_ASSERT (d->dim == P4EST_DIM); -#ifndef P4_TO_P8 - domain = d->d.d2.domain2; -#else - domain = d->d.d3.domain3; -#endif - - FCLAW_ASSERT (domain != NULL && domain->mpisize > 0); - FCLAW_ASSERT (d->du.count_set_patch == d->du.count_delete_patch); - - /* iterate over all patches to deinitialize */ - if (dele != NULL) { - for (i = 0; i < domain->num_blocks; ++i) - { - block = domain->blocks + i; - for (j = 0; j < block->num_patches; ++j) - { - /* free the new dimension-independent patch into storage */ - patch = block->patches + j; - p = (fclaw_patch_t *) patch->user; - dele (d, p, i, j, user); - } - } - } - fclaw2d_domain_destroy (domain); - sc_mstamp_reset (&d->pstamp); - FCLAW_FREE (d); -} - -/* we're holding back with 3d counterparts - since much of this will move into fclaw_domain.c */ -/* below follows the previous code unchanged */ -/* edit: do it anyway for now to support p8/swirl */ - -void fclaw2d_domain_data_new(fclaw2d_domain_t *domain) -{ - fclaw2d_domain_data_t* ddata = (fclaw2d_domain_data_t*) domain->user; - ddata = FCLAW_ALLOC_ZERO (fclaw2d_domain_data_t, 1); - domain->user = ddata; - - ddata->count_set_patch = ddata->count_delete_patch = 0; - - ddata->domain_exchange = NULL; - ddata->domain_indirect = NULL; -} - -void fclaw2d_domain_data_delete(fclaw2d_domain_t* domain) -{ - fclaw2d_domain_data_t* ddata = (fclaw2d_domain_data_t*) domain->user; - - FCLAW_FREE (ddata); - domain->user = NULL; -} - -fclaw2d_domain_data_t *fclaw2d_domain_get_data(fclaw2d_domain_t *domain) -{ - return (fclaw2d_domain_data_t *) domain->user; -} - -void fclaw2d_domain_setup(fclaw2d_global_t* glob, - fclaw2d_domain_t* new_domain) -{ - fclaw2d_domain_t *old_domain = glob->domain; - double t; - - if (old_domain == new_domain) - { - fclaw_global_infof("Building initial domain\n"); - t = 0; - glob->curr_time = t;//new_domain - } - else - { - fclaw_global_infof("Rebuilding domain\n"); - fclaw2d_domain_data_new(new_domain); - } - fclaw_global_infof("Done\n"); -} - -void fclaw2d_domain_reset(fclaw2d_global_t* glob) -{ - fclaw2d_domain_t** domain = &glob->domain; - fclaw2d_domain_data_t *ddata = fclaw2d_domain_get_data (*domain); - int i, j; - - for(i = 0; i < (*domain)->num_blocks; i++) - { - fclaw2d_block_t *block = (*domain)->blocks + i; - - for(j = 0; j < block->num_patches; j++) - { - /* This is here to delete any patches created during - initialization, and not through regridding */ - fclaw2d_patch_t *patch = block->patches + j; - fclaw2d_patch_data_delete(glob,patch); - } - block->user = NULL; - } - - if (ddata->domain_exchange != NULL) - { - /* TO DO: translate fclaw2d_exchange files */ - fclaw2d_exchange_delete(glob); - } - - /* Output memory discrepancy for the ClawPatch */ - if (ddata->count_set_patch != ddata->count_delete_patch) - { - printf ("[%d] This domain had Clawpatch set %d and deleted %d times\n", - (*domain)->mpirank, - ddata->count_set_patch, ddata->count_delete_patch); - } - - fclaw2d_domain_data_delete(*domain); // Delete allocated pointers to set of functions. - - fclaw2d_domain_destroy(*domain); - *domain = NULL; -} - -void fclaw2d_domain_iterate_level_mthread (fclaw2d_domain_t * domain, int level, - fclaw2d_patch_callback_t pcb, void *user) -{ -#if (_OPENMP) - int i, j; - fclaw2d_block_t *block; - fclaw2d_patch_t *patch; - - for (i = 0; i < domain->num_blocks; i++) - { - block = domain->blocks + i; -#pragma omp parallel for private(patch,j) - for (j = 0; j < block->num_patches; j++) - { - patch = block->patches + j; - if (patch->level == level) - { - pcb (domain, patch, i, j, user); - } - } - } -#else -#ifndef P4_TO_P8 - fclaw_global_essentialf("fclaw2d_patch_iterator_mthread: We should not be here\n"); -#else - fclaw_global_essentialf("fclaw3d_patch_iterator_mthread: We should not be here\n"); -#endif -#endif -} diff --git a/src/fclaw2d_domain.h b/src/fclaw2d_domain.h deleted file mode 100644 index 539f6fbba..000000000 --- a/src/fclaw2d_domain.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/** - * @file - * Domain structures and routines - */ - -#ifndef FCLAW2D_DOMAIN_H -#define FCLAW2D_DOMAIN_H - -#include /* Needed for domain_exchange/domain_indirect info */ -#include - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -/* CB: chicken and egg -- should global include domain or vice versa? - Believe removing any dependence on global from domain will work. - Setting a global timer in domain_setup may likely be refactored. - Deleting patch and exchange data in domain_reset might go into a - toplevel algorithmic function quite naturally outside of domain. - */ -struct fclaw2d_global; - -typedef struct fclaw2d_domain_data -{ - /* Debug counters and timers */ - int count_set_patch; - int count_delete_patch; - - fclaw2d_domain_exchange_t *domain_exchange; - fclaw2d_domain_indirect_t *domain_indirect; - -} fclaw2d_domain_data_t; - -void fclaw2d_domain_data_new(struct fclaw2d_domain *domain); - -void fclaw2d_domain_data_delete(struct fclaw2d_domain* domain); - -void fclaw2d_domain_setup(struct fclaw2d_global* glob, - struct fclaw2d_domain* new_domain); - -void fclaw2d_domain_reset(struct fclaw2d_global* glob); - -fclaw2d_domain_data_t* fclaw2d_domain_get_data(struct fclaw2d_domain *domain); - -/* OpenMP iterator (not part of forestclaw2d.h */ -void fclaw2d_domain_iterate_level_mthread (struct fclaw2d_domain * domain, int level, - fclaw2d_patch_callback_t pcb, void *user); - -/* below are the functions needed for dimension independence */ - -/** safeguard value for dimension-independent domain */ -#define FCLAW2D_DOMAIN_MAGIC 0x56780202 - -void fclaw2d_domain_iterate_cb - (fclaw2d_domain_t * d2, fclaw2d_patch_t * patch, - int blockno, int patchno, void *user); - -/** Construct a dimension-specific domain and initialize patch data. - * \param [in] domain Freshly created, valid domain structure - * without any user data attached to it. - * \param [in] init This callback is pointed to a freshly - * allocated fclaw_patch whose 2D data it - * is supposed to fill with fitting values. - * This includes allocating and filling - * the patch user pointer, which the - * callback can do using the third - * parameter to this function, \a user. - * May be NULL for no callback. - * \param [in,out] user Pointer passed through to \a init. - * \return Initialized dimension-independent domain. - */ -fclaw_domain_t *fclaw_domain_new2d (fclaw2d_domain_t * domain, - fclaw_domain_callback_t init, void *user); - -/** Destruct a dimension-specific domain and deinitialize patch data. - * \param [in] domain Valid domain-independent domain structure. - * \param [in] dele This callback is pointed to each existing - * fclaw_patch whose 2D data it is supposed to - * deinitialize, as well as the patch user data. - * Note, just don't allocate the patch itself! - * May be NULL for no callback. - * \param [in,out] user Pointer passed through to \a init. - */ -void fclaw_domain_destroy2d (fclaw_domain_t * domain, - fclaw_domain_callback_t dele, void *user); - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - -#endif /* FCLAW2D_DOMAIN_H */ diff --git a/src/fclaw2d_elliptic_solver.h.TEST.cpp b/src/fclaw2d_elliptic_solver.h.TEST.cpp deleted file mode 100644 index 1e3e8f6d7..000000000 --- a/src/fclaw2d_elliptic_solver.h.TEST.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include - -TEST_CASE("fclaw2d_elliptic_vtable_initialize stores two seperate vtables in two seperate globs") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - fclaw2d_elliptic_vtable_initialize(glob1); - fclaw2d_elliptic_vtable_initialize(glob2); - - CHECK_NE(fclaw2d_elliptic_vt(glob1), fclaw2d_elliptic_vt(glob2)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw2d_elliptic_vtable_initialize sets is_set flag") -{ - fclaw2d_global_t* glob = fclaw2d_global_new(); - - fclaw2d_elliptic_vtable_initialize(glob); - - CHECK_UNARY(fclaw2d_elliptic_vt(glob)->is_set); - - fclaw2d_global_destroy(glob); -} - -#ifdef FCLAW_ENABLE_DEBUG - -TEST_CASE("fclaw2d_elliptic_vtable_initialize fails if called twice on a glob") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - fclaw2d_elliptic_vtable_initialize(glob1); - CHECK_SC_ABORTED(fclaw2d_elliptic_vtable_initialize(glob1)); - fclaw2d_elliptic_vtable_initialize(glob2); - CHECK_SC_ABORTED(fclaw2d_elliptic_vtable_initialize(glob2)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -#endif \ No newline at end of file diff --git a/src/fclaw2d_global.c b/src/fclaw2d_global.c deleted file mode 100644 index 8a1c12b15..000000000 --- a/src/fclaw2d_global.c +++ /dev/null @@ -1,377 +0,0 @@ -/* -Copyright (c) 2012-2023 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include - -#include -#include -#include -#include - -#ifndef P4_TO_P8 -#include -#include -#include - -#include -#include -#include -#else -#include -#include - -#include -/* figure out dimension-independent diagnostics */ -#include -#endif - -void -fclaw2d_iterate_patch_cb - (fclaw2d_domain_t *domain, fclaw2d_patch_t *patch, - int blockno, int patchno, void *user) -{ - fclaw_global_iterate_t *gi = (fclaw_global_iterate_t *) user; - - FCLAW_ASSERT (gi->gpcb != NULL); - gi->gpcb (gi->glob, (fclaw_patch_t *) patch->user, blockno, patchno, gi->user); -} - -void -fclaw2d_iterate_family_cb - (fclaw2d_domain_t *domain, fclaw2d_patch_t *patch, - int blockno, int patchno, void *user) -{ - fclaw_global_iterate_t *gi = (fclaw_global_iterate_t *) user; - fclaw_patch_t *family[FCLAW2D_NUMSIBLINGS]; - int i; - - for (i = 0; i < FCLAW2D_NUMSIBLINGS; ++i) { - family[i] = (fclaw_patch_t *) patch[i].user; - } - - FCLAW_ASSERT (gi->gfcb != NULL); - gi->gfcb (gi->glob, family, blockno, patchno, gi->user); -} - -/* much of this will eventually move into fclaw_global.c */ - -fclaw2d_global_t* fclaw2d_global_new (void) -{ - fclaw2d_global_t *glob; - - glob = FCLAW_ALLOC (fclaw2d_global_t, 1); - - /* these variables need to be set after calling this function */ - glob->mpicomm = sc_MPI_COMM_NULL; - glob->mpisize = 0; - glob->mpirank = -1; - - glob->pkg_container = fclaw_package_container_new (); - glob->vtables = fclaw_pointer_map_new (); - glob->options = fclaw_pointer_map_new (); - - glob->count_amr_advance = 0; - glob->count_ghost_exchange = 0; - glob->count_amr_regrid = 0; - glob->count_amr_new_domain = 0; - glob->count_multiproc_corner = 0; - glob->count_grids_per_proc = 0; - glob->count_grids_remote_boundary = 0; - glob->count_grids_local_boundary = 0; - glob->count_single_step = 0; - glob->count_elliptic_grids = 0; - glob->curr_time = 0; - glob->cont = NULL; - -#ifndef P4_TO_P8 - /* think about how this can work independent of dimension */ - glob->acc = FCLAW_ALLOC (fclaw2d_diagnostics_accumulator_t, 1); -#endif /* P4_TO_P8 */ - - return glob; -} - -fclaw2d_global_t* fclaw2d_global_new_comm (sc_MPI_Comm mpicomm, - int mpisize, int mpirank) -{ - fclaw2d_global_t *glob = fclaw2d_global_new (); - - /* - * Set the communicator. - * With the current code, overridden by fclaw2d_global_store_domain. - * Maybe we should streamline this in the future. - */ - glob->mpicomm = mpicomm; - glob->mpisize = mpisize; - glob->mpirank = mpirank; - - return glob; -} - -#ifndef P4_TO_P8 -// packing unpacking functions only 2d for now - -static void check_vt(fclaw_packing_vtable_t* vt, const char* name) -{ - char msg[1024]; - sprintf(msg,"Unregistered options packing vtable for \"%s\"",name); - SC_CHECK_ABORT ((vt != NULL), msg); -} - -static void -pack_iterator_callback(const char* key, void* value, void* user) -{ - char** buffer_ptr = (char **) user; - - *buffer_ptr += fclaw_pack_string(key, *buffer_ptr); - - fclaw_packing_vtable_t* vt = fclaw_app_get_options_packing_vtable(key); - check_vt(vt,key); - - // advance buffer pointer - *buffer_ptr += vt->pack(value,*buffer_ptr); -} - -size_t -fclaw2d_global_pack(const fclaw2d_global_t * glob, char* buffer) -{ - const char* buffer_start = buffer; - - buffer += fclaw_pack_double(glob->curr_time, buffer); - buffer += fclaw_pack_double(glob->curr_dt, buffer); - - buffer += fclaw_pack_size_t(fclaw_pointer_map_size(glob->options), buffer); - - fclaw_pointer_map_iterate(glob->options, pack_iterator_callback, &buffer); - - return (buffer-buffer_start); -} - -static void -packsize_iterator_callback(const char* key, void* value, void* user) -{ - size_t* options_size = (size_t*) user; - fclaw_packing_vtable_t* vt = fclaw_app_get_options_packing_vtable(key); - check_vt(vt,key); - (*options_size) += fclaw_packsize_string(key) + vt->size(value); -} - -size_t -fclaw2d_global_packsize(const fclaw2d_global_t * glob) -{ - size_t options_size = sizeof(size_t); - fclaw_pointer_map_iterate(glob->options, packsize_iterator_callback, &options_size); - return 2*sizeof(double) + options_size; -} - -size_t -fclaw2d_global_unpack(char* buffer, fclaw2d_global_t ** glob_ptr) -{ - char* buffer_start = buffer; - - fclaw2d_global_t* glob = fclaw2d_global_new(); - *glob_ptr = glob; - - buffer += fclaw_unpack_double(buffer,&glob->curr_time); - buffer += fclaw_unpack_double(buffer,&glob->curr_dt); - - size_t num_option_structs; - buffer += fclaw_unpack_size_t(buffer,&num_option_structs); - - for(size_t i = 0; i< num_option_structs; i++) - { - char * key; - buffer += fclaw_unpack_string(buffer,&key); - fclaw_packing_vtable_t* vt = fclaw_app_get_options_packing_vtable(key); - check_vt(vt,key); - void * options; - buffer += vt->unpack(buffer,&options); - fclaw_pointer_map_insert(glob->options, key, options, vt->destroy); - FCLAW_FREE(key); - } - - return buffer-buffer_start; -} - -#endif - -void -fclaw2d_global_store_domain (fclaw2d_global_t* glob, fclaw2d_domain_t* domain) -{ - glob->domain = domain; - - /* this is redundant if global has been created with a communicator */ - if (glob->mpisize > 0) { - /* double-check for extra paranoia */ - FCLAW_ASSERT (glob->mpisize == domain->mpisize); - FCLAW_ASSERT (glob->mpirank == domain->mpirank); - } -} - -void -fclaw2d_global_store_map (fclaw2d_global_t* glob, - fclaw2d_map_context_t * map) -{ - glob->cont = map; -} - -void -fclaw2d_global_destroy (fclaw2d_global_t * glob) -{ - FCLAW_ASSERT (glob != NULL); - - if(glob->pkg_container != NULL) fclaw_package_container_destroy ((fclaw_package_container_t *)glob->pkg_container); - if(glob->vtables != NULL) fclaw_pointer_map_destroy (glob->vtables); - if(glob->options != NULL) fclaw_pointer_map_destroy (glob->options); - -#ifndef P4_TO_P8 - FCLAW_FREE (glob->acc); -#endif - FCLAW_FREE (glob); -} - -void fclaw2d_global_iterate_level (fclaw2d_global_t * glob, int level, - fclaw2d_patch_callback_t pcb, void *user) -{ - fclaw2d_global_iterate_t g; - g.glob = glob; - g.user = user; - fclaw2d_domain_iterate_level (glob->domain, level, pcb, &g); -} - -void fclaw2d_global_iterate_patches (fclaw2d_global_t * glob, - fclaw2d_patch_callback_t pcb, void *user) -{ - fclaw2d_global_iterate_t g; - g.glob = glob; - g.user = user; - fclaw2d_domain_iterate_patches (glob->domain, pcb, &g); -} - -void fclaw2d_global_iterate_families (fclaw2d_global_t * glob, - fclaw2d_patch_callback_t pcb, void *user) -{ - fclaw2d_global_iterate_t g; - g.glob = glob; - g.user = user; - fclaw2d_domain_iterate_families (glob->domain, pcb, &g); -} - -void fclaw2d_global_iterate_adapted (fclaw2d_global_t * glob, fclaw2d_domain_t* new_domain, - fclaw2d_match_callback_t mcb, void *user) -{ - fclaw2d_global_iterate_t g; - g.glob = glob; - g.user = user; - fclaw2d_domain_iterate_adapted (glob->domain, new_domain,mcb,&g); -} - -void fclaw2d_global_iterate_level_mthread (fclaw2d_global_t * glob, int level, - fclaw2d_patch_callback_t pcb, void *user) -{ - fclaw2d_global_iterate_t g; - g.glob = glob; - g.user = user; - fclaw2d_domain_iterate_level_mthread (glob->domain, level,pcb,&g); -} - -void fclaw2d_global_iterate_partitioned (fclaw2d_global_t * glob, - fclaw2d_domain_t * new_domain, - fclaw2d_transfer_callback_t tcb, - void *user) -{ - fclaw2d_global_iterate_t g; - g.glob = glob; - g.user = user; - fclaw2d_domain_iterate_partitioned (glob->domain,new_domain,tcb,&g); -} - -void fclaw2d_global_options_store (fclaw2d_global_t* glob, const char* key, void* options) -{ - - FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,key) == NULL); - fclaw_pointer_map_insert(glob->options, key, options, NULL); -} - -void* fclaw2d_global_get_options (fclaw2d_global_t* glob, const char* key) -{ - - void* options = fclaw_pointer_map_get(glob->options, key); - FCLAW_ASSERT(options != NULL); - return options; -} - -static fclaw2d_global_t* fclaw2d_global_glob = NULL; - -void fclaw2d_global_set_global (fclaw2d_global_t* glob) -{ - FCLAW_ASSERT (fclaw2d_global_glob == NULL); - fclaw2d_global_glob = glob; -} - -void fclaw2d_global_unset_global (void) -{ - FCLAW_ASSERT (fclaw2d_global_glob != NULL); - fclaw2d_global_glob = NULL; -} - -fclaw2d_global_t* fclaw2d_global_get_global (void) -{ - FCLAW_ASSERT(fclaw2d_global_glob != NULL); - return fclaw2d_global_glob; -} - -// Only 2d for now need fclaw2d_options -#ifndef P4_TO_P8 - -static char* old_path = NULL; - -void fclaw2d_set_global_context(fclaw2d_global_t *glob) -{ - fclaw_options_t* opts = fclaw2d_get_options(glob); - - // Change run directory - if(strcmp(opts->run_directory,"") != 0){ - FCLAW_ASSERT(old_path == NULL); - fclaw_set_logging_prefix(opts->logging_prefix); - old_path = fclaw_cwd(); - fclaw_cd(opts->run_directory); - } -} - -void fclaw2d_clear_global_context(fclaw2d_global_t *glob) -{ - fclaw_set_logging_prefix(NULL); - - // Return to previous cwd - if(old_path != NULL){ - fclaw_cd(old_path); - FCLAW_FREE(old_path); - old_path = NULL; - } -} - -#endif \ No newline at end of file diff --git a/src/fclaw2d_global.h b/src/fclaw2d_global.h deleted file mode 100644 index 41707faa5..000000000 --- a/src/fclaw2d_global.h +++ /dev/null @@ -1,235 +0,0 @@ -/* -Copyright (c) 2012-2023 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW2D_GLOBAL_H -#define FCLAW2D_GLOBAL_H - -#include /* Needed to declare callbacks (below) */ -#include /* Needed to store the map context */ - -#include /* Needed to create statically allocated array of timers */ - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -/* these are dimension-specific functions */ - -void fclaw2d_iterate_patch_cb - (fclaw2d_domain_t *domain, fclaw2d_patch_t *patch, - int blockno, int patchno, void *user); - -void fclaw2d_iterate_family_cb - (fclaw2d_domain_t *domain, fclaw2d_patch_t *patch, - int blockno, int patchno, void *user); - -/* much of the following will move into fclaw_global.h */ - -typedef struct fclaw2d_global fclaw2d_global_t; -typedef struct fclaw2d_global_iterate fclaw2d_global_iterate_t; - -struct fclaw2d_global -{ - int count_amr_advance; - int count_ghost_exchange; - int count_amr_regrid; - int count_amr_new_domain; - int count_single_step; - int count_elliptic_grids; - int count_multiproc_corner; - int count_grids_per_proc; - int count_grids_remote_boundary; - int count_grids_local_boundary; - fclaw2d_timer_t timers[FCLAW2D_TIMER_COUNT]; - - /* Time at start of each subcycled time step */ - double curr_time; - double curr_dt; - - sc_MPI_Comm mpicomm; - int mpisize; /**< Size of communicator. */ - int mpirank; /**< Rank of this process in \b mpicomm. */ - - /** Solver packages for internal use. */ - struct fclaw_package_container *pkg_container; - - struct fclaw_pointer_map *vtables; /**< Vtables */ - struct fclaw_pointer_map *options; /**< options */ - - struct fclaw2d_map_context* cont; - struct fclaw2d_domain *domain; - - /* CB: is this a good place for the accumulator? - Would it be possible to add and retrieve it as an anonymous - object that does not need to be known to this file? */ - struct fclaw2d_diagnostics_accumulator *acc; - - /* CB: this is application specific. - Would it not be cleaner to add the gauges in a way to global - that this file does not need to know about gauges at all? */ - struct fclaw_gauge_info* gauge_info; - - void *user; -}; - -struct fclaw2d_global_iterate -{ - fclaw2d_global_t* glob; - void* user; -}; - -/* Use forward references here, since this file gets included everywhere */ -/* CB: is there a way not to need the forward references? - Depending on fclaw2d_domain, _map, package seems entirely acceptable. - For those, including the respective headers might not be so bad. - About the diagnostics accumulator see remark above. */ -struct fclaw2d_domain; -struct fclaw2d_map_context; -struct fclaw_package_container; -struct fclaw2d_diagnostics_accumulator; - -/** Allocate a new global structure. */ -fclaw2d_global_t* fclaw2d_global_new (void); - -fclaw2d_global_t* fclaw2d_global_new_comm (sc_MPI_Comm mpicomm, - int mpisize, int mpirank); - -void fclaw2d_global_destroy (fclaw2d_global_t * glob); - -void fclaw2d_global_store_domain (fclaw2d_global_t* glob, - struct fclaw2d_domain* domain); - -void fclaw2d_global_store_map (fclaw2d_global_t* glob, - struct fclaw2d_map_context * map); -/** - * @brief Pack global structure into buffer - * - * @param glob the global structure - * @param buffer the buffer to write to - * @return size_t number of bytes written - */ -size_t fclaw2d_global_pack(const fclaw2d_global_t * glob, char* buffer); - -/** - * @brief Get the number of bytes needed to pack the global structure - * - * @param glob the structure - * @return size_t the number of bytes needed to store structure - */ -size_t fclaw2d_global_packsize(const fclaw2d_global_t * glob); - -/** - * @brief Unpack global structure from buffer - * - * @param buffer the buffer to read from - * @param glob newly create global structure - * @return size_t number of bytes read - */ -size_t fclaw2d_global_unpack(char* buffer, fclaw2d_global_t** glob); - -void fclaw2d_global_iterate_level (fclaw2d_global_t * glob, int level, - fclaw2d_patch_callback_t pcb, void *user); - -void fclaw2d_global_iterate_patches (fclaw2d_global_t * glob, - fclaw2d_patch_callback_t pcb, void *user); - -void fclaw2d_global_iterate_families (fclaw2d_global_t * glob, - fclaw2d_patch_callback_t pcb, void *user); - -void fclaw2d_global_iterate_adapted (fclaw2d_global_t * glob, - struct fclaw2d_domain* new_domain, - fclaw2d_match_callback_t mcb, void *user); - -void fclaw2d_global_iterate_level_mthread (fclaw2d_global_t * glob, int level, - fclaw2d_patch_callback_t pcb, void *user); - -void fclaw2d_global_iterate_partitioned (fclaw2d_global_t * glob, - struct fclaw2d_domain * new_domain, - fclaw2d_transfer_callback_t tcb, - void *user); - -/** - * @brief Store an options structure in the glob - * - * @param glob the global context - * @param key the key to store the options under - * @param options the options structure - */ -void fclaw2d_global_options_store (fclaw2d_global_t* glob, const char* key, void* options); - -/** - * @brief Get an options structure from the glob - * - * @param glob the global context - * @param key the key to retrieve the options from - * @return void* the options - */ -void* fclaw2d_global_get_options (fclaw2d_global_t* glob, const char* key); - -/** - * @brief Store a glob variable in static memory - * - * @param glob the glob variable - */ -void fclaw2d_global_set_global (fclaw2d_global_t* glob); - -/** - * @brief Set the static glob variable to NULL - */ -void fclaw2d_global_unset_global (void); - -/** - * @brief Get the static glob variable - * - * @return fclaw2d_global_t* the glob variable - */ -fclaw2d_global_t* fclaw2d_global_get_global (void); - -/** - * @brief - * - * @param glob - */ -void fclaw2d_set_global_context(fclaw2d_global_t *glob); - -/** - * @brief - * - * @param glob - */ -void fclaw2d_clear_global_context(fclaw2d_global_t *glob); - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - -#endif /* !FCLAW2D_GLOBAL_H */ diff --git a/src/fclaw2d_map_brick.c b/src/fclaw2d_map_brick.c deleted file mode 100644 index f32f09d96..000000000 --- a/src/fclaw2d_map_brick.c +++ /dev/null @@ -1,181 +0,0 @@ -/* Cartesian grid, tranformed to Ax + b */ - -#include - -#include -#include - -static int -fclaw2d_map_query_brick (fclaw2d_map_context_t * cont, int query_identifier) -{ - switch (query_identifier) - { - case FCLAW2D_MAP_QUERY_IS_USED: - return 1; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: - return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: - return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: - return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: - return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: - return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: - return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: - return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: - return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: - return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: - return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: - return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: - return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: - return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: - return 0; - case FCLAW2D_MAP_QUERY_IS_CART: - return 1; - case FCLAW2D_MAP_QUERY_IS_BRICK: - return 1; - default: - printf("\n"); - printf("fclaw2d_map_query_brick (fclaw2d_map_brick.h) : "\ - "Query id not identified; Maybe the query is not up to "\ - "date?\nSee fclaw2d_map_brick.c.\n"); - printf("Requested query id : %d\n",query_identifier); - SC_ABORT_NOT_REACHED (); - } - return 0; -} - -void -FCLAW2D_MAP_BRICK_GET_DIM(fclaw2d_map_context_t **cont, - int *mi, int* mj) -{ - fclaw2d_block_ll_t *bv = (fclaw2d_block_ll_t *) (*cont)->brick->user_data; - *mi = bv->mi; - *mj = bv->mj; -} - - -static void -fclaw2d_map_c2m_brick(fclaw2d_map_context_t * cont, int blockno, - double xc, double yc, - double *xp, double *yp, double *zp) -{ - /* Map the brick coordinates to global [0,1] coordinates. */ - fclaw2d_block_ll_t *bv = (fclaw2d_block_ll_t *) cont->user_data; - *xp = (double) (bv->xv[blockno] + xc)/bv->mi; - *yp = (double) (bv->yv[blockno] + yc)/bv->mj; - *zp = 0; -} - -void fclaw2d_map_destroy_brick(fclaw2d_map_context_t *cont) -{ - fclaw2d_block_ll_t *bv = (fclaw2d_block_ll_t *) cont->user_data; - FCLAW_FREE(bv->xv); - FCLAW_FREE(bv->yv); - - FCLAW_FREE (cont->user_data); - FCLAW_FREE (cont); -} - - -fclaw2d_map_context_t* fclaw2d_map_new_brick_conn - (p4est_connectivity_t *conn, int mi, int mj) -{ - fclaw2d_map_context_t *cont; - fclaw2d_block_ll_t *bv; - int i,nb,vnum; - - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); - cont->query = fclaw2d_map_query_brick; - cont->mapc2m = fclaw2d_map_c2m_brick; - cont->destroy = fclaw2d_map_destroy_brick; - - nb = (int) conn->num_trees; - bv = FCLAW_ALLOC_ZERO(fclaw2d_block_ll_t,1); - - /* We don't store this in user_double[], since that only has limited - storage (16 doubles) */ - bv->xv = FCLAW_ALLOC_ZERO(double,nb); - bv->yv = FCLAW_ALLOC_ZERO(double,nb); - - bv->nb = nb; /* These integer values could also be stored in user_int[] data */ - bv->mi = mi; - bv->mj = mj; - - for (i = 0; i < nb; i++) - { - vnum = conn->tree_to_vertex[4 * i]; - /* (x,y) coordinates of lower-left corner */ - bv->xv[i] = conn->vertices[3*vnum]; - bv->yv[i] = conn->vertices[3*vnum+1]; - } - cont->user_data = (void*) bv; - - /* Write data for Matlab plotting */ - FILE *fid; - fid = fopen("brick.dat","w"); - fprintf(fid,"%8d %8d\n",mi, mj); - for(i = 0; i < nb; i++) - { - fprintf(fid,"%12g %12g\n",bv->xv[i], bv->yv[i]); - } - fclose(fid); - return cont; -} - -fclaw2d_map_context_t* -fclaw2d_map_new_brick (fclaw2d_domain_t *domain, - int mi, int mj, int periodic_i, int periodic_j) -{ - fclaw2d_map_context_t *cont; - fclaw2d_block_ll_t *bv; - int i,nb; - - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); - cont->query = fclaw2d_map_query_brick; - cont->mapc2m = fclaw2d_map_c2m_brick; - cont->destroy = fclaw2d_map_destroy_brick; - - nb = domain->num_blocks; - bv = FCLAW_ALLOC_ZERO(fclaw2d_block_ll_t,1); - - /* We don't store this in user_double[], since that only has limited - storage (16 doubles) */ - bv->xv = FCLAW_ALLOC_ZERO(double,nb); - bv->yv = FCLAW_ALLOC_ZERO(double,nb); - - bv->nb = nb; /* These integer values could also be stored in user_int[] data */ - bv->mi = mi; - bv->mj = mj; - - for (i = 0; i < nb; i++) - { - fclaw2d_block_t *block = &domain->blocks[i]; - - /* (x,y) reference coordinates of lower-left block corner */ - bv->xv[i] = block->vertices[0]; - bv->yv[i] = block->vertices[1]; - } - cont->user_data = (void*) bv; - - /* Write data for Matlab plotting */ - FILE *fid; - fid = fopen("brick.dat","w"); - fprintf(fid,"%8d %8d\n",mi, mj); - for(i = 0; i < nb; i++) - { - fprintf(fid,"%12g %12g\n",bv->xv[i], bv->yv[i]); - } - fclose(fid); - return cont; -} diff --git a/src/fclaw2d_map_query.h b/src/fclaw2d_map_query.h deleted file mode 100644 index d8f6ff06a..000000000 --- a/src/fclaw2d_map_query.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#ifndef FCLAW2D_MAP_QUERY_H -#define FCLAW2D_MAP_QUERY_H - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -#define FCLAW2D_MAP_IS_USED FCLAW_F77_FUNC_(fclaw2d_map_is_used,FCLAW2D_MAP_IS_USED) -int FCLAW2D_MAP_IS_USED(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_CART FCLAW_F77_FUNC_(fclaw2d_map_is_cart,FCLAW2D_MAP_IS_CART) -int FCLAW2D_MAP_IS_CART(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_AFFINE FCLAW_F77_FUNC_(fclaw2d_map_is_affine,FCLAW2D_MAP_IS_AFFINE) -int FCLAW2D_MAP_IS_AFFINE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_DISK FCLAW_F77_FUNC_(fclaw2d_map_is_disk,FCLAW2D_MAP_IS_DISK) -int FCLAW2D_MAP_IS_DISK(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_PILLOWDISK FCLAW_F77_FUNC_(fclaw2d_map_is_pillowdisk,FCLAW2D_MAP_IS_PILLOWDISK) -int FCLAW2D_MAP_IS_PILLOWDISK(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_SQUAREDDISK FCLAW_F77_FUNC_(fclaw2d_map_is_squareddisk,FCLAW2D_MAP_IS_SQUAREDDISK) -int FCLAW2D_MAP_IS_SQUAREDDISK(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_PILLOWSPHERE FCLAW_F77_FUNC_(fclaw2d_map_is_pillowsphere,FCLAW2D_MAP_IS_PILLOWSPHERE) -int FCLAW2D_MAP_IS_PILLOWSPHERE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_CUBEDSPHERE FCLAW_F77_FUNC_(fclaw2d_map_is_cubedsphere,FCLAW2D_MAP_IS_CUBEDSPHERE) -int FCLAW2D_MAP_IS_CUBEDSPHERE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_FLAT FCLAW_F77_FUNC_(fclaw2d_map_is_flat,FCLAW2D_MAP_IS_FLAT) -int FCLAW2D_MAP_IS_FLAT(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_SPHERE FCLAW_F77_FUNC_(fclaw2d_map_is_sphere,FCLAW2D_MAP_IS_SPHERE) -int FCLAW2D_MAP_IS_SPHERE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_HEMISPHERE FCLAW_F77_FUNC_(fclaw2d_map_is_hemisphere,FCLAW2D_MAP_IS_HEMISPHERE) -int FCLAW2D_MAP_IS_HEMISPHERE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_TORUS FCLAW_F77_FUNC_(fclaw2d_map_is_torus,FCLAW2D_MAP_TORUS) -int FCLAW2D_MAP_IS_TORUS(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_BRICK FCLAW_F77_FUNC_(fclaw2d_map_is_brick,FCLAW2D_MAP_BRICK) -int FCLAW2D_MAP_IS_BRICK(fclaw2d_map_context_t** cont); - - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - - -#endif diff --git a/src/fclaw2d_options.c b/src/fclaw2d_options.c deleted file mode 100644 index 86d5164ec..000000000 --- a/src/fclaw2d_options.c +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright (c) 2012-2023 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#ifndef P4_TO_P8 -#include -#include -#else -#include -#include -#endif - -/* --------------------------------------------------------- - Public interface to ForestClaw options - --------------------------------------------------------- */ - -void fclaw2d_options_store (fclaw2d_global_t *glob, fclaw_options_t* gparms) -{ - fclaw2d_global_options_store(glob, "fclaw2d", gparms); -} - -fclaw_options_t* fclaw2d_get_options(fclaw2d_global_t* glob) -{ - return (fclaw_options_t*) fclaw2d_global_get_options(glob, "fclaw2d"); -} diff --git a/src/fclaw2d_options.h b/src/fclaw2d_options.h deleted file mode 100644 index cf8571fbb..000000000 --- a/src/fclaw2d_options.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** \file - * - * Routines for handling general ForestClaw input options. - * - */ - -#ifndef FCLAW2D_OPTIONS_H -#define FCLAW2D_OPTIONS_H - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -struct fclaw2d_global; -struct fclaw_options; - -void fclaw2d_options_store (struct fclaw2d_global *glob, struct fclaw_options* fclaw_opt); - -fclaw_options_t* fclaw2d_get_options(struct fclaw2d_global *glob); - - -#ifndef FCLAW_PATCH_DIM -#define FCLAW_PATCH_DIM 2 -#endif - -#ifndef FCLAW_REFINE_DIM -#define FCLAW_REFINE_DIM 2 -#endif - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - -#endif /* !FCLAW2D_OPTIONS_H */ diff --git a/src/fclaw2d_output_tikz.c b/src/fclaw2d_output_tikz.c index cec9bc0f4..c98318a90 100644 --- a/src/fclaw2d_output_tikz.c +++ b/src/fclaw2d_output_tikz.c @@ -23,17 +23,17 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include /* Needed for MPI declarations */ -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include -#include +#include #include typedef struct @@ -49,14 +49,14 @@ typedef struct } fclaw2d_tikz_info_t; static -void convert_brick(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void convert_brick(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, double* xlower, double* ylower) { - fclaw2d_map_context_t* cont = glob->cont; + fclaw_map_context_t* cont = glob->cont; - int is_brick = FCLAW2D_MAP_IS_BRICK(&cont); + int is_brick = FCLAW_MAP_IS_BRICK(&cont); double xl = this_patch->xlower; double yl = this_patch->ylower; @@ -67,7 +67,7 @@ void convert_brick(fclaw2d_global_t *glob, { double z; /* Scale to [0,1]x[0,1], based on blockno */ - fclaw2d_map_c2m_nomap_brick(cont,blockno,xl,yl,&xlow,&ylow,&z); + fclaw_map_2d_c2m_nomap_brick(cont,blockno,xl,yl,&xlow,&ylow,&z); } else { @@ -93,12 +93,12 @@ void convert_brick(fclaw2d_global_t *glob, static void -cb_tikz_output (fclaw2d_domain_t * domain, - fclaw2d_patch_t * this_patch, +cb_tikz_output (fclaw_domain_t * domain, + fclaw_patch_t * this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t *s = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *s = (fclaw_global_iterate_t *) user; fclaw2d_tikz_info_t *s_tikz = (fclaw2d_tikz_info_t*) s->user; int mx, my, mi, mj, level, lmax, mxf, myf; @@ -107,9 +107,9 @@ cb_tikz_output (fclaw2d_domain_t * domain, const char* indent = " "; FILE *fp = s_tikz->fp; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(s->glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(s->glob); - fclaw2d_block_t *this_block = &domain->blocks[this_block_idx]; + fclaw_block_t *this_block = &domain->blocks[this_block_idx]; int64_t patch_num = domain->global_num_patches_before + (int64_t) (this_block->num_patches_before + this_patch_idx); @@ -156,15 +156,15 @@ cb_tikz_output (fclaw2d_domain_t * domain, #endif } -void fclaw2d_output_frame_tikz(fclaw2d_global_t* glob, int iframe) +void fclaw2d_output_frame_tikz(fclaw_global_t* glob, int iframe) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; fclaw2d_tikz_info_t s_tikz; char fname[20]; /* Should be in fclaw_opt */ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double figsize[2]; figsize[0] = fclaw_opt->tikz_figsize[0]; /* Inches */ @@ -237,9 +237,9 @@ void fclaw2d_output_frame_tikz(fclaw2d_global_t* glob, int iframe) fp = fopen(fname,"a"); s_tikz.fp = fp; - fclaw2d_domain_serialization_enter (domain); - fclaw2d_global_iterate_patches (glob, cb_tikz_output, (void *) &s_tikz); - fclaw2d_domain_serialization_leave (domain); + fclaw_domain_serialization_enter (domain); + fclaw_global_iterate_patches (glob, cb_tikz_output, (void *) &s_tikz); + fclaw_domain_serialization_leave (domain); fclose(fp); diff --git a/src/fclaw2d_patch.h b/src/fclaw2d_patch.h deleted file mode 100644 index 0bbd968fd..000000000 --- a/src/fclaw2d_patch.h +++ /dev/null @@ -1,1849 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/** - * @file - * @brief Patch related functions and typedefs - */ - - -#ifndef FCLAW2D_PATCH_H -#define FCLAW2D_PATCH_H - -#include /* Contains definition of patch-iterator callback */ - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} -#endif -#endif - - -/** vtable type */ -typedef struct fclaw2d_patch_vtable fclaw2d_patch_vtable_t; -/** patch data type */ -typedef struct fclaw2d_patch_data fclaw2d_patch_data_t; -/** transform data type */ -typedef struct fclaw2d_patch_transform_data fclaw2d_patch_transform_data_t; - -/** - * @brief The build mode - */ -typedef enum -{ - /** Expect the patch's area array to be computed when unpacked */ - FCLAW2D_BUILD_FOR_GHOST_AREA_COMPUTED = 0, - /** Pack a patch's area array */ - FCLAW2D_BUILD_FOR_GHOST_AREA_PACKED, - /** Build for an updated grid */ - FCLAW2D_BUILD_FOR_UPDATE, - /** Use a user defined build mode */ - FCLAW2D_BUILD_CUSTOM -} fclaw2d_build_mode_t; - - - -/** - * @brief Structure for user patch data - * - * The user patch (clawpatch, for example) is stored in fclaw2d_patch_data.user_patch - */ -struct fclaw2d_patch_data -{ - /** Pointer to the core patch structure in the domain */ - const fclaw2d_patch_t *real_patch; - - /** Neighbor relation on each face */ - fclaw2d_patch_relation_t face_neighbors[4]; - /** Neighbor relation on each corner */ - fclaw2d_patch_relation_t corner_neighbors[4]; - /** True if coner has neighbor */ - int corners[4]; - /** The number of patches that meet at each corner */ - int block_corner_count[4]; - /** True if this patch lies on a coarse-fine interface */ - int on_coarsefine_interface; - /** True if there are finer neighbors */ - int has_finegrid_neighbors; - /** True if neighbor information is set */ - int neighbors_set; - - /** Patch index */ - int patch_idx; - /** Block index */ - int block_idx; - - /** User defined patch structure */ - void *user_patch; - /** Additional user data */ - void *user_data; -}; - -/** - * @brief Transform data for a neighboring patch's coordinate system - */ -struct fclaw2d_patch_transform_data -{ - /** Pointer to this patch */ - struct fclaw2d_patch *this_patch; - /** Pointer to the neighbor patch */ - struct fclaw2d_patch *neighbor_patch; - /** - * @brief Transform array - * - * This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - * [1,4,7] 0 (unused for compatibility with 3D).ftransform - */ - int transform[9]; - /** The corner that the neighboring patch is on. */ - int icorner; - /** - * @brief Base index - * - * 1 for cell-centered (1 .. mx); 0 for nodes (0 .. mx) - */ - int based; - /** True if patch is on a block corner */ - int is_block_corner; - /** -1 for interior faces or block corners */ - int block_iface; - - /** Pointer to the glboal context */ - struct fclaw2d_global *glob; - /** User pointer */ - void* user; -}; - - -struct fclaw2d_global; -struct fclaw2d_domain; -struct fclaw2d_patch; - - -/* ------------------------------------------------------------------------------------ */ -/// @name Creating/Deleting Patches -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * DEPRECATED - * @deprecated NOT USED - */ -void fclaw2d_patch_reset_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* old_patch, - struct fclaw2d_patch* new_patch, - int blockno,int old_patchno, int new_patchno); - - -/** - * @brief Deallocate the user data pointer for a patch - * - * @param[in] glob the global context - * @param[in,out] patch the patch context, user data pointer is set to NULL on return - */ -void fclaw2d_patch_data_delete(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch); - -/** - * @brief Construct a new patch object - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in,out] user user data pointer - */ -void fclaw2d_patch_build(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - void *user); - -/** - * @brief Construct a new patch object from a set of fine patches - * - * @param[in] glob the global context - * @param[in] fine_patches the fine patch contexts - * @param[in,out] coarse_patches the coarse patch context - * @param[in] blockno the block number - * @param[in] coarse_patchno coarse patch number - * @param[in] fine0_patchno first fine patch number - * @param[in] build_mode the build mode - */ -void fclaw2d_patch_build_from_fine(struct fclaw2d_global *glob, - struct fclaw2d_patch *fine_patches, - struct fclaw2d_patch *coarse_patch, - int blockno, - int coarse_patchno, - int fine0_patchno, - fclaw2d_build_mode_t build_mode); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Solver Specific Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Initialize patch data for a solver - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -void fclaw2d_patch_initialize(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno); - -/** - * @brief Initialize boundary conditions - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] t the time - * @param[in] dt the timestep - * @param[in] intersects_bc array of values for each face, true if physical boundary - * @param[in] time_interp true if in time interpolation stage (not global) - */ -void fclaw2d_patch_physical_bc(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - double t, - double dt, - int *intersects_bc, - int time_interp); - -/** - * @brief Advance a patch with a single time step - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] t the time - * @param[in] dt the timestep - * @param[in] user pointer to the ::fclaw2d_single_step_buffer_data struct (used in cudaclaw) - * @return double the maxcfl - */ -double fclaw2d_patch_single_step_update(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - double t, - double dt, void* user); - -/** - * @brief Set the right hand side for a patch - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -void fclaw2d_patch_set_rhs(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - int blockno, - int patchno); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Time Stepping -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Restores a previously saved solution - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - */ -void fclaw2d_patch_restore_step(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch); - -/** - * @brief Saves the current solution for later use - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - */ -void fclaw2d_patch_save_step(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch); - -/** - * @brief Sets up interpolated values for a patch - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] alpha the alpha value, with 0 being the last time step and 1 being the current time step - */ -void fclaw2d_patch_setup_timeinterp(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - double alpha); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Ghost Filling -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Copies ghost data from a face-neighboring grid on the same level - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch context - * @param[in] neighbor_patch the neighbor patch context - * @param[in] iface the interface that the neighbor patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw2d_patch_copy_face(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, - struct fclaw2d_patch *neighbor_patch, - int iface, - int time_interp, - struct fclaw2d_patch_transform_data *transform_data); - -/** - * @brief Averages values from a face-neighboring fine grid - * - * @param[in] glob the global context - * @param[in,out] coarse_patch this patch context - * @param[in] fine_patch the fine patch context - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] ifaced_coarse the interface of the fine neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refine_factor the refinement factor (number of neighbors) - * @param[in] refratio the refinement ratio - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] igrid the index of the fine neighbor in the child array - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw2d_patch_average_face(struct fclaw2d_global* glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch *fine_patch, - int idir, - int iface_coarse, - int refine_factor, - int refratio, - int time_interp, - int igrid, - struct fclaw2d_patch_transform_data* transform_data); - -/** - * @brief Interpolates values from a face-neighboring coarse grid - * - * @param[in] glob the global context - * @param[in] coarse_patch this patch context - * @param[in,out] fine_patch the fine patch context - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] ifaced_coarse the interface of the fine neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refine_factor the refinement factor (number of neighbors) - * @param[in] refratio the refinement ratio - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] igrid the index of the fine neighbor in the child array - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw2d_patch_interpolate_face(struct fclaw2d_global* glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch *fine_patch, - int idir, - int iside, - int RefineFactor, - int refratio, - int time_interp, - int igrid, - struct fclaw2d_patch_transform_data* transform_data); - -/** - * @brief Copies values from a corner-neighboring grid - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch context - * @param[in] neighbor_patch the neighbor patch context - * @param[in] this_blockno the block number of this patch - * @param[in] neighbor_blockno the block number of the neighbor patch - * @param[in] is_block_corner true if corner is on the corner of a block - * @param[in] icorner the corner that the neighboring patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw2d_patch_copy_corner(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, - struct fclaw2d_patch *neighbor_patch, - int this_blockno, - int neighbor_blockno, - int is_block_corner, - int icorner, - int time_interp, - struct fclaw2d_patch_transform_data *transform_data); - -/** - * @brief Averages values from a corner-neighboring fine grid - * - * @param[in] glob the global context - * @param[in,out] coarse_patch the coarse patch context - * @param[in] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] is_block_corner true if corner is on the corner of a block - * @param[in] icorner the corner of the coarse patch that the fine patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw2d_patch_average_corner(struct fclaw2d_global* glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch *fine_patch, - int coarse_blockno, - int fine_blockno, - int is_block_corner, - int coarse_corner, - int time_interp, - struct fclaw2d_patch_transform_data* transform_data); - -/** - * @brief Interpolates values from a corner-neighboring coarse grid - * - * @param[in] glob the global context - * @param[in] coarse_patch the coarse patch context - * @param[in,out] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] is_block_corner true if corner is on the corner of a block - * @param[in] icorner the corner of the coarse patch that the fine patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw2d_patch_interpolate_corner(struct fclaw2d_global* glob, - struct fclaw2d_patch* coarse_patch, - struct fclaw2d_patch* fine_patch, - int coarse_blockno, - int fine_blockno, - int is_block_corner, - int coarse_corner, - int time_interp, - struct fclaw2d_patch_transform_data* transform_data); - -///@} -/** - * DEPRECATED - * @deprecated NOT USED - */ -void fclaw2d_patch_create_user_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - -/** - * DEPRECATED - * @deprecated NOT USED - */ -void fclaw2d_patch_destroy_user_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - -/* ------------------------------------------------------------------------------------ */ -/// @name Transform Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Initialize the transform data for a patch - * - * @param[in] glob the global context - * @param[in] patch the patch context - * @param[in] blockno the block number, -1 if ghost patch - * @param[in] patchno the patch number - * @param[in,out] tdata the stransform data structure - */ -void fclaw2d_patch_transform_init_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int blockno, int patchno, - struct fclaw2d_patch_transform_data *tdata); - -/** - * @brief Get the transform on a block face - * - * @param[in] glob the global context - * @param[in] faceno - * @param[in] rfaceno - * @param[out] ftransform This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - * [1,4,7] 0 (unused for compatibility with 3D).ftransform - */ -void fclaw2d_patch_transform_blockface(struct fclaw2d_global* glob, - int faceno, int rfaceno, - int ftransform[]); - -/** - * @brief Get the transform for within a block (the identity transform) - * - * @param[in] glob the global context - * @param[out] ftransform This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - * [1,4,7] 0 (unused for compatibility with 3D).ftransform - */ -void fclaw2d_patch_transform_blockface_intra(struct fclaw2d_global* glob, - int ftransform[]); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Regridding Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Tag a patch for refinement - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] this_blockno the block number - * @param[in] this_patchno the patch number - * @param[in] initflag true if in init phase - * @return true if patch should be refined - */ -int fclaw2d_patch_tag4refinement(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, int patchno, - int initflag); - -/** - * @brief Tag a patch for coarsening - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] this_blockno the block number - * @param[in] this_patchno the patch number - * @param[in] initflag true if in init phase - * @return true if patch should be coarsened - */ -int fclaw2d_patch_tag4coarsening(struct fclaw2d_global *glob, - struct fclaw2d_patch *fine_patches, - int blockno, - int patchno, - int initflag); - -/** - * @brief Interpolates a set of patches from a coarse patch - * - * @param[in] glob the global context - * @param[in] coarse_patch the coarse patch context - * @param[in,out] fine_patches the fine patch contexts - * @param[in] blockno the block number - * @param[in] coarse_patchno the patch number of the coarse patch - * @param[in] fine0_patchno the patch number of the first fine patch - */ -void fclaw2d_patch_interpolate2fine(struct fclaw2d_global *glob, - struct fclaw2d_patch* coarse_patch, - struct fclaw2d_patch* fine_patches, - int this_blockno, int coarse_patchno, - int fine0_patchno); - -/** - * @brief Averages from a set of fine patches to a coarse patch - * - * @param[in] glob the global context - * @param[in] fine_patches the fine patch contexts - * @param[in,out] coarse_patch the coarse patch context - * @param[in] blockno the block number - * @param[in] fine_patchno the patch number of the first fine patch - * @param[in] coarse_patchno the patch number of the coarse patch - */ -void fclaw2d_patch_average2coarse(struct fclaw2d_global *glob, - struct fclaw2d_patch *fine_patches, - struct fclaw2d_patch *coarse_patch, - int blockno, int fine0_patchno, - int coarse_patchno); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Parallel Ghost Patches -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Get the buffer size needed to pack a single patch's ghost data - * - * @param[in] glob the global context - * @return the buffer size (in bytes) - */ -size_t fclaw2d_patch_ghost_packsize(struct fclaw2d_global* glob); - -/** - * @brief Allocates a buffer for the patch ghost data - * - * @param[in] glob the global context - * @param[out] q pointer to the allocated buffer - */ -void fclaw2d_patch_local_ghost_alloc(struct fclaw2d_global* glob, - void** q); - -/** - * @brief Frees a buffer for the patch ghost data - * - * @param[in] glob the global context - * @param[out] q pointer to the buffer to free - */ -void fclaw2d_patch_local_ghost_free(struct fclaw2d_global* glob, - void **q); - -/** - * @brief Packs the patch ghost data into a buffer - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in,out] patch_data the buffer - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - */ -void fclaw2d_patch_local_ghost_pack(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - void *patch_data, - int time_interp); - -/** - * @brief Builds a new ghost patch - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] build_mode the build mode - */ -void fclaw2d_patch_remote_ghost_build(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - fclaw2d_build_mode_t build_mode); - -/** - * @brief Unpacks a ghost patch from a buffer - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] qdata the buffer to unpack from - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - */ -void fclaw2d_patch_remote_ghost_unpack(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - int blockno, int patchno, - void *qdata, int time_interp); - - -/** - * @brief Frees memory used by a ghost patch - * - * @param[in] glob the global context - * @param[in,out] ghost_patch the patch context - */ -void fclaw2d_patch_remote_ghost_delete(struct fclaw2d_global *glob, - struct fclaw2d_patch *ghost_patch); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Parallel Partitioning -/* ------------------------------------------------------------------------------------ */ -///@{ - - -/** - * @brief Packs a patch into a buffer - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[out] pack_data_here the buffer - */ -void fclaw2d_patch_partition_pack(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - void *pack_data_here); - -/** - * @brief Unpacks a patch from a buffer - * - * @param[in] glob the global context (contains the old domain) - * @param[in] new_domain the new domain - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] packed_data the buffer - */ -void fclaw2d_patch_partition_unpack(struct fclaw2d_global *glob, - struct fclaw2d_domain *new_domain, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - void *packed_data); - -/** - * @brief Gets the buffer size (in bytes) needed to pack a patch - * - * @param[in] glob the global context - * @return size_t the size of buffer needed - */ -size_t fclaw2d_patch_partition_packsize(struct fclaw2d_global* glob); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Time Syncing Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Adds fine grid corrections to coarse grid. - * - * @param[in] glob the global context - * @param[in,out] coarse_patch the coarse patch context - * @param[in] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] coarse_patchno the patch number of the coarse patch - * @param[in] idir the direction of the interface 0 for bottom/top - * 1 for left/right - * @param[in] igrid the index of the fine grid in the child array - * @param[in] iface_coarse the interface on the coarse patch - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] transform_data the transform for the neighbor's coordinates - */ -void fclaw2d_patch_time_sync_f2c(struct fclaw2d_global* glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch *fine_patch, - int coarse_blockno, int fine_blockno, - int coarse_patchno, - int idir, - int igrid, - int iface_coarse, - int time_interp, - struct fclaw2d_patch_transform_data* transform_data); - -/** - * @brief Adds corrections to patches that are at the same levle and are at block boundaries. - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch - * @param[in] neighbor_patch the neighbor patch - * @param[in] this_iface the interface that the neighbor patch is on - * @param[in] idir the direction of the interface 0 for bottom/top - * 1 for left/right - * @param[in] transform_data the transform for the neighbor's coordinates - */ -void fclaw2d_patch_time_sync_samesize(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, - struct fclaw2d_patch *neighbor_patch, - int this_iface, int idir, - struct fclaw2d_patch_transform_data *transform_data); - -/** - * @brief Resets conservation data - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] coarse_level the the level of the coarse patch - * @param[in] reset_mode the reset mode ::fclaw2d_time_sync_type - */ -void fclaw2d_patch_time_sync_reset(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - int coarse_level, - int reset_mode); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Creating/Deleting Patches (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Allocates a new patch - * - * @return the newly allocated patch - */ -typedef void* (*fclaw2d_patch_new_t)(); - -/** - * @brief Deallocates a patch - * - * @param[in] user_patch the patch to deallocate - */ -typedef void (*fclaw2d_patch_delete_t)(void *user_patch); - -/** - * @brief Initializes the data members of a patch - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno patch number - * @param[in,out] user user data pointer - */ -typedef void (*fclaw2d_patch_build_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - void *user); - -/** - * @brief Initializes a new coarser patch from a set of finer patches - * - * @param[in] glob the global context - * @param[in] fine_patches the fine patch contexts - * @param[in,out] coarse_patches the coarse patch context - * @param[in] blockno the block number - * @param[in] coarse_patchno coarse patch number - * @param[in] fine0_patchno first fine patch number - * @param[in] build_mode the build mode - */ -typedef void (*fclaw2d_patch_build_from_fine_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *fine_patches, - struct fclaw2d_patch *coarse_patch, - int blockno, - int coarse_patchno, - int fine0_patchno, - fclaw2d_build_mode_t build_mode); - -/** - * @brief Performs additional setup for a patch - * - * @param[in] the global context - * @param[in,out] the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -typedef void (*fclaw2d_patch_setup_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int patchno, - int blockno); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Solver Specific Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Initializes values in arrays of patch - * - * @param[in] the global context - * @param[in,out] the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -typedef void (*fclaw2d_patch_initialize_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno); - -/** - * @brief Initializes boundary conditions - * - * @param[in] the global context - * @param[in,out] the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] t the the current time - * @param[in] dt the size of time step - * @param[in] intersects_bc array of values for each face, true if boundary on face is - * a physical boundary - * @param[in] time_interp the patch number - */ -typedef void (*fclaw2d_patch_physical_bc_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - double t, - double dt, - int *intersects_bc, - int time_interp); - -/** - * @brief Advances a patch using a single explicit time step. - * - * @param[in] the global context - * @param[in,out] the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] t the the current time - * @param[in] dt the size of time step - * @param[in,out] buffer_data pointer to the ::fclaw2d_single_step_buffer_data struct - * (used in cudaclaw) - * @return the maxcfl - */ -typedef double (*fclaw2d_patch_single_step_update_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - double t, - double dt, - void *user); - - -/** - * @brief Sets the right hand side for a patch - * - * @param[in] glob the global context - * @param[in,out] patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -typedef void (*fclaw2d_patch_rhs_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - int blockno, - int patchno); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Time Stepping (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** @copydoc fclaw2d_patch_setup_timeinterp() */ -typedef void (*fclaw2d_patch_setup_timeinterp_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - double alpha); - -/** @copydoc fclaw2d_patch_restore_step() */ -typedef void (*fclaw2d_patch_restore_step_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch* this_patch); - -/** @copydoc fclaw2d_patch_save_step() */ -typedef void (*fclaw2d_patch_save_step_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch* this_patch); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Ghost Filling (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Copies ghost data from a face-neighboring grid on the same level - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch context - * @param[in] neighbor_patch the neighbor patch context - * @param[in] iface the interface that the neighbor patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw2d_patch_copy_face_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, - struct fclaw2d_patch *neighbor_patch, - int iface, - int time_interp, - struct fclaw2d_patch_transform_data - *transform_data); - -/** - * @brief Averages values from a face-neighboring fine grid - * - * @param[in] glob the global context - * @param[in,out] coarse_patch this patch context - * @param[in] fine_patch the fine patch context - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] ifaced_coarse the interface of the fine neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refine_factor the refinement factor (number of neighbors) - * @param[in] refratio the refinement ratio - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] igrid the index of the fine neighbor in the child array - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw2d_patch_average_face_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch *fine_patch, - int idir, - int iface_coarse, - int refine_factor, - int refratio, - int time_interp, - int igrid, - struct fclaw2d_patch_transform_data - *transform_data); - -/** - * @brief Interpolates values from a face-neighboring coarse grid - * - * @param[in] glob the global context - * @param[in] coarse_patch this patch context - * @param[in,out] fine_patch the fine patch context - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] ifaced_coarse the interface of the fine neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refine_factor the refinement factor (number of neighbors) - * @param[in] refratio the refinement ratio - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] igrid the index of the fine neighbor in the child array - * @param[in] manifold true if using mainifold - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw2d_patch_interpolate_face_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch *fine_patch, - int idir, - int iside, - int refine_factor, - int refratio, - int time_interp, - int igrid, - struct fclaw2d_patch_transform_data - *transform_data); - -/** - * @brief Copies values from a corner-neighboring grid - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch context - * @param[in] neighbor_patch the neighbor patch context - * @param[in] this_blockno the block number of this patch - * @param[in] neighbor_blockno the block number of the neighbor patch - * @param[in] icorner the corner that the neighboring patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw2d_patch_copy_corner_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, - struct fclaw2d_patch *neighbor_patch, - int this_blockno, - int neighbor_blockno, - int icorner, - int time_interp, - struct fclaw2d_patch_transform_data - *transform_data); - -/** - * @brief Averages values from a corner-neighboring fine grid - * - * @param[in] glob the global context - * @param[in,out] coarse_patch the coarse patch context - * @param[in] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] icorner the corner of the coarse patch that the fine patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw2d_patch_average_corner_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch *fine_patch, - int coarse_blockno, - int fine_blockno, - int icorner, - int time_interp, - struct fclaw2d_patch_transform_data - *transform_data); - -/** - * @brief Interpolates values from a corner-neighboring coarse grid - * - * @param[in] glob the global context - * @param[in] coarse_patch the coarse patch context - * @param[in,out] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] icorner the corner of the coarse patch that the fine patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw2d_patch_interpolate_corner_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch *fine_patch, - int coarse_blockno, - int fine_blockno, - int icorner, - int time_interp, - struct fclaw2d_patch_transform_data - *transform_data); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Transform Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Initialize the transform data for a patch - * - * @param[in] glob the global context - * @param[in] patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in,out] tdata the stransform data structure - */ -typedef void (*fclaw2d_patch_transform_init_data_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int blockno, int patchno, - struct fclaw2d_patch_transform_data *tdata); - -/** - * @brief Gets the transform on a block face - * - * @param[in] faceno - * @param[in] rfaceno - * @param[out] ftransform This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - * [1,4,7] 0 (unused for compatibility with 3D).ftransform - */ -typedef void (*fclaw2d_patch_transform_blockface_t)(int faceno, int rfaceno, - int ftransform[]); - -/** - * @brief Gets the transform for within a block (the identity transform) - * - * @param[out] ftransform This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - * [1,4,7] 0 (unused for compatibility with 3D).ftransform - */ -typedef void (*fclaw2d_patch_transform_blockface_intra_t)(int ftransform[]); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Regridding Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Tags a patch for refinement - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] this_blockno the block number - * @param[in] this_patchno the patch number - * @param[in] initflag true if in init phase - * @return true if patch should be refined - */ -typedef int (*fclaw2d_patch_tag4refinement_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int this_blockno, int this_patchno, - int initflag); - -/** - * @brief Tags a patch for coarsening - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] this_blockno the block number - * @param[in] this_patchno the patch number - * @param[in] initflag true if in init phase - * @return true if patch should be coarsened - */ -typedef int (*fclaw2d_patch_tag4coarsening_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int this_blockno, - int this_patchno, - int initflag); - -/** - * @brief Interpolates a set of patches from a coarse patch - * - * @param[in] glob the global context - * @param[in] coarse_patch the coarse patch context - * @param[in,out] fine_patches the fine patch contexts - * @param[in] blockno the block number - * @param[in] coarse_patchno the patch number of the coarse patch - * @param[in] fine_patchno the patch number of the first fine patch - */ -typedef void (*fclaw2d_patch_interpolate2fine_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch* fine_patches, - int blockno, int coarse_patchno, - int fine_patchno); -/** - * @brief Averages from a set of fine patches to a coarse patch - * - * @param[in] glob the global context - * @param[in] fine_patches the fine patch contexts - * @param[in,out] coarse_patch the coarse patch context - * @param[in] blockno the block number - * @param[in] fine_patchno the patch number of the first fine patch - * @param[in] coarse_patchno the patch number of the coarse patch - */ -typedef void (*fclaw2d_patch_average2coarse_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *fine_patches, - struct fclaw2d_patch *coarse_patch, - int blockno, int fine_patchno, - int coarse_patchno); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Parallel Ghost Patches (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** @copydoc fclaw2d_patch_ghost_packsize() */ -typedef size_t (*fclaw2d_patch_ghost_packsize_t)(struct fclaw2d_global* glob); - -/** @copydoc fclaw2d_patch_local_ghost_pack() */ -typedef void (*fclaw2d_patch_local_ghost_pack_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - void *patch_data, - int time_interp); - -/** @copydoc fclaw2d_patch_local_ghost_alloc() */ -typedef void (*fclaw2d_patch_local_ghost_alloc_t)(struct fclaw2d_global* glob, - void** q); - -/** @copydoc fclaw2d_patch_local_ghost_free() */ -typedef void (*fclaw2d_patch_local_ghost_free_t)(struct fclaw2d_global* glob, - void **q); - - -/** @copydoc fclaw2d_patch_remote_ghost_build() */ -typedef void (*fclaw2d_patch_remote_ghost_build_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - fclaw2d_build_mode_t build_mode); - -/** - * @brief Performs additional setup step after build - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] blockno the patch number - */ -typedef void (*fclaw2d_patch_remote_ghost_setup_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno); - - -/** @copydoc fclaw2d_patch_remote_ghost_unpack() */ -typedef void (*fclaw2d_patch_remote_ghost_unpack_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch* this_patch, - int blockno, int patchno, - void *qdata, int time_interp); - -/** @copydoc fclaw2d_patch_remote_ghost_delete() */ -typedef void (*fclaw2d_patch_remote_ghost_delete_t)(void *user_patch); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Partitioning (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** @copydoc fclaw2d_patch_partition_packsize() */ -typedef size_t (*fclaw2d_patch_partition_packsize_t)(struct fclaw2d_global* glob); - - -/** @copydoc fclaw2d_patch_partition_pack() */ -typedef void (*fclaw2d_patch_partition_pack_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - void *pack_data_here); - -/** @copydoc fclaw2d_patch_partition_unpack() */ -typedef void (*fclaw2d_patch_partition_unpack_t)(struct fclaw2d_global *glob, - struct fclaw2d_domain *new_domain, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - void *unpack_data_from_here); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Conservative Updates (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - - -/** @copydoc fclaw2d_patch_time_sync_f2c() */ -typedef void (*fclaw2d_patch_time_sync_f2c_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *coarse_patch, - struct fclaw2d_patch *fine_patch, - int coarse_blockno, int fine_blockno, - int coarse_patchno, - int idir, - int igrid, - int iface_coarse, - int time_interp, - struct fclaw2d_patch_transform_data - *transform_data); - -/** @copydoc fclaw2d_patch_time_sync_samesize() */ -typedef void (*fclaw2d_patch_time_sync_samesize_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - struct fclaw2d_patch* neighbor_patch, - int this_iface, int idir, - struct fclaw2d_patch_transform_data - *transform_data); - -/** @copydoc fclaw2d_patch_time_sync_reset() */ -typedef void (*fclaw2d_patch_time_sync_reset_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - int coarse_level, - int reset_mode); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name User Data Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Creates user data - * - * @param[in] glob the global context - * @param[in,out] patch the patch context - */ -typedef void (*fclaw2d_patch_create_user_data_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch); - -/** - * @brief Destroys user data - * - * @param[in] glob the global context - * @param[in,out] patch the patch context - */ -typedef void (*fclaw2d_patch_destroy_user_data_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Access Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Returns the corresponding metric patch - * - * @param[in] patch the patch context - */ -typedef void* (*fclaw2d_patch_metric_patch_t)(struct fclaw2d_patch *patch); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Virtual Table -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** vtable for patch level routines */ -struct fclaw2d_patch_vtable -{ - /** @{ @name Creating/Deleting/Building */ - - /** @copybrief ::fclaw2d_patch_new_t */ - fclaw2d_patch_new_t patch_new; - /** @copybrief ::fclaw2d_patch_delete_t */ - fclaw2d_patch_delete_t patch_delete; - /** @copybrief ::fclaw2d_patch_build_t */ - fclaw2d_patch_build_t build; - /** @copybrief ::fclaw2d_patch_build_from_fine_t */ - fclaw2d_patch_build_from_fine_t build_from_fine; - /** @copybrief ::fclaw2d_patch_setup_t */ - fclaw2d_patch_setup_t setup; - - /** @} */ - - /** @copybrief ::fclaw2d_patch_metric_patch_t */ - fclaw2d_patch_metric_patch_t metric_patch; - - /** @{ @name User Data */ - - /** @copybrief ::fclaw2d_patch_create_user_data_t */ - fclaw2d_patch_create_user_data_t create_user_data; - /** @copybrief ::fclaw2d_patch_destroy_user_data_t */ - fclaw2d_patch_destroy_user_data_t destroy_user_data; - - /** @} */ - - /** @{ @name Solver Functions */ - - /** @copybrief ::fclaw2d_patch_initialize_t */ - fclaw2d_patch_initialize_t initialize; - /** @copybrief ::fclaw2d_patch_physical_bc_t */ - fclaw2d_patch_physical_bc_t physical_bc; - /** @copybrief ::fclaw2d_patch_single_step_update_t */ - fclaw2d_patch_single_step_update_t single_step_update; - /** @copybrief ::fclaw2d_patch_rhs_t */ - fclaw2d_patch_rhs_t rhs; - - /** @} */ - - /** @{ @name Time Stepping */ - - /** @copybrief ::fclaw2d_patch_restore_step_t */ - fclaw2d_patch_restore_step_t restore_step; - /** @copybrief ::fclaw2d_patch_save_step_t */ - fclaw2d_patch_save_step_t save_step; - /** @copybrief ::fclaw2d_patch_setup_timeinterp_t */ - fclaw2d_patch_setup_timeinterp_t setup_timeinterp; - - /** @} */ - - /** @{ @name Regridding Functions */ - - /** @copybrief ::fclaw2d_patch_tag4refinement_t */ - fclaw2d_patch_tag4refinement_t tag4refinement; - /** @copybrief ::fclaw2d_patch_tag4coarsening_t */ - fclaw2d_patch_tag4coarsening_t tag4coarsening; - /** @copybrief ::fclaw2d_patch_average2coarse_t */ - fclaw2d_patch_average2coarse_t average2coarse; - /** @copybrief ::fclaw2d_patch_interpolate2fine_t */ - fclaw2d_patch_interpolate2fine_t interpolate2fine; - - /** @} */ - - /** @{ @name Time Syncing Functions for Conservation */ - - /** @copybrief ::fclaw2d_patch_time_sync_f2c_t */ - fclaw2d_patch_time_sync_f2c_t time_sync_f2c; - /** @copybrief ::fclaw2d_patch_time_sync_samesize_t */ - fclaw2d_patch_time_sync_samesize_t time_sync_samesize; - /** @copybrief ::fclaw2d_patch_time_sync_reset_t */ - fclaw2d_patch_time_sync_reset_t time_sync_reset; - - /** @} */ - - - /** @{ @name Face Ghost Filling Functions */ - - /** @copybrief ::fclaw2d_patch_copy_face_t */ - fclaw2d_patch_copy_face_t copy_face; - /** @copybrief ::fclaw2d_patch_average_face_t */ - fclaw2d_patch_average_face_t average_face; - /** @copybrief ::fclaw2d_patch_interpolate_face_t */ - fclaw2d_patch_interpolate_face_t interpolate_face; - - /** @} */ - - /** @{ @name Block Face and Interior Corner Ghost Filling Functions */ - - /** @copybrief ::fclaw2d_patch_copy_corner_t */ - fclaw2d_patch_copy_corner_t copy_corner; - /** @copybrief ::fclaw2d_patch_average_corner_t */ - fclaw2d_patch_average_corner_t average_corner; - /** @copybrief ::fclaw2d_patch_interpolate_corner_t */ - fclaw2d_patch_interpolate_corner_t interpolate_corner; - - /** @} */ - - /** @{ @name Block Corner Ghost Filling Functions */ - - /** @copybrief ::fclaw2d_patch_copy_corner_t */ - fclaw2d_patch_copy_corner_t copy_block_corner; - /** @copybrief ::fclaw2d_patch_average_corner_t */ - fclaw2d_patch_average_corner_t average_block_corner; - /** @copybrief ::fclaw2d_patch_interpolate_corner_t */ - fclaw2d_patch_interpolate_corner_t interpolate_block_corner; - - /** @} */ - - /** @{ @name Transform Functions */ - - /** @copybrief ::fclaw2d_patch_transform_init_data_t */ - fclaw2d_patch_transform_init_data_t transform_init_data; - /** @copybrief ::fclaw2d_patch_transform_blockface_t */ - fclaw2d_patch_transform_blockface_t transform_face; - /** @copybrief ::fclaw2d_patch_transform_blockface_intra_t */ - fclaw2d_patch_transform_blockface_intra_t transform_face_intra; - - /** @} */ - - /** @{ @name Ghost Packing Functions (for parallel use) */ - - /** @copybrief ::fclaw2d_patch_ghost_packsize_t */ - fclaw2d_patch_ghost_packsize_t ghost_packsize; - /** @copybrief ::fclaw2d_patch_local_ghost_pack_t */ - fclaw2d_patch_local_ghost_pack_t local_ghost_pack; - /** @copybrief ::fclaw2d_patch_local_ghost_alloc_t */ - fclaw2d_patch_local_ghost_alloc_t local_ghost_alloc; - /** @copybrief ::fclaw2d_patch_local_ghost_free_t */ - fclaw2d_patch_local_ghost_free_t local_ghost_free; - - /** @copybrief ::fclaw2d_patch_remote_ghost_build_t */ - fclaw2d_patch_remote_ghost_build_t remote_ghost_build; - /** @copybrief ::fclaw2d_patch_remote_ghost_setup_t */ - fclaw2d_patch_remote_ghost_setup_t remote_ghost_setup; - /** @copybrief ::fclaw2d_patch_remote_ghost_unpack_t */ - fclaw2d_patch_remote_ghost_unpack_t remote_ghost_unpack; - /** @copybrief ::fclaw2d_patch_remote_ghost_delete_t */ - fclaw2d_patch_remote_ghost_delete_t remote_ghost_delete; - - /** @} */ - - /** @{ @name Parallel Load Balancing (partitioning) */ - - /** @copybrief ::fclaw2d_patch_partition_pack_t */ - fclaw2d_patch_partition_pack_t partition_pack; - /** @copybrief ::fclaw2d_patch_partition_unpack_t */ - fclaw2d_patch_partition_unpack_t partition_unpack; - /** @copybrief ::fclaw2d_patch_partition_packsize_t */ - fclaw2d_patch_partition_packsize_t partition_packsize; - - /** @} */ - - /** True if vtable has been set */ - int is_set; -}; - -/** - * @brief Get the patch vtable - * - * @param glob the global context - * @return fclaw2d_patch_vtable_t* the vtable - */ -fclaw2d_patch_vtable_t* fclaw2d_patch_vt(struct fclaw2d_global* glob); - -/** - * @brief Initialize the patch vtable - * - * @param glob the global context - */ -void fclaw2d_patch_vtable_initialize(struct fclaw2d_global* glob); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Misc Access Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Get the global_num, local_num, and level of a patch - * - * @param[in] domain - * @param[in] patch - * @param[in] blockno - * @param[in] patchno - * @param[out] global_num the global patch number - * @param[out] local_num the local patch number - * @param[out] level the level that the patch is on - */ -void fclaw2d_patch_get_info(struct fclaw2d_domain * domain, - struct fclaw2d_patch * patch, - int blockno, int patchno, - int *global_num, int* local_num, - int *level); - -/** - * @brief Get the block number, patch number, global_num, and level of a patch - * - * @param[in] domain the domain - * @param[in] this_patch the patch context - * @param[out] blockno the block number - * @param[out] patchno the patch number - * @param[out] global_num the global patch number - * @param[out] level the level - */ -/* I don't completely trust this routine */ -void fclaw2d_patch_get_info2(struct fclaw2d_domain * domain, - struct fclaw2d_patch * this_patch, - int *blockno, int *patchno, - int *global_num, int *level); -/** - * @brief Get the user patch pointer - * - * @param patch the patch context - * @return void* the pointer - */ -void* fclaw2d_patch_get_user_patch(struct fclaw2d_patch* patch); - -/** - * @brief Get the patch data - * - * @param patch the patch context - * @return struct fclaw2d_patch_data* pointer to the patch data - */ -struct fclaw2d_patch_data* fclaw2d_patch_get_patch_data(struct fclaw2d_patch* patch); - -/** - * @brief Get the user data pointer - * - * @param glob the global context - * @param this_patch the patch context - * @return void* the user data pointer - */ -void* fclaw2d_patch_get_user_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch); - - -/** - * @brief Get the metric patch - * - * @param glob the global context - * @param patch the patch context - * @return void* pointer to the metric patch - */ -void* fclaw2d_patch_metric_patch(struct fclaw2d_global* glob, - struct fclaw2d_patch *patch); - -/** - * @brief Get the block number - * - * @param this_patch the patch context - * @return int the block number - */ -int fclaw2d_patch_get_blockno(struct fclaw2d_patch* this_patch); - -/** - * @brief Get the patch number - * - * @param this_patch the patch context - * @return int the patch number - */ -int fclaw2d_patch_get_patchno(struct fclaw2d_patch* this_patch); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Misc User Data -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Get the user data pointer of a patch - * - * @param glob the global context - * @param this_patch the patch context - * @return void* the user data pointer - */ -void* fclaw2d_patch_user_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch); - -/** - * @brief Set the user data pointer of a patch - * - * @param glob the global context - * @param this_patch the patch context - * @param user the user data pointer - */ -void fclaw2d_patch_set_user_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - void* user); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Misc Functions (mostly internal) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Returns true if patch lies on a parallel boundary - * - * @param patch the patch context - * @return int true if on parallel boundary - */ -int fclaw2d_patch_on_parallel_boundary (const struct fclaw2d_patch * patch); - - -/** - * @brief Set the face type for a patch - * - * @param patch the patch context - * @param iface the interface - * @param face_type the face type - */ -void fclaw2d_patch_set_face_type(struct fclaw2d_patch *patch, int iface, - fclaw2d_patch_relation_t face_type); - -/** - * @brief Set the corner type for a patch - * - * @param patch the patch context - * @param icorner the corner - * @param corner_type the corner type - */ -void fclaw2d_patch_set_corner_type(struct fclaw2d_patch *patch, int icorner, - fclaw2d_patch_relation_t corner_type); - -/** - * @brief Set the missing corner of a patch - * - * @param patch the patch context - * @param icorner the missing corner - */ -void fclaw2d_patch_set_missing_corner(struct fclaw2d_patch *patch, int icorner); - -/** - * @brief Get the face type of a patch - * - * @param patch the patch context - * @param iface the face - * @return fclaw2d_patch_relation_t the face type - */ -fclaw2d_patch_relation_t fclaw2d_patch_get_face_type(struct fclaw2d_patch* patch, - int iface); - -/** - * @brief Get the corner type of a patch - * - * @param patch the patch context - * @param icorner the corner - * @return fclaw2d_patch_relation_t the patch relation - */ -fclaw2d_patch_relation_t fclaw2d_patch_get_corner_type(struct fclaw2d_patch* patch, - int icorner); - -/** - * @brief Returns true if a corner is missing - * - * @param patch the patch context - * @param icorner the corner - * @return int true if a corner is missing - */ -int fclaw2d_patch_corner_is_missing(struct fclaw2d_patch* patch, - int icorner); - -/** - * @brief Set the neighbor relation data for a patch - * - * @param patch the patch context - */ -void fclaw2d_patch_neighbors_set(fclaw2d_patch_t* patch); - -/** - * @brief Reset the neighbor relation data for a patch - * - * @param patch the patch context - */ -void fclaw2d_patch_neighbors_reset(struct fclaw2d_patch* patch); - -/** - * @brief Returns true if the patch neighbor information is set - * - * @param patch the patch context - * @return int true if the patch neighbor information is set - */ -int fclaw2d_patch_neighbor_type_set(struct fclaw2d_patch* patch); - -/** - * @brief Returns true if a patch has finer neighbors - * - * @param patch the patch context - * @return int true if the patch has finer neighbors - */ -int fclaw2d_patch_has_finegrid_neighbors(struct fclaw2d_patch *patch); - -/** - * @brief Returns true if the patch is on a coarse fine interface - * - * @param patch the patch context - * @return int true if the patch is on a coarse fine interface - */ -int fclaw2d_patch_on_coarsefine_interface(struct fclaw2d_patch *patch); - -/** - * @brief Get the block corner count array for a patch - * - * @param glob the global context - * @param this_patch the patch context - * @return int* the array with the block corner count (the number of blocks that meet) for each corner - */ -int* fclaw2d_patch_block_corner_count(struct fclaw2d_global *glob, - struct fclaw2d_patch* this_patch); - -/** - * @brief Set the block corner count for a corner - * - * @param glob the global context - * @param this_patch the patch context - * @param icorner the corner to set - * @param block_corner_count the block corner count (the number of blocks that meet) - */ -void fclaw2d_patch_set_block_corner_count(struct fclaw2d_global *glob, - struct fclaw2d_patch* this_patch, - int icorner, int block_corner_count); - -///@} - -#ifdef __cplusplus -#if 0 -{ -#endif -} -#endif - -#endif diff --git a/src/fclaw2d_regrid.c b/src/fclaw2d_regrid.c deleted file mode 100644 index 2a57ec5ed..000000000 --- a/src/fclaw2d_regrid.c +++ /dev/null @@ -1,400 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -#include - -#include /* p4est domain, patch handling routines */ -#include /* Needed for patch_relation_t data */ - -#include - -#include -#include -#include -#include -#include -#include -#include - - -/* This is also called from fclaw2d_initialize, so is not made static */ -void cb_fclaw2d_regrid_tag4refinement(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, - int this_block_idx, - int this_patch_idx, - void *user) -{ - int refine_patch, maxlevel, level; - const fclaw_options_t* fclaw_opt; - - fclaw2d_global_iterate_t* g = (fclaw2d_global_iterate_t*) user; - int domain_init = *((int*) g->user); - - fclaw_opt = fclaw2d_get_options(g->glob); - - maxlevel = fclaw_opt->maxlevel; - level = this_patch->level; - - if (level < maxlevel) - { - refine_patch = - fclaw2d_patch_tag4refinement(g->glob,this_patch,this_block_idx, - this_patch_idx, domain_init); - if (refine_patch == 1) - { - fclaw2d_patch_mark_refine(domain, this_block_idx, this_patch_idx); - } - } -} - -/* Tag family for coarsening */ - -void cb_regrid_tag4coarsening(fclaw2d_domain_t *domain, - fclaw2d_patch_t *fine_patches, - int blockno, int fine0_patchno, - void *user) -{ - const fclaw_options_t* fclaw_opt; - fclaw2d_global_iterate_t* g = (fclaw2d_global_iterate_t*) user; - - fclaw_opt = fclaw2d_get_options(g->glob); - int domain_init = *((int*) g->user); - - int minlevel = fclaw_opt->minlevel; - - int level = fine_patches[0].level; - - if (level > minlevel) - { - int family_coarsened = 1; - family_coarsened = fclaw2d_patch_tag4coarsening(g->glob,&fine_patches[0], - blockno, fine0_patchno, - domain_init); - if (family_coarsened == 1) - { - int igrid; - for (igrid = 0; igrid < 4; igrid++) - { - int fine_patchno = fine0_patchno + igrid; - fclaw2d_patch_mark_coarsen(domain,blockno, fine_patchno); - } - } - } -} - - -/* ---------------------------------------------------------------- - Public interface - -------------------------------------------------------------- */ - -void cb_fclaw2d_regrid_repopulate(fclaw2d_domain_t * old_domain, - fclaw2d_patch_t * old_patch, - fclaw2d_domain_t * new_domain, - fclaw2d_patch_t * new_patch, - fclaw2d_patch_relation_t newsize, - int blockno, - int old_patchno, - int new_patchno, - void *user) -{ - fclaw2d_global_iterate_t* g = (fclaw2d_global_iterate_t*) user; - int domain_init = *((int*) g->user); - - fclaw2d_domain_data_t *ddata_old = fclaw2d_domain_get_data (old_domain); - fclaw2d_domain_data_t *ddata_new = fclaw2d_domain_get_data (new_domain); - fclaw2d_build_mode_t build_mode = FCLAW2D_BUILD_FOR_UPDATE; - - if (newsize == FCLAW2D_PATCH_SAMESIZE) - { - FCLAW_ASSERT(0 <= blockno && blockno < new_domain->num_blocks); - FCLAW_ASSERT(0 <= new_patchno && new_patchno < new_domain->local_num_patches); - new_patch->user = old_patch->user; - old_patch->user = NULL; - ++ddata_old->count_delete_patch; - ++ddata_new->count_set_patch; - } - else if (newsize == FCLAW2D_PATCH_HALFSIZE) - { - fclaw2d_patch_t *fine_siblings = new_patch; - fclaw2d_patch_t *coarse_patch = old_patch; - - int i; - for (i = 0; i < 4; i++) - { - fclaw2d_patch_t *fine_patch = &fine_siblings[i]; - int fine_patchno = new_patchno + i; - /* Reason for the following two lines: the glob contains the old domain which is incremented in ddata_old - but we really want to increment the new domain. This will be fixed! */ - --ddata_old->count_set_patch; - ++ddata_new->count_set_patch; - - fclaw2d_patch_build(g->glob,fine_patch,blockno, - fine_patchno,(void*) &build_mode); - if (domain_init) - { - fclaw2d_patch_initialize(g->glob,fine_patch,blockno,fine_patchno);//new_domain - } - } - - if (!domain_init) - { - int coarse_patchno = old_patchno; - int fine_patchno = new_patchno; - - fclaw2d_patch_interpolate2fine(g->glob,coarse_patch,fine_siblings, - blockno,coarse_patchno,fine_patchno);//new_domain - } - /* used to pass in old_domain */ - fclaw2d_patch_data_delete(g->glob,coarse_patch); - } - else if (newsize == FCLAW2D_PATCH_DOUBLESIZE) - { - -#if 0 - if (domain_init) - { - /* We now do coarsening at the initial refinement */ - fclaw_debugf("fclaw2d_regrid.cpp (repopulate): We shouldn't end up here\n"); - exit(0); - } -#endif - - /* Old grids are the finer grids; new grid is the coarsened grid */ - fclaw2d_patch_t *fine_siblings = old_patch; - int fine_patchno = old_patchno; - - fclaw2d_patch_t *coarse_patch = new_patch; - int coarse_patchno = new_patchno; - - /* Reason for the following two lines: the glob contains the old domain which is incremented in ddata_old - but we really want to increment the new domain. This will be fixed! */ - --ddata_old->count_set_patch; - ++ddata_new->count_set_patch; - - if (domain_init) - { - fclaw2d_patch_build(g->glob,coarse_patch,blockno, - coarse_patchno,(void*) &build_mode); - fclaw2d_patch_initialize(g->glob,coarse_patch,blockno,coarse_patchno); - } - else - { - /* Area (and possibly other things) should be averaged to coarse grid. */ - fclaw2d_patch_build_from_fine(g->glob,fine_siblings,coarse_patch, - blockno,coarse_patchno,fine_patchno, - build_mode); - /* Average the solution. Does this need to be customizable? */ - fclaw2d_patch_average2coarse(g->glob,fine_siblings,coarse_patch, - blockno,fine_patchno,coarse_patchno); - - } - int i; - for(i = 0; i < 4; i++) - { - fclaw2d_patch_t* fine_patch = &fine_siblings[i]; - /* used to pass in old_domain */ - fclaw2d_patch_data_delete(g->glob,fine_patch); - } - } - else - { - fclaw_global_essentialf("cb_adapt_domain : newsize not recognized\n"); - exit(1); - } - fclaw2d_patch_neighbors_reset(new_patch); -} - -/* ---------------------------------------------------------------- - Public interface - -------------------------------------------------------------- */ -void fclaw2d_regrid(fclaw2d_global_t *glob) -{ - fclaw2d_domain_t** domain = &glob->domain; - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_REGRID]); - - fclaw_global_infof("Regridding domain\n"); - - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_REGRID_TAGGING]); - /* First determine which families should be coarsened. */ - int domain_init = 0; - fclaw2d_global_iterate_families(glob, cb_regrid_tag4coarsening, - (void *) &domain_init); - - fclaw2d_global_iterate_patches(glob, cb_fclaw2d_regrid_tag4refinement, - (void *) &domain_init); - - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_REGRID_TAGGING]); - - /* Rebuild domain if necessary */ - /* Will return be NULL if no refining was done */ - - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_REGRID]); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_ADAPT_COMM]); - fclaw2d_domain_t *new_domain = fclaw2d_domain_adapt(*domain); - - int have_new_refinement = new_domain != NULL; - - if (have_new_refinement) - { - /* allocate memory for user patch data and user domain data in the new - domain; copy data from the old to new the domain. */ - fclaw2d_domain_setup(glob, new_domain); - } - - /* Stop the new timer (copied from old timer) */ - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_ADAPT_COMM]); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_REGRID]); - - if (have_new_refinement) - { - fclaw_global_infof(" -- Have new refinement\n"); - - /* Average to new coarse grids and interpolate to new fine grids */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_REGRID_BUILD]); - fclaw2d_global_iterate_adapted(glob, new_domain, - cb_fclaw2d_regrid_repopulate, - (void *) &domain_init); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_REGRID_BUILD]); - - /* free memory associated with old domain */ - fclaw2d_domain_reset(glob); - *domain = new_domain; - new_domain = NULL; - - /* Repartition for load balancing. Second arg (mode) for vtk output */ - fclaw2d_partition_domain(glob,FCLAW2D_TIMER_REGRID); - - /* Set up ghost patches. Communication happens for indirect ghost exchanges. */ - - - /* This includes timers for building patches and (exclusive) communication */ - fclaw2d_exchange_setup(glob,FCLAW2D_TIMER_REGRID); - - /* Get new neighbor information. This is used to short circuit - ghost filling procedures in some cases */ - fclaw2d_regrid_set_neighbor_types(glob); - - /* Update ghost cells. This is needed because we have new coarse or fine - patches without valid ghost cells. Time_interp = 0, since we only - only regrid when all levels are time synchronized. */ - int minlevel = (*domain)->global_minlevel; - int maxlevel = (*domain)->global_maxlevel; - int time_interp = 0; - double sync_time = glob->curr_time; - fclaw2d_ghost_update(glob, - minlevel, - maxlevel, - sync_time, - time_interp, - FCLAW2D_TIMER_REGRID); - - ++glob->count_amr_new_domain; - } - else - { - /* We updated all the ghost cells when leaving advance, so don't need to do - it here */ - } - - /* User defined */ - fclaw2d_after_regrid(glob, have_new_refinement); - - /* Only if gauges count > 0 */ - fclaw_locate_gauges(glob); - - /* Stop timer. Be sure to use timers from new grid, if one was - created */ - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_REGRID]); - - /* Count calls to this function */ - ++glob->count_amr_regrid; -} - -static -void cb_set_neighbor_types(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, - int blockno, - int patchno, - void *user) -{ - int iface, icorner; - - for (iface = 0; iface < 4; iface++) - { - int rproc[2]; - int rblockno; - int rpatchno[2]; - int rfaceno; - - fclaw2d_patch_relation_t neighbor_type = - fclaw2d_patch_face_neighbors(domain, - blockno, - patchno, - iface, - rproc, - &rblockno, - rpatchno, - &rfaceno); - - fclaw2d_patch_set_face_type(this_patch,iface,neighbor_type); - } - - for (icorner = 0; icorner < 4; icorner++) - { - int rproc_corner; - int cornerpatchno; - int cornerblockno; - int rcornerno; - fclaw2d_patch_relation_t neighbor_type; - - int has_corner_neighbor = - fclaw2d_patch_corner_neighbors(domain, - blockno, - patchno, - icorner, - &rproc_corner, - &cornerblockno, - &cornerpatchno, - &rcornerno, - &neighbor_type); - - fclaw2d_patch_set_corner_type(this_patch,icorner,neighbor_type); - if (!has_corner_neighbor) - { - fclaw2d_patch_set_missing_corner(this_patch,icorner); - } - } - fclaw2d_patch_neighbors_set(this_patch); -} - -/* Set neighbor type : samesize, halfsize, or doublesize */ -void fclaw2d_regrid_set_neighbor_types(fclaw2d_global_t *glob) -{ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_NEIGHBOR_SEARCH]); - fclaw2d_global_iterate_patches(glob,cb_set_neighbor_types,NULL); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_NEIGHBOR_SEARCH]); -} diff --git a/src/fclaw2d_to_3d.h b/src/fclaw2d_to_3d.h index 169be4023..4f747679c 100644 --- a/src/fclaw2d_to_3d.h +++ b/src/fclaw2d_to_3d.h @@ -46,14 +46,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* redefine typedefs */ #define fclaw2d_patch_flags_t fclaw3d_patch_flags_t #define fclaw2d_patch_t fclaw3d_patch_t -#define fclaw2d_patch_vtable_t fclaw3d_patch_vtable_t -#define fclaw2d_patch_transform_data_t fclaw3d_patch_transform_data_t -#define fclaw2d_patch_data_t fclaw3d_patch_data_t #define fclaw2d_block_t fclaw3d_block_t #define fclaw2d_domain_t fclaw3d_domain_t #define fclaw2d_file_context fclaw3d_file_context #define fclaw2d_file_context_t fclaw3d_file_context_t -#define fclaw2d_domain_data_t fclaw3d_domain_data_t #define fclaw2d_domain_persist_t fclaw3d_domain_persist_t #define fclaw2d_timer_names_t fclaw3d_timer_names_t #define fclaw2d_patch_callback_t fclaw3d_patch_callback_t @@ -65,49 +61,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define fclaw2d_domain_indirect_t fclaw3d_domain_indirect_t #define fclaw2d_integrate_ray_t fclaw3d_integrate_ray_t #define fclaw2d_interpolate_point_t fclaw3d_interpolate_point_t -#define fclaw2d_build_mode_t fclaw3d_build_mode_t -#define fclaw2d_patch_new_t fclaw3d_patch_new_t -#define fclaw2d_patch_delete_t fclaw3d_patch_delete_t -#define fclaw2d_patch_build_t fclaw3d_patch_build_t -#define fclaw2d_patch_build_from_fine_t fclaw3d_patch_build_from_fine_t -#define fclaw2d_patch_setup_t fclaw3d_patch_setup_t -#define fclaw2d_patch_initialize_t fclaw3d_patch_initialize_t -#define fclaw2d_patch_physical_bc_t fclaw3d_patch_physical_bc_t -#define fclaw2d_patch_single_step_update_t fclaw3d_patch_single_step_update_t -#define fclaw2d_patch_rhs_t fclaw3d_patch_rhs_t -#define fclaw2d_patch_setup_timeinterp_t fclaw3d_patch_setup_timeinterp_t -#define fclaw2d_patch_restore_step_t fclaw3d_patch_restore_step_t -#define fclaw2d_patch_save_step_t fclaw3d_patch_save_step_t -#define fclaw2d_patch_copy_face_t fclaw3d_patch_copy_face_t -#define fclaw2d_patch_average_face_t fclaw3d_patch_average_face_t -#define fclaw2d_patch_interpolate_face_t fclaw3d_patch_interpolate_face_t -#define fclaw2d_patch_copy_corner_t fclaw3d_patch_copy_corner_t -#define fclaw2d_patch_average_corner_t fclaw3d_patch_average_corner_t -#define fclaw2d_patch_interpolate_corner_t fclaw3d_patch_interpolate_corner_t -#define fclaw2d_patch_transform_init_data_t fclaw3d_patch_transform_init_data_t -#define fclaw2d_patch_transform_blockface_t fclaw3d_patch_transform_blockface_t -#define fclaw2d_patch_transform_blockface_intra_t fclaw3d_patch_transform_blockface_intra_t -#define fclaw2d_patch_tag4refinement_t fclaw3d_patch_tag4refinement_t -#define fclaw2d_patch_tag4coarsening_t fclaw3d_patch_tag4coarsening_t -#define fclaw2d_patch_interpolate2fine_t fclaw3d_patch_interpolate2fine_t -#define fclaw2d_patch_average2coarse_t fclaw3d_patch_average2coarse_t -#define fclaw2d_patch_ghost_packsize_t fclaw3d_patch_ghost_packsize_t -#define fclaw2d_patch_local_ghost_pack_t fclaw3d_patch_local_ghost_pack_t -#define fclaw2d_patch_local_ghost_alloc_t fclaw3d_patch_local_ghost_alloc_t -#define fclaw2d_patch_local_ghost_free_t fclaw3d_patch_local_ghost_free_t -#define fclaw2d_patch_remote_ghost_build_t fclaw3d_patch_remote_ghost_build_t -#define fclaw2d_patch_remote_ghost_setup_t fclaw3d_patch_remote_ghost_setup_t -#define fclaw2d_patch_remote_ghost_unpack_t fclaw3d_patch_remote_ghost_unpack_t -#define fclaw2d_patch_remote_ghost_delete_t fclaw3d_patch_remote_ghost_delete_t -#define fclaw2d_patch_partition_packsize_t fclaw3d_patch_partition_packsize_t -#define fclaw2d_patch_partition_pack_t fclaw3d_patch_partition_pack_t -#define fclaw2d_patch_partition_unpack_t fclaw3d_patch_partition_unpack_t -#define fclaw2d_patch_time_sync_f2c_t fclaw3d_patch_time_sync_f2c_t -#define fclaw2d_patch_time_sync_samesize_t fclaw3d_patch_time_sync_samesize_t -#define fclaw2d_patch_time_sync_reset_t fclaw3d_patch_time_sync_reset_t -#define fclaw2d_patch_create_user_data_t fclaw3d_patch_create_user_data_t -#define fclaw2d_patch_destroy_user_data_t fclaw3d_patch_destroy_user_data_t -#define fclaw2d_patch_metric_patch_t fclaw3d_patch_metric_patch_t #define fclaw2d_file_context_p4est_v1_t fclaw2d_file_context_p4est_v1_t #define fclaw2d_file_error_t fclaw3d_file_error_t @@ -173,7 +126,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define fclaw2d_file_read_array fclaw3d_file_read_array #define fclaw2d_file_error_string fclaw3d_file_error_string #define fclaw2d_file_close fclaw3d_file_close -#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 @@ -191,71 +143,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define fclaw2d_patch_childid fclaw3d_patch_childid #define fclaw2d_patch_is_first_sibling fclaw3d_patch_is_first_sibling #define fclaw2d_patch_is_ghost fclaw3d_patch_is_ghost -#define fclaw2d_patch_reset_data fclaw3d_patch_reset_data -#define fclaw2d_patch_data_delete fclaw3d_patch_data_delete -#define fclaw2d_patch_build fclaw3d_patch_build -#define fclaw2d_patch_build_from_fine fclaw3d_patch_build_from_fine -#define fclaw2d_patch_initialize fclaw3d_patch_initialize -#define fclaw2d_patch_physical_bc fclaw3d_patch_physical_bc -#define fclaw2d_patch_single_step_update fclaw3d_patch_single_step_update -#define fclaw2d_patch_set_rhs fclaw3d_patch_set_rhs -#define fclaw2d_patch_restore_step fclaw3d_patch_restore_step -#define fclaw2d_patch_save_step fclaw3d_patch_save_step -#define fclaw2d_patch_setup_timeinterp fclaw3d_patch_setup_timeinterp -#define fclaw2d_patch_copy_face fclaw3d_patch_copy_face -#define fclaw2d_patch_average_face fclaw3d_patch_average_face -#define fclaw2d_patch_interpolate_face fclaw3d_patch_interpolate_face -#define fclaw2d_patch_copy_corner fclaw3d_patch_copy_corner -#define fclaw2d_patch_average_corner fclaw3d_patch_average_corner -#define fclaw2d_patch_interpolate_corner fclaw3d_patch_interpolate_corner -#define fclaw2d_patch_create_user_data fclaw3d_patch_create_user_data -#define fclaw2d_patch_destroy_user_data fclaw3d_patch_destroy_user_data -#define fclaw2d_patch_transform_init_data fclaw3d_patch_transform_init_data -#define fclaw2d_patch_transform_blockface fclaw3d_patch_transform_blockface -#define fclaw2d_patch_transform_blockface_intra fclaw3d_patch_transform_blockface_intra -#define fclaw2d_patch_tag4refinement fclaw3d_patch_tag4refinement -#define fclaw2d_patch_tag4coarsening fclaw3d_patch_tag4coarsening -#define fclaw2d_patch_interpolate2fine fclaw3d_patch_interpolate2fine -#define fclaw2d_patch_average2coarse fclaw3d_patch_average2coarse -#define fclaw2d_patch_ghost_packsize fclaw3d_patch_ghost_packsize -#define fclaw2d_patch_local_ghost_alloc fclaw3d_patch_local_ghost_alloc -#define fclaw2d_patch_local_ghost_free fclaw3d_patch_local_ghost_free -#define fclaw2d_patch_local_ghost_pack fclaw3d_patch_local_ghost_pack -#define fclaw2d_patch_remote_ghost_build fclaw3d_patch_remote_ghost_build -#define fclaw2d_patch_remote_ghost_unpack fclaw3d_patch_remote_ghost_unpack -#define fclaw2d_patch_remote_ghost_delete fclaw3d_patch_remote_ghost_delete -#define fclaw2d_patch_partition_pack fclaw3d_patch_partition_pack -#define fclaw2d_patch_partition_unpack fclaw3d_patch_partition_unpack -#define fclaw2d_patch_partition_packsize fclaw3d_patch_partition_packsize -#define fclaw2d_patch_time_sync_f2c fclaw3d_patch_time_sync_f2c -#define fclaw2d_patch_time_sync_samesize fclaw3d_patch_time_sync_samesize -#define fclaw2d_patch_time_sync_reset fclaw3d_patch_time_sync_reset -#define fclaw2d_patch_vt fclaw3d_patch_vt -#define fclaw2d_patch_vtable_initialize fclaw3d_patch_vtable_initialize -#define fclaw2d_patch_get_info fclaw3d_patch_get_info -#define fclaw2d_patch_get_info2 fclaw3d_patch_get_info2 -#define fclaw2d_patch_get_user_patch fclaw3d_patch_get_user_patch -#define fclaw2d_patch_get_patch_data fclaw3d_patch_get_patch_data -#define fclaw2d_patch_get_user_data fclaw3d_patch_get_user_data -#define fclaw2d_patch_metric_patch fclaw3d_patch_metric_patch -#define fclaw2d_patch_get_blockno fclaw3d_patch_get_blockno -#define fclaw2d_patch_get_patchno fclaw3d_patch_get_patchno -#define fclaw2d_patch_user_data fclaw3d_patch_user_data -#define fclaw2d_patch_set_user_data fclaw3d_patch_set_user_data -#define fclaw2d_patch_on_parallel_boundary fclaw3d_patch_on_parallel_boundary -#define fclaw2d_patch_set_face_type fclaw3d_patch_set_face_type -#define fclaw2d_patch_set_corner_type fclaw3d_patch_set_corner_type -#define fclaw2d_patch_set_missing_corner fclaw3d_patch_set_missing_corner -#define fclaw2d_patch_get_face_type fclaw3d_patch_get_face_type -#define fclaw2d_patch_get_corner_type fclaw3d_patch_get_corner_type -#define fclaw2d_patch_corner_is_missing fclaw3d_patch_corner_is_missing -#define fclaw2d_patch_neighbors_set fclaw3d_patch_neighbors_set -#define fclaw2d_patch_neighbors_reset fclaw3d_patch_neighbors_reset -#define fclaw2d_patch_neighbor_type_set fclaw3d_patch_neighbor_type_set -#define fclaw2d_patch_has_finegrid_neighbors fclaw3d_patch_has_finegrid_neighbors -#define fclaw2d_patch_on_coarsefine_interface fclaw3d_patch_on_coarsefine_interface -#define fclaw2d_patch_block_corner_count fclaw3d_patch_block_corner_count -#define fclaw2d_patch_set_block_corner_count fclaw3d_patch_set_block_corner_count #define fclaw2d_domain_attribute_add fclaw3d_domain_attribute_add #define fclaw2d_domain_attribute_access fclaw3d_domain_attribute_access #define fclaw2d_domain_attribute_remove fclaw3d_domain_attribute_remove @@ -277,13 +164,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define fclaw2d_patch_transform_corner fclaw3d_patch_transform_corner #define fclaw2d_patch_transform_corner2 fclaw3d_patch_transform_corner2 #define fclaw2d_domain_set_refinement fclaw3d_domain_set_refinement +#define fclaw2d_domain_set_partitioning fclaw3d_domain_set_partitioning #define fclaw2d_patch_mark_refine fclaw3d_patch_mark_refine #define fclaw2d_patch_mark_coarsen fclaw3d_patch_mark_coarsen -#define fclaw2d_domain_data_new fclaw3d_domain_data_new -#define fclaw2d_domain_data_delete fclaw3d_domain_data_delete -#define fclaw2d_domain_get_data fclaw3d_domain_get_data -#define fclaw2d_domain_setup fclaw3d_domain_setup -#define fclaw2d_domain_reset fclaw3d_domain_reset #define fclaw2d_domain_iterate_adapted fclaw3d_domain_iterate_adapted #define fclaw2d_domain_assign_for_partition fclaw3d_domain_assign_for_partition #define fclaw2d_domain_allocate_before_partition fclaw3d_domain_allocate_before_partition @@ -297,10 +180,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define fclaw2d_domain_ghost_exchange_end fclaw3d_domain_ghost_exchange_end #define fclaw2d_domain_free_after_exchange fclaw3d_domain_free_after_exchange -#define fclaw2d_exchange_setup fclaw3d_exchange_setup -#define fclaw2d_exchange_delete fclaw3d_exchange_delete -#define fclaw2d_exchange_ghost_patches_begin fclaw3d_exchange_ghost_patches_begin -#define fclaw2d_exchange_ghost_patches_end fclaw3d_exchange_ghost_patches_end #define fclaw2d_domain_serialization_enter fclaw3d_domain_serialization_enter #define fclaw2d_domain_serialization_leave fclaw3d_domain_serialization_leave #define fclaw2d_domain_is_meta fclaw3d_domain_is_meta @@ -315,53 +194,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define fclaw2d_domain_list_neighbors fclaw3d_domain_list_neighbors #define fclaw2d_domain_list_adapted fclaw3d_domain_list_adapted #define fclaw2d_domain_search_points fclaw3d_domain_search_points -#define fclaw2d_domain_iterate_cb fclaw3d_domain_iterate_cb -#define fclaw2d_domain_iterate_level_mthread fclaw3d_domain_iterate_level_mthread -#define fclaw_domain_new2d fclaw_domain_new3d -#define fclaw_domain_destroy2d fclaw_domain_destroy3d - -/* translations for maps */ -#define fclaw2d_map_context_t fclaw3d_map_context_t -#define fclaw2d_map_destroy_t fclaw3d_map_destroy_t -#define fclaw2d_map_destroy fclaw3d_map_destroy -#define fclaw2d_map_new_nomap fclaw3d_map_new_nomap /* translations for the global data structure */ -#define fclaw2d_iterate_patch_cb fclaw3d_iterate_patch_cb -#define fclaw2d_iterate_family_cb fclaw3d_iterate_family_cb #define fclaw2d_domain_integrate_rays fclaw3d_domain_integrate_rays #define fclaw2d_overlap_exchange fclaw3d_overlap_exchange -#define fclaw2d_global_t fclaw3d_global_t -#define fclaw2d_global_iterate_t fclaw3d_global_iterate_t -#define fclaw2d_global_new fclaw3d_global_new -#define fclaw2d_global_new_comm fclaw3d_global_new_comm -#define fclaw2d_global_destroy fclaw3d_global_destroy -#define fclaw2d_global_store_domain fclaw3d_global_store_domain -#define fclaw2d_global_store_map fclaw3d_global_store_map -#define fclaw2d_global_unpack fclaw3d_global_unpack -#define fclaw2d_global_pack fclaw3d_global_pack -#define fclaw2d_global_packsize fclaw3d_global_packsize -#define fclaw2d_global_iterate_level fclaw3d_global_iterate_level -#define fclaw2d_global_iterate_patches fclaw3d_global_iterate_patches -#define fclaw2d_global_iterate_families fclaw3d_global_iterate_families -#define fclaw2d_global_iterate_adapted fclaw3d_global_iterate_adapted -#define fclaw2d_global_iterate_level_mthread fclaw3d_global_iterate_level_mthread -#define fclaw2d_global_iterate_partitioned fclaw3d_global_iterate_partitioned -#define fclaw2d_global_options_store fclaw3d_global_options_store -#define fclaw2d_global_get_options fclaw3d_global_get_options -#define fclaw2d_global_set_global fclaw3d_global_set_global -#define fclaw2d_global_unset_global fclaw3d_global_unset_global -#define fclaw2d_global_get_global fclaw3d_global_get_global -#define fclaw2d_set_global_context fclaw3d_set_global_context -#define fclaw2d_clear_global_context fclaw3d_clear_global_context - -/* translations for the options */ -#define fclaw2d_options_store fclaw3d_options_store -#define fclaw2d_get_options fclaw3d_get_options /* translations not found in p4est */ #ifndef p4est_wrap_new_unitsquare #define p4est_wrap_new_unitsquare p8est_wrap_new_unitcube #endif +/* translations for dimension independent wrapper functions/types */ +#define fclaw_domain_wrap_2d fclaw_domain_wrap_3d +#define fclaw2d_patch_wrap_cb fclaw3d_patch_wrap_cb +#define fclaw2d_transfer_wrap_cb fclaw3d_transfer_wrap_cb +#define fclaw2d_match_wrap_cb fclaw3d_match_wrap_cb +#define fclaw2d_intersect_wrap_cb fclaw3d_intersect_wrap_cb +#define fclaw2d_interpolate_point_wrap_cb fclaw3d_interpolate_point_wrap_cb + #endif /* !FCLAW2D_TO_3D_H */ diff --git a/src/fclaw2d_wrap.c b/src/fclaw2d_wrap.c new file mode 100644 index 000000000..7836a287b --- /dev/null +++ b/src/fclaw2d_wrap.c @@ -0,0 +1,324 @@ +/* +Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#ifndef P4_TO_P8 + +#include +#include + +#else + +#include +#include + +#endif + +static +void copy_patch(fclaw_patch_t* patch, fclaw2d_patch_t* patch_2d) +{ + patch->refine_dim = FCLAW2D_SPACEDIM; +#ifndef P4_TO_P8 + patch->d2 = patch_2d; +#else + patch->d3 = patch_2d; +#endif + patch->xlower = patch_2d->xlower; + patch->xupper = patch_2d->xupper; + patch->ylower = patch_2d->ylower; + patch->yupper = patch_2d->yupper; +#ifndef P4_TO_P8 + patch->zlower = 0; + patch->zupper = 1; +#else + patch->zlower = patch_2d->zlower; + patch->zupper = patch_2d->zupper; +#endif + + + patch->level = patch_2d->level; + patch_2d->user = patch; +} + +static +void copy_block(fclaw_block_t* block, fclaw2d_block_t* block_2d) +{ + block->refine_dim = FCLAW2D_SPACEDIM; +#ifndef P4_TO_P8 + block->d2 = block_2d; +#else + block->d3 = block_2d; +#endif + + block->num_patches = block_2d->num_patches; + block->num_patches_before = block_2d->num_patches_before; + + block->vertices = block_2d->vertices; + + block->patches = FCLAW_ALLOC_ZERO(fclaw_patch_t, block->num_patches); + for(int patchno = 0; patchno < block->num_patches; patchno++) + { + copy_patch(&block->patches[patchno], &block_2d->patches[patchno]); + } +} + +fclaw_domain_t* fclaw_domain_wrap_2d(fclaw2d_domain_t* domain_2d) +{ + if(domain_2d == NULL) + { + return NULL; + } + + fclaw_domain_t* domain = FCLAW_ALLOC_ZERO(fclaw_domain_t, 1); + domain->refine_dim = FCLAW2D_SPACEDIM; +#ifndef P4_TO_P8 + domain->d2 = domain_2d; +#else + domain->d3 = domain_2d; +#endif + + domain->mpicomm = domain_2d->mpicomm; + domain->mpisize = domain_2d->mpisize; + domain->mpirank = domain_2d->mpirank; + + domain->local_num_patches = domain_2d->local_num_patches; + domain->local_max_patches = domain_2d->local_max_patches; + domain->local_minlevel = domain_2d->local_minlevel; + domain->local_maxlevel = domain_2d->local_maxlevel; + domain->global_num_patches = domain_2d->global_num_patches; + domain->global_num_patches_before = domain_2d->global_num_patches_before; + domain->global_minlevel = domain_2d->global_minlevel; + domain->global_maxlevel = domain_2d->global_maxlevel; + + domain->num_blocks = domain_2d->num_blocks; + + domain->blocks = FCLAW_ALLOC_ZERO(fclaw_block_t, domain->num_blocks); + + for(int blockno = 0; blockno < domain->num_blocks; ++blockno) + { + copy_block(&domain->blocks[blockno], &domain_2d->blocks[blockno]); + } + + domain->num_exchange_patches = domain_2d->num_exchange_patches; + + domain->num_ghost_patches = domain_2d->num_ghost_patches; + domain->ghost_patches = FCLAW_ALLOC_ZERO(fclaw_patch_t, domain->num_ghost_patches); + for(int patchno = 0; patchno < domain->num_ghost_patches; patchno++) + { + copy_patch(&domain->ghost_patches[patchno], &domain_2d->ghost_patches[patchno]); + } + + domain_2d->user = domain; + + return domain; +} + +static +fclaw_domain_t* get_domain(fclaw2d_domain_t* domain_2d) +{ + FCLAW_ASSERT(domain_2d->user != NULL); + return (fclaw_domain_t*) domain_2d->user; +} + +static +fclaw_patch_t* get_patch(fclaw2d_patch_t* patch_2d) +{ + if(patch_2d == NULL) + { + return NULL; + } + FCLAW_ASSERT(patch_2d->user != NULL); + return (fclaw_patch_t*) patch_2d->user; +} + +void fclaw2d_patch_wrap_cb(fclaw2d_domain_t * domain_2d, + fclaw2d_patch_t * patch_2d, + int blockno, int patchno, void *user) +{ + fclaw_patch_wrap_user_t* wrap = + (fclaw_patch_wrap_user_t*) user; + fclaw_domain_t* domain = get_domain(domain_2d); + fclaw_patch_t* patch = get_patch(patch_2d); + wrap->pcb(domain, patch, blockno, patchno, wrap->user); +} + +void +fclaw2d_transfer_wrap_cb(fclaw2d_domain_t * old_domain_2d, + fclaw2d_patch_t * old_patch_2d, + fclaw2d_domain_t * new_domain_2d, + fclaw2d_patch_t * new_patch_2d, + int blockno, + int old_patchno, int new_patchno, + void *user) +{ + fclaw_transfer_wrap_user_t* wrap = + (fclaw_transfer_wrap_user_t*) user; + + fclaw_domain_t* old_domain = get_domain(old_domain_2d); + fclaw_patch_t* old_patch = get_patch(old_patch_2d); + fclaw_domain_t* new_domain = get_domain(new_domain_2d); + fclaw_patch_t* new_patch = get_patch(new_patch_2d); + + wrap->tcb(old_domain, old_patch, + new_domain, new_patch, + blockno, old_patchno, new_patchno, + wrap->user); +} + +void +fclaw2d_match_wrap_cb(fclaw2d_domain_t * old_domain_2d, + fclaw2d_patch_t * old_patch_2d, + fclaw2d_domain_t * new_domain_2d, + fclaw2d_patch_t * new_patch_2d, + fclaw2d_patch_relation_t newsize_2d, + int blockno, + int old_patchno, int new_patchno, + void *user) +{ + fclaw_match_wrap_user_t* wrap = + (fclaw_match_wrap_user_t*) user; + + fclaw_domain_t* old_domain = get_domain(old_domain_2d); + fclaw_patch_t* old_patch = get_patch(old_patch_2d); + fclaw_domain_t* new_domain = get_domain(new_domain_2d); + fclaw_patch_t* new_patch = get_patch(new_patch_2d); + + fclaw_patch_relation_t newsize = (fclaw_patch_relation_t) newsize_2d; + + wrap->mcb(old_domain, old_patch, new_domain, new_patch, + newsize, blockno, old_patchno, new_patchno, + wrap->user); +} + +int +fclaw2d_intersect_wrap_cb (fclaw2d_domain_t * domain_2d, + fclaw2d_patch_t * patch_2d, + int blockno, int patchno, + void *ray, double *integral, + void *user) +{ + fclaw_intersect_wrap_user_t* wrap = + (fclaw_intersect_wrap_user_t*) user; + + fclaw_domain_t* domain = get_domain(domain_2d); + fclaw_patch_t* patch; + + /* if it's a leaf the user data will be set to the dim_ind patch */ + int artificial_patch = (patch_2d->user == NULL); + if(artificial_patch) + { + patch = FCLAW_ALLOC_ZERO(fclaw_patch_t, 1); + copy_patch(patch, patch_2d); + } + else + { + patch = get_patch(patch_2d); + } + + int retval = wrap->intersect(domain, patch, blockno, patchno, ray, integral, + wrap->user); + + if(artificial_patch) + { + FCLAW_FREE(patch); + patch_2d->user = NULL; + } + + return retval; +} + +static +fclaw_domain_t* domain_wrap_meta(fclaw2d_domain_t* domain_2d) +{ + /* Only the mpi-information + (mpicomm, mpisize and mpirank) should be copied */ + fclaw_domain_t* domain = FCLAW_ALLOC_ZERO(fclaw_domain_t, 1); +#ifndef P4_TO_P8 + domain->d2 = domain_2d; +#else + domain->d3 = domain_2d; +#endif + domain->refine_dim = FCLAW2D_SPACEDIM; + domain->mpicomm = domain_2d->mpicomm; + domain->mpisize = domain_2d->mpisize; + domain->mpirank = domain_2d->mpirank; + domain_2d->user = domain; + + return domain; +} + +int +fclaw2d_interpolate_point_wrap_cb (fclaw2d_domain_t * domain_2d, + fclaw2d_patch_t * patch_2d, + int blockno, int patchno, + void *point, void *user) +{ + fclaw_interpolate_point_wrap_user_t* wrap = + (fclaw_interpolate_point_wrap_user_t*) user; + + fclaw_domain_t* domain; + + int domain_is_meta = fclaw2d_domain_is_meta(domain_2d); + if(domain_is_meta) + { + domain = domain_wrap_meta(domain_2d); + } + else + { + domain = get_domain(domain_2d); + } + + fclaw_patch_t* patch; + + /* if it's a leaf the user data will be set to the dim_ind patch */ + int artificial_patch = (patch_2d->user == NULL); + if(artificial_patch) + { + patch = FCLAW_ALLOC_ZERO(fclaw_patch_t, 1); + copy_patch(patch, patch_2d); + } + else + { + patch = get_patch(patch_2d); + } + + int retval = wrap->interpolate(domain, patch, blockno, patchno, point, + wrap->user); + + if(artificial_patch) + { + FCLAW_FREE(patch); + patch_2d->user = NULL; + } + + if(domain_is_meta) + { + FCLAW_FREE(domain); + domain_2d->user = NULL; + } + + return retval; +} diff --git a/src/fclaw2d_wrap.h b/src/fclaw2d_wrap.h new file mode 100644 index 000000000..913188614 --- /dev/null +++ b/src/fclaw2d_wrap.h @@ -0,0 +1,123 @@ +/* +Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/** + * @file + * @brief Functions needed for underlying wrapped types + * Most users will not need to include the file, unless doing something more advanced. + */ + + +#ifndef FCLAW2D_WRAP_H +#define FCLAW2D_WRAP_H + +#include +#include /* Contains definition of patch-iterator callback */ + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} /* need this because indent is dumb */ +#endif +#endif + +/** + * @brief Wraps a 2d domain in a fclaw_domain_t struct. + * + * This overwrites the user pointer in the domain and domain patches with a + * pointer to the dimension independent types. + * + * @param[in,out] domain2d The domain to wrap + * @return struct fclaw_domain* the wrapped domain + */ +struct fclaw_domain* fclaw_domain_wrap_2d(fclaw2d_domain_t *domain2d); + +/** + * @brief Wraps a patch callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_patch_callback_t. + * The user pointer should be a pointer to a @ref fclaw_patch_wrap_user_t. + */ +void fclaw2d_patch_wrap_cb(fclaw2d_domain_t * domain, + fclaw2d_patch_t * patch, + int blockno, int patchno, void *user); + +/** + * @brief Wraps a transfer callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_transfer_callback_t. + * The user pointer should be a pointer to a @ref fclaw_transfer_wrap_user_t. + */ +void +fclaw2d_transfer_wrap_cb(fclaw2d_domain_t * old_domain, + fclaw2d_patch_t * old_patch, + fclaw2d_domain_t * new_domain, + fclaw2d_patch_t * new_patch, + int blockno, + int old_patchno, int new_patchno, + void *user); + +/** + * @brief Wraps a match callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_match_callback_t. + * The user pointer should be a pointer to a @ref fclaw_match_wrap_user_t. + */ +void +fclaw2d_match_wrap_cb(fclaw2d_domain_t * old_domain, + fclaw2d_patch_t * old_patch_2d, + fclaw2d_domain_t * new_domain, + fclaw2d_patch_t * new_patch_2d, + fclaw2d_patch_relation_t newsize, + int blockno, + int old_patchno, int new_patchno, + void *user); +/** + * @brief Wraps a intersect callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_intersect_callback_t. + * The user pointer should be a pointer to a @ref fclaw_intersect_wrap_user_t. + */ +int +fclaw2d_intersect_wrap_cb (fclaw2d_domain_t * domain, + fclaw2d_patch_t * patch, + int blockno, int patchno, + void *ray, double *integral, + void *user); +/** + * @brief Wraps a interpolate_point callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_interpolate_point_callback_t. + * The user pointer should be a pointer to a @ref fclaw_interpolate_point_wrap_user_t. + */ +int +fclaw2d_interpolate_point_wrap_cb (fclaw2d_domain_t * domain, + fclaw2d_patch_t * patch, + int blockno, int patchno, + void *point, void *user); + +#ifdef __cplusplus +#if 0 +{ +#endif +} +#endif + +#endif diff --git a/src/fclaw3d_convenience.c b/src/fclaw3d_convenience.c index 592cb735e..4012c6319 100644 --- a/src/fclaw3d_convenience.c +++ b/src/fclaw3d_convenience.c @@ -25,3 +25,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "fclaw2d_convenience.c" + +fclaw2d_domain_t * +fclaw3d_domain_new_unitcube (sc_MPI_Comm mpicomm, int initial_level) +{ + return fclaw2d_domain_new_conn (mpicomm, initial_level, + p8est_connectivity_new_unitcube ()); +} diff --git a/src/fclaw3d_domain.c b/src/fclaw3d_domain.c deleted file mode 100644 index 6a4cb95e0..000000000 --- a/src/fclaw3d_domain.c +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include "fclaw2d_domain.c" diff --git a/src/fclaw3d_domain.h b/src/fclaw3d_domain.h deleted file mode 100644 index 716630268..000000000 --- a/src/fclaw3d_domain.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/** - * @file - * Domain structures and routines - */ - -#ifndef FCLAW3D_DOMAIN_H -#define FCLAW3D_DOMAIN_H - -#include /* Needed for domain_exchange/domain_indirect info */ -#include - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -struct fclaw3d_global; - -typedef struct fclaw3d_domain_data -{ - /* Debug counters and timers */ - int count_set_patch; - int count_delete_patch; - - fclaw3d_domain_exchange_t *domain_exchange; - fclaw3d_domain_indirect_t *domain_indirect; - -} fclaw3d_domain_data_t; - -void fclaw3d_domain_data_new(struct fclaw3d_domain *domain); - -void fclaw3d_domain_data_delete(struct fclaw3d_domain* domain); - -void fclaw3d_domain_setup(struct fclaw3d_global* glob, - struct fclaw3d_domain* new_domain); - -void fclaw3d_domain_reset(struct fclaw3d_global* glob); - -fclaw3d_domain_data_t* fclaw3d_domain_get_data(struct fclaw3d_domain *domain); - -/* OpenMP iterator (not part of forestclaw3d.h */ -void fclaw3d_domain_iterate_level_mthread (struct fclaw3d_domain * domain, int level, - fclaw3d_patch_callback_t pcb, void *user); - -/* below are the functions needed for dimension independence */ - -/** safeguard value for dimension-independent domain */ -#define FCLAW3D_DOMAIN_MAGIC 0x67890303 - -void fclaw3d_domain_iterate_cb - (fclaw3d_domain_t * d3, fclaw3d_patch_t * patch, - int blockno, int patchno, void *user); - -/** Construct a dimension-specific domain and initialize patch data. - * \param [in] domain Freshly created, valid domain structure - * without any user data attached to it. - * \param [in] init This callback is pointed to a freshly - * allocated fclaw_patch whose 3D data it - * is supposed to fill with fitting values. - * This includes allocating and filling - * the patch user pointer, which the - * callback can do using the third - * parameter to this function, \a user. - * May be NULL for no callback. - * \param [in,out] user Pointer passed through to \a init. - * \return Initialized dimension-independent domain. - */ -fclaw_domain_t *fclaw_domain_new3d (fclaw3d_domain_t * domain, - fclaw_domain_callback_t init, void *user); - -/** Destruct a dimension-specific domain and deinitialize patch data. - * \param [in] domain Valid dimension-independent domain structure. - * \param [in] dele This callback is pointed to each existing - * fclaw_patch whose 3D data it is supposed to - * deinitialize, as well as the patch user data. - * Note, just don't allocate the patch itself! - * May be NULL for no callback. - * \param [in,out] user Pointer passed through to \a init. - */ -void fclaw_domain_destroy3d (fclaw_domain_t * domain, - fclaw_domain_callback_t dele, void *user); - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - -#endif /* FCLAW3D_DOMAIN_H */ diff --git a/src/fclaw3d_exchange.c b/src/fclaw3d_exchange.c deleted file mode 100644 index fee1f1aa9..000000000 --- a/src/fclaw3d_exchange.c +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include "fclaw2d_exchange.c" diff --git a/src/fclaw3d_exchange.h b/src/fclaw3d_exchange.h deleted file mode 100644 index 43a06bc74..000000000 --- a/src/fclaw3d_exchange.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3D_EXCHANGE_H -#define FCLAW3D_EXCHANGE_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} -#endif -#endif - -struct fclaw3d_global; - -void fclaw3d_exchange_setup(struct fclaw3d_global* glob, - fclaw3d_timer_names_t running); - -void fclaw3d_exchange_delete(struct fclaw3d_global* glob); - -void fclaw3d_exchange_ghost_patches_begin(struct fclaw3d_global* glob, - int minlevel, - int maxlevel, - int time_interp, - fclaw3d_timer_names_t running); - -void fclaw3d_exchange_ghost_patches_end(struct fclaw3d_global* glob, - int minlevel, - int maxlevel, - int time_interp, - fclaw3d_timer_names_t running); - - -#ifdef __cplusplus -#if 0 -{ -#endif -} -#endif - -#endif diff --git a/src/fclaw3d_global.c b/src/fclaw3d_global.c deleted file mode 100644 index 18bb052a8..000000000 --- a/src/fclaw3d_global.c +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include "fclaw2d_global.c" diff --git a/src/fclaw3d_global.h b/src/fclaw3d_global.h deleted file mode 100644 index 779b3ed3f..000000000 --- a/src/fclaw3d_global.h +++ /dev/null @@ -1,223 +0,0 @@ -/* -Copyright (c) 2012-2023 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3D_GLOBAL_H -#define FCLAW3D_GLOBAL_H - -#include /* Needed to declare callbacks (below) */ -#include /* Needed to store the map context */ - -#include /* Needed to create statically allocated array of timers */ - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -/* these are dimension-specific functions */ - -void fclaw3d_iterate_patch_cb - (fclaw3d_domain_t * domain, fclaw3d_patch_t * patch, - int blockno, int patchno, void *user); - -void fclaw3d_iterate_family_cb - (fclaw3d_domain_t * domain, fclaw3d_patch_t * patch, - int blockno, int patchno, void *user); - -/* much of the following will move into fclaw_global.h */ - -typedef struct fclaw3d_global fclaw3d_global_t; -typedef struct fclaw3d_global_iterate fclaw3d_global_iterate_t; - -struct fclaw3d_global -{ - int count_amr_advance; - int count_ghost_exchange; - int count_amr_regrid; - int count_amr_new_domain; - int count_single_step; - int count_elliptic_grids; - int count_multiproc_corner; - int count_grids_per_proc; - int count_grids_remote_boundary; - int count_grids_local_boundary; - fclaw2d_timer_t timers[FCLAW2D_TIMER_COUNT]; - - /* Time at start of each subcycled time step */ - double curr_time; - double curr_dt; - - sc_MPI_Comm mpicomm; - int mpisize; /**< Size of communicator. */ - int mpirank; /**< Rank of this process in \b mpicomm. */ - - /** Solver packages for internal use. */ - struct fclaw_package_container *pkg_container; - - struct fclaw_pointer_map *vtables; /**< Vtables */ - struct fclaw_pointer_map *options; /**< options */ - - struct fclaw3d_map_context* cont; - struct fclaw3d_domain *domain; - -#if 0 - /* CB: is this a good place for the accumulator? - Would it be possible to add and retrieve it as an anonymous - object that does not need to be known to this file? */ - - struct fclaw3d_diagnostics_accumulator *acc; -#endif - - void *user; -}; - -struct fclaw3d_global_iterate -{ - fclaw3d_global_t* glob; - void* user; -}; - -/** Allocate a new global structure. */ -fclaw3d_global_t* fclaw3d_global_new (void); - -fclaw3d_global_t* fclaw3d_global_new_comm (sc_MPI_Comm mpicomm, - int mpisize, int mpirank); - -void fclaw3d_global_destroy (fclaw3d_global_t * glob); - -void fclaw3d_global_store_domain (fclaw3d_global_t* glob, - struct fclaw3d_domain* domain); - -void fclaw3d_global_store_map (fclaw3d_global_t* glob, - fclaw3d_map_context_t * map); - -/** - * @brief Pack global structure into buffer - * - * @param glob the global structure - * @param buffer the buffer to write to - * @return size_t number of bytes written - */ -size_t fclaw3d_global_pack(const fclaw3d_global_t * glob, char* buffer); - -/** - * @brief Get the number of bytes needed to pack the global structure - * - * @param glob the structure - * @return size_t the number of bytes needed to store structure - */ -size_t fclaw3d_global_packsize(const fclaw3d_global_t * glob); - -/** - * @brief Unpack global structure from buffer - * - * @param buffer the buffer to read from - * @param glob newly create global structure - * @return size_t number of bytes read - */ -size_t fclaw3d_global_unpack(char* buffer, fclaw3d_global_t** glob); - -void fclaw3d_global_iterate_level (fclaw3d_global_t * glob, int level, - fclaw3d_patch_callback_t pcb, void *user); - -void fclaw3d_global_iterate_patches (fclaw3d_global_t * glob, - fclaw3d_patch_callback_t pcb, void *user); - -void fclaw3d_global_iterate_families (fclaw3d_global_t * glob, - fclaw3d_patch_callback_t pcb, void *user); - -void fclaw3d_global_iterate_adapted (fclaw3d_global_t * glob, - struct fclaw3d_domain* new_domain, - fclaw3d_match_callback_t mcb, void *user); - -void fclaw3d_global_iterate_level_mthread (fclaw3d_global_t * glob, int level, - fclaw3d_patch_callback_t pcb, void *user); - -void fclaw3d_global_iterate_partitioned (fclaw3d_global_t * glob, - struct fclaw3d_domain * new_domain, - fclaw3d_transfer_callback_t tcb, - void *user); -/** - * @brief Store an options structure in the glob - * - * @param glob the global context - * @param key the key to store the options under - * @param options the options structure - */ -void fclaw3d_global_options_store (fclaw3d_global_t* glob, const char* key, void* options); - -/** - * @brief Get an options structure from the glob - * - * @param glob the global context - * @param key the key to retrieve the options from - * @return void* the options - */ -void* fclaw3d_global_get_options (fclaw3d_global_t* glob, const char* key); - -/** - * @brief Store a glob variable in static memory - * - * @param glob the glob variable - */ -void fclaw3d_global_set_global (fclaw3d_global_t* glob); - -/** - * @brief Set the static glob variable to NULL - */ -void fclaw3d_global_unset_global (void); - -/** - * @brief Get the static glob variable - * - * @return fclaw2d_global_t* the glob variable - */ -fclaw3d_global_t* fclaw3d_global_get_global (void); - -/** - * @brief - * - * @param glob - */ -void fclaw3d_set_global_context(fclaw3d_global_t *glob); - -/** - * @brief - * - * @param glob - */ -void fclaw3d_clear_global_context(fclaw3d_global_t *glob); - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - -#endif /* !FCLAW3D_GLOBAL_H */ diff --git a/src/fclaw3d_include_all.h b/src/fclaw3d_include_all.h deleted file mode 100644 index 2dbe338cd..000000000 --- a/src/fclaw3d_include_all.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (c) 2012 Carsten Burstedde, Donna Calhoun - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3D_INCLUDE_ALL_H -#define FCLAW3D_INCLUDE_ALL_H - -#include -#include -#include - -#include - -#ifdef P8HACK - -#include - -#include -#include - -#endif /* P8HACK */ - -#include -#include -#include -#include - -#ifdef P8HACK - -#include - -#include - -#include - -#include -#include -#include - -#include - -#endif /* P8HACK */ - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -/* This file is for convenience only and should only be used in - applications ... */ - -#ifdef __cplusplus -#if 0 -{ -#endif -} -#endif - -#endif /* !FCLAW3D_INCLUDE_ALL_H */ diff --git a/src/fclaw3d_map.h b/src/fclaw3d_map.h deleted file mode 100644 index 1bad6a1f3..000000000 --- a/src/fclaw3d_map.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3D_MAP_H -#define FCLAW3D_MAP_H - -#include -#if 0 -/* put whatever is needed into that file */ -#include -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#if 0 -/* Fix syntax highlighting */ -#endif - -struct fclaw3d_map_context; -typedef struct fclaw3d_map_context fclaw3d_map_context_t; - -/** Destructor for a fclaw3d_map_context. -*/ -typedef void (*fclaw3d_map_destroy_t) (fclaw3d_map_context_t * cont); - -/** Mapping context that is interpreted by its query and c2m members. -* The callbacks are free to define the meaning of the user_* fields. -*/ -struct fclaw3d_map_context -{ - fclaw3d_map_destroy_t destroy; - void *user_data; -}; - -/** Deallocate a mapping context. - * If the \a destroy member is not NULL, it is called on the context. - * Otherwise, this function calls FCLAW_FREE (cont). - * \param [in] cont Mapping context where the \a destroy member is either - * NULL or a valid function that is then called. - */ -void fclaw3d_map_destroy (fclaw3d_map_context_t * cont); - -fclaw3d_map_context_t* fclaw3d_map_new_nomap (void); - -#ifdef __cplusplus -} -#endif - -#endif /* !FCLAW3D_MAP_H */ diff --git a/src/fclaw3d_map_query.h b/src/fclaw3d_map_query.h deleted file mode 100644 index 5e71a9bf7..000000000 --- a/src/fclaw3d_map_query.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#ifndef FCLAW3D_MAP_QUERY_H -#define FCLAW3D_MAP_QUERY_H - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -#if 0 -/* Fix syntax highlighting */ -#endif - -#if 0 -#define FCLAW2D_MAP_IS_USED FCLAW_F77_FUNC_(fclaw2d_map_is_used,FCLAW2D_MAP_IS_USED) -int FCLAW2D_MAP_IS_USED(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_CART FCLAW_F77_FUNC_(fclaw2d_map_is_cart,FCLAW2D_MAP_IS_CART) -int FCLAW2D_MAP_IS_CART(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_AFFINE FCLAW_F77_FUNC_(fclaw2d_map_is_affine,FCLAW2D_MAP_IS_AFFINE) -int FCLAW2D_MAP_IS_AFFINE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_DISK FCLAW_F77_FUNC_(fclaw2d_map_is_disk,FCLAW2D_MAP_IS_DISK) -int FCLAW2D_MAP_IS_DISK(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_PILLOWDISK FCLAW_F77_FUNC_(fclaw2d_map_is_pillowdisk,FCLAW2D_MAP_IS_PILLOWDISK) -int FCLAW2D_MAP_IS_PILLOWDISK(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_SQUAREDDISK FCLAW_F77_FUNC_(fclaw2d_map_is_squareddisk,FCLAW2D_MAP_IS_SQUAREDDISK) -int FCLAW2D_MAP_IS_SQUAREDDISK(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_PILLOWSPHERE FCLAW_F77_FUNC_(fclaw2d_map_is_pillowsphere,FCLAW2D_MAP_IS_PILLOWSPHERE) -int FCLAW2D_MAP_IS_PILLOWSPHERE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_CUBEDSPHERE FCLAW_F77_FUNC_(fclaw2d_map_is_cubedsphere,FCLAW2D_MAP_IS_CUBEDSPHERE) -int FCLAW2D_MAP_IS_CUBEDSPHERE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_FLAT FCLAW_F77_FUNC_(fclaw2d_map_is_flat,FCLAW2D_MAP_IS_FLAT) -int FCLAW2D_MAP_IS_FLAT(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_SPHERE FCLAW_F77_FUNC_(fclaw2d_map_is_sphere,FCLAW2D_MAP_IS_SPHERE) -int FCLAW2D_MAP_IS_SPHERE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_HEMISPHERE FCLAW_F77_FUNC_(fclaw2d_map_is_hemisphere,FCLAW2D_MAP_IS_HEMISPHERE) -int FCLAW2D_MAP_IS_HEMISPHERE(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_TORUS FCLAW_F77_FUNC_(fclaw2d_map_is_torus,FCLAW2D_MAP_TORUS) -int FCLAW2D_MAP_IS_TORUS(fclaw2d_map_context_t** cont); - -#define FCLAW2D_MAP_IS_BRICK FCLAW_F77_FUNC_(fclaw2d_map_is_brick,FCLAW2D_MAP_BRICK) -int FCLAW2D_MAP_IS_BRICK(fclaw2d_map_context_t** cont); -#endif - - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - - -#endif diff --git a/src/fclaw3d_options.c b/src/fclaw3d_options.c deleted file mode 100644 index b965dac50..000000000 --- a/src/fclaw3d_options.c +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include "fclaw2d_options.c" diff --git a/src/fclaw3d_options.h b/src/fclaw3d_options.h deleted file mode 100644 index c76f11de6..000000000 --- a/src/fclaw3d_options.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** \file - * - * Routines for handling general ForestClaw input options. - * - */ - -#ifndef FCLAW3D_OPTIONS_H -#define FCLAW3D_OPTIONS_H - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -struct fclaw3d_global; -struct fclaw_options; - -void fclaw3d_options_store (struct fclaw3d_global *glob, struct fclaw_options* fclaw_opt); - -fclaw_options_t* fclaw3d_get_options(struct fclaw3d_global *glob); - - -#ifndef FCLAW_PATCH_DIM -#define FCLAW_PATCH_DIM 3 -#endif - -#ifndef FCLAW_REFINE_DIM -#define FCLAW_REFINE_DIM 3 -#endif - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - -#endif /* !FCLAW3D_OPTIONS_H */ diff --git a/src/fclaw3d_patch.c b/src/fclaw3d_patch.c deleted file mode 100644 index 6207e7958..000000000 --- a/src/fclaw3d_patch.c +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include "fclaw2d_patch.c" - -void fclaw3d_patch_set_edge_type(fclaw2d_patch_t *patch,int iedge, - fclaw2d_patch_relation_t edge_type) -{ - fclaw2d_patch_data_t *pdata = get_patch_data(patch); - pdata->edge_neighbors[iedge] = edge_type; -} - -fclaw2d_patch_relation_t fclaw3d_patch_get_edge_type(fclaw2d_patch_t* patch, - int iedge) -{ - fclaw2d_patch_data_t *pdata = get_patch_data(patch); - FCLAW_ASSERT(pdata->neighbors_set != 0); - FCLAW_ASSERT(0 <= iedge && iedge < FCLAW3D_NUMEDGES); - return pdata->edge_neighbors[iedge]; -} \ No newline at end of file diff --git a/src/fclaw3d_patch.h b/src/fclaw3d_patch.h deleted file mode 100644 index 1d0bd3097..000000000 --- a/src/fclaw3d_patch.h +++ /dev/null @@ -1,1876 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -/** - * @file - * @brief Patch related functions and typedefs - */ - - -#ifndef FCLAW3D_PATCH_H -#define FCLAW3D_PATCH_H - -#include /* Contains definition of patch-iterator callback */ - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} -#endif -#endif - - -/** vtable type */ -typedef struct fclaw3d_patch_vtable fclaw3d_patch_vtable_t; -/** patch data type */ -typedef struct fclaw3d_patch_data fclaw3d_patch_data_t; -/** transform data type */ -typedef struct fclaw3d_patch_transform_data fclaw3d_patch_transform_data_t; - -/** - * @brief The build mode - */ -typedef enum -{ - /** Expect the patch's area array to be computed when unpacked */ - FCLAW3D_BUILD_FOR_GHOST_AREA_COMPUTED = 0, - /** Pack a patch's area array */ - FCLAW3D_BUILD_FOR_GHOST_AREA_PACKED, - /** Build for an updated grid */ - FCLAW3D_BUILD_FOR_UPDATE, - /** Use a user defined build mode */ - FCLAW3D_BUILD_CUSTOM -} fclaw3d_build_mode_t; - - - -/** - * @brief Structure for user patch data - * - * The user patch (clawpatch, for example) is stored in fclaw3d_patch_data.user_patch - */ -struct fclaw3d_patch_data -{ - /** Pointer to the core patch structure in the domain */ - const fclaw3d_patch_t *real_patch; - - /** Neighbor relation on each face */ - fclaw3d_patch_relation_t face_neighbors[6]; - /** Neighbor relation on each corner */ - fclaw3d_patch_relation_t edge_neighbors[12]; - /** Neighbor relation on each corner */ - fclaw3d_patch_relation_t corner_neighbors[8]; - /** Edge variables required or not? Feel free to add */ - /** True if corner has neighbor */ - int corners[8]; - /** The number of patches that meet at each corner */ - int block_corner_count[8]; - /** True if this patch lies on a coarse-fine interface */ - int on_coarsefine_interface; - /** True if there are finer neighbors */ - int has_finegrid_neighbors; - /** True if neighbor information is set */ - int neighbors_set; - - /** Patch index */ - int patch_idx; - /** Block index */ - int block_idx; - - /** User defined patch structure */ - void *user_patch; - /** Additional user data */ - void *user_data; -}; - -/** - * @brief Transform data for a neighboring patch's coordinate system - */ -struct fclaw3d_patch_transform_data -{ - /** Pointer to this patch */ - struct fclaw3d_patch *this_patch; - /** Pointer to the neighbor patch */ - struct fclaw3d_patch *neighbor_patch; - /** - * @brief Transform array - * - * This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - */ - int transform[9]; - /** The corner that the neighboring patch is on. */ - int icorner; - /** - * @brief Base index - * - * 1 for cell-centered (1 .. mx); 0 for nodes (0 .. mx) - */ - int based; - /** True if patch is on a block corner */ - int is_block_corner; - /** -1 for interior faces or block corners */ - int block_iface; - - /** Pointer to the glboal context */ - struct fclaw3d_global *glob; - /** User pointer */ - void* user; -}; - - -struct fclaw3d_global; -struct fclaw3d_domain; -struct fclaw3d_patch; - - -/* ------------------------------------------------------------------------------------ */ -/// @name Creating/Deleting Patches -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * DEPRECATED - * @deprecated NOT USED - */ -void fclaw3d_patch_reset_data(struct fclaw3d_global* glob, - struct fclaw3d_patch* old_patch, - struct fclaw3d_patch* new_patch, - int blockno,int old_patchno, int new_patchno); - - -/** - * @brief Deallocate the user data pointer for a patch - * - * @param[in] glob the global context - * @param[in,out] patch the patch context, user data pointer is set to NULL on return - */ -void fclaw3d_patch_data_delete(struct fclaw3d_global *glob, - struct fclaw3d_patch *patch); - -/** - * @brief Construct a new patch object - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in,out] user user data pointer - */ -void fclaw3d_patch_build(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - void *user); - -/** - * @brief Construct a new patch object from a set of fine patches - * - * @param[in] glob the global context - * @param[in] fine_patches the fine patch contexts - * @param[in,out] coarse_patches the coarse patch context - * @param[in] blockno the block number - * @param[in] coarse_patchno coarse patch number - * @param[in] fine0_patchno first fine patch number - * @param[in] build_mode the build mode - */ -void fclaw3d_patch_build_from_fine(struct fclaw3d_global *glob, - struct fclaw3d_patch *fine_patches, - struct fclaw3d_patch *coarse_patch, - int blockno, - int coarse_patchno, - int fine0_patchno, - fclaw3d_build_mode_t build_mode); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Solver Specific Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Initialize patch data for a solver - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -void fclaw3d_patch_initialize(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno); - -/** - * @brief Initialize boundary conditions - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] t the time - * @param[in] dt the timestep - * @param[in] intersects_bc array of values for each face, true if physical boundary - * @param[in] time_interp true if in time interpolation stage (not global) - */ -void fclaw3d_patch_physical_bc(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - double t, - double dt, - int *intersects_bc, - int time_interp); - -/** - * @brief Advance a patch with a single time step - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] t the time - * @param[in] dt the timestep - * @param[in] user pointer to the ::fclaw3d_single_step_buffer_data struct (used in cudaclaw) - * @return double the maxcfl - */ -double fclaw3d_patch_single_step_update(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - double t, - double dt, void* user); - -/** - * @brief Set the right hand side for a patch - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -void fclaw3d_patch_set_rhs(struct fclaw3d_global *glob, - struct fclaw3d_patch *patch, - int blockno, - int patchno); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Time Stepping -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Restores a previously saved solution - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - */ -void fclaw3d_patch_restore_step(struct fclaw3d_global* glob, - struct fclaw3d_patch* this_patch); - -/** - * @brief Saves the current solution for later use - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - */ -void fclaw3d_patch_save_step(struct fclaw3d_global* glob, - struct fclaw3d_patch* this_patch); - -/** - * @brief Sets up interpolated values for a patch - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] alpha the alpha value, with 0 being the last time step and 1 being the current time step - */ -void fclaw3d_patch_setup_timeinterp(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - double alpha); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Ghost Filling -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Copies ghost data from a face-neighboring grid on the same level - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch context - * @param[in] neighbor_patch the neighbor patch context - * @param[in] iface the interface that the neighbor patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw3d_patch_copy_face(struct fclaw3d_global* glob, - struct fclaw3d_patch *this_patch, - struct fclaw3d_patch *neighbor_patch, - int iface, - int time_interp, - struct fclaw3d_patch_transform_data *transform_data); - -/** - * @brief Averages values from a face-neighboring fine grid - * - * @param[in] glob the global context - * @param[in,out] coarse_patch this patch context - * @param[in] fine_patch the fine patch context - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] ifaced_coarse the interface of the fine neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refine_factor the refinement factor (number of neighbors) - * @param[in] refratio the refinement ratio - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] igrid the index of the fine neighbor in the child array - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw3d_patch_average_face(struct fclaw3d_global* glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch *fine_patch, - int idir, - int iface_coarse, - int refine_factor, - int refratio, - int time_interp, - int igrid, - struct fclaw3d_patch_transform_data* transform_data); - -/** - * @brief Interpolates values from a face-neighboring coarse grid - * - * @param[in] glob the global context - * @param[in] coarse_patch this patch context - * @param[in,out] fine_patch the fine patch context - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] ifaced_coarse the interface of the fine neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refine_factor the refinement factor (number of neighbors) - * @param[in] refratio the refinement ratio - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] igrid the index of the fine neighbor in the child array - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw3d_patch_interpolate_face(struct fclaw3d_global* glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch *fine_patch, - int idir, - int iside, - int RefineFactor, - int refratio, - int time_interp, - int igrid, - struct fclaw3d_patch_transform_data* transform_data); - -/* Do we want fclaw3d_patch_copy/average/interpolate_edge as well? - * Feel free to add. */ - -/** - * @brief Copies values from a corner-neighboring grid - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch context - * @param[in] neighbor_patch the neighbor patch context - * @param[in] this_blockno the block number of this patch - * @param[in] neighbor_blockno the block number of the neighbor patch - * @param[in] is_block_corner true if corner is on the corner of a block - * @param[in] icorner the corner that the neighboring patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw3d_patch_copy_corner(struct fclaw3d_global* glob, - struct fclaw3d_patch *this_patch, - struct fclaw3d_patch *neighbor_patch, - int this_blockno, - int neighbor_blockno, - int is_block_corner, - int icorner, - int time_interp, - struct fclaw3d_patch_transform_data *transform_data); - -/** - * @brief Averages values from a corner-neighboring fine grid - * - * @param[in] glob the global context - * @param[in,out] coarse_patch the coarse patch context - * @param[in] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] is_block_corner true if corner is on the corner of a block - * @param[in] icorner the corner of the coarse patch that the fine patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw3d_patch_average_corner(struct fclaw3d_global* glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch *fine_patch, - int coarse_blockno, - int fine_blockno, - int is_block_corner, - int coarse_corner, - int time_interp, - struct fclaw3d_patch_transform_data* transform_data); - -/** - * @brief Interpolates values from a corner-neighboring coarse grid - * - * @param[in] glob the global context - * @param[in] coarse_patch the coarse patch context - * @param[in,out] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] is_block_corner true if corner is on the corner of a block - * @param[in] icorner the corner of the coarse patch that the fine patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -void fclaw3d_patch_interpolate_corner(struct fclaw3d_global* glob, - struct fclaw3d_patch* coarse_patch, - struct fclaw3d_patch* fine_patch, - int coarse_blockno, - int fine_blockno, - int is_block_corner, - int coarse_corner, - int time_interp, - struct fclaw3d_patch_transform_data* transform_data); - -///@} -/** - * DEPRECATED - * @deprecated NOT USED - */ -void fclaw3d_patch_create_user_data(struct fclaw3d_global* glob, - struct fclaw3d_patch* patch); - -/** - * DEPRECATED - * @deprecated NOT USED - */ -void fclaw3d_patch_destroy_user_data(struct fclaw3d_global* glob, - struct fclaw3d_patch* patch); - -/* ------------------------------------------------------------------------------------ */ -/// @name Transform Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Initialize the transform data for a patch - * - * @param[in] glob the global context - * @param[in] patch the patch context - * @param[in] blockno the block number, -1 if ghost patch - * @param[in] patchno the patch number - * @param[in,out] tdata the stransform data structure - */ -void fclaw3d_patch_transform_init_data(struct fclaw3d_global* glob, - struct fclaw3d_patch* patch, - int blockno, int patchno, - struct fclaw3d_patch_transform_data *tdata); - -/** - * @brief Get the transform on a block face - * - * @param[in] glob the global context - * @param[in] faceno - * @param[in] rfaceno - * @param[out] ftransform This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - */ -void fclaw3d_patch_transform_blockface(struct fclaw3d_global* glob, - int faceno, int rfaceno, - int ftransform[]); - -/** - * @brief Get the transform for within a block (the identity transform) - * - * @param[in] glob the global context - * @param[out] ftransform This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - */ -void fclaw3d_patch_transform_blockface_intra(struct fclaw3d_global* glob, - int ftransform[]); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Regridding Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Tag a patch for refinement - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] this_blockno the block number - * @param[in] this_patchno the patch number - * @param[in] initflag true if in init phase - * @return true if patch should be refined - */ -int fclaw3d_patch_tag4refinement(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, int patchno, - int initflag); - -/** - * @brief Tag a patch for coarsening - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] this_blockno the block number - * @param[in] this_patchno the patch number - * @param[in] initflag true if in init phase - * @return true if patch should be coarsened - */ -int fclaw3d_patch_tag4coarsening(struct fclaw3d_global *glob, - struct fclaw3d_patch *fine_patches, - int blockno, - int patchno, - int initflag); - -/** - * @brief Interpolates a set of patches from a coarse patch - * - * @param[in] glob the global context - * @param[in] coarse_patch the coarse patch context - * @param[in,out] fine_patches the fine patch contexts - * @param[in] blockno the block number - * @param[in] coarse_patchno the patch number of the coarse patch - * @param[in] fine0_patchno the patch number of the first fine patch - */ -void fclaw3d_patch_interpolate2fine(struct fclaw3d_global *glob, - struct fclaw3d_patch* coarse_patch, - struct fclaw3d_patch* fine_patches, - int this_blockno, int coarse_patchno, - int fine0_patchno); - -/** - * @brief Averages from a set of fine patches to a coarse patch - * - * @param[in] glob the global context - * @param[in] fine_patches the fine patch contexts - * @param[in,out] coarse_patch the coarse patch context - * @param[in] blockno the block number - * @param[in] fine_patchno the patch number of the first fine patch - * @param[in] coarse_patchno the patch number of the coarse patch - */ -void fclaw3d_patch_average2coarse(struct fclaw3d_global *glob, - struct fclaw3d_patch *fine_patches, - struct fclaw3d_patch *coarse_patch, - int blockno, int fine0_patchno, - int coarse_patchno); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Parallel Ghost Patches -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Get the buffer size needed to pack a single patch's ghost data - * - * @param[in] glob the global context - * @return the buffer size (in bytes) - */ -size_t fclaw3d_patch_ghost_packsize(struct fclaw3d_global* glob); - -/** - * @brief Allocates a buffer for the patch ghost data - * - * @param[in] glob the global context - * @param[out] q pointer to the allocated buffer - */ -void fclaw3d_patch_local_ghost_alloc(struct fclaw3d_global* glob, - void** q); - -/** - * @brief Frees a buffer for the patch ghost data - * - * @param[in] glob the global context - * @param[out] q pointer to the buffer to free - */ -void fclaw3d_patch_local_ghost_free(struct fclaw3d_global* glob, - void **q); - -/** - * @brief Packs the patch ghost data into a buffer - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in,out] patch_data the buffer - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - */ -void fclaw3d_patch_local_ghost_pack(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - void *patch_data, - int time_interp); - -/** - * @brief Builds a new ghost patch - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] build_mode the build mode - */ -void fclaw3d_patch_remote_ghost_build(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - fclaw3d_build_mode_t build_mode); - -/** - * @brief Unpacks a ghost patch from a buffer - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] qdata the buffer to unpack from - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - */ -void fclaw3d_patch_remote_ghost_unpack(struct fclaw3d_global* glob, - struct fclaw3d_patch* this_patch, - int blockno, int patchno, - void *qdata, int time_interp); - - -/** - * @brief Frees memory used by a ghost patch - * - * @param[in] glob the global context - * @param[in,out] ghost_patch the patch context - */ -void fclaw3d_patch_remote_ghost_delete(struct fclaw3d_global *glob, - struct fclaw3d_patch *ghost_patch); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Parallel Partitioning -/* ------------------------------------------------------------------------------------ */ -///@{ - - -/** - * @brief Packs a patch into a buffer - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[out] pack_data_here the buffer - */ -void fclaw3d_patch_partition_pack(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - void *pack_data_here); - -/** - * @brief Unpacks a patch from a buffer - * - * @param[in] glob the global context (contains the old domain) - * @param[in] new_domain the new domain - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] packed_data the buffer - */ -void fclaw3d_patch_partition_unpack(struct fclaw3d_global *glob, - struct fclaw3d_domain *new_domain, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - void *packed_data); - -/** - * @brief Gets the buffer size (in bytes) needed to pack a patch - * - * @param[in] glob the global context - * @return size_t the size of buffer needed - */ -size_t fclaw3d_patch_partition_packsize(struct fclaw3d_global* glob); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Time Syncing Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Adds fine grid corrections to coarse grid. - * - * @param[in] glob the global context - * @param[in,out] coarse_patch the coarse patch context - * @param[in] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] coarse_patchno the patch number of the coarse patch - * @param[in] idir the direction of the interface 0 for bottom/top - * 1 for left/right - * @param[in] igrid the index of the fine grid in the child array - * @param[in] iface_coarse the interface on the coarse patch - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] transform_data the transform for the neighbor's coordinates - */ -void fclaw3d_patch_time_sync_f2c(struct fclaw3d_global* glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch *fine_patch, - int coarse_blockno, int fine_blockno, - int coarse_patchno, - int idir, - int igrid, - int iface_coarse, - int time_interp, - struct fclaw3d_patch_transform_data* transform_data); - -/** - * @brief Adds corrections to patches that are at the same levle and are at block boundaries. - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch - * @param[in] neighbor_patch the neighbor patch - * @param[in] this_iface the interface that the neighbor patch is on - * @param[in] idir the direction of the interface 0 for bottom/top - * 1 for left/right - * @param[in] transform_data the transform for the neighbor's coordinates - */ -void fclaw3d_patch_time_sync_samesize(struct fclaw3d_global* glob, - struct fclaw3d_patch *this_patch, - struct fclaw3d_patch *neighbor_patch, - int this_iface, int idir, - struct fclaw3d_patch_transform_data *transform_data); - -/** - * @brief Resets conservation data - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] coarse_level the the level of the coarse patch - * @param[in] reset_mode the reset mode ::fclaw3d_time_sync_type - */ -void fclaw3d_patch_time_sync_reset(struct fclaw3d_global* glob, - struct fclaw3d_patch* this_patch, - int coarse_level, - int reset_mode); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Creating/Deleting Patches (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Allocates a new patch - * - * @return the newly allocated patch - */ -typedef void* (*fclaw3d_patch_new_t)(); - -/** - * @brief Deallocates a patch - * - * @param[in] user_patch the patch to deallocate - */ -typedef void (*fclaw3d_patch_delete_t)(void *user_patch); - -/** - * @brief Initializes the data members of a patch - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno patch number - * @param[in,out] user user data pointer - */ -typedef void (*fclaw3d_patch_build_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - void *user); - -/** - * @brief Initializes a new coarser patch from a set of finer patches - * - * @param[in] glob the global context - * @param[in] fine_patches the fine patch contexts - * @param[in,out] coarse_patches the coarse patch context - * @param[in] blockno the block number - * @param[in] coarse_patchno coarse patch number - * @param[in] fine0_patchno first fine patch number - * @param[in] build_mode the build mode - */ -typedef void (*fclaw3d_patch_build_from_fine_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *fine_patches, - struct fclaw3d_patch *coarse_patch, - int blockno, - int coarse_patchno, - int fine0_patchno, - fclaw3d_build_mode_t build_mode); - -/** - * @brief Performs additional setup for a patch - * - * @param[in] the global context - * @param[in,out] the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -typedef void (*fclaw3d_patch_setup_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int patchno, - int blockno); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Solver Specific Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Initializes values in arrays of patch - * - * @param[in] the global context - * @param[in,out] the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -typedef void (*fclaw3d_patch_initialize_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno); - -/** - * @brief Initializes boundary conditions - * - * @param[in] the global context - * @param[in,out] the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] t the the current time - * @param[in] dt the size of time step - * @param[in] intersects_bc array of values for each face, true if boundary on face is - * a physical boundary - * @param[in] time_interp the patch number - */ -typedef void (*fclaw3d_patch_physical_bc_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - double t, - double dt, - int *intersects_bc, - int time_interp); - -/** - * @brief Advances a patch using a single explicit time step. - * - * @param[in] the global context - * @param[in,out] the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in] t the the current time - * @param[in] dt the size of time step - * @param[in,out] buffer_data pointer to the ::fclaw3d_single_step_buffer_data struct - * (used in cudaclaw) - * @return the maxcfl - */ -typedef double (*fclaw3d_patch_single_step_update_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - double t, - double dt, - void *user); - - -/** - * @brief Sets the right hand side for a patch - * - * @param[in] glob the global context - * @param[in,out] patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -typedef void (*fclaw3d_patch_rhs_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *patch, - int blockno, - int patchno); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Time Stepping (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** @copydoc fclaw2d_patch_setup_timeinterp() */ -typedef void (*fclaw3d_patch_setup_timeinterp_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - double alpha); - -/** @copydoc fclaw2d_patch_restore_step() */ -typedef void (*fclaw3d_patch_restore_step_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch* this_patch); - -/** @copydoc fclaw2d_patch_save_step() */ -typedef void (*fclaw3d_patch_save_step_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch* this_patch); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Ghost Filling (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Copies ghost data from a face-neighboring grid on the same level - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch context - * @param[in] neighbor_patch the neighbor patch context - * @param[in] iface the interface that the neighbor patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw3d_patch_copy_face_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch *this_patch, - struct fclaw3d_patch *neighbor_patch, - int iface, - int time_interp, - struct fclaw3d_patch_transform_data - *transform_data); - -/** - * @brief Averages values from a face-neighboring fine grid - * - * @param[in] glob the global context - * @param[in,out] coarse_patch this patch context - * @param[in] fine_patch the fine patch context - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] ifaced_coarse the interface of the fine neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refine_factor the refinement factor (number of neighbors) - * @param[in] refratio the refinement ratio - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] igrid the index of the fine neighbor in the child array - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw3d_patch_average_face_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch *fine_patch, - int idir, - int iface_coarse, - int refine_factor, - int refratio, - int time_interp, - int igrid, - struct fclaw3d_patch_transform_data - *transform_data); - -/** - * @brief Interpolates values from a face-neighboring coarse grid - * - * @param[in] glob the global context - * @param[in] coarse_patch this patch context - * @param[in,out] fine_patch the fine patch context - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] ifaced_coarse the interface of the fine neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refine_factor the refinement factor (number of neighbors) - * @param[in] refratio the refinement ratio - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] igrid the index of the fine neighbor in the child array - * @param[in] manifold true if using mainifold - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw3d_patch_interpolate_face_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch *fine_patch, - int idir, - int iside, - int refine_factor, - int refratio, - int time_interp, - int igrid, - struct fclaw3d_patch_transform_data - *transform_data); - -/* Do we want a fclaw3d_patch_copy/average/interpolate_edge_t as well? - * Feel free to add. */ - -/** - * @brief Copies values from a corner-neighboring grid - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch context - * @param[in] neighbor_patch the neighbor patch context - * @param[in] this_blockno the block number of this patch - * @param[in] neighbor_blockno the block number of the neighbor patch - * @param[in] icorner the corner that the neighboring patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw3d_patch_copy_corner_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch *this_patch, - struct fclaw3d_patch *neighbor_patch, - int this_blockno, - int neighbor_blockno, - int icorner, - int time_interp, - struct fclaw3d_patch_transform_data - *transform_data); - -/** - * @brief Averages values from a corner-neighboring fine grid - * - * @param[in] glob the global context - * @param[in,out] coarse_patch the coarse patch context - * @param[in] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] icorner the corner of the coarse patch that the fine patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw3d_patch_average_corner_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch *fine_patch, - int coarse_blockno, - int fine_blockno, - int icorner, - int time_interp, - struct fclaw3d_patch_transform_data - *transform_data); - -/** - * @brief Interpolates values from a corner-neighboring coarse grid - * - * @param[in] glob the global context - * @param[in] coarse_patch the coarse patch context - * @param[in,out] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] icorner the corner of the coarse patch that the fine patch is on - * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) - * @param[in] tranform_data the tranform data for the neighbor's coordinate system - */ -typedef void (*fclaw3d_patch_interpolate_corner_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch *fine_patch, - int coarse_blockno, - int fine_blockno, - int icorner, - int time_interp, - struct fclaw3d_patch_transform_data - *transform_data); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Transform Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Initialize the transform data for a patch - * - * @param[in] glob the global context - * @param[in] patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in,out] tdata the stransform data structure - */ -typedef void (*fclaw3d_patch_transform_init_data_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch* patch, - int blockno, int patchno, - struct fclaw3d_patch_transform_data *tdata); - -/** - * @brief Gets the transform on a block face - * - * @param[in] faceno - * @param[in] rfaceno - * @param[out] ftransform This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - */ -typedef void (*fclaw3d_patch_transform_blockface_t)(int faceno, int rfaceno, - int ftransform[]); - -/** - * @brief Gets the transform for within a block (the identity transform) - * - * @param[out] ftransform This array holds 9 integers. - * [0,2] The coordinate axis sequence of the origin face, - * the first referring to the tangential and the second - * to the normal. A permutation of (0, 1). - * [3,5] The coordinate axis sequence of the target face. - * [6,8] Edge reversal flag for tangential axis (boolean); - * face code in [0, 3] for the normal coordinate q: - * 0: q' = -q - * 1: q' = q + 1 - * 2: q' = q - 1 - * 3: q' = 2 - q - * [8] & 4: Both patches are in the same block, - * the \a ftransform contents are ignored. - */ -typedef void (*fclaw3d_patch_transform_blockface_intra_t)(int ftransform[]); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Regridding Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Tags a patch for refinement - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] this_blockno the block number - * @param[in] this_patchno the patch number - * @param[in] initflag true if in init phase - * @return true if patch should be refined - */ -typedef int (*fclaw3d_patch_tag4refinement_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int this_blockno, int this_patchno, - int initflag); - -/** - * @brief Tags a patch for coarsening - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] this_blockno the block number - * @param[in] this_patchno the patch number - * @param[in] initflag true if in init phase - * @return true if patch should be coarsened - */ -typedef int (*fclaw3d_patch_tag4coarsening_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int this_blockno, - int this_patchno, - int initflag); - -/** - * @brief Interpolates a set of patches from a coarse patch - * - * @param[in] glob the global context - * @param[in] coarse_patch the coarse patch context - * @param[in,out] fine_patches the fine patch contexts - * @param[in] blockno the block number - * @param[in] coarse_patchno the patch number of the coarse patch - * @param[in] fine_patchno the patch number of the first fine patch - */ -typedef void (*fclaw3d_patch_interpolate2fine_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch* fine_patches, - int blockno, int coarse_patchno, - int fine_patchno); -/** - * @brief Averages from a set of fine patches to a coarse patch - * - * @param[in] glob the global context - * @param[in] fine_patches the fine patch contexts - * @param[in,out] coarse_patch the coarse patch context - * @param[in] blockno the block number - * @param[in] fine_patchno the patch number of the first fine patch - * @param[in] coarse_patchno the patch number of the coarse patch - */ -typedef void (*fclaw3d_patch_average2coarse_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *fine_patches, - struct fclaw3d_patch *coarse_patch, - int blockno, int fine_patchno, - int coarse_patchno); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Parallel Ghost Patches (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** @copydoc fclaw2d_patch_ghost_packsize() */ -typedef size_t (*fclaw3d_patch_ghost_packsize_t)(struct fclaw3d_global* glob); - -/** @copydoc fclaw2d_patch_local_ghost_pack() */ -typedef void (*fclaw3d_patch_local_ghost_pack_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - void *patch_data, - int time_interp); - -/** @copydoc fclaw2d_patch_local_ghost_alloc() */ -typedef void (*fclaw3d_patch_local_ghost_alloc_t)(struct fclaw3d_global* glob, - void** q); - -/** @copydoc fclaw2d_patch_local_ghost_free() */ -typedef void (*fclaw3d_patch_local_ghost_free_t)(struct fclaw3d_global* glob, - void **q); - - -/** @copydoc fclaw2d_patch_remote_ghost_build() */ -typedef void (*fclaw3d_patch_remote_ghost_build_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - fclaw3d_build_mode_t build_mode); - -/** - * @brief Performs additional setup step after build - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] blockno the block number - * @param[in] blockno the patch number - */ -typedef void (*fclaw3d_patch_remote_ghost_setup_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno); - - -/** @copydoc fclaw2d_patch_remote_ghost_unpack() */ -typedef void (*fclaw3d_patch_remote_ghost_unpack_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch* this_patch, - int blockno, int patchno, - void *qdata, int time_interp); - -/** @copydoc fclaw2d_patch_remote_ghost_delete() */ -typedef void (*fclaw3d_patch_remote_ghost_delete_t)(void *user_patch); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Partitioning (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** @copydoc fclaw2d_patch_partition_packsize() */ -typedef size_t (*fclaw3d_patch_partition_packsize_t)(struct fclaw3d_global* glob); - - -/** @copydoc fclaw2d_patch_partition_pack() */ -typedef void (*fclaw3d_patch_partition_pack_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - void *pack_data_here); - -/** @copydoc fclaw2d_patch_partition_unpack() */ -typedef void (*fclaw3d_patch_partition_unpack_t)(struct fclaw3d_global *glob, - struct fclaw3d_domain *new_domain, - struct fclaw3d_patch *this_patch, - int blockno, - int patchno, - void *unpack_data_from_here); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Conservative Updates (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - - -/** @copydoc fclaw2d_patch_time_sync_f2c() */ -typedef void (*fclaw3d_patch_time_sync_f2c_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch *coarse_patch, - struct fclaw3d_patch *fine_patch, - int coarse_blockno, int fine_blockno, - int coarse_patchno, - int idir, - int igrid, - int iface_coarse, - int time_interp, - struct fclaw3d_patch_transform_data - *transform_data); - -/** @copydoc fclaw2d_patch_time_sync_samesize() */ -typedef void (*fclaw3d_patch_time_sync_samesize_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch* this_patch, - struct fclaw3d_patch* neighbor_patch, - int this_iface, int idir, - struct fclaw3d_patch_transform_data - *transform_data); - -/** @copydoc fclaw2d_patch_time_sync_reset() */ -typedef void (*fclaw3d_patch_time_sync_reset_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *this_patch, - int coarse_level, - int reset_mode); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name User Data Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Creates user data - * - * @param[in] glob the global context - * @param[in,out] patch the patch context - */ -typedef void (*fclaw3d_patch_create_user_data_t)(struct fclaw3d_global *glob, - struct fclaw3d_patch *patch); - -/** - * @brief Destroys user data - * - * @param[in] glob the global context - * @param[in,out] patch the patch context - */ -typedef void (*fclaw3d_patch_destroy_user_data_t)(struct fclaw3d_global* glob, - struct fclaw3d_patch* patch); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Access Functions (typedefs) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Returns the corresponding metric patch - * - * @param[in] patch the patch context - */ -typedef void* (*fclaw3d_patch_metric_patch_t)(struct fclaw3d_patch *patch); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Virtual Table -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** vtable for patch level routines */ -struct fclaw3d_patch_vtable -{ - /** @{ @name Creating/Deleting/Building */ - - /** @copybrief ::fclaw2d_patch_new_t */ - fclaw3d_patch_new_t patch_new; - /** @copybrief ::fclaw2d_patch_delete_t */ - fclaw3d_patch_delete_t patch_delete; - /** @copybrief ::fclaw2d_patch_build_t */ - fclaw3d_patch_build_t build; - /** @copybrief ::fclaw2d_patch_build_from_fine_t */ - fclaw3d_patch_build_from_fine_t build_from_fine; - /** @copybrief ::fclaw2d_patch_setup_t */ - fclaw3d_patch_setup_t setup; - - /** @} */ - - /** @copybrief ::fclaw2d_patch_metric_patch_t */ - fclaw3d_patch_metric_patch_t metric_patch; - - /** @{ @name User Data */ - - /** @copybrief ::fclaw2d_patch_create_user_data_t */ - fclaw3d_patch_create_user_data_t create_user_data; - /** @copybrief ::fclaw2d_patch_destroy_user_data_t */ - fclaw3d_patch_destroy_user_data_t destroy_user_data; - - /** @} */ - - /** @{ @name Solver Functions */ - - /** @copybrief ::fclaw2d_patch_initialize_t */ - fclaw3d_patch_initialize_t initialize; - /** @copybrief ::fclaw2d_patch_physical_bc_t */ - fclaw3d_patch_physical_bc_t physical_bc; - /** @copybrief ::fclaw2d_patch_single_step_update_t */ - fclaw3d_patch_single_step_update_t single_step_update; - /** @copybrief ::fclaw2d_patch_rhs_t */ - fclaw3d_patch_rhs_t rhs; - - /** @} */ - - /** @{ @name Time Stepping */ - - /** @copybrief ::fclaw2d_patch_restore_step_t */ - fclaw3d_patch_restore_step_t restore_step; - /** @copybrief ::fclaw2d_patch_save_step_t */ - fclaw3d_patch_save_step_t save_step; - /** @copybrief ::fclaw2d_patch_setup_timeinterp_t */ - fclaw3d_patch_setup_timeinterp_t setup_timeinterp; - - /** @} */ - - /** @{ @name Regridding Functions */ - - /** @copybrief ::fclaw2d_patch_tag4refinement_t */ - fclaw3d_patch_tag4refinement_t tag4refinement; - /** @copybrief ::fclaw2d_patch_tag4coarsening_t */ - fclaw3d_patch_tag4coarsening_t tag4coarsening; - /** @copybrief ::fclaw2d_patch_average2coarse_t */ - fclaw3d_patch_average2coarse_t average2coarse; - /** @copybrief ::fclaw2d_patch_interpolate2fine_t */ - fclaw3d_patch_interpolate2fine_t interpolate2fine; - - /** @} */ - - /** @{ @name Time Syncing Functions for Conservation */ - - /** @copybrief ::fclaw2d_patch_time_sync_f2c_t */ - fclaw3d_patch_time_sync_f2c_t time_sync_f2c; - /** @copybrief ::fclaw2d_patch_time_sync_samesize_t */ - fclaw3d_patch_time_sync_samesize_t time_sync_samesize; - /** @copybrief ::fclaw2d_patch_time_sync_reset_t */ - fclaw3d_patch_time_sync_reset_t time_sync_reset; - - /** @} */ - - - /** @{ @name Face Ghost Filling Functions */ - - /** @copybrief ::fclaw2d_patch_copy_face_t */ - fclaw3d_patch_copy_face_t copy_face; - /** @copybrief ::fclaw2d_patch_average_face_t */ - fclaw3d_patch_average_face_t average_face; - /** @copybrief ::fclaw2d_patch_interpolate_face_t */ - fclaw3d_patch_interpolate_face_t interpolate_face; - - /** @} */ - - /* Do we want to include a fclaw3d_patch_copy/average/interpolate_edge_t? - * Feel free to add. */ - - /** @{ @name Block Face and Interior Corner Ghost Filling Functions */ - - /** @copybrief ::fclaw2d_patch_copy_corner_t */ - fclaw3d_patch_copy_corner_t copy_corner; - /** @copybrief ::fclaw2d_patch_average_corner_t */ - fclaw3d_patch_average_corner_t average_corner; - /** @copybrief ::fclaw2d_patch_interpolate_corner_t */ - fclaw3d_patch_interpolate_corner_t interpolate_corner; - - /** @} */ - - /** @{ @name Block Corner Ghost Filling Functions */ - - /** @copybrief ::fclaw2d_patch_copy_corner_t */ - fclaw3d_patch_copy_corner_t copy_block_corner; - /** @copybrief ::fclaw2d_patch_average_corner_t */ - fclaw3d_patch_average_corner_t average_block_corner; - /** @copybrief ::fclaw2d_patch_interpolate_corner_t */ - fclaw3d_patch_interpolate_corner_t interpolate_block_corner; - - /** @} */ - - /** @{ @name Transform Functions */ - - /** @copybrief ::fclaw2d_patch_transform_init_data_t */ - fclaw3d_patch_transform_init_data_t transform_init_data; - /** @copybrief ::fclaw2d_patch_transform_blockface_t */ - fclaw3d_patch_transform_blockface_t transform_face; - /** @copybrief ::fclaw2d_patch_transform_blockface_intra_t */ - fclaw3d_patch_transform_blockface_intra_t transform_face_intra; - - /** @} */ - - /** @{ @name Ghost Packing Functions (for parallel use) */ - - /** @copybrief ::fclaw2d_patch_ghost_packsize_t */ - fclaw3d_patch_ghost_packsize_t ghost_packsize; - /** @copybrief ::fclaw2d_patch_local_ghost_pack_t */ - fclaw3d_patch_local_ghost_pack_t local_ghost_pack; - /** @copybrief ::fclaw2d_patch_local_ghost_alloc_t */ - fclaw3d_patch_local_ghost_alloc_t local_ghost_alloc; - /** @copybrief ::fclaw2d_patch_local_ghost_free_t */ - fclaw3d_patch_local_ghost_free_t local_ghost_free; - - /** @copybrief ::fclaw2d_patch_remote_ghost_build_t */ - fclaw3d_patch_remote_ghost_build_t remote_ghost_build; - /** @copybrief ::fclaw2d_patch_remote_ghost_setup_t */ - fclaw3d_patch_remote_ghost_setup_t remote_ghost_setup; - /** @copybrief ::fclaw2d_patch_remote_ghost_unpack_t */ - fclaw3d_patch_remote_ghost_unpack_t remote_ghost_unpack; - /** @copybrief ::fclaw2d_patch_remote_ghost_delete_t */ - fclaw3d_patch_remote_ghost_delete_t remote_ghost_delete; - - /** @} */ - - /** @{ @name Parallel Load Balancing (partitioning) */ - - /** @copybrief ::fclaw2d_patch_partition_pack_t */ - fclaw3d_patch_partition_pack_t partition_pack; - /** @copybrief ::fclaw2d_patch_partition_unpack_t */ - fclaw3d_patch_partition_unpack_t partition_unpack; - /** @copybrief ::fclaw2d_patch_partition_packsize_t */ - fclaw3d_patch_partition_packsize_t partition_packsize; - - /** @} */ - - /** True if vtable has been set */ - int is_set; -}; - -/** - * @brief Get the patch vtable - * - * @param glob the global context - * @return fclaw3d_patch_vtable_t* the vtable - */ -fclaw3d_patch_vtable_t* fclaw3d_patch_vt(struct fclaw3d_global* glob); - -/** - * @brief Initialize the patch vtable - * - * @param glob the global context - */ -void fclaw3d_patch_vtable_initialize(struct fclaw3d_global* glob); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Misc Access Functions -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Get the global_num, local_num, and level of a patch - * - * @param[in] domain - * @param[in] patch - * @param[in] blockno - * @param[in] patchno - * @param[out] global_num the global patch number - * @param[out] local_num the local patch number - * @param[out] level the level that the patch is on - */ -void fclaw3d_patch_get_info(struct fclaw3d_domain * domain, - struct fclaw3d_patch * patch, - int blockno, int patchno, - int *global_num, int* local_num, - int *level); - -/** - * @brief Get the block number, patch number, global_num, and level of a patch - * - * @param[in] domain the domain - * @param[in] this_patch the patch context - * @param[out] blockno the block number - * @param[out] patchno the patch number - * @param[out] global_num the global patch number - * @param[out] level the level - */ -/* I don't completely trust this routine */ -void fclaw3d_patch_get_info2(struct fclaw3d_domain * domain, - struct fclaw3d_patch * this_patch, - int *blockno, int *patchno, - int *global_num, int *level); -/** - * @brief Get the user patch pointer - * - * @param patch the patch context - * @return void* the pointer - */ -void* fclaw3d_patch_get_user_patch(struct fclaw3d_patch* patch); - -/** - * @brief Get the patch data - * - * @param patch the patch context - * @return struct fclaw3d_patch_data* pointer to the patch data - */ -struct fclaw3d_patch_data* fclaw3d_patch_get_patch_data(struct fclaw3d_patch* patch); - -/** - * @brief Get the user data pointer - * - * @param glob the global context - * @param this_patch the patch context - * @return void* the user data pointer - */ -void* fclaw3d_patch_get_user_data(struct fclaw3d_global* glob, - struct fclaw3d_patch* this_patch); - - -/** - * @brief Get the metric patch - * - * @param glob the global context - * @param patch the patch context - * @return void* pointer to the metric patch - */ -void* fclaw3d_patch_metric_patch(struct fclaw3d_global* glob, - struct fclaw3d_patch *patch); - -/** - * @brief Get the block number - * - * @param this_patch the patch context - * @return int the block number - */ -int fclaw3d_patch_get_blockno(struct fclaw3d_patch* this_patch); - -/** - * @brief Get the patch number - * - * @param this_patch the patch context - * @return int the patch number - */ -int fclaw3d_patch_get_patchno(struct fclaw3d_patch* this_patch); - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Misc User Data -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Get the user data pointer of a patch - * - * @param glob the global context - * @param this_patch the patch context - * @return void* the user data pointer - */ -void* fclaw3d_patch_user_data(struct fclaw3d_global* glob, - struct fclaw3d_patch* this_patch); - -/** - * @brief Set the user data pointer of a patch - * - * @param glob the global context - * @param this_patch the patch context - * @param user the user data pointer - */ -void fclaw3d_patch_set_user_data(struct fclaw3d_global* glob, - struct fclaw3d_patch* this_patch, - void* user); - - -///@} -/* ------------------------------------------------------------------------------------ */ -/// @name Misc Functions (mostly internal) -/* ------------------------------------------------------------------------------------ */ -///@{ - -/** - * @brief Returns true if patch lies on a parallel boundary - * - * @param patch the patch context - * @return int true if on parallel boundary - */ -int fclaw3d_patch_on_parallel_boundary (const struct fclaw3d_patch * patch); - - -/** - * @brief Set the face type for a patch - * - * @param patch the patch context - * @param iface the interface - * @param face_type the face type - */ -void fclaw3d_patch_set_face_type(struct fclaw3d_patch *patch, int iface, - fclaw3d_patch_relation_t face_type); - -/** - * @brief Set the edge type for a patch - * - * @param patch the patch context - * @param iedge the edge - * @param edge_type the edge type - */ -void fclaw3d_patch_set_edge_type(fclaw3d_patch_t *patch,int iedge, - fclaw3d_patch_relation_t edge_type); - -/** - * @brief Set the corner type for a patch - * - * @param patch the patch context - * @param icorner the corner - * @param corner_type the corner type - */ -void fclaw3d_patch_set_corner_type(struct fclaw3d_patch *patch, int icorner, - fclaw3d_patch_relation_t corner_type); - -/** - * @brief Set the missing corner of a patch - * - * @param patch the patch context - * @param icorner the missing corner - */ -void fclaw3d_patch_set_missing_corner(struct fclaw3d_patch *patch, int icorner); - -/** - * @brief Get the face type of a patch - * - * @param patch the patch context - * @param iface the face - * @return fclaw3d_patch_relation_t the face type - */ -fclaw3d_patch_relation_t fclaw3d_patch_get_face_type(struct fclaw3d_patch* patch, - int iface); - -/** - * @brief Get the edge type of a patch - * - * @param patch the patch context - * @param iface the edge - * @return fclaw3d_patch_relation_t the edge type - */ -fclaw3d_patch_relation_t fclaw2d_patch_get_edge_type(fclaw3d_patch_t* patch, - int iedge); - -/** - * @brief Get the corner type of a patch - * - * @param patch the patch context - * @param icorner the corner - * @return fclaw3d_patch_relation_t the patch relation - */ -fclaw3d_patch_relation_t fclaw3d_patch_get_corner_type(struct fclaw3d_patch* patch, - int icorner); - -/** - * @brief Returns true if a corner is missing - * - * @param patch the patch context - * @param icorner the corner - * @return int true if a corner is missing - */ -int fclaw3d_patch_corner_is_missing(struct fclaw3d_patch* patch, - int icorner); - -/** - * @brief Set the neighbor relation data for a patch - * - * @param patch the patch context - */ -void fclaw3d_patch_neighbors_set(fclaw3d_patch_t* patch); - -/** - * @brief Reset the neighbor relation data for a patch - * - * @param patch the patch context - */ -void fclaw3d_patch_neighbors_reset(struct fclaw3d_patch* patch); - -/** - * @brief Returns true if the patch neighbor information is set - * - * @param patch the patch context - * @return int true if the patch neighbor information is set - */ -int fclaw3d_patch_neighbor_type_set(struct fclaw3d_patch* patch); - -/** - * @brief Returns true if a patch has finer neighbors - * - * @param patch the patch context - * @return int true if the patch has finer neighbors - */ -int fclaw3d_patch_has_finegrid_neighbors(struct fclaw3d_patch *patch); - -/** - * @brief Returns true if the patch is on a coarse fine interface - * - * @param patch the patch context - * @return int true if the patch is on a coarse fine interface - */ -int fclaw3d_patch_on_coarsefine_interface(struct fclaw3d_patch *patch); - -/** - * @brief Get the block corner count array for a patch - * - * @param glob the global context - * @param this_patch the patch context - * @return int* the array with the block corner count (the number of blocks that meet) for each corner - */ -int* fclaw3d_patch_block_corner_count(struct fclaw3d_global *glob, - struct fclaw3d_patch* this_patch); - -/** - * @brief Set the block corner count for a corner - * - * @param glob the global context - * @param this_patch the patch context - * @param icorner the corner to set - * @param block_corner_count the block corner count (the number of blocks that meet) - */ -void fclaw3d_patch_set_block_corner_count(struct fclaw3d_global *glob, - struct fclaw3d_patch* this_patch, - int icorner, int block_corner_count); - -///@} - -#ifdef __cplusplus -#if 0 -{ -#endif -} -#endif - -#endif diff --git a/src/fclaw3d_map.c b/src/fclaw3d_wrap.c similarity index 93% rename from src/fclaw3d_map.c rename to src/fclaw3d_wrap.c index f92792c34..102eb3060 100644 --- a/src/fclaw3d_map.c +++ b/src/fclaw3d_wrap.c @@ -1,5 +1,5 @@ /* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun +Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,4 +24,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include "fclaw2d_map.c" +#include "fclaw2d_wrap.c" diff --git a/src/fclaw3d_wrap.h b/src/fclaw3d_wrap.h new file mode 100644 index 000000000..fb78b81e9 --- /dev/null +++ b/src/fclaw3d_wrap.h @@ -0,0 +1,125 @@ +/* +Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/** + * @file + * @brief Functions needed for wrapped fclaw types + * Most users will not need to include the file, unless doing something more advanced. + */ + + +#ifndef FCLAW3D_WRAP_H +#define FCLAW3D_WRAP_H + +#include +#include /* Contains definition of patch-iterator callback */ + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} /* need this because indent is dumb */ +#endif +#endif + +/** + * @brief Wraps a 2d domain in a fclaw_domain_t struct. + * + * This will overwrite the user pointer in the domain and domain patches with a + * pointer to the dimension independent wrapper types. + * + * @param[in,out] domain2d The domain to wrap + * @return struct fclaw_domain* the wrapped domain + */ +struct fclaw_domain* fclaw_domain_wrap_3d(fclaw3d_domain_t *domain2d); + +/** + * @brief Wraps a patch callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_patch_callback_t. + * The user pointer should be a pointer to a @ref fclaw_patch_wrap_user_t. + */ +void fclaw3d_patch_wrap_cb(fclaw3d_domain_t * domain, + fclaw3d_patch_t * patch, + int blockno, int patchno, void *user); + +/** + * @brief Wraps a transfer callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_transfer_callback_t. + * The user pointer should be a pointer to a @ref fclaw_transfer_wrap_user_t. + */ +void +fclaw3d_transfer_wrap_cb(fclaw3d_domain_t * old_domain, + fclaw3d_patch_t * old_patch, + fclaw3d_domain_t * new_domain, + fclaw3d_patch_t * new_patch, + int blockno, + int old_patchno, int new_patchno, + void *user); + +/** + * @brief Wraps a match callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_match_callback_t. + * The user pointer should be a pointer to a @ref fclaw_match_wrap_user_t. + */ +void +fclaw3d_match_wrap_cb(fclaw3d_domain_t * old_domain, + fclaw3d_patch_t * old_patch_3d, + fclaw3d_domain_t * new_domain, + fclaw3d_patch_t * new_patch_3d, + fclaw3d_patch_relation_t newsize, + int blockno, + int old_patchno, int new_patchno, + void *user); + +/** + * @brief Wraps a intersect callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_intersect_callback_t. + * The user pointer should be a pointer to a @ref fclaw_intersect_wrap_user_t. + */ +int +fclaw3d_intersect_wrap_cb (fclaw3d_domain_t * domain, + fclaw3d_patch_t * patch, + int blockno, int patchno, + void *ray, double *integral, + void *user); + +/** + * @brief Wraps a intersect callback for 2d domains. + * This is used by passing this callback to a function that takes a @ref fclaw2d_intersect_callback_t. + * The user pointer should be a pointer to a @ref fclaw_intersect_wrap_user_t. + */ +int +fclaw3d_interpolate_point_wrap_cb (fclaw3d_domain_t * domain, + fclaw3d_patch_t * patch, + int blockno, int patchno, + void *point, void *user); + +#ifdef __cplusplus +#if 0 +{ +#endif +} +#endif + +#endif diff --git a/src/fclaw2d_TEST.cpp b/src/fclaw_TEST.cpp similarity index 62% rename from src/fclaw2d_TEST.cpp rename to src/fclaw_TEST.cpp index 9b0b68001..c07ec6ccb 100644 --- a/src/fclaw2d_TEST.cpp +++ b/src/fclaw_TEST.cpp @@ -23,45 +23,45 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include -TEST_CASE("fclaw2d_global_set_global") +TEST_CASE("fclaw_global_set_global") { - fclaw2d_global_t* glob = (fclaw2d_global_t*)123; - fclaw2d_global_set_global(glob); - CHECK_EQ(fclaw2d_global_get_global(), glob); + fclaw_global_t* glob = (fclaw_global_t*)123; + fclaw_global_set_static(glob); + CHECK_EQ(fclaw_global_get_static_global(), glob); } -TEST_CASE("fclaw2d_global_unset_global") +TEST_CASE("fclaw_global_unset_global") { - fclaw2d_global_t* glob = (fclaw2d_global_t*)123; - fclaw2d_global_set_global(glob); - fclaw2d_global_unset_global(); + fclaw_global_t* glob = (fclaw_global_t*)123; + fclaw_global_set_static(glob); + fclaw_global_clear_static(); #ifdef FCLAW_ENABLE_DEBUG - CHECK_SC_ABORTED(fclaw2d_global_get_global()); + CHECK_SC_ABORTED(fclaw_global_get_static_global()); #else - CHECK_EQ(fclaw2d_global_get_global(), nullptr); + CHECK_EQ(fclaw_global_get_static_global(), nullptr); #endif } #ifdef FCLAW_ENABLE_DEBUG -TEST_CASE("fclaw2d_global_set_global twice fails") +TEST_CASE("fclaw_global_set_global twice fails") { - fclaw2d_global_t* glob = (fclaw2d_global_t*)123; - fclaw2d_global_set_global(glob); - CHECK_SC_ABORTED(fclaw2d_global_set_global(glob)); + fclaw_global_t* glob = (fclaw_global_t*)123; + fclaw_global_set_static(glob); + CHECK_SC_ABORTED(fclaw_global_set_static(glob)); } -TEST_CASE("fclaw2d_global_unset_global assert fails when NULL") +TEST_CASE("fclaw_global_unset_global assert fails when NULL") { - CHECK_SC_ABORTED(fclaw2d_global_unset_global()); + CHECK_SC_ABORTED(fclaw_global_clear_static()); } -TEST_CASE("fclaw2d_global_get_global assert fails when NULL") +TEST_CASE("fclaw_global_get_global assert fails when NULL") { - CHECK_SC_ABORTED(fclaw2d_global_get_global()); + CHECK_SC_ABORTED(fclaw_global_get_static_global()); } #endif diff --git a/src/fclaw2d_advance.c b/src/fclaw_advance.c similarity index 85% rename from src/fclaw2d_advance.c rename to src/fclaw_advance.c index 3da682a0e..74b903718 100644 --- a/src/fclaw2d_advance.c +++ b/src/fclaw_advance.c @@ -24,17 +24,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include +#include typedef struct fclaw2d_level_data @@ -52,12 +52,12 @@ typedef struct fclaw2d_level_data typedef fclaw2d_level_data_t fclaw2d_timestep_counters; static -void initialize_timestep_counters(fclaw2d_global_t* glob, +void initialize_timestep_counters(fclaw_global_t* glob, fclaw2d_timestep_counters **ts_counter_ptr, double t_init, double dt) { - fclaw2d_domain_t *domain = glob->domain; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_domain_t *domain = glob->domain; + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); fclaw2d_timestep_counters *ts_counter; int level; @@ -150,7 +150,7 @@ int timeinterp_level(fclaw2d_timestep_counters *ts_counter, int maxlevel) } static -double compute_alpha(fclaw2d_global_t *glob, +double compute_alpha(fclaw_global_t *glob, fclaw2d_timestep_counters *ts_counter, int level) { @@ -174,25 +174,25 @@ double compute_alpha(fclaw2d_global_t *glob, ---------------------------------------------------------- */ static -double update_level_solution(fclaw2d_global_t *glob, +double update_level_solution(fclaw_global_t *glob, int level, double t, double dt) { /* There might not be any grids at this level */ - double cfl = fclaw2d_update_single_step(glob,level,t,dt); + double cfl = fclaw_update_single_step(glob,level,t,dt); return cfl; } static -double advance_level(fclaw2d_global_t *glob, +double advance_level(fclaw_global_t *glob, const int level, const int curr_fine_step, double maxcfl, fclaw2d_timestep_counters* ts_counter) { - fclaw2d_domain_t* domain = glob->domain; - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + fclaw_domain_t* domain = glob->domain; + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); double t_level = ts_counter[level].current_time; double dt_level = ts_counter[level].dt_step; @@ -227,9 +227,9 @@ double advance_level(fclaw2d_global_t *glob, fclaw_global_infof("Time interpolating level %d using alpha = %5.2f\n", coarser_level,alpha); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_EXTRA1]); - fclaw2d_timeinterp(glob,coarser_level,alpha); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_EXTRA1]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_EXTRA1]); + fclaw_timeinterp(glob,coarser_level,alpha); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_EXTRA1]); } } } @@ -244,15 +244,15 @@ double advance_level(fclaw2d_global_t *glob, Main routine : Called from fclaw2d_run. ------------------------------------------------------------- */ -double fclaw2d_advance_all_levels(fclaw2d_global_t *glob, +double fclaw_advance_all_levels(fclaw_global_t *glob, double t_curr, double dt) { - fclaw2d_domain_t* domain = glob->domain; + fclaw_domain_t* domain = glob->domain; int level; - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_ADVANCE]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_ADVANCE]); - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); fclaw2d_timestep_counters *ts_counter; initialize_timestep_counters(glob,&ts_counter,t_curr,dt); @@ -291,15 +291,15 @@ double fclaw2d_advance_all_levels(fclaw2d_global_t *glob, int time_interp = 1; /* Do conservative fix up here */ - fclaw2d_ghost_update(glob, + fclaw_ghost_update(glob, time_interp_level+1, maxlevel, sync_time, time_interp, - FCLAW2D_TIMER_ADVANCE); + FCLAW_TIMER_ADVANCE); if (fclaw_opt->time_sync) { - fclaw2d_time_sync(glob,time_interp_level+1,maxlevel); + fclaw_time_sync(glob,time_interp_level+1,maxlevel); } } else @@ -307,15 +307,15 @@ double fclaw2d_advance_all_levels(fclaw2d_global_t *glob, /* End up here is we are doing global time stepping but return from advance after 2^(maxlevel-minlevel) time steps. */ int time_interp = 0; - fclaw2d_ghost_update(glob, + fclaw_ghost_update(glob, minlevel, maxlevel, sync_time, time_interp, - FCLAW2D_TIMER_ADVANCE); + FCLAW_TIMER_ADVANCE); if (fclaw_opt->time_sync) { - fclaw2d_time_sync(glob,minlevel,maxlevel); + fclaw_time_sync(glob,minlevel,maxlevel); } } } @@ -331,19 +331,19 @@ double fclaw2d_advance_all_levels(fclaw2d_global_t *glob, double sync_time = ts_counter[maxlevel].current_time; int time_interp = 0; - fclaw2d_ghost_update(glob,minlevel,maxlevel,sync_time, - time_interp,FCLAW2D_TIMER_ADVANCE); + fclaw_ghost_update(glob,minlevel,maxlevel,sync_time, + time_interp,FCLAW_TIMER_ADVANCE); if (fclaw_opt->time_sync) { /* This is the final synchronization not covered in fine_steps loop */ - fclaw2d_time_sync(glob,minlevel,maxlevel); + fclaw_time_sync(glob,minlevel,maxlevel); } delete_timestep_counters(&ts_counter); /* Stop the timer */ - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_ADVANCE]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_ADVANCE]); /* Count total grids on this processor */ glob->count_grids_per_proc += domain->local_num_patches; diff --git a/src/fclaw2d_advance.h b/src/fclaw_advance.h similarity index 90% rename from src/fclaw2d_advance.h rename to src/fclaw_advance.h index 0fa1e90e5..8f5cef500 100644 --- a/src/fclaw2d_advance.h +++ b/src/fclaw_advance.h @@ -24,8 +24,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_ADVANCE_H -#define FCLAW2D_ADVANCE_H +#ifndef FCLAW_ADVANCE_H +#define FCLAW_ADVANCE_H #ifdef __cplusplus extern "C" @@ -35,9 +35,9 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; -double fclaw2d_advance_all_levels (struct fclaw2d_global * glob,double t, double dt); +double fclaw_advance_all_levels (struct fclaw_global * glob,double t, double dt); #ifdef __cplusplus diff --git a/src/fclaw_base.c b/src/fclaw_base.c index 6a8a1156c..c0df4d475 100644 --- a/src/fclaw_base.c +++ b/src/fclaw_base.c @@ -945,39 +945,12 @@ fclaw_packing_vtable_t* fclaw_app_get_options_packing_vtable(const char*name){ return (fclaw_packing_vtable_t*) fclaw_pointer_map_get(packing_vtables,name); } -/*** which of the following do we need? ***/ - -#if 0 - -void -fclaw2d_global_log (int log_priority, const char *message) -{ - /* TODO: establish an fclaw_package_id */ - SC_GEN_LOG (sc_package_id, SC_LC_GLOBAL, log_priority, message); -} - -void * -fclaw2d_alloc (size_t size) -{ - return sc_malloc (p4est_package_id, size); -} - -void * -fclaw2d_calloc (size_t nmemb, size_t size) -{ - return sc_calloc (p4est_package_id, nmemb, size); -} - -void * -fclaw2d_realloc (void *ptr, size_t size) -{ - return sc_realloc (p4est_package_id, ptr, size); -} - void -fclaw2d_free (void *ptr) -{ - sc_free (p4est_package_id, ptr); -} +fclaw_abortf(const char *fmt, ...){ + va_list ap; -#endif /* 0 */ + va_start (ap, fmt); + fclaw_logv (SC_LC_NORMAL, SC_LP_ERROR, fmt, ap); + va_end (ap); + sc_abort(); +} \ No newline at end of file diff --git a/src/fclaw_base.h b/src/fclaw_base.h index edfc83a16..66d8ff61f 100644 --- a/src/fclaw_base.h +++ b/src/fclaw_base.h @@ -341,6 +341,13 @@ void fclaw_debugf (const char *fmt, ...) ; /* *INDENT-ON* */ +/** + * Print a an error mesage and abort the program + * \param [in] fmt A printf-style format string. + */ +void fclaw_abortf(const char* fmt,...) + __attribute__ ((noreturn)); + /** Register ForestClaw with libsc and print version and variable information. * It is not necessary to call this function, but it makes the log output more * useful and separates ForestClaw's memory allocation from other packages. diff --git a/src/fclaw2d_block.c b/src/fclaw_block.c similarity index 62% rename from src/fclaw2d_block.c rename to src/fclaw_block.c index 9f75e4044..5906d350c 100644 --- a/src/fclaw2d_block.c +++ b/src/fclaw_block.c @@ -23,25 +23,46 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include +#include -#include +#include +#include +#include +#include +#include -void fclaw2d_block_get_block_boundary(fclaw2d_global_t * glob, - fclaw2d_patch_t * patch, +void fclaw_block_get_block_boundary(fclaw_global_t * glob, + fclaw_patch_t * patch, int *intersects_block) { - int iside; - - for (iside = 0; iside < FCLAW2D_NUMFACES; iside++) + if(glob->domain->refine_dim == 2) { + for (int iside = 0; iside < FCLAW2D_NUMFACES; iside++) + { int iface_flags = fclaw2d_patch_block_face_flags[iside]; - int is_block_face = (patch->flags & iface_flags) != 0; + int is_block_face = (patch->d2->flags & iface_flags) != 0; /* True for physical and block boundaries across a face */ intersects_block[iside] = is_block_face; + } + } + else if(glob->domain->refine_dim == 3) + { + for (int iside = 0; iside < FCLAW3D_NUMFACES; iside++) + { + int iface_flags = fclaw3d_patch_block_face_flags[iside]; + int is_block_face = (patch->d3->flags & iface_flags) != 0; + + /* True for physical and block boundaries across a face */ + intersects_block[iside] = is_block_face; + } + } + else + { + SC_ABORT_NOT_REACHED(); } } diff --git a/src/fclaw2d_block.h b/src/fclaw_block.h similarity index 87% rename from src/fclaw2d_block.h rename to src/fclaw_block.h index 8905effe0..eaa0ab7db 100644 --- a/src/fclaw2d_block.h +++ b/src/fclaw_block.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_BLOCK_H -#define FCLAW2D_BLOCK_H +#ifndef FCLAW_BLOCK_H +#define FCLAW_BLOCK_H #ifdef __cplusplus extern "C" @@ -34,12 +34,12 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; void -fclaw2d_block_get_block_boundary(struct fclaw2d_global * glob, - struct fclaw2d_patch * patch, +fclaw_block_get_block_boundary(struct fclaw_global * glob, + struct fclaw_patch * patch, int *intersects_block); #ifdef __cplusplus diff --git a/src/fclaw_convenience.c b/src/fclaw_convenience.c new file mode 100644 index 000000000..d799793d3 --- /dev/null +++ b/src/fclaw_convenience.c @@ -0,0 +1,354 @@ +/* +Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include + +fclaw_domain_t *fclaw_domain_new_unitsquare (sc_MPI_Comm mpicomm, + int initial_level) +{ + fclaw2d_domain_t* domain2d; + domain2d = fclaw2d_domain_new_unitsquare(mpicomm, initial_level); + return fclaw_domain_wrap_2d(domain2d); +} + +fclaw_domain_t *fclaw_domain_new_2d_torus (sc_MPI_Comm mpicomm, + int initial_level) +{ + fclaw2d_domain_t* domain2d; + domain2d = fclaw2d_domain_new_torus(mpicomm, initial_level); + return fclaw_domain_wrap_2d(domain2d); +} + +fclaw_domain_t *fclaw_domain_new_2d_twosphere (sc_MPI_Comm mpicomm, + int initial_level) +{ + fclaw2d_domain_t* domain2d; + domain2d = fclaw2d_domain_new_twosphere(mpicomm, initial_level); + return fclaw_domain_wrap_2d(domain2d); +} + +fclaw_domain_t *fclaw_domain_new_2d_cubedsphere (sc_MPI_Comm mpicomm, + int initial_level) +{ + fclaw2d_domain_t* domain2d; + domain2d = fclaw2d_domain_new_cubedsphere(mpicomm, initial_level); + return fclaw_domain_wrap_2d(domain2d); +} + +fclaw_domain_t *fclaw_domain_new_2d_disk (sc_MPI_Comm mpicomm, + int periodic_in_x, + int periodic_in_y, + int initial_level) +{ + fclaw2d_domain_t* domain2d; + domain2d = fclaw2d_domain_new_disk(mpicomm, periodic_in_x, periodic_in_y, + initial_level); + return fclaw_domain_wrap_2d(domain2d); +} + +fclaw_domain_t *fclaw_domain_new_2d_brick (sc_MPI_Comm mpicomm, + int blocks_in_x, int blocks_in_y, + int periodic_in_x, + int periodic_in_y, + int initial_level) +{ + fclaw2d_domain_t* domain2d; + domain2d = fclaw2d_domain_new_brick(mpicomm, blocks_in_x, blocks_in_y, + periodic_in_x, periodic_in_y, + initial_level); + return fclaw_domain_wrap_2d(domain2d); +} + +fclaw_domain_t *fclaw_domain_new_unitcube (sc_MPI_Comm mpicomm, + int initial_level) +{ + fclaw3d_domain_t* domain3d; + domain3d = fclaw3d_domain_new_unitcube(mpicomm,initial_level); + return fclaw_domain_wrap_3d(domain3d); +} + +fclaw_domain_t *fclaw_domain_new_3d_brick (sc_MPI_Comm mpicomm, + int blocks_in_x, int blocks_in_y, + int blocks_in_z, + int periodic_in_x, + int periodic_in_y, + int periodic_in_z, + int initial_level) +{ + fclaw3d_domain_t* domain3d; + domain3d = fclaw3d_domain_new_brick(mpicomm, blocks_in_x, blocks_in_y, blocks_in_z, + periodic_in_x, periodic_in_y, periodic_in_z, + initial_level); + return fclaw_domain_wrap_3d(domain3d); +} + + +void fclaw_domain_destroy (fclaw_domain_t * domain) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_destroy(domain->d2); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_destroy(domain->d3); + } + else + { + SC_ABORT_NOT_REACHED (); + } + for(int blockno = 0; blockno < domain->num_blocks; ++blockno) + { + fclaw_block_t *block = &domain->blocks[blockno]; + FCLAW_FREE(block->patches); + } + FCLAW_FREE(domain->blocks); + FCLAW_FREE(domain->ghost_patches); + + FCLAW_FREE(domain); +} + +fclaw_domain_t* fclaw_domain_adapt (fclaw_domain_t * domain) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_t* new_domain = fclaw2d_domain_adapt(domain->d2); + return fclaw_domain_wrap_2d(new_domain); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_t* new_domain = fclaw3d_domain_adapt(domain->d3); + + return fclaw_domain_wrap_3d(new_domain); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +fclaw_domain_t* fclaw_domain_partition (fclaw_domain_t * domain, + int weight_exponent) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_t* new_domain; + new_domain = fclaw2d_domain_partition(domain->d2, weight_exponent); + + return fclaw_domain_wrap_2d(new_domain); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_t* new_domain; + new_domain = fclaw3d_domain_partition(domain->d3, weight_exponent); + + return fclaw_domain_wrap_3d(new_domain); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +void fclaw_domain_partition_unchanged (fclaw_domain_t * domain, + int *unchanged_first, + int *unchanged_length, + int *unchanged_old_first) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_partition_unchanged(domain->d2, + unchanged_first, + unchanged_length, + unchanged_old_first); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_partition_unchanged(domain->d3, + unchanged_first, + unchanged_length, + unchanged_old_first); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +void fclaw_domain_complete (fclaw_domain_t * domain) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_complete(domain->d2); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_complete(domain->d3); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +void fclaw_domain_write_vtk (fclaw_domain_t * domain, + const char *basename) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_write_vtk(domain->d2,basename); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_write_vtk(domain->d3,basename); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +void fclaw_domain_list_levels (fclaw_domain_t * domain, int log_priority) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_list_levels(domain->d2,log_priority); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_list_levels(domain->d3,log_priority); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +void fclaw_domain_list_neighbors (fclaw_domain_t * domain, int log_priority) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_list_neighbors(domain->d2,log_priority); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_list_neighbors(domain->d3,log_priority); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +void fclaw_domain_list_adapted (fclaw_domain_t * old_domain, + fclaw_domain_t * new_domain, + int log_priority) +{ + FCLAW_ASSERT(old_domain->refine_dim == new_domain->refine_dim); + if(old_domain->refine_dim == 2) + { + fclaw2d_domain_list_adapted(old_domain->d2,new_domain->d2,log_priority); + } + else if(old_domain->refine_dim == 3) + { + fclaw3d_domain_list_adapted(old_domain->d3,new_domain->d3,log_priority); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +void fclaw_domain_search_points (fclaw_domain_t * domain, + sc_array_t * block_offsets, + sc_array_t * coordinates, + sc_array_t * results) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_search_points(domain->d2,block_offsets,coordinates,results); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_search_points(domain->d3,block_offsets,coordinates,results); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +void fclaw_domain_integrate_rays (fclaw_domain_t * domain, + fclaw_integrate_ray_t intersect, + sc_array_t * rays, + sc_array_t * integrals, + void * user) +{ + fclaw_intersect_wrap_user_t wrap_user; + wrap_user.intersect = intersect; + wrap_user.user = user; + + if(domain->refine_dim == 2) + { + fclaw2d_domain_integrate_rays(domain->d2,fclaw2d_intersect_wrap_cb, + rays,integrals,&wrap_user); + } + else if(domain->refine_dim == 3) + { + fclaw3d_domain_integrate_rays(domain->d3,fclaw3d_intersect_wrap_cb, + rays,integrals,&wrap_user); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} + +void fclaw_overlap_exchange (fclaw_domain_t * domain, + sc_array_t * query_points, + fclaw_interpolate_point_t interpolate, + void *user) +{ + fclaw_interpolate_point_wrap_user_t wrap_user; + wrap_user.interpolate = interpolate; + wrap_user.user = user; + + if(domain->refine_dim == 2) + { + fclaw2d_overlap_exchange(domain->d2,query_points,fclaw2d_interpolate_point_wrap_cb,&wrap_user); + } + else if(domain->refine_dim == 3) + { + fclaw3d_overlap_exchange(domain->d3,query_points,fclaw3d_interpolate_point_wrap_cb,&wrap_user); + } + else + { + SC_ABORT_NOT_REACHED (); + } +} \ No newline at end of file diff --git a/src/fclaw_convenience.h b/src/fclaw_convenience.h new file mode 100644 index 000000000..ba30ef414 --- /dev/null +++ b/src/fclaw_convenience.h @@ -0,0 +1,369 @@ +/* +Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FCLAW_CONVENIENCE_H +#define FCLAW_CONVENIENCE_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} /* need this because indent is dumb */ +#endif +#endif + +fclaw_domain_t *fclaw_domain_new_unitsquare (sc_MPI_Comm mpicomm, + int initial_level); + +fclaw_domain_t *fclaw_domain_new_2d_torus (sc_MPI_Comm mpicomm, + int initial_level); + +fclaw_domain_t *fclaw_domain_new_2d_twosphere (sc_MPI_Comm mpicomm, + int initial_level); +fclaw_domain_t *fclaw_domain_new_2d_cubedsphere (sc_MPI_Comm mpicomm, + int initial_level); +fclaw_domain_t *fclaw_domain_new_2d_disk (sc_MPI_Comm mpicomm, + int periodic_in_x, + int periodic_in_y, + int initial_level); + +/** Create a brick connectivity, that is, a rectangular grid of blocks. + * The origin is in the lower-left corner of the brick. + * \param [in] mpicomm We expect sc_MPI_Init to be called earlier. + * \param [in] blocks_in_x Positive number of blocks in x direction. + * \param [in] blocks_in_y Positive number of blocks in y direction. + * \param [in] periodic_in_x True if the right side of the rightmost blocks + * connect periodically to the left side of the + * leftmost blocks. + * \param [in] periodic_in_y Periodicity along the vertical direction. + * \param [in] initial_level A non-negative integer <= P4EST_QMAXLEVEL. + * \return A fully initialized domain structure. + */ +fclaw_domain_t *fclaw_domain_new_2d_brick (sc_MPI_Comm mpicomm, + int blocks_in_x, int blocks_in_y, + int periodic_in_x, + int periodic_in_y, + int initial_level); + +fclaw_domain_t *fclaw_domain_new_unitcube (sc_MPI_Comm mpicomm, + int initial_level); + +/** Create a brick connectivity, that is, a rectangular grid of blocks. + * The origin is in the lower-left corner of the brick. + * \param [in] mpicomm We expect sc_MPI_Init to be called earlier. + * \param [in] blocks_in_x Positive number of blocks in x direction. + * \param [in] blocks_in_y Positive number of blocks in y direction. + * \param [in] periodic_in_x True if the right side of the rightmost blocks + * connect periodically to the left side of the + * leftmost blocks. + * \param [in] periodic_in_y Periodicity along the vertical direction. + * \param [in] initial_level A non-negative integer <= P4EST_QMAXLEVEL. + * \return A fully initialized domain structure. + */ +fclaw_domain_t *fclaw_domain_new_3d_brick (sc_MPI_Comm mpicomm, + int blocks_in_x, int blocks_in_y, + int blocks_in_z, + int periodic_in_x, + int periodic_in_y, + int periodic_in_z, + int initial_level); + +void fclaw_domain_destroy (fclaw_domain_t * domain); + +/** Create a new domain based on refine and coarsen marks set previously. + * All refine and coarsen markers are cancelled when this function is done. + * \param [in,out] domain Current domain with set adaptation markers. + * It stays alive because it is needed to + * project numerical values to the adapted domain. + * If adapted, no queries are allowed afterwards. + * \return Adapted domain if refinement occurred, or NULL. + * The return status is identical across all ranks. + */ +fclaw_domain_t *fclaw_domain_adapt (fclaw_domain_t * domain); + +/** Create a repartitioned domain after fclaw_domain_adapt returned non-NULL. + * All refine and coarsen markers are cancelled when this function is done. + * \param [in,out] domain Current domain that was adapted previously. + * It stays alive because it is needed to + * transfer numerical values to the new partition. + * If partitioned, no queries allowed afterwards. + * \param [in] weight_exponent The patches are weighted with an integer factor + * 2 ** (level * exponent). If the exponent is 0, + * all patches have equal weight. If it is 1, + * smaller patches are considered more expensive + * by a factor two per level increase. + * \return Partitioned domain if different, or NULL. + * The return status is identical across all ranks. + */ +fclaw_domain_t *fclaw_domain_partition (fclaw_domain_t * domain, + int weight_exponent); + +/** Query the window of patches that is not transferred on partition. + * \param [in] domain A domain after a non-trivial partition + * and before calling \ref fclaw_domain_complete. + * \param [out] unchanged_first First still-local patch in the new partition. + * \param [out] unchanged_length Number of patches that not changed owners. + * \param [out] unchanged_old_first First stayed_local patch in the old partition. + */ +void fclaw_domain_partition_unchanged (fclaw_domain_t * domain, + int *unchanged_first, + int *unchanged_length, + int *unchanged_old_first); + +/** Clean up after fclaw_domain_partition returned non-NULL. + * \param [in,out] domain Current domain that was partitioned. + */ +void fclaw_domain_complete (fclaw_domain_t * domain); + +/** Write VTK file(s) for a domain structure. + * Each patch is drawn as one rectangle. + * We ignore any geometric transformations. + * and use the vertex locations specified in the p4est's connectivity. + * \param [in] domain A valid domain structure. Is not changed. + * \param [in] basename Filename prefix passed to p4est_vtk functions. + */ +void fclaw_domain_write_vtk (fclaw_domain_t * domain, + const char *basename); + +/** Print patch number by level on all processors */ +void fclaw_domain_list_levels (fclaw_domain_t * domain, int log_priority); + +/** Print face neighbor status for each face */ +void fclaw_domain_list_neighbors (fclaw_domain_t * domain, + int log_priority); + +/** Print information on adapted patches */ +void fclaw_domain_list_adapted (fclaw_domain_t * old_domain, + fclaw_domain_t * new_domain, + int log_priority); + +/** Search tuples of (block number, x, y, (z for 3D) coordinates) in the mesh. + * The coordinates must be in [0, 1]^2 (or [0, 1]^3 for 3D domains) + * The input data must be equal on every process: This is a collective call. + * + * A point is found at most once even if it is on a patch boundary. + * We return the smallest patch number on the smallest processor touching it. + * However, if a point is on a block boundary, it must be decided before + * calling this function which tree shall be queried for it. + * + * \param [in] domain Must be valid domain structure. Will not be changed. + * \param [in] block_offsets Monotonous array of (num_blocks + 1) int variables. + * The points to search in block t in [0, num_blocks) + * have indices [block_offsets[t], block_offsets[t + 1]) + * in the \b coordinates and results arrays. + * \param [in] coordinates An array of elem_size == 2 * sizeof (double) with + * entries (x, y) in [0, 1]^2, or an array of + * elem_size == 3 * sizeof (double) with entries + * (x, y, z) in [0, 1]^3 for 3D domains. + * Of these entries, + * there are \b block_offsets[num_blocks] many. + * We do not enforce the coordinate ranges + * and simply do not find any point outside its block. + * \param [in,out] results On input, an array of type int and an element + * count of \b block_offsets[num_blocks]. + * The data in \b results is ignored on input. + * On output, an entry will be -1 if the point has + * not been found on this process, or the patch + * number within its block otherwise. + */ +void fclaw_domain_search_points (fclaw_domain_t * domain, + sc_array_t * block_offsets, + sc_array_t * coordinates, + sc_array_t * results); + +/** Callback function to compute the integral of a "ray" within a patch. + * + * This function can be passed to \ref fclaw_domain_integrate_rays to + * eventually compute the integrals over the whole domain for an array of rays. + * + * \param [in] domain The domain to integrate on. + * \param [in] patch The patch under consideration. + * When on a leaf, this is a valid forestclaw patch. + * Otherwise, this is a temporary artificial patch + * containing all standard patch information except + * for the pointer to the next patch and user-data. + * Only the FCLAW2D_PATCH_CHILDID and the + * FCLAW2D_PATCH_ON_BLOCK_FACE_* flags are set. + * Artificial patches are generally ancestors of + * valid forestclaw patches that are leaves. + * \param [in] blockno The block id of the patch under consideration. + * \param [in] patchno When on a leaf, this is a valid patch number, + * as always relative to its block. For a leaf, + * this callback must set the integral value to + * the local contribution of this patch and ray. + * Otherwise, patchno is -1. In this case, the + * integral value is ignored. + * \param [in] ray Representation of a "ray"; user-defined. + * Points to an array element of the rays passed + * to \ref fclaw_domain_integrate_rays. + * \param [in,out] integral The integral value associated with the ray. + * On input this is 0. + * For leaves this callback must set it to the + * exact integral contribution for this patch and + * ray. + * \param [in,out] user Arbitrary data passed in earlier. + * \return True if there is a possible/partial intersection of the + * patch (which may be an ancestor) with the ray. + * This may be a false positive; we'll be fine. + * Return false if there is definitely no intersection. + * Only for leaves, this function must compute + * the exact integral contribution for this + * patch by intersecting this ray and store it in + * the \a integral output argument. + * The integral value may well be 0. if the intersection + * is, in fact, none (a false positive). + */ +typedef int (*fclaw_integrate_ray_t) (fclaw_domain_t * domain, + fclaw_patch_t * patch, + int blockno, int patchno, + void *ray, double *integral, + void *user); + +/** Compute the integrals of an array of user-defined rays. + * The integral for each ray and intersection quadrant is supplied by a callback. + * We store the results in an array of integral values of type double. + * + * \param [in] domain The domain to integrate on. + * \param [in] intersect Callback function that returns true if a ray + * intersects a patch and -- when called for a leaf + * -- shall output the integral of the ray segment. + * \param [in] rays Array containing the rays of user-defined type. + * Each entry contains one item of arbitrary data. + * We do not dereference, just pass pointers around. + * \param [in,out] integrals Array of double variables. The number of entries + * must equal the number of rays. Input values ignored. + * On output, we provide the final integral values. + * \param [in,out] user Arbitrary data to be passed to the callback. + */ +void fclaw_domain_integrate_rays (fclaw_domain_t * domain, + fclaw_integrate_ray_t intersect, + sc_array_t * rays, + sc_array_t * integrals, + void * user); + +/** Callback function to compute the interpolation data for a point and a patch. + * + * This function can be passed to \ref fclaw_overlap_exchange to eventually + * compute the interpolation data over the whole producer domain for an + * array of points. + * It will be called both in a partition search and a local search of the + * producer domain. Use \ref fclaw_domain_is_meta, to determine which is the + * case. + * + * \param [in] domain The domain we interpolate on. + * On the producer side, this is a valid forestclaw + * domain. + * On the consumer side, this is a temporary + * artifical domain. Only the mpi-information + * (mpicomm, mpisize and mpirank) as well as the + * backend data (pp, pp_owned and attributes) are + * set. The backend data is not owned and shall + * not be changed by the callback. The mpirank is + * set to a valid rank only when we are at a leaf + * (a patch that belongs to exactly one process) + * of the partition search, else it will be -1. + * \param [in] patch The patch under consideration. + * When on a leaf on the producer side, this is a + * valid patch from the producer domain. + * Otherwise, this is a temporary artificial patch + * containing all standard patch information except + * for the pointer to the next patch and user-data. + * Only the FCLAW2D_PATCH_CHILDID and the + * FCLAW2D_PATCH_ON_BLOCK_FACE_* flags are set. + * Artificial patches are generally ancestors of + * valid forestclaw patches that are leaves. + * \param [in] blockno The block id of the patch under consideration. + * \param [in] patchno If patchno is -1, we are on an artifical patch. + * Otherwise, this is a valid patchno from the + * producer domain. + * \param [in,out] point Representation of a point; user-defined. + * Points to an array element of the query points + * passed to \ref fclaw_overlap_exchange. + * If patchno is non-negative, the points + * interpolation data should be updated by the + * local patch's contribution. + * \param [in, out] user Arbitrary data passed in earlier. + * \return True, if there is a possible contribution of the + * patch or one of its ancestors to the point + * interpolation data. + * Return false if there is definitely no + * contribution. + * If we are on a leaf on the producer side + * (patchno is non-negative) or the consumer side + * (domain_is_meta and mpirank is non-negative) + * this callback should do an exact test for + * contribution. + * Else, the return value may be a false positive, + * we'll be fine. + */ +typedef int (*fclaw_interpolate_point_t) (fclaw_domain_t * domain, + fclaw_patch_t * patch, + int blockno, int patchno, + void *point, void *user); + +/** Exchange interpolation data of query points between two domains. + * + * We compute the user-defined interpolation data of an array of user-defined + * query points, which originate from the so-called consumer side. + * The interpolation data will be computed on the domain of the so-called + * producer-side based on a \ref fclaw_interpolate_point_t callback function. + * Afterwards, the results will be collected and combined on the consumer side. + * + * \param [in] domain The producer domain to interpolate on. + * \param [in,out] query_points Array containing points of user-defined type. + * Each entry contains one item of arbitrary data. + * We do not dereference, just pass pointers around. + * The points will be sent via MPI, so they may not + * contain pointers to further data. + * The array is defined processor-local and may + * contain different points on different processes. + * The query points are supposed to be computed + * (and transformed to the producer space by an + * inverse mapping) locally on the consumer side. + * On output, the points will contain collected + * interpolation data according to \b interpolate. + * \param [in] interpolate Callback function that returns true if a point + * intersects a patch and -- when called for a leaf + * on the producer side -- shall write the + * interpolation data for the current + * point-patch-combination into the user-defined + * point structure. + * \param [in,out] user Arbitrary data to be passed to the callback. + */ +void fclaw_overlap_exchange (fclaw_domain_t * domain, + sc_array_t * query_points, + fclaw_interpolate_point_t interpolate, + void *user); + +#ifdef __cplusplus +#if 0 +{ /* need this because indent is dumb */ +#endif +} +#endif + +#endif /* !FCLAW_CONVENIENCE_H */ diff --git a/src/fclaw_corner_neighbors.c b/src/fclaw_corner_neighbors.c new file mode 100644 index 000000000..f127efedb --- /dev/null +++ b/src/fclaw_corner_neighbors.c @@ -0,0 +1,654 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include + + + +static +int get_num_intersections(int dim,int intersects[], int faces[]) +{ + int num_intersections = 0; + for (int i = 0; i < dim; i++) + { + if (intersects[faces[i]]) + { + num_intersections++; + } + } + return num_intersections; +} + +static +int find_face(int dim, int intersects[], int faces[]) +{ + for (int i = 0; i < dim; i++) + { + if (intersects[faces[i]]) + { + return faces[i]; + } + } + return -1; +} + +static +int find_edge(int corner, int intersects[], int faces[]) +{ + int non_intersecting_face = -1; + for (int i = 0; i < 3; i++) + { + if (!intersects[faces[i]]) + { + non_intersecting_face = faces[i]; + break; + } + } + FCLAW_ASSERT(non_intersecting_face >= 0); + int edge_axis = non_intersecting_face / 2; + int face_0; + int face_1; + switch(edge_axis) + { + case 0: + face_0 = faces[1]; + face_1 = faces[2]; + break; + case 1: + face_0 = faces[0]; + face_1 = faces[2]; + break; + case 2: + face_0 = faces[0]; + face_1 = faces[1]; + break; + } + FCLAW_ASSERT(face_0 != non_intersecting_face); + FCLAW_ASSERT(face_1 != non_intersecting_face); + + int upper_0 = face_0 % 2; + int upper_1 = face_1 % 2; + + int edge = 4*edge_axis + 2*upper_1 + upper_0; + + FCLAW_ASSERT(edge >= 0 && edge < 12); + + return edge; +} + +/** + * @brief Get the corner type for a patch + * + * @param glob the global context + * @param icorner the corner to get the cornertype on + * @param intersects_bdry Size 4 for 2D, 6 for 3D. True if patch intersects a boundary on a face + * @param intersects_block Size 4 for 2D, 6 for 3D. True if patch intersects a block boundary on a face + * @param interior_corner Returns true if the corner is interior to a block + * @param ftransform The ftransform object to fill in + * This will fill in the is_block_corner, is_block_edge, is_block_face, block_iface, block_iedge, and block_iface fields. + * @param ftransform_fine The ftransform object to fill in + * This will fill in the is_block_corner, is_block_edge, and is_block_face fields. + * block_iface and block_iedge will be initialized to -1. + */ +static +void get_corner_type(fclaw_global_t* glob, + int icorner, + int intersects_bdry[], + int intersects_block[], + int *is_interior_in_domain, + fclaw_patch_transform_data_t* tdata, + fclaw_patch_transform_data_t* tdata_finegrid) +{ + fclaw_domain_t *domain = glob->domain; + + tdata->icorner = icorner; + tdata->iedge = -1; + tdata->iface = -1; + + // p4est has tons of lookup table like this, can be exposed similarly + int corner_faces[domain->refine_dim]; + fclaw_domain_corner_faces(domain, icorner, corner_faces); + + /* Both faces are at a physical boundary */ + int num_phys_faces = get_num_intersections(domain->refine_dim, + intersects_bdry, + corner_faces); + + /* Either a corner is at a block boundary (but not a physical boundary), + or internal to a block. L-shaped domains are excluded for now + (i.e. no reentrant corners). */ + *is_interior_in_domain = num_phys_faces == 0; + + int num_block_faces = get_num_intersections(domain->refine_dim, + intersects_block, + corner_faces); + /* Both faces are at a block boundary, physical or not */ + tdata->is_block_corner = num_block_faces == domain->refine_dim; + + if(domain->refine_dim == 2) + { + tdata->is_block_edge = 0; + tdata->block_iedge = -1; + } + else + { + tdata->is_block_edge = num_block_faces == 2; + tdata->block_iedge = -1; + if(tdata->is_block_edge) + { + tdata->block_iedge = find_edge(icorner, intersects_block, corner_faces); + } + } + + tdata->is_block_face = num_block_faces == 1; + tdata->block_iface = -1; + if (num_block_faces == 1) + { + tdata->block_iface = find_face(domain->refine_dim, intersects_block, corner_faces); + } + + tdata_finegrid->is_block_corner = tdata->is_block_corner; + tdata_finegrid->is_block_edge = tdata->is_block_edge; + tdata_finegrid->is_block_face = tdata->is_block_face; + + tdata_finegrid->block_iface = -1; + tdata_finegrid->block_iedge = -1; +} + +/* -------------------------------------------------------- + Four cases to consider. The 'has_corner_neighbor' + value is returned from p4est. The assumption going + into this routine is that we have found a valid + interior corner (not a corner on a physical boundary). + The corner than satisfies one of the following four + cases. + + Case No. | has_corner_neighbor | block_boundary_type + -------------------------------------------------------- + 1 | T | is_block_corner + 2 | T | is_block_edge + 3 | T | is_block_face + 4 | T | interior + 2 | F | F + 3 | T | F + 4 | F | T + + Case 1-2 : In this case, 4 or more patches meet at a + corner. No transforms are yet available, so we + assume that at block corners, the patches all + have the same orientation. + Case 3 : Corner is either is on block face. + The transform is well-defined. + Case 4 : Corner is either interior to a block. + The transform is well-defined. + Case 2 : Corner is at a hanging node and has no valid + adjacent corner. + Case 4 : Either 3 patches meet at a corner, in which + case we don't have an adjacent corner, or we are + on a pillow grid, in which case we have a + corner, but one which we nonetheless treat + as a special case. + ------------------------------------------------------ */ + +static +void get_corner_neighbor(fclaw_global_t *glob, + int icorner, + int *is_valid_neighbor, + int *block_corner_count, + fclaw_patch_transform_data_t* tdata, + fclaw_patch_transform_data_t* tdata_fine) +{ + fclaw_domain_t *domain = glob->domain; + /* assume neighbor is valid for now*/ + *is_valid_neighbor = 1; + /* See what p4est thinks we have for corners, and consider four cases */ + int rproc_corner; + + /* Note : Pillowsphere case does not return a block corner neighbor */ + int ispillowsphere = 0; + if(domain->refine_dim == 2) + { + ispillowsphere = FCLAW_MAP_IS_PILLOWSPHERE(&glob->cont); + } + + fclaw_timer_start (&glob->timers[FCLAW_TIMER_NEIGHBOR_SEARCH]); + int has_corner_neighbor = + fclaw_patch_corner_neighbors(domain, + tdata->this_blockno, + tdata->this_patchno, + icorner, + &rproc_corner, + &tdata->neighbor_blockno, + &tdata->neighbor_patchno, + &tdata_fine->icorner, + &tdata->neighbor_type); + + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_NEIGHBOR_SEARCH]); + + *block_corner_count = 0; /* Assume we are not at a block corner */ + if (has_corner_neighbor && tdata->is_block_corner) + { + /* Case 1 : 4 or more patches meet at a block corner. + This case does NOT include the pillowgrid. */ + *block_corner_count = 4; /* assume four for now */ + + /* No block corner transforms yet, so we use the + interior 'default' transforms. */ + fclaw_patch_transform_blockface_intra (glob, tdata->transform); + fclaw_patch_transform_blockface_intra + (glob, tdata_fine->transform); + } + else if (has_corner_neighbor && tdata->is_block_edge) + { + FCLAW_ASSERT(domain->refine_dim == 3); + /* The corner is on a block face (but is not a block corner). + Compute a transform between blocks. First, get the + remote face number. The remote face number encodes the + orientation, so we have 0 <= rfaceno < 8 */ + + //int rfaceno; + //int rproc[2]; + //int rpatchno[2]; + //int rblockno; /* Should equal *corner_block_idx, above. */ + //fclaw_patch_edge_neighbors(domain, + // tdata->this_blockno, + // tdata->this_patchno, + // tdata->block_iface, + // rproc, + // &rblockno, + // rpatchno, + // &rfaceno); + + //FCLAW_ASSERT(rblockno == tdata->neighbor_blockno); + + ///* Get encoding of transforming a neighbor coordinate across a face */ + //fclaw_patch_transform_blockface (glob, tdata->block_iface, rfaceno, tdata->transform); + fclaw_patch_transform_blockface_intra(glob, tdata->transform); + + /* Get transform needed to swap parallel ghost patch with fine + grid on-proc patch. This is done so that averaging and + interpolation routines can be re-used. */ + //int iface1 = tdata->block_iface; + //int rface1 = rfaceno; + //fclaw_patch_face_swap(domain->refine_dim, &iface1, &rface1); + //TODO edge transforms + fclaw_patch_transform_blockface_intra(glob, tdata_fine->transform); + + //TODO update this for rotation + tdata_fine->block_iedge = tdata->block_iedge ^ 3; + } + else if (has_corner_neighbor && tdata->is_block_face) + { + /* The corner is on a block face (but is not a block corner). + Compute a transform between blocks. First, get the + remote face number. The remote face number encodes the + orientation, so we have 0 <= rfaceno < 8 */ + + int rfaceno; + int rproc[4]; // overallocate for 3d + int rpatchno[4]; + int rblockno; /* Should equal *corner_block_idx, above. */ + fclaw_patch_face_neighbors(domain, + tdata->this_blockno, + tdata->this_patchno, + tdata->block_iface, + rproc, + &rblockno, + rpatchno, + &rfaceno); + + FCLAW_ASSERT(rblockno == tdata->neighbor_blockno); + + /* Get encoding of transforming a neighbor coordinate across a face */ + fclaw_patch_transform_blockface (glob, tdata->block_iface, rfaceno, tdata->transform); + + /* Get transform needed to swap parallel ghost patch with fine + grid on-proc patch. This is done so that averaging and + interpolation routines can be re-used. */ + int iface1 = tdata->block_iface; + int rface1 = rfaceno; + fclaw_patch_face_swap(domain->refine_dim, &iface1, &rface1); + fclaw_patch_transform_blockface(glob, iface1, rface1, + tdata_fine->transform); + + tdata_fine->block_iface = iface1; + } + else if (has_corner_neighbor && !tdata->is_block_corner) + { + /* Case 4 : 'icorner' is an interior corner, + or we are on a periodic single block. Need to return a valid + transform in 'ftransform' */ + if (tdata->this_blockno == tdata->neighbor_blockno) + { + /* Both patches are in the same block, so we set the transform to + a default transform. This could be the case for periodic boundaries. */ + *block_corner_count = 4; /* assume four for now */ + fclaw_patch_transform_blockface_intra (glob, tdata->transform); + fclaw_patch_transform_blockface_intra + (glob, tdata_fine->transform); + + } + else + { + fclaw_errorf("WARNING : this_block_idx = %d\n",tdata->this_blockno); + fclaw_errorf("WARNING : corner_block_idx = %d\n",tdata->neighbor_blockno); + fclaw_abortf("get_corner_neighbors " \ + "(fclaw2d_corner_neighbors.c : " \ + "We should not be here\n"); + } + } + else if (!has_corner_neighbor && tdata->is_block_corner) + { + /* Case 4 : In 2d: Pillow sphere case or cubed sphere + In 3D: not yet supported */ + if(domain->refine_dim == 3) + { + *block_corner_count = 0; + *is_valid_neighbor = 0; + return; + } + + if (!ispillowsphere) + { + *block_corner_count = 3; + /* Exactly 3 patches meet at a corner, e.g. the cubed sphere. + In this case, 'this_patch' has no corner-adjacent only + neighbors, and so there is nothing to do. */ + *is_valid_neighbor = 0; + return; + } + else + { + /* return face neighbor as corner neighbor */ + *block_corner_count = 2; + has_corner_neighbor = 1; + int rpatchno[4]; // overallocate for 3d + int rproc[4]; + int rfaceno; + + /* Use only faces 0 or 1 to get block data. */ + int iface = icorner % 2; + tdata->neighbor_type = + fclaw_patch_face_neighbors(domain, + tdata->this_blockno, + tdata->this_patchno, + iface, + rproc, + &tdata->neighbor_blockno, + rpatchno, + &rfaceno); + + int igrid; + if (tdata->neighbor_type == FCLAW_PATCH_HALFSIZE) + { + /* igrid = 0 at corners 0,1 and (R-1) at corners 2,3, + where R = refinement factor */ + igrid = (icorner/2)*(2 - 1); + } + else + { + /* Same size or double size grids. */ + igrid = 0; + } + + tdata_fine->icorner = icorner; /* This wasn't being set! */ + tdata->neighbor_patchno = rpatchno[igrid]; + rproc_corner = rproc[igrid]; + } + } + else if (!has_corner_neighbor) + { + /* 'icorner' is a hanging node or not yet supported */ + /* We do not return valid transformation objects! */ + *is_valid_neighbor = 0; + return; + } + + /* --------------------------------------------------------------------- + We have a valid neighbor and possibly a transform. We just now need + to get a pointer to the neighbor patch (which may be a parallel patch) + and the relative level (-1,0,1). + --------------------------------------------------------------------- */ + + if (domain->mpirank != rproc_corner) + { + tdata->neighbor_patch = &domain->ghost_patches[tdata->neighbor_patchno]; + } + else + { + fclaw_block_t *neighbor_block = &domain->blocks[tdata->neighbor_blockno]; + tdata->neighbor_patch = &neighbor_block->patches[tdata->neighbor_patchno]; + } + + + + // set neighbor information in tdata_finegrid + tdata_fine->this_patch = tdata->neighbor_patch; + tdata_fine->this_blockno = tdata->neighbor_blockno; + tdata_fine->this_patchno = tdata->neighbor_patchno; + + if (tdata->neighbor_type == FCLAW_PATCH_HALFSIZE) + { + tdata_fine->neighbor_type = FCLAW_PATCH_DOUBLESIZE; + } + else if (tdata->neighbor_type == FCLAW_PATCH_SAMESIZE) + { + tdata_fine->neighbor_type = FCLAW_PATCH_SAMESIZE; + } + else /* FCLAW2D_PATCH_DOUBLESIZE */ + { + tdata_fine->neighbor_type = FCLAW_PATCH_HALFSIZE; + } +} + + + +void fclaw_corner_fill_cb(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, + int this_blockno, + int this_patchno, + void *user) +{ + const int num_faces = fclaw_domain_num_faces(domain); + const int num_corners = fclaw_domain_num_corners(domain); + + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + + fclaw_exchange_info_t *filltype = (fclaw_exchange_info_t*) s->user; + int time_interp = filltype->time_interp; + int is_coarse = filltype->grid_type == FCLAW_IS_COARSE; + int is_fine = filltype->grid_type == FCLAW_IS_FINE; + + int read_parallel_patches = filltype->read_parallel_patches; + + int copy_from_neighbor = filltype->exchange_type == FCLAW_COPY; + int average_from_neighbor = filltype->exchange_type == FCLAW_AVERAGE; + int interpolate_to_neighbor = filltype->exchange_type == FCLAW_INTERPOLATE; + + + int intersects_bdry[num_faces]; + fclaw_physical_get_bc(s->glob,this_blockno,this_patchno, + intersects_bdry); + + int intersects_block[num_faces]; + fclaw_block_get_block_boundary(s->glob, this_patch, intersects_block); + + /* Transform data needed at multi-block boundaries */ + fclaw_patch_transform_data_t tdata; + + tdata.glob = s->glob; + tdata.based = 1; // cell-centered data in this routine. + tdata.this_patch = this_patch; + tdata.this_blockno = this_blockno; + tdata.this_patchno = this_patchno; + tdata.neighbor_patch = NULL; // gets filled in below. + + fclaw_patch_transform_init_data(s->glob,this_patch, + this_blockno, + this_patchno, + &tdata); + + + fclaw_patch_transform_data_t tdata_fine; + + tdata_fine.glob = s->glob; + tdata_fine.neighbor_patch = this_patch; + tdata_fine.neighbor_blockno = this_blockno; + tdata_fine.neighbor_patchno = this_patchno; + tdata_fine.based = 1; // cell-centered data in this routine. + + fclaw_patch_transform_init_data(s->glob,this_patch, + this_blockno, + this_patchno, + &tdata_fine); + + + for (int icorner = 0; icorner < num_corners; icorner++) + { + int block_corner_count = 0; + // get corner type and initialize is_block_* values in transform_data and transform_data_finegrid + // block_i* values will be initialized for transform_data + // block_i* values will be initialized to -1 for transform_data_finegrid + int is_interior_in_domain; + get_corner_type(s->glob,icorner, + intersects_bdry, + intersects_block, + &is_interior_in_domain, + &tdata, + &tdata_fine); + + /* Sets block_corner_count to 0 */ + fclaw_patch_set_block_corner_count(s->glob, this_patch, + icorner,block_corner_count); + + if (is_interior_in_domain) + { + /* Is an interior patch corner; may also be a block corner */ + + int is_valid_neighbor; + + get_corner_neighbor(s->glob, + icorner, + &is_valid_neighbor, + &block_corner_count, + &tdata, + &tdata_fine); + + /* This sets value in block_corner_count_array */ + fclaw_patch_set_block_corner_count(s->glob, this_patch, + icorner,block_corner_count); + + + if (!is_valid_neighbor) + { + /* No corner neighbor. Either : + -- Hanging node + -- Cubed sphere + */ + continue; + } + + int remote_neighbor = fclaw_patch_is_ghost(tdata.neighbor_patch); + if (is_coarse && ((read_parallel_patches && remote_neighbor) || !remote_neighbor)) + { + if (tdata.neighbor_type == FCLAW_PATCH_HALFSIZE) + { + if (interpolate_to_neighbor && !remote_neighbor) + { + /* No need to interpolate to remote ghost patches. */ + fclaw_patch_interpolate_corner(s->glob, + tdata.this_patch, + tdata.neighbor_patch, + tdata.this_blockno, + tdata.neighbor_blockno, + tdata.is_block_corner, + tdata.icorner, + time_interp, + &tdata); + } + else if (average_from_neighbor) + { + /* Average even if neighbor is a remote neighbor */ + fclaw_patch_average_corner(s->glob, + tdata.this_patch, + tdata.neighbor_patch, + tdata.this_blockno, + tdata.neighbor_blockno, + tdata.is_block_corner, + tdata.icorner, + time_interp, + &tdata); + } + } + else if (tdata.neighbor_type == FCLAW_PATCH_SAMESIZE && copy_from_neighbor) + { + fclaw_patch_copy_corner(s->glob, + tdata.this_patch, + tdata.neighbor_patch, + tdata.this_blockno, + tdata.neighbor_blockno, + tdata.is_block_corner, + tdata.icorner, + time_interp, + &tdata); + } + + } /* End of non-parallel patch case */ + else if (is_fine && tdata.neighbor_type == FCLAW_PATCH_DOUBLESIZE && + remote_neighbor && read_parallel_patches) + { + /* The coarse grid is now the remote patch; swap contexts and + call same routines above, but with remote patch as the "coarse" + grid */ + + if (interpolate_to_neighbor) + { + /* Interpolate from remote coarse grid patch (coarse grid) to + local fine grid patch. We do not need to average to the + remote patch corners unless corners are used in the + interpolation stencil. */ + fclaw_patch_interpolate_corner(s->glob, + tdata_fine.this_patch, + tdata_fine.neighbor_patch, + tdata_fine.this_blockno, + tdata_fine.neighbor_blockno, + tdata_fine.is_block_corner, + tdata_fine.icorner, + time_interp, + &tdata_fine); + + } + } /* End of parallel case */ + } /* End of 'interior_corner' */ + } /* End of icorner loop */ +} diff --git a/src/fclaw_corner_neighbors.h b/src/fclaw_corner_neighbors.h new file mode 100644 index 000000000..fc0a56119 --- /dev/null +++ b/src/fclaw_corner_neighbors.h @@ -0,0 +1,57 @@ +/* +Copyright (c) 2012 Carsten Burstedde, Donna Calhoun +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FCLAW_CORNER_NEIGHBORS_H +#define FCLAW_CORNER_NEIGHBORS_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} +#endif +#endif + +struct fclaw_global; +struct fclaw_domain; +struct fclaw_patch; + + +void fclaw_corner_fill_cb(struct fclaw_domain *domain, + struct fclaw_patch *this_patch, + int this_block_idx, + int this_patch_idx, + void *user); + +#ifdef __cplusplus +#if 0 +{ +#endif +} +#endif + +#endif diff --git a/src/fclaw2d_diagnostics.c b/src/fclaw_diagnostics.c similarity index 74% rename from src/fclaw2d_diagnostics.c rename to src/fclaw_diagnostics.c index 34d764035..9b9c3dd21 100644 --- a/src/fclaw2d_diagnostics.c +++ b/src/fclaw_diagnostics.c @@ -23,19 +23,19 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include -#include -#include +#include +#include +#include #include #include static -fclaw2d_diagnostics_vtable_t* diagnostics_vt_new() +fclaw_diagnostics_vtable_t* diagnostics_vt_new() { - return (fclaw2d_diagnostics_vtable_t*) FCLAW_ALLOC_ZERO (fclaw2d_diagnostics_vtable_t, 1); + return (fclaw_diagnostics_vtable_t*) FCLAW_ALLOC_ZERO (fclaw_diagnostics_vtable_t, 1); } static @@ -48,9 +48,9 @@ void diagnostics_vt_destroy(void* vt) Public interface ------------------------------------------------ */ -fclaw2d_diagnostics_vtable_t* fclaw2d_diagnostics_vt(fclaw2d_global_t* glob) +fclaw_diagnostics_vtable_t* fclaw_diagnostics_vt(fclaw_global_t* glob) { - fclaw2d_diagnostics_vtable_t* diagnostics_vt = (fclaw2d_diagnostics_vtable_t*) + fclaw_diagnostics_vtable_t* diagnostics_vt = (fclaw_diagnostics_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fclaw2d_diagnostics"); FCLAW_ASSERT(diagnostics_vt != NULL); FCLAW_ASSERT(diagnostics_vt->is_set != 0); @@ -58,12 +58,12 @@ fclaw2d_diagnostics_vtable_t* fclaw2d_diagnostics_vt(fclaw2d_global_t* glob) } /* global_maximum is in forestclaw2d.c */ -double fclaw2d_domain_global_minimum (fclaw2d_domain_t* domain, double d) +double fclaw_domain_global_minimum (fclaw_domain_t* domain, double d) { double neg_d; double maxvalue; neg_d = -d; - maxvalue = fclaw2d_domain_global_maximum(domain,neg_d); + maxvalue = fclaw_domain_global_maximum(domain,neg_d); return -maxvalue; } @@ -75,10 +75,10 @@ double fclaw2d_domain_global_minimum (fclaw2d_domain_t* domain, double d) Note that the check for whether the user has specified diagnostics to run is done here, not in fclaw2d_run.cpp ---------------------------------------------------------------- */ -void fclaw2d_diagnostics_vtable_initialize(fclaw2d_global_t* glob) +void fclaw_diagnostics_vtable_initialize(fclaw_global_t* glob) { - fclaw2d_diagnostics_vtable_t *diag_vt = diagnostics_vt_new(); + fclaw_diagnostics_vtable_t *diag_vt = diagnostics_vt_new(); /* Function pointers all set to zero, since diag_vt has static storage */ @@ -89,12 +89,12 @@ void fclaw2d_diagnostics_vtable_initialize(fclaw2d_global_t* glob) } -void fclaw2d_diagnostics_initialize(fclaw2d_global_t *glob) +void fclaw_diagnostics_initialize(fclaw_global_t *glob) { - fclaw2d_diagnostics_vtable_t *diag_vt = fclaw2d_diagnostics_vt(glob); + fclaw_diagnostics_vtable_t *diag_vt = fclaw_diagnostics_vt(glob); - fclaw2d_diagnostics_accumulator_t *acc = glob->acc; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_diagnostics_accumulator_t *acc = glob->acc; + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); /* Return an error accumulator */ if (diag_vt->patch_init_diagnostics != NULL) @@ -119,17 +119,17 @@ void fclaw2d_diagnostics_initialize(fclaw2d_global_t *glob) /* Collect statistics in the accumulator */ -void fclaw2d_diagnostics_gather(fclaw2d_global_t *glob, +void fclaw_diagnostics_gather(fclaw_global_t *glob, int init_flag) { - fclaw2d_diagnostics_accumulator_t *acc = glob->acc; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - fclaw2d_diagnostics_vtable_t *diag_vt = fclaw2d_diagnostics_vt(glob); + fclaw_diagnostics_accumulator_t *acc = glob->acc; + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + fclaw_diagnostics_vtable_t *diag_vt = fclaw_diagnostics_vt(glob); /* ----------------------------------------------------- Compute diagnostics on all local patches ----------------------------------------------------- */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_DIAGNOSTICS]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_DIAGNOSTICS]); /* Patch diagnostics */ @@ -152,13 +152,13 @@ void fclaw2d_diagnostics_gather(fclaw2d_global_t *glob, if (fclaw_opt->run_user_diagnostics != 0 && diag_vt->user_compute_diagnostics != NULL) diag_vt->user_compute_diagnostics(glob,acc->user_accumulator); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_DIAGNOSTICS]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_DIAGNOSTICS]); /* --------------------------------------------------------- Gather all of the statistics (requires communication) --------------------------------------------------------- */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_DIAGNOSTICS_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_DIAGNOSTICS_COMM]); if (diag_vt->patch_gather_diagnostics != NULL) diag_vt->patch_gather_diagnostics(glob,acc->patch_accumulator,init_flag); @@ -175,18 +175,18 @@ void fclaw2d_diagnostics_gather(fclaw2d_global_t *glob, if (fclaw_opt->run_user_diagnostics != 0 && diag_vt->user_gather_diagnostics != NULL) diag_vt->user_gather_diagnostics(glob,acc->user_accumulator,init_flag); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_DIAGNOSTICS_COMM]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_DIAGNOSTICS_COMM]); - fclaw2d_diagnostics_reset(glob); + fclaw_diagnostics_reset(glob); } -void fclaw2d_diagnostics_reset(fclaw2d_global_t *glob) +void fclaw_diagnostics_reset(fclaw_global_t *glob) { - fclaw2d_diagnostics_accumulator_t *acc = glob->acc; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - fclaw2d_diagnostics_vtable_t *diag_vt = fclaw2d_diagnostics_vt(glob); + fclaw_diagnostics_accumulator_t *acc = glob->acc; + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + fclaw_diagnostics_vtable_t *diag_vt = fclaw_diagnostics_vt(glob); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_DIAGNOSTICS]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_DIAGNOSTICS]); if (diag_vt->patch_reset_diagnostics != NULL) diag_vt->patch_reset_diagnostics(glob,acc->patch_accumulator); @@ -203,16 +203,16 @@ void fclaw2d_diagnostics_reset(fclaw2d_global_t *glob) if (fclaw_opt->run_user_diagnostics != 0 && diag_vt->user_reset_diagnostics != NULL) diag_vt->user_reset_diagnostics(glob,acc->user_accumulator); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_DIAGNOSTICS]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_DIAGNOSTICS]); } -void fclaw2d_diagnostics_finalize(fclaw2d_global_t *glob) +void fclaw_diagnostics_finalize(fclaw_global_t *glob) { - fclaw2d_diagnostics_accumulator_t *acc = glob->acc; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - fclaw2d_diagnostics_vtable_t *diag_vt = fclaw2d_diagnostics_vt(glob); + fclaw_diagnostics_accumulator_t *acc = glob->acc; + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + fclaw_diagnostics_vtable_t *diag_vt = fclaw_diagnostics_vt(glob); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_DIAGNOSTICS]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_DIAGNOSTICS]); if (diag_vt->patch_finalize_diagnostics != NULL) diag_vt->patch_finalize_diagnostics(glob,&acc->patch_accumulator); @@ -229,6 +229,6 @@ void fclaw2d_diagnostics_finalize(fclaw2d_global_t *glob) if (fclaw_opt->run_user_diagnostics != 0 && diag_vt->user_finalize_diagnostics != NULL) diag_vt->user_finalize_diagnostics(glob,&acc->user_accumulator); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_DIAGNOSTICS]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_DIAGNOSTICS]); } diff --git a/src/fclaw_diagnostics.h b/src/fclaw_diagnostics.h new file mode 100644 index 000000000..b49fa9468 --- /dev/null +++ b/src/fclaw_diagnostics.h @@ -0,0 +1,125 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FCLAW_DIAGNOSTICS_H +#define FCLAW_DIAGNOSTICS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +struct fclaw_global; +struct fclaw_domain; + +typedef struct fclaw_diagnostics_vtable fclaw_diagnostics_vtable_t; + +typedef struct fclaw_diagnostics_accumulator fclaw_diagnostics_accumulator_t; + +struct fclaw_diagnostics_accumulator +{ + void* patch_accumulator; + void* solver_accumulator; + void* user_accumulator; + void* gauge_accumulator; + void* ray_accumulator; +}; + +/* Diagnostic information */ +typedef void (*fclaw_diagnostics_initialize_t)(struct fclaw_global *glob, + void** acc); + +typedef void (*fclaw_diagnostics_compute_t)(struct fclaw_global *glob, + void* acc); + +typedef void (*fclaw_diagnostics_gather_t)(struct fclaw_global *glob, + void* acc, + int init_flag); + +typedef void (*fclaw_diagnostics_reset_t)(struct fclaw_global *glob, + void* acc); + +typedef void (*fclaw_diagnostics_finalize_t)(struct fclaw_global *glob, + void** acc); + +struct fclaw_diagnostics_vtable +{ + /* patch diagnostic functions (error, conservation, area, etc) */ + fclaw_diagnostics_initialize_t patch_init_diagnostics; + fclaw_diagnostics_compute_t patch_compute_diagnostics; + fclaw_diagnostics_gather_t patch_gather_diagnostics; + fclaw_diagnostics_reset_t patch_reset_diagnostics; + fclaw_diagnostics_finalize_t patch_finalize_diagnostics; + + /* gauge diagnostic functions */ + fclaw_diagnostics_initialize_t solver_init_diagnostics; + fclaw_diagnostics_compute_t solver_compute_diagnostics; + fclaw_diagnostics_gather_t solver_gather_diagnostics; + fclaw_diagnostics_reset_t solver_reset_diagnostics; + fclaw_diagnostics_finalize_t solver_finalize_diagnostics; + + /* solver diagnostic functions (other solver functions) */ + fclaw_diagnostics_initialize_t gauges_init_diagnostics; + fclaw_diagnostics_compute_t gauges_compute_diagnostics; + fclaw_diagnostics_gather_t gauges_gather_diagnostics; + fclaw_diagnostics_reset_t gauges_reset_diagnostics; + fclaw_diagnostics_finalize_t gauges_finalize_diagnostics; + + /* ray defined diagnostics */ + fclaw_diagnostics_initialize_t ray_init_diagnostics; + fclaw_diagnostics_compute_t ray_compute_diagnostics; + fclaw_diagnostics_gather_t ray_gather_diagnostics; + fclaw_diagnostics_reset_t ray_reset_diagnostics; + fclaw_diagnostics_finalize_t ray_finalize_diagnostics; + + /* user defined diagnostics */ + fclaw_diagnostics_initialize_t user_init_diagnostics; + fclaw_diagnostics_compute_t user_compute_diagnostics; + fclaw_diagnostics_gather_t user_gather_diagnostics; + fclaw_diagnostics_reset_t user_reset_diagnostics; + fclaw_diagnostics_finalize_t user_finalize_diagnostics; + + int is_set; +}; + +fclaw_diagnostics_vtable_t* fclaw_diagnostics_vt(struct fclaw_global* glob); + +void fclaw_diagnostics_vtable_initialize(struct fclaw_global* glob); + +double fclaw_domain_global_minimum (struct fclaw_domain* domain, double d); + +void fclaw_diagnostics_initialize(struct fclaw_global *glob); + +void fclaw_diagnostics_gather(struct fclaw_global *glob, int init_flag); + +void fclaw_diagnostics_reset(struct fclaw_global *glob); + +void fclaw_diagnostics_finalize(struct fclaw_global *glob); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/fclaw_diagnostics.h.TEST.cpp b/src/fclaw_diagnostics.h.TEST.cpp new file mode 100644 index 000000000..b83e88ca3 --- /dev/null +++ b/src/fclaw_diagnostics.h.TEST.cpp @@ -0,0 +1,71 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include + +TEST_CASE("fclaw_diagnostics_vtable_initialize stores two seperate vtables in two seperate globs") +{ + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_diagnostics_vtable_initialize(glob1); + fclaw_diagnostics_vtable_initialize(glob2); + + CHECK_NE(fclaw_diagnostics_vt(glob1), fclaw_diagnostics_vt(glob2)); + + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +TEST_CASE("fclaw_diagnostics_vtable_initialize sets is_set flag") +{ + fclaw_global_t* glob = fclaw_global_new(); + + fclaw_diagnostics_vtable_initialize(glob); + + CHECK_UNARY(fclaw_diagnostics_vt(glob)->is_set); + + fclaw_global_destroy(glob); +} + +#ifdef FCLAW_ENABLE_DEBUG + +TEST_CASE("fclaw_diagnostics_vtable_initialize fails if called twice on a glob") +{ + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_diagnostics_vtable_initialize(glob1); + CHECK_SC_ABORTED(fclaw_diagnostics_vtable_initialize(glob1)); + fclaw_diagnostics_vtable_initialize(glob2); + CHECK_SC_ABORTED(fclaw_diagnostics_vtable_initialize(glob2)); + + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +#endif \ No newline at end of file diff --git a/src/fclaw_domain.c b/src/fclaw_domain.c index aa8ac0ec4..e4cf4e031 100644 --- a/src/fclaw_domain.c +++ b/src/fclaw_domain.c @@ -24,99 +24,105 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include -#include +#include /* Contains domain_destroy and others */ +#include +#include +#include -int -fclaw_domain_is_valid (fclaw_domain_t * domain) +/* dimension-independent helper functions first */ + +#if 0 + +static fclaw2d_domain_t * +fclaw_domain_get_domain (fclaw_domain_t *d) { - if (domain == NULL) - return 0; - if (domain->dim == 2) - { - if (domain->d.d2.dmagic2 != FCLAW2D_DOMAIN_MAGIC) - return 0; - if (domain->d.d2.domain2 == NULL) - return 0; - if (domain->d.d2.domain2->mpisize <= 0) - return 0; - } - else - { - if (domain->dim != 3) - return 0; - if (domain->d.d3.dmagic3 != FCLAW3D_DOMAIN_MAGIC) - return 0; - if (domain->d.d3.domain3 == NULL) - return 0; - if (domain->d.d3.domain3->mpisize <= 0) - return 0; - } - return 1; +#ifndef P4_TO_P8 + return d->d.d2.domain2; +#else + return d->d.d3.domain3; +#endif } -void -fclaw_domain_destroy (fclaw_domain_t * domain, - fclaw_domain_callback_t dele, void *user) +#endif + +void fclaw_domain_setup(fclaw_global_t* glob, + fclaw_domain_t* new_domain) { - FCLAW_ASSERT (fclaw_domain_is_valid (domain)); - if (domain->dim == 2) + fclaw_domain_t *old_domain = glob->domain; + double t; + + if (old_domain == new_domain) { - fclaw_domain_destroy2d (domain, dele, user); + fclaw_global_infof("Building initial domain\n"); + t = 0; + glob->curr_time = t;//new_domain } else { - FCLAW_ASSERT (domain->dim == 3); - fclaw_domain_destroy3d (domain, dele, user); + fclaw_global_infof("Rebuilding domain\n"); } + fclaw_global_infof("Done\n"); } -void -fclaw_domain_iterate_patches (fclaw_domain_t * domain, - fclaw_domain_callback_t iter, void *user) +void fclaw_domain_reset(fclaw_global_t* glob) { - fclaw_domain_iterate_t di; + fclaw_domain_t** domain = &glob->domain; + int i, j; - FCLAW_ASSERT (fclaw_domain_is_valid (domain)); + for(i = 0; i < (*domain)->num_blocks; i++) + { + fclaw_block_t *block = (*domain)->blocks + i; - di.d = domain; - di.iter = iter; - di.user = user; + for(j = 0; j < block->num_patches; j++) + { + /* This is here to delete any patches created during + initialization, and not through regridding */ + fclaw_patch_t *patch = block->patches + j; + fclaw_patch_data_delete(glob,patch); + } + block->user = NULL; + } - if (domain->dim == 2) + if ((*domain)->exchange != NULL) { - fclaw2d_domain_iterate_patches (domain->d.d2.domain2, - fclaw2d_domain_iterate_cb, &di); + /* TO DO: translate fclaw2d_exchange files */ + fclaw_exchange_delete(glob); } - else + + /* Output memory discrepancy for the ClawPatch */ + if ((*domain)->count_set_patch != (*domain)->count_delete_patch) { - FCLAW_ASSERT (domain->dim == 3); - fclaw3d_domain_iterate_patches (domain->d.d3.domain3, - fclaw3d_domain_iterate_cb, &di); + printf ("[%d] This domain had Clawpatch set %d and deleted %d times\n", + (*domain)->mpirank, + (*domain)->count_set_patch, (*domain)->count_delete_patch); } + + fclaw_domain_destroy(*domain); + *domain = NULL; } -void -fclaw_domain_iterate_level (fclaw_domain_t * domain, int level, - fclaw_domain_callback_t iter, void *user) +void fclaw_domain_iterate_level_mthread (fclaw_domain_t * domain, int level, + fclaw_patch_callback_t pcb, void *user) { - fclaw_domain_iterate_t di; - - FCLAW_ASSERT (fclaw_domain_is_valid (domain)); +#if (_OPENMP) + int i, j; + fclaw_block_t *block; + fclaw_patch_t *patch; - di.d = domain; - di.iter = iter; - di.user = user; - - if (domain->dim == 2) - { - fclaw2d_domain_iterate_level (domain->d.d2.domain2, level, - fclaw2d_domain_iterate_cb, &di); - } - else + for (i = 0; i < domain->num_blocks; i++) { - FCLAW_ASSERT (domain->dim == 3); - fclaw3d_domain_iterate_level (domain->d.d3.domain3, level, - fclaw3d_domain_iterate_cb, &di); + block = domain->blocks + i; +#pragma omp parallel for private(patch,j) + for (j = 0; j < block->num_patches; j++) + { + patch = block->patches + j; + if (patch->level == level) + { + pcb (domain, patch, i, j, user); + } + } } +#else + fclaw_global_essentialf("fclaw2d_patch_iterator_mthread: We should not be here\n"); +#endif } diff --git a/src/fclaw_domain.h b/src/fclaw_domain.h index 124106b71..1ad44a2b0 100644 --- a/src/fclaw_domain.h +++ b/src/fclaw_domain.h @@ -22,119 +22,47 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** +/** * @file - * Dimension-independent wrapper of a forestclaw domain. + * Domain structures and routines */ #ifndef FCLAW_DOMAIN_H #define FCLAW_DOMAIN_H -/* - * Domain-independent header file should not include domain-specific headers. - * The corresponding source file include the 2d and 3d domain-specific headers. - */ -#include - -typedef struct fclaw_domain_user -{ - /* Debug counters and timers */ - int count_set_patch; - int count_delete_patch; -} -fclaw_domain_user_t; +#include /* Needed for domain_exchange/domain_indirect info */ -typedef struct fclaw_domain +#ifdef __cplusplus +extern "C" { - /* store dimension-specific domain structures */ - int dim; - union - { - struct - { - /* avoid including dimension-specific files */ - int dmagic2; - struct fclaw2d_domain *domain2; - struct fclaw2d_domain_exchange *exchange2; - struct fclaw2d_domain_indirect *indirect2; - - } - d2; - struct - { - int dmagic3; - struct fclaw3d_domain *domain3; #if 0 - struct fclaw3d_domain_exchange *exchange3; - struct fclaw3d_domain_indirect *indirect3; +} /* need this because indent is dumb */ +#endif #endif - } - d3; - } - d; - sc_mstamp_t pstamp; /**< internal: quickly allocate same-size patches */ - - fclaw_domain_user_t du; -} -fclaw_domain_t; -/** Dimension-independent callback prototype for the patch iterators. - * We iterate over local patches only. - * \param [in] domain Dimension-independent domain structure. - * \param [in] patch The local patch currently processed by the iterator. - * \param [in] blockno Block number of processed patch. - * \param [in] patchno Patch number within block of processed patch. - * \param [in,out] user Data that was passed into the iterator functions. +/* CB: chicken and egg -- should global include domain or vice versa? + Believe removing any dependence on global from domain will work. + Setting a global timer in domain_setup may likely be refactored. + Deleting patch and exchange data in domain_reset might go into a + toplevel algorithmic function quite naturally outside of domain. */ -typedef void (*fclaw_domain_callback_t) - (fclaw_domain_t * domain, fclaw_patch_t * patch, - int blockno, int patchno, void *user); +struct fclaw_global; -typedef struct fclaw_domain_iterate -{ - fclaw_domain_t *d; - fclaw_domain_callback_t iter; - void *user; -} -fclaw_domain_iterate_t; +void fclaw_domain_setup(struct fclaw_global* glob, + struct fclaw_domain* new_domain); -/* Verify that dimension and domain object are set correctly. - * \param [in] domain Dimension-independent domain. - * \return True if dimension and magic valid and a - * non-NULL dimension-specific domain assigned. - */ -int fclaw_domain_is_valid (fclaw_domain_t * domain); +void fclaw_domain_reset(struct fclaw_global* glob); -/** Destruct a dimension-specific domain and its patch data. - * \param [in,out] domain Initialized, valid domain structure. - * On output, the pointer is invalidated. - * \param [in] dele This callback is pointed to an existing - * fclaw_patch whose data it is supposed to - * delete. This includes deleting - * the patch user pointer, which the - * callback can do using the third - * parameter to this function, \a user. - * Just do not delete the patch itself! - * \param [in,out] user Pointer passed through to \a init. - */ -void fclaw_domain_destroy (fclaw_domain_t * domain, - fclaw_domain_callback_t dele, void *user); +/* OpenMP iterator (not part of forestclaw2d.h */ +void fclaw_domain_iterate_level_mthread (struct fclaw_domain * domain, int level, + fclaw_patch_callback_t pcb, void *user); -/** Iterate over all local patches. - * \param [in] domain Dimension-independent domain structure. - * \param [in] iter Function called for each patch of matching level. - * \param [in,out] user Data is passed to the \a iter callback. - */ -void fclaw_domain_iterate_patches (fclaw_domain_t * domain, - fclaw_domain_callback_t iter, void *user); -/** Iterate over all local patches on a given level. - * \param [in] domain Dimension-independent domain structure. - * \param [in] level Level to iterate. Ignore patches of other levels. - * \param [in] iter Function called for each patch of matching level. - * \param [in,out] user Data is passed to the \a iter callback. - */ -void fclaw_domain_iterate_level (fclaw_domain_t * domain, int level, - fclaw_domain_callback_t iter, void *user); +#ifdef __cplusplus +#if 0 +{ /* need this because indent is dumb */ +#endif +} +#endif -#endif /* !FCLAW_DOMAIN_H */ +#endif /* FCLAW2D_DOMAIN_H */ diff --git a/src/fclaw_edge_neighbors.c b/src/fclaw_edge_neighbors.c new file mode 100644 index 000000000..228a7d575 --- /dev/null +++ b/src/fclaw_edge_neighbors.c @@ -0,0 +1,536 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +static +int get_num_intersections(int intersects[], int faces[]) +{ + int num_intersections = 0; + int i; + for (i = 0; i < 2; i++) + { + if (intersects[faces[i]]) + { + num_intersections++; + } + } + return num_intersections; +} + +static +int find_face(int intersects[], int faces[]) +{ + int i; + for (i = 0; i < 2; i++) + { + if (intersects[faces[i]]) + { + return faces[i]; + } + } + return -1; +} + +static +void get_edge_type(fclaw_global_t* glob, + int iedge, + int intersects_bdry[], + int intersects_block[], + int *is_interior_in_domain, + fclaw_patch_transform_data_t* tdata, + fclaw_patch_transform_data_t* tdata_nbr) +{ + fclaw_domain_t *domain = glob->domain; + + tdata->icorner = -1; + tdata->iedge = iedge; + tdata->iface = -1; + + tdata_nbr->icorner = -1; + tdata_nbr->iedge = -1; + tdata_nbr->iface = -1; + + //can't be corner + tdata->is_block_corner = 0; + tdata_nbr->is_block_corner = 0; + + // p4est has tons of lookup table like this, can be exposed similarly + int edge_faces[2]; + fclaw_domain_edge_faces(domain, iedge, edge_faces); + + /* Both faces are at a physical boundary */ + int num_phys_faces = get_num_intersections(intersects_bdry, + edge_faces); + + /* Either a edge is at a block boundary (but not a physical boundary), + or internal to a block. L-shaped domains are excluded for now + (i.e. no reentrant corners). */ + *is_interior_in_domain = num_phys_faces == 0; + + int num_block_faces = get_num_intersections(intersects_block, + edge_faces); + /* Both faces are at a block boundary, physical or not */ + tdata->is_block_edge = num_block_faces == 2; + if(tdata->is_block_edge) + { + tdata->block_iedge = iedge; + } + else + { + tdata->block_iedge = -1; + } + + tdata->is_block_face = num_block_faces == 1; + tdata->block_iface = -1; + if (tdata->is_block_face) + { + tdata->block_iface = find_face(intersects_block, edge_faces); + } + + //set nbr tdata + tdata_nbr->is_block_edge = tdata->is_block_edge; + tdata_nbr->is_block_face = tdata->is_block_face; + tdata_nbr->block_iedge = -1; + tdata_nbr->block_iface = -1; +} + + +/* -------------------------------------------------------- + Four cases to consider. The 'has_corner_neighbor' + value is returned from p4est. The assumption going + into this routine is that we have found a valid + interior corner (not a corner on a physical boundary). + The corner than satisfies one of the following four + cases. + + Case No. | has_corner_neighbor | is_block_corner + -------------------------------------------------------- + 1 | T | T + 2 | F | F + 3 | T | F + 4 | F | T + + Case 1 : In this case, 4 or more patches meet at a block + corner. No transforms are yet available, so we + assume that at block corners, the patches all + have the same orientation. + Case 2 : Corner is at a hanging node and has no valid + adjacent corner. + Case 3 : Corner is either interior to a block, or on a + block edge. In each case, the transform is + well-defined. + Case 4 : Either 3 patches meet at a corner, in which + case we don't have an adjacent corner, or we are + on a pillow grid, in which case we have a + corner, but one which we nonetheless treat + as a special case. + ------------------------------------------------------ */ + +typedef struct get_edge_neighbors_return +{ + int is_valid_neighbor; + fclaw_patch_t* patches[2]; + int patchnos[2]; + int block_edge_count; +} edge_neighbors_t; + +static +edge_neighbors_t +get_edge_neighbors(fclaw_global_t *glob, + fclaw_patch_transform_data_t* tdata, + fclaw_patch_transform_data_t* tdata_nbr) +{ + edge_neighbors_t retval; + /* assume it is a valid neighbor for now */ + retval.is_valid_neighbor = 1; + + fclaw_domain_t *domain = glob->domain; + const int num_face_neighbors = fclaw_domain_num_siblings(domain)/2; + + for(int i=0; i<2; i++) + { + retval.patches[i] = NULL; + } + + fclaw_timer_start (&glob->timers[FCLAW_TIMER_NEIGHBOR_SEARCH]); + + /* See what p4est thinks we have for edges, and consider four cases */ + int rproc_edge[2]; + int has_edge_neighbor = + fclaw_patch_edge_neighbors(domain, + tdata->this_blockno, + tdata->this_patchno, + tdata->iedge, + rproc_edge, + &tdata->neighbor_blockno, + retval.patchnos, + &tdata_nbr->iedge, + &tdata->neighbor_type); + + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_NEIGHBOR_SEARCH]); + + retval.block_edge_count = 0; /* Assume we are not at a block edge */ + if (has_edge_neighbor && tdata->is_block_edge) + { + /* Case 1 : 4 or more patches meet at a block corner. + This case does NOT include the pillowgrid. */ + retval.block_edge_count = 4; /* assume four for now */ + + /* No block corner transforms yet, so we use the + interior 'default' transforms. */ + fclaw_patch_transform_blockface_intra (glob, tdata->transform); + fclaw_patch_transform_blockface_intra + (glob, tdata_nbr->transform); + } + else if (has_edge_neighbor && tdata->is_block_face) + { + /* The corner is on a block face (but is not a block edge). + Compute a transform between blocks. First, get the + remote face number. The remote face number encodes the + orientation, so we have 0 <= rfaceno < 8 */ + int rfaceno; + int rproc[num_face_neighbors]; + int rpatchno[num_face_neighbors]; + int rblockno; /* Should equal *corner_block_idx, above. */ + fclaw_patch_face_neighbors(domain, + tdata->this_blockno, + tdata->this_patchno, + tdata->block_iface, + rproc, + &rblockno, + rpatchno, + &rfaceno); + + FCLAW_ASSERT(rblockno == tdata->neighbor_blockno); + + /* Get encoding of transforming a neighbor coordinate across a face */ + fclaw_patch_transform_blockface (glob, tdata->block_iface, rfaceno, tdata->transform); + + /* Get transform needed to swap parallel ghost patch with fine + grid on-proc patch. This is done so that averaging and + interpolation routines can be re-used. */ + int iface1 = tdata->block_iface; + int rface1 = rfaceno; + fclaw_patch_face_swap(domain->refine_dim, &iface1, &rface1); + fclaw_patch_transform_blockface(glob, iface1, rface1, + tdata_nbr->transform); + + tdata_nbr->block_iface = iface1; + } + else if (has_edge_neighbor) + { + /* Case 3 : 'iedge' is an interior edge */ + if (tdata->this_blockno == tdata->neighbor_blockno) + { + /* Both patches are in the same block, so we set the transform to + a default transform. This could be the case for periodic boundaries. */ + retval.block_edge_count = 4; + fclaw_patch_transform_blockface_intra(glob, tdata->transform); + fclaw_patch_transform_blockface_intra(glob, tdata_nbr->transform); + + } + else + { + fclaw_errorf("WARNING : this_block_idx = %d\n",tdata->this_blockno); + fclaw_errorf("WARNING : neighbor_block_idx = %d\n",tdata->neighbor_blockno); + fclaw_abortf("get_edge_neighbors " \ + "(fclaw_edge_neighbors.c : " \ + "We should not be here\n"); + } + } + else if (!has_edge_neighbor) + { + /* Case 2 : 'iedge' is a hanging node */ + /* We do not return valid transformation objects! */ + retval.is_valid_neighbor = 0; + return retval; + } + + /* --------------------------------------------------------------------- + We have a valid neighbor and possibly a transform. We just now need + to get a pointer to the neighbor patch (which may be a parallel patch) + and the relative level (-1,0,1). + --------------------------------------------------------------------- */ + + + int num_neighbors; + if (tdata->neighbor_type == FCLAW_PATCH_HALFSIZE) + { + tdata_nbr->neighbor_type = FCLAW_PATCH_DOUBLESIZE; + num_neighbors = 2; + } + else if (tdata->neighbor_type == FCLAW_PATCH_SAMESIZE) + { + tdata_nbr->neighbor_type = FCLAW_PATCH_SAMESIZE; + num_neighbors = 1; + } + else /* FCLAW2D_PATCH_DOUBLESIZE */ + { + tdata_nbr->neighbor_type = FCLAW_PATCH_HALFSIZE; + num_neighbors = 1; + } + + for(int i=0; i < num_neighbors; i++) + { + if (domain->mpirank != rproc_edge[i]) + { + retval.patches[i] = &domain->ghost_patches[retval.patchnos[i]]; + } + else + { + fclaw_block_t *neighbor_block = &domain->blocks[tdata->neighbor_blockno]; + retval.patches[i] = &neighbor_block->patches[retval.patchnos[i]]; + } + } + + //set tdata_fine + tdata_nbr->this_blockno = tdata->neighbor_blockno; + + return retval; +} + + + +void fclaw_edge_fill_cb(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, + int this_blockno, + int this_patchno, + void *user) +{ + const int num_faces = fclaw_domain_num_faces(domain); + const int num_edges = fclaw_domain_num_edges(domain); + + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + + fclaw_exchange_info_t *filltype = (fclaw_exchange_info_t*) s->user; + int time_interp = filltype->time_interp; + int is_coarse = filltype->grid_type == FCLAW_IS_COARSE; + int is_fine = filltype->grid_type == FCLAW_IS_FINE; + + int read_parallel_patches = filltype->read_parallel_patches; + + int copy_from_neighbor = filltype->exchange_type == FCLAW_COPY; + int average_from_neighbor = filltype->exchange_type == FCLAW_AVERAGE; + int interpolate_to_neighbor = filltype->exchange_type == FCLAW_INTERPOLATE; + + int intersects_bdry[num_faces]; + int intersects_block[num_faces]; + + fclaw_physical_get_bc(s->glob,this_blockno,this_patchno, + intersects_bdry); + + fclaw_block_get_block_boundary(s->glob, this_patch, intersects_block); + + /* Transform data needed at multi-block boundaries */ + fclaw_patch_transform_data_t tdata; + + tdata.glob = s->glob; + tdata.based = 1; // cell-centered data in this routine. + tdata.this_patch = this_patch; + tdata.this_blockno = this_blockno; + tdata.this_patchno = this_patchno; + tdata.neighbor_patch = NULL; // gets filled in below. + + fclaw_patch_transform_init_data(s->glob,this_patch, + this_blockno, + this_patchno, + &tdata); + + + fclaw_patch_transform_data_t tdata_nbr; + + tdata_nbr.glob = s->glob; + tdata_nbr.based = 1; // cell-centered data in this routine. + tdata_nbr.neighbor_patch = this_patch; + tdata_nbr.neighbor_blockno = this_blockno; + tdata_nbr.neighbor_patchno = this_patchno; + + fclaw_patch_transform_init_data(s->glob,this_patch, + this_blockno, + this_patchno, + &tdata_nbr); + + + for (int iedge = 0; iedge < num_edges; iedge++) + { + int is_interior_in_domain; + get_edge_type(s->glob,iedge, + intersects_bdry, + intersects_block, + &is_interior_in_domain, + &tdata, + &tdata_nbr); + + /* Sets block_corner_count to 0 */ + // TODO is this necessary? + //fclaw_patch_set_block_edge_count(s->glob, this_patch, + // iedge,block_edge_count); + + if (is_interior_in_domain) + { + /* Is an interior patch edge; may also be a block edge */ + + edge_neighbors_t edge_neighbors = + get_edge_neighbors(s->glob, + &tdata, + &tdata_nbr); + + /* This sets value in block_corner_count_array */ + //TODO is this necessary? + //fclaw_patch_set_block_corner_count(s->glob, this_patch, + // icorner,block_corner_count); + + if (!edge_neighbors.is_valid_neighbor) + { + /* No corner neighbor. Either : + -- Hanging node + -- Cubed sphere + */ + continue; + } + FCLAW_ASSERT(tdata.iedge == iedge); + FCLAW_ASSERT(tdata_nbr.iedge == (iedge^3)); + + /* Parallel distribution keeps siblings on same processor */ + int remote_neighbor = fclaw_patch_is_ghost(edge_neighbors.patches[0]); + if (is_coarse) + { + if (tdata.neighbor_type == FCLAW_PATCH_HALFSIZE) + { + for (int igrid = 0; igrid < 2; igrid++) + { + tdata.neighbor_patch = edge_neighbors.patches[igrid]; + tdata.neighbor_patchno = edge_neighbors.patchnos[igrid]; + + remote_neighbor = fclaw_patch_is_ghost(tdata.neighbor_patch); + int valid_remote = read_parallel_patches && remote_neighbor; + int local_neighbor = !remote_neighbor; + if (!(local_neighbor || valid_remote)) + { + continue; + } + + if (interpolate_to_neighbor && !remote_neighbor) + { + /* interpolate to igrid */ + fclaw_patch_interpolate_edge(s->glob, + tdata.this_patch, + tdata.neighbor_patch, + tdata.iedge, + time_interp, + &tdata); + } + else if (average_from_neighbor) + { + /* average from igrid */ + fclaw_patch_average_edge(s->glob, + tdata.this_patch, + tdata.neighbor_patch, + tdata.iedge, + time_interp, + &tdata); + } + } + } + else if (tdata.neighbor_type == FCLAW_PATCH_SAMESIZE && copy_from_neighbor) + { + /* Copy to same size patch */ + tdata.neighbor_patch = edge_neighbors.patches[0]; + tdata.neighbor_patchno = edge_neighbors.patchnos[0]; + + fclaw_patch_copy_edge(s->glob, + tdata.this_patch, + tdata.neighbor_patch, + tdata.this_blockno, + tdata.neighbor_blockno, + tdata.iedge, + time_interp, + &tdata); + + /* We also need to copy _to_ the remote neighbor; switch contexts, but + use ClawPatches that are only in scope here, to avoid + conflicts with above uses of the same variables. This is needed + in case we want to interpolate to adjacent corners on fine grids.*/ + if (remote_neighbor) + { + tdata_nbr.this_patch = edge_neighbors.patches[0]; + tdata_nbr.this_patchno = edge_neighbors.patchnos[0]; + fclaw_patch_copy_edge(s->glob, + tdata_nbr.this_patch, + tdata_nbr.neighbor_patch, + tdata_nbr.this_blockno, + tdata_nbr.neighbor_blockno, + tdata_nbr.iedge, + time_interp, + &tdata_nbr); + } + } + } + else if (is_fine && tdata.neighbor_type == FCLAW_PATCH_DOUBLESIZE && remote_neighbor + && read_parallel_patches) + { + /* Swap 'this_patch' (fine grid) and the neighbor patch + (a coarse grid) */ + tdata_nbr.this_patch = edge_neighbors.patches[0]; + tdata_nbr.this_patchno = edge_neighbors.patchnos[0]; + + if (average_from_neighbor) + { + /* Average from 'this' grid (fine grid) to remote grid + (coarse grid) */ + fclaw_patch_average_edge(s->glob, + tdata_nbr.this_patch, + tdata_nbr.neighbor_patch, + tdata_nbr.iedge, + time_interp, + &tdata_nbr); + } + else if (interpolate_to_neighbor) + { + /* Interpolate from remote neighbor to 'this' patch (the finer grid */ + fclaw_patch_interpolate_edge(s->glob, + tdata_nbr.this_patch, + tdata_nbr.neighbor_patch, + tdata_nbr.iedge, + time_interp, + &tdata_nbr); + } + } + } /* End of 'interior_edge' */ + } /* End of iedge loop */ +} diff --git a/src/fclaw2d_corner_neighbors.h b/src/fclaw_edge_neighbors.h similarity index 80% rename from src/fclaw2d_corner_neighbors.h rename to src/fclaw_edge_neighbors.h index 175b0dc1f..4476734b0 100644 --- a/src/fclaw2d_corner_neighbors.h +++ b/src/fclaw_edge_neighbors.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_CORNER_NEIGHBORS_H -#define FCLAW2D_CORNER_NEIGHBORS_H +#ifndef FCLAW_EDGE_NEIGHBORS_H +#define FCLAW_EDGE_NEIGHBORS_H #include @@ -36,16 +36,16 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_domain; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_domain; +struct fclaw_patch; -void cb_corner_fill(struct fclaw2d_domain *domain, - struct fclaw2d_patch *this_patch, - int this_block_idx, - int this_patch_idx, - void *user); +void fclaw_edge_fill_cb(struct fclaw_domain *domain, + struct fclaw_patch *this_patch, + int this_block_idx, + int this_patch_idx, + void *user); #ifdef __cplusplus #if 0 diff --git a/src/fclaw2d_elliptic_solver.c b/src/fclaw_elliptic_solver.c similarity index 72% rename from src/fclaw2d_elliptic_solver.c rename to src/fclaw_elliptic_solver.c index f765935ef..1dbabd462 100644 --- a/src/fclaw2d_elliptic_solver.c +++ b/src/fclaw_elliptic_solver.c @@ -25,18 +25,18 @@ #include -#include -#include +#include +#include -#include +#include /* ---------------------------- Setup solver functions -------------------------------- */ static -void elliptic_setup_solver(fclaw2d_global_t *glob) +void elliptic_setup_solver(fclaw_global_t *glob) { - fclaw2d_elliptic_vtable_t* elliptic_vt = fclaw2d_elliptic_vt(glob); + fclaw_elliptic_vtable_t* elliptic_vt = fclaw_elliptic_vt(glob); /* May not be anything to set up */ if (elliptic_vt->setup != NULL) @@ -46,15 +46,15 @@ void elliptic_setup_solver(fclaw2d_global_t *glob) /* -------------------------------- RHS functions -------------------------------- */ static -void cb_elliptic_rhs(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void cb_elliptic_rhs(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void* user) { - fclaw2d_global_iterate_t* g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*) user; - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(g->glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(g->glob); /* Check that the user has set the right hand side function */ FCLAW_ASSERT(patch_vt->rhs != NULL); @@ -63,16 +63,16 @@ void cb_elliptic_rhs(fclaw2d_domain_t *domain, } static -void elliptic_rhs_default(fclaw2d_global_t *glob) +void elliptic_rhs_default(fclaw_global_t *glob) { /* Set up right hand side by iterating over patches. */ - fclaw2d_global_iterate_patches (glob, cb_elliptic_rhs, NULL); + fclaw_global_iterate_patches (glob, cb_elliptic_rhs, NULL); } static -void elliptic_rhs(fclaw2d_global_t *glob) +void elliptic_rhs(fclaw_global_t *glob) { - fclaw2d_elliptic_vtable_t* elliptic_vt = fclaw2d_elliptic_vt(glob); + fclaw_elliptic_vtable_t* elliptic_vt = fclaw_elliptic_vt(glob); FCLAW_ASSERT(elliptic_vt->rhs != NULL); @@ -85,9 +85,9 @@ void elliptic_rhs(fclaw2d_global_t *glob) /* ----------------------------------- Solve functions -------------------------------- */ static -void elliptic_solve(fclaw2d_global_t *glob) +void elliptic_solve(fclaw_global_t *glob) { - fclaw2d_elliptic_vtable_t* elliptic_vt = fclaw2d_elliptic_vt(glob); + fclaw_elliptic_vtable_t* elliptic_vt = fclaw_elliptic_vt(glob); /* Check that the user has set an elliptic solver */ FCLAW_ASSERT(elliptic_vt->solve != NULL); @@ -98,9 +98,9 @@ void elliptic_solve(fclaw2d_global_t *glob) /*----------------------------------- Public interface -------------------------------- */ -void fclaw2d_elliptic_solve(fclaw2d_global_t *glob) +void fclaw_elliptic_solve(fclaw_global_t *glob) { - fclaw2d_domain_t* domain = glob->domain; + fclaw_domain_t* domain = glob->domain; /* Any solver related setup that should happen before each solve */ elliptic_setup_solver(glob); @@ -110,20 +110,20 @@ void fclaw2d_elliptic_solve(fclaw2d_global_t *glob) /* Pass p4est pointer to elliptic solver, solve and transfer solution back. */ glob->count_elliptic_grids += domain->local_num_patches; - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_ELLIPTIC_SOLVE]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_ELLIPTIC_SOLVE]); elliptic_solve(glob); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_ELLIPTIC_SOLVE]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_ELLIPTIC_SOLVE]); } /*---------------------------- Virtual table functions -------------------------------- */ static -fclaw2d_elliptic_vtable_t* elliptic_vt_new() +fclaw_elliptic_vtable_t* elliptic_vt_new() { - return (fclaw2d_elliptic_vtable_t*) FCLAW_ALLOC_ZERO (fclaw2d_elliptic_vtable_t, 1); + return (fclaw_elliptic_vtable_t*) FCLAW_ALLOC_ZERO (fclaw_elliptic_vtable_t, 1); } static @@ -133,9 +133,9 @@ void elliptic_vt_destroy(void* vt) } -void fclaw2d_elliptic_vtable_initialize(fclaw2d_global_t* glob) +void fclaw_elliptic_vtable_initialize(fclaw_global_t* glob) { - fclaw2d_elliptic_vtable_t *elliptic_vt = elliptic_vt_new(); + fclaw_elliptic_vtable_t *elliptic_vt = elliptic_vt_new(); elliptic_vt->rhs = elliptic_rhs_default; @@ -148,9 +148,9 @@ void fclaw2d_elliptic_vtable_initialize(fclaw2d_global_t* glob) /*----------------------------------- Access functions -------------------------------- */ -fclaw2d_elliptic_vtable_t* fclaw2d_elliptic_vt(fclaw2d_global_t* glob) +fclaw_elliptic_vtable_t* fclaw_elliptic_vt(fclaw_global_t* glob) { - fclaw2d_elliptic_vtable_t* elliptic_vt = (fclaw2d_elliptic_vtable_t*) + fclaw_elliptic_vtable_t* elliptic_vt = (fclaw_elliptic_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fclaw2d_elliptic"); FCLAW_ASSERT(elliptic_vt != NULL); FCLAW_ASSERT(elliptic_vt->is_set != 0); diff --git a/src/fclaw2d_elliptic_solver.h b/src/fclaw_elliptic_solver.h similarity index 65% rename from src/fclaw2d_elliptic_solver.h rename to src/fclaw_elliptic_solver.h index 6df4827fb..75140d805 100644 --- a/src/fclaw2d_elliptic_solver.h +++ b/src/fclaw_elliptic_solver.h @@ -24,8 +24,8 @@ */ -#ifndef FCLAW2D_ELLIPTIC_SOLVER_H -#define FCLAW2D_ELLIPTIC_SOLVER_H +#ifndef FCLAW_ELLIPTIC_SOLVER_H +#define FCLAW_ELLIPTIC_SOLVER_H #ifdef __cplusplus extern "C" @@ -35,34 +35,34 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; -typedef void (*fclaw2d_elliptic_setup_t)(struct fclaw2d_global *glob); +typedef void (*fclaw_elliptic_setup_t)(struct fclaw_global *glob); -typedef void (*fclaw2d_elliptic_rhs_t)(struct fclaw2d_global *glob); +typedef void (*fclaw_elliptic_rhs_t)(struct fclaw_global *glob); -typedef void (*fclaw2d_elliptic_solve_t)(struct fclaw2d_global *glob); +typedef void (*fclaw_elliptic_solve_t)(struct fclaw_global *glob); -typedef void (*fclaw2d_elliptic_physical_bc_t)(struct fclaw2d_global *glob); +typedef void (*fclaw_elliptic_physical_bc_t)(struct fclaw_global *glob); -typedef struct fclaw2d_elliptic_vtable +typedef struct fclaw_elliptic_vtable { - fclaw2d_elliptic_setup_t setup; - fclaw2d_elliptic_rhs_t rhs; - fclaw2d_elliptic_solve_t solve; - fclaw2d_elliptic_physical_bc_t apply_bc; + fclaw_elliptic_setup_t setup; + fclaw_elliptic_rhs_t rhs; + fclaw_elliptic_solve_t solve; + fclaw_elliptic_physical_bc_t apply_bc; int is_set; -} fclaw2d_elliptic_vtable_t; +} fclaw_elliptic_vtable_t; -void fclaw2d_elliptic_vtable_initialize(struct fclaw2d_global* glob); +void fclaw_elliptic_vtable_initialize(struct fclaw_global* glob); -void fclaw2d_elliptic_solve(struct fclaw2d_global *glob); +void fclaw_elliptic_solve(struct fclaw_global *glob); -fclaw2d_elliptic_vtable_t* fclaw2d_elliptic_vt(struct fclaw2d_global* glob); +fclaw_elliptic_vtable_t* fclaw_elliptic_vt(struct fclaw_global* glob); #ifdef __cplusplus #if 0 diff --git a/src/fclaw2d_patch.h.TEST.cpp b/src/fclaw_elliptic_solver.h.TEST.cpp similarity index 55% rename from src/fclaw2d_patch.h.TEST.cpp rename to src/fclaw_elliptic_solver.h.TEST.cpp index f72633749..41a0731ca 100644 --- a/src/fclaw2d_patch.h.TEST.cpp +++ b/src/fclaw_elliptic_solver.h.TEST.cpp @@ -23,49 +23,49 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include -TEST_CASE("fclaw2d_patch_vtable_initialize stores two seperate vtables in two seperate globs") +TEST_CASE("fclaw_elliptic_vtable_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); - fclaw2d_patch_vtable_initialize(glob1); - fclaw2d_patch_vtable_initialize(glob2); + fclaw_elliptic_vtable_initialize(glob1); + fclaw_elliptic_vtable_initialize(glob2); - CHECK_NE(fclaw2d_patch_vt(glob1), fclaw2d_patch_vt(glob2)); + CHECK_NE(fclaw_elliptic_vt(glob1), fclaw_elliptic_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } -TEST_CASE("fclaw2d_patch_vtable_initialize sets is_set flag") +TEST_CASE("fclaw_elliptic_vtable_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_global_t* glob = fclaw_global_new(); - fclaw2d_patch_vtable_initialize(glob); + fclaw_elliptic_vtable_initialize(glob); - CHECK_UNARY(fclaw2d_patch_vt(glob)->is_set); + CHECK_UNARY(fclaw_elliptic_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG -TEST_CASE("fclaw2d_patch_vtable_initialize fails if called twice on a glob") +TEST_CASE("fclaw_elliptic_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); - fclaw2d_patch_vtable_initialize(glob1); - CHECK_SC_ABORTED(fclaw2d_patch_vtable_initialize(glob1)); - fclaw2d_patch_vtable_initialize(glob2); - CHECK_SC_ABORTED(fclaw2d_patch_vtable_initialize(glob2)); + fclaw_elliptic_vtable_initialize(glob1); + CHECK_SC_ABORTED(fclaw_elliptic_vtable_initialize(glob1)); + fclaw_elliptic_vtable_initialize(glob2); + CHECK_SC_ABORTED(fclaw_elliptic_vtable_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/fclaw2d_exchange.c b/src/fclaw_exchange.c similarity index 52% rename from src/fclaw2d_exchange.c rename to src/fclaw_exchange.c index 5cf525fc2..2d8c908fd 100644 --- a/src/fclaw2d_exchange.c +++ b/src/fclaw_exchange.c @@ -23,77 +23,69 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef P4_TO_P8 -#include +#include -#include -#include -#include +#include +#include +#include -#include -#else -#include +#include -#include -#include -#include - -#include -#endif +#include +#include /* Also needed in fclaw2d_domain_reset */ /* edit: right now this is not the case, switching to static */ static -fclaw2d_domain_exchange_t* - get_exchange_data(fclaw2d_global_t* glob) +void** get_patch_data(fclaw_domain_t *domain) { - fclaw2d_domain_data_t *ddata = fclaw2d_domain_get_data (glob->domain); - return ddata->domain_exchange; -} + FCLAW_ASSERT(domain->refine_dim == 2 || domain->refine_dim == 3); + FCLAW_ASSERT(domain->exchange != NULL); -/* Should these be access functions in domain? */ -static -void set_exchange_data(fclaw2d_global_t* glob, - fclaw2d_domain_exchange_t *e) -{ - fclaw2d_domain_data_t *ddata = fclaw2d_domain_get_data (glob->domain); - ddata->domain_exchange = e; + if(domain->refine_dim == 2) + { + return domain->exchange->d2->patch_data; + } + else + { + return domain->exchange->d3->patch_data; + } } static -fclaw2d_domain_indirect_t* - get_indirect_data(fclaw2d_global_t* glob) +void** get_ghost_data(fclaw_domain_t *domain) { - fclaw2d_domain_data_t *ddata = fclaw2d_domain_get_data (glob->domain); - return ddata->domain_indirect; -} + FCLAW_ASSERT(domain->refine_dim == 2 || domain->refine_dim == 3); + FCLAW_ASSERT(domain->exchange != NULL); -static -void set_indirect_data(fclaw2d_global_t* glob, - fclaw2d_domain_indirect_t *ind) -{ - fclaw2d_domain_data_t *ddata = fclaw2d_domain_get_data (glob->domain); - ddata->domain_indirect = ind; + if(domain->refine_dim == 2) + { + return domain->exchange->d2->ghost_data; + } + else + { + return domain->exchange->d3->ghost_data; + } } static -void build_remote_ghost_patches(fclaw2d_global_t* glob) +void build_remote_ghost_patches(fclaw_global_t* glob) { - fclaw2d_domain_t *domain = glob->domain; - const fclaw_options_t *gparms = fclaw2d_get_options(glob); + fclaw_domain_t *domain = glob->domain; + const fclaw_options_t *gparms = fclaw_get_options(glob); fclaw_infof("[%d] Number of ghost patches : %d\n", domain->mpirank,domain->num_ghost_patches); int blockno, patchno; - fclaw2d_patch_t *ghost_patch; - fclaw2d_build_mode_t build_mode; + fclaw_patch_t *ghost_patch; + fclaw_build_mode_t build_mode; if (gparms->ghost_patch_pack_area) { - build_mode = FCLAW2D_BUILD_FOR_GHOST_AREA_PACKED; + build_mode = FCLAW_BUILD_FOR_GHOST_AREA_PACKED; } else { - build_mode = FCLAW2D_BUILD_FOR_GHOST_AREA_COMPUTED; + build_mode = FCLAW_BUILD_FOR_GHOST_AREA_COMPUTED; } int i; @@ -101,14 +93,14 @@ void build_remote_ghost_patches(fclaw2d_global_t* glob) { ghost_patch = &domain->ghost_patches[i]; - blockno = ghost_patch->u.blockno; + blockno = fclaw_patch_get_ghost_block(ghost_patch); /* not clear how useful this patchno is. In any case, it isn't used in defining the ClawPatch, so probably doesn't need to be passed in */ patchno = i; - fclaw2d_patch_remote_ghost_build(glob,ghost_patch,blockno, + fclaw_patch_remote_ghost_build(glob,ghost_patch,blockno, patchno, build_mode); } fclaw_infof("[%d] Done building remote ghost patches : %d\n", @@ -116,49 +108,49 @@ void build_remote_ghost_patches(fclaw2d_global_t* glob) } static -void delete_remote_ghost_patches(fclaw2d_global_t* glob) +void delete_remote_ghost_patches(fclaw_global_t* glob) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; int i; for(i = 0; i < domain->num_ghost_patches; i++) { - fclaw2d_patch_t* ghost_patch = &domain->ghost_patches[i]; + fclaw_patch_t* ghost_patch = &domain->ghost_patches[i]; - fclaw2d_patch_remote_ghost_delete(glob,ghost_patch); + fclaw_patch_remote_ghost_delete(glob,ghost_patch); } } static void -unpack_remote_ghost_patches(fclaw2d_global_t* glob, - fclaw2d_domain_exchange_t *e, +unpack_remote_ghost_patches(fclaw_global_t* glob, int minlevel, int maxlevel, int time_interp) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; + void** ghost_data = get_ghost_data(domain); int i; for(i = 0; i < domain->num_ghost_patches; i++) { - fclaw2d_patch_t* ghost_patch = &domain->ghost_patches[i]; + fclaw_patch_t* ghost_patch = &domain->ghost_patches[i]; int level = ghost_patch->level; if (level >= minlevel-1) { - int blockno = ghost_patch->u.blockno; + int blockno = fclaw_patch_get_ghost_block(ghost_patch); int patchno = i; /* access data stored on remote procs. */ - void *q = e->ghost_data[patchno]; + void *q = ghost_data[patchno]; int unpack_to_timeinterp_patch=0; if (time_interp && level == minlevel-1) { unpack_to_timeinterp_patch = 1; } - fclaw2d_patch_remote_ghost_unpack(glob, ghost_patch, blockno, + fclaw_patch_remote_ghost_unpack(glob, ghost_patch, blockno, patchno, q, unpack_to_timeinterp_patch); } } @@ -168,24 +160,21 @@ unpack_remote_ghost_patches(fclaw2d_global_t* glob, Public interface -------------------------------------------------------------------------- */ /* This is called whenever a new domain is created (initialize, regrid) */ -void fclaw2d_exchange_setup(fclaw2d_global_t* glob, - fclaw2d_timer_names_t running) +void fclaw_exchange_setup(fclaw_global_t* glob, + fclaw_timer_names_t running) { - fclaw2d_domain_t* domain = glob->domain; + fclaw_domain_t* domain = glob->domain; /* Time spend in build here is negligible and is included in regrid */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); - size_t psize = fclaw2d_patch_ghost_packsize(glob); + size_t psize = fclaw_patch_ghost_packsize(glob); size_t data_size = psize; /* Includes sizeof(datatype), i.e. sizeof(double) */ - fclaw2d_domain_exchange_t *e; - - /* we just created a grid by fclaw2d_initialize or fclaw2d_regrid + + /* we just created a grid by fclaw_initialize or fclaw_regrid and we now need to allocate data to store and retrieve local boundary patches and remote ghost patches */ - e = fclaw2d_domain_allocate_before_exchange (domain, data_size); - - /* Store e so we can retrieve it later */ - set_exchange_data(glob,e); + FCLAW_ASSERT(domain->exchange == NULL); + domain->exchange = fclaw_domain_allocate_before_exchange (domain, data_size); /* Store locations of on-proc boundary patches that will be communicated to neighboring remote procs. The pointer stored in e->patch_data[] @@ -194,15 +183,16 @@ void fclaw2d_exchange_setup(fclaw2d_global_t* glob, on manifolds).*/ int zz = 0; int nb; + void ** patch_data = get_patch_data(domain); for (nb = 0; nb < domain->num_blocks; ++nb) { int np; for (np = 0; np < domain->blocks[nb].num_patches; ++np) { - if (domain->blocks[nb].patches[np].flags & - FCLAW2D_PATCH_ON_PARALLEL_BOUNDARY) + if (fclaw_patch_on_parallel_boundary(&domain->blocks[nb].patches[np])) { - fclaw2d_patch_local_ghost_alloc(glob, &e->patch_data[zz++]); + FCLAW_ASSERT(zz < domain->num_exchange_patches); + fclaw_patch_local_ghost_alloc(glob, &patch_data[zz++]); } } } @@ -214,61 +204,61 @@ void fclaw2d_exchange_setup(fclaw2d_global_t* glob, Note that this is a parallel communication, but only needs to happen once when setting up the exchange. ------------------------------------------------------- */ - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); - if (running != FCLAW2D_TIMER_NONE) + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_stop (&glob->timers[running]); + fclaw_timer_stop (&glob->timers[running]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM]); - fclaw2d_domain_indirect_t *ind = - fclaw2d_domain_indirect_begin(domain); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM]); + FCLAW_ASSERT(domain->indirect == NULL); + domain->indirect = fclaw_domain_indirect_begin(domain); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM]); - if (running != FCLAW2D_TIMER_NONE) + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_start (&glob->timers[running]); + fclaw_timer_start (&glob->timers[running]); } /* Do some some work that we hope to hide by communication above. */ - set_indirect_data(glob,ind); - + /* Build ghost patches from neighboring remote processors. These will be filled later with q data and the area, if we are on a manifold */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); build_remote_ghost_patches(glob); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); /* --------------------------------------------------------- Receive ghost patch meta data from send initiated above. ------------------------------------------------------- */ - if (running != FCLAW2D_TIMER_NONE) + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_stop (&glob->timers[running]); + fclaw_timer_stop (&glob->timers[running]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM]); - fclaw2d_domain_indirect_end(domain,ind); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM]); + fclaw_domain_indirect_end(domain, domain->indirect); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM]); - if (running != FCLAW2D_TIMER_NONE) + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_start (&glob->timers[running]); + fclaw_timer_start (&glob->timers[running]); } } -void fclaw2d_exchange_delete(fclaw2d_global_t* glob) +void fclaw_exchange_delete(fclaw_global_t* glob) { - fclaw2d_domain_t** domain = &glob->domain; - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); + fclaw_domain_t** domain = &glob->domain; + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); /* Free old parallel ghost patch data structure, must exist by construction. */ - fclaw2d_domain_exchange_t *e_old = get_exchange_data(glob); + fclaw_domain_exchange_t *e_old = (*domain)->exchange; /* Free contiguous memory, if allocated. If no memory was allocated (because we are not storing the area), nothing de-allocated. */ + void ** patch_data = get_patch_data(*domain); if (e_old != NULL) { /* Delete local patches which are passed to other procs */ @@ -279,10 +269,9 @@ void fclaw2d_exchange_delete(fclaw2d_global_t* glob) int np; for (np = 0; np < (*domain)->blocks[nb].num_patches; ++np) { - if ((*domain)->blocks[nb].patches[np].flags & - FCLAW2D_PATCH_ON_PARALLEL_BOUNDARY) + if (fclaw_patch_on_parallel_boundary(&(*domain)->blocks[nb].patches[np])) { - fclaw2d_patch_local_ghost_free(glob,&e_old->patch_data[zz++]); + fclaw_patch_local_ghost_free(glob,&patch_data[zz++]); } } } @@ -290,13 +279,15 @@ void fclaw2d_exchange_delete(fclaw2d_global_t* glob) /* Delete ghost patches from remote neighboring patches */ delete_remote_ghost_patches(glob); - fclaw2d_domain_free_after_exchange (*domain, e_old); + fclaw_domain_free_after_exchange (*domain, e_old); + (*domain)->exchange = NULL; /* Destroy indirect data needed to communicate between ghost patches from different procs */ - fclaw2d_domain_indirect_t* ind_old = get_indirect_data(glob); - fclaw2d_domain_indirect_destroy(*domain,ind_old); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); + fclaw_domain_indirect_t* ind_old = (*domain)->indirect; + fclaw_domain_indirect_destroy(*domain,ind_old); + (*domain)->indirect = NULL; + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); } @@ -305,16 +296,16 @@ void fclaw2d_exchange_delete(fclaw2d_global_t* glob) -------------------------------------------------------------- */ /* This is called whenever all time levels are time synchronized. */ -void fclaw2d_exchange_ghost_patches_begin(fclaw2d_global_t* glob, +void fclaw_exchange_ghost_patches_begin(fclaw_global_t* glob, int minlevel, int maxlevel, int time_interp, - fclaw2d_timer_names_t running) + fclaw_timer_names_t running) { - fclaw2d_domain_t* domain = glob->domain; - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); + fclaw_domain_t* domain = glob->domain; + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); - fclaw2d_domain_exchange_t *e = get_exchange_data(glob); + void** patch_data = get_patch_data(domain); /* Pack local data into on-proc patches at the parallel boundary that will be shipped of to other processors. */ @@ -325,89 +316,86 @@ void fclaw2d_exchange_ghost_patches_begin(fclaw2d_global_t* glob, int np; for (np = 0; np < domain->blocks[nb].num_patches; ++np) { - if (domain->blocks[nb].patches[np].flags & - FCLAW2D_PATCH_ON_PARALLEL_BOUNDARY) + if (fclaw_patch_on_parallel_boundary(&domain->blocks[nb].patches[np])) { - fclaw2d_patch_t *this_patch = &domain->blocks[nb].patches[np]; + fclaw_patch_t *this_patch = &domain->blocks[nb].patches[np]; int level = this_patch->level; FCLAW_ASSERT(level <= maxlevel); int pack_time_interp = time_interp && level == minlevel-1; /* Pack q and area into one contingous block */ - fclaw2d_patch_local_ghost_pack(glob,this_patch, - e->patch_data[zz++], + fclaw_patch_local_ghost_pack(glob,this_patch, + patch_data[zz++], pack_time_interp); } } } - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); - if (running != FCLAW2D_TIMER_NONE) + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_stop (&glob->timers[running]); + fclaw_timer_stop (&glob->timers[running]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM]); /* Exchange only over levels currently in use */ if (time_interp) { int time_interp_level = minlevel-1; - fclaw2d_domain_ghost_exchange_begin - (domain, e,time_interp_level, maxlevel); + fclaw_domain_ghost_exchange_begin + (domain, domain->exchange, time_interp_level, maxlevel); } else { - fclaw2d_domain_ghost_exchange_begin(domain, e, minlevel, maxlevel); + fclaw_domain_ghost_exchange_begin(domain, domain->exchange, minlevel, maxlevel); } - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM]); - if (running != FCLAW2D_TIMER_NONE) + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM]); + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_start (&glob->timers[running]); + fclaw_timer_start (&glob->timers[running]); } } /* This is called whenever all time levels are time synchronized. */ -void fclaw2d_exchange_ghost_patches_end(fclaw2d_global_t* glob, +void fclaw_exchange_ghost_patches_end(fclaw_global_t* glob, int minlevel, int maxlevel, int time_interp, - fclaw2d_timer_names_t running) + fclaw_timer_names_t running) { - fclaw2d_domain_t* domain = glob->domain; - if (running != FCLAW2D_TIMER_NONE) + fclaw_domain_t* domain = glob->domain; + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_stop (&glob->timers[running]); + fclaw_timer_stop (&glob->timers[running]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM]); - - fclaw2d_domain_exchange_t *e = get_exchange_data(glob); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM]); /* Exchange only over levels currently in use */ if (time_interp) { - fclaw2d_domain_ghost_exchange_end (domain, e); + fclaw_domain_ghost_exchange_end (domain, domain->exchange); } else { - fclaw2d_domain_ghost_exchange_end (domain, e); + fclaw_domain_ghost_exchange_end (domain, domain->exchange); } - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM]); - if (running != FCLAW2D_TIMER_NONE) + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM]); + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_start (&glob->timers[running]); + fclaw_timer_start (&glob->timers[running]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); /* Unpack data from remote patches to corresponding ghost patches stored locally */ - unpack_remote_ghost_patches(glob,e,minlevel,maxlevel,time_interp); + unpack_remote_ghost_patches(glob,minlevel,maxlevel,time_interp); /* Count calls to this function */ ++glob->count_ghost_exchange; - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTPATCH_BUILD]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTPATCH_BUILD]); } diff --git a/src/fclaw2d_exchange.h b/src/fclaw_exchange.h similarity index 77% rename from src/fclaw2d_exchange.h rename to src/fclaw_exchange.h index 5c353e8a3..02c6cf009 100644 --- a/src/fclaw2d_exchange.h +++ b/src/fclaw_exchange.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_EXCHANGE_H -#define FCLAW2D_EXCHANGE_H +#ifndef FCLAW_EXCHANGE_H +#define FCLAW_EXCHANGE_H #include @@ -36,24 +36,24 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; -void fclaw2d_exchange_setup(struct fclaw2d_global* glob, - fclaw2d_timer_names_t running); +void fclaw_exchange_setup(struct fclaw_global* glob, + fclaw_timer_names_t running); -void fclaw2d_exchange_delete(struct fclaw2d_global* glob); +void fclaw_exchange_delete(struct fclaw_global* glob); -void fclaw2d_exchange_ghost_patches_begin(struct fclaw2d_global* glob, +void fclaw_exchange_ghost_patches_begin(struct fclaw_global* glob, int minlevel, int maxlevel, int time_interp, - fclaw2d_timer_names_t running); + fclaw_timer_names_t running); -void fclaw2d_exchange_ghost_patches_end(struct fclaw2d_global* glob, +void fclaw_exchange_ghost_patches_end(struct fclaw_global* glob, int minlevel, int maxlevel, int time_interp, - fclaw2d_timer_names_t running); + fclaw_timer_names_t running); #ifdef __cplusplus diff --git a/src/fclaw2d_face_neighbors.c b/src/fclaw_face_neighbors.c similarity index 68% rename from src/fclaw2d_face_neighbors.c rename to src/fclaw_face_neighbors.c index 9249c8ab8..8e7343f67 100644 --- a/src/fclaw2d_face_neighbors.c +++ b/src/fclaw_face_neighbors.c @@ -27,18 +27,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Average, coarsen and copy between grids at faces. **/ -#include +#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /* This is used to determine neighbor patch relative level @@ -53,7 +53,7 @@ enum /* This function is a bit overkill, but I put it here so the logic in both the corner fill and face fill are the same */ static -void get_face_type(fclaw2d_global_t *glob, +void get_face_type(fclaw_global_t *glob, int iface, int intersects_phys_bdry[], int intersects_block[], @@ -66,35 +66,37 @@ void get_face_type(fclaw2d_global_t *glob, static -void get_face_neighbors(fclaw2d_global_t *glob, +void get_face_neighbors(fclaw_global_t *glob, int this_block_idx, int this_patch_idx, int iface, int is_block_face, int *neighbor_block_idx, - fclaw2d_patch_t* neighbor_patches[], + fclaw_patch_t* neighbor_patches[], int **ref_flag_ptr, int **fine_grid_pos_ptr, int **iface_neighbor_ptr, int ftransform[], - fclaw2d_patch_transform_data_t* ftransform_finegrid) + fclaw_patch_transform_data_t* ftransform_finegrid) { - fclaw2d_domain_t *domain = glob->domain; - int rproc[FCLAW2D_NUMFACENEIGHBORS]; + fclaw_domain_t *domain = glob->domain; + const int num_faces = fclaw_domain_num_faces(domain); + + int rproc[num_faces]; int rblockno; - int rpatchno[FCLAW2D_NUMFACENEIGHBORS]; + int rpatchno[num_faces]; int rfaceno; int num_neighbors; int ir; - for(ir = 0; ir < FCLAW2D_NUMFACENEIGHBORS; ir++) + for(ir = 0; ir < num_faces; ir++) { neighbor_patches[ir] = NULL; } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_NEIGHBOR_SEARCH]); - fclaw2d_patch_relation_t neighbor_type = - fclaw2d_patch_face_neighbors(domain, + fclaw_timer_start (&glob->timers[FCLAW_TIMER_NEIGHBOR_SEARCH]); + fclaw_patch_relation_t neighbor_type = + fclaw_patch_face_neighbors(domain, this_block_idx, this_patch_idx, iface, @@ -102,7 +104,7 @@ void get_face_neighbors(fclaw2d_global_t *glob, &rblockno, rpatchno, &rfaceno); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_NEIGHBOR_SEARCH]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_NEIGHBOR_SEARCH]); /* ------------------------------ @@ -113,25 +115,25 @@ void get_face_neighbors(fclaw2d_global_t *glob, FCLAW2D_PATCH_DOUBLESIZE ------------------------------- */ - if (neighbor_type == FCLAW2D_PATCH_BOUNDARY) + if (neighbor_type == FCLAW_PATCH_BOUNDARY) { /* This case should be excluded by earlier checks */ - printf("get_face_neighbors (fclaw2d_face_neighbors.cpp) : No patch " \ + fclaw_abortf("get_face_neighbors (fclaw2d_face_neighbors.cpp) : No patch " \ "found\n"); - exit(0); - } + } else { *neighbor_block_idx = is_block_face ? rblockno : -1; /* Get encoding of transforming a neighbor coordinate across a face */ - fclaw2d_patch_transform_blockface (glob, iface, rfaceno, ftransform); + fclaw_patch_transform_blockface (glob, iface, rfaceno, ftransform); int iface1, rface1; iface1 = iface; rface1 = rfaceno; - fclaw2d_patch_face_swap(&iface1,&rface1); - fclaw2d_patch_transform_blockface (glob, iface1, rface1, + fclaw_patch_face_swap(domain->refine_dim, &iface1,&rface1); + fclaw_patch_transform_blockface (glob, iface1, rface1, ftransform_finegrid->transform); + ftransform_finegrid->block_iface = iface1; **iface_neighbor_ptr = iface1; @@ -140,43 +142,42 @@ void get_face_neighbors(fclaw2d_global_t *glob, { /* If we are within one patch this is a special case */ FCLAW_ASSERT (*neighbor_block_idx == -1); - fclaw2d_patch_transform_blockface_intra (glob, ftransform); - fclaw2d_patch_transform_blockface_intra + fclaw_patch_transform_blockface_intra (glob, ftransform); + fclaw_patch_transform_blockface_intra (glob, ftransform_finegrid->transform); } - if (neighbor_type == FCLAW2D_PATCH_SAMESIZE) + if (neighbor_type == FCLAW_PATCH_SAMESIZE) { **ref_flag_ptr = 0; *fine_grid_pos_ptr = NULL; num_neighbors = 1; } - else if (neighbor_type == FCLAW2D_PATCH_DOUBLESIZE) + else if (neighbor_type == FCLAW_PATCH_DOUBLESIZE) { **ref_flag_ptr = -1; **fine_grid_pos_ptr = rproc[1]; /* Special storage for fine grid info */ num_neighbors = 1; } - else if (neighbor_type == FCLAW2D_PATCH_HALFSIZE) + else if (neighbor_type == FCLAW_PATCH_HALFSIZE) { /* Patch has two neighbors */ **ref_flag_ptr = 1; /* patches are at one level finer */ *fine_grid_pos_ptr = NULL; - num_neighbors = FCLAW2D_NUMFACENEIGHBORS; + num_neighbors = fclaw_domain_num_siblings(domain)/2; } else { - printf ("Illegal fclaw2d_patch_face_neighbors return value\n"); - exit (1); + fclaw_abortf ("Illegal fclaw2d_patch_face_neighbors return value\n"); } for(ir = 0; ir < num_neighbors; ir++) { - fclaw2d_patch_t *neighbor; + fclaw_patch_t *neighbor; if (rproc[ir] == domain->mpirank) { /* neighbor patch is local */ - fclaw2d_block_t *neighbor_block = &domain->blocks[rblockno]; + fclaw_block_t *neighbor_block = &domain->blocks[rblockno]; neighbor = &neighbor_block->patches[rpatchno[ir]]; } else @@ -192,66 +193,70 @@ void get_face_neighbors(fclaw2d_global_t *glob, /** * \ingroup Averaging **/ -void cb_face_fill(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, - int this_block_idx, - int this_patch_idx, - void *user) +void fclaw_face_fill_cb(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, + int this_block_idx, + int this_patch_idx, + void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; + const int num_faces = fclaw_domain_num_faces(domain); + + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; - fclaw2d_exchange_info_t *filltype = (fclaw2d_exchange_info_t*) s->user; + fclaw_exchange_info_t *filltype = (fclaw_exchange_info_t*) s->user; int time_interp = filltype->time_interp; - int is_coarse = filltype->grid_type == FCLAW2D_IS_COARSE; - int is_fine = filltype->grid_type == FCLAW2D_IS_FINE; + int is_coarse = filltype->grid_type == FCLAW_IS_COARSE; + int is_fine = filltype->grid_type == FCLAW_IS_FINE; int iface, igrid; int read_parallel_patches = filltype->read_parallel_patches; - int copy_from_neighbor = filltype->exchange_type == FCLAW2D_COPY; - int average_from_neighbor = filltype->exchange_type == FCLAW2D_AVERAGE; - int interpolate_to_neighbor = filltype->exchange_type == FCLAW2D_INTERPOLATE; + int copy_from_neighbor = filltype->exchange_type == FCLAW_COPY; + int average_from_neighbor = filltype->exchange_type == FCLAW_AVERAGE; + int interpolate_to_neighbor = filltype->exchange_type == FCLAW_INTERPOLATE; - int time_sync_fine_to_coarse = filltype->exchange_type == FCLAW2D_TIME_SYNC_F2C; - int time_sync_samesize = filltype->exchange_type == FCLAW2D_TIME_SYNC_SAMESIZE; + int time_sync_fine_to_coarse = filltype->exchange_type == FCLAW_TIME_SYNC_F2C; + int time_sync_samesize = filltype->exchange_type == FCLAW_TIME_SYNC_SAMESIZE; - const fclaw_options_t *gparms = fclaw2d_get_options(s->glob); + const fclaw_options_t *gparms = fclaw_get_options(s->glob); const int refratio = gparms->refratio; - int intersects_phys_bdry[FCLAW2D_NUMFACES]; - int intersects_block[FCLAW2D_NUMFACES]; + int intersects_phys_bdry[num_faces]; + int intersects_block[num_faces]; - fclaw2d_physical_get_bc(s->glob,this_block_idx,this_patch_idx, + fclaw_physical_get_bc(s->glob,this_block_idx,this_patch_idx, intersects_phys_bdry); - fclaw2d_block_get_block_boundary(s->glob, this_patch, intersects_block); + fclaw_block_get_block_boundary(s->glob, this_patch, intersects_block); /* Transform data needed at block boundaries */ - fclaw2d_patch_transform_data_t transform_data; + fclaw_patch_transform_data_t transform_data; + transform_data.glob = s->glob; transform_data.based = 1; /* Set by user defined patch routine */ transform_data.this_patch = this_patch; transform_data.neighbor_patch = NULL; /* gets filled in below. */ /* This calls a patch-specific initialization routine - does nothing yet. */ - fclaw2d_patch_transform_init_data(s->glob,this_patch, + fclaw_patch_transform_init_data(s->glob,this_patch, this_block_idx, this_patch_idx, &transform_data); - fclaw2d_patch_transform_data_t transform_data_finegrid; + fclaw_patch_transform_data_t transform_data_finegrid; + transform_data_finegrid.glob = s->glob; transform_data_finegrid.based = 1; /* cell-centered data in this routine. */ /* This calls a patch-specific initialization routine - does nothing yet. */ - fclaw2d_patch_transform_init_data(s->glob,this_patch, + fclaw_patch_transform_init_data(s->glob,this_patch, this_block_idx, this_patch_idx, &transform_data_finegrid); - for (iface = 0; iface < FCLAW2D_NUMFACES; iface++) + for (iface = 0; iface < num_faces; iface++) { int idir = iface/2; @@ -279,11 +284,11 @@ void cb_face_fill(fclaw2d_domain_t *domain, int iface_neighbor; int *iface_neighbor_ptr = &iface_neighbor; - fclaw2d_patch_t* neighbor_patches[FCLAW2D_NUMFACENEIGHBORS]; + fclaw_patch_t* neighbor_patches[num_faces]; /* Reset this in case it got set in a remote copy */ transform_data.this_patch = this_patch; - transform_data_finegrid.block_iface = -1; + transform_data.block_iface = -1; /* transform_data.block_iface = iface; */ get_face_neighbors(s->glob, @@ -314,22 +319,22 @@ void cb_face_fill(fclaw2d_domain_t *domain, /* Parallel distribution keeps siblings on same processor */ int remote_neighbor; - remote_neighbor = fclaw2d_patch_is_ghost(neighbor_patches[0]); + remote_neighbor = fclaw_patch_is_ghost(neighbor_patches[0]); if (is_coarse) { if (neighbor_level == FINER_GRID) { - for (igrid = 0; igrid < 2; igrid++) + for (igrid = 0; igrid < fclaw_domain_num_siblings(domain)/2; igrid++) { - remote_neighbor = fclaw2d_patch_is_ghost(neighbor_patches[igrid]); + remote_neighbor = fclaw_patch_is_ghost(neighbor_patches[igrid]); int valid_remote = read_parallel_patches && remote_neighbor; int local_neighbor = !remote_neighbor; if (!(local_neighbor || valid_remote)) { continue; } - fclaw2d_patch_t* fine_patch = neighbor_patches[igrid]; - fclaw2d_patch_t *coarse_patch = this_patch; + fclaw_patch_t* fine_patch = neighbor_patches[igrid]; + fclaw_patch_t *coarse_patch = this_patch; transform_data.neighbor_patch = neighbor_patches[igrid]; if (time_sync_fine_to_coarse) { @@ -338,7 +343,7 @@ void cb_face_fill(fclaw2d_domain_t *domain, int fine_blockno = neighbor_block_idx; /* Add correction to coarse grid from fine grid. */ - fclaw2d_patch_time_sync_f2c(s->glob,coarse_patch,fine_patch, + fclaw_patch_time_sync_f2c(s->glob,coarse_patch,fine_patch, coarse_blockno, fine_blockno, coarse_patchno, idir,igrid, @@ -348,16 +353,16 @@ void cb_face_fill(fclaw2d_domain_t *domain, else if (interpolate_to_neighbor && !remote_neighbor) { /* interpolate to igrid */ - fclaw2d_patch_interpolate_face(s->glob,this_patch,fine_patch, - idir,iface,FCLAW2D_REFINEFACTOR, + fclaw_patch_interpolate_face(s->glob,this_patch,fine_patch, + idir,iface,2, refratio,time_interp,igrid, &transform_data); } else if (average_from_neighbor) { /* average from igrid */ - fclaw2d_patch_average_face(s->glob,coarse_patch,fine_patch,idir, - iface,FCLAW2D_REFINEFACTOR, + fclaw_patch_average_face(s->glob,coarse_patch,fine_patch,idir, + iface,2, refratio,time_interp,igrid, &transform_data); } @@ -367,15 +372,15 @@ void cb_face_fill(fclaw2d_domain_t *domain, (copy_from_neighbor || time_sync_samesize)) { /* Copy to same size patch */ - fclaw2d_patch_t *neighbor_patch = neighbor_patches[0]; + fclaw_patch_t *neighbor_patch = neighbor_patches[0]; transform_data.neighbor_patch = neighbor_patch; if (time_sync_samesize) // && is_block_face) { /* Correct for metric discontinuities at block boundaries */ - if (!fclaw2d_patch_is_ghost(this_patch)) + if (!fclaw_patch_is_ghost(this_patch)) { - fclaw2d_patch_time_sync_samesize(s->glob,this_patch, + fclaw_patch_time_sync_samesize(s->glob,this_patch, neighbor_patch, iface,idir, &transform_data); @@ -383,7 +388,7 @@ void cb_face_fill(fclaw2d_domain_t *domain, } else { - fclaw2d_patch_copy_face(s->glob,this_patch,neighbor_patch,iface, + fclaw_patch_copy_face(s->glob,this_patch,neighbor_patch,iface, time_interp,&transform_data); } @@ -400,13 +405,13 @@ void cb_face_fill(fclaw2d_domain_t *domain, { /* Correct ghost patches, since these will be used to copy or interpolate to local grids. */ - fclaw2d_patch_time_sync_samesize(s->glob,neighbor_patch,this_patch, + fclaw_patch_time_sync_samesize(s->glob,neighbor_patch,this_patch, this_iface,idir, &transform_data_finegrid); } else { - fclaw2d_patch_copy_face(s->glob,neighbor_patch,this_patch, + fclaw_patch_copy_face(s->glob,neighbor_patch,this_patch, this_iface, time_interp, &transform_data_finegrid); } @@ -422,25 +427,25 @@ void cb_face_fill(fclaw2d_domain_t *domain, /* Swap 'this_patch' (fine grid) and the neighbor patch (a coarse grid) */ - fclaw2d_patch_t* coarse_patch = neighbor_patches[0]; - fclaw2d_patch_t* fine_patch = this_patch; + fclaw_patch_t* coarse_patch = neighbor_patches[0]; + fclaw_patch_t* fine_patch = this_patch; if (average_from_neighbor) { /* Average from 'this' grid (fine grid) to remote grid (coarse grid) */ - fclaw2d_patch_average_face(s->glob,coarse_patch,fine_patch, + fclaw_patch_average_face(s->glob,coarse_patch,fine_patch, idir_coarse,iface_coarse, - FCLAW2D_REFINEFACTOR,refratio, + 2,refratio, time_interp,igrid, &transform_data_finegrid); } else if (interpolate_to_neighbor) { /* Interpolate from remote neighbor to 'this' patch (the finer grid */ - fclaw2d_patch_interpolate_face(s->glob,coarse_patch,fine_patch, + fclaw_patch_interpolate_face(s->glob,coarse_patch,fine_patch, idir_coarse,iface_coarse, - FCLAW2D_REFINEFACTOR,refratio, + 2,refratio, time_interp, igrid,&transform_data_finegrid); } @@ -450,37 +455,36 @@ void cb_face_fill(fclaw2d_domain_t *domain, } -void fclaw2d_face_neighbor_ghost(fclaw2d_global_t* glob, +void fclaw_face_neighbor_ghost(fclaw_global_t* glob, int minlevel, int maxlevel, int time_interp) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; - fclaw2d_domain_data_t *ddata = fclaw2d_domain_get_data(domain); - const fclaw_options_t *gparms = fclaw2d_get_options(glob); + const fclaw_options_t *gparms = fclaw_get_options(glob); int refratio = gparms->refratio; - int rproc[2]; - int rpatchno[2]; + int rproc[4]; + int rpatchno[4]; int rblockno; int rfaceno; int i, iface, igrid; int min_interp_level = time_interp ? minlevel-1 : minlevel; - fclaw2d_patch_transform_data_t transform_data; + fclaw_patch_transform_data_t transform_data; + + transform_data.dim = domain->refine_dim; transform_data.glob = glob; transform_data.based = 1; /* cell-centered data in this routine. */ - fclaw2d_domain_indirect_t *ind = ddata->domain_indirect; - /* Loop over ghost patches to do any face exchanges that didn't happen before the ghost patch exchange was done */ for(i = 0; i < domain->num_ghost_patches; i++) { - fclaw2d_patch_t* this_ghost_patch = &domain->ghost_patches[i]; + fclaw_patch_t* this_ghost_patch = &domain->ghost_patches[i]; int level = this_ghost_patch->level; if (level < min_interp_level) { @@ -499,12 +503,13 @@ void fclaw2d_face_neighbor_ghost(fclaw2d_global_t* glob, int this_ghost_idx = i; transform_data.this_patch = this_ghost_patch; - fclaw2d_patch_transform_init_data(glob,this_ghost_patch, + fclaw_patch_transform_init_data(glob,this_ghost_patch, -1, i, &transform_data); - for (iface = 0; iface < FCLAW2D_NUMFACES; iface++) + const int num_faces = fclaw_domain_num_faces(domain); + for (iface = 0; iface < num_faces; iface++) { int idir = iface/2; @@ -512,62 +517,63 @@ void fclaw2d_face_neighbor_ghost(fclaw2d_global_t* glob, from different processors, since these will not have exchange face data before being thrown over proc fence. */ - fclaw2d_patch_relation_t neighbor_type = - fclaw2d_domain_indirect_face_neighbors(domain, - ind, - this_ghost_idx, - iface,rproc, - &rblockno, rpatchno, - &rfaceno); - - if (neighbor_type != FCLAW2D_PATCH_BOUNDARY) + fclaw_patch_relation_t neighbor_type = + fclaw_domain_indirect_face_neighbors(domain, + domain->indirect, + this_ghost_idx, + iface,rproc, + &rblockno, rpatchno, + &rfaceno); + + if (neighbor_type != FCLAW_PATCH_BOUNDARY) { /* We have a neighbor ghost patch that came from a different proc */ - int intersects_block[FCLAW2D_NUMFACES]; - fclaw2d_block_get_block_boundary(glob, this_ghost_patch, + int intersects_block[num_faces]; + fclaw_block_get_block_boundary(glob, this_ghost_patch, intersects_block); int is_block_face = intersects_block[iface]; - fclaw2d_patch_transform_blockface (glob, iface, rfaceno, + fclaw_patch_transform_blockface (glob, iface, rfaceno, transform_data.transform); if (!is_block_face) { - fclaw2d_patch_transform_blockface_intra(glob, transform_data.transform); + fclaw_patch_transform_blockface_intra(glob, transform_data.transform); } - if (neighbor_type == FCLAW2D_PATCH_SAMESIZE) + if (neighbor_type == FCLAW_PATCH_SAMESIZE) { /* Copy from same size neighbor */ - fclaw2d_patch_t *neighbor_patch = &domain->ghost_patches[rpatchno[0]]; + fclaw_patch_t *neighbor_patch = &domain->ghost_patches[rpatchno[0]]; transform_data.neighbor_patch = neighbor_patch; - fclaw2d_patch_copy_face(glob,this_ghost_patch,neighbor_patch,iface, + fclaw_patch_copy_face(glob,this_ghost_patch,neighbor_patch,iface, use_timeinterp_patch,&transform_data); ++glob->count_multiproc_corner; } - else if (neighbor_type == FCLAW2D_PATCH_HALFSIZE) + else if (neighbor_type == FCLAW_PATCH_HALFSIZE) { /* Average from fine grid neighbor */ - for (igrid = 0; igrid < FCLAW2D_NUMFACENEIGHBORS; igrid++) + int num_neighbors = fclaw_domain_num_siblings(domain)/2; + for (igrid = 0; igrid < num_neighbors; igrid++) { if (rpatchno[igrid] != -1) { - fclaw2d_patch_t* coarse_patch = this_ghost_patch; - fclaw2d_patch_t *fine_patch = + fclaw_patch_t* coarse_patch = this_ghost_patch; + fclaw_patch_t *fine_patch = &domain->ghost_patches[rpatchno[igrid]]; transform_data.neighbor_patch = fine_patch; - fclaw2d_patch_average_face(glob,coarse_patch,fine_patch, - idir,iface,FCLAW2D_REFINEFACTOR, + fclaw_patch_average_face(glob,coarse_patch,fine_patch, + idir,iface,2, refratio,use_timeinterp_patch, igrid,&transform_data); } } ++glob->count_multiproc_corner; } - else if (neighbor_type == FCLAW2D_PATCH_DOUBLESIZE) + else if (neighbor_type == FCLAW_PATCH_DOUBLESIZE) { /* Don't do anything; we don't need fine grid ghost cells on ghost patches. Proof : Consider the corners of the fine diff --git a/src/fclaw2d_face_neighbors.h b/src/fclaw_face_neighbors.h similarity index 79% rename from src/fclaw2d_face_neighbors.h rename to src/fclaw_face_neighbors.h index fb8405d4b..0eb815ce0 100644 --- a/src/fclaw2d_face_neighbors.h +++ b/src/fclaw_face_neighbors.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_FACE_NEIGHBORS_H -#define FCLAW2D_FACE_NEIGHBORS_H +#ifndef FCLAW_FACE_NEIGHBORS_H +#define FCLAW_FACE_NEIGHBORS_H #ifdef __cplusplus extern "C" @@ -34,18 +34,18 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_domain; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_domain; +struct fclaw_patch; -void cb_face_fill(struct fclaw2d_domain *domain, - struct fclaw2d_patch *this_patch, - int this_block_idx, - int this_patch_idx, - void *user); +void fclaw_face_fill_cb(struct fclaw_domain *domain, + struct fclaw_patch *this_patch, + int this_block_idx, + int this_patch_idx, + void *user); -void fclaw2d_face_neighbor_ghost(struct fclaw2d_global* glob, +void fclaw_face_neighbor_ghost(struct fclaw_global* glob, int minlevel, int maxlevel, int time_interp); diff --git a/src/fclaw2d_farraybox.cpp b/src/fclaw_farraybox.cpp similarity index 98% rename from src/fclaw2d_farraybox.cpp rename to src/fclaw_farraybox.cpp index bae4e07b6..639399aef 100644 --- a/src/fclaw2d_farraybox.cpp +++ b/src/fclaw_farraybox.cpp @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include /* Difference in nan values : The first one is not trapped; the second one is. @@ -64,7 +64,7 @@ void set_big_number(double& f) } -void fclaw2d_farraybox_set_to_nan(double& f) +void fclaw_farraybox_set_to_nan(double& f) { set_snan(f); } diff --git a/src/fclaw2d_farraybox.hpp b/src/fclaw_farraybox.hpp similarity index 95% rename from src/fclaw2d_farraybox.hpp rename to src/fclaw_farraybox.hpp index 79fabcdd8..641d9f9ed 100644 --- a/src/fclaw2d_farraybox.hpp +++ b/src/fclaw_farraybox.hpp @@ -23,13 +23,13 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_FARRAYBOX_H -#define FCLAW2D_FARRAYBOX_H +#ifndef FCLAW_FARRAYBOX_HPP +#define FCLAW_FARRAYBOX_HPP #include #include -void fclaw2d_farraybox_set_to_nan(double& f); +void fclaw_farraybox_set_to_nan(double& f); class Box { diff --git a/src/fclaw_filesystem.h b/src/fclaw_filesystem.h index f62b94dbd..4379961da 100644 --- a/src/fclaw_filesystem.h +++ b/src/fclaw_filesystem.h @@ -29,8 +29,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief functions for filesystem operations * */ -#ifndef FCLAW_FILESYSTEM -#define FCLAW_FILESYSTEM +#ifndef FCLAW_FILESYSTEM_H +#define FCLAW_FILESYSTEM_H #ifdef __cplusplus extern "C" diff --git a/src/fclaw2d_finalize.c b/src/fclaw_finalize.c similarity index 93% rename from src/fclaw2d_finalize.c rename to src/fclaw_finalize.c index 0985bb7bc..02f6d41c2 100644 --- a/src/fclaw2d_finalize.c +++ b/src/fclaw_finalize.c @@ -24,13 +24,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /** * This macro defines two utility functions for reading and writing CSV data of a specified type, @@ -116,7 +116,7 @@ DEFINE_READ_AND_WRITE(long int,long_int,ld) * @param[in] filename Name of the file containing the expected values for the regression tests. */ static void -output_expected_values(fclaw2d_global_t* glob, const char* filename) +output_expected_values(fclaw_global_t* glob, const char* filename) { if(glob->mpirank == 0) { @@ -167,16 +167,16 @@ output_expected_values(fclaw2d_global_t* glob, const char* filename) Public interface ---------------------------------------------------------------- */ -void fclaw2d_finalize(fclaw2d_global_t* glob) +void fclaw_finalize(fclaw_global_t* glob) { - const fclaw_options_t *gparms = fclaw2d_get_options(glob); + const fclaw_options_t *gparms = fclaw_get_options(glob); fclaw_global_essentialf("Finalizing run\n"); - fclaw2d_diagnostics_finalize(glob); + fclaw_diagnostics_finalize(glob); if (glob->cont != NULL) { - fclaw2d_map_destroy(glob->cont); + fclaw_map_destroy(glob->cont); } - fclaw2d_domain_barrier (glob->domain); + fclaw_domain_barrier (glob->domain); if (gparms->report_timing) { @@ -197,5 +197,5 @@ void fclaw2d_finalize(fclaw2d_global_t* glob) output_expected_values(glob, gparms->regression_check); fclaw_global_essentialf("Regression check passed.\n"); } - fclaw2d_domain_reset(glob); + fclaw_domain_reset(glob); } diff --git a/src/fclaw2d_forestclaw.c b/src/fclaw_forestclaw.c similarity index 68% rename from src/fclaw2d_forestclaw.c rename to src/fclaw_forestclaw.c index 7331dfc91..93fc51864 100644 --- a/src/fclaw2d_forestclaw.c +++ b/src/fclaw_forestclaw.c @@ -23,34 +23,34 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include +#include -#include +#include -void fclaw2d_vtables_initialize(fclaw2d_global_t *glob) +void fclaw_vtables_initialize(fclaw_global_t *glob) { - fclaw2d_vtable_initialize(glob); - fclaw2d_patch_vtable_initialize(glob); - fclaw2d_diagnostics_vtable_initialize(glob); - fclaw2d_elliptic_vtable_initialize(glob); + fclaw_vtable_initialize(glob); + fclaw_patch_vtable_initialize(glob); + fclaw_diagnostics_vtable_initialize(glob); + fclaw_elliptic_vtable_initialize(glob); fclaw_gauges_vtable_initialize(glob); - fclaw2d_ray_vtable_initialize(glob); + fclaw_ray_vtable_initialize(glob); } -void fclaw2d_problem_setup(fclaw2d_global_t *glob) +void fclaw_problem_setup(fclaw_global_t *glob) { - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); + fclaw_vtable_t *fc_vt = fclaw_vt(glob); /* User defined problem setup */ - if (fclaw_vt->problem_setup != NULL) + if (fc_vt->problem_setup != NULL) { - fclaw_vt->problem_setup(glob); + fc_vt->problem_setup(glob); } } diff --git a/src/fclaw2d_forestclaw.h b/src/fclaw_forestclaw.h similarity index 82% rename from src/fclaw2d_forestclaw.h rename to src/fclaw_forestclaw.h index 23914b1ef..ac4b143c0 100644 --- a/src/fclaw2d_forestclaw.h +++ b/src/fclaw_forestclaw.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_FORESTCLAW_H -#define FCLAW2D_FORESTCLAW_H +#ifndef FCLAW_FORESTCLAW_H +#define FCLAW_FORESTCLAW_H #ifdef __cplusplus extern "C" @@ -34,14 +34,14 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; -void fclaw2d_problem_setup(struct fclaw2d_global *glob); -void fclaw2d_vtables_initialize(struct fclaw2d_global *glob); +void fclaw_problem_setup(struct fclaw_global *glob); +void fclaw_vtables_initialize(struct fclaw_global *glob); -void fclaw2d_initialize (struct fclaw2d_global *glob); -void fclaw2d_run (struct fclaw2d_global *glob); -void fclaw2d_finalize(struct fclaw2d_global *glob); +void fclaw_initialize (struct fclaw_global *glob); +void fclaw_run (struct fclaw_global *glob); +void fclaw_finalize(struct fclaw_global *glob); #ifdef __cplusplus #if 0 diff --git a/src/fclaw_gauges.c b/src/fclaw_gauges.c index dc772f08e..48cf234ce 100644 --- a/src/fclaw_gauges.c +++ b/src/fclaw_gauges.c @@ -27,15 +27,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include -#include -#include /* Needed to get search function for gauges */ -#include +#include +#include +#include /* Needed to get search function for gauges */ +#include /* Some mapping functions */ -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" @@ -61,9 +61,9 @@ typedef struct fclaw_gauge_info static -void gauge_initialize(fclaw2d_global_t* glob, void** acc) +void gauge_initialize(fclaw_global_t* glob, void** acc) { - const fclaw_options_t * fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t * fclaw_opt = fclaw_get_options(glob); /* ------------------------------------------------------------------ These two calls are the only calls that should worry about the format @@ -127,7 +127,7 @@ void gauge_initialize(fclaw2d_global_t* glob, void** acc) ----------------------------------------------------- */ - fclaw2d_map_context_t* cont = glob->cont; + fclaw_map_context_t* cont = glob->cont; int num_blocks = glob->domain->num_blocks; @@ -142,11 +142,11 @@ void gauge_initialize(fclaw2d_global_t* glob, void** acc) double x1 = 1; double y1 = 1; - int is_brick = FCLAW2D_MAP_IS_BRICK(&cont); + int is_brick = FCLAW_MAP_IS_BRICK(&cont); int mi = fclaw_opt->mi; int mj = fclaw_opt->mj; - fclaw2d_block_t *blocks = glob->domain->blocks; + fclaw_block_t *blocks = glob->domain->blocks; int number_of_gauges_set = 0; int *bo = (int*) sc_array_index_int(glob->gauge_info->block_offsets,0); @@ -155,7 +155,7 @@ void gauge_initialize(fclaw2d_global_t* glob, void** acc) double xll,yll, xur, yur; for (int nb = 0; nb < num_blocks; nb++) { - fclaw2d_block_t *block = &blocks[nb]; + fclaw_block_t *block = &blocks[nb]; if (is_brick) { /* Scale local block coordinates to global @@ -170,8 +170,8 @@ void gauge_initialize(fclaw2d_global_t* glob, void** acc) brick grid */ double z; - fclaw2d_map_c2m_nomap_brick(cont,nb,x0,y0,&xll,&yll,&z); - fclaw2d_map_c2m_nomap_brick(cont,nb,x1,y1,&xur,&yur,&z); + fclaw_map_2d_c2m_nomap_brick(cont,nb,x0,y0,&xll,&yll,&z); + fclaw_map_2d_c2m_nomap_brick(cont,nb,x1,y1,&xur,&yur,&z); } else { @@ -217,16 +217,16 @@ void gauge_initialize(fclaw2d_global_t* glob, void** acc) static -void gauge_update(fclaw2d_global_t *glob, void* acc) +void gauge_update(fclaw_global_t *glob, void* acc) { double tcurr; int i, num_gauges; - fclaw2d_block_t *block; - fclaw2d_patch_t *patch; + fclaw_block_t *block; + fclaw_patch_t *patch; fclaw_gauge_t *g; - const fclaw_options_t * fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t * fclaw_opt = fclaw_get_options(glob); fclaw_gauge_acc_t* gauge_acc = (fclaw_gauge_acc_t*) acc; fclaw_gauge_t *gauges = gauge_acc->gauges; @@ -274,7 +274,7 @@ void gauge_update(fclaw2d_global_t *glob, void* acc) } -void fclaw_locate_gauges(fclaw2d_global_t *glob) +void fclaw_locate_gauges(fclaw_global_t *glob) { int i,index,num; fclaw_gauge_t *g; @@ -293,7 +293,7 @@ void fclaw_locate_gauges(fclaw2d_global_t *glob) sc_array_t *results = sc_array_new_size(sizeof(int), num); - fclaw2d_domain_search_points(glob->domain, + fclaw_domain_search_points(glob->domain, glob->gauge_info->block_offsets, glob->gauge_info->coordinates, results); @@ -323,7 +323,7 @@ void fclaw_locate_gauges(fclaw2d_global_t *glob) } static -void gauge_finalize(fclaw2d_global_t *glob, void** acc) +void gauge_finalize(fclaw_global_t *glob, void** acc) { /* Clean up gauges and print anything left over in buffers */ fclaw_gauge_acc_t* gauge_acc = *((fclaw_gauge_acc_t**) acc); @@ -377,7 +377,7 @@ void fclaw_gauges_vt_destroy(void* vt) FCLAW_FREE (vt); } -fclaw_gauges_vtable_t* fclaw_gauges_vt(fclaw2d_global_t* glob) +fclaw_gauges_vtable_t* fclaw_gauges_vt(fclaw_global_t* glob) { fclaw_gauges_vtable_t* gauges_vt = (fclaw_gauges_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fclaw_gauges"); @@ -387,9 +387,9 @@ fclaw_gauges_vtable_t* fclaw_gauges_vt(fclaw2d_global_t* glob) return gauges_vt; } -void fclaw_gauges_vtable_initialize(fclaw2d_global_t* glob) +void fclaw_gauges_vtable_initialize(fclaw_global_t* glob) { - fclaw2d_diagnostics_vtable_t * diag_vt = fclaw2d_diagnostics_vt(glob); + fclaw_diagnostics_vtable_t * diag_vt = fclaw_diagnostics_vt(glob); fclaw_gauges_vtable_t* gauges_vt = fclaw_gauges_vt_new(); @@ -404,7 +404,7 @@ void fclaw_gauges_vtable_initialize(fclaw2d_global_t* glob) } /* ---------------------------- Virtualized Functions --------------------------------- */ -void fclaw_set_gauge_data(fclaw2d_global_t* glob, +void fclaw_set_gauge_data(fclaw_global_t* glob, fclaw_gauge_t **gauges, int *num_gauges) { @@ -420,7 +420,7 @@ void fclaw_set_gauge_data(fclaw2d_global_t* glob, } } -void fclaw_create_gauge_files(fclaw2d_global_t* glob, +void fclaw_create_gauge_files(fclaw_global_t* glob, fclaw_gauge_t *gauges, int num_gauges) { @@ -430,8 +430,8 @@ void fclaw_create_gauge_files(fclaw2d_global_t* glob, } -void fclaw_gauge_normalize_coordinates(fclaw2d_global_t *glob, - fclaw2d_block_t *block, +void fclaw_gauge_normalize_coordinates(fclaw_global_t *glob, + fclaw_block_t *block, int blockno, fclaw_gauge_t *g, double *xc, double *yc) @@ -442,9 +442,9 @@ void fclaw_gauge_normalize_coordinates(fclaw2d_global_t *glob, } -void fclaw_update_gauge(fclaw2d_global_t* glob, - fclaw2d_block_t *block, - fclaw2d_patch_t *patch, +void fclaw_update_gauge(fclaw_global_t* glob, + fclaw_block_t *block, + fclaw_patch_t *patch, int blockno, int patchno, double tcurr, fclaw_gauge_t *g) { @@ -454,7 +454,7 @@ void fclaw_update_gauge(fclaw2d_global_t* glob, gauge_vt->update_gauge(glob,block,patch,blockno,patchno,tcurr,g); } -void fclaw_print_gauge_buffer(fclaw2d_global_t* glob, fclaw_gauge_t *g) +void fclaw_print_gauge_buffer(fclaw_global_t* glob, fclaw_gauge_t *g) { const fclaw_gauges_vtable_t* gauge_vt = fclaw_gauges_vt(glob); FCLAW_ASSERT(gauge_vt->print_gauge_buffer != NULL); @@ -464,13 +464,13 @@ void fclaw_print_gauge_buffer(fclaw2d_global_t* glob, fclaw_gauge_t *g) /* ---------------------------- Get Access Functions ---------------------------------- */ -void fclaw_gauge_allocate(fclaw2d_global_t *glob, int num_gauges, +void fclaw_gauge_allocate(fclaw_global_t *glob, int num_gauges, fclaw_gauge_t **g) { *g = (fclaw_gauge_t*) FCLAW_ALLOC(fclaw_gauge_t,num_gauges); } -void fclaw_gauge_set_data(fclaw2d_global_t *glob, +void fclaw_gauge_set_data(fclaw_global_t *glob, fclaw_gauge_t *g, int num, double xc, double yc, double t1, double t2, @@ -486,7 +486,7 @@ void fclaw_gauge_set_data(fclaw2d_global_t *glob, -void fclaw_gauge_get_data(fclaw2d_global_t *glob, +void fclaw_gauge_get_data(fclaw_global_t *glob, fclaw_gauge_t *g, int *num, double *xc, double *yc, @@ -499,14 +499,14 @@ void fclaw_gauge_get_data(fclaw2d_global_t *glob, *t2 = g->t2; } -int fclaw_gauge_get_id(fclaw2d_global_t *glob, +int fclaw_gauge_get_id(fclaw_global_t *glob, fclaw_gauge_t *g) { return g->num; } -void fclaw_gauge_get_buffer(fclaw2d_global_t *glob, +void fclaw_gauge_get_buffer(fclaw_global_t *glob, fclaw_gauge_t *g, int *kmax, void*** gauge_buffer) { @@ -514,7 +514,7 @@ void fclaw_gauge_get_buffer(fclaw2d_global_t *glob, *gauge_buffer = g->buffer; } -void fclaw_gauge_set_buffer_entry(fclaw2d_global_t *glob, +void fclaw_gauge_set_buffer_entry(fclaw_global_t *glob, fclaw_gauge_t* g, void* guser) { @@ -522,14 +522,14 @@ void fclaw_gauge_set_buffer_entry(fclaw2d_global_t *glob, g->buffer[k] = guser; } -void fclaw_gauge_set_user_data(fclaw2d_global_t *glob, +void fclaw_gauge_set_user_data(fclaw_global_t *glob, fclaw_gauge_t* g, void* user) { g->user_data = user; } -void* fclaw_gauge_get_user_data(fclaw2d_global_t *glob, +void* fclaw_gauge_get_user_data(fclaw_global_t *glob, fclaw_gauge_t* g) { return g->user_data; diff --git a/src/fclaw_gauges.h b/src/fclaw_gauges.h index d08468e18..9b8fd0754 100644 --- a/src/fclaw_gauges.h +++ b/src/fclaw_gauges.h @@ -86,9 +86,9 @@ typedef struct fclaw_gauge } fclaw_gauge_t; -struct fclaw2d_global; -struct fclaw2d_patch; -struct fclaw2d_block; +struct fclaw_global; +struct fclaw_patch; +struct fclaw_block; struct fclaw_gauge; /** @@ -98,7 +98,7 @@ struct fclaw_gauge; * @param[in,out] gauges the array of gauges * @param[in] num_gauges the number of gauges */ -typedef void (*fclaw_gauge_set_data_t)(struct fclaw2d_global *glob, +typedef void (*fclaw_gauge_set_data_t)(struct fclaw_global *glob, struct fclaw_gauge **gauges, int *num); @@ -109,7 +109,7 @@ typedef void (*fclaw_gauge_set_data_t)(struct fclaw2d_global *glob, * @param[in] gauges the array of gauges * @param[in] num_gauges the number of gauges */ -typedef void (*fclaw_gauge_create_files_t)(struct fclaw2d_global *glob, +typedef void (*fclaw_gauge_create_files_t)(struct fclaw_global *glob, struct fclaw_gauge *gauges, int num_gauges); @@ -122,8 +122,8 @@ typedef void (*fclaw_gauge_create_files_t)(struct fclaw2d_global *glob, * @param[in] g the gauge * @param[out] xc,yc the normalized coordinates */ -typedef void (*fclaw_gauge_normalize_t)(struct fclaw2d_global *glob, - struct fclaw2d_block *block, +typedef void (*fclaw_gauge_normalize_t)(struct fclaw_global *glob, + struct fclaw_block *block, int blockno, struct fclaw_gauge *g, double *xc, double *yc); @@ -139,9 +139,9 @@ typedef void (*fclaw_gauge_normalize_t)(struct fclaw2d_global *glob, * @param[in] tcurr the current time * @param[in,out] g the gauge */ -typedef void (*fclaw_gauge_update_t)(struct fclaw2d_global* glob, - struct fclaw2d_block* block, - struct fclaw2d_patch* patch, +typedef void (*fclaw_gauge_update_t)(struct fclaw_global* glob, + struct fclaw_block* block, + struct fclaw_patch* patch, int blockno, int patchno, double tcurr, struct fclaw_gauge *g); @@ -151,7 +151,7 @@ typedef void (*fclaw_gauge_update_t)(struct fclaw2d_global* glob, * @param glob the global context * @param g the gauge */ -typedef void (*fclaw_gauge_print_t)(struct fclaw2d_global *glob, +typedef void (*fclaw_gauge_print_t)(struct fclaw_global *glob, struct fclaw_gauge *gauge); /** @@ -180,14 +180,14 @@ typedef struct fclaw_gauges_vtable * * @param glob the global context */ -void fclaw_locate_gauges(struct fclaw2d_global *glob); +void fclaw_locate_gauges(struct fclaw_global *glob); /** * @brief Initialize the gauges vtable * * @param glob the global context */ -void fclaw_gauges_vtable_initialize(struct fclaw2d_global *glob); +void fclaw_gauges_vtable_initialize(struct fclaw_global *glob); /** * @brief Get the gauges vtable @@ -195,7 +195,7 @@ void fclaw_gauges_vtable_initialize(struct fclaw2d_global *glob); * @param glob the global context * @return fclaw_gauges_vtable_t* the vtable */ -fclaw_gauges_vtable_t* fclaw_gauges_vt(struct fclaw2d_global *glob); +fclaw_gauges_vtable_t* fclaw_gauges_vt(struct fclaw_global *glob); @@ -208,7 +208,7 @@ fclaw_gauges_vtable_t* fclaw_gauges_vt(struct fclaw2d_global *glob); * @param gauges the array of gauges * @param num_gauges the number of gauges */ -void fclaw_set_gauge_data(struct fclaw2d_global* glob, +void fclaw_set_gauge_data(struct fclaw_global* glob, struct fclaw_gauge **gauges, int *num_gauges); @@ -219,7 +219,7 @@ void fclaw_set_gauge_data(struct fclaw2d_global* glob, * @param[in] gauges the array of gauges * @param[in] num_gauges the number of gauges */ -void fclaw_create_gauge_files(struct fclaw2d_global* glob, +void fclaw_create_gauge_files(struct fclaw_global* glob, struct fclaw_gauge *gauges, int num_gauges); @@ -232,8 +232,8 @@ void fclaw_create_gauge_files(struct fclaw2d_global* glob, * @param[in] g the gauge * @param[out] xc,yc the normalized coordinates */ -void fclaw_gauge_normalize_coordinates(struct fclaw2d_global *glob, - struct fclaw2d_block *block, +void fclaw_gauge_normalize_coordinates(struct fclaw_global *glob, + struct fclaw_block *block, int blockno, struct fclaw_gauge *g, double *xc, double *yc); @@ -249,9 +249,9 @@ void fclaw_gauge_normalize_coordinates(struct fclaw2d_global *glob, * @param[in] tcurr the current time * @param[in,out] g the gauge */ -void fclaw_update_gauge(struct fclaw2d_global* glob, - struct fclaw2d_block *block, - struct fclaw2d_patch *patch, +void fclaw_update_gauge(struct fclaw_global* glob, + struct fclaw_block *block, + struct fclaw_patch *patch, int blockno, int patchno, double tcurr, fclaw_gauge_t *g); @@ -261,7 +261,7 @@ void fclaw_update_gauge(struct fclaw2d_global* glob, * @param glob the global context * @param g the gauge */ -void fclaw_print_gauge_buffer(struct fclaw2d_global* glob, +void fclaw_print_gauge_buffer(struct fclaw_global* glob, struct fclaw_gauge *g); @@ -274,7 +274,7 @@ void fclaw_print_gauge_buffer(struct fclaw2d_global* glob, * @param[in] num_gauges the number of gauges * @param[out] g allocated array of gauges */ -void fclaw_gauge_allocate(struct fclaw2d_global *glob, int num_gauges, +void fclaw_gauge_allocate(struct fclaw_global *glob, int num_gauges, struct fclaw_gauge **g); /** @@ -288,7 +288,7 @@ void fclaw_gauge_allocate(struct fclaw2d_global *glob, int num_gauges, * @param[in] t2 Tend * @param[in] min_time_increment How often to output the gauge */ -void fclaw_gauge_set_data(struct fclaw2d_global *glob, +void fclaw_gauge_set_data(struct fclaw_global *glob, struct fclaw_gauge *g, int num, double xc, double yc, @@ -305,7 +305,7 @@ void fclaw_gauge_set_data(struct fclaw2d_global *glob, * @param[out] t1 Tstart * @param[out] t2 Tend */ -void fclaw_gauge_get_data(struct fclaw2d_global *glob, +void fclaw_gauge_get_data(struct fclaw_global *glob, struct fclaw_gauge *g, int *num, double *xc, double *yc, @@ -318,7 +318,7 @@ void fclaw_gauge_get_data(struct fclaw2d_global *glob, * @param g the gauge * @return int the gauge number */ -int fclaw_gauge_get_id(struct fclaw2d_global *glob, +int fclaw_gauge_get_id(struct fclaw_global *glob, struct fclaw_gauge *g); /** @@ -328,7 +328,7 @@ int fclaw_gauge_get_id(struct fclaw2d_global *glob, * @param g the gauge * @param guser the data */ -void fclaw_gauge_set_buffer_entry(struct fclaw2d_global *glob, +void fclaw_gauge_set_buffer_entry(struct fclaw_global *glob, struct fclaw_gauge* g, void* guser); @@ -340,7 +340,7 @@ void fclaw_gauge_set_buffer_entry(struct fclaw2d_global *glob, * @param[out] kmax size of buffer * @param[out] gauge_buffer the buffer */ -void fclaw_gauge_get_buffer(struct fclaw2d_global *glob, +void fclaw_gauge_get_buffer(struct fclaw_global *glob, struct fclaw_gauge *g, int *kmax, void*** gauge_buffer); @@ -351,7 +351,7 @@ void fclaw_gauge_get_buffer(struct fclaw2d_global *glob, * @param[in] g the gauge * @param[in] user the user data */ -void fclaw_gauge_set_user_data(struct fclaw2d_global *glob, +void fclaw_gauge_set_user_data(struct fclaw_global *glob, struct fclaw_gauge* g, void* user); @@ -362,7 +362,7 @@ void fclaw_gauge_set_user_data(struct fclaw2d_global *glob, * @param g the gauge * @return void* the user data */ -void* fclaw_gauge_get_user_data(struct fclaw2d_global *glob, +void* fclaw_gauge_get_user_data(struct fclaw_global *glob, struct fclaw_gauge* g); diff --git a/src/fclaw_gauges.h.TEST.cpp b/src/fclaw_gauges.h.TEST.cpp index 16ca42e6b..845e4c8d3 100644 --- a/src/fclaw_gauges.h.TEST.cpp +++ b/src/fclaw_gauges.h.TEST.cpp @@ -24,56 +24,56 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include -#include +#include +#include #include TEST_CASE("fclaw_gauges_vtable_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); - fclaw2d_diagnostics_vtable_initialize(glob1); + fclaw_diagnostics_vtable_initialize(glob1); fclaw_gauges_vtable_initialize(glob1); - fclaw2d_diagnostics_vtable_initialize(glob2); + fclaw_diagnostics_vtable_initialize(glob2); fclaw_gauges_vtable_initialize(glob2); CHECK_NE(fclaw_gauges_vt(glob1), fclaw_gauges_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fclaw_gauges_vtable_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_global_t* glob = fclaw_global_new(); - fclaw2d_diagnostics_vtable_initialize(glob); + fclaw_diagnostics_vtable_initialize(glob); fclaw_gauges_vtable_initialize(glob); CHECK_UNARY(fclaw_gauges_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fclaw_guages_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); - fclaw2d_diagnostics_vtable_initialize(glob1); + fclaw_diagnostics_vtable_initialize(glob1); fclaw_gauges_vtable_initialize(glob1); CHECK_SC_ABORTED(fclaw_gauges_vtable_initialize(glob1)); - fclaw2d_diagnostics_vtable_initialize(glob2); + fclaw_diagnostics_vtable_initialize(glob2); fclaw_gauges_vtable_initialize(glob2); CHECK_SC_ABORTED(fclaw_gauges_vtable_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/fclaw2d_ghost_fill.c b/src/fclaw_ghost_fill.c similarity index 73% rename from src/fclaw2d_ghost_fill.c rename to src/fclaw_ghost_fill.c index 3c17e2091..67c63d1e4 100644 --- a/src/fclaw2d_ghost_fill.c +++ b/src/fclaw_ghost_fill.c @@ -65,17 +65,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ -#include -#include -#include +#include +#include +#include +#include -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* ------------------------------------------------- @@ -86,25 +87,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. typedef struct fclaw2d_ghost_fill_wrap_info { - fclaw2d_ghost_fill_parallel_mode_t ghost_mode; - fclaw2d_patch_callback_t cb_fill; + fclaw_ghost_fill_parallel_mode_t ghost_mode; + fclaw_patch_callback_t cb_fill; void *user; } fclaw2d_ghost_fill_wrap_info_t; -static void cb_parallel_wrap(fclaw2d_domain_t* domain, - fclaw2d_patch_t* this_patch, +static void cb_parallel_wrap(fclaw_domain_t* domain, + fclaw_patch_t* this_patch, int this_block_idx, int this_patch_idx, void *user); -static void cb_interface_wrap(fclaw2d_domain_t* domain, - fclaw2d_patch_t* this_patch, +static void cb_interface_wrap(fclaw_domain_t* domain, + fclaw_patch_t* this_patch, int this_block_idx, int this_patch_idx, void *user) { - if (fclaw2d_patch_on_coarsefine_interface(this_patch)) + if (fclaw_patch_on_coarsefine_interface(this_patch)) { cb_parallel_wrap(domain, this_patch, @@ -118,21 +119,21 @@ static void cb_interface_wrap(fclaw2d_domain_t* domain, patches on the parallel boundary only, or on interior patches. */ /* Passing in a function pointer is somehow slower ... */ -static void cb_parallel_wrap(fclaw2d_domain_t* domain, - fclaw2d_patch_t* this_patch, +static void cb_parallel_wrap(fclaw_domain_t* domain, + fclaw_patch_t* this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; fclaw2d_ghost_fill_wrap_info_t w = *((fclaw2d_ghost_fill_wrap_info_t*) s->user); - int on_boundary = fclaw2d_patch_on_parallel_boundary(this_patch); - if (((w.ghost_mode == FCLAW2D_BOUNDARY_GHOST_ONLY) && on_boundary) || - ((w.ghost_mode == FCLAW2D_BOUNDARY_INTERIOR_ONLY) && !on_boundary) || - w.ghost_mode == FCLAW2D_BOUNDARY_ALL) + int on_boundary = fclaw_patch_on_parallel_boundary(this_patch); + if (((w.ghost_mode == FCLAW_BOUNDARY_GHOST_ONLY) && on_boundary) || + ((w.ghost_mode == FCLAW_BOUNDARY_INTERIOR_ONLY) && !on_boundary) || + w.ghost_mode == FCLAW_BOUNDARY_ALL) { - fclaw2d_global_iterate_t g; + fclaw_global_iterate_t g; g.glob = s->glob; g.user = w.user; @@ -142,73 +143,90 @@ static void cb_parallel_wrap(fclaw2d_domain_t* domain, static -void copy2ghost(fclaw2d_global_t *glob, +void copy2ghost(fclaw_global_t *glob, int level, int time_interp, int read_parallel_patches, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { struct fclaw2d_ghost_fill_wrap_info parallel_mode; - fclaw2d_exchange_info_t e_info; - e_info.exchange_type = FCLAW2D_COPY; - e_info.grid_type = FCLAW2D_IS_COARSE; + fclaw_exchange_info_t e_info; + e_info.exchange_type = FCLAW_COPY; + e_info.grid_type = FCLAW_IS_COARSE; e_info.time_interp = time_interp; e_info.read_parallel_patches = read_parallel_patches; parallel_mode.ghost_mode = ghost_mode; parallel_mode.user = (void*) &e_info; - parallel_mode.cb_fill = cb_face_fill; - fclaw2d_global_iterate_level(glob, level, cb_parallel_wrap, + parallel_mode.cb_fill = fclaw_face_fill_cb; + fclaw_global_iterate_level(glob, level, cb_parallel_wrap, (void *) ¶llel_mode); + + if(glob->domain->refine_dim == 3) + { + /* edge exchanges */ + parallel_mode.cb_fill = fclaw_edge_fill_cb; + fclaw_global_iterate_level(glob, level, cb_parallel_wrap, + (void *) ¶llel_mode); + } + /* corner exchanges */ - parallel_mode.cb_fill = cb_corner_fill; - fclaw2d_global_iterate_level(glob, level, cb_parallel_wrap, + parallel_mode.cb_fill = fclaw_corner_fill_cb; + fclaw_global_iterate_level(glob, level, cb_parallel_wrap, (void *) ¶llel_mode); } static -void average2ghost(fclaw2d_global_t *glob, +void average2ghost(fclaw_global_t *glob, int coarse_level, int time_interp, int read_parallel_patches, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { fclaw2d_ghost_fill_wrap_info_t parallel_mode; - fclaw2d_exchange_info_t e_info; + fclaw_exchange_info_t e_info; e_info.time_interp = time_interp; /* Does this matter here? */ e_info.read_parallel_patches = read_parallel_patches; - e_info.exchange_type = FCLAW2D_AVERAGE; + e_info.exchange_type = FCLAW_AVERAGE; e_info.has_fine_grid_neighbor = 0; /* Only update ghost cells at local boundaries */ - e_info.grid_type = FCLAW2D_IS_COARSE; + e_info.grid_type = FCLAW_IS_COARSE; parallel_mode.user = (void*) &e_info; parallel_mode.ghost_mode = ghost_mode; - parallel_mode.cb_fill = cb_face_fill; - fclaw2d_global_iterate_level(glob, coarse_level, + parallel_mode.cb_fill = fclaw_face_fill_cb; + fclaw_global_iterate_level(glob, coarse_level, cb_interface_wrap, (void *) ¶llel_mode); + if(glob->domain->refine_dim ==3) + { + /* Edge average */ + parallel_mode.cb_fill = fclaw_edge_fill_cb; + fclaw_global_iterate_level(glob, coarse_level, cb_interface_wrap, + (void *) ¶llel_mode); + } + /* Corner average */ - parallel_mode.cb_fill = cb_corner_fill; - fclaw2d_global_iterate_level(glob, coarse_level, cb_interface_wrap, + parallel_mode.cb_fill = fclaw_corner_fill_cb; + fclaw_global_iterate_level(glob, coarse_level, cb_interface_wrap, (void *) ¶llel_mode); if (read_parallel_patches) { /* Second pass : average from local fine grids to remote coarse grids. These coarse grids might be needed for interpolation later. */ - e_info.grid_type = FCLAW2D_IS_FINE; + e_info.grid_type = FCLAW_IS_FINE; int fine_level = coarse_level + 1; /* Face average */ - parallel_mode.cb_fill = cb_face_fill; - fclaw2d_global_iterate_level(glob, fine_level, + parallel_mode.cb_fill = fclaw_face_fill_cb; + fclaw_global_iterate_level(glob, fine_level, cb_interface_wrap, (void *) ¶llel_mode); /* Corner average : @@ -223,40 +241,48 @@ void average2ghost(fclaw2d_global_t *glob, } static -void interpolate2ghost(fclaw2d_global_t *glob, +void interpolate2ghost(fclaw_global_t *glob, int coarse_level, int time_interp, int read_parallal_patches, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { struct fclaw2d_ghost_fill_wrap_info parallel_mode; - fclaw2d_exchange_info_t e_info; + fclaw_exchange_info_t e_info; e_info.time_interp = time_interp; #if 0 e_info.level = coarse_level; #endif e_info.level = -1; - e_info.exchange_type = FCLAW2D_INTERPOLATE; + e_info.exchange_type = FCLAW_INTERPOLATE; /* ---------------------------------------------------------- First pass - look for fine grids to interpolate to. This should include include the time interpolated level. ---------------------------------------------------------- */ - e_info.grid_type = FCLAW2D_IS_COARSE; + e_info.grid_type = FCLAW_IS_COARSE; e_info.read_parallel_patches = read_parallal_patches; parallel_mode.ghost_mode = ghost_mode; parallel_mode.user = (void*) &e_info; /* Face interpolate */ - parallel_mode.cb_fill = cb_face_fill; - fclaw2d_global_iterate_level(glob,coarse_level, cb_interface_wrap, + parallel_mode.cb_fill = fclaw_face_fill_cb; + fclaw_global_iterate_level(glob,coarse_level, cb_interface_wrap, (void *) ¶llel_mode); + if(glob->domain->refine_dim ==3) + { + /* Edge interpolate */ + parallel_mode.cb_fill = fclaw_edge_fill_cb; + fclaw_global_iterate_level(glob, coarse_level, cb_interface_wrap, + (void *) ¶llel_mode); + } + /* Corner interpolate */ - parallel_mode.cb_fill = cb_corner_fill; - fclaw2d_global_iterate_level(glob,coarse_level, cb_interface_wrap, + parallel_mode.cb_fill = fclaw_corner_fill_cb; + fclaw_global_iterate_level(glob,coarse_level, cb_interface_wrap, (void *) ¶llel_mode); /* ----------------------------------------------------- Second pass - Iterate over local fine grids, looking @@ -264,42 +290,51 @@ void interpolate2ghost(fclaw2d_global_t *glob, fine grid ghost cells along the parallel boundary ----------------------------------------------------- */ - e_info.grid_type = FCLAW2D_IS_FINE; + e_info.grid_type = FCLAW_IS_FINE; /* Interpolate to faces at parallel boundaries from coarse grid ghost patches */ int fine_level = coarse_level + 1; - parallel_mode.cb_fill = cb_face_fill; - fclaw2d_global_iterate_level(glob, fine_level, cb_interface_wrap, + parallel_mode.cb_fill = fclaw_face_fill_cb; + fclaw_global_iterate_level(glob, fine_level, cb_interface_wrap, (void *) ¶llel_mode); + if(glob->domain->refine_dim == 3) + { + /* Interpolate to edges at parallel boundaries from coarse grid + ghost patches */ + parallel_mode.cb_fill = fclaw_edge_fill_cb; + fclaw_global_iterate_level(glob, fine_level, cb_interface_wrap, + (void *) ¶llel_mode); + } + /* Interpolate to corners at parallel boundaries from coarse grid ghost patches */ - parallel_mode.cb_fill = cb_corner_fill; - fclaw2d_global_iterate_level(glob, fine_level, cb_interface_wrap, + parallel_mode.cb_fill = fclaw_corner_fill_cb; + fclaw_global_iterate_level(glob, fine_level, cb_interface_wrap, (void *) ¶llel_mode); } static -void setphysical(fclaw2d_global_t *glob, +void setphysical(fclaw_global_t *glob, int level, double sync_time, int time_interp, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { struct fclaw2d_ghost_fill_wrap_info parallel_mode; - fclaw2d_physical_time_info_t t_info; + fclaw_physical_time_info_t t_info; t_info.level_time = sync_time; t_info.time_interp = time_interp; parallel_mode.ghost_mode = ghost_mode; parallel_mode.user = (void*) &t_info; - parallel_mode.cb_fill = cb_fclaw2d_physical_set_bc; - fclaw2d_global_iterate_level(glob, level, cb_parallel_wrap, + parallel_mode.cb_fill = cb_fclaw_physical_set_bc; + fclaw_global_iterate_level(glob, level, cb_parallel_wrap, (void *) ¶llel_mode); } @@ -339,14 +374,14 @@ void time_sync(fclaw2d_global_t* glob, static -void copy_samelevel(fclaw2d_global_t* glob, +void copy_samelevel(fclaw_global_t* glob, int minlevel, int maxlevel, int time_interp, int read_parallel_patches, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_COPY]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL_COPY]); int level; /* Copy between grids that are at the same level. */ @@ -362,7 +397,7 @@ void copy_samelevel(fclaw2d_global_t* glob, copy2ghost(glob,time_interp_level,time_interp, read_parallel_patches,ghost_mode); } - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_COPY]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL_COPY]); } @@ -370,14 +405,14 @@ void copy_samelevel(fclaw2d_global_t* glob, * Fill in coarse grid ghost cells by averaging or copying from neighboring fine grids. */ static -void average_fine2coarse_ghost(fclaw2d_global_t *glob, +void average_fine2coarse_ghost(fclaw_global_t *glob, int mincoarse, int maxcoarse, int time_interp, int read_parallel_patches, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_AVERAGE]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL_AVERAGE]); int level; @@ -397,18 +432,18 @@ void average_fine2coarse_ghost(fclaw2d_global_t *glob, average2ghost(glob,time_interp_level,time_interp, read_parallel_patches,ghost_mode); } - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_AVERAGE]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL_AVERAGE]); } static -void interpolate_coarse2fine_ghost(fclaw2d_global_t* glob, +void interpolate_coarse2fine_ghost(fclaw_global_t* glob, int mincoarse, int maxcoarse, int time_interp, int read_parallel_patches, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_INTERP]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL_INTERP]); int level; @@ -426,19 +461,19 @@ void interpolate_coarse2fine_ghost(fclaw2d_global_t* glob, interpolate2ghost(glob,time_interp_level,time_interp, read_parallel_patches,ghost_mode); } - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_INTERP]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL_INTERP]); } static -void fill_physical_ghost(fclaw2d_global_t* glob, +void fill_physical_ghost(fclaw_global_t* glob, int minlevel, int maxlevel, double sync_time, int time_interp, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_PHYSBC]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL_PHYSBC]); int level; @@ -456,24 +491,24 @@ void fill_physical_ghost(fclaw2d_global_t* glob, time_interp, ghost_mode); } - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_PHYSBC]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL_PHYSBC]); } /* ----------------------------------------------------------------------- Public interface ---------------------------------------------------------------------*/ -void fclaw2d_ghost_update_nonasync(fclaw2d_global_t* glob, +void fclaw_ghost_update_nonasync(fclaw_global_t* glob, int minlevel, int maxlevel, double sync_time, int time_interp, - fclaw2d_timer_names_t running) + fclaw_timer_names_t running) { - if (running != FCLAW2D_TIMER_NONE) { - fclaw2d_timer_stop (&glob->timers[running]); + if (running != FCLAW_TIMER_NONE) { + fclaw_timer_stop (&glob->timers[running]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL]); fclaw_global_infof("Exchanging ghost patches across all levels\n"); @@ -511,10 +546,10 @@ void fclaw2d_ghost_update_nonasync(fclaw2d_global_t* glob, This is needed so that when these boundary patches get sent to other processors as ghost patches, they have valid ghost cells if needed for interpolation.*/ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP1]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP1]); - fclaw2d_ghost_fill_parallel_mode_t parallel_mode - = FCLAW2D_BOUNDARY_GHOST_ONLY; + fclaw_ghost_fill_parallel_mode_t parallel_mode + = FCLAW_BOUNDARY_GHOST_ONLY; int read_parallel_patches = 0; @@ -542,33 +577,33 @@ void fclaw2d_ghost_update_nonasync(fclaw2d_global_t* glob, time_interp, parallel_mode); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP1]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP1]); /* -------------------------------------------------------------- Send and receive ghost patches ------------------------------------------------------------*/ - fclaw2d_exchange_ghost_patches_begin(glob,minlevel,maxlevel,time_interp, - FCLAW2D_TIMER_GHOSTFILL); + fclaw_exchange_ghost_patches_begin(glob,minlevel,maxlevel,time_interp, + FCLAW_TIMER_GHOSTFILL); - fclaw2d_exchange_ghost_patches_end(glob,minlevel,maxlevel,time_interp, - FCLAW2D_TIMER_GHOSTFILL); + fclaw_exchange_ghost_patches_end(glob,minlevel,maxlevel,time_interp, + FCLAW_TIMER_GHOSTFILL); /* ------------------------------------------------------------- Indirect neighbor exchange ------------------------------------------------------------- */ - fclaw2d_face_neighbor_ghost(glob,minlevel,maxlevel,time_interp); + fclaw_face_neighbor_ghost(glob,minlevel,maxlevel,time_interp); /* ------------------------------------------------------------- Do everything in one set of sequential steps ------------------------------------------------------------- */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP3]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP3]); read_parallel_patches = 1; parallel_mode = - FCLAW2D_BOUNDARY_ALL; + FCLAW_BOUNDARY_ALL; /* Average */ average_fine2coarse_ghost(glob,mincoarse,maxcoarse, time_interp, @@ -596,29 +631,29 @@ void fclaw2d_ghost_update_nonasync(fclaw2d_global_t* glob, maxlevel, sync_time, time_interp, - FCLAW2D_BOUNDARY_ALL); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP3]); + FCLAW_BOUNDARY_ALL); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP3]); // Stop timing - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL]); - if (running != FCLAW2D_TIMER_NONE) + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL]); + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_start (&glob->timers[running]); + fclaw_timer_start (&glob->timers[running]); } } -void fclaw2d_ghost_update_async(fclaw2d_global_t* glob, +void fclaw_ghost_update_async(fclaw_global_t* glob, int minlevel, int maxlevel, double sync_time, int time_interp, - fclaw2d_timer_names_t running) + fclaw_timer_names_t running) { - if (running != FCLAW2D_TIMER_NONE) { - fclaw2d_timer_stop (&glob->timers[running]); + if (running != FCLAW_TIMER_NONE) { + fclaw_timer_stop (&glob->timers[running]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL]); fclaw_global_infof("Exchanging ghost patches across all levels\n"); @@ -649,8 +684,8 @@ void fclaw2d_ghost_update_async(fclaw2d_global_t* glob, int mincoarse = minlevel; int maxcoarse = maxlevel-1; /* maxlevel >= minlevel */ - fclaw2d_ghost_fill_parallel_mode_t parallel_mode = - FCLAW2D_BOUNDARY_ALL; + fclaw_ghost_fill_parallel_mode_t parallel_mode = + FCLAW_BOUNDARY_ALL; int read_parallel_patches; /* -------------------------------------------------------------- @@ -660,9 +695,9 @@ void fclaw2d_ghost_update_async(fclaw2d_global_t* glob, This is needed so that when these boundary patches get sent to other processors as ghost patches, they have valid ghost cells if needed for interpolation.*/ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP1]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP1]); - parallel_mode = FCLAW2D_BOUNDARY_GHOST_ONLY; + parallel_mode = FCLAW_BOUNDARY_GHOST_ONLY; read_parallel_patches = 0; @@ -690,20 +725,20 @@ void fclaw2d_ghost_update_async(fclaw2d_global_t* glob, time_interp, parallel_mode); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP1]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP1]); /* -------------------------------------------------------------- Start send ... ------------------------------------------------------------*/ - fclaw2d_exchange_ghost_patches_begin(glob,minlevel,maxlevel,time_interp, - FCLAW2D_TIMER_GHOSTFILL); + fclaw_exchange_ghost_patches_begin(glob,minlevel,maxlevel,time_interp, + FCLAW_TIMER_GHOSTFILL); /* -------------------------------------------------------------- Finish exchanges in the interior of the grid. ------------------------------------------------------------*/ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP2]); - parallel_mode = FCLAW2D_BOUNDARY_INTERIOR_ONLY; + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP2]); + parallel_mode = FCLAW_BOUNDARY_INTERIOR_ONLY; /* Average */ average_fine2coarse_ghost(glob,mincoarse,maxcoarse, @@ -744,14 +779,14 @@ void fclaw2d_ghost_update_async(fclaw2d_global_t* glob, time_interp, parallel_mode); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP2]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP2]); /* ------------------------------------------------------------- Receive ghost patches ... ------------------------------------------------------------- */ - fclaw2d_exchange_ghost_patches_end(glob,minlevel,maxlevel,time_interp, - FCLAW2D_TIMER_GHOSTFILL); + fclaw_exchange_ghost_patches_end(glob,minlevel,maxlevel,time_interp, + FCLAW_TIMER_GHOSTFILL); /* ------------------------------------------------------------- Loop over ghost patches to find indirect neighbors and do @@ -760,14 +795,14 @@ void fclaw2d_ghost_update_async(fclaw2d_global_t* glob, Note : There is no special timer for this call, but checks show that ghostfill-(step1+step2+step3+comm) << 1 ------------------------------------------------------------- */ - fclaw2d_face_neighbor_ghost(glob,minlevel,maxlevel,time_interp); + fclaw_face_neighbor_ghost(glob,minlevel,maxlevel,time_interp); /* ------------------------------------------------------------- Repeat above, but now with parallel ghost cells. ------------------------------------------------------------- */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP3]); - parallel_mode = FCLAW2D_BOUNDARY_GHOST_ONLY; + fclaw_timer_start (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP3]); + parallel_mode = FCLAW_BOUNDARY_GHOST_ONLY; read_parallel_patches = 1; /* Average */ @@ -818,14 +853,14 @@ void fclaw2d_ghost_update_async(fclaw2d_global_t* glob, maxlevel, sync_time, time_interp, - FCLAW2D_BOUNDARY_ALL); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL_STEP3]); + FCLAW_BOUNDARY_ALL); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL_STEP3]); // Stop timing - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_GHOSTFILL]); - if (running != FCLAW2D_TIMER_NONE) + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_GHOSTFILL]); + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_start (&glob->timers[running]); + fclaw_timer_start (&glob->timers[running]); } } @@ -835,23 +870,23 @@ void fclaw2d_ghost_update_async(fclaw2d_global_t* glob, Public interface ---------------------------------------------------------------------*/ -void fclaw2d_ghost_update(fclaw2d_global_t* glob, +void fclaw_ghost_update(fclaw_global_t* glob, int minlevel, int maxlevel, double sync_time, int time_interp, - fclaw2d_timer_names_t running) + fclaw_timer_names_t running) { int async = 1; if (async == 0) { - fclaw2d_ghost_update_nonasync(glob,minlevel,maxlevel,sync_time,time_interp,running); + fclaw_ghost_update_nonasync(glob,minlevel,maxlevel,sync_time,time_interp,running); } else { /* About 10% faster? */ - fclaw2d_ghost_update_async(glob,minlevel,maxlevel,sync_time,time_interp,running); + fclaw_ghost_update_async(glob,minlevel,maxlevel,sync_time,time_interp,running); } } diff --git a/src/fclaw2d_ghost_fill.h b/src/fclaw_ghost_fill.h similarity index 70% rename from src/fclaw2d_ghost_fill.h rename to src/fclaw_ghost_fill.h index 070ace357..858d8c73e 100644 --- a/src/fclaw2d_ghost_fill.h +++ b/src/fclaw_ghost_fill.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_GHOST_FILL_H -#define FCLAW2D_GHOST_FILL_H +#ifndef FCLAW_GHOST_FILL_H +#define FCLAW_GHOST_FILL_H #include /* Needed for definition of timer names */ @@ -36,78 +36,66 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_domain; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_domain; +struct fclaw_patch; /** * @file * Routines needed to fill in ghost cells */ -typedef enum fclaw2d_ghost_fill_parallel_mode +typedef enum fclaw_ghost_fill_parallel_mode { - FCLAW2D_BOUNDARY_INTERIOR_ONLY = 0, /* Don't read parallel patches */ - FCLAW2D_BOUNDARY_GHOST_ONLY, /* read parallel patches */ - FCLAW2D_BOUNDARY_ALL, /* read parallel patches */ - FCLAW2D_BOUNDARY_LOCAL_ALL, -} fclaw2d_ghost_fill_parallel_mode_t; + FCLAW_BOUNDARY_INTERIOR_ONLY = 0, /* Don't read parallel patches */ + FCLAW_BOUNDARY_GHOST_ONLY, /* read parallel patches */ + FCLAW_BOUNDARY_ALL, /* read parallel patches */ + FCLAW_BOUNDARY_LOCAL_ALL, +} fclaw_ghost_fill_parallel_mode_t; -typedef enum fclaw2d_exchange_type +typedef enum fclaw_exchange_type { - FCLAW2D_COPY = 1, - FCLAW2D_AVERAGE, - FCLAW2D_INTERPOLATE, - FCLAW2D_TIME_SYNC_F2C, - FCLAW2D_TIME_SYNC_SAMESIZE, -} fclaw2d_exchange_type_t; + FCLAW_COPY = 1, + FCLAW_AVERAGE, + FCLAW_INTERPOLATE, + FCLAW_TIME_SYNC_F2C, + FCLAW_TIME_SYNC_SAMESIZE, +} fclaw_exchange_type_t; /** enum for which type of grid is being filled */ -typedef enum fclaw2d_grid_type +typedef enum fclaw_grid_type { /** fill ghost cells for coarser neighbor grid */ - FCLAW2D_IS_COARSE = 1, + FCLAW_IS_COARSE = 1, /** fill ghost cells for finer neighbor grid */ - FCLAW2D_IS_FINE, -} fclaw2d_grid_type_t; + FCLAW_IS_FINE, +} fclaw_grid_type_t; -typedef struct fclaw2d_exchange_info +typedef struct fclaw_exchange_info { int time_interp; int level; int read_parallel_patches; /* before we have done a parallel exchange */ - fclaw2d_exchange_type_t exchange_type; - fclaw2d_grid_type_t grid_type; + fclaw_exchange_type_t exchange_type; + fclaw_grid_type_t grid_type; int has_fine_grid_neighbor; -} fclaw2d_exchange_info_t; +} fclaw_exchange_info_t; -void cb_corner_fill(struct fclaw2d_domain *domain, - struct fclaw2d_patch *this_patch, - int this_block_idx, - int this_patch_idx, - void *user); - -void cb_face_fill(struct fclaw2d_domain *domain, - struct fclaw2d_patch *this_patch, - int this_block_idx, - int this_patch_idx, - void *user); - -void fclaw2d_ghost_update(struct fclaw2d_global* glob, +void fclaw_ghost_update(struct fclaw_global* glob, int fine_level, int coarse_level, double sync_time, int time_interp, - fclaw2d_timer_names_t running); + fclaw_timer_names_t running); -void fclaw2d_ghost_update_async(struct fclaw2d_global* glob, +void fclaw_ghost_update_async(struct fclaw_global* glob, int fine_level, int coarse_level, double sync_time, int time_interp, - fclaw2d_timer_names_t running); + fclaw_timer_names_t running); /** * Complete exchange of all ghost patches at all levels. @@ -124,12 +112,12 @@ void fclaw2d_ghost_update_async(struct fclaw2d_global* glob, * the logic here is considerably simpler than for the partial * update used in intermediate steps in the subcycled case. **/ -void fclaw2d_ghost_update_nonasync(struct fclaw2d_global* glob, +void fclaw_ghost_update_nonasync(struct fclaw_global* glob, int fine_level, int coarse_level, double sync_time, int time_interp, - fclaw2d_timer_names_t running); + fclaw_timer_names_t running); /** * Complete exchange of all ghost patches at all levels. @@ -146,7 +134,7 @@ void fclaw2d_ghost_update_nonasync(struct fclaw2d_global* glob, * the logic here is considerably simpler than for the partial * update used in intermediate steps in the subcycled case. **/ -void fclaw2d_face_neighbor_ghost(struct fclaw2d_global* glob, +void fclaw_face_neighbor_ghost(struct fclaw_global* glob, int minlevel, int maxlevel, int time_interp); diff --git a/src/fclaw_global.c b/src/fclaw_global.c index 1945411fd..7205d822c 100644 --- a/src/fclaw_global.c +++ b/src/fclaw_global.c @@ -1,5 +1,5 @@ /* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun +Copyright (c) 2012-2023 Carsten Burstedde, Donna Calhoun, Scott Aiton All rights reserved. Redistribution and use in source and binary forms, with or without @@ -23,75 +23,321 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + +#include +#include +#include +#include + +#include #include -#include -#include +#include -void -fclaw_global_iterate_patches (fclaw_global_t * glob, - fclaw_patch_callback_t gpcb, void *user) +#include +#include +#include + +fclaw_global_t* fclaw_global_new (void) { - fclaw_global_iterate_t gi; - gi.glob = glob; - gi.gpcb = gpcb; - gi.gfcb = NULL; - gi.user = user; + fclaw_global_t *glob; - if (glob->domain->dim == 2) - { - fclaw2d_domain_iterate_patches (glob->domain->d.d2.domain2, - fclaw2d_iterate_patch_cb, &gi); - } - else + glob = FCLAW_ALLOC (fclaw_global_t, 1); + + /* these variables need to be set after calling this function */ + glob->mpicomm = sc_MPI_COMM_NULL; + glob->mpisize = 0; + glob->mpirank = -1; + + glob->pkg_container = fclaw_package_container_new (); + glob->vtables = fclaw_pointer_map_new (); + glob->options = fclaw_pointer_map_new (); + + glob->count_amr_advance = 0; + glob->count_ghost_exchange = 0; + glob->count_amr_regrid = 0; + glob->count_amr_new_domain = 0; + glob->count_multiproc_corner = 0; + glob->count_grids_per_proc = 0; + glob->count_grids_remote_boundary = 0; + glob->count_grids_local_boundary = 0; + glob->count_single_step = 0; + glob->count_elliptic_grids = 0; + glob->curr_time = 0; + glob->cont = NULL; + +#ifndef P4_TO_P8 + /* think about how this can work independent of dimension */ + glob->acc = FCLAW_ALLOC (fclaw_diagnostics_accumulator_t, 1); +#endif /* P4_TO_P8 */ + + return glob; +} + +fclaw_global_t* fclaw_global_new_comm (sc_MPI_Comm mpicomm, + int mpisize, int mpirank) +{ + fclaw_global_t *glob = fclaw_global_new (); + + /* + * Set the communicator. + * With the current code, overridden by fclaw2d_global_store_domain. + * Maybe we should streamline this in the future. + */ + glob->mpicomm = mpicomm; + glob->mpisize = mpisize; + glob->mpirank = mpirank; + + return glob; +} + +#ifndef P4_TO_P8 +// packing unpacking functions only 2d for now + +static void check_vt(fclaw_packing_vtable_t* vt, const char* name) +{ + char msg[1024]; + sprintf(msg,"Unregistered options packing vtable for \"%s\"",name); + SC_CHECK_ABORT ((vt != NULL), msg); +} + +static void +pack_iterator_callback(const char* key, void* value, void* user) +{ + char** buffer_ptr = (char **) user; + + *buffer_ptr += fclaw_pack_string(key, *buffer_ptr); + + fclaw_packing_vtable_t* vt = fclaw_app_get_options_packing_vtable(key); + check_vt(vt,key); + + // advance buffer pointer + *buffer_ptr += vt->pack(value,*buffer_ptr); +} + +size_t +fclaw2d_global_pack(const fclaw_global_t * glob, char* buffer) +{ + const char* buffer_start = buffer; + + buffer += fclaw_pack_double(glob->curr_time, buffer); + buffer += fclaw_pack_double(glob->curr_dt, buffer); + + buffer += fclaw_pack_size_t(fclaw_pointer_map_size(glob->options), buffer); + + fclaw_pointer_map_iterate(glob->options, pack_iterator_callback, &buffer); + + return (buffer-buffer_start); +} + +static void +packsize_iterator_callback(const char* key, void* value, void* user) +{ + size_t* options_size = (size_t*) user; + fclaw_packing_vtable_t* vt = fclaw_app_get_options_packing_vtable(key); + check_vt(vt,key); + (*options_size) += fclaw_packsize_string(key) + vt->size(value); +} + +size_t +fclaw2d_global_packsize(const fclaw_global_t * glob) +{ + size_t options_size = sizeof(size_t); + fclaw_pointer_map_iterate(glob->options, packsize_iterator_callback, &options_size); + return 2*sizeof(double) + options_size; +} + +size_t +fclaw2d_global_unpack(char* buffer, fclaw_global_t ** glob_ptr) +{ + char* buffer_start = buffer; + + fclaw_global_t* glob = fclaw_global_new(); + *glob_ptr = glob; + + buffer += fclaw_unpack_double(buffer,&glob->curr_time); + buffer += fclaw_unpack_double(buffer,&glob->curr_dt); + + size_t num_option_structs; + buffer += fclaw_unpack_size_t(buffer,&num_option_structs); + + for(size_t i = 0; i< num_option_structs; i++) { - FCLAW_ASSERT (glob->domain->dim == 3); - fclaw3d_domain_iterate_patches (glob->domain->d.d3.domain3, - fclaw3d_iterate_patch_cb, &gi); + char * key; + buffer += fclaw_unpack_string(buffer,&key); + fclaw_packing_vtable_t* vt = fclaw_app_get_options_packing_vtable(key); + check_vt(vt,key); + void * options; + buffer += vt->unpack(buffer,&options); + fclaw_pointer_map_insert(glob->options, key, options, vt->destroy); + FCLAW_FREE(key); } + + return buffer-buffer_start; } +#endif + void -fclaw_global_iterate_level (fclaw_global_t * glob, int level, - fclaw_patch_callback_t gpcb, void *user) +fclaw_global_store_domain (fclaw_global_t* glob, fclaw_domain_t* domain) { - fclaw_global_iterate_t gi; - gi.glob = glob; - gi.gpcb = gpcb; - gi.gfcb = NULL; - gi.user = user; + glob->domain = domain; - if (glob->domain->dim == 2) - { - fclaw2d_domain_iterate_level (glob->domain->d.d2.domain2, level, - fclaw2d_iterate_patch_cb, &gi); - } - else - { - FCLAW_ASSERT (glob->domain->dim == 3); - fclaw3d_domain_iterate_level (glob->domain->d.d3.domain3, level, - fclaw3d_iterate_patch_cb, &gi); + /* this is redundant if global has been created with a communicator */ + if (glob->mpisize > 0) { + /* double-check for extra paranoia */ + FCLAW_ASSERT (glob->mpisize == domain->mpisize); + FCLAW_ASSERT (glob->mpirank == domain->mpirank); } } void -fclaw_global_iterate_families (fclaw_global_t * glob, - fclaw_family_callback_t gfcb, void *user) +fclaw_map_store (fclaw_global_t* glob, + fclaw_map_context_t * map) { - fclaw_global_iterate_t gi; - gi.glob = glob; - gi.gpcb = NULL; - gi.gfcb = gfcb; - gi.user = user; + glob->cont = map; +} - if (glob->domain->dim == 2) - { - fclaw2d_domain_iterate_families (glob->domain->d.d2.domain2, - fclaw2d_iterate_family_cb, &gi); +fclaw_map_context_t* +fclaw_map_get(fclaw_global_t* glob) +{ + return glob->cont; +} + +void +fclaw_global_destroy (fclaw_global_t * glob) +{ + FCLAW_ASSERT (glob != NULL); + + if(glob->pkg_container != NULL) fclaw_package_container_destroy ((fclaw_package_container_t *)glob->pkg_container); + if(glob->vtables != NULL) fclaw_pointer_map_destroy (glob->vtables); + if(glob->options != NULL) fclaw_pointer_map_destroy (glob->options); + +#ifndef P4_TO_P8 + FCLAW_FREE (glob->acc); +#endif + FCLAW_FREE (glob); +} + +void fclaw_global_iterate_level (fclaw_global_t * glob, int level, + fclaw_patch_callback_t pcb, void *user) +{ + fclaw_global_iterate_t g; + g.glob = glob; + g.user = user; + fclaw_domain_iterate_level (glob->domain, level, pcb, &g); +} + +void fclaw_global_iterate_patches (fclaw_global_t * glob, + fclaw_patch_callback_t pcb, void *user) +{ + fclaw_global_iterate_t g; + g.glob = glob; + g.user = user; + fclaw_domain_iterate_patches (glob->domain, pcb, &g); +} + +void fclaw_global_iterate_families (fclaw_global_t * glob, + fclaw_patch_callback_t pcb, void *user) +{ + fclaw_global_iterate_t g; + g.glob = glob; + g.user = user; + fclaw_domain_iterate_families (glob->domain, pcb, &g); +} + +void fclaw_global_iterate_adapted (fclaw_global_t * glob, fclaw_domain_t* new_domain, + fclaw_match_callback_t mcb, void *user) +{ + fclaw_global_iterate_t g; + g.glob = glob; + g.user = user; + fclaw_domain_iterate_adapted (glob->domain, new_domain,mcb,&g); +} + +void fclaw_global_iterate_level_mthread (fclaw_global_t * glob, int level, + fclaw_patch_callback_t pcb, void *user) +{ + fclaw_global_iterate_t g; + g.glob = glob; + g.user = user; + fclaw_domain_iterate_level_mthread (glob->domain, level,pcb,&g); +} + +void fclaw_global_iterate_partitioned (fclaw_global_t * glob, + fclaw_domain_t * new_domain, + fclaw_transfer_callback_t tcb, + void *user) +{ + fclaw_global_iterate_t g; + g.glob = glob; + g.user = user; + fclaw_domain_iterate_partitioned (glob->domain,new_domain,tcb,&g); +} + +void fclaw_global_options_store (fclaw_global_t* glob, const char* key, void* options) +{ + + FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,key) == NULL); + fclaw_pointer_map_insert(glob->options, key, options, NULL); +} + +void* fclaw_global_get_options (fclaw_global_t* glob, const char* key) +{ + + void* options = fclaw_pointer_map_get(glob->options, key); + FCLAW_ASSERT(options != NULL); + return options; +} + +static fclaw_global_t* fclaw2d_global_glob = NULL; + +void fclaw_global_set_static (fclaw_global_t* glob) +{ + FCLAW_ASSERT (fclaw2d_global_glob == NULL); + fclaw2d_global_glob = glob; +} + +void fclaw_global_clear_static (void) +{ + FCLAW_ASSERT (fclaw2d_global_glob != NULL); + fclaw2d_global_glob = NULL; +} + +fclaw_global_t* fclaw_global_get_static_global (void) +{ + FCLAW_ASSERT(fclaw2d_global_glob != NULL); + return fclaw2d_global_glob; +} + +// Only 2d for now need fclaw2d_options +#ifndef P4_TO_P8 + +static char* old_path = NULL; + +void fclaw_set_global_context(fclaw_global_t *glob) +{ + fclaw_options_t* opts = fclaw_get_options(glob); + + // Change run directory + if(strcmp(opts->run_directory,"") != 0){ + FCLAW_ASSERT(old_path == NULL); + fclaw_set_logging_prefix(opts->logging_prefix); + old_path = fclaw_cwd(); + fclaw_cd(opts->run_directory); } - else - { - FCLAW_ASSERT (glob->domain->dim == 3); - fclaw3d_domain_iterate_families (glob->domain->d.d3.domain3, - fclaw3d_iterate_family_cb, &gi); +} + +void fclaw_clear_global_context(fclaw_global_t *glob) +{ + fclaw_set_logging_prefix(NULL); + + // Return to previous cwd + if(old_path != NULL){ + fclaw_cd(old_path); + FCLAW_FREE(old_path); + old_path = NULL; } } + +#endif \ No newline at end of file diff --git a/src/fclaw_global.h b/src/fclaw_global.h index 5207873cd..3e88826ad 100644 --- a/src/fclaw_global.h +++ b/src/fclaw_global.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun +Copyright (c) 2012-2023 Carsten Burstedde, Donna Calhoun, Scott Aiton All rights reserved. Redistribution and use in source and binary forms, with or without @@ -22,73 +22,223 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** - * @file - * Dimension-independent per-simulation global data structure. - */ #ifndef FCLAW_GLOBAL_H #define FCLAW_GLOBAL_H -/* - * Domain-independent header file should not include domain-specific headers. - * The corresponding source file include the 2d and 3d domain-specific headers. - */ -#include +#include /* Needed to declare callbacks (below) */ +#include /* Needed to store the map context */ + +#include /* Needed to create statically allocated array of timers */ -typedef struct fclaw_global +#ifdef __cplusplus +extern "C" { - fclaw_domain_t *domain; +#if 0 +} /* need this because indent is dumb */ +#endif +#endif - /* lots of dimension-independent stuff */ -} -fclaw_global_t; - -/** Dimension-independent callback prototype for patch iterators. - * We iterate over local patches only. - * \param [in] domain Dimension-independent global context. - * \param [in] patch The local patch currently processed by the iterator. - * \param [in] blockno Block number of processed patch. - * \param [in] patchno Patch number within block of processed patch. - * \param [in,out] user Data that was passed into the iterator functions. - */ -typedef void (*fclaw_patch_callback_t) - (fclaw_global_t * global, fclaw_patch_t * patch, - int blockno, int patchno, void *user); - -/** Dimension-independent callback prototype for family iterators. - * We iterate over local families of patches only. - * \param [in] domain Dimension-independent global context. - * \param [in] family Array of the patches in the family. - * \param [in] blockno Block number of processed patches. - * \param [in] patchno The local number of the first sibling patch - * in the family, relative to the block. The - * remaining 3 (2D) or 7 (3D) are consecutive. - * \param [in,out] user Data that was passed into the iterator functions. - */ -typedef void (*fclaw_family_callback_t) - (fclaw_global_t * global, fclaw_patch_t * family[], - int blockno, int patchno, void *user); +/* these are dimension-specific functions */ + +void fclaw_iterate_patch_cb + (fclaw_domain_t *domain, fclaw_patch_t *patch, + int blockno, int patchno, void *user); -typedef struct fclaw_global_iterate +void fclaw_iterate_family_cb + (fclaw_domain_t *domain, fclaw_patch_t *patch, + int blockno, int patchno, void *user); + +/* much of the following will move into fclaw_global.h */ + +typedef struct fclaw_global fclaw_global_t; +typedef struct fclaw_global_iterate fclaw_global_iterate_t; + +struct fclaw_global { - fclaw_global_t *glob; - fclaw_patch_callback_t gpcb; - fclaw_family_callback_t gfcb; + int count_amr_advance; + int count_ghost_exchange; + int count_amr_regrid; + int count_amr_new_domain; + int count_single_step; + int count_elliptic_grids; + int count_multiproc_corner; + int count_grids_per_proc; + int count_grids_remote_boundary; + int count_grids_local_boundary; + fclaw_timer_t timers[FCLAW_TIMER_COUNT]; + + /* Time at start of each subcycled time step */ + double curr_time; + double curr_dt; + + sc_MPI_Comm mpicomm; + int mpisize; /**< Size of communicator. */ + int mpirank; /**< Rank of this process in \b mpicomm. */ + + /** Solver packages for internal use. */ + struct fclaw_package_container *pkg_container; + + struct fclaw_pointer_map *vtables; /**< Vtables */ + struct fclaw_pointer_map *options; /**< options */ + + struct fclaw_map_context* cont; + struct fclaw_domain *domain; + + /* CB: is this a good place for the accumulator? + Would it be possible to add and retrieve it as an anonymous + object that does not need to be known to this file? */ + struct fclaw_diagnostics_accumulator *acc; + + /* CB: this is application specific. + Would it not be cleaner to add the gauges in a way to global + that this file does not need to know about gauges at all? */ + struct fclaw_gauge_info* gauge_info; + void *user; -} -fclaw_global_iterate_t; +}; -/** Iterate through all local patches one at a time. */ -void fclaw_global_iterate_patches (fclaw_global_t * glob, - fclaw_patch_callback_t gpcb, void *user); +struct fclaw_global_iterate +{ + fclaw_global_t* glob; + void* user; +}; + +/* Use forward references here, since this file gets included everywhere */ +/* CB: is there a way not to need the forward references? + Depending on fclaw2d_domain, _map, package seems entirely acceptable. + For those, including the respective headers might not be so bad. + About the diagnostics accumulator see remark above. */ +struct fclaw_domain; +struct fclaw_map_context; +struct fclaw_package_container; +struct fclaw_diagnostics_accumulator; + +/** Allocate a new global structure. */ +fclaw_global_t* fclaw_global_new (void); + +fclaw_global_t* fclaw_global_new_comm (sc_MPI_Comm mpicomm, + int mpisize, int mpirank); + +void fclaw_global_destroy (fclaw_global_t * glob); + +void fclaw_global_store_domain (fclaw_global_t* glob, + struct fclaw_domain* domain); + +void fclaw_map_store (fclaw_global_t* glob, + struct fclaw_map_context * map); + +/** + * @brief Get the mapping context + * + * @param glob the global context + * @return struct fclaw_map_context* the mapping context + */ +struct fclaw_map_context* fclaw_map_get(fclaw_global_t* glob); + +/** + * @brief Pack global structure into buffer + * + * @param glob the global structure + * @param buffer the buffer to write to + * @return size_t number of bytes written + */ +size_t fclaw2d_global_pack(const fclaw_global_t * glob, char* buffer); + +/** + * @brief Get the number of bytes needed to pack the global structure + * + * @param glob the structure + * @return size_t the number of bytes needed to store structure + */ +size_t fclaw2d_global_packsize(const fclaw_global_t * glob); + +/** + * @brief Unpack global structure from buffer + * + * @param buffer the buffer to read from + * @param glob newly create global structure + * @return size_t number of bytes read + */ +size_t fclaw2d_global_unpack(char* buffer, fclaw_global_t** glob); -/** Iterate through all local patches on given level. */ void fclaw_global_iterate_level (fclaw_global_t * glob, int level, - fclaw_patch_callback_t gpcb, void *user); + fclaw_patch_callback_t pcb, void *user); + +void fclaw_global_iterate_patches (fclaw_global_t * glob, + fclaw_patch_callback_t pcb, void *user); -/** Iterate through families of patches. */ void fclaw_global_iterate_families (fclaw_global_t * glob, - fclaw_family_callback_t gfcb, void *user); + fclaw_patch_callback_t pcb, void *user); + +void fclaw_global_iterate_adapted (fclaw_global_t * glob, + struct fclaw_domain* new_domain, + fclaw_match_callback_t mcb, void *user); + +void fclaw_global_iterate_level_mthread (fclaw_global_t * glob, int level, + fclaw_patch_callback_t pcb, void *user); + +void fclaw_global_iterate_partitioned (fclaw_global_t * glob, + struct fclaw_domain * new_domain, + fclaw_transfer_callback_t tcb, + void *user); + +/** + * @brief Store an options structure in the glob + * + * @param glob the global context + * @param key the key to store the options under + * @param options the options structure + */ +void fclaw_global_options_store (fclaw_global_t* glob, const char* key, void* options); + +/** + * @brief Get an options structure from the glob + * + * @param glob the global context + * @param key the key to retrieve the options from + * @return void* the options + */ +void* fclaw_global_get_options (fclaw_global_t* glob, const char* key); + +/** + * @brief Store a glob variable in static memory + * + * @param glob the glob variable + */ +void fclaw_global_set_static (fclaw_global_t* glob); + +/** + * @brief Set the static glob variable to NULL + */ +void fclaw_global_clear_static (void); + +/** + * @brief Get the static glob variable + * + * @return fclaw2d_global_t* the glob variable + */ +fclaw_global_t* fclaw_global_get_static_global (void); + +/** + * @brief + * + * @param glob + */ +void fclaw_set_global_context(fclaw_global_t *glob); + +/** + * @brief + * + * @param glob + */ +void fclaw_clear_global_context(fclaw_global_t *glob); + +#ifdef __cplusplus +#if 0 +{ /* need this because indent is dumb */ +#endif +} +#endif -#endif /* FCLAW_GLOBAL_H */ +#endif /* !FCLAW2D_GLOBAL_H */ diff --git a/src/fclaw2d_global.h.TEST.cpp b/src/fclaw_global.h.TEST.cpp similarity index 78% rename from src/fclaw2d_global.h.TEST.cpp rename to src/fclaw_global.h.TEST.cpp index 0cbd2256c..6a6dde604 100644 --- a/src/fclaw2d_global.h.TEST.cpp +++ b/src/fclaw_global.h.TEST.cpp @@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include #include #include @@ -39,8 +39,8 @@ TEST_CASE("fclaw2d_global_pack with no options") for(double curr_time : {1.0, 1.2}) for(double curr_dt : {1.0, 1.2}) { - fclaw2d_global_t* glob1; - glob1 = fclaw2d_global_new(); + fclaw_global_t* glob1; + glob1 = fclaw_global_new(); glob1->curr_time = curr_time; glob1->curr_dt = curr_dt; @@ -54,7 +54,7 @@ TEST_CASE("fclaw2d_global_pack with no options") REQUIRE_EQ(bytes_written, packsize); - fclaw2d_global_t* glob2; + fclaw_global_t* glob2; size_t bytes_read = fclaw2d_global_unpack(buffer, &glob2); REQUIRE_EQ(bytes_read, packsize); @@ -65,8 +65,8 @@ TEST_CASE("fclaw2d_global_pack with no options") CHECK_EQ(fclaw_pointer_map_size(glob2->options), 0); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } } @@ -134,14 +134,14 @@ fclaw_packing_vtable_t dummy_opts_vt = }; } -TEST_CASE("fclaw2d_global_pack with no options structure") +TEST_CASE("fclaw_global_pack with no options structure") { for(double curr_time : {1.0, 1.2}) for(double curr_dt : {1.0, 1.2}) { - fclaw2d_global_t* glob1; - glob1 = fclaw2d_global_new(); + fclaw_global_t* glob1; + glob1 = fclaw_global_new(); glob1->curr_time = curr_time; glob1->curr_dt = curr_dt; @@ -154,7 +154,7 @@ TEST_CASE("fclaw2d_global_pack with no options structure") REQUIRE_EQ(bytes_written, packsize); - fclaw2d_global_t* glob2; + fclaw_global_t* glob2; size_t bytes_read = fclaw2d_global_unpack(buffer, &glob2); REQUIRE_EQ(bytes_read, packsize); @@ -164,11 +164,11 @@ TEST_CASE("fclaw2d_global_pack with no options structure") REQUIRE_EQ(fclaw_pointer_map_size(glob2->options), 0); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } } -TEST_CASE("fclaw2d_global_pack with a single options structure") +TEST_CASE("fclaw_global_pack with a single options structure") { for(double curr_time : {1.0, 1.2}) @@ -179,8 +179,8 @@ TEST_CASE("fclaw2d_global_pack with a single options structure") char ** argv = args.data(); int argc = 1; //fclaw_app_t* app = fclaw_app_new_on_comm(sc_MPI_COMM_WORLD,&argc,&argv,NULL); - fclaw2d_global_t* glob1; - glob1 = fclaw2d_global_new(); + fclaw_global_t* glob1; + glob1 = fclaw_global_new(); glob1->curr_time = curr_time; glob1->curr_dt = curr_dt; @@ -197,7 +197,7 @@ TEST_CASE("fclaw2d_global_pack with a single options structure") REQUIRE_EQ(bytes_written, packsize); - fclaw2d_global_t* glob2; + fclaw_global_t* glob2; size_t bytes_read = fclaw2d_global_unpack(buffer, &glob2); REQUIRE_EQ(bytes_read, packsize); @@ -215,18 +215,18 @@ TEST_CASE("fclaw2d_global_pack with a single options structure") - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } } -TEST_CASE("fclaw2d_global_pack with two options structure") +TEST_CASE("fclaw_global_pack with two options structure") { for(double curr_time : {1.0, 1.2}) for(double curr_dt : {1.0, 1.2}) { - fclaw2d_global_t* glob1; - glob1 = fclaw2d_global_new(); + fclaw_global_t* glob1; + glob1 = fclaw_global_new(); glob1->curr_time = curr_time; glob1->curr_dt = curr_dt; @@ -246,7 +246,7 @@ TEST_CASE("fclaw2d_global_pack with two options structure") REQUIRE_EQ(bytes_written, packsize); - fclaw2d_global_t* glob2; + fclaw_global_t* glob2; size_t bytes_read = fclaw2d_global_unpack(buffer, &glob2); REQUIRE_EQ(bytes_read, packsize); @@ -267,14 +267,14 @@ TEST_CASE("fclaw2d_global_pack with two options structure") CHECK_EQ(options_unpacked2->size, options2->size); CHECK_EQ(options_unpacked2->value, options2->value); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } } -TEST_CASE("fclaw2d_global_pack aborts with unregistered vtable") +TEST_CASE("fclaw_global_pack aborts with unregistered vtable") { - fclaw2d_global_t* glob1; - glob1 = fclaw2d_global_new(); + fclaw_global_t* glob1; + glob1 = fclaw_global_new(); glob1->curr_time = 100; glob1->curr_dt = 200; @@ -286,8 +286,8 @@ TEST_CASE("fclaw2d_global_pack aborts with unregistered vtable") } TEST_CASE("fclaw2d_global_packsize aborts with unregistered vtable") { - fclaw2d_global_t* glob1; - glob1 = fclaw2d_global_new(); + fclaw_global_t* glob1; + glob1 = fclaw_global_new(); glob1->curr_time = 100; glob1->curr_dt = 200; @@ -296,10 +296,10 @@ TEST_CASE("fclaw2d_global_packsize aborts with unregistered vtable") CHECK_SC_ABORTED(fclaw2d_global_packsize(glob1)); } -TEST_CASE("fclaw2d_global_unppack aborts with unregistered vtable") +TEST_CASE("fclaw_global_unppack aborts with unregistered vtable") { - fclaw2d_global_t* glob1; - glob1 = fclaw2d_global_new(); + fclaw_global_t* glob1; + glob1 = fclaw_global_new(); glob1->curr_time = 1; glob1->curr_dt = 1; @@ -316,62 +316,62 @@ TEST_CASE("fclaw2d_global_unppack aborts with unregistered vtable") REQUIRE_EQ(bytes_written, packsize); - fclaw2d_global_t* glob2=nullptr; + fclaw_global_t* glob2=nullptr; fclaw_app_register_options_packing_vtable("dummy1", nullptr); CHECK_SC_ABORTED(fclaw2d_global_unpack(buffer, &glob2)); } -TEST_CASE("fclaw2d_global_options_store and fclaw2d_global_get_options test") { - fclaw2d_global_t* glob = fclaw2d_global_new(); +TEST_CASE("fclaw_global_options_store and fclaw_global_get_options test") { + fclaw_global_t* glob = fclaw_global_new(); // Test with an integer int option1 = 10; const char* key1 = "option1"; - fclaw2d_global_options_store(glob, key1, &option1); + fclaw_global_options_store(glob, key1, &option1); - int* retrieved_option1 = static_cast(fclaw2d_global_get_options(glob, key1)); + int* retrieved_option1 = static_cast(fclaw_global_get_options(glob, key1)); CHECK_EQ(*retrieved_option1, option1); // Test with a string const char* option2 = "Test string"; const char* key2 = "option2"; - fclaw2d_global_options_store(glob, key2, &option2); + fclaw_global_options_store(glob, key2, &option2); - const char** retrieved_option2 = static_cast(fclaw2d_global_get_options(glob, key2)); + const char** retrieved_option2 = static_cast(fclaw_global_get_options(glob, key2)); CHECK_EQ(retrieved_option2, &option2); #ifdef FCLAW_ENABLE_DEBUG // TEST inserting twice - CHECK_SC_ABORTED(fclaw2d_global_options_store(glob, key2, &option2)); + CHECK_SC_ABORTED(fclaw_global_options_store(glob, key2, &option2)); #endif // Test with a non-existing key const char* key3 = "non-existing key"; #ifdef FCLAW_ENABLE_DEBUG - CHECK_SC_ABORTED(fclaw2d_global_get_options(glob, key3)); + CHECK_SC_ABORTED(fclaw_global_get_options(glob, key3)); #else - void* retrieved_option3 = fclaw2d_global_get_options(glob, key3); + void* retrieved_option3 = fclaw_global_get_options(glob, key3); CHECK_EQ(retrieved_option3, nullptr); #endif - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } TEST_CASE("fclaw2d_global_set_global") { - fclaw2d_global_t* glob = (fclaw2d_global_t*)123; - fclaw2d_global_set_global(glob); - CHECK_EQ(fclaw2d_global_get_global(), glob); - fclaw2d_global_unset_global(); + fclaw_global_t* glob = (fclaw_global_t*)123; + fclaw_global_set_static(glob); + CHECK_EQ(fclaw_global_get_static_global(), glob); + fclaw_global_clear_static(); } -TEST_CASE("fclaw2d_global_unset_global") +TEST_CASE("fclaw_global_clear_static") { - fclaw2d_global_t* glob = (fclaw2d_global_t*)123; - fclaw2d_global_set_global(glob); - fclaw2d_global_unset_global(); + fclaw_global_t* glob = (fclaw_global_t*)123; + fclaw_global_set_static(glob); + fclaw_global_clear_static(); #ifdef FCLAW_ENABLE_DEBUG - CHECK_SC_ABORTED(fclaw2d_global_get_global()); + CHECK_SC_ABORTED(fclaw_global_get_static_global()); #else - CHECK_EQ(fclaw2d_global_get_global(), nullptr); + CHECK_EQ(fclaw_global_get_static_global(), nullptr); #endif } @@ -379,20 +379,20 @@ TEST_CASE("fclaw2d_global_unset_global") TEST_CASE("fclaw2d_global_set_global twice fails") { - fclaw2d_global_t* glob = (fclaw2d_global_t*)123; - fclaw2d_global_set_global(glob); - CHECK_SC_ABORTED(fclaw2d_global_set_global(glob)); - fclaw2d_global_unset_global(); + fclaw_global_t* glob = (fclaw_global_t*)123; + fclaw_global_set_static(glob); + CHECK_SC_ABORTED(fclaw_global_set_static(glob)); + fclaw_global_clear_static(); } TEST_CASE("fclaw2d_global_unset_global assert fails when NULL") { - CHECK_SC_ABORTED(fclaw2d_global_unset_global()); + CHECK_SC_ABORTED(fclaw_global_clear_static()); } TEST_CASE("fclaw2d_global_get_global assert fails when NULL") { - CHECK_SC_ABORTED(fclaw2d_global_get_global()); + CHECK_SC_ABORTED(fclaw_global_get_static_global()); } #endif diff --git a/src/fclaw2d_include_all.h b/src/fclaw_include_all.h similarity index 80% rename from src/fclaw2d_include_all.h rename to src/fclaw_include_all.h index b11eb9671..c3ccec1b3 100644 --- a/src/fclaw2d_include_all.h +++ b/src/fclaw_include_all.h @@ -23,30 +23,30 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_INCLUDE_ALL_H -#define FCLAW2D_INCLUDE_ALL_H +#ifndef FCLAW_INCLUDE_ALL_H +#define FCLAW_INCLUDE_ALL_H #include #include #include -#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include +#include #include -#include -#include -#include +#include +#include +#include #include diff --git a/src/fclaw2d_initialize.c b/src/fclaw_initialize.c similarity index 61% rename from src/fclaw2d_initialize.c rename to src/fclaw_initialize.c index 2e5b7c42b..4fca9c294 100644 --- a/src/fclaw2d_initialize.c +++ b/src/fclaw_initialize.c @@ -23,25 +23,25 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include -#include +#include +#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(_OPENMP) #include @@ -51,21 +51,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Initial grid ----------------------------------------------------------------- */ static -void cb_initialize (fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_initialize (fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*) user; - fclaw2d_build_mode_t build_mode = FCLAW2D_BUILD_FOR_UPDATE; + fclaw_build_mode_t build_mode = FCLAW_BUILD_FOR_UPDATE; - fclaw2d_patch_build(g->glob,this_patch, + fclaw_patch_build(g->glob,this_patch, this_block_idx, this_patch_idx, &build_mode); - fclaw2d_patch_initialize(g->glob,this_patch,this_block_idx,this_patch_idx); + fclaw_patch_initialize(g->glob,this_patch,this_block_idx,this_patch_idx); } @@ -73,15 +73,18 @@ void cb_initialize (fclaw2d_domain_t *domain, /* ----------------------------------------------------------------- Public interface ----------------------------------------------------------------- */ -void fclaw2d_initialize(fclaw2d_global_t *glob) +void fclaw_initialize(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int time_interp = 0; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + + /* set partitioning */ + fclaw_domain_set_partitioning(*domain, fclaw_opt->partition_for_coarsening); /* This mapping context is needed by fortran mapping functions */ - fclaw2d_map_context_t *cont = glob->cont; + fclaw_map_context_t *cont = glob->cont; FCLAW_MAP_SET_CONTEXT(&cont); int maxthreads = 0; @@ -97,20 +100,20 @@ void fclaw2d_initialize(fclaw2d_global_t *glob) /* Initialize all timers */ int i; - for (i = 0; i < FCLAW2D_TIMER_COUNT; ++i) { - fclaw2d_timer_init (&glob->timers[i]); + for (i = 0; i < FCLAW_TIMER_COUNT; ++i) { + fclaw_timer_init (&glob->timers[i]); } /* start timing */ - fclaw2d_domain_barrier (*domain); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_WALLTIME]); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_INIT]); + fclaw_domain_barrier (*domain); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_WALLTIME]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_INIT]); /* User defined problem setup */ - fclaw2d_problem_setup(glob); + fclaw_problem_setup(glob); /* set specific refinement strategy */ - fclaw2d_domain_set_refinement + fclaw_domain_set_refinement (*domain, fclaw_opt->smooth_refine, fclaw_opt->smooth_level, fclaw_opt->coarsen_delay); @@ -123,26 +126,26 @@ void fclaw2d_initialize(fclaw2d_global_t *glob) ------------------------------------------------ */ /* Get an initial domain */ - fclaw2d_domain_setup(glob,*domain); + fclaw_domain_setup(glob,*domain); /* Initialize patches on uniformly refined level minlevel */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_REGRID_BUILD]); - fclaw2d_global_iterate_level(glob, minlevel, cb_initialize, + fclaw_timer_start (&glob->timers[FCLAW_TIMER_REGRID_BUILD]); + fclaw_global_iterate_level(glob, minlevel, cb_initialize, NULL); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_REGRID_BUILD]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_REGRID_BUILD]); /* Set up ghost patches */ - fclaw2d_exchange_setup(glob,FCLAW2D_TIMER_INIT); + fclaw_exchange_setup(glob,FCLAW_TIMER_INIT); /* This is normally called from regrid */ - fclaw2d_regrid_set_neighbor_types(glob); + fclaw_regrid_set_neighbor_types(glob); /* We need a user option here to set ghost values after initialization */ if (fclaw_opt->init_ghostcell) { - fclaw2d_ghost_update(glob,(*domain)->global_minlevel, + fclaw_ghost_update(glob,(*domain)->global_minlevel, (*domain)->global_maxlevel,0.0, - time_interp,FCLAW2D_TIMER_INIT); + time_interp,FCLAW_TIMER_INIT); } #if 0 @@ -164,31 +167,35 @@ void fclaw2d_initialize(fclaw2d_global_t *glob) int level; for (level = minlevel; level <= maxlevel; level++) { - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_REGRID_TAGGING]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_REGRID_TAGGING]); - fclaw2d_global_iterate_families(glob, cb_regrid_tag4coarsening, + fclaw_global_iterate_families(glob, cb_regrid_tag4coarsening, (void*) &domain_init); - fclaw2d_global_iterate_patches(glob,cb_fclaw2d_regrid_tag4refinement, - &domain_init); + fclaw_tag4f_user_t tag_user; + tag_user.domain_init = domain_init; + tag_user.num_patches_refined = 0; + tag_user.num_patches_to_refine = 0; + fclaw_global_iterate_patches(glob,cb_fclaw_regrid_tag4refinement, + &tag_user); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_REGRID_TAGGING]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_REGRID_TAGGING]); // Construct new domain based on tagged patches. - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_INIT]); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_ADAPT_COMM]); - fclaw2d_domain_t *new_domain = fclaw2d_domain_adapt(*domain); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_INIT]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_ADAPT_COMM]); + fclaw_domain_t *new_domain = fclaw_domain_adapt(*domain); int have_new_refinement = new_domain != NULL; if (have_new_refinement) { /* Have to get a new ddata */ - fclaw2d_domain_setup(glob,new_domain); + fclaw_domain_setup(glob,new_domain); } - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_ADAPT_COMM]); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_INIT]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_ADAPT_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_INIT]); if (have_new_refinement) { @@ -196,28 +203,28 @@ void fclaw2d_initialize(fclaw2d_global_t *glob) /* Re-initialize new grids. Ghost cell values needed for interpolation have already been set by initialization */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_REGRID_BUILD]); - fclaw2d_global_iterate_adapted(glob, new_domain, - cb_fclaw2d_regrid_repopulate, + fclaw_timer_start (&glob->timers[FCLAW_TIMER_REGRID_BUILD]); + fclaw_global_iterate_adapted(glob, new_domain, + cb_fclaw_regrid_repopulate, (void *) &domain_init); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_REGRID_BUILD]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_REGRID_BUILD]); /* free all memory associated with old domain */ - fclaw2d_domain_reset(glob); + fclaw_domain_reset(glob); *domain = new_domain; new_domain = NULL; /* Repartition domain to new processors. */ - fclaw2d_partition_domain(glob,FCLAW2D_TIMER_INIT); + fclaw_partition_domain(glob,FCLAW_TIMER_INIT); /* Set up ghost patches. This probably doesn't need to be done each time we add a new level. */ - fclaw2d_exchange_setup(glob,FCLAW2D_TIMER_INIT); + fclaw_exchange_setup(glob,FCLAW_TIMER_INIT); /* This is normally called from regrid, once the initial domain has been set up */ - fclaw2d_regrid_set_neighbor_types(glob); + fclaw_regrid_set_neighbor_types(glob); } else { @@ -230,20 +237,20 @@ void fclaw2d_initialize(fclaw2d_global_t *glob) if (fclaw_opt->init_ghostcell) { - fclaw2d_ghost_update(glob,(*domain)->global_minlevel, + fclaw_ghost_update(glob,(*domain)->global_minlevel, (*domain)->global_maxlevel,0.0, - time_interp,FCLAW2D_TIMER_INIT); + time_interp,FCLAW_TIMER_INIT); } - fclaw2d_diagnostics_initialize(glob); + fclaw_diagnostics_initialize(glob); fclaw_locate_gauges(glob); - fclaw2d_after_regrid(glob, 1); + fclaw_after_regrid(glob, 1); /* Print global minimum and maximum levels */ fclaw_global_infof("Global minlevel %d maxlevel %d\n", (*domain)->global_minlevel, (*domain)->global_maxlevel); /* Stop timer */ - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_INIT]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_INIT]); } diff --git a/src/fclaw2d_map.c b/src/fclaw_map.c similarity index 86% rename from src/fclaw2d_map.c rename to src/fclaw_map.c index 3e321654d..c3c6af966 100644 --- a/src/fclaw2d_map.c +++ b/src/fclaw_map.c @@ -23,51 +23,28 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif - -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif - - -#if PATCH_DIM == 2 - -#include -#include -#include /* Needed for pillowsphere query */ - -#elif PATCH_DIM == 3 && REFINE_DIM == 2 +#include +#include +#include /* Needed for pillowsphere query */ -#include -#include -//#include /* Needed for pillowsphere query */ -//#include <_fclaw2d_to_fclaw3d.h> - -#else /* this is full 3D */ -#include -#endif - -#ifndef P4_TO_P8 /* This function can be called from Fortran inside of ClawPatch. */ void -FCLAW2D_MAP_QUERY (fclaw2d_map_context_t ** pcont, +FCLAW_MAP_QUERY (fclaw_map_context_t ** pcont, const int *query_identifier, int *iresult) { - fclaw2d_map_context_t *cont = *pcont; + fclaw_map_context_t *cont = *pcont; *iresult = cont->query (cont, *query_identifier); } /* This function can be called from Fortran inside of ClawPatch. */ void -FCLAW2D_MAP_C2M (fclaw2d_map_context_t ** pcont, int *blockno, +FCLAW_MAP_2D_C2M (fclaw_map_context_t ** pcont, int *blockno, const double *xc, const double *yc, double *xp, double *yp, double *zp) { - fclaw2d_map_context_t *cont = *pcont; + fclaw_map_context_t *cont = *pcont; FCLAW_ASSERT(cont->mapc2m != NULL); cont->mapc2m (cont, *blockno, *xc, *yc, xp, yp, zp); } @@ -76,12 +53,12 @@ FCLAW2D_MAP_C2M (fclaw2d_map_context_t ** pcont, int *blockno, /* This function can be called from Fortran inside of ClawPatch. */ void -FCLAW2D_MAP_C2M_BASIS (fclaw2d_map_context_t ** pcont, +FCLAW_MAP_2D_C2M_BASIS (fclaw_map_context_t ** pcont, const double *xc, const double *yc, double *t, double *tinv, double *tderivs, int *flag) { - fclaw2d_map_context_t *cont = *pcont; + fclaw_map_context_t *cont = *pcont; FCLAW_ASSERT(cont->basis != NULL); cont->basis (cont, *xc, *yc, t, tinv, tderivs, *flag); @@ -95,40 +72,40 @@ FCLAW2D_MAP_C2M_BASIS (fclaw2d_map_context_t ** pcont, //#if PATCH_DIM == 3 && REFINE_DIM == 2 void -FCLAW3D_MAP_C2M (fclaw2d_map_context_t ** pcont, int *blockno, +FCLAW_MAP_3D_C2M (fclaw_map_context_t ** pcont, int *blockno, const double *xc, const double *yc, const double *zc, double *xp, double *yp, double *zp) { - fclaw2d_map_context_t *cont = *pcont; - FCLAW_ASSERT(cont->mapc2m_3dx != NULL); - cont->mapc2m_3dx (cont, *blockno, *xc, *yc, *zc, xp, yp, zp); + fclaw_map_context_t *cont = *pcont; + FCLAW_ASSERT(cont->mapc2m_3d != NULL); + cont->mapc2m_3d (cont, *blockno, *xc, *yc, *zc, xp, yp, zp); } void -FCLAW3D_MAP_C2M_BASIS (fclaw2d_map_context_t ** pcont, +FCLAW_MAP_3D_C2M_BASIS (fclaw_map_context_t ** pcont, const double *xc, const double *yc, const double *zc, double *t, double *tinv, double *tderivs, int *flag) { - fclaw2d_map_context_t *cont = *pcont; - FCLAW_ASSERT(cont->basis_3dx != NULL); + fclaw_map_context_t *cont = *pcont; + FCLAW_ASSERT(cont->basis_3d != NULL); /* DAC : Still need to decide what should go here */ - cont->basis_3dx (cont, *xc, *yc, *zc, t, tinv, tderivs, *flag); + cont->basis_3d (cont, *xc, *yc, *zc, t, tinv, tderivs, *flag); } //#endif -void FCLAW2D_MAP_BRICK2C (fclaw2d_map_context_t ** pcont, int *blockno, +void FCLAW_MAP_2D_BRICK2C (fclaw_map_context_t ** pcont, int *blockno, const double *xc, const double *yc, double *xp, double *yp, double *zp) { - fclaw2d_map_context_t *cont = *pcont; + fclaw_map_context_t *cont = *pcont; if (cont->brick != NULL) { - fclaw2d_map_context_t *brick = cont->brick; + fclaw_map_context_t *brick = cont->brick; brick->mapc2m (brick, *blockno, *xc, *yc, xp, yp, zp); } else @@ -141,16 +118,35 @@ void FCLAW2D_MAP_BRICK2C (fclaw2d_map_context_t ** pcont, int *blockno, } } -#endif /* !P4_TO_P8 */ +void FCLAW_MAP_3D_BRICK2C (fclaw_map_context_t ** pcont, int *blockno, + const double *xc, const double *yc, const double *zc, + double *xp, double *yp, double *zp) +{ + fclaw_map_context_t *cont = *pcont; + + if (cont->brick != NULL) + { + fclaw_map_context_t *brick = cont->brick; + brick->mapc2m_3d (brick, *blockno, *xc, *yc, *zc, xp, yp, zp); + } + else + { + /* We only have one tree */ + FCLAW_ASSERT(blockno == 0); + *xp = *xc; + *yp = *yc; + *zp = *zc; + } +} /* This function is expected to be called from C or C++. */ void -fclaw2d_map_destroy (fclaw2d_map_context_t * cont) +fclaw_map_destroy (fclaw_map_context_t * cont) { #ifndef P4_TO_P8 if (cont->brick != NULL) { - fclaw2d_map_destroy(cont->brick); /* recursive call */ + fclaw_map_destroy(cont->brick); /* recursive call */ } #endif if (cont->destroy == NULL) @@ -163,8 +159,6 @@ fclaw2d_map_destroy (fclaw2d_map_context_t * cont) } } -#ifndef P4_TO_P8 - #if 0 /* Cubed sphere surface. Matches p4est_connectivity_new_cubed (). */ @@ -489,18 +483,18 @@ fclaw2d_options_postprocess_map_data(fclaw2d_map_data_t * map_data) } #endif -int fclaw2d_map_pillowsphere(fclaw2d_global_t* glob) +int fclaw_map_pillowsphere(fclaw_global_t* glob) { - fclaw2d_map_context_t *cont = glob->cont; - return FCLAW2D_MAP_IS_PILLOWSPHERE(&cont) != 0; + fclaw_map_context_t *cont = glob->cont; + return FCLAW_MAP_IS_PILLOWSPHERE(&cont) != 0; } -void set_scale(fclaw2d_map_context_t* cont, const double scale[]) +void set_scale(fclaw_map_context_t* cont, const double scale[]) { memcpy(cont->scale,scale,3*sizeof(double)); } -void set_shift(fclaw2d_map_context_t* cont, const double shift[]) +void set_shift(fclaw_map_context_t* cont, const double shift[]) { memcpy(cont->shift,shift,3*sizeof(double)); } @@ -517,28 +511,28 @@ void set_default_transform(double scale[],double shift[],double rotate[]) rotate[1] = 0; } -void set_rotate(fclaw2d_map_context_t* cont, const double rotate[]) +void set_rotate(fclaw_map_context_t* cont, const double rotate[]) { double rotate_mat[9]; SET_ROTATION_MATRIX(rotate,rotate_mat); memcpy(cont->rotate,rotate_mat,9*sizeof(double)); } -void scale_map(fclaw2d_map_context_t* cont, double *xp, double *yp, double *zp) +void scale_map(fclaw_map_context_t* cont, double *xp, double *yp, double *zp) { *xp *= cont->scale[0]; *yp *= cont->scale[1]; *zp *= cont->scale[2]; } -void shift_map(fclaw2d_map_context_t* cont, double *xp, double *yp, double *zp) +void shift_map(fclaw_map_context_t* cont, double *xp, double *yp, double *zp) { *xp += cont->shift[0]; *yp += cont->shift[1]; *zp += cont->shift[2]; } -void rotate_map(fclaw2d_map_context_t* cont, double *xp, double *yp, double *zp) +void rotate_map(fclaw_map_context_t* cont, double *xp, double *yp, double *zp) { double v[3], vrot[3]; int i,j; @@ -560,4 +554,3 @@ void rotate_map(fclaw2d_map_context_t* cont, double *xp, double *yp, double *zp) *zp = vrot[2]; } -#endif /* !P4_TO_P8 */ diff --git a/src/fclaw2d_map.h b/src/fclaw_map.h similarity index 65% rename from src/fclaw2d_map.h rename to src/fclaw_map.h index 7e1cffcc8..20cdfae92 100644 --- a/src/fclaw2d_map.h +++ b/src/fclaw_map.h @@ -23,11 +23,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_MAP_H -#define FCLAW2D_MAP_H +#ifndef FCLAW_MAP_H +#define FCLAW_MAP_H #include -#include +#include #ifdef __cplusplus extern "C" @@ -39,9 +39,9 @@ extern "C" #endif struct p4est_connectivity; -struct fclaw2d_global; +struct fclaw_global; -struct fclaw2d_map_context; +struct fclaw_map_context; /** This prototype matches the Fortran mapc2m functions used in ClawPatch. */ @@ -49,9 +49,9 @@ typedef void (*fclaw2d_map_c2m_fortran_t) (const double *xc, const double *yc, double *xp, double *yp, double *zp); -#define FCLAW2D_MAP_QUERY FCLAW_F77_FUNC_(fclaw2d_map_query,FCLAW2D_MAP_QUERY) +#define FCLAW_MAP_QUERY FCLAW_F77_FUNC_(fclaw_map_query,FCLAW_MAP_QUERY) -typedef struct fclaw2d_map_context fclaw2d_map_context_t; +typedef struct fclaw_map_context fclaw_map_context_t; typedef struct fclaw2d_map_data fclaw2d_map_data_t; /** This function is used to query the map for general properties. @@ -60,7 +60,7 @@ typedef struct fclaw2d_map_data fclaw2d_map_data_t; * Be sure to use the symbolic constants above. * \return Result of the query. */ -typedef int (*fclaw2d_map_query_t) (fclaw2d_map_context_t * cont, +typedef int (*fclaw_map_query_t) (fclaw_map_context_t * cont, int query_identifier); /** This function performs the coordinate transformation. @@ -72,78 +72,78 @@ typedef int (*fclaw2d_map_query_t) (fclaw2d_map_context_t * cont, * \param [out] yp Transformed y-coordinate. * \param [out] zp Transformed z-coordinate. */ -typedef void (*fclaw2d_map_c2m_t) (fclaw2d_map_context_t * cont, int blockno, +typedef void (*fclaw_map_2d_c2m_t) (fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp); /* Covariant and contravariant basis vectors needed for exact solution */ -typedef void (*fclaw2d_map_c2m_basis_t)(fclaw2d_map_context_t * cont, +typedef void (*fclaw_map_2d_c2m_basis_t)(fclaw_map_context_t * cont, double xc, double yc, double *t, double *tinv, double *tderivs, int flag); /* For extruded mesh mappings */ -typedef void (*fclaw3dx_map_c2m_t) (fclaw2d_map_context_t * cont, int blockno, +typedef void (*fclaw_map_3d_c2m_t) (fclaw_map_context_t * cont, int blockno, double xc, double yc,double zc, double *xp, double *yp, double *zp); /* Covariant and contravariant basis vectors needed for exact solution */ -typedef void (*fclaw3dx_map_c2m_basis_t)(fclaw2d_map_context_t * cont, +typedef void (*fclaw_map_3d_c2m_basis_t)(fclaw_map_context_t * cont, double xc, double yc, double zc, double *t, double *tinv, double *tderivs, int flag); /** Destructor for a fclaw2d_map_context. */ -typedef void (*fclaw2d_map_destroy_t) (fclaw2d_map_context_t * cont); +typedef void (*fclaw_map_destroy_t) (fclaw_map_context_t * cont); /** Mapping context that is interpreted by its query and c2m members. * The callbacks are free to define the meaning of the user_* fields. */ -struct fclaw2d_map_context +struct fclaw_map_context { - fclaw2d_map_query_t query; + fclaw_map_query_t query; - fclaw2d_map_c2m_t mapc2m; - fclaw2d_map_c2m_basis_t basis; + fclaw_map_2d_c2m_t mapc2m; + fclaw_map_2d_c2m_basis_t basis; - fclaw3dx_map_c2m_t mapc2m_3dx; /* Takes a 2d context */ - fclaw3dx_map_c2m_basis_t basis_3dx; + fclaw_map_3d_c2m_t mapc2m_3d; + fclaw_map_3d_c2m_basis_t basis_3d; int is_extruded; - fclaw2d_map_destroy_t destroy; + fclaw_map_destroy_t destroy; /* Used strictly for 2d mapping */ int user_int[16]; double user_double[16]; /* Create separate data for 2d and 3dx */ - int user_int_3dx[16]; - double user_double_3dx[16]; + int user_int_3d[16]; + double user_double_3d[16]; double scale[3]; double shift[3]; double rotate[9]; - fclaw2d_map_context_t *brick; + fclaw_map_context_t *brick; void *user_data; }; -void set_scale(fclaw2d_map_context_t* cont, const double scale[]); -void set_shift(fclaw2d_map_context_t* cont, const double shift[]); -void set_rotate(fclaw2d_map_context_t* cont, const double rotate[]); +void set_scale(fclaw_map_context_t* cont, const double scale[]); +void set_shift(fclaw_map_context_t* cont, const double shift[]); +void set_rotate(fclaw_map_context_t* cont, const double rotate[]); void set_default_transform(double scale[],double shift[],double rotate[]); -void scale_map(fclaw2d_map_context_t* cont, +void scale_map(fclaw_map_context_t* cont, double *xp, double *yp, double *zp); -void shift_map(fclaw2d_map_context_t* cont, +void shift_map(fclaw_map_context_t* cont, double *xp, double *yp, double *zp); -void rotate_map(fclaw2d_map_context_t* cont, +void rotate_map(fclaw_map_context_t* cont, double *xp, double *yp, double *zp); #define SET_ROTATION_MATRIX FCLAW_F77_FUNC (set_rotation_matrix,SET_ROTATION_MATRIX) @@ -159,7 +159,7 @@ void SET_ROTATION_MATRIX (const double rot_angles[],double rrot[]); */ -void FCLAW2D_MAP_QUERY (fclaw2d_map_context_t ** cont, +void FCLAW_MAP_QUERY (fclaw_map_context_t ** cont, const int *query_identifier, int *iresult); @@ -174,31 +174,31 @@ void FCLAW2D_MAP_QUERY (fclaw2d_map_context_t ** cont, * \param [out] mz Transformed z-coordinate. */ -#define FCLAW2D_MAP_C2M FCLAW_F77_FUNC_(fclaw2d_map_c2m,FCLAW2D_MAP_C2M) -void FCLAW2D_MAP_C2M (fclaw2d_map_context_t ** cont, int *blockno, +#define FCLAW_MAP_2D_C2M FCLAW_F77_FUNC_(fclaw_map_2d_c2m,FCLAW_MAP_2D_C2M) +void FCLAW_MAP_2D_C2M (fclaw_map_context_t ** cont, int *blockno, const double *xc, const double *yc, double *xp, double *yp, double *zp); -#define FCLAW2D_MAP_C2M_BASIS FCLAW_F77_FUNC_(fclaw2d_map_c2m_basis, \ - FCLAW2D_MAP_C2M_BASIS) +#define FCLAW_MAP_2D_C2M_BASIS FCLAW_F77_FUNC_(fclaw_map_2d_c2m_basis, \ + FCLAW_MAP_2D_C2M_BASIS) -void FCLAW2D_MAP_C2M_BASIS (fclaw2d_map_context_t ** cont, +void FCLAW_MAP_2D_C2M_BASIS (fclaw_map_context_t ** cont, const double *xc, const double *yc, double *t, double *tinv, double *tderivs, int * flag); -#define FCLAW3D_MAP_C2M FCLAW_F77_FUNC_(fclaw3d_map_c2m,FCLAW3D_MAP_C2M) -void FCLAW3D_MAP_C2M (fclaw2d_map_context_t ** cont, int *blockno, +#define FCLAW_MAP_3D_C2M FCLAW_F77_FUNC_(fclaw_map_3d_c2m,FCLAW_MAP_3D_C2M) +void FCLAW_MAP_3D_C2M (fclaw_map_context_t ** cont, int *blockno, const double *xc, const double *yc, const double *zc, double *xp, double *yp, double *zp); -#define FCLAW3D_MAP_C2M_BASIS FCLAW_F77_FUNC_(fclaw3d_map_c2m_basis, \ - FCLAW3D_MAP_C2M_BASIS) +#define FCLAW_MAP_3D_C2M_BASIS FCLAW_F77_FUNC_(fclaw_map_3d_c2m_basis, \ + FCLAW_MAP_3D_C2M_BASIS) -void FCLAW3D_MAP_C2M_BASIS (fclaw2d_map_context_t ** cont, +void FCLAW_MAP_3D_C2M_BASIS (fclaw_map_context_t ** cont, const double *xc, const double *yc, const double *zc, double *t, double *tinv, double *tderivs, int * flag); @@ -207,19 +207,36 @@ void FCLAW3D_MAP_C2M_BASIS (fclaw2d_map_context_t ** cont, /** Map brick to computational coordinates in [0,1]x[0,1] * \param [in] cont Mapping context with matching callback functions. * \param [in] blockno Number of the block to be transformed. - * \param [in] cx X-coordinate in [block->xlower, block->xupper]. - * \param [in] cy Y-coordinate in [block->ylower, block->yupper]. + * \param [in] xc X-coordinate in [block->xlower, block->xupper]. + * \param [in] yc Y-coordinate in [block->ylower, block->yupper]. * \param [out] mx Transformed x-coordinate. * \param [out] my Transformed y-coordinate. * \param [out] mz Transformed z-coordinate. */ -#define FCLAW2D_MAP_BRICK2C FCLAW_F77_FUNC_(fclaw2d_map_brick2c, \ - FCLAW2D_MAP_BRICK2C) -void FCLAW2D_MAP_BRICK2C (fclaw2d_map_context_t ** cont, int *blockno, +#define FCLAW_MAP_2D_BRICK2C FCLAW_F77_FUNC_(fclaw_map_2d_brick2c, \ + FCLAW_MAP_2D_BRICK2C) +void FCLAW_MAP_2D_BRICK2C (fclaw_map_context_t ** cont, int *blockno, const double *xc, const double *yc, double *xp, double *yp, double *zp); +/** Map brick to computational coordinates in [0,1]x[0,1]x[0,1] + * \param [in] cont Mapping context with matching callback functions. + * \param [in] blockno Number of the block to be transformed. + * \param [in] xc X-coordinate in [block->xlower, block->xupper]. + * \param [in] yc Y-coordinate in [block->ylower, block->yupper]. + * \param [in] zc Z-coordinate in [block->zlower, block->zupper]. + * \param [out] mx Transformed x-coordinate. + * \param [out] my Transformed y-coordinate. + * \param [out] mz Transformed z-coordinate. + */ +#define FCLAW_MAP_3D_BRICK2C FCLAW_F77_FUNC_(fclaw_map_3d_brick2c, \ + FCLAW_MAP_3D_BRICK2C) +void FCLAW_MAP_3D_BRICK2C (fclaw_map_context_t ** cont, int *blockno, + const double *xc, const double *yc, const double *zc, + double *xp, double *yp, double *zp); + + /** Deallocate a mapping context. * If the \a destroy member is not NULL, it is called on the context. @@ -227,12 +244,40 @@ void FCLAW2D_MAP_BRICK2C (fclaw2d_map_context_t ** cont, int *blockno, * \param [in] cont Mapping context where the \a destroy member is either * NULL or a valid function that is then called. */ -void fclaw2d_map_destroy (fclaw2d_map_context_t * cont); - -fclaw2d_map_context_t* fclaw2d_map_new_nomap_brick(fclaw2d_map_context_t* brick); -void fclaw2d_map_c2m_nomap_brick(fclaw2d_map_context_t * cont, int blockno, - double xc, double yc, - double *xp, double* yp, double *zp); +void fclaw_map_destroy (fclaw_map_context_t * cont); + +fclaw_map_context_t* fclaw_map_new_nomap_brick(fclaw_map_context_t* brick); + +/** + * Maps the coordinates (xc, yc) from within a block to the entire brick + * + * @param cont The map context. + * @param blockno The block number. + * @param xc The x-coordinate in the block + * @param yc The y-coordinate in the block + * @param xp Pointer to store the x-coordinate in the brick + * @param yp Pointer to store the y-coordinate in the brick + * @param zp Pointer to store the z-coordinate in the brick + */ +void fclaw_map_2d_c2m_nomap_brick(fclaw_map_context_t * cont, int blockno, + double xc, double yc, + double *xp, double* yp, double *zp); + +/** + * Maps the coordinates (xc, yc, zc) from within a block to the entire brick + * + * @param cont The map context. + * @param blockno The block number. + * @param xc The x-coordinate in the block + * @param yc The y-coordinate in the block + * @param zc The z-coordinate in the block + * @param xp Pointer to store the x-coordinate in the brick + * @param yp Pointer to store the y-coordinate in the brick + * @param zp Pointer to store the z-coordinate in the brick + */ +void fclaw_map_3d_c2m_nomap_brick(fclaw_map_context_t * cont, int blockno, + double xc, double yc, double zc, + double *xp, double* yp, double *zp); /* ---------------------------------------------------------------------------------- @@ -291,7 +336,7 @@ fclaw2d_map_context_t *fclaw2d_map_new_fortran (fclaw2d_map_c2m_fortran_t We provide an alternative, temporarily called fclaw2d_map_new_brick_domain, in the fclaw2d_map_brick files. */ -fclaw2d_map_context_t* fclaw2d_map_new_brick_conn +fclaw_map_context_t* fclaw2d_map_new_brick_conn (struct p4est_connectivity* conn, int mi, int mj); @@ -300,7 +345,7 @@ fclaw2d_map_context_t* fclaw2d_map_new_brick_conn ---------------------------------------------------------------------------------- */ /* This is called to determine is a map is a pillow sphere or not */ -int fclaw2d_map_pillowsphere(struct fclaw2d_global* glob); +int fclaw_map_pillowsphere(struct fclaw_global* glob); #if 0 @@ -346,7 +391,7 @@ void SET_BLOCK(const int * a_blockno); #define FCLAW_MAP_SET_CONTEXT FCLAW_F77_FUNC (fclaw_map_set_context, \ FCLAW_MAP_SET_CONTEXT) -void FCLAW_MAP_SET_CONTEXT (fclaw2d_map_context_t** a_context); +void FCLAW_MAP_SET_CONTEXT (fclaw_map_context_t** a_context); /* ---------------------------------------------------------------------------------- @@ -355,7 +400,7 @@ void FCLAW_MAP_SET_CONTEXT (fclaw2d_map_context_t** a_context); /* -------------------------------------- No map -------------------------------------- */ -fclaw2d_map_context_t* fclaw2d_map_new_nomap(); +fclaw_map_context_t* fclaw_map_new_nomap(); /* -------------------------------- Brick mapping ----------------------------------- */ @@ -370,39 +415,39 @@ fclaw2d_map_context_t* fclaw2d_map_new_brick(struct p4est_connectivity* conn, /* --------------------------------- Square mappings ---------------------------------- */ -fclaw2d_map_context_t* fclaw2d_map_new_identity(fclaw2d_map_context_t *brick); +fclaw_map_context_t* fclaw2d_map_new_identity(fclaw_map_context_t *brick); -fclaw2d_map_context_t* fclaw2d_map_new_cart(fclaw2d_map_context_t* brick, +fclaw_map_context_t* fclaw2d_map_new_cart(fclaw_map_context_t* brick, const double scale[], const double shift[]); -fclaw2d_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_fivepatch(const double scale[], const double shift[], const double alpha); -fclaw2d_map_context_t* fclaw2d_map_new_squareddisk(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_squareddisk(const double scale[], const double shift[], const double alpha); -fclaw2d_map_context_t* fclaw2d_map_new_bilinear(fclaw2d_map_context_t *brick, +fclaw_map_context_t* fclaw2d_map_new_bilinear(fclaw_map_context_t *brick, const double scale[], const double shift[], const double center[]); /* ---------------------------------- Disk mappings ----------------------------------- */ -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk(const double scale[], const double shift[], const double rotate[]); -fclaw2d_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowdisk5(const double scale[], const double shift[], const double rotate[], const double alpha); /* --------------------------------- Annulus mapping ---------------------------------- */ -fclaw2d_map_context_t * - fclaw2d_map_new_annulus (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_annulus (fclaw_map_context_t* brick, const double scale[], const double rotate[], const double alpha, @@ -410,8 +455,8 @@ fclaw2d_map_context_t * /* --------------------------------- Latlong mapping ---------------------------------- */ -fclaw2d_map_context_t * - fclaw2d_map_new_latlong (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_latlong (fclaw_map_context_t* brick, const double scale[], const double rotate[], const double lat[], @@ -420,21 +465,21 @@ fclaw2d_map_context_t * /* --------------------------------- Hemisphere mappings ------------------------------ */ -fclaw2d_map_context_t* fclaw2d_map_new_pillowsphere5(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowsphere5(const double scale[], const double rotate[], const double alpha); /* --------------------------------- Sphere mappings ---------------------------------- */ -fclaw2d_map_context_t* fclaw2d_map_new_pillowsphere(const double scale[], +fclaw_map_context_t* fclaw2d_map_new_pillowsphere(const double scale[], const double rotate[]); -fclaw2d_map_context_t * fclaw2d_map_new_cubedsphere (const double scale[], +fclaw_map_context_t * fclaw2d_map_new_cubedsphere (const double scale[], const double rotate[]); /* --------------------------------- Torus mappings ---------------------------------- */ -fclaw2d_map_context_t * - fclaw2d_map_new_torus (fclaw2d_map_context_t* brick, +fclaw_map_context_t * + fclaw2d_map_new_torus (fclaw_map_context_t* brick, const double scale[], const double rotate[], const double alpha, @@ -450,59 +495,59 @@ fclaw2d_map_context_t * ---------------------------------------------------------------------------------- */ /* Single block mappings */ -#define MAPC2M_IDENTITY FCLAW_F77_FUNC (mapc2m_identity,MAPC2M_IDENTITY) -void MAPC2M_IDENTITY (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_IDENTITY FCLAW_F77_FUNC (fclaw_map_2d_c2m_identity,FCLAW_MAP_2D_C2M_IDENTITY) +void FCLAW_MAP_2D_C2M_IDENTITY (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp); /* Single block mappings */ -#define MAPC2M_CART FCLAW_F77_FUNC (mapc2m_cart,MAPC2M_CART) -void MAPC2M_CART (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_CART FCLAW_F77_FUNC (fclaw_map_2d_c2m_cart,FCLAW_MAP_2D_C2M_CART) +void FCLAW_MAP_2D_C2M_CART (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp); -#define MAPC2M_PILLOWDISK FCLAW_F77_FUNC (mapc2m_pillowdisk,MAPC2M_PILLOWDISK) -void MAPC2M_PILLOWDISK (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_PILLOWDISK FCLAW_F77_FUNC (fclaw_map_2d_c2m_pillowdisk,FCLAW_MAP_2D_C2M_PILLOWDISK) +void FCLAW_MAP_2D_C2M_PILLOWDISK (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp); -#define MAPC2M_PILLOWDISK5 FCLAW_F77_FUNC (mapc2m_pillowdisk5,MAPC2M_PILLOWDISK5) -void MAPC2M_PILLOWDISK5 (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_PILLOWDISK5 FCLAW_F77_FUNC (fclaw_map_2d_c2m_pillowdisk5,FCLAW_MAP_2D_C2M_PILLOWDISK5) +void FCLAW_MAP_2D_C2M_PILLOWDISK5 (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp, double *alpha); /* multi-block mappings */ -#define MAPC2M_SQUAREDDISK FCLAW_F77_FUNC (mapc2m_squareddisk,MAPC2M_SQUAREDDISK) -void MAPC2M_SQUAREDDISK (int *blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_SQUAREDDISK FCLAW_F77_FUNC (fclaw_map_2d_c2m_squareddisk,FCLAW_MAP_2D_C2M_SQUAREDDISK) +void FCLAW_MAP_2D_C2M_SQUAREDDISK (int *blockno, double *xc, double *yc, double *xp, double *yp, double *zp, double *alpha); -#define MAPC2M_FIVEPATCH FCLAW_F77_FUNC (mapc2m_fivepatch,MAPC2M_FIVEPATCH) -void MAPC2M_FIVEPATCH (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_FIVEPATCH FCLAW_F77_FUNC (fclaw_map_2d_c2m_fivepatch,FCLAW_MAP_2D_C2M_FIVEPATCH) +void FCLAW_MAP_2D_C2M_FIVEPATCH (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp,double *alpha); -#define MAPC2M_CUBEDSPHERE FCLAW_F77_FUNC (mapc2m_cubedsphere,MAPC2M_CUBEDSPHERE) -void MAPC2M_CUBEDSPHERE (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_CUBEDSPHERE FCLAW_F77_FUNC (fclaw_map_2d_c2m_cubedsphere,FCLAW_MAP_2D_C2M_CUBEDSPHERE) +void FCLAW_MAP_2D_C2M_CUBEDSPHERE (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp); -#define MAPC2M_PILLOWSPHERE FCLAW_F77_FUNC (mapc2m_pillowsphere,MAPC2M_PILLOWSPHERE) -void MAPC2M_PILLOWSPHERE (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_PILLOWSPHERE FCLAW_F77_FUNC (fclaw_map_2d_c2m_pillowsphere,FCLAW_MAP_2D_C2M_PILLOWSPHERE) +void FCLAW_MAP_2D_C2M_PILLOWSPHERE (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp); -#define MAPC2M_TORUS FCLAW_F77_FUNC (mapc2m_torus,MAPC2M_TORUS) -void MAPC2M_TORUS (double *xc, double *yc, double *xp, double *yp, double *zp, +#define FCLAW_MAP_2D_C2M_TORUS FCLAW_F77_FUNC (fclaw_map_2d_c2m_torus,FCLAW_MAP_2D_C2M_TORUS) +void FCLAW_MAP_2D_C2M_TORUS (double *xc, double *yc, double *xp, double *yp, double *zp, double* alpha, double* beta); -#define MAPC2M_TWISTED_TORUS FCLAW_F77_FUNC (mapc2m_twisted_torus,MAPC2M_TWISTED_TORUS) -void MAPC2M_TWISTED_TORUS (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_TWISTED_TORUS FCLAW_F77_FUNC (fclaw_map_2d_c2m_twisted_torus,FCLAW_MAP_2D_C2M_TWISTED_TORUS) +void FCLAW_MAP_2D_C2M_TWISTED_TORUS (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp, double* alpha); -#define MAPC2M_BRICK FCLAW_F77_FUNC (mapc2m_brick,MAPC2M_BRICK) -void MAPC2M_BRICK (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_BRICK FCLAW_F77_FUNC (fclaw_map_2d_c2m_brick,FCLAW_MAP_2D_C2M_BRICK) +void FCLAW_MAP_2D_C2M_BRICK (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp, int *mi, int *mj); -#define MAPC2M_LATLONG FCLAW_F77_FUNC (mapc2m_latlong,MAPC2M_LATLONG) -void MAPC2M_LATLONG (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_LATLONG FCLAW_F77_FUNC (fclaw_map_2d_c2m_latlong,FCLAW_MAP_2D_C2M_LATLONG) +void FCLAW_MAP_2D_C2M_LATLONG (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp); -#define MAPC2M_ANNULUS FCLAW_F77_FUNC (mapc2m_annulus,MAPC2M_ANNULUS) -void MAPC2M_ANNULUS (int* blockno, double *xc, double *yc, +#define FCLAW_MAP_2D_C2M_ANNULUS FCLAW_F77_FUNC (fclaw_map_2d_c2m_annulus,FCLAW_MAP_2D_C2M_ANNULUS) +void FCLAW_MAP_2D_C2M_ANNULUS (int* blockno, double *xc, double *yc, double *xp, double *yp, double *zp, double *alpha, double *theta); diff --git a/src/fclaw_map_brick.c b/src/fclaw_map_brick.c new file mode 100644 index 000000000..a48fbba78 --- /dev/null +++ b/src/fclaw_map_brick.c @@ -0,0 +1,182 @@ +/* Cartesian grid, tranformed to Ax + b */ + +#include + +#include +#include + +static int +fclaw2d_map_query_brick (fclaw_map_context_t * cont, int query_identifier) +{ + switch (query_identifier) + { + case FCLAW_MAP_QUERY_IS_USED: + return 1; + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: + return 1; + case FCLAW_MAP_QUERY_IS_AFFINE: + return 1; + case FCLAW_MAP_QUERY_IS_NONLINEAR: + return 0; + case FCLAW_MAP_QUERY_IS_GRAPH: + return 0; + case FCLAW_MAP_QUERY_IS_PLANAR: + return 1; + case FCLAW_MAP_QUERY_IS_ALIGNED: + return 0; + case FCLAW_MAP_QUERY_IS_FLAT: + return 1; + case FCLAW_MAP_QUERY_IS_DISK: + return 0; + case FCLAW_MAP_QUERY_IS_SPHERE: + return 0; + case FCLAW_MAP_QUERY_IS_PILLOWDISK: + return 0; + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: + return 0; + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: + return 0; + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: + return 0; + case FCLAW_MAP_QUERY_IS_FIVEPATCH: + return 0; + case FCLAW_MAP_QUERY_IS_CART: + return 1; + case FCLAW_MAP_QUERY_IS_BRICK: + return 1; + default: + printf("\n"); + printf("fclaw2d_map_query_brick (fclaw2d_map_brick.h) : "\ + "Query id not identified; Maybe the query is not up to "\ + "date?\nSee fclaw2d_map_brick.c.\n"); + printf("Requested query id : %d\n",query_identifier); + SC_ABORT_NOT_REACHED (); + } + return 0; +} + +void +FCLAW_MAP_BRICK_GET_2D_DIM(fclaw_map_context_t **cont, + int *mi, int* mj) +{ + fclaw_block_ll_t *bv = (fclaw_block_ll_t *) (*cont)->brick->user_data; + *mi = bv->mi; + *mj = bv->mj; +} + + +static void +fclaw_map_c2m_2d_brick(fclaw_map_context_t * cont, int blockno, + double xc, double yc, + double *xp, double *yp, double *zp) +{ + /* Map the brick coordinates to global [0,1] coordinates. */ + fclaw_block_ll_t *bv = (fclaw_block_ll_t *) cont->user_data; + *xp = (double) (bv->xv[blockno] + xc)/bv->mi; + *yp = (double) (bv->yv[blockno] + yc)/bv->mj; + *zp = 0; +} +static void +fclaw_map_c2m_3d_brick(fclaw_map_context_t * cont, int blockno, + double xc, double yc, double zc, + double *xp, double *yp, double *zp) +{ + /* Map the brick coordinates to global [0,1] coordinates. */ + fclaw_block_ll_t *bv = (fclaw_block_ll_t *) cont->user_data; + *xp = (double) (bv->xv[blockno] + xc)/bv->mi; + *yp = (double) (bv->yv[blockno] + yc)/bv->mj; + *zp = (double) (bv->zv[blockno] + zc)/bv->mk; +} + +void fclaw_map_destroy_brick(fclaw_map_context_t *cont) +{ + fclaw_block_ll_t *bv = (fclaw_block_ll_t *) cont->user_data; + FCLAW_FREE(bv->xv); + FCLAW_FREE(bv->yv); + FCLAW_FREE(bv->zv); + + FCLAW_FREE (cont->user_data); + FCLAW_FREE (cont); +} + +static +fclaw_block_ll_t* new_block_data(fclaw_domain_t *domain, + int mi, int mj, int mk, + int periodic_i, int periodic_j, int periodic_k) +{ + int nb = domain->num_blocks; + + fclaw_block_ll_t *bv = FCLAW_ALLOC_ZERO(fclaw_block_ll_t,1); + + /* We don't store this in user_double[], since that only has limited + storage (16 doubles) */ + bv->xv = FCLAW_ALLOC_ZERO(double,nb); + bv->yv = FCLAW_ALLOC_ZERO(double,nb); + bv->zv = FCLAW_ALLOC_ZERO(double,nb); + + bv->nb = nb; /* These integer values could also be stored in user_int[] data */ + bv->mi = mi; + bv->mj = mj; + bv->mk = mk; + + for (int i = 0; i < nb; i++) + { + fclaw_block_t *block = &domain->blocks[i]; + + /* (x,y) reference coordinates of lower-left block corner */ + bv->xv[i] = block->vertices[0]; + bv->yv[i] = block->vertices[1]; + bv->zv[i] = block->vertices[2]; + } + return bv; +} + +fclaw_map_context_t* +fclaw_map_new_2d_brick (fclaw_domain_t *domain, + int mi, int mj, int periodic_i, int periodic_j) +{ + fclaw_map_context_t* cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); + cont->query = fclaw2d_map_query_brick; + cont->mapc2m = fclaw_map_c2m_2d_brick; + cont->destroy = fclaw_map_destroy_brick; + + fclaw_block_ll_t *bv = new_block_data(domain, mi, mj, 1, periodic_i, periodic_j, 0); + + cont->user_data = (void*) bv; + + /* Write data for Matlab plotting */ + FILE *fid; + fid = fopen("brick.dat","w"); + fprintf(fid,"%8d %8d\n",mi, mj); + for(int i = 0; i < bv->nb; i++) + { + fprintf(fid,"%12g %12g\n",bv->xv[i], bv->yv[i]); + } + fclose(fid); + return cont; +} + +fclaw_map_context_t* +fclaw_map_new_3d_brick (fclaw_domain_t *domain, + int mi, int mj, int mk, int periodic_i, int periodic_j, int periodic_k) +{ + fclaw_map_context_t* cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); + cont->query = fclaw2d_map_query_brick; + cont->mapc2m_3d = fclaw_map_c2m_3d_brick; + cont->destroy = fclaw_map_destroy_brick; + + fclaw_block_ll_t *bv = new_block_data(domain, mi, mj, mk, periodic_i, periodic_j, periodic_k); + + cont->user_data = (void*) bv; + + /* Write data for Matlab plotting */ + FILE *fid; + fid = fopen("brick.dat","w"); + fprintf(fid,"%8d %8d\n",mi, mj); + for(int i = 0; i < bv->nb; i++) + { + fprintf(fid,"%12g %12g %12g\n",bv->xv[i], bv->yv[i], bv->zv[i]); + } + fclose(fid); + return cont; +} diff --git a/src/fclaw2d_map_brick.h b/src/fclaw_map_brick.h similarity index 53% rename from src/fclaw2d_map_brick.h rename to src/fclaw_map_brick.h index e7d9c5a04..6357648e6 100644 --- a/src/fclaw2d_map_brick.h +++ b/src/fclaw_map_brick.h @@ -23,11 +23,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_MAP_BRICK_H -#define FCLAW2D_MAP_BRICK_H +#ifndef FCLAW_MAP_BRICK_H +#define FCLAW_MAP_BRICK_H #include -#include +#include #ifdef __cplusplus extern "C" @@ -37,14 +37,14 @@ extern "C" #endif #endif -struct fclaw2d_map_context; +struct fclaw_map_context; -#define FCLAW2D_MAP_BRICK_GET_DIM FCLAW_F77_FUNC (fclaw2d_map_brick_get_dim, \ - FCLAW2D_MAP_BRICK_GET_DIM) +#define FCLAW_MAP_BRICK_GET_2D_DIM FCLAW_F77_FUNC (fclaw_map_brick_get_2d_dim, \ + FCLAW_MAP_BRICK_GET_2D_DIM) -void FCLAW2D_MAP_BRICK_GET_DIM(struct fclaw2d_map_context **cont, +void FCLAW_MAP_BRICK_GET_2D_DIM(struct fclaw_map_context **cont, int *mi, int* mj); @@ -57,20 +57,52 @@ void WRITE_BRICK_DATA(int* n, double xv[], double yv[]); -typedef struct fclaw2d_block_ll +typedef struct fclaw_block_ll { int nb; - int mi, mj; + int mi, mj, mk; /**< Number of blocks in each direction */ double *xv; double *yv; + double *zv; } -fclaw2d_block_ll_t; - -struct fclaw2d_map_context* -fclaw2d_map_new_brick (fclaw2d_domain_t *domain, +fclaw_block_ll_t; + +/** + * @brief Creates a new 2D brick map context. + * + * @param domain The domain to which the map context belongs. + * @param mi The number of cells in the x-direction of the brick. + * @param mj The number of cells in the y-direction of the brick. + * @param periodic_i Flag indicating whether the x-direction is periodic. + * @param periodic_j Flag indicating whether the y-direction is periodic. + * @return A pointer to the newly created map context. + */ +struct fclaw_map_context* +fclaw_map_new_2d_brick (fclaw_domain_t *domain, int mi, int mj, int periodic_i, int periodic_j); -void fclaw2d_map_destroy_brick (struct fclaw2d_map_context *cont); +/** + * @brief Creates a new 2D brick map context. + * + * @param domain The domain to which the map context belongs. + * @param mi The number of cells in the x-direction of the brick. + * @param mj The number of cells in the y-direction of the brick. + * @param periodic_i Flag indicating whether the x-direction is periodic. + * @param periodic_j Flag indicating whether the y-direction is periodic. + * @return A pointer to the newly created map context. + */ +struct fclaw_map_context* +fclaw_map_new_3d_brick (fclaw_domain_t *domain, + int mi, int mj, int mk, + int periodic_i, int periodic_j, int periodic_k); + + +/** + * @brief Destroys a brick mapping context. + * + * @param cont The fclaw_map_context to destroy + */ +void fclaw_map_destroy_brick (struct fclaw_map_context *cont); #ifdef __cplusplus #if 0 diff --git a/src/fclaw2d_map_query.c b/src/fclaw_map_query.c similarity index 58% rename from src/fclaw2d_map_query.c rename to src/fclaw_map_query.c index 855b63c13..2149da47b 100644 --- a/src/fclaw2d_map_query.c +++ b/src/fclaw_map_query.c @@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if PATCH_DIM == 2 -#include +#include #elif PATCH_DIM == 3 @@ -42,121 +42,121 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif -int FCLAW2D_MAP_IS_USED(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_USED(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_USED; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_USED; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_DISK(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_DISK(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_DISK; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_DISK; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_CART(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_CART(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_CART; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_CART; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_AFFINE(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_AFFINE(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_AFFINE; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_AFFINE; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_PILLOWDISK(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_PILLOWDISK(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_PILLOWDISK; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_PILLOWDISK; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_SQUAREDDISK(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_SQUAREDDISK(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_SQUAREDDISK; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_SQUAREDDISK; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_PILLOWSPHERE(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_PILLOWSPHERE(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_PILLOWSPHERE; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_CUBEDSPHERE(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_CUBEDSPHERE(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_CUBEDSPHERE; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_FLAT(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_FLAT(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_FLAT; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_FLAT; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_SPHERE(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_SPHERE(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_SPHERE; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_SPHERE; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_HEMISPHERE(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_HEMISPHERE(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_HEMISPHERE; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_HEMISPHERE; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_TORUS(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_TORUS(fclaw_map_context_t** pcont) { int iresult; - fclaw2d_map_context_t *cont = *pcont; - int id = FCLAW2D_MAP_QUERY_IS_TORUS; + fclaw_map_context_t *cont = *pcont; + int id = FCLAW_MAP_QUERY_IS_TORUS; iresult = cont->query(cont,id); return iresult != 0; } -int FCLAW2D_MAP_IS_BRICK(fclaw2d_map_context_t** pcont) +int FCLAW_MAP_IS_BRICK(fclaw_map_context_t** pcont) { - fclaw2d_map_context_t *cont = *pcont; - fclaw2d_map_context_t *brick = cont->brick; + fclaw_map_context_t *cont = *pcont; + fclaw_map_context_t *brick = cont->brick; int iresult; - int id = FCLAW2D_MAP_QUERY_IS_BRICK; + int id = FCLAW_MAP_QUERY_IS_BRICK; if (brick != NULL) { iresult = brick->query(cont,id); diff --git a/src/fclaw_map_query.h b/src/fclaw_map_query.h new file mode 100644 index 000000000..aa03ee198 --- /dev/null +++ b/src/fclaw_map_query.h @@ -0,0 +1,89 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#ifndef FCLAW_MAP_QUERY_H +#define FCLAW_MAP_QUERY_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} /* need this because indent is dumb */ +#endif +#endif + +#define FCLAW_MAP_IS_USED FCLAW_F77_FUNC_(fclaw_map_is_used,FCLAW_MAP_IS_USED) +int FCLAW_MAP_IS_USED(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_CART FCLAW_F77_FUNC_(fclaw_map_is_cart,FCLAW_MAP_IS_CART) +int FCLAW_MAP_IS_CART(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_AFFINE FCLAW_F77_FUNC_(fclaw_map_is_affine,FCLAW_MAP_IS_AFFINE) +int FCLAW_MAP_IS_AFFINE(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_DISK FCLAW_F77_FUNC_(fclaw_map_is_disk,FCLAW_MAP_IS_DISK) +int FCLAW_MAP_IS_DISK(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_PILLOWDISK FCLAW_F77_FUNC_(fclaw_map_is_pillowdisk,FCLAW_MAP_IS_PILLOWDISK) +int FCLAW_MAP_IS_PILLOWDISK(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_SQUAREDDISK FCLAW_F77_FUNC_(fclaw_map_is_squareddisk,FCLAW_MAP_IS_SQUAREDDISK) +int FCLAW_MAP_IS_SQUAREDDISK(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_PILLOWSPHERE FCLAW_F77_FUNC_(fclaw_map_is_pillowsphere,FCLAW_MAP_IS_PILLOWSPHERE) +int FCLAW_MAP_IS_PILLOWSPHERE(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_CUBEDSPHERE FCLAW_F77_FUNC_(fclaw_map_is_cubedsphere,FCLAW_MAP_IS_CUBEDSPHERE) +int FCLAW_MAP_IS_CUBEDSPHERE(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_FLAT FCLAW_F77_FUNC_(fclaw_map_is_flat,FCLAW_MAP_IS_FLAT) +int FCLAW_MAP_IS_FLAT(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_SPHERE FCLAW_F77_FUNC_(fclaw_map_is_sphere,FCLAW_MAP_IS_SPHERE) +int FCLAW_MAP_IS_SPHERE(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_HEMISPHERE FCLAW_F77_FUNC_(fclaw_map_is_hemisphere,FCLAW_MAP_IS_HEMISPHERE) +int FCLAW_MAP_IS_HEMISPHERE(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_TORUS FCLAW_F77_FUNC_(fclaw_map_is_torus,FCLAW_MAP_IS_TORUS) +int FCLAW_MAP_IS_TORUS(fclaw_map_context_t** cont); + +#define FCLAW_MAP_IS_BRICK FCLAW_F77_FUNC_(fclaw_map_is_brick,FCLAW_MAP_IS_BRICK) +int FCLAW_MAP_IS_BRICK(fclaw_map_context_t** cont); + + +#ifdef __cplusplus +#if 0 +{ /* need this because indent is dumb */ +#endif +} +#endif + + +#endif diff --git a/src/fclaw2d_map_query_defs.h b/src/fclaw_map_query_defs.h similarity index 73% rename from src/fclaw2d_map_query_defs.h rename to src/fclaw_map_query_defs.h index ca2e1c784..e187a109d 100644 --- a/src/fclaw2d_map_query_defs.h +++ b/src/fclaw_map_query_defs.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_MAP_QUERY_DEFS_H -#define FCLAW2D_MAP_QUERY_DEFS_H +#ifndef FCLAW_MAP_QUERY_DEFS_H +#define FCLAW_MAP_QUERY_DEFS_H #include @@ -40,27 +40,27 @@ extern "C" Note : These categories are not completely well defined, and are used primarily for the user's benefit and so subject to the user's interpretation */ -#define FCLAW2D_MAP_QUERY_IS_USED 0 /* is the map used at all? */ -#define FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT 1 /* x_i -> a_i x_i + b_i */ -#define FCLAW2D_MAP_QUERY_IS_AFFINE 2 /* x -> A x + b */ -#define FCLAW2D_MAP_QUERY_IS_NONLINEAR 3 /* x -> F(x) */ -#define FCLAW2D_MAP_QUERY_IS_CART 4 /* x -> x (Cartesian) */ -#define FCLAW2D_MAP_QUERY_IS_GRAPH 5 /* (x,y) -> (x,y,f(x,y)) */ -#define FCLAW2D_MAP_QUERY_IS_PLANAR 6 /* (x,y) -> (?,?,0) */ -#define FCLAW2D_MAP_QUERY_IS_ALIGNED 7 /* (x,y) -> (f(x),g(y),0) */ -#define FCLAW2D_MAP_QUERY_IS_FLAT 8 /* Zero curvature */ -#define FCLAW2D_MAP_QUERY_IS_SPHERE 9 /* A topological sphere */ -#define FCLAW2D_MAP_QUERY_IS_DISK 10 /* A topological disk */ -#define FCLAW2D_MAP_QUERY_IS_PILLOWDISK 11 /* Pillow disk */ -#define FCLAW2D_MAP_QUERY_IS_SQUAREDDISK 12 /* Squared disk */ -#define FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE 13 /* Pillow sphere */ -#define FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE 14 /* Cubed sphere */ -#define FCLAW2D_MAP_QUERY_IS_FIVEPATCH 15 /* Five patch unit square */ -#define FCLAW2D_MAP_QUERY_IS_BILINEAR 16 /* Five patch unit square */ -#define FCLAW2D_MAP_QUERY_IS_HEMISPHERE 17 /* Hemisphere grid */ -#define FCLAW2D_MAP_QUERY_IS_TORUS 18 /* Hemisphere grid */ -#define FCLAW2D_MAP_QUERY_IS_BRICK 19 /* Is a Cartesian brick */ -#define FCLAW2D_MAP_QUERY_LAST 20 /* Number of "official" queries. */ +#define FCLAW_MAP_QUERY_IS_USED 0 /* is the map used at all? */ +#define FCLAW_MAP_QUERY_IS_SCALEDSHIFT 1 /* x_i -> a_i x_i + b_i */ +#define FCLAW_MAP_QUERY_IS_AFFINE 2 /* x -> A x + b */ +#define FCLAW_MAP_QUERY_IS_NONLINEAR 3 /* x -> F(x) */ +#define FCLAW_MAP_QUERY_IS_CART 4 /* x -> x (Cartesian) */ +#define FCLAW_MAP_QUERY_IS_GRAPH 5 /* (x,y) -> (x,y,f(x,y)) */ +#define FCLAW_MAP_QUERY_IS_PLANAR 6 /* (x,y) -> (?,?,0) */ +#define FCLAW_MAP_QUERY_IS_ALIGNED 7 /* (x,y) -> (f(x),g(y),0) */ +#define FCLAW_MAP_QUERY_IS_FLAT 8 /* Zero curvature */ +#define FCLAW_MAP_QUERY_IS_SPHERE 9 /* A topological sphere */ +#define FCLAW_MAP_QUERY_IS_DISK 10 /* A topological disk */ +#define FCLAW_MAP_QUERY_IS_PILLOWDISK 11 /* Pillow disk */ +#define FCLAW_MAP_QUERY_IS_SQUAREDDISK 12 /* Squared disk */ +#define FCLAW_MAP_QUERY_IS_PILLOWSPHERE 13 /* Pillow sphere */ +#define FCLAW_MAP_QUERY_IS_CUBEDSPHERE 14 /* Cubed sphere */ +#define FCLAW_MAP_QUERY_IS_FIVEPATCH 15 /* Five patch unit square */ +#define FCLAW_MAP_QUERY_IS_BILINEAR 16 /* Five patch unit square */ +#define FCLAW_MAP_QUERY_IS_HEMISPHERE 17 /* Hemisphere grid */ +#define FCLAW_MAP_QUERY_IS_TORUS 18 /* Hemisphere grid */ +#define FCLAW_MAP_QUERY_IS_BRICK 19 /* Is a Cartesian brick */ +#define FCLAW_MAP_QUERY_LAST 20 /* Number of "official" queries. */ #if 0 /* Generic query function (kept up to date with list above) */ diff --git a/src/fclaw_mpi.c b/src/fclaw_mpi.c index e773a4068..a4b0e077a 100644 --- a/src/fclaw_mpi.c +++ b/src/fclaw_mpi.c @@ -24,7 +24,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include +#include /* Functions with C prototypes to use forestclaw from C code */ @@ -72,15 +72,15 @@ fclaw_mpi_barrier (sc_MPI_Comm mpicomm) } void -fclaw_mpi_serialization_enter (struct fclaw2d_global *glob) +fclaw_mpi_serialization_enter (struct fclaw_global *glob) { - fclaw2d_domain_serialization_enter(glob->domain); + fclaw_domain_serialization_enter(glob->domain); } void -fclaw_mpi_serialization_leave (struct fclaw2d_global *glob) +fclaw_mpi_serialization_leave (struct fclaw_global *glob) { - fclaw2d_domain_serialization_leave(glob->domain); + fclaw_domain_serialization_leave(glob->domain); } diff --git a/src/fclaw_mpi.h b/src/fclaw_mpi.h index b0129cb5e..904b5f716 100644 --- a/src/fclaw_mpi.h +++ b/src/fclaw_mpi.h @@ -36,7 +36,7 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; /* Functions with C prototypes to use forestclaw from C code */ @@ -47,10 +47,10 @@ void fclaw_mpi_barrier (sc_MPI_Comm mpicomm); void -fclaw_mpi_serialization_enter (struct fclaw2d_global *glob); +fclaw_mpi_serialization_enter (struct fclaw_global *glob); void -fclaw_mpi_serialization_leave (struct fclaw2d_global *glob); +fclaw_mpi_serialization_leave (struct fclaw_global *glob); diff --git a/src/fclaw_options.c b/src/fclaw_options.c index 70723ab52..6dd3803d0 100644 --- a/src/fclaw_options.c +++ b/src/fclaw_options.c @@ -28,6 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include /* Get whatever definitions exist already */ #ifdef FCLAW_HAVE_FENV_H @@ -217,6 +218,10 @@ fclaw_register (fclaw_options_t* fclaw_opt, sc_options_t * opt) &fclaw_opt->refine_threshold, 0.5, "Refinement threshold [0.5]"); + sc_options_add_bool(opt, 0, "partition-for-coarsening", + &fclaw_opt->partition_for_coarsening, 1, + "Partition for coarsening [T]"); + sc_options_add_double (opt, 0, "coarsen_threshold", &fclaw_opt->coarsen_threshold, 0.1, "Coarsening threshold [0.1]"); @@ -306,12 +311,18 @@ fclaw_register (fclaw_options_t* fclaw_opt, sc_options_t * opt) sc_options_add_int (opt, 0, "mj", &fclaw_opt->mj, 1, "Number of blocks in y direction [1]"); + sc_options_add_int (opt, 0, "mk", &fclaw_opt->mk, 1, + "Number of blocks in z direction [1]"); + sc_options_add_bool (opt, 0, "periodic_x", &fclaw_opt->periodic_x, 0, "Periodic in x direction [F]"); sc_options_add_bool (opt, 0, "periodic_y", &fclaw_opt->periodic_y, 0, "Periodic in y direction [F]"); + sc_options_add_bool (opt, 0, "periodic_z", &fclaw_opt->periodic_z, 0, + "Periodic in z direction [F]"); + fclaw_options_add_double_array (opt,0, "scale", &fclaw_opt->scale_string, "1 1 1", &fclaw_opt->scale, 3, @@ -344,6 +355,9 @@ fclaw_register (fclaw_options_t* fclaw_opt, sc_options_t * opt) &fclaw_opt->regression_check, "","filename of expected regresssion values [NULL]"); + sc_options_add_double(opt, 0, "max-refinement-ratio", + &fclaw_opt->max_refinement_ratio, 1.0, + "Ratio of patches to refine before paritioning and continuing refinement. [1.0]"); fclaw_opt->is_registered = 1; fclaw_opt->is_unpacked = 0; @@ -745,3 +759,16 @@ void fclaw_options_destroy_array(void* array) FCLAW_FREE (array); } +/* --------------------------------------------------------- + Public interface to ForestClaw options + --------------------------------------------------------- */ + +void fclaw_options_store (fclaw_global_t *glob, fclaw_options_t* gparms) +{ + fclaw_global_options_store(glob, "fclaw2d", gparms); +} + +fclaw_options_t* fclaw_get_options(fclaw_global_t* glob) +{ + return (fclaw_options_t*) fclaw_global_get_options(glob, "fclaw2d"); +} diff --git a/src/fclaw_options.h b/src/fclaw_options.h index 6583162bd..1dcf7b26a 100644 --- a/src/fclaw_options.h +++ b/src/fclaw_options.h @@ -150,6 +150,7 @@ struct fclaw_options int smooth_refine; int smooth_level; double refine_threshold; + int partition_for_coarsening; /**< True if domain will be partitioned for coarsening */ /* Conservation */ int time_sync; @@ -164,8 +165,10 @@ struct fclaw_options int manifold; int mi; int mj; + int mk; int periodic_x; int periodic_y; + int periodic_z; /* Advanced options */ int flux_correction; @@ -201,9 +204,8 @@ struct fclaw_options double bx; /**< Only for the single block, unmapped case */ double ay; /**< Only for the single block, unmapped case */ double by; /**< Only for the single block, unmapped case */ - // TODO - double az; - double bz; + double az; /**< Only for the single block, unmapped case */ + double bz; /**< Only for the single block, unmapped case */ /* Diagnostics */ int run_user_diagnostics; @@ -248,10 +250,18 @@ struct fclaw_options const char * logging_prefix; /**< prefix presented in logging ie. [prefix] */ const char * regression_check; /**< filename of regression check values */ + + double max_refinement_ratio; /**< Maximum refinment ratio before partitioning and continuing refinement. */ }; +struct fclaw_global; + +void fclaw_options_store (struct fclaw_global *glob, struct fclaw_options* fclaw_opt); + +fclaw_options_t* fclaw_get_options(struct fclaw_global *glob); + #ifdef __cplusplus } #endif -#endif /* !FCLAW2D_OPTIONS_H */ +#endif /* !FCLAW_OPTIONS_H */ diff --git a/src/fclaw2d_options.h.TEST.cpp b/src/fclaw_options.h.TEST.cpp similarity index 88% rename from src/fclaw2d_options.h.TEST.cpp rename to src/fclaw_options.h.TEST.cpp index 5b680bc8e..46502d97c 100644 --- a/src/fclaw2d_options.h.TEST.cpp +++ b/src/fclaw_options.h.TEST.cpp @@ -26,60 +26,60 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include -#include +#include +#include #include #include -TEST_CASE("fclaw2d_options can store options in two seperate globs") +TEST_CASE("fclaw_options can store options in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fclaw_options_t* opts1 = FCLAW_ALLOC_ZERO(fclaw_options_t,1); fclaw_options_t* opts2 = FCLAW_ALLOC_ZERO(fclaw_options_t,1); - fclaw2d_options_store(glob1, opts1); + fclaw_options_store(glob1, opts1); /* glob1 has one package glob2 has two */ - fclaw2d_options_store(glob2, opts2); + fclaw_options_store(glob2, opts2); - CHECK_EQ(fclaw2d_get_options(glob1), opts1); - CHECK_EQ(fclaw2d_get_options(glob2), opts2); + CHECK_EQ(fclaw_get_options(glob1), opts1); + CHECK_EQ(fclaw_get_options(glob2), opts2); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #ifdef FCLAW_ENABLE_DEBUG -TEST_CASE("fclaw2d_get_options fails if not intialized") +TEST_CASE("fclaw_get_options fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); - CHECK_SC_ABORTED(fclaw2d_get_options(glob1)); + CHECK_SC_ABORTED(fclaw_get_options(glob1)); - CHECK_SC_ABORTED(fclaw2d_get_options(glob2)); + CHECK_SC_ABORTED(fclaw_get_options(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } -TEST_CASE("fclaw2d_options_store fails if called twice on a glob") +TEST_CASE("fclaw_options_store fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); - fclaw2d_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); - CHECK_SC_ABORTED(fclaw2d_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_options_t,1))); + fclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); + CHECK_SC_ABORTED(fclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_options_t,1))); - fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); - CHECK_SC_ABORTED(fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1))); + fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); + CHECK_SC_ABORTED(fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1))); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } -TEST_CASE("fclaw2d_options packing/unpacking") +TEST_CASE("fclaw_options packing/unpacking") { fclaw_options_t* opts = FCLAW_ALLOC_ZERO(fclaw_options_t,1); opts->dim = 3; diff --git a/src/fclaw2d_output.c b/src/fclaw_output.c similarity index 83% rename from src/fclaw2d_output.c rename to src/fclaw_output.c index d8388f275..3a437cb5a 100644 --- a/src/fclaw2d_output.c +++ b/src/fclaw_output.c @@ -23,19 +23,19 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include +#include +#include +#include +#include /* ----------------------------------------------------------------------- Public interface -------------------------------------------------------------------- */ void -fclaw2d_output_frame (fclaw2d_global_t * glob, int iframe) +fclaw_output_frame (fclaw_global_t * glob, int iframe) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double time; time = glob->curr_time; @@ -43,12 +43,12 @@ fclaw2d_output_frame (fclaw2d_global_t * glob, int iframe) if (fclaw_opt->output != 0) { - fclaw2d_vtable_t *vt = fclaw2d_vt(glob); + fclaw_vtable_t *vt = fclaw_vt(glob); FCLAW_ASSERT(vt->output_frame != NULL); /* Record output time */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_OUTPUT]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_OUTPUT]); /* User or solver set output file */ fclaw_global_essentialf("Output Frame %4d at time %16.8e\n\n", @@ -56,7 +56,7 @@ fclaw2d_output_frame (fclaw2d_global_t * glob, int iframe) vt->output_frame(glob,iframe); /* Record output time */ - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_OUTPUT]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_OUTPUT]); } else { diff --git a/src/fclaw2d_output.h b/src/fclaw_output.h similarity index 85% rename from src/fclaw2d_output.h rename to src/fclaw_output.h index a2e94a8b4..85eafd8a3 100644 --- a/src/fclaw2d_output.h +++ b/src/fclaw_output.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_OUTPUT_H -#define FCLAW2D_OUTPUT_H +#ifndef FCLAW_OUTPUT_H +#define FCLAW_OUTPUT_H #ifdef __cplusplus extern "C" @@ -34,11 +34,11 @@ extern "C" #endif #endif -struct fclaw2d_global; /* This is a hack !! */ +struct fclaw_global; /* This is a hack !! */ -void fclaw2d_output_frame(struct fclaw2d_global * glob, int iframe); +void fclaw_output_frame(struct fclaw_global * glob, int iframe); -void fclaw2d_output_frame_tikz(struct fclaw2d_global* glob, int iframe); +void fclaw2d_output_frame_tikz(struct fclaw_global* glob, int iframe); #ifdef __cplusplus #if 0 diff --git a/src/fclaw_package.c b/src/fclaw_package.c index ec34275f5..227117842 100644 --- a/src/fclaw_package.c +++ b/src/fclaw_package.c @@ -24,7 +24,7 @@ */ #include -#include +#include #define FCLAW_MAX_PACKAGES 20 @@ -113,7 +113,7 @@ fclaw_package_container_add (fclaw_package_container_t * pkg_container, return id; } -int fclaw_package_container_add_pkg(fclaw2d_global_t* glob, +int fclaw_package_container_add_pkg(fclaw_global_t* glob, void* opt) { fclaw_package_container_t *pkg_container = @@ -122,7 +122,7 @@ int fclaw_package_container_add_pkg(fclaw2d_global_t* glob, } -void* fclaw_package_get_options(fclaw2d_global_t *glob, +void* fclaw_package_get_options(fclaw_global_t *glob, int id) { fclaw_package_t *pkg; diff --git a/src/fclaw_package.h b/src/fclaw_package.h index 7e4a4db68..b99dbfb9f 100644 --- a/src/fclaw_package.h +++ b/src/fclaw_package.h @@ -43,7 +43,7 @@ extern "C" #pragma message("WARNING: You need to implement DEPRECATED for this compiler") #define DEPRECATED #endif -struct fclaw2d_global; +struct fclaw_global; /* Opaque pointers */ typedef struct fclaw_package_container fclaw_package_container_t; @@ -60,9 +60,9 @@ int fclaw_package_container_add (fclaw_package_container_t * pkg_container, void fclaw_package_container_new_app (fclaw_app_t *app); void fclaw_package_container_destroy_app (fclaw_app_t *app); -DEPRECATED int fclaw_package_container_add_pkg(struct fclaw2d_global* glob, +DEPRECATED int fclaw_package_container_add_pkg(struct fclaw_global* glob, void* opt); -DEPRECATED void* fclaw_package_get_options(struct fclaw2d_global *glob, int id); +DEPRECATED void* fclaw_package_get_options(struct fclaw_global *glob, int id); #ifdef __cplusplus diff --git a/src/fclaw_packing.h b/src/fclaw_packing.h index 639343ea9..31f56372f 100644 --- a/src/fclaw_packing.h +++ b/src/fclaw_packing.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW_SERIALIZATION_H -#define FCLAW_SERIALIZATION_H +#ifndef FCLAW_PACKING_H +#define FCLAW_PACKING_H #include diff --git a/src/fclaw2d_partition.c b/src/fclaw_partition.c similarity index 61% rename from src/fclaw2d_partition.c rename to src/fclaw_partition.c index 9054885c5..547a7b4b6 100644 --- a/src/fclaw2d_partition.c +++ b/src/fclaw_partition.c @@ -23,83 +23,83 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include /* p4est domain, patch handling routines */ +#include /* p4est domain, patch handling routines */ -#include -#include -#include +#include +#include +#include -#include +#include static -void cb_partition_pack(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void cb_partition_pack(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void *user) { /* Pack everything in old domain */ - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t *) user; - fclaw2d_block_t *this_block = &domain->blocks[blockno]; + fclaw_block_t *this_block = &domain->blocks[blockno]; int patch_num = this_block->num_patches_before + patchno; void* pack_data_here = (void*) ((void**)g->user)[patch_num]; - fclaw2d_patch_partition_pack(g->glob,patch, + fclaw_patch_partition_pack(g->glob,patch, blockno,patchno, pack_data_here); } static -void cb_partition_transfer(fclaw2d_domain_t * old_domain, - fclaw2d_patch_t * old_patch, - fclaw2d_domain_t * new_domain, - fclaw2d_patch_t * new_patch, +void cb_partition_transfer(fclaw_domain_t * old_domain, + fclaw_patch_t * old_patch, + fclaw_domain_t * new_domain, + fclaw_patch_t * new_patch, int blockno, int old_patchno, int new_patchno, void *user) { /* Transfer data to new domain */ - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t *) user; - fclaw2d_domain_data_t *ddata_old = fclaw2d_domain_get_data (old_domain); - fclaw2d_domain_data_t *ddata_new = fclaw2d_domain_get_data (new_domain); + fclaw_global_iterate_t *g = (fclaw_global_iterate_t *) user; if (old_patch != NULL) { FCLAW_ASSERT(old_patch->xlower == new_patch->xlower); FCLAW_ASSERT(old_patch->ylower == new_patch->ylower); + FCLAW_ASSERT(old_patch->zlower == new_patch->zlower); FCLAW_ASSERT(old_patch->xupper == new_patch->xupper); FCLAW_ASSERT(old_patch->yupper == new_patch->yupper); + FCLAW_ASSERT(old_patch->zupper == new_patch->zupper); new_patch->user = old_patch->user; old_patch->user = NULL; - ++ddata_old->count_delete_patch; - ++ddata_new->count_set_patch; + ++old_domain->count_delete_patch; + ++new_domain->count_set_patch; } else { /* We need to rebuild the patch from scratch. 'user' contains the packed data received from remote processor. */ - fclaw2d_domain_t *domain = new_domain; /* get patch id in new domain */ + fclaw_domain_t *domain = new_domain; /* get patch id in new domain */ - fclaw2d_block_t *this_block = &domain->blocks[blockno]; + fclaw_block_t *this_block = &domain->blocks[blockno]; int patch_num = this_block->num_patches_before + new_patchno; void* unpack_data_from_here = (void*) ((void**)g->user)[patch_num]; /* pass in new_domain, since glob only contains old domain at this point and the both domains are needed to increment/decrement patches */ - fclaw2d_patch_partition_unpack(g->glob,new_domain,new_patch, + fclaw_patch_partition_unpack(g->glob,new_domain,new_patch, blockno,new_patchno,unpack_data_from_here); /* Reason for the following two lines: the glob contains the old domain which is incremented in ddata_old but we really want to increment the new domain. */ - --ddata_old->count_set_patch; - ++ddata_new->count_set_patch; + --old_domain->count_set_patch; + ++new_domain->count_set_patch; } @@ -110,84 +110,84 @@ void cb_partition_transfer(fclaw2d_domain_t * old_domain, Public interface -------------------------------------------------------------------------- */ /* Question : Do all patches on this processor get packed? */ -void fclaw2d_partition_domain(fclaw2d_global_t* glob, - fclaw2d_timer_names_t running) +void fclaw_partition_domain(fclaw_global_t* glob, + fclaw_timer_names_t running) { - fclaw2d_domain_t** domain = &glob->domain; - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_PARTITION]); + fclaw_domain_t** domain = &glob->domain; + fclaw_timer_start (&glob->timers[FCLAW_TIMER_PARTITION]); /* will need to access the subcyle switch */ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); /* allocate memory for parallel transfor of patches use data size (in bytes per patch) below. */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_PARTITION_BUILD]); - size_t psize = fclaw2d_patch_partition_packsize(glob); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_PARTITION_BUILD]); + size_t psize = fclaw_patch_partition_packsize(glob); size_t data_size = psize; /* Includes sizeof(data_type) */ void ** patch_data = NULL; - fclaw2d_domain_allocate_before_partition (*domain, data_size, + fclaw_domain_allocate_before_partition (*domain, data_size, &patch_data); /* For all (patch i) { pack its numerical data into patch_data[i] } Does all the data in every patch need to be copied? */ - fclaw2d_global_iterate_patches(glob, + fclaw_global_iterate_patches(glob, cb_partition_pack, (void *) patch_data); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_PARTITION_BUILD]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_PARTITION_BUILD]); /* this call creates a new domain that is valid after partitioning and transfers the data packed above to the new owner processors */ int exponent = fclaw_opt->subcycle && fclaw_opt->weighted_partition ? 1 : 0; - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_PARTITION]); - if (running != FCLAW2D_TIMER_NONE) + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_PARTITION]); + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_stop (&glob->timers[running]); + fclaw_timer_stop (&glob->timers[running]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_PARTITION_COMM]); - fclaw2d_domain_t *domain_partitioned = - fclaw2d_domain_partition (*domain, exponent); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_PARTITION_COMM]); + fclaw_domain_t *domain_partitioned = + fclaw_domain_partition (*domain, exponent); int have_new_partition = domain_partitioned != NULL; if (have_new_partition) { /* Do this part so we can get a pointer to the new data */ - fclaw2d_domain_setup(glob, domain_partitioned); + fclaw_domain_setup(glob, domain_partitioned); } /* Stop the communication timer */ - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_PARTITION_COMM]); - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_PARTITION]); - if (running != FCLAW2D_TIMER_NONE) + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_PARTITION_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_PARTITION]); + if (running != FCLAW_TIMER_NONE) { - fclaw2d_timer_start (&glob->timers[running]); + fclaw_timer_start (&glob->timers[running]); } if (have_new_partition) { - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_PARTITION_BUILD]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_PARTITION_BUILD]); /* update patch array to point to the numerical data that was received */ - fclaw2d_domain_retrieve_after_partition (domain_partitioned,&patch_data); + fclaw_domain_retrieve_after_partition (domain_partitioned,&patch_data); /* New version? */ - fclaw2d_global_iterate_partitioned(glob,domain_partitioned, + fclaw_global_iterate_partitioned(glob,domain_partitioned, cb_partition_transfer, (void*) patch_data); /* then the old domain is no longer necessary */ - fclaw2d_domain_reset(glob); + fclaw_domain_reset(glob); *domain = domain_partitioned; domain_partitioned = NULL; /* internal clean up */ - fclaw2d_domain_complete(*domain); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_PARTITION_BUILD]); + fclaw_domain_complete(*domain); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_PARTITION_BUILD]); } /* free the data that was used in the parallel transfer of patches */ - fclaw2d_domain_free_after_partition (*domain, &patch_data); + fclaw_domain_free_after_partition (*domain, &patch_data); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_PARTITION]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_PARTITION]); } diff --git a/src/fclaw2d_partition.h b/src/fclaw_partition.h similarity index 87% rename from src/fclaw2d_partition.h rename to src/fclaw_partition.h index 334d4d0a8..4a7c8bb6c 100644 --- a/src/fclaw2d_partition.h +++ b/src/fclaw_partition.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_PARTITION_H -#define FCLAW2D_PARTITION_H +#ifndef FCLAW_PARTITION_H +#define FCLAW_PARTITION_H #include @@ -36,10 +36,10 @@ extern "C" #endif #endif -struct fclaw2d_domain; +struct fclaw_domain; -void fclaw2d_partition_domain(struct fclaw2d_global* glob, - fclaw2d_timer_names_t running); +void fclaw_partition_domain(struct fclaw_global* glob, + fclaw_timer_names_t running); #ifdef __cplusplus #if 0 diff --git a/src/fclaw2d_patch.c b/src/fclaw_patch.c similarity index 51% rename from src/fclaw2d_patch.c rename to src/fclaw_patch.c index 15605e2bd..72bf73a87 100644 --- a/src/fclaw2d_patch.c +++ b/src/fclaw_patch.c @@ -25,33 +25,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#ifndef P4_TO_P8 -#include -#include -#include +#include +#include +#include +#include + #include -#else -#include -#include -#include #include -#endif +#include +#include -struct fclaw2d_patch_transform_data; +struct fclaw_patch_transform_data; /* ------------------------------- static access functions ---------------------------- */ static -fclaw2d_patch_data_t* get_patch_data(fclaw2d_patch_t* patch) +fclaw_patch_data_t* get_patch_data(fclaw_patch_t* patch) { - fclaw2d_patch_data_t *pdata = (fclaw2d_patch_data_t*) patch->user; + fclaw_patch_data_t *pdata = (fclaw_patch_data_t*) patch->user; FCLAW_ASSERT(pdata != NULL); return pdata; } static -void* get_user_patch(fclaw2d_patch_t* patch) +void* get_user_patch(fclaw_patch_t* patch) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); return pdata->user_patch; } @@ -60,14 +58,14 @@ void* get_user_patch(fclaw2d_patch_t* patch) /* ----------------------------- Creating/deleting patches ---------------------------- */ static -void patch_data_new(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch, +void patch_data_new(fclaw_global_t* glob, + fclaw_patch_t* this_patch, int this_block_idx, int this_patch_idx) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); /* Initialize user data */ - fclaw2d_patch_data_t *pdata = FCLAW_ALLOC(fclaw2d_patch_data_t, 1); + fclaw_patch_data_t *pdata = FCLAW_ALLOC(fclaw_patch_data_t, 1); this_patch->user = (void *) pdata; #if 0 @@ -89,17 +87,41 @@ void patch_data_new(fclaw2d_global_t* glob, FCLAW_ASSERT(patch_vt->patch_new != NULL); pdata->user_patch = patch_vt->patch_new(); - fclaw2d_domain_data_t *ddata = fclaw2d_domain_get_data(glob->domain); - ++ddata->count_set_patch; //this is now in cb_fclaw2d_regrid_repopulate + ++glob->domain->count_set_patch; //this is now in cb_fclaw2d_regrid_repopulate pdata->neighbors_set = 0; + pdata->considered_for_refinement = 0; +} + +static +size_t patch_data_packsize() +{ + return sizeof(int); } -void fclaw2d_patch_reset_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* old_patch, - fclaw2d_patch_t* new_patch, +static +void patch_data_pack(fclaw_global_t* glob, + fclaw_patch_t* this_patch, + void* pack_data_here) +{ + fclaw_patch_data_t *pdata = get_patch_data(this_patch); + fclaw_pack_int(pdata->considered_for_refinement, (char*) pack_data_here); +} + +static +void patch_data_unpack(fclaw_global_t* glob, + fclaw_patch_t* this_patch, + void* unpack_data_from_here) +{ + fclaw_patch_data_t *pdata = get_patch_data(this_patch); + fclaw_unpack_int((char*) unpack_data_from_here, &pdata->considered_for_refinement); +} + +void fclaw_patch_reset_data(fclaw_global_t* glob, + fclaw_patch_t* old_patch, + fclaw_patch_t* new_patch, int blockno,int old_patchno, int new_patchno) { - fclaw2d_patch_data_t *pdata = (fclaw2d_patch_data_t*) new_patch->user; + fclaw_patch_data_t *pdata = (fclaw_patch_data_t*) new_patch->user; pdata->block_idx = blockno; #if 0 /* This check may be bogus, since glob->domain is the old domain */ @@ -114,12 +136,12 @@ void fclaw2d_patch_reset_data(fclaw2d_global_t* glob, /* Everything else will hopefully sort itself out ... */ } -void fclaw2d_patch_data_delete(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch) +void fclaw_patch_data_delete(fclaw_global_t *glob, + fclaw_patch_t *this_patch) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->patch_delete != NULL); - fclaw2d_patch_data_t *pdata = (fclaw2d_patch_data_t*) this_patch->user; + fclaw_patch_data_t *pdata = (fclaw_patch_data_t*) this_patch->user; if (pdata != NULL) { @@ -128,22 +150,21 @@ void fclaw2d_patch_data_delete(fclaw2d_global_t *glob, patch_vt->destroy_user_data(glob,this_patch); } - fclaw2d_domain_data_t *ddata = fclaw2d_domain_get_data(glob->domain); patch_vt->patch_delete(pdata->user_patch); - ++ddata->count_delete_patch; + ++glob->domain->count_delete_patch; FCLAW_FREE(pdata); this_patch->user = NULL; } } -void fclaw2d_patch_build(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw_patch_build(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, int patchno, void *user) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); /* This is where we store 'user' (from the point of view of a p4est user) data */ patch_data_new(glob,this_patch,blockno, patchno); @@ -176,20 +197,20 @@ void fclaw2d_patch_build(fclaw2d_global_t *glob, -void fclaw2d_patch_build_from_fine(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, - fclaw2d_patch_t *coarse_patch, +void fclaw_patch_build_from_fine(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + fclaw_patch_t *coarse_patch, int blockno, int coarse_patchno, int fine0_patchno, - fclaw2d_build_mode_t build_mode) + fclaw_build_mode_t build_mode) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->build_from_fine != NULL); patch_data_new(glob,coarse_patch,blockno, coarse_patchno); - fclaw2d_patch_data_t *pdata = get_patch_data(coarse_patch); + fclaw_patch_data_t *pdata = get_patch_data(coarse_patch); pdata->block_idx = blockno; patch_vt->build_from_fine(glob, @@ -205,7 +226,7 @@ void fclaw2d_patch_build_from_fine(fclaw2d_global_t *glob, patch_vt->create_user_data(glob,coarse_patch); } - if (patch_vt->setup != NULL && build_mode == FCLAW2D_BUILD_FOR_UPDATE) + if (patch_vt->setup != NULL && build_mode == FCLAW_BUILD_FOR_UPDATE) { patch_vt->setup(glob,coarse_patch,blockno,coarse_patchno); } @@ -249,12 +270,12 @@ void fclaw2d_patch_set_user_data(fclaw2d_global_t* glob, /* --------------------------- Solver specific functions ------------------------------ */ -void fclaw2d_patch_initialize(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw_patch_initialize(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); if (patch_vt->initialize != NULL) { patch_vt->initialize(glob,this_patch,this_block_idx,this_patch_idx); @@ -263,8 +284,8 @@ void fclaw2d_patch_initialize(fclaw2d_global_t *glob, -void fclaw2d_patch_physical_bc(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw_patch_physical_bc(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -272,21 +293,21 @@ void fclaw2d_patch_physical_bc(fclaw2d_global_t *glob, int *intersects_bc, int time_interp) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->physical_bc != NULL); patch_vt->physical_bc(glob,this_patch,this_block_idx,this_patch_idx, t,dt,intersects_bc,time_interp); } -double fclaw2d_patch_single_step_update(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double fclaw_patch_single_step_update(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, double dt, void* user) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->single_step_update != NULL); double maxcfl = patch_vt->single_step_update(glob,this_patch,this_block_idx, @@ -295,12 +316,12 @@ double fclaw2d_patch_single_step_update(fclaw2d_global_t *glob, } -void fclaw2d_patch_set_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fclaw_patch_set_rhs(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->rhs != NULL); @@ -310,29 +331,29 @@ void fclaw2d_patch_set_rhs(fclaw2d_global_t *glob, /* ------------------------------------ time stepping --------------------------------- */ -void fclaw2d_patch_restore_step(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch) +void fclaw_patch_restore_step(fclaw_global_t* glob, + fclaw_patch_t* this_patch) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->restore_step != NULL); patch_vt->restore_step(glob, this_patch); } /* This is called from libraries routines (clawpack4.6, clawpack5, etc) */ -void fclaw2d_patch_save_step(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch) +void fclaw_patch_save_step(fclaw_global_t* glob, + fclaw_patch_t* this_patch) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->save_step != NULL); patch_vt->save_step(glob, this_patch); } -void fclaw2d_patch_setup_timeinterp(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw_patch_setup_timeinterp(fclaw_global_t *glob, + fclaw_patch_t *this_patch, double alpha) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->setup_timeinterp != NULL); patch_vt->setup_timeinterp(glob,this_patch,alpha); @@ -340,32 +361,32 @@ void fclaw2d_patch_setup_timeinterp(fclaw2d_global_t *glob, /* ---------------------------------- Ghost filling ---------------------------------- */ -void fclaw2d_patch_copy_face(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, - fclaw2d_patch_t *neighbor_patch, +void fclaw_patch_copy_face(fclaw_global_t* glob, + fclaw_patch_t *this_patch, + fclaw_patch_t *neighbor_patch, int iface, int time_interp, - fclaw2d_patch_transform_data_t *transform_data) + fclaw_patch_transform_data_t *transform_data) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->copy_face != NULL); patch_vt->copy_face(glob,this_patch,neighbor_patch,iface, time_interp,transform_data); } -void fclaw2d_patch_average_face(fclaw2d_global_t* glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, +void fclaw_patch_average_face(fclaw_global_t* glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, int idir, int iface_coarse, int RefineFactor, int refratio, int time_interp, int igrid, - fclaw2d_patch_transform_data_t* transform_data) + fclaw_patch_transform_data_t* transform_data) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->average_face != NULL); patch_vt->average_face(glob,coarse_patch,fine_patch,idir, @@ -374,36 +395,84 @@ void fclaw2d_patch_average_face(fclaw2d_global_t* glob, transform_data); } -void fclaw2d_patch_interpolate_face(fclaw2d_global_t* glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, +void fclaw_patch_interpolate_face(fclaw_global_t* glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, int idir, int iside, int RefineFactor, int refratio, int time_interp, int igrid, - fclaw2d_patch_transform_data_t* transform_data) + fclaw_patch_transform_data_t* transform_data) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->interpolate_face != NULL); patch_vt->interpolate_face(glob,coarse_patch,fine_patch,idir, iside,RefineFactor,refratio, time_interp,igrid,transform_data); } +void fclaw_patch_copy_edge(fclaw_global_t* glob, + fclaw_patch_t *this_patch, + fclaw_patch_t *edge_patch, + int coarse_blockno, + int fine_blockno, + int icorner, + int time_interp, + fclaw_patch_transform_data_t *transform_data) +{ + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); + FCLAW_ASSERT(this_patch->refine_dim == 3); + patch_vt->copy_edge(glob,this_patch,edge_patch, + coarse_blockno,fine_blockno, + icorner,time_interp,transform_data); +} + +void fclaw_patch_average_edge(fclaw_global_t* glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, + int iedge_coarse, + int time_interp, + fclaw_patch_transform_data_t* transform_data) +{ + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); + FCLAW_ASSERT(coarse_patch->refine_dim == 3); + FCLAW_ASSERT(patch_vt->copy_edge != NULL); + patch_vt->average_edge(glob,coarse_patch,fine_patch, + iedge_coarse, + time_interp,transform_data); + +} -void fclaw2d_patch_copy_corner(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, - fclaw2d_patch_t *corner_patch, +void fclaw_patch_interpolate_edge(fclaw_global_t* glob, + fclaw_patch_t* coarse_patch, + fclaw_patch_t* fine_patch, + int coarse_edge, + int time_interp, + fclaw_patch_transform_data_t + *transform_data) +{ + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); + FCLAW_ASSERT(coarse_patch->refine_dim == 3); + FCLAW_ASSERT(patch_vt->interpolate_edge != NULL); + patch_vt->interpolate_edge(glob,coarse_patch,fine_patch, + coarse_edge,time_interp, + transform_data); +} + + +void fclaw_patch_copy_corner(fclaw_global_t* glob, + fclaw_patch_t *this_patch, + fclaw_patch_t *corner_patch, int coarse_blockno, int fine_blockno, int is_block_corner, int icorner, int time_interp, - fclaw2d_patch_transform_data_t *transform_data) + fclaw_patch_transform_data_t *transform_data) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); if (!is_block_corner) { FCLAW_ASSERT(patch_vt->copy_corner != NULL); @@ -420,17 +489,17 @@ void fclaw2d_patch_copy_corner(fclaw2d_global_t* glob, } } -void fclaw2d_patch_average_corner(fclaw2d_global_t* glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, +void fclaw_patch_average_corner(fclaw_global_t* glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, int coarse_blockno, int fine_blockno, int is_block_corner, int coarse_corner, int time_interp, - fclaw2d_patch_transform_data_t* transform_data) + fclaw_patch_transform_data_t* transform_data) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); if (!is_block_corner) { FCLAW_ASSERT(patch_vt->average_corner != NULL); @@ -449,18 +518,18 @@ void fclaw2d_patch_average_corner(fclaw2d_global_t* glob, } } -void fclaw2d_patch_interpolate_corner(fclaw2d_global_t* glob, - fclaw2d_patch_t* coarse_patch, - fclaw2d_patch_t* fine_patch, +void fclaw_patch_interpolate_corner(fclaw_global_t* glob, + fclaw_patch_t* coarse_patch, + fclaw_patch_t* fine_patch, int coarse_blockno, int fine_blockno, int is_block_corner, int coarse_corner, int time_interp, - fclaw2d_patch_transform_data_t + fclaw_patch_transform_data_t *transform_data) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); if (!is_block_corner) { FCLAW_ASSERT(patch_vt->interpolate_corner != NULL); @@ -484,31 +553,31 @@ void fclaw2d_patch_interpolate_corner(fclaw2d_global_t* glob, /* -------------------------- Transform functions ------------------------------------- */ -void fclaw2d_patch_transform_init_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, +void fclaw_patch_transform_init_data(fclaw_global_t* glob, + fclaw_patch_t* patch, int blockno, int patchno, - fclaw2d_patch_transform_data_t *ftransform) + fclaw_patch_transform_data_t *ftransform) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->transform_init_data != NULL); patch_vt->transform_init_data(glob,patch,blockno,patchno,ftransform); } /* This is the transform at block faces. */ -void fclaw2d_patch_transform_blockface(fclaw2d_global_t* glob, +void fclaw_patch_transform_blockface(fclaw_global_t* glob, int faceno, int rfaceno, int ftransform[]) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->transform_face != NULL); patch_vt->transform_face(faceno, rfaceno, ftransform); } /* Transform within a block, where we only have the identity transform */ -void fclaw2d_patch_transform_blockface_intra(fclaw2d_global_t* glob, +void fclaw_patch_transform_blockface_intra(fclaw_global_t* glob, int ftransform[]) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->transform_face_intra != NULL); patch_vt->transform_face_intra(ftransform); } @@ -516,52 +585,52 @@ void fclaw2d_patch_transform_blockface_intra(fclaw2d_global_t* glob, /* ------------------------------- Regridding functions ------------------------------- */ -int fclaw2d_patch_tag4refinement(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +int fclaw_patch_tag4refinement(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, int patchno, int initflag) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->tag4refinement != NULL); return patch_vt->tag4refinement(glob,this_patch,blockno, patchno, initflag); } -int fclaw2d_patch_tag4coarsening(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, +int fclaw_patch_tag4coarsening(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, int blockno, int patchno, int initflag) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->tag4coarsening != NULL); return patch_vt->tag4coarsening(glob,fine_patches, blockno, patchno,initflag); } -void fclaw2d_patch_average2coarse(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, - fclaw2d_patch_t *coarse_patch, +void fclaw_patch_average2coarse(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + fclaw_patch_t *coarse_patch, int blockno, int fine0_patchno, int coarse_patchno) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->average2coarse != NULL); patch_vt->average2coarse(glob,fine_patches,coarse_patch, blockno,fine0_patchno,coarse_patchno); } -void fclaw2d_patch_interpolate2fine(fclaw2d_global_t* glob, - fclaw2d_patch_t* coarse_patch, - fclaw2d_patch_t* fine_patches, +void fclaw_patch_interpolate2fine(fclaw_global_t* glob, + fclaw_patch_t* coarse_patch, + fclaw_patch_t* fine_patches, int this_blockno, int coarse_patchno, int fine0_patchno) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->interpolate2fine != NULL); patch_vt->interpolate2fine(glob,coarse_patch,fine_patches, @@ -571,17 +640,17 @@ void fclaw2d_patch_interpolate2fine(fclaw2d_global_t* glob, /* ---------------------------- Ghost patches (local and remote) ---------------------- */ -size_t fclaw2d_patch_ghost_packsize(fclaw2d_global_t* glob) +size_t fclaw_patch_ghost_packsize(fclaw_global_t* glob) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->ghost_packsize != NULL); return patch_vt->ghost_packsize(glob); } -void fclaw2d_patch_local_ghost_alloc(fclaw2d_global_t* glob, +void fclaw_patch_local_ghost_alloc(fclaw_global_t* glob, void** q) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); if (patch_vt->local_ghost_alloc != NULL) { patch_vt->local_ghost_alloc(glob, q); @@ -589,16 +658,16 @@ void fclaw2d_patch_local_ghost_alloc(fclaw2d_global_t* glob, else { /* This assumes that sizeof(char) = 1 */ - size_t psize = fclaw2d_patch_ghost_packsize(glob); + size_t psize = fclaw_patch_ghost_packsize(glob); *q = (void*) FCLAW_ALLOC(char,psize); /* sizeof(datatype) included in psize */ FCLAW_ASSERT(*q != NULL); } } -void fclaw2d_patch_local_ghost_free(fclaw2d_global_t* glob, +void fclaw_patch_local_ghost_free(fclaw_global_t* glob, void **q) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); if (patch_vt->local_ghost_free != NULL) { patch_vt->local_ghost_free(glob,q); @@ -610,12 +679,12 @@ void fclaw2d_patch_local_ghost_free(fclaw2d_global_t* glob, } } -void fclaw2d_patch_local_ghost_pack(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw_patch_local_ghost_pack(fclaw_global_t *glob, + fclaw_patch_t *this_patch, void *patch_data, int time_interp) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->local_ghost_pack != NULL); patch_vt->local_ghost_pack(glob, this_patch, @@ -623,13 +692,13 @@ void fclaw2d_patch_local_ghost_pack(fclaw2d_global_t *glob, time_interp); } -void fclaw2d_patch_remote_ghost_build(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw_patch_remote_ghost_build(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int blockno, int patchno, - fclaw2d_build_mode_t build_mode) + fclaw_build_mode_t build_mode) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->remote_ghost_build != NULL); @@ -644,12 +713,12 @@ void fclaw2d_patch_remote_ghost_build(fclaw2d_global_t *glob, } -void fclaw2d_patch_remote_ghost_delete(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch) +void fclaw_patch_remote_ghost_delete(fclaw_global_t *glob, + fclaw_patch_t *this_patch) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); - fclaw2d_patch_data_t *pdata = get_patch_data(this_patch); + fclaw_patch_data_t *pdata = get_patch_data(this_patch); if (pdata != NULL) @@ -660,18 +729,17 @@ void fclaw2d_patch_remote_ghost_delete(fclaw2d_global_t *glob, FCLAW_FREE(pdata); this_patch->user = NULL; - fclaw2d_domain_data_t *ddata = fclaw2d_domain_get_data(glob->domain); - ++ddata->count_delete_patch; + ++glob->domain->count_delete_patch; } } -void fclaw2d_patch_remote_ghost_unpack(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch, +void fclaw_patch_remote_ghost_unpack(fclaw_global_t* glob, + fclaw_patch_t* this_patch, int this_block_idx, int this_patch_idx, void *qdata, int time_interp) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->remote_ghost_unpack != NULL); patch_vt->remote_ghost_unpack(glob, this_patch, this_block_idx, this_patch_idx, qdata, time_interp); @@ -680,43 +748,49 @@ void fclaw2d_patch_remote_ghost_unpack(fclaw2d_global_t* glob, /* ----------------------------------- Partitioning ----------------------------------- */ -size_t fclaw2d_patch_partition_packsize(fclaw2d_global_t* glob) +size_t fclaw_patch_partition_packsize(fclaw_global_t* glob) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->partition_packsize != NULL); - return patch_vt->partition_packsize(glob); + return patch_data_packsize() + patch_vt->partition_packsize(glob); } -void fclaw2d_patch_partition_pack(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw_patch_partition_pack(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void* pack_data_here) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->partition_pack != NULL); + patch_vt->partition_pack(glob, this_patch, this_block_idx, this_patch_idx, pack_data_here); + + FCLAW_ASSERT(patch_vt->partition_packsize != NULL); + void* pdata_pack_data_here = (void*) ((char*) pack_data_here + patch_vt->partition_packsize(glob)); + patch_data_pack(glob,this_patch,pdata_pack_data_here); } -void fclaw2d_patch_partition_unpack(fclaw2d_global_t *glob, - fclaw2d_domain_t *new_domain, - fclaw2d_patch_t *this_patch, +void fclaw_patch_partition_unpack(fclaw_global_t *glob, + fclaw_domain_t *new_domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *unpack_data_from_here) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); - fclaw2d_build_mode_t build_mode = FCLAW2D_BUILD_FOR_UPDATE; + fclaw_build_mode_t build_mode = FCLAW_BUILD_FOR_UPDATE; - fclaw2d_patch_build(glob,this_patch,this_block_idx, + fclaw_patch_build(glob,this_patch,this_block_idx, this_patch_idx,(void*) &build_mode); /* This copied q data from memory */ @@ -728,24 +802,28 @@ void fclaw2d_patch_partition_unpack(fclaw2d_global_t *glob, this_block_idx, this_patch_idx, unpack_data_from_here); + + FCLAW_ASSERT(patch_vt->partition_packsize != NULL); + void* pdata_unpack_data_from_here = (void*) ((char*) unpack_data_from_here + patch_vt->partition_packsize(glob)); + patch_data_unpack(glob,this_patch,pdata_unpack_data_from_here); } /* ----------------------------- Conservative updates --------------------------------- */ -/* We need to virtualize this because we call it from fclaw2d_face_neighbors */ +/* We need to virtualize this because we call it from fclaw_face_neighbors */ -void fclaw2d_patch_time_sync_f2c(fclaw2d_global_t* glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, +void fclaw_patch_time_sync_f2c(fclaw_global_t* glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, int coarse_blockno, int fine_blockno, int coarse_patchno, int idir, int igrid, int iface_coarse, int time_interp, - fclaw2d_patch_transform_data_t* transform_data) + fclaw_patch_transform_data_t* transform_data) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->time_sync_f2c != NULL); patch_vt->time_sync_f2c(glob,coarse_patch,fine_patch, @@ -756,26 +834,26 @@ void fclaw2d_patch_time_sync_f2c(fclaw2d_global_t* glob, } /* Correct for metric discontinuities at block boundaries */ -void fclaw2d_patch_time_sync_samesize(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, - fclaw2d_patch_t *neighbor_patch, +void fclaw_patch_time_sync_samesize(fclaw_global_t* glob, + fclaw_patch_t *this_patch, + fclaw_patch_t *neighbor_patch, int iface, int idir, - fclaw2d_patch_transform_data_t *transform_data) + fclaw_patch_transform_data_t *transform_data) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->time_sync_samesize != NULL); patch_vt->time_sync_samesize(glob,this_patch,neighbor_patch,iface,idir, transform_data); } -void fclaw2d_patch_time_sync_reset(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch, +void fclaw_patch_time_sync_reset(fclaw_global_t* glob, + fclaw_patch_t* this_patch, int coarse_level, int reset_mode) { - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->time_sync_reset != NULL); patch_vt->time_sync_reset(glob,this_patch,coarse_level, reset_mode); @@ -785,9 +863,9 @@ void fclaw2d_patch_time_sync_reset(fclaw2d_global_t* glob, /* ----------------------------------- Virtual table ---------------------------------- */ static -fclaw2d_patch_vtable_t* patch_vt_new() +fclaw_patch_vtable_t* patch_vt_new() { - return (fclaw2d_patch_vtable_t*) FCLAW_ALLOC_ZERO (fclaw2d_patch_vtable_t, 1); + return (fclaw_patch_vtable_t*) FCLAW_ALLOC_ZERO (fclaw_patch_vtable_t, 1); } static @@ -796,9 +874,9 @@ void patch_vt_destroy(void* vt) FCLAW_FREE (vt); } -void fclaw2d_patch_vtable_initialize(fclaw2d_global_t* glob) +void fclaw_patch_vtable_initialize(fclaw_global_t* glob) { - fclaw2d_patch_vtable_t *patch_vt = patch_vt_new(); + fclaw_patch_vtable_t *patch_vt = patch_vt_new(); patch_vt->is_set = 1; @@ -808,9 +886,9 @@ void fclaw2d_patch_vtable_initialize(fclaw2d_global_t* glob) /* ------------------------------ User access functions ------------------------------- */ -fclaw2d_patch_vtable_t* fclaw2d_patch_vt(fclaw2d_global_t* glob) +fclaw_patch_vtable_t* fclaw_patch_vt(fclaw_global_t* glob) { - fclaw2d_patch_vtable_t* patch_vt = (fclaw2d_patch_vtable_t*) + fclaw_patch_vtable_t* patch_vt = (fclaw_patch_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fclaw2d_patch"); FCLAW_ASSERT(patch_vt != NULL); FCLAW_ASSERT(patch_vt->is_set != 0); @@ -820,14 +898,14 @@ fclaw2d_patch_vtable_t* fclaw2d_patch_vt(fclaw2d_global_t* glob) /* Use this one if you have the patch or block number */ -void fclaw2d_patch_get_info(fclaw2d_domain_t * domain, - fclaw2d_patch_t * patch, +void fclaw_patch_get_info(fclaw_domain_t * domain, + fclaw_patch_t * patch, int blockno, int patchno, int *global_num, int *local_num, int *level) { - fclaw2d_block_t *block = &domain->blocks[blockno]; + fclaw_block_t *block = &domain->blocks[blockno]; /* For blockno = 0, we have patchno == local_num. @@ -843,8 +921,8 @@ void fclaw2d_patch_get_info(fclaw2d_domain_t * domain, } /* Use this one if you don't have the patch or block number */ -void fclaw2d_patch_get_info2(fclaw2d_domain_t * domain, - fclaw2d_patch_t * this_patch, +void fclaw_patch_get_info2(fclaw_domain_t * domain, + fclaw_patch_t * this_patch, int *this_block_idx, int *this_patch_idx, int *global_num, int *level) @@ -852,11 +930,11 @@ void fclaw2d_patch_get_info2(fclaw2d_domain_t * domain, /* I don't completely trust this that blockno and patchno are consistent with p4est numbering. */ - fclaw2d_patch_data_t *pdata = (fclaw2d_patch_data_t*) this_patch->user; + fclaw_patch_data_t *pdata = (fclaw_patch_data_t*) this_patch->user; *this_patch_idx = pdata->patch_idx; *this_block_idx = pdata->block_idx; - fclaw2d_block_t *this_block = &domain->blocks[*this_block_idx]; + fclaw_block_t *this_block = &domain->blocks[*this_block_idx]; *global_num = domain->global_num_patches_before + (this_block->num_patches_before + *this_patch_idx); @@ -867,58 +945,58 @@ void fclaw2d_patch_get_info2(fclaw2d_domain_t * domain, void* -fclaw2d_patch_get_user_patch(fclaw2d_patch_t* patch) +fclaw_patch_get_user_patch(fclaw_patch_t* patch) { return get_user_patch(patch); } -fclaw2d_patch_data_t* -fclaw2d_patch_get_patch_data(fclaw2d_patch_t* patch) +fclaw_patch_data_t* +fclaw_patch_get_patch_data(fclaw_patch_t* patch) { return get_patch_data(patch); } -void* fclaw2d_patch_get_user_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch) +void* fclaw_patch_get_user_data(fclaw_global_t* glob, + fclaw_patch_t* this_patch) { - fclaw2d_patch_data_t *pdata = get_patch_data(this_patch); + fclaw_patch_data_t *pdata = get_patch_data(this_patch); return pdata->user_data; } -void fclaw2d_patch_set_user_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch, +void fclaw_patch_set_user_data(fclaw_global_t* glob, + fclaw_patch_t* this_patch, void* user) { - fclaw2d_patch_data_t *pdata = get_patch_data(this_patch); + fclaw_patch_data_t *pdata = get_patch_data(this_patch); pdata->user_data = user; } -void* fclaw2d_patch_metric_patch(fclaw2d_global_t* glob, - fclaw2d_patch_t *patch) +void* fclaw_patch_metric_patch(fclaw_global_t* glob, + fclaw_patch_t *patch) { - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); FCLAW_ASSERT(patch_vt->metric_patch != NULL); return patch_vt->metric_patch(patch); } int -fclaw2d_patch_get_blockno(fclaw2d_patch_t* this_patch) +fclaw_patch_get_blockno(fclaw_patch_t* this_patch) { /* This is is really only here if we fail to pass in the blockno to a patch routine. */ - fclaw2d_patch_data_t* pdata = get_patch_data(this_patch); + fclaw_patch_data_t* pdata = get_patch_data(this_patch); FCLAW_ASSERT(pdata->block_idx >= 0); return pdata->block_idx; } int -fclaw2d_patch_get_patchno(fclaw2d_patch_t* this_patch) +fclaw_patch_get_patchno(fclaw_patch_t* this_patch) { /* This is is really only here if we fail to pass in the patchno to a patch routine. */ - fclaw2d_patch_data_t* pdata = get_patch_data(this_patch); + fclaw_patch_data_t* pdata = get_patch_data(this_patch); FCLAW_ASSERT(pdata->patch_idx >= 0); return pdata->patch_idx; } @@ -926,104 +1004,109 @@ fclaw2d_patch_get_patchno(fclaw2d_patch_t* this_patch) /* -------------------------- Internal ForestClaw functions --------------------------- */ -void fclaw2d_patch_set_face_type(fclaw2d_patch_t *patch,int iface, - fclaw2d_patch_relation_t face_type) +void fclaw_patch_set_face_type(fclaw_patch_t *patch,int iface, + fclaw_patch_relation_t face_type) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); pdata->face_neighbors[iface] = face_type; } -void fclaw2d_patch_set_corner_type(fclaw2d_patch_t *patch,int icorner, - fclaw2d_patch_relation_t corner_type) +void fclaw_patch_set_corner_type(fclaw_patch_t *patch,int icorner, + fclaw_patch_relation_t corner_type) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); pdata->corner_neighbors[icorner] = corner_type; pdata->corners[icorner] = 1; } -void fclaw2d_patch_set_missing_corner(fclaw2d_patch_t *patch,int icorner) +void fclaw_patch_set_missing_corner(fclaw_patch_t *patch,int icorner) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); pdata->corners[icorner] = 0; } -fclaw2d_patch_relation_t fclaw2d_patch_get_face_type(fclaw2d_patch_t* patch, +fclaw_patch_relation_t fclaw_patch_get_face_type(fclaw_patch_t* patch, int iface) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); FCLAW_ASSERT(pdata->neighbors_set != 0); - FCLAW_ASSERT(0 <= iface && iface < FCLAW2D_NUMFACES); + FCLAW_ASSERT(0 <= iface && iface < (patch->refine_dim == 2 ? FCLAW2D_NUMFACES : FCLAW3D_NUMFACES)); return pdata->face_neighbors[iface]; } -fclaw2d_patch_relation_t fclaw2d_patch_get_corner_type(fclaw2d_patch_t* patch, +fclaw_patch_relation_t fclaw_patch_get_corner_type(fclaw_patch_t* patch, int icorner) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); FCLAW_ASSERT(pdata->corners[icorner] != 0); FCLAW_ASSERT(pdata->neighbors_set != 0); return pdata->corner_neighbors[icorner]; } -int fclaw2d_patch_corner_is_missing(fclaw2d_patch_t* patch, +int fclaw_patch_corner_is_missing(fclaw_patch_t* patch, int icorner) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); return !pdata->corners[icorner]; } -void fclaw2d_patch_neighbors_set(fclaw2d_patch_t* patch) +void fclaw_patch_neighbors_set(fclaw_patch_t* patch) { - int iface, icorner; -#ifdef P4_TO_P8 - int iedge; -#endif - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); FCLAW_ASSERT(pdata->neighbors_set == 0); pdata->has_finegrid_neighbors = 0; pdata->on_coarsefine_interface = 0; - for (iface = 0; iface < FCLAW2D_NUMFACES; iface++) + int num_faces = patch->refine_dim == 2 ? FCLAW2D_NUMFACES : FCLAW3D_NUMFACES; + fclaw_patch_relation_t* face_neighbors = pdata->face_neighbors; + for (int iface = 0; iface < num_faces; iface++) { - fclaw2d_patch_relation_t nt; - nt = pdata->face_neighbors[iface]; - if (nt == FCLAW2D_PATCH_HALFSIZE || (nt == FCLAW2D_PATCH_DOUBLESIZE)) + fclaw_patch_relation_t nt; + nt = face_neighbors[iface]; + if (nt == FCLAW_PATCH_HALFSIZE || (nt == FCLAW_PATCH_DOUBLESIZE)) { pdata->on_coarsefine_interface = 1; - if (nt == FCLAW2D_PATCH_HALFSIZE) + if (nt == FCLAW_PATCH_HALFSIZE) { pdata->has_finegrid_neighbors = 1; } } } -#ifdef P4_TO_P8 - for (iedge = 0; iedge < FCLAW3D_NUMEDGES; iedge++) - { - fclaw2d_patch_relation_t nt; - nt = pdata->edge_neighbors[iedge]; - if (nt == FCLAW2D_PATCH_HALFSIZE || (nt == FCLAW2D_PATCH_DOUBLESIZE)) + if(patch->refine_dim == 3) + { + for (int iedge = 0; iedge < FCLAW3D_NUMEDGES; iedge++) { - pdata->on_coarsefine_interface = 1; - if (nt == FCLAW2D_PATCH_HALFSIZE) + fclaw_patch_relation_t nt; + nt = pdata->edge_neighbors[iedge]; + if (nt == FCLAW_PATCH_HALFSIZE || (nt == FCLAW_PATCH_DOUBLESIZE)) { - pdata->has_finegrid_neighbors = 1; + pdata->on_coarsefine_interface = 1; + if (nt == FCLAW_PATCH_HALFSIZE) + { + pdata->has_finegrid_neighbors = 1; + } } } } -#endif - for (icorner = 0; icorner < FCLAW2D_NUMCORNERS; icorner++) + int num_corners; + fclaw_patch_relation_t* corner_neighbors; + int* corners; + num_corners = patch->refine_dim == 2 ? FCLAW2D_NUMCORNERS : FCLAW3D_NUMCORNERS; + corner_neighbors = pdata->corner_neighbors; + corners = pdata->corners; + for (int icorner = 0; icorner < num_corners; icorner++) { - fclaw2d_patch_relation_t nt; - int has_corner = pdata->corners[icorner]; + fclaw_patch_relation_t nt; + int has_corner = corners[icorner]; if (has_corner) { - nt = pdata->corner_neighbors[icorner]; - if ((nt == FCLAW2D_PATCH_HALFSIZE) || (nt == FCLAW2D_PATCH_DOUBLESIZE)) + nt = corner_neighbors[icorner]; + if ((nt == FCLAW_PATCH_HALFSIZE) || (nt == FCLAW_PATCH_DOUBLESIZE)) { pdata->on_coarsefine_interface = 1; - if (nt == FCLAW2D_PATCH_HALFSIZE) + if (nt == FCLAW_PATCH_HALFSIZE) { pdata->has_finegrid_neighbors = 1; } @@ -1033,52 +1116,135 @@ void fclaw2d_patch_neighbors_set(fclaw2d_patch_t* patch) pdata->neighbors_set = 1; } -void fclaw2d_patch_neighbors_reset(fclaw2d_patch_t* patch) +void fclaw_patch_neighbors_reset(fclaw_patch_t* patch) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); pdata->neighbors_set = 0; } -int fclaw2d_patch_neighbor_type_set(fclaw2d_patch_t* patch) +int fclaw_patch_neighbor_type_set(fclaw_patch_t* patch) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); return pdata->neighbors_set; } -int fclaw2d_patch_has_finegrid_neighbors(fclaw2d_patch_t *patch) +int fclaw_patch_has_finegrid_neighbors(fclaw_patch_t *patch) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); return pdata->has_finegrid_neighbors; } -int fclaw2d_patch_on_coarsefine_interface(fclaw2d_patch_t *patch) +int fclaw_patch_on_coarsefine_interface(fclaw_patch_t *patch) { - fclaw2d_patch_data_t *pdata = get_patch_data(patch); + fclaw_patch_data_t *pdata = get_patch_data(patch); return pdata->on_coarsefine_interface; } int -fclaw2d_patch_on_parallel_boundary (const fclaw2d_patch_t * patch) +fclaw_patch_on_parallel_boundary (const fclaw_patch_t * patch) { - return patch->flags & FCLAW2D_PATCH_ON_PARALLEL_BOUNDARY ? 1 : 0; + if(patch->refine_dim == 2) + { + return patch->d2->flags & FCLAW2D_PATCH_ON_PARALLEL_BOUNDARY ? 1 : 0; + } + else if(patch->refine_dim == 3) + { + return patch->d3->flags & FCLAW3D_PATCH_ON_PARALLEL_BOUNDARY ? 1 : 0; + } + else + { + SC_ABORT_NOT_REACHED (); + } } -int* fclaw2d_patch_block_corner_count(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch) +int* fclaw_patch_block_corner_count(fclaw_global_t* glob, + fclaw_patch_t* this_patch) { - fclaw2d_patch_data_t *pdata = get_patch_data(this_patch); + fclaw_patch_data_t *pdata = get_patch_data(this_patch); return pdata->block_corner_count; } -void fclaw2d_patch_set_block_corner_count(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch, +void fclaw_patch_set_block_corner_count(fclaw_global_t* glob, + fclaw_patch_t* this_patch, int icorner, int block_corner_count) { - fclaw2d_patch_data_t *pdata = get_patch_data(this_patch); + fclaw_patch_data_t *pdata = get_patch_data(this_patch); pdata->block_corner_count[icorner] = block_corner_count; } +void fclaw_patch_set_edge_type(fclaw_patch_t *patch,int iedge, + fclaw_patch_relation_t edge_type) +{ + fclaw_patch_data_t *pdata = get_patch_data(patch); + pdata->edge_neighbors[iedge] = edge_type; +} +fclaw_patch_relation_t fclaw_patch_get_edge_type(fclaw_patch_t* patch, + int iedge) +{ + fclaw_patch_data_t *pdata = get_patch_data(patch); + FCLAW_ASSERT(pdata->neighbors_set != 0); + FCLAW_ASSERT(0 <= iedge && iedge < FCLAW3D_NUMEDGES); + return pdata->edge_neighbors[iedge]; +} +void fclaw_patch_considered_for_refinement_set(struct fclaw_global *glob, + struct fclaw_patch* patch) +{ + fclaw_patch_data_t *pdata = get_patch_data(patch); + //FCLAW_ASSERT(pdata->considered_for_refinement == 0); + pdata->considered_for_refinement = 1; +} +void fclaw_patch_considered_for_refinement_clear(struct fclaw_global *glob, + struct fclaw_patch* patch) +{ + fclaw_patch_data_t *pdata = get_patch_data(patch); + pdata->considered_for_refinement = 0; +} + +int fclaw_patch_considered_for_refinement(struct fclaw_global *glob, + struct fclaw_patch* patch) +{ + fclaw_patch_data_t *pdata = get_patch_data(patch); + return pdata->considered_for_refinement; +} + +static +void considred_for_refinement_cb(fclaw_domain_t *domain, + fclaw_patch_t *patch, + int blockno, int patchno, + void *user) +{ + fclaw_patch_data_t *pdata = get_patch_data(patch); + int *all_patches_considered = (int*) user; + if (!pdata->considered_for_refinement) + { + *all_patches_considered = 0; + } +} + +int fclaw_patch_all_considered_for_refinement(struct fclaw_global *glob) +{ + int local_all_patches_considered = 1; + fclaw_domain_iterate_patches(glob->domain, considred_for_refinement_cb, &local_all_patches_considered); + int all_patches_considered; + sc_MPI_Allreduce(&local_all_patches_considered, &all_patches_considered, 1, sc_MPI_INT, sc_MPI_LAND, glob->mpicomm); + return all_patches_considered; +} + +static +void clear_considred_for_refinement_cb(fclaw_domain_t *domain, + fclaw_patch_t *patch, + int blockno, int patchno, + void *user) +{ + fclaw_patch_data_t *pdata = get_patch_data(patch); + pdata->considered_for_refinement = 0; +} + +void fclaw_patch_clear_all_considered_for_refinement(struct fclaw_global *glob) +{ + fclaw_domain_iterate_patches(glob->domain, clear_considred_for_refinement_cb, NULL); +} \ No newline at end of file diff --git a/src/fclaw_patch.h b/src/fclaw_patch.h index b48168f12..d0ec0ea61 100644 --- a/src/fclaw_patch.h +++ b/src/fclaw_patch.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton All rights reserved. Redistribution and use in source and binary forms, with or without @@ -22,44 +22,2040 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** +/** * @file - * Dimension-independent wrapper of a forestclaw patch. + * @brief Patch related functions and typedefs */ + #ifndef FCLAW_PATCH_H #define FCLAW_PATCH_H -/* - * Domain-independent header file should not include domain-specific headers. - * The corresponding source file include the 2d and 3d domain-specific headers. +#include /* Contains definition of patch-iterator callback */ + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} +#endif +#endif + + +/** vtable type */ +typedef struct fclaw_patch_vtable fclaw_patch_vtable_t; +/** patch data type */ +typedef struct fclaw_patch_data fclaw_patch_data_t; +/** transform data type */ +typedef struct fclaw_patch_transform_data fclaw_patch_transform_data_t; + +/** + * @brief The build mode */ -#include +typedef enum +{ + /** Expect the patch's area array to be computed when unpacked */ + FCLAW_BUILD_FOR_GHOST_AREA_COMPUTED = 0, + /** Pack a patch's area array */ + FCLAW_BUILD_FOR_GHOST_AREA_PACKED, + /** Build for an updated grid */ + FCLAW_BUILD_FOR_UPDATE, + /** Use a user defined build mode */ + FCLAW_BUILD_CUSTOM +} fclaw_build_mode_t; -typedef struct fclaw_patch_user + + +/** + * @brief Structure for user patch data + * + * The user patch (clawpatch, for example) is stored in fclaw2d_patch_data.user_patch + */ +struct fclaw_patch_data { + int refine_dim; + + /** Pointer to the core patch structure in the domain */ + const fclaw_patch_t *real_patch; + + /** Neighbor relation on each face */ + fclaw_patch_relation_t face_neighbors[6]; + /** Neighbor relation on each edge */ + fclaw_patch_relation_t edge_neighbors[12]; + /** Neighbor relation on each corner */ + fclaw_patch_relation_t corner_neighbors[8]; + /** True if coner has neighbor */ + int corners[8]; + /** The number of patches that meet at each corner */ + int block_corner_count[8]; + /** True if this patch lies on a coarse-fine interface */ + int on_coarsefine_interface; + /** True if there are finer neighbors */ + int has_finegrid_neighbors; + /** True if neighbor information is set */ + int neighbors_set; + + /** Patch index */ + int patch_idx; + /** Block index */ + int block_idx; + + /** True if patch has been considered for refinement */ + int considered_for_refinement; + /** User defined patch structure */ void *user_patch; - /** Additional user data */ void *user_data; -} -fclaw_patch_user_t; +}; + +/** + * @brief Transform data for a neighboring patch's coordinate system + */ +struct fclaw_patch_transform_data +{ + int dim; + + /** Pointer to this patch */ + struct fclaw_patch *this_patch; + /** This patch's blockno */ + int this_blockno; + /** This patch's patchno */ + int this_patchno; + /** Pointer to the neighbor patch */ + struct fclaw_patch *neighbor_patch; + /** Neighbor patch's blockno */ + int neighbor_blockno; + /** Neighbor patch's patchno */ + int neighbor_patchno; + /** Neighbor type */ + fclaw_patch_relation_t neighbor_type; + /** + * @brief Transform array + * + * . For 2D: + * + * This array holds 9 integers. + * [0,2] The coordinate axis sequence of the origin face, + * the first referring to the tangential and the second + * to the normal. A permutation of (0, 1). + * [3,5] The coordinate axis sequence of the target face. + * [6,8] Edge reversal flag for tangential axis (boolean); + * face code in [0, 3] for the normal coordinate q: + * 0: q' = -q + * 1: q' = q + 1 + * 2: q' = q - 1 + * 3: q' = 2 - q + * [8] & 4: Both patches are in the same block, + * the \a ftransform contents are ignored. + * [1,4,7] 0 (unused for compatibility with 3D).ftransform + * + * . For 3D: + * + * [0]..[2] The coordinate axis sequence of the origin face, + * the first two referring to the tangentials and the + * third to the normal. A permutation of (0, 1, 2). + * [3]..[5] The coordinate axis sequence of the target face. + * [6]..[8] Edge reversal flags for tangential axes (boolean); + * face code in [0, 3] for the normal coordinate q: + * 0: q' = -q + * 1: q' = q + 1 + * 2: q' = q - 1 + * 3: q' = 2 - q + * + */ + int transform[9]; + /** + * @brief Base index + * + * 1 for cell-centered (1 .. mx); 0 for nodes (0 .. mx) + */ + int based; + + /** The corner that the neighboring patch is on. */ + int icorner; + /** The edge that the neighboring patch is on. */ + int iedge; + /** The face that the neighboring patch is on */ + int iface; + + /** True if neighbor is across a block corner */ + int is_block_corner; + /** True if neighbor is accross a block edge */ + int is_block_edge; + /** True if neighbor is across a block face */ + int is_block_face; + /** -1 for unless neighbor is across a block edge */ + int block_iedge; + /** -1 for unless neighbor is across a block face */ + int block_iface; + + /** Pointer to the glboal context */ + struct fclaw_global *glob; + /** User pointer */ + void* user; +}; + + +struct fclaw_global; +struct fclaw_domain; +struct fclaw_patch; + + +/* ------------------------------------------------------------------------------------ */ +/// @name Creating/Deleting Patches +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Deallocate the user data pointer for a patch + * + * @param[in] glob the global context + * @param[in,out] patch the patch context, user data pointer is set to NULL on return + */ +void fclaw_patch_data_delete(struct fclaw_global *glob, + struct fclaw_patch *patch); + +/** + * @brief Construct a new patch object + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in,out] user user data pointer + */ +void fclaw_patch_build(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + void *user); + +/** + * @brief Construct a new patch object from a set of fine patches + * + * @param[in] glob the global context + * @param[in] fine_patches the fine patch contexts + * @param[in,out] coarse_patches the coarse patch context + * @param[in] blockno the block number + * @param[in] coarse_patchno coarse patch number + * @param[in] fine0_patchno first fine patch number + * @param[in] build_mode the build mode + */ +void fclaw_patch_build_from_fine(struct fclaw_global *glob, + struct fclaw_patch *fine_patches, + struct fclaw_patch *coarse_patch, + int blockno, + int coarse_patchno, + int fine0_patchno, + fclaw_build_mode_t build_mode); + + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Solver Specific Functions +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Initialize patch data for a solver + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + */ +void fclaw_patch_initialize(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno); + +/** + * @brief Initialize boundary conditions + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in] t the time + * @param[in] dt the timestep + * @param[in] intersects_bc array of values for each face, true if physical boundary + * @param[in] time_interp true if in time interpolation stage (not global) + */ +void fclaw_patch_physical_bc(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + double t, + double dt, + int *intersects_bc, + int time_interp); + +/** + * @brief Advance a patch with a single time step + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in] t the time + * @param[in] dt the timestep + * @param[in] user pointer to the ::fclaw2d_single_step_buffer_data struct (used in cudaclaw) + * @return double the maxcfl + */ +double fclaw_patch_single_step_update(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + double t, + double dt, void* user); + +/** + * @brief Set the right hand side for a patch + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + */ +void fclaw_patch_set_rhs(struct fclaw_global *glob, + struct fclaw_patch *patch, + int blockno, + int patchno); + + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Time Stepping +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Restores a previously saved solution + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + */ +void fclaw_patch_restore_step(struct fclaw_global* glob, + struct fclaw_patch* this_patch); + +/** + * @brief Saves the current solution for later use + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + */ +void fclaw_patch_save_step(struct fclaw_global* glob, + struct fclaw_patch* this_patch); + +/** + * @brief Sets up interpolated values for a patch + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] alpha the alpha value, with 0 being the last time step and 1 being the current time step + */ +void fclaw_patch_setup_timeinterp(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + double alpha); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Ghost Filling +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Copies ghost data from a face-neighboring grid on the same level + * + * @param[in] glob the global context + * @param[in,out] this_patch this patch context + * @param[in] neighbor_patch the neighbor patch context + * @param[in] iface the interface that the neighbor patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +void fclaw_patch_copy_face(struct fclaw_global* glob, + struct fclaw_patch *this_patch, + struct fclaw_patch *neighbor_patch, + int iface, + int time_interp, + struct fclaw_patch_transform_data *transform_data); + +/** + * @brief Averages values from a face-neighboring fine grid + * + * @param[in] glob the global context + * @param[in,out] coarse_patch this patch context + * @param[in] fine_patch the fine patch context + * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] + * @param[in] ifaced_coarse the interface of the fine neighbor patch + * @param[in] num_neighbors the number of neighbors + * @param[in] refine_factor the refinement factor (number of neighbors) + * @param[in] refratio the refinement ratio + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] igrid the index of the fine neighbor in the child array + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +void fclaw_patch_average_face(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int idir, + int iface_coarse, + int refine_factor, + int refratio, + int time_interp, + int igrid, + struct fclaw_patch_transform_data* transform_data); + +/** + * @brief Interpolates values from a face-neighboring coarse grid + * + * @param[in] glob the global context + * @param[in] coarse_patch this patch context + * @param[in,out] fine_patch the fine patch context + * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] + * @param[in] ifaced_coarse the interface of the fine neighbor patch + * @param[in] num_neighbors the number of neighbors + * @param[in] refine_factor the refinement factor (number of neighbors) + * @param[in] refratio the refinement ratio + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] igrid the index of the fine neighbor in the child array + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +void fclaw_patch_interpolate_face(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int idir, + int iside, + int RefineFactor, + int refratio, + int time_interp, + int igrid, + struct fclaw_patch_transform_data* transform_data); + +/** + * @brief Copies values from a edge-neighboring grid + * + * @param[in] glob the global context + * @param[in,out] this_patch this patch context + * @param[in] neighbor_patch the neighbor patch context + * @param[in] this_blockno the block number of this patch + * @param[in] neighbor_blockno the block number of the neighbor patch + * @param[in] is_block_corner true if corner is on the corner of a block + * @param[in] iedge the edge that the neighboring patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +void fclaw_patch_copy_edge(struct fclaw_global* glob, + struct fclaw_patch *this_patch, + struct fclaw_patch *neighbor_patch, + int this_blockno, + int neighbor_blockno, + int iedge, + int time_interp, + struct fclaw_patch_transform_data *transform_data); + +/** + * @brief Averages values from a edge-neighboring fine grid + * + * @param[in] glob the global context + * @param[in,out] coarse_patch the coarse patch context + * @param[in] fine_patch the fine patch context + * @param[in] iedge_coarse the edge of the coarse patch that the fine patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +void fclaw_patch_average_edge(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int iedge_coarse, + int time_interp, + struct fclaw_patch_transform_data* transform_data); + +/** + * @brief Interpolates values from a edge-neighboring coarse grid + * + * @param[in] glob the global context + * @param[in] coarse_patch the coarse patch context + * @param[in,out] fine_patch the fine patch context + * @param[in] iedge the edge of the coarse patch that the fine patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +void fclaw_patch_interpolate_edge(struct fclaw_global* glob, + struct fclaw_patch* coarse_patch, + struct fclaw_patch* fine_patch, + int iedge, + int time_interp, + struct fclaw_patch_transform_data* transform_data); + + + +/** + * @brief Copies values from a corner-neighboring grid + * + * @param[in] glob the global context + * @param[in,out] this_patch this patch context + * @param[in] neighbor_patch the neighbor patch context + * @param[in] this_blockno the block number of this patch + * @param[in] neighbor_blockno the block number of the neighbor patch + * @param[in] is_block_corner true if corner is on the corner of a block + * @param[in] icorner the corner that the neighboring patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +void fclaw_patch_copy_corner(struct fclaw_global* glob, + struct fclaw_patch *this_patch, + struct fclaw_patch *neighbor_patch, + int this_blockno, + int neighbor_blockno, + int is_block_corner, + int icorner, + int time_interp, + struct fclaw_patch_transform_data *transform_data); + +/** + * @brief Averages values from a corner-neighboring fine grid + * + * @param[in] glob the global context + * @param[in,out] coarse_patch the coarse patch context + * @param[in] fine_patch the fine patch context + * @param[in] coarse_blockno the block number of the coarse patch + * @param[in] fine_blockno the block number of the fine patch + * @param[in] is_block_corner true if corner is on the corner of a block + * @param[in] icorner the corner of the coarse patch that the fine patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +void fclaw_patch_average_corner(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int coarse_blockno, + int fine_blockno, + int is_block_corner, + int coarse_corner, + int time_interp, + struct fclaw_patch_transform_data* transform_data); + +/** + * @brief Interpolates values from a corner-neighboring coarse grid + * + * @param[in] glob the global context + * @param[in] coarse_patch the coarse patch context + * @param[in,out] fine_patch the fine patch context + * @param[in] coarse_blockno the block number of the coarse patch + * @param[in] fine_blockno the block number of the fine patch + * @param[in] is_block_corner true if corner is on the corner of a block + * @param[in] icorner the corner of the coarse patch that the fine patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +void fclaw_patch_interpolate_corner(struct fclaw_global* glob, + struct fclaw_patch* coarse_patch, + struct fclaw_patch* fine_patch, + int coarse_blockno, + int fine_blockno, + int is_block_corner, + int coarse_corner, + int time_interp, + struct fclaw_patch_transform_data* transform_data); + +///@} + +/* ------------------------------------------------------------------------------------ */ +/// @name Transform Functions +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Initialize the transform data for a patch + * + * @param[in] glob the global context + * @param[in] patch the patch context + * @param[in] blockno the block number, -1 if ghost patch + * @param[in] patchno the patch number + * @param[in,out] tdata the stransform data structure + */ +void fclaw_patch_transform_init_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + int blockno, int patchno, + struct fclaw_patch_transform_data *tdata); + +/** + * @brief Get the transform on a block face + * + * @param[in] glob the global context + * @param[in] faceno + * @param[in] rfaceno + * @param[out] ftransform This array holds 9 integers. + * [0,2] The coordinate axis sequence of the origin face, + * the first referring to the tangential and the second + * to the normal. A permutation of (0, 1). + * [3,5] The coordinate axis sequence of the target face. + * [6,8] Edge reversal flag for tangential axis (boolean); + * face code in [0, 3] for the normal coordinate q: + * 0: q' = -q + * 1: q' = q + 1 + * 2: q' = q - 1 + * 3: q' = 2 - q + * [8] & 4: Both patches are in the same block, + * the \a ftransform contents are ignored. + * [1,4,7] 0 (unused for compatibility with 3D).ftransform + */ +void fclaw_patch_transform_blockface(struct fclaw_global* glob, + int faceno, int rfaceno, + int ftransform[]); + +/** + * @brief Get the transform for within a block (the identity transform) + * + * @param[in] glob the global context + * @param[out] ftransform This array holds 9 integers. + * [0,2] The coordinate axis sequence of the origin face, + * the first referring to the tangential and the second + * to the normal. A permutation of (0, 1). + * [3,5] The coordinate axis sequence of the target face. + * [6,8] Edge reversal flag for tangential axis (boolean); + * face code in [0, 3] for the normal coordinate q: + * 0: q' = -q + * 1: q' = q + 1 + * 2: q' = q - 1 + * 3: q' = 2 - q + * [8] & 4: Both patches are in the same block, + * the \a ftransform contents are ignored. + * [1,4,7] 0 (unused for compatibility with 3D).ftransform + */ +void fclaw_patch_transform_blockface_intra(struct fclaw_global* glob, + int ftransform[]); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Regridding Functions +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Tag a patch for refinement + * + * @param[in] glob the global context + * @param[in] this_patch the patch context + * @param[in] this_blockno the block number + * @param[in] this_patchno the patch number + * @param[in] initflag true if in init phase + * @return true if patch should be refined + */ +int fclaw_patch_tag4refinement(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, int patchno, + int initflag); + +/** + * @brief Tag a patch for coarsening + * + * @param[in] glob the global context + * @param[in] this_patch the patch context + * @param[in] this_blockno the block number + * @param[in] this_patchno the patch number + * @param[in] initflag true if in init phase + * @return true if patch should be coarsened + */ +int fclaw_patch_tag4coarsening(struct fclaw_global *glob, + struct fclaw_patch *fine_patches, + int blockno, + int patchno, + int initflag); + +/** + * @brief Interpolates a set of patches from a coarse patch + * + * @param[in] glob the global context + * @param[in] coarse_patch the coarse patch context + * @param[in,out] fine_patches the fine patch contexts + * @param[in] blockno the block number + * @param[in] coarse_patchno the patch number of the coarse patch + * @param[in] fine0_patchno the patch number of the first fine patch + */ +void fclaw_patch_interpolate2fine(struct fclaw_global *glob, + struct fclaw_patch* coarse_patch, + struct fclaw_patch* fine_patches, + int this_blockno, int coarse_patchno, + int fine0_patchno); + +/** + * @brief Averages from a set of fine patches to a coarse patch + * + * @param[in] glob the global context + * @param[in] fine_patches the fine patch contexts + * @param[in,out] coarse_patch the coarse patch context + * @param[in] blockno the block number + * @param[in] fine_patchno the patch number of the first fine patch + * @param[in] coarse_patchno the patch number of the coarse patch + */ +void fclaw_patch_average2coarse(struct fclaw_global *glob, + struct fclaw_patch *fine_patches, + struct fclaw_patch *coarse_patch, + int blockno, int fine0_patchno, + int coarse_patchno); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Parallel Ghost Patches +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Get the buffer size needed to pack a single patch's ghost data + * + * @param[in] glob the global context + * @return the buffer size (in bytes) + */ +size_t fclaw_patch_ghost_packsize(struct fclaw_global* glob); + +/** + * @brief Allocates a buffer for the patch ghost data + * + * @param[in] glob the global context + * @param[out] q pointer to the allocated buffer + */ +void fclaw_patch_local_ghost_alloc(struct fclaw_global* glob, + void** q); + +/** + * @brief Frees a buffer for the patch ghost data + * + * @param[in] glob the global context + * @param[out] q pointer to the buffer to free + */ +void fclaw_patch_local_ghost_free(struct fclaw_global* glob, + void **q); + +/** + * @brief Packs the patch ghost data into a buffer + * + * @param[in] glob the global context + * @param[in] this_patch the patch context + * @param[in,out] patch_data the buffer + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + */ +void fclaw_patch_local_ghost_pack(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + void *patch_data, + int time_interp); + +/** + * @brief Builds a new ghost patch + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in] build_mode the build mode + */ +void fclaw_patch_remote_ghost_build(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + fclaw_build_mode_t build_mode); + +/** + * @brief Unpacks a ghost patch from a buffer + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in] qdata the buffer to unpack from + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + */ +void fclaw_patch_remote_ghost_unpack(struct fclaw_global* glob, + struct fclaw_patch* this_patch, + int blockno, int patchno, + void *qdata, int time_interp); + + +/** + * @brief Frees memory used by a ghost patch + * + * @param[in] glob the global context + * @param[in,out] ghost_patch the patch context + */ +void fclaw_patch_remote_ghost_delete(struct fclaw_global *glob, + struct fclaw_patch *ghost_patch); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Parallel Partitioning +/* ------------------------------------------------------------------------------------ */ +///@{ + + +/** + * @brief Packs a patch into a buffer + * + * @param[in] glob the global context + * @param[in] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[out] pack_data_here the buffer + */ +void fclaw_patch_partition_pack(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + void *pack_data_here); + +/** + * @brief Unpacks a patch from a buffer + * + * @param[in] glob the global context (contains the old domain) + * @param[in] new_domain the new domain + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in] packed_data the buffer + */ +void fclaw_patch_partition_unpack(struct fclaw_global *glob, + struct fclaw_domain *new_domain, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + void *packed_data); + +/** + * @brief Gets the buffer size (in bytes) needed to pack a patch + * + * @param[in] glob the global context + * @return size_t the size of buffer needed + */ +size_t fclaw_patch_partition_packsize(struct fclaw_global* glob); + + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Time Syncing Functions +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Adds fine grid corrections to coarse grid. + * + * @param[in] glob the global context + * @param[in,out] coarse_patch the coarse patch context + * @param[in] fine_patch the fine patch context + * @param[in] coarse_blockno the block number of the coarse patch + * @param[in] fine_blockno the block number of the fine patch + * @param[in] coarse_patchno the patch number of the coarse patch + * @param[in] idir the direction of the interface 0 for bottom/top + * 1 for left/right + * @param[in] igrid the index of the fine grid in the child array + * @param[in] iface_coarse the interface on the coarse patch + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] transform_data the transform for the neighbor's coordinates + */ +void fclaw_patch_time_sync_f2c(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int coarse_blockno, int fine_blockno, + int coarse_patchno, + int idir, + int igrid, + int iface_coarse, + int time_interp, + struct fclaw_patch_transform_data* transform_data); + +/** + * @brief Adds corrections to patches that are at the same levle and are at block boundaries. + * + * @param[in] glob the global context + * @param[in,out] this_patch this patch + * @param[in] neighbor_patch the neighbor patch + * @param[in] this_iface the interface that the neighbor patch is on + * @param[in] idir the direction of the interface 0 for bottom/top + * 1 for left/right + * @param[in] transform_data the transform for the neighbor's coordinates + */ +void fclaw_patch_time_sync_samesize(struct fclaw_global* glob, + struct fclaw_patch *this_patch, + struct fclaw_patch *neighbor_patch, + int this_iface, int idir, + struct fclaw_patch_transform_data *transform_data); + +/** + * @brief Resets conservation data + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] coarse_level the the level of the coarse patch + * @param[in] reset_mode the reset mode ::fclaw2d_time_sync_type + */ +void fclaw_patch_time_sync_reset(struct fclaw_global* glob, + struct fclaw_patch* this_patch, + int coarse_level, + int reset_mode); + + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Creating/Deleting Patches (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Allocates a new patch + * + * @return the newly allocated patch + */ +typedef void* (*fclaw_patch_new_t)(); + +/** + * @brief Deallocates a patch + * + * @param[in] user_patch the patch to deallocate + */ +typedef void (*fclaw_patch_delete_t)(void *user_patch); + +/** + * @brief Initializes the data members of a patch + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno patch number + * @param[in,out] user user data pointer + */ +typedef void (*fclaw_patch_build_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + void *user); + +/** + * @brief Initializes a new coarser patch from a set of finer patches + * + * @param[in] glob the global context + * @param[in] fine_patches the fine patch contexts + * @param[in,out] coarse_patches the coarse patch context + * @param[in] blockno the block number + * @param[in] coarse_patchno coarse patch number + * @param[in] fine0_patchno first fine patch number + * @param[in] build_mode the build mode + */ +typedef void (*fclaw_patch_build_from_fine_t)(struct fclaw_global *glob, + struct fclaw_patch *fine_patches, + struct fclaw_patch *coarse_patch, + int blockno, + int coarse_patchno, + int fine0_patchno, + fclaw_build_mode_t build_mode); + +/** + * @brief Performs additional setup for a patch + * + * @param[in] the global context + * @param[in,out] the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + */ +typedef void (*fclaw_patch_setup_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int patchno, + int blockno); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Solver Specific Functions (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Initializes values in arrays of patch + * + * @param[in] the global context + * @param[in,out] the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + */ +typedef void (*fclaw_patch_initialize_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno); + +/** + * @brief Initializes boundary conditions + * + * @param[in] the global context + * @param[in,out] the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in] t the the current time + * @param[in] dt the size of time step + * @param[in] intersects_bc array of values for each face, true if boundary on face is + * a physical boundary + * @param[in] time_interp the patch number + */ +typedef void (*fclaw_patch_physical_bc_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + double t, + double dt, + int *intersects_bc, + int time_interp); + +/** + * @brief Advances a patch using a single explicit time step. + * + * @param[in] the global context + * @param[in,out] the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in] t the the current time + * @param[in] dt the size of time step + * @param[in,out] buffer_data pointer to the ::fclaw2d_single_step_buffer_data struct + * (used in cudaclaw) + * @return the maxcfl + */ +typedef double (*fclaw_patch_single_step_update_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + double t, + double dt, + void *user); + + +/** + * @brief Sets the right hand side for a patch + * + * @param[in] glob the global context + * @param[in,out] patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + */ +typedef void (*fclaw_patch_rhs_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, + int blockno, + int patchno); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Time Stepping (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** @copydoc fclaw2d_patch_setup_timeinterp() */ +typedef void (*fclaw_patch_setup_timeinterp_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + double alpha); + +/** @copydoc fclaw2d_patch_restore_step() */ +typedef void (*fclaw_patch_restore_step_t)(struct fclaw_global *glob, + struct fclaw_patch* this_patch); + +/** @copydoc fclaw2d_patch_save_step() */ +typedef void (*fclaw_patch_save_step_t)(struct fclaw_global *glob, + struct fclaw_patch* this_patch); + + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Ghost Filling (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Copies ghost data from a face-neighboring grid on the same level + * + * @param[in] glob the global context + * @param[in,out] this_patch this patch context + * @param[in] neighbor_patch the neighbor patch context + * @param[in] iface the interface that the neighbor patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +typedef void (*fclaw_patch_copy_face_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, + struct fclaw_patch *neighbor_patch, + int iface, + int time_interp, + struct fclaw_patch_transform_data + *transform_data); + +/** + * @brief Averages values from a face-neighboring fine grid + * + * @param[in] glob the global context + * @param[in,out] coarse_patch this patch context + * @param[in] fine_patch the fine patch context + * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] + * @param[in] ifaced_coarse the interface of the fine neighbor patch + * @param[in] num_neighbors the number of neighbors + * @param[in] refine_factor the refinement factor (number of neighbors) + * @param[in] refratio the refinement ratio + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] igrid the index of the fine neighbor in the child array + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +typedef void (*fclaw_patch_average_face_t)(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int idir, + int iface_coarse, + int refine_factor, + int refratio, + int time_interp, + int igrid, + struct fclaw_patch_transform_data + *transform_data); + +/** + * @brief Interpolates values from a face-neighboring coarse grid + * + * @param[in] glob the global context + * @param[in] coarse_patch this patch context + * @param[in,out] fine_patch the fine patch context + * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] + * @param[in] ifaced_coarse the interface of the fine neighbor patch + * @param[in] num_neighbors the number of neighbors + * @param[in] refine_factor the refinement factor (number of neighbors) + * @param[in] refratio the refinement ratio + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] igrid the index of the fine neighbor in the child array + * @param[in] manifold true if using mainifold + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +typedef void (*fclaw_patch_interpolate_face_t)(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int idir, + int iside, + int refine_factor, + int refratio, + int time_interp, + int igrid, + struct fclaw_patch_transform_data + *transform_data); + +/** + * @brief Copies values from a edge-neighboring grid + * + * @param[in] glob the global context + * @param[in,out] this_patch this patch context + * @param[in] neighbor_patch the neighbor patch context + * @param[in] this_blockno the block number of this patch + * @param[in] neighbor_blockno the block number of the neighbor patch + * @param[in] iedge the edge that the neighboring patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +typedef void (*fclaw_patch_copy_edge_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, + struct fclaw_patch *neighbor_patch, + int this_blockno, + int neighbor_blockno, + int iedge, + int time_interp, + struct fclaw_patch_transform_data + *transform_data); + +/** + * @brief Averages values from a edge-neighboring fine grid + * + * @param[in] glob the global context + * @param[in,out] coarse_patch the coarse patch context + * @param[in] fine_patch the fine patch context + * @param[in] icorner the corner of the coarse patch that the fine patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +typedef void (*fclaw_patch_average_edge_t)(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int icorner, + int time_interp, + struct fclaw_patch_transform_data + *transform_data); + +/** + * @brief Interpolates values from a edge-neighboring coarse grid + * + * @param[in] glob the global context + * @param[in] coarse_patch the coarse patch context + * @param[in,out] fine_patch the fine patch context + * @param[in] iedge the edge of the coarse patch that the fine patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +typedef void (*fclaw_patch_interpolate_edge_t)(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int iedge, + int time_interp, + struct fclaw_patch_transform_data + *transform_data); + + +/** + * @brief Copies values from a corner-neighboring grid + * + * @param[in] glob the global context + * @param[in,out] this_patch this patch context + * @param[in] neighbor_patch the neighbor patch context + * @param[in] this_blockno the block number of this patch + * @param[in] neighbor_blockno the block number of the neighbor patch + * @param[in] icorner the corner that the neighboring patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +typedef void (*fclaw_patch_copy_corner_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, + struct fclaw_patch *neighbor_patch, + int this_blockno, + int neighbor_blockno, + int icorner, + int time_interp, + struct fclaw_patch_transform_data + *transform_data); + +/** + * @brief Averages values from a corner-neighboring fine grid + * + * @param[in] glob the global context + * @param[in,out] coarse_patch the coarse patch context + * @param[in] fine_patch the fine patch context + * @param[in] coarse_blockno the block number of the coarse patch + * @param[in] fine_blockno the block number of the fine patch + * @param[in] icorner the corner of the coarse patch that the fine patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +typedef void (*fclaw_patch_average_corner_t)(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int coarse_blockno, + int fine_blockno, + int icorner, + int time_interp, + struct fclaw_patch_transform_data + *transform_data); + +/** + * @brief Interpolates values from a corner-neighboring coarse grid + * + * @param[in] glob the global context + * @param[in] coarse_patch the coarse patch context + * @param[in,out] fine_patch the fine patch context + * @param[in] coarse_blockno the block number of the coarse patch + * @param[in] fine_blockno the block number of the fine patch + * @param[in] icorner the corner of the coarse patch that the fine patch is on + * @param[in] time_interp true if ghost filling for time interpolated level (non-global update) + * @param[in] tranform_data the tranform data for the neighbor's coordinate system + */ +typedef void (*fclaw_patch_interpolate_corner_t)(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int coarse_blockno, + int fine_blockno, + int icorner, + int time_interp, + struct fclaw_patch_transform_data + *transform_data); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Transform Functions (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Initialize the transform data for a patch + * + * @param[in] glob the global context + * @param[in] patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in,out] tdata the stransform data structure + */ +typedef void (*fclaw_patch_transform_init_data_t)(struct fclaw_global* glob, + struct fclaw_patch* patch, + int blockno, int patchno, + struct fclaw_patch_transform_data *tdata); + +/** + * @brief Gets the transform on a block face + * + * @param[in] faceno + * @param[in] rfaceno + * @param[out] ftransform This array holds 9 integers. + * [0,2] The coordinate axis sequence of the origin face, + * the first referring to the tangential and the second + * to the normal. A permutation of (0, 1). + * [3,5] The coordinate axis sequence of the target face. + * [6,8] Edge reversal flag for tangential axis (boolean); + * face code in [0, 3] for the normal coordinate q: + * 0: q' = -q + * 1: q' = q + 1 + * 2: q' = q - 1 + * 3: q' = 2 - q + * [8] & 4: Both patches are in the same block, + * the \a ftransform contents are ignored. + * [1,4,7] 0 (unused for compatibility with 3D).ftransform + */ +typedef void (*fclaw_patch_transform_blockface_t)(int faceno, int rfaceno, + int ftransform[]); + +/** + * @brief Gets the transform for within a block (the identity transform) + * + * @param[out] ftransform This array holds 9 integers. + * [0,2] The coordinate axis sequence of the origin face, + * the first referring to the tangential and the second + * to the normal. A permutation of (0, 1). + * [3,5] The coordinate axis sequence of the target face. + * [6,8] Edge reversal flag for tangential axis (boolean); + * face code in [0, 3] for the normal coordinate q: + * 0: q' = -q + * 1: q' = q + 1 + * 2: q' = q - 1 + * 3: q' = 2 - q + * [8] & 4: Both patches are in the same block, + * the \a ftransform contents are ignored. + * [1,4,7] 0 (unused for compatibility with 3D).ftransform + */ +typedef void (*fclaw_patch_transform_blockface_intra_t)(int ftransform[]); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Regridding Functions (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Tags a patch for refinement + * + * @param[in] glob the global context + * @param[in] this_patch the patch context + * @param[in] this_blockno the block number + * @param[in] this_patchno the patch number + * @param[in] initflag true if in init phase + * @return true if patch should be refined + */ +typedef int (*fclaw_patch_tag4refinement_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int this_blockno, int this_patchno, + int initflag); + +/** + * @brief Tags a patch for coarsening + * + * @param[in] glob the global context + * @param[in] this_patch the patch context + * @param[in] this_blockno the block number + * @param[in] this_patchno the patch number + * @param[in] initflag true if in init phase + * @return true if patch should be coarsened + */ +typedef int (*fclaw_patch_tag4coarsening_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int this_blockno, + int this_patchno, + int initflag); + +/** + * @brief Interpolates a set of patches from a coarse patch + * + * @param[in] glob the global context + * @param[in] coarse_patch the coarse patch context + * @param[in,out] fine_patches the fine patch contexts + * @param[in] blockno the block number + * @param[in] coarse_patchno the patch number of the coarse patch + * @param[in] fine_patchno the patch number of the first fine patch + */ +typedef void (*fclaw_patch_interpolate2fine_t)(struct fclaw_global *glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch* fine_patches, + int blockno, int coarse_patchno, + int fine_patchno); +/** + * @brief Averages from a set of fine patches to a coarse patch + * + * @param[in] glob the global context + * @param[in] fine_patches the fine patch contexts + * @param[in,out] coarse_patch the coarse patch context + * @param[in] blockno the block number + * @param[in] fine_patchno the patch number of the first fine patch + * @param[in] coarse_patchno the patch number of the coarse patch + */ +typedef void (*fclaw_patch_average2coarse_t)(struct fclaw_global *glob, + struct fclaw_patch *fine_patches, + struct fclaw_patch *coarse_patch, + int blockno, int fine_patchno, + int coarse_patchno); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Parallel Ghost Patches (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** @copydoc fclaw2d_patch_ghost_packsize() */ +typedef size_t (*fclaw_patch_ghost_packsize_t)(struct fclaw_global* glob); + +/** @copydoc fclaw2d_patch_local_ghost_pack() */ +typedef void (*fclaw_patch_local_ghost_pack_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + void *patch_data, + int time_interp); + +/** @copydoc fclaw2d_patch_local_ghost_alloc() */ +typedef void (*fclaw_patch_local_ghost_alloc_t)(struct fclaw_global* glob, + void** q); + +/** @copydoc fclaw2d_patch_local_ghost_free() */ +typedef void (*fclaw_patch_local_ghost_free_t)(struct fclaw_global* glob, + void **q); + + +/** @copydoc fclaw2d_patch_remote_ghost_build() */ +typedef void (*fclaw_patch_remote_ghost_build_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + fclaw_build_mode_t build_mode); + +/** + * @brief Performs additional setup step after build + * + * @param[in] glob the global context + * @param[in,out] this_patch the patch context + * @param[in] blockno the block number + * @param[in] blockno the patch number + */ +typedef void (*fclaw_patch_remote_ghost_setup_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno); + + +/** @copydoc fclaw2d_patch_remote_ghost_unpack() */ +typedef void (*fclaw_patch_remote_ghost_unpack_t)(struct fclaw_global *glob, + struct fclaw_patch* this_patch, + int blockno, int patchno, + void *qdata, int time_interp); + +/** @copydoc fclaw2d_patch_remote_ghost_delete() */ +typedef void (*fclaw_patch_remote_ghost_delete_t)(void *user_patch); + + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Partitioning (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** @copydoc fclaw2d_patch_partition_packsize() */ +typedef size_t (*fclaw_patch_partition_packsize_t)(struct fclaw_global* glob); + + +/** @copydoc fclaw2d_patch_partition_pack() */ +typedef void (*fclaw_patch_partition_pack_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + void *pack_data_here); + +/** @copydoc fclaw2d_patch_partition_unpack() */ +typedef void (*fclaw_patch_partition_unpack_t)(struct fclaw_global *glob, + struct fclaw_domain *new_domain, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + void *unpack_data_from_here); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Conservative Updates (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + + +/** @copydoc fclaw2d_patch_time_sync_f2c() */ +typedef void (*fclaw_patch_time_sync_f2c_t)(struct fclaw_global* glob, + struct fclaw_patch *coarse_patch, + struct fclaw_patch *fine_patch, + int coarse_blockno, int fine_blockno, + int coarse_patchno, + int idir, + int igrid, + int iface_coarse, + int time_interp, + struct fclaw_patch_transform_data + *transform_data); + +/** @copydoc fclaw2d_patch_time_sync_samesize() */ +typedef void (*fclaw_patch_time_sync_samesize_t)(struct fclaw_global* glob, + struct fclaw_patch* this_patch, + struct fclaw_patch* neighbor_patch, + int this_iface, int idir, + struct fclaw_patch_transform_data + *transform_data); + +/** @copydoc fclaw2d_patch_time_sync_reset() */ +typedef void (*fclaw_patch_time_sync_reset_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, + int coarse_level, + int reset_mode); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name User Data Functions (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Creates user data + * + * @param[in] glob the global context + * @param[in,out] patch the patch context + */ +typedef void (*fclaw_patch_create_user_data_t)(struct fclaw_global *glob, + struct fclaw_patch *patch); + +/** + * @brief Destroys user data + * + * @param[in] glob the global context + * @param[in,out] patch the patch context + */ +typedef void (*fclaw_patch_destroy_user_data_t)(struct fclaw_global* glob, + struct fclaw_patch* patch); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Access Functions (typedefs) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Returns the corresponding metric patch + * + * @param[in] patch the patch context + */ +typedef void* (*fclaw_patch_metric_patch_t)(struct fclaw_patch *patch); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Virtual Table +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** vtable for patch level routines */ +struct fclaw_patch_vtable +{ + /** @{ @name Creating/Deleting/Building */ + + /** @copybrief ::fclaw_patch_new_t */ + fclaw_patch_new_t patch_new; + /** @copybrief ::fclaw_patch_delete_t */ + fclaw_patch_delete_t patch_delete; + /** @copybrief ::fclaw_patch_build_t */ + fclaw_patch_build_t build; + /** @copybrief ::fclaw_patch_build_from_fine_t */ + fclaw_patch_build_from_fine_t build_from_fine; + /** @copybrief ::fclaw_patch_setup_t */ + fclaw_patch_setup_t setup; + + /** @} */ + + /** @copybrief ::fclaw2d_patch_metric_patch_t */ + fclaw_patch_metric_patch_t metric_patch; + + /** @{ @name User Data */ + + /** @copybrief ::fclaw_patch_create_user_data_t */ + fclaw_patch_create_user_data_t create_user_data; + /** @copybrief ::fclaw_patch_destroy_user_data_t */ + fclaw_patch_destroy_user_data_t destroy_user_data; + + /** @} */ + + /** @{ @name Solver Functions */ + + /** @copybrief ::fclaw_patch_initialize_t */ + fclaw_patch_initialize_t initialize; + /** @copybrief ::fclaw_patch_physical_bc_t */ + fclaw_patch_physical_bc_t physical_bc; + /** @copybrief ::fclaw_patch_single_step_update_t */ + fclaw_patch_single_step_update_t single_step_update; + /** @copybrief ::fclaw_patch_rhs_t */ + fclaw_patch_rhs_t rhs; + + /** @} */ + + /** @{ @name Time Stepping */ + + /** @copybrief ::fclaw_patch_restore_step_t */ + fclaw_patch_restore_step_t restore_step; + /** @copybrief ::fclaw_patch_save_step_t */ + fclaw_patch_save_step_t save_step; + /** @copybrief ::fclaw_patch_setup_timeinterp_t */ + fclaw_patch_setup_timeinterp_t setup_timeinterp; + + /** @} */ + + /** @{ @name Regridding Functions */ + + /** @copybrief ::fclaw_patch_tag4refinement_t */ + fclaw_patch_tag4refinement_t tag4refinement; + /** @copybrief ::fclaw_patch_tag4coarsening_t */ + fclaw_patch_tag4coarsening_t tag4coarsening; + /** @copybrief ::fclaw_patch_average2coarse_t */ + fclaw_patch_average2coarse_t average2coarse; + /** @copybrief ::fclaw_patch_interpolate2fine_t */ + fclaw_patch_interpolate2fine_t interpolate2fine; + + /** @} */ + + /** @{ @name Time Syncing Functions for Conservation */ + + /** @copybrief ::fclaw_patch_time_sync_f2c_t */ + fclaw_patch_time_sync_f2c_t time_sync_f2c; + /** @copybrief ::fclaw_patch_time_sync_samesize_t */ + fclaw_patch_time_sync_samesize_t time_sync_samesize; + /** @copybrief ::fclaw_patch_time_sync_reset_t */ + fclaw_patch_time_sync_reset_t time_sync_reset; + + /** @} */ + + + /** @{ @name Face Ghost Filling Functions */ + + /** @copybrief ::fclaw_patch_copy_face_t */ + fclaw_patch_copy_face_t copy_face; + /** @copybrief ::fclaw_patch_average_face_t */ + fclaw_patch_average_face_t average_face; + /** @copybrief ::fclaw_patch_interpolate_face_t */ + fclaw_patch_interpolate_face_t interpolate_face; + + /** @} */ + + /** @{ @name Edge Ghost Filling Functions */ + + /** @copybrief ::fclaw_patch_copy_edge_t */ + fclaw_patch_copy_edge_t copy_edge; + /** @copybrief ::fclaw_patch_average_edge_t */ + fclaw_patch_average_edge_t average_edge; + /** @copybrief ::fclaw_patch_average_edge_t */ + fclaw_patch_interpolate_edge_t interpolate_edge; + + /** @} */ + /** @{ @name Block Face and Interior Corner Ghost Filling Functions */ + + /** @copybrief ::fclaw_patch_copy_corner_t */ + fclaw_patch_copy_corner_t copy_corner; + /** @copybrief ::fclaw_patch_average_corner_t */ + fclaw_patch_average_corner_t average_corner; + /** @copybrief ::fclaw_patch_interpolate_corner_t */ + fclaw_patch_interpolate_corner_t interpolate_corner; + + /** @} */ + + /** @{ @name Block Corner Ghost Filling Functions */ + + /** @copybrief ::fclaw_patch_copy_corner_t */ + fclaw_patch_copy_corner_t copy_block_corner; + /** @copybrief ::fclaw_patch_average_corner_t */ + fclaw_patch_average_corner_t average_block_corner; + /** @copybrief ::fclaw_patch_interpolate_corner_t */ + fclaw_patch_interpolate_corner_t interpolate_block_corner; + + /** @} */ + + /** @{ @name Transform Functions */ + + /** @copybrief ::fclaw_patch_transform_init_data_t */ + fclaw_patch_transform_init_data_t transform_init_data; + /** @copybrief ::fclaw_patch_transform_blockface_t */ + fclaw_patch_transform_blockface_t transform_face; + /** @copybrief ::fclaw_patch_transform_blockface_intra_t */ + fclaw_patch_transform_blockface_intra_t transform_face_intra; + + /** @} */ + + /** @{ @name Ghost Packing Functions (for parallel use) */ + + /** @copybrief ::fclaw_patch_ghost_packsize_t */ + fclaw_patch_ghost_packsize_t ghost_packsize; + /** @copybrief ::fclaw_patch_local_ghost_pack_t */ + fclaw_patch_local_ghost_pack_t local_ghost_pack; + /** @copybrief ::fclaw_patch_local_ghost_alloc_t */ + fclaw_patch_local_ghost_alloc_t local_ghost_alloc; + /** @copybrief ::fclaw_patch_local_ghost_free_t */ + fclaw_patch_local_ghost_free_t local_ghost_free; + + /** @copybrief ::fclaw_patch_remote_ghost_build_t */ + fclaw_patch_remote_ghost_build_t remote_ghost_build; + /** @copybrief ::fclaw_patch_remote_ghost_setup_t */ + fclaw_patch_remote_ghost_setup_t remote_ghost_setup; + /** @copybrief ::fclaw_patch_remote_ghost_unpack_t */ + fclaw_patch_remote_ghost_unpack_t remote_ghost_unpack; + /** @copybrief ::fclaw_patch_remote_ghost_delete_t */ + fclaw_patch_remote_ghost_delete_t remote_ghost_delete; + + /** @} */ + + /** @{ @name Parallel Load Balancing (partitioning) */ + + /** @copybrief ::fclaw_patch_partition_pack_t */ + fclaw_patch_partition_pack_t partition_pack; + /** @copybrief ::fclaw_patch_partition_unpack_t */ + fclaw_patch_partition_unpack_t partition_unpack; + /** @copybrief ::fclaw_patch_partition_packsize_t */ + fclaw_patch_partition_packsize_t partition_packsize; + + /** @} */ + + /** True if vtable has been set */ + int is_set; +}; + +/** + * @brief Get the patch vtable + * + * @param glob the global context + * @return fclaw2d_patch_vtable_t* the vtable + */ +fclaw_patch_vtable_t* fclaw_patch_vt(struct fclaw_global* glob); + +/** + * @brief Initialize the patch vtable + * + * @param glob the global context + */ +void fclaw_patch_vtable_initialize(struct fclaw_global* glob); + + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Misc Access Functions +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Get the global_num, local_num, and level of a patch + * + * @param[in] domain + * @param[in] patch + * @param[in] blockno + * @param[in] patchno + * @param[out] global_num the global patch number + * @param[out] local_num the local patch number + * @param[out] level the level that the patch is on + */ +void fclaw_patch_get_info(struct fclaw_domain * domain, + struct fclaw_patch * patch, + int blockno, int patchno, + int *global_num, int* local_num, + int *level); + +/** + * @brief Get the block number, patch number, global_num, and level of a patch + * + * @param[in] domain the domain + * @param[in] this_patch the patch context + * @param[out] blockno the block number + * @param[out] patchno the patch number + * @param[out] global_num the global patch number + * @param[out] level the level + */ +/* I don't completely trust this routine */ +void fclaw_patch_get_info2(struct fclaw_domain * domain, + struct fclaw_patch * this_patch, + int *blockno, int *patchno, + int *global_num, int *level); +/** + * @brief Get the user patch pointer + * + * @param patch the patch context + * @return void* the pointer + */ +void* fclaw_patch_get_user_patch(struct fclaw_patch* patch); + +/** + * @brief Get the patch data + * + * @param patch the patch context + * @return struct fclaw2d_patch_data* pointer to the patch data + */ +struct fclaw_patch_data* fclaw_patch_get_patch_data(struct fclaw_patch* patch); + +/** + * @brief Get the user data pointer + * + * @param glob the global context + * @param this_patch the patch context + * @return void* the user data pointer + */ +void* fclaw_patch_get_user_data(struct fclaw_global* glob, + struct fclaw_patch* this_patch); + + +/** + * @brief Get the metric patch + * + * @param glob the global context + * @param patch the patch context + * @return void* pointer to the metric patch + */ +void* fclaw_patch_metric_patch(struct fclaw_global* glob, + struct fclaw_patch *patch); + +/** + * @brief Get the block number + * + * @param this_patch the patch context + * @return int the block number + */ +int fclaw_patch_get_blockno(struct fclaw_patch* this_patch); + +/** + * @brief Get the patch number + * + * @param this_patch the patch context + * @return int the patch number + */ +int fclaw_patch_get_patchno(struct fclaw_patch* this_patch); + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Misc User Data +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Get the user data pointer of a patch + * + * @param glob the global context + * @param this_patch the patch context + * @return void* the user data pointer + */ +void* fclaw_patch_user_data(struct fclaw_global* glob, + struct fclaw_patch* this_patch); + +/** + * @brief Set the user data pointer of a patch + * + * @param glob the global context + * @param this_patch the patch context + * @param user the user data pointer + */ +void fclaw_patch_set_user_data(struct fclaw_global* glob, + struct fclaw_patch* this_patch, + void* user); + + +///@} +/* ------------------------------------------------------------------------------------ */ +/// @name Misc Functions (mostly internal) +/* ------------------------------------------------------------------------------------ */ +///@{ + +/** + * @brief Returns true if patch lies on a parallel boundary + * + * @param patch the patch context + * @return int true if on parallel boundary + */ +int fclaw_patch_on_parallel_boundary (const struct fclaw_patch * patch); + + +/** + * @brief Set the face type for a patch + * + * @param patch the patch context + * @param iface the interface + * @param face_type the face type + */ +void fclaw_patch_set_face_type(struct fclaw_patch *patch, int iface, + fclaw_patch_relation_t face_type); + +/** + * @brief Set the edge type for a patch + * + * @param patch the patch context + * @param iedge the edge + * @param edge_type the edge type + */ +void fclaw_patch_set_edge_type(fclaw_patch_t *patch,int iedge, + fclaw_patch_relation_t edge_type); + + +/** + * @brief Set the corner type for a patch + * + * @param patch the patch context + * @param icorner the corner + * @param corner_type the corner type + */ +void fclaw_patch_set_corner_type(struct fclaw_patch *patch, int icorner, + fclaw_patch_relation_t corner_type); + +/** + * @brief Set the missing corner of a patch + * + * @param patch the patch context + * @param icorner the missing corner + */ +void fclaw_patch_set_missing_corner(struct fclaw_patch *patch, int icorner); + +/** + * @brief Get the face type of a patch + * + * @param patch the patch context + * @param iface the face + * @return fclaw_patch_relation_t the face type + */ +fclaw_patch_relation_t fclaw_patch_get_face_type(struct fclaw_patch* patch, + int iface); +/** + * @brief Get the edge type of a patch + * + * @param patch the patch context + * @param iface the edge + * @return fclaw3d_patch_relation_t the edge type + */ +fclaw_patch_relation_t fclaw_patch_get_edge_type(fclaw_patch_t* patch, + int iedge); +/** + * @brief Get the corner type of a patch + * + * @param patch the patch context + * @param icorner the corner + * @return fclaw_patch_relation_t the patch relation + */ +fclaw_patch_relation_t fclaw_patch_get_corner_type(struct fclaw_patch* patch, + int icorner); + +/** + * @brief Returns true if a corner is missing + * + * @param patch the patch context + * @param icorner the corner + * @return int true if a corner is missing + */ +int fclaw_patch_corner_is_missing(struct fclaw_patch* patch, + int icorner); + +/** + * @brief Set the neighbor relation data for a patch + * + * @param patch the patch context + */ +void fclaw_patch_neighbors_set(fclaw_patch_t* patch); + +/** + * @brief Reset the neighbor relation data for a patch + * + * @param patch the patch context + */ +void fclaw_patch_neighbors_reset(struct fclaw_patch* patch); + +/** + * @brief Returns true if the patch neighbor information is set + * + * @param patch the patch context + * @return int true if the patch neighbor information is set + */ +int fclaw_patch_neighbor_type_set(struct fclaw_patch* patch); + +/** + * @brief Returns true if a patch has finer neighbors + * + * @param patch the patch context + * @return int true if the patch has finer neighbors + */ +int fclaw_patch_has_finegrid_neighbors(struct fclaw_patch *patch); + +/** + * @brief Returns true if the patch is on a coarse fine interface + * + * @param patch the patch context + * @return int true if the patch is on a coarse fine interface + */ +int fclaw_patch_on_coarsefine_interface(struct fclaw_patch *patch); + +/** + * @brief Get the block corner count array for a patch + * + * @param glob the global context + * @param this_patch the patch context + * @return int* the array with the block corner count (the number of blocks that meet) for each corner + */ +int* fclaw_patch_block_corner_count(struct fclaw_global *glob, + struct fclaw_patch* this_patch); + +/** + * @brief Set the block corner count for a corner + * + * @param glob the global context + * @param this_patch the patch context + * @param icorner the corner to set + * @param block_corner_count the block corner count (the number of blocks that meet) + */ +void fclaw_patch_set_block_corner_count(struct fclaw_global *glob, + struct fclaw_patch* this_patch, + int icorner, int block_corner_count); + +/** + * @brief Set that this patch has been considered for refinement + * + * @param glob the global context + * @param patch the patch context + */ +void fclaw_patch_considered_for_refinement_set(struct fclaw_global *glob, + struct fclaw_patch* patch); +/** + * @brief Clear the flag that this patch has been considered for refinement + * + * @param glob the global context + * @param patch the patch context + */ +void fclaw_patch_considered_for_refinement_clear(struct fclaw_global *glob, + struct fclaw_patch* patch); + +/** + * @brief Returns true if a patch has been considered for refinement + * + * @param glob the global context + * @param patch the patch context + * @return int true if a patch has been considered for refinement + */ +int fclaw_patch_considered_for_refinement(struct fclaw_global *glob, + struct fclaw_patch* patch); +/** + * @brief returns true if all patches have been considered for refinement in the domain + * + * This is a collective call. + * + * @param glob the global context + */ +int fclaw_patch_all_considered_for_refinement(struct fclaw_global *glob); + +/** + * @brief Clear the considered for refinement flag for all patches + * + * @param glob the global context + */ +void fclaw_patch_clear_all_considered_for_refinement(struct fclaw_global *glob); + +///@} -typedef struct fclaw_patch +#ifdef __cplusplus +#if 0 { - union - { - /* avoid including dimension-specific files */ - struct fclaw2d_patch_data *pd2; - struct fclaw3d_patch_data *pd3; - } - pd; - - /* Those below are currently also in pd2, pd3. - Shall be removed from pd2, pd3. */ - fclaw_patch_user_t pu; +#endif } -fclaw_patch_t; +#endif -#endif /* !FCLAW_PATCH_H */ +#endif diff --git a/src/fclaw_patch.h.TEST.cpp b/src/fclaw_patch.h.TEST.cpp new file mode 100644 index 000000000..4d6e51494 --- /dev/null +++ b/src/fclaw_patch.h.TEST.cpp @@ -0,0 +1,71 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include + +TEST_CASE("fclaw_patch_vtable_initialize stores two seperate vtables in two seperate globs") +{ + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_patch_vtable_initialize(glob1); + fclaw_patch_vtable_initialize(glob2); + + CHECK_NE(fclaw_patch_vt(glob1), fclaw_patch_vt(glob2)); + + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +TEST_CASE("fclaw_patch_vtable_initialize sets is_set flag") +{ + fclaw_global_t* glob = fclaw_global_new(); + + fclaw_patch_vtable_initialize(glob); + + CHECK_UNARY(fclaw_patch_vt(glob)->is_set); + + fclaw_global_destroy(glob); +} + +#ifdef FCLAW_ENABLE_DEBUG + +TEST_CASE("fclaw_patch_vtable_initialize fails if called twice on a glob") +{ + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_patch_vtable_initialize(glob1); + CHECK_SC_ABORTED(fclaw_patch_vtable_initialize(glob1)); + fclaw_patch_vtable_initialize(glob2); + CHECK_SC_ABORTED(fclaw_patch_vtable_initialize(glob2)); + + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +#endif \ No newline at end of file diff --git a/src/fclaw2d_physical_bc.c b/src/fclaw_physical_bc.c similarity index 74% rename from src/fclaw2d_physical_bc.c rename to src/fclaw_physical_bc.c index 2200c04ed..0ff97cb79 100644 --- a/src/fclaw2d_physical_bc.c +++ b/src/fclaw_physical_bc.c @@ -23,16 +23,14 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include +#include +#include +#include -#include -#include -#include - -void fclaw2d_physical_bc_default(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw_physical_bc_default(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -43,19 +41,19 @@ void fclaw2d_physical_bc_default(fclaw2d_global_t *glob, /* This can be used when no BCs are to be called */ } -void cb_fclaw2d_physical_set_bc(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_fclaw_physical_set_bc(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; - fclaw2d_physical_time_info_t *t_info; + fclaw_physical_time_info_t *t_info; - t_info = (fclaw2d_physical_time_info_t*) s->user; + t_info = (fclaw_physical_time_info_t*) s->user; - int intersects_bc[FCLAW2D_NUMFACES]; + int intersects_bc[fclaw_domain_num_faces(domain)]; /* Time dt should not be passed in here. If BCs are obtained by evolving an ODE, then we should really evolve the ODE at the same time @@ -64,8 +62,8 @@ void cb_fclaw2d_physical_set_bc(fclaw2d_domain_t *domain, could mess up the BC evolution. */ double dt = 1e20; /* Signals that not a good idea to use dt in this context */ - fclaw2d_physical_get_bc(s->glob,this_block_idx,this_patch_idx,intersects_bc); - fclaw2d_patch_physical_bc(s->glob, + fclaw_physical_get_bc(s->glob,this_block_idx,this_patch_idx,intersects_bc); + fclaw_patch_physical_bc(s->glob, this_patch, this_block_idx, this_patch_idx, @@ -76,16 +74,16 @@ void cb_fclaw2d_physical_set_bc(fclaw2d_domain_t *domain, } /* This is needed by other routines, so we don't set it to static. */ -void fclaw2d_physical_get_bc(fclaw2d_global_t *glob, +void fclaw_physical_get_bc(fclaw_global_t *glob, int this_block_idx, int this_patch_idx, int *intersects_bdry) { - // const int numfaces = get_faces_per_patch(domain); - int bdry[FCLAW2D_NUMFACES]; - fclaw2d_patch_boundary_type(glob->domain,this_block_idx,this_patch_idx,bdry); + const int num_faces = fclaw_domain_num_faces(glob->domain); + int bdry[num_faces]; //overallocate for 3d + fclaw_patch_boundary_type(glob->domain,this_block_idx,this_patch_idx,bdry); int i; - for(i = 0; i < FCLAW2D_NUMFACES; i++) + for(i = 0; i < num_faces; i++) { // Physical boundary conditions intersects_bdry[i] = bdry[i] == 1; @@ -97,15 +95,15 @@ void fclaw2d_physical_get_bc(fclaw2d_global_t *glob, Public interface : Set physical boundary conditions on a patch ----------------------------------------------------------------------------- */ -void fclaw2d_physical_set_bc(fclaw2d_global_t *glob, +void fclaw_physical_set_bc(fclaw_global_t *glob, int level, double sync_time, int time_interp) { - fclaw2d_physical_time_info_t t_info; + fclaw_physical_time_info_t t_info; t_info.level_time = sync_time; t_info.time_interp = time_interp; - fclaw2d_global_iterate_level(glob, level, - cb_fclaw2d_physical_set_bc, + fclaw_global_iterate_level(glob, level, + cb_fclaw_physical_set_bc, (void *) &t_info); } diff --git a/src/fclaw2d_physical_bc.h b/src/fclaw_physical_bc.h similarity index 80% rename from src/fclaw2d_physical_bc.h rename to src/fclaw_physical_bc.h index 8179927ba..39af438e8 100644 --- a/src/fclaw2d_physical_bc.h +++ b/src/fclaw_physical_bc.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_PHYSICAL_BC_H -#define FCLAW2D_PHYSICAL_BC_H +#ifndef FCLAW_PHYSICAL_BC_H +#define FCLAW_PHYSICAL_BC_H #ifdef __cplusplus extern "C" @@ -34,39 +34,39 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_domain; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_domain; +struct fclaw_patch; -typedef struct fclaw2d_physical_time_info +typedef struct fclaw_physical_time_info { double level_time; double dt; int time_interp; -} fclaw2d_physical_time_info_t; +} fclaw_physical_time_info_t; -void cb_fclaw2d_physical_set_bc(struct fclaw2d_domain *domain, - struct fclaw2d_patch *this_patch, +void cb_fclaw_physical_set_bc(struct fclaw_domain *domain, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, void *user); /* This is needed by other routines, so we don't set it to static. */ -void fclaw2d_physical_get_bc(struct fclaw2d_global *glob, +void fclaw_physical_get_bc(struct fclaw_global *glob, int this_block_idx, int this_patch_idx, int *intersects_bdry); -void fclaw2d_physical_set_bc(struct fclaw2d_global *glob, +void fclaw_physical_set_bc(struct fclaw_global *glob, int level, double level_time, int time_interp); -void fclaw2d_physical_bc_default(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fclaw_physical_bc_default(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/fclaw_pointer_map.h b/src/fclaw_pointer_map.h index 87b43115b..dd77fb822 100644 --- a/src/fclaw_pointer_map.h +++ b/src/fclaw_pointer_map.h @@ -29,8 +29,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief c interface to c++ std::map * */ -#ifndef FCLAW_POINTER_MAP -#define FCLAW_POINTER_MAP +#ifndef FCLAW_POINTER_MAP_H +#define FCLAW_POINTER_MAP_H #ifdef __cplusplus extern "C" diff --git a/src/fclaw2d_rays.c b/src/fclaw_rays.c similarity index 79% rename from src/fclaw2d_rays.c rename to src/fclaw_rays.c index 1b6fb5065..14c04edb2 100644 --- a/src/fclaw2d_rays.c +++ b/src/fclaw_rays.c @@ -23,12 +23,12 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "fclaw2d_rays.h" -#include "fclaw2d_global.h" -#include "fclaw2d_options.h" -#include "fclaw2d_diagnostics.h" +#include +#include +#include +#include -#include "fclaw2d_convenience.h" +#include #include @@ -41,7 +41,7 @@ typedef struct fclaw2d_ray_acc int num_rays; //sc_array_t *rays; //sc_array_t *integrals; - fclaw2d_ray_t *rays; + fclaw_ray_t *rays; } fclaw2d_ray_acc_t; @@ -50,22 +50,22 @@ typedef struct fclaw2d_ray_acc /* Do I need this level of indirection? */ static -void ray_allocate_and_define(fclaw2d_global_t* glob, - fclaw2d_ray_t **rays, +void ray_allocate_and_define(fclaw_global_t* glob, + fclaw_ray_t **rays, int *num_rays) { - const fclaw2d_ray_vtable_t* ray_vt = fclaw2d_ray_vt(glob); + const fclaw_ray_vtable_t* ray_vt = fclaw_ray_vt(glob); FCLAW_ASSERT(ray_vt->allocate_and_define != NULL); ray_vt->allocate_and_define(glob, rays, num_rays); } static -void ray_deallocate(fclaw2d_global_t* glob, - fclaw2d_ray_t **rays, +void ray_deallocate(fclaw_global_t* glob, + fclaw_ray_t **rays, int *num_rays) { - const fclaw2d_ray_vtable_t* ray_vt = fclaw2d_ray_vt(glob); + const fclaw_ray_vtable_t* ray_vt = fclaw_ray_vt(glob); FCLAW_ASSERT(ray_vt->deallocate != NULL); ray_vt->deallocate(glob, rays, num_rays); @@ -73,13 +73,13 @@ void ray_deallocate(fclaw2d_global_t* glob, static -void ray_initialize(fclaw2d_global_t* glob, void** acc) +void ray_initialize(fclaw_global_t* glob, void** acc) { fclaw2d_ray_acc_t *ray_acc = FCLAW_ALLOC(fclaw2d_ray_acc_t,1); /* Check to see if user wants ray output */ int i, num_rays; - const fclaw_options_t * fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t * fclaw_opt = fclaw_get_options(glob); if (!fclaw_opt->output_rays) { num_rays = 0; @@ -94,10 +94,10 @@ void ray_initialize(fclaw2d_global_t* glob, void** acc) ray_allocate_and_define(glob, &ray_acc->rays, &num_rays); /* We initialize untrustworthy to 0 */ - fclaw2d_ray_t *rays = ray_acc->rays; + fclaw_ray_t *rays = ray_acc->rays; for (i =0; i < num_rays; i++) { - fclaw2d_ray_t *ray = &rays[i]; + fclaw_ray_t *ray = &rays[i]; ray->untrustworthy = 0; } } @@ -126,7 +126,7 @@ void ray_initialize(fclaw2d_global_t* glob, void** acc) } static -void ray_reset(fclaw2d_global_t *glob, void*acc) +void ray_reset(fclaw_global_t *glob, void*acc) { fclaw2d_ray_acc_t* ray_acc = (fclaw2d_ray_acc_t*) acc; @@ -138,8 +138,8 @@ void ray_reset(fclaw2d_global_t *glob, void*acc) /* We reset untrustworthy to 0 */ int i, num_rays; - fclaw2d_ray_t *ray; - fclaw2d_ray_t *rays = ray_acc->rays; + fclaw_ray_t *ray; + fclaw_ray_t *rays = ray_acc->rays; num_rays = ray_acc->num_rays; for (i =0; i < num_rays; i++) { @@ -150,7 +150,7 @@ void ray_reset(fclaw2d_global_t *glob, void*acc) static -void ray_integrate(fclaw2d_global_t *glob, void *acc) +void ray_integrate(fclaw_global_t *glob, void *acc) { fclaw2d_ray_acc_t* ray_acc = (fclaw2d_ray_acc_t*) acc; @@ -163,13 +163,13 @@ void ray_integrate(fclaw2d_global_t *glob, void *acc) /* Copy arrays stored in accumulator to an sc_array */ int i, num_rays; double intval; - fclaw2d_ray_t *ray, *fclaw_ray; - sc_array_t *sc_rays = sc_array_new (sizeof (fclaw2d_ray_t)); + fclaw_ray_t *ray, *fclaw_ray; + sc_array_t *sc_rays = sc_array_new (sizeof (fclaw_ray_t)); num_rays = ray_acc->num_rays; for(i = 0; i < num_rays; i++) { /* Add one ray to sc_rays; return newly pushed array */ - fclaw_ray = (fclaw2d_ray_t *) sc_array_push (sc_rays); + fclaw_ray = (fclaw_ray_t *) sc_array_push (sc_rays); /* Set data for ray */ fclaw_ray->num = ray_acc->rays[i].num; @@ -179,20 +179,20 @@ void ray_integrate(fclaw2d_global_t *glob, void *acc) sc_array_t *integrals = sc_array_new_count (sizeof (double), num_rays); - const fclaw2d_ray_vtable_t* ray_vt = fclaw2d_ray_vt(glob); + const fclaw_ray_vtable_t* ray_vt = fclaw_ray_vt(glob); /* This does a compute and a gather. */ - fclaw2d_domain_integrate_rays(glob->domain, ray_vt->integrate, + fclaw_domain_integrate_rays(glob->domain, ray_vt->integrate, sc_rays, integrals, glob); /* Copy integral value back to fclaw2d_ray_t */ - fclaw2d_ray_t *rays = ray_acc->rays; + fclaw_ray_t *rays = ray_acc->rays; for(i = 0; i < num_rays; i++) { /* Return values from integrals */ intval = *((double*) sc_array_index_int(integrals,i)); - fclaw_ray = (fclaw2d_ray_t*)sc_array_index_int(sc_rays, i); + fclaw_ray = (fclaw_ray_t*)sc_array_index_int(sc_rays, i); /* Update rays stored in accumulator so we can report values later */ ray = &rays[i]; @@ -205,7 +205,7 @@ void ray_integrate(fclaw2d_global_t *glob, void *acc) } static -void ray_gather(fclaw2d_global_t *glob, void* acc, int init_flag) +void ray_gather(fclaw_global_t *glob, void* acc, int init_flag) { /* Here is where we would do an all-reduce, but again this is handled by fclaw2d_convenience routines */ @@ -219,9 +219,9 @@ void ray_gather(fclaw2d_global_t *glob, void* acc, int init_flag) /* we check if the rays yielded trustworthy results on all processes */ int i, *local_untrustworthy, *global_untrustworthy; - fclaw2d_ray_t *ray; + fclaw_ray_t *ray; int num_rays = ray_acc->num_rays; - fclaw2d_ray_t *rays = ray_acc->rays; + fclaw_ray_t *rays = ray_acc->rays; local_untrustworthy = FCLAW_ALLOC (int, num_rays); for (i = 0; i < num_rays; i++) @@ -253,7 +253,7 @@ void ray_gather(fclaw2d_global_t *glob, void* acc, int init_flag) static -void ray_finalize(fclaw2d_global_t *glob, void** acc) +void ray_finalize(fclaw_global_t *glob, void** acc) { fclaw2d_ray_acc_t* ray_acc = *((fclaw2d_ray_acc_t**) acc); if (ray_acc->rays != NULL) @@ -274,9 +274,9 @@ void ray_finalize(fclaw2d_global_t *glob, void** acc) /* ---------------------------------- Virtual table ---------------------------------- */ static -fclaw2d_ray_vtable_t* fclaw2d_ray_vt_new() +fclaw_ray_vtable_t* fclaw2d_ray_vt_new() { - return (fclaw2d_ray_vtable_t*) FCLAW_ALLOC_ZERO (fclaw2d_ray_vtable_t, 1); + return (fclaw_ray_vtable_t*) FCLAW_ALLOC_ZERO (fclaw_ray_vtable_t, 1); } static @@ -300,16 +300,16 @@ fclaw2d_ray_vtable_t* fclaw2d_ray_vt() } #endif -void fclaw2d_ray_vtable_initialize(fclaw2d_global_t *glob) +void fclaw_ray_vtable_initialize(fclaw_global_t *glob) { - fclaw2d_diagnostics_vtable_t * diag_vt = fclaw2d_diagnostics_vt(glob); + fclaw_diagnostics_vtable_t * diag_vt = fclaw_diagnostics_vt(glob); diag_vt->ray_init_diagnostics = ray_initialize; diag_vt->ray_compute_diagnostics = ray_integrate; diag_vt->ray_gather_diagnostics = ray_gather; diag_vt->ray_reset_diagnostics = ray_reset; diag_vt->ray_finalize_diagnostics = ray_finalize; - fclaw2d_ray_vtable_t* rays_vt = fclaw2d_ray_vt_new(); + fclaw_ray_vtable_t* rays_vt = fclaw2d_ray_vt_new(); FCLAW_ASSERT(fclaw_pointer_map_get(glob->vtables,"fclaw2d_rays") == NULL); fclaw_pointer_map_insert(glob->vtables, "fclaw2d_rays", rays_vt, fclaw2d_ray_vt_destroy); @@ -321,9 +321,9 @@ void fclaw2d_ray_vtable_initialize(fclaw2d_global_t *glob) /* ---------------------------- Get Access Functions ---------------------------------- */ -fclaw2d_ray_vtable_t* fclaw2d_ray_vt(fclaw2d_global_t* glob) +fclaw_ray_vtable_t* fclaw_ray_vt(fclaw_global_t* glob) { - fclaw2d_ray_vtable_t* ray_vt = (fclaw2d_ray_vtable_t*) + fclaw_ray_vtable_t* ray_vt = (fclaw_ray_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fclaw2d_rays"); FCLAW_ASSERT(ray_vt != NULL); FCLAW_ASSERT(ray_vt->is_set != 0); @@ -331,13 +331,13 @@ fclaw2d_ray_vtable_t* fclaw2d_ray_vt(fclaw2d_global_t* glob) } -fclaw2d_ray_t* fclaw2d_ray_allocate_rays(int num_rays) +fclaw_ray_t* fclaw_ray_allocate_rays(int num_rays) { - fclaw2d_ray_t* rays = FCLAW_ALLOC(fclaw2d_ray_t,num_rays); + fclaw_ray_t* rays = FCLAW_ALLOC(fclaw_ray_t,num_rays); return rays; } -int fclaw2d_ray_deallocate_rays(fclaw2d_ray_t **rays) +int fclaw_ray_deallocate_rays(fclaw_ray_t **rays) { FCLAW_ASSERT(*rays != NULL); FCLAW_FREE(*rays); @@ -347,7 +347,7 @@ int fclaw2d_ray_deallocate_rays(fclaw2d_ray_t **rays) /* Routines that operate on a single array */ -void fclaw2d_ray_set_ray(fclaw2d_ray_t *r, +void fclaw_ray_set_ray(fclaw_ray_t *r, int id, void* user_ray){ /* User calls this to set ray data */ @@ -357,7 +357,7 @@ void fclaw2d_ray_set_ray(fclaw2d_ray_t *r, -void* fclaw2d_ray_get_ray(fclaw2d_ray_t *r, +void* fclaw_ray_get_ray(fclaw_ray_t *r, int *id) { *id = r->num; diff --git a/src/fclaw2d_rays.h b/src/fclaw_rays.h similarity index 71% rename from src/fclaw2d_rays.h rename to src/fclaw_rays.h index 4d658f556..201ff5b9c 100644 --- a/src/fclaw2d_rays.h +++ b/src/fclaw_rays.h @@ -23,10 +23,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_INTEGRATE_H -#define FCLAW2D_INTEGRATE_H +#ifndef FCLAW_RAYS_H +#define FCLAW_RAYS_H -#include "fclaw2d_convenience.h" /* Needed for def. of fclaw2d_integrate_t */ +#include /* Needed for def. of fclaw2d_integrate_t */ #ifdef __cplusplus extern "C" @@ -37,32 +37,32 @@ extern "C" /* fix syntax highlighting */ #endif -struct fclaw2d_global; -struct fclaw2d_domain; +struct fclaw_global; +struct fclaw_domain; -typedef struct fclaw2d_ray_vtable fclaw2d_ray_vtable_t; +typedef struct fclaw_ray_vtable fclaw_ray_vtable_t; -struct fclaw2d_global; +struct fclaw_global; /* This is a polynmorphic type */ -typedef struct fclaw2d_ray +typedef struct fclaw_ray { int num; /* User defined ID */ void* ray_data; /* User defined */ double integral; /**< scalar integral value lives here */ int untrustworthy; /**< set to nonzero if integration result may be inaccurate */ -} fclaw2d_ray_t; +} fclaw_ray_t; -typedef void (*fclaw2d_ray_allocate_and_define_t)(struct fclaw2d_global *glob, - fclaw2d_ray_t **rays, +typedef void (*fclaw_ray_allocate_and_define_t)(struct fclaw_global *glob, + fclaw_ray_t **rays, int *num); -typedef void (*fclaw2d_ray_deallocate_t)(struct fclaw2d_global *glob, - fclaw2d_ray_t **rays, +typedef void (*fclaw_ray_deallocate_t)(struct fclaw_global *glob, + fclaw_ray_t **rays, int *num); @@ -94,12 +94,12 @@ typedef void (*fclaw2d_ray_destroy_buffer_data_t)(struct fclaw2d_global *glob, #endif -struct fclaw2d_ray_vtable +struct fclaw_ray_vtable { - fclaw2d_ray_allocate_and_define_t allocate_and_define; - fclaw2d_ray_deallocate_t deallocate; + fclaw_ray_allocate_and_define_t allocate_and_define; + fclaw_ray_deallocate_t deallocate; - fclaw2d_integrate_ray_t integrate; /* Function that does the integration */ + fclaw_integrate_ray_t integrate; /* Function that does the integration */ #if 0 fclaw2d_ray_create_files_t create_ray_files; fclaw2d_ray_update_t update_ray; @@ -111,28 +111,28 @@ struct fclaw2d_ray_vtable }; -void fclaw2d_ray_allocate_and_define(struct fclaw2d_global* glob, - fclaw2d_ray_t **rays, +void fclaw_ray_allocate_and_define(struct fclaw_global* glob, + fclaw_ray_t **rays, int *num_rays); -void fclaw2d_ray_deallocate(struct fclaw2d_global* glob, - fclaw2d_ray_t **rays, +void fclaw_ray_deallocate(struct fclaw_global* glob, + fclaw_ray_t **rays, int *num_rays); -void fclaw2d_ray_set_ray(fclaw2d_ray_t *r, +void fclaw_ray_set_ray(fclaw_ray_t *r, int id, void* ray_data); -void* fclaw2d_ray_get_ray(fclaw2d_ray_t *r, +void* fclaw_ray_get_ray(fclaw_ray_t *r, int *id); -fclaw2d_ray_vtable_t* fclaw2d_ray_vt(struct fclaw2d_global *glob); +fclaw_ray_vtable_t* fclaw_ray_vt(struct fclaw_global *glob); -void fclaw2d_ray_vtable_initialize(struct fclaw2d_global *glob); +void fclaw_ray_vtable_initialize(struct fclaw_global *glob); -fclaw2d_ray_t* fclaw2d_ray_allocate_rays(int num_rays); +fclaw_ray_t* fclaw_ray_allocate_rays(int num_rays); -int fclaw2d_ray_deallocate_rays(fclaw2d_ray_t **rays); +int fclaw_ray_deallocate_rays(fclaw_ray_t **rays); #endif diff --git a/src/fclaw_regrid.c b/src/fclaw_regrid.c new file mode 100644 index 000000000..6a008c489 --- /dev/null +++ b/src/fclaw_regrid.c @@ -0,0 +1,470 @@ +/* +Copyright (c) 2012 Carsten Burstedde, Donna Calhoun +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include + +#include /* p4est domain, patch handling routines */ +#include /* Needed for patch_relation_t data */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +/* This is also called from fclaw2d_initialize, so is not made static */ +void cb_fclaw_regrid_tag4refinement(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, + int this_block_idx, + int this_patch_idx, + void *user) +{ + int refine_patch, maxlevel, level; + const fclaw_options_t* fclaw_opt; + + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*) user; + fclaw_tag4f_user_t *tag_user = ((fclaw_tag4f_user_t*) g->user); + + fclaw_opt = fclaw_get_options(g->glob); + + maxlevel = fclaw_opt->maxlevel; + level = this_patch->level; + + if(!tag_user->domain_init && fclaw_patch_considered_for_refinement(g->glob, this_patch)) + { + return; + } + + if(tag_user->num_patches_to_refine > 0 + && tag_user->num_patches_refined == tag_user->num_patches_to_refine) + { + return; + } + + fclaw_patch_considered_for_refinement_set(g->glob, this_patch); + + if (level < maxlevel) + { + refine_patch = + fclaw_patch_tag4refinement(g->glob,this_patch,this_block_idx, + this_patch_idx, tag_user->domain_init); + if (refine_patch == 1) + { + tag_user->num_patches_refined++; + fclaw_patch_mark_refine(domain, this_block_idx, this_patch_idx); + } + } +} + +/* Tag family for coarsening */ + +void cb_regrid_tag4coarsening(fclaw_domain_t *domain, + fclaw_patch_t *fine_patches, + int blockno, int fine0_patchno, + void *user) +{ + const fclaw_options_t* fclaw_opt; + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*) user; + + fclaw_opt = fclaw_get_options(g->glob); + int domain_init = *((int*) g->user); + + int minlevel = fclaw_opt->minlevel; + + int level = fine_patches[0].level; + + if (level > minlevel) + { + int family_coarsened = 1; + family_coarsened = fclaw_patch_tag4coarsening(g->glob,&fine_patches[0], + blockno, fine0_patchno, + domain_init); + if (family_coarsened == 1) + { + int igrid; + for (igrid = 0; igrid < fclaw_domain_num_siblings(domain); igrid++) + { + int fine_patchno = fine0_patchno + igrid; + fclaw_patch_mark_coarsen(domain,blockno, fine_patchno); + } + } + } +} + + +/* ---------------------------------------------------------------- + Public interface + -------------------------------------------------------------- */ + +void cb_fclaw_regrid_repopulate(fclaw_domain_t * old_domain, + fclaw_patch_t * old_patch, + fclaw_domain_t * new_domain, + fclaw_patch_t * new_patch, + fclaw_patch_relation_t newsize, + int blockno, + int old_patchno, + int new_patchno, + void *user) +{ + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*) user; + int domain_init = *((int*) g->user); + + fclaw_build_mode_t build_mode = FCLAW_BUILD_FOR_UPDATE; + + if (newsize == FCLAW_PATCH_SAMESIZE) + { + FCLAW_ASSERT(0 <= blockno && blockno < new_domain->num_blocks); + FCLAW_ASSERT(0 <= new_patchno && new_patchno < new_domain->local_num_patches); + new_patch->user = old_patch->user; + old_patch->user = NULL; + ++old_domain->count_delete_patch; + ++new_domain->count_set_patch; + } + else if (newsize == FCLAW_PATCH_HALFSIZE) + { + fclaw_patch_t *fine_siblings = new_patch; + fclaw_patch_t *coarse_patch = old_patch; + + int i; + for (i = 0; i < fclaw_domain_num_siblings(old_domain); i++) + { + fclaw_patch_t *fine_patch = &fine_siblings[i]; + int fine_patchno = new_patchno + i; + /* Reason for the following two lines: the glob contains the old domain which is incremented in ddata_old + but we really want to increment the new domain. This will be fixed! */ + --old_domain->count_set_patch; + ++new_domain->count_set_patch; + + fclaw_patch_build(g->glob,fine_patch,blockno, + fine_patchno,(void*) &build_mode); + if (domain_init) + { + fclaw_patch_initialize(g->glob,fine_patch,blockno,fine_patchno);//new_domain + } + /* don't try to refine this patch in the next round of refinement */ + fclaw_patch_considered_for_refinement_set(g->glob, fine_patch); + } + + if (!domain_init) + { + int coarse_patchno = old_patchno; + int fine_patchno = new_patchno; + + fclaw_patch_interpolate2fine(g->glob,coarse_patch,fine_siblings, + blockno,coarse_patchno,fine_patchno);//new_domain + } + /* used to pass in old_domain */ + fclaw_patch_data_delete(g->glob,coarse_patch); + } + else if (newsize == FCLAW_PATCH_DOUBLESIZE) + { + +#if 0 + if (domain_init) + { + /* We now do coarsening at the initial refinement */ + fclaw_debugf("fclaw2d_regrid.cpp (repopulate): We shouldn't end up here\n"); + exit(0); + } +#endif + + /* Old grids are the finer grids; new grid is the coarsened grid */ + fclaw_patch_t *fine_siblings = old_patch; + int fine_patchno = old_patchno; + + fclaw_patch_t *coarse_patch = new_patch; + int coarse_patchno = new_patchno; + + /* Reason for the following two lines: the glob contains the old domain which is incremented in ddata_old + but we really want to increment the new domain. This will be fixed! */ + --old_domain->count_set_patch; + ++new_domain->count_set_patch; + + if (domain_init) + { + fclaw_patch_build(g->glob,coarse_patch,blockno, + coarse_patchno,(void*) &build_mode); + fclaw_patch_initialize(g->glob,coarse_patch,blockno,coarse_patchno); + } + else + { + /* Area (and possibly other things) should be averaged to coarse grid. */ + fclaw_patch_build_from_fine(g->glob,fine_siblings,coarse_patch, + blockno,coarse_patchno,fine_patchno, + build_mode); + /* Average the solution. Does this need to be customizable? */ + fclaw_patch_average2coarse(g->glob,fine_siblings,coarse_patch, + blockno,fine_patchno,coarse_patchno); + + } + int i; + for(i = 0; i < fclaw_domain_num_siblings(old_domain); i++) + { + fclaw_patch_t* fine_patch = &fine_siblings[i]; + /* used to pass in old_domain */ + fclaw_patch_data_delete(g->glob,fine_patch); + } + /* don't try to refine this patch in the next round of refinement */ + fclaw_patch_considered_for_refinement_set(g->glob, coarse_patch); + } + else + { + fclaw_global_essentialf("cb_adapt_domain : newsize not recognized\n"); + exit(1); + } + fclaw_patch_neighbors_reset(new_patch); +} + +/* ---------------------------------------------------------------- + Public interface + -------------------------------------------------------------- */ +void fclaw_regrid(fclaw_global_t *glob) +{ + fclaw_domain_t** domain = &glob->domain; + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + + fclaw_patch_clear_all_considered_for_refinement(glob); + int tagged4coarsening = 0; + int all_patches_considered = 0; + int has_been_refined = 0; + while(!all_patches_considered) + { + fclaw_timer_start (&glob->timers[FCLAW_TIMER_REGRID]); + + fclaw_global_infof("Regridding domain\n"); + + fclaw_timer_start (&glob->timers[FCLAW_TIMER_REGRID_TAGGING]); + /* First determine which families should be coarsened. */ + int domain_init = 0; + if(!tagged4coarsening) + { + fclaw_global_iterate_families(glob, cb_regrid_tag4coarsening, + (void *) &domain_init); + tagged4coarsening = 1; + } + + fclaw_tag4f_user_t refine_user; + refine_user.domain_init = domain_init; + refine_user.num_patches_refined = 0; + if(fclaw_opt->max_refinement_ratio == 1.0) + { + refine_user.num_patches_to_refine = 0; + } + else + { + double num_patches_to_refine = fclaw_opt->max_refinement_ratio * (*domain)->local_num_patches; + refine_user.num_patches_to_refine = (int) ceil(num_patches_to_refine); + } + + fclaw_global_iterate_patches(glob, cb_fclaw_regrid_tag4refinement, + (void *) &refine_user); + + fclaw_infof("Regrid : num_patches_refined = %d\n",refine_user.num_patches_refined); + + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_REGRID_TAGGING]); + + /* Rebuild domain if necessary */ + /* Will return be NULL if no refining was done */ + + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_REGRID]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_ADAPT_COMM]); + fclaw_domain_t *new_domain = fclaw_domain_adapt(*domain); + + int have_new_refinement = new_domain != NULL; + + if (have_new_refinement) + { + has_been_refined = 1; + /* allocate memory for user patch data and user domain data in the new + domain; copy data from the old to new the domain. */ + fclaw_domain_setup(glob, new_domain); + } + + /* Stop the new timer (copied from old timer) */ + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_ADAPT_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_REGRID]); + + if (have_new_refinement) + { + fclaw_global_infof(" -- Have new refinement\n"); + + /* Average to new coarse grids and interpolate to new fine grids */ + fclaw_timer_start (&glob->timers[FCLAW_TIMER_REGRID_BUILD]); + fclaw_global_iterate_adapted(glob, new_domain, + cb_fclaw_regrid_repopulate, + (void *) &domain_init); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_REGRID_BUILD]); + + /* free memory associated with old domain */ + fclaw_domain_reset(glob); + *domain = new_domain; + new_domain = NULL; + + /* Repartition for load balancing. Second arg (mode) for vtk output */ + fclaw_partition_domain(glob,FCLAW_TIMER_REGRID); + + /* Set up ghost patches. Communication happens for indirect ghost exchanges. */ + + + /* This includes timers for building patches and (exclusive) communication */ + fclaw_exchange_setup(glob,FCLAW_TIMER_REGRID); + + /* Get new neighbor information. This is used to short circuit + ghost filling procedures in some cases */ + fclaw_regrid_set_neighbor_types(glob); + + /* Update ghost cells. This is needed because we have new coarse or fine + patches without valid ghost cells. Time_interp = 0, since we only + only regrid when all levels are time synchronized. */ + int minlevel = (*domain)->global_minlevel; + int maxlevel = (*domain)->global_maxlevel; + int time_interp = 0; + double sync_time = glob->curr_time; + fclaw_ghost_update(glob, + minlevel, + maxlevel, + sync_time, + time_interp, + FCLAW_TIMER_REGRID); + + ++glob->count_amr_new_domain; + } + else + { + /* We updated all the ghost cells when leaving advance, so don't need to do + it here */ + } + all_patches_considered = fclaw_patch_all_considered_for_refinement(glob); + if(!all_patches_considered) + { + fclaw_global_productionf("Max number of patches to refine reached. Repartitioning and continuing refinement.\n"); + } + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_REGRID]); + } + + fclaw_timer_start (&glob->timers[FCLAW_TIMER_REGRID]); + /* User defined */ + fclaw_after_regrid(glob, has_been_refined); + + /* Only if gauges count > 0 */ + fclaw_locate_gauges(glob); + + /* Stop timer. Be sure to use timers from new grid, if one was + created */ + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_REGRID]); + + /* Count calls to this function */ + ++glob->count_amr_regrid; +} + +static +void cb_set_neighbor_types(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, + int blockno, + int patchno, + void *user) +{ + for (int iface = 0; iface < fclaw_domain_num_faces(domain); iface++) + { + int rproc[4]; //allocate for 3d + int rblockno; + int rpatchno[4]; + int rfaceno; + + fclaw_patch_relation_t neighbor_type = + fclaw_patch_face_neighbors(domain, + blockno, + patchno, + iface, + rproc, + &rblockno, + rpatchno, + &rfaceno); + + fclaw_patch_set_face_type(this_patch,iface,neighbor_type); + } + + for (int iedge = 0; iedge < fclaw_domain_num_edges(domain); iedge++) + { + int rproc[2]; + int rblockno; + int rpatchno[2]; + int redgeno; + + fclaw_patch_relation_t neighbor_type; + fclaw_patch_edge_neighbors(domain, + blockno, + patchno, + iedge, + rproc, + &rblockno, + rpatchno, + &redgeno, + &neighbor_type); + + fclaw_patch_set_edge_type(this_patch,iedge,neighbor_type); + } + + for (int icorner = 0; icorner < fclaw_domain_num_corners(domain); icorner++) + { + int rproc_corner; + int cornerpatchno; + int cornerblockno; + int rcornerno; + fclaw_patch_relation_t neighbor_type; + + int has_corner_neighbor = + fclaw_patch_corner_neighbors(domain, + blockno, + patchno, + icorner, + &rproc_corner, + &cornerblockno, + &cornerpatchno, + &rcornerno, + &neighbor_type); + + fclaw_patch_set_corner_type(this_patch,icorner,neighbor_type); + if (!has_corner_neighbor) + { + fclaw_patch_set_missing_corner(this_patch,icorner); + } + } + fclaw_patch_neighbors_set(this_patch); +} + +/* Set neighbor type : samesize, halfsize, or doublesize */ +void fclaw_regrid_set_neighbor_types(fclaw_global_t *glob) +{ + fclaw_timer_start (&glob->timers[FCLAW_TIMER_NEIGHBOR_SEARCH]); + fclaw_global_iterate_patches(glob,cb_set_neighbor_types,NULL); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_NEIGHBOR_SEARCH]); +} diff --git a/src/fclaw2d_regrid.h b/src/fclaw_regrid.h similarity index 56% rename from src/fclaw2d_regrid.h rename to src/fclaw_regrid.h index 1662981a9..2474865f1 100644 --- a/src/fclaw2d_regrid.h +++ b/src/fclaw_regrid.h @@ -23,10 +23,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_REGRID_H -#define FCLAW2D_REGRID_H +#ifndef FCLAW_REGRID_H +#define FCLAW_REGRID_H -#include /* Needed to define fclaw2d_patch_relation_t */ +#include /* Needed to define fclaw2d_patch_relation_t */ #ifdef __cplusplus extern "C" @@ -36,38 +36,61 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_domain; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_domain; +struct fclaw_patch; + +/** + * @brief Passed to cb_fclaw_regrid_tag4refinement as user data. + */ +typedef struct fclaw_tag4f_user +{ + /** True if in domain initialization phase */ + int domain_init; + /** + * @Brief A running counter of how many patches have been initialized. + * + * This MUST be initalized to zero. + */ + int num_patches_refined; + /** + * @brief Number of patches to refine. + * + * Set to zero to have no limit. If not zero, cb_fclaw_regrid_tag4refinement + * Will only tag this many patches for refinement. + */ + int num_patches_to_refine; +} fclaw_tag4f_user_t; + /* Called from both fclaw2d_initialize and fclaw2d_regrid */ -void cb_fclaw2d_regrid_tag4refinement(struct fclaw2d_domain *domain, - struct fclaw2d_patch *this_patch, +void cb_fclaw_regrid_tag4refinement(struct fclaw_domain *domain, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, void *user); -void cb_regrid_tag4coarsening(fclaw2d_domain_t *domain, - fclaw2d_patch_t *fine_patches, +void cb_regrid_tag4coarsening(fclaw_domain_t *domain, + fclaw_patch_t *fine_patches, int blockno, int fine0_patchno, void *user); -void cb_fclaw2d_regrid_repopulate(struct fclaw2d_domain * old_domain, - struct fclaw2d_patch * old_patch, - struct fclaw2d_domain * new_domain, - struct fclaw2d_patch * new_patch, - fclaw2d_patch_relation_t newsize, +void cb_fclaw_regrid_repopulate(struct fclaw_domain * old_domain, + struct fclaw_patch * old_patch, + struct fclaw_domain * new_domain, + struct fclaw_patch * new_patch, + fclaw_patch_relation_t newsize, int blockno, int old_patchno, int new_patchno, void *user); -void fclaw2d_regrid_set_neighbor_types(struct fclaw2d_global *glob); +void fclaw_regrid_set_neighbor_types(struct fclaw_global *glob); -void fclaw2d_regrid(struct fclaw2d_global *glob); +void fclaw_regrid(struct fclaw_global *glob); -void fclaw2d_regrid_set_neighbor_types(struct fclaw2d_global *glob); +void fclaw_regrid_set_neighbor_types(struct fclaw_global *glob); diff --git a/src/fclaw2d_run.c b/src/fclaw_run.c similarity index 82% rename from src/fclaw2d_run.c rename to src/fclaw_run.c index 5b6709970..914d4f2b0 100644 --- a/src/fclaw2d_run.c +++ b/src/fclaw_run.c @@ -23,16 +23,16 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "fclaw_math.h" @@ -44,40 +44,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------- */ static -void cb_restore_time_step(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_restore_time_step(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_patch_restore_step(s->glob,this_patch); + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_patch_restore_step(s->glob,this_patch); } static -void restore_time_step(fclaw2d_global_t *glob) +void restore_time_step(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob,cb_restore_time_step,(void *) NULL); + fclaw_global_iterate_patches(glob,cb_restore_time_step,(void *) NULL); //fclaw_options_t *fopt = fclaw2d_get_options(glob); //fclaw2d_time_sync_reset(glob,fopt->minlevel,fopt->maxlevel,0); } static -void cb_save_time_step(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_save_time_step(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_patch_save_step(s->glob,this_patch); + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_patch_save_step(s->glob,this_patch); } static -void save_time_step(fclaw2d_global_t *glob) +void save_time_step(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob,cb_save_time_step,(void *) NULL); + fclaw_global_iterate_patches(glob,cb_save_time_step,(void *) NULL); } @@ -85,16 +85,16 @@ void save_time_step(fclaw2d_global_t *glob) Output style 1 Output times are at times [0,dT, 2*dT, 3*dT,...,Tfinal], where dT = tfinal/nout -------------------------------------------------------------------------------- */ -static void outstyle_0(fclaw2d_global_t *glob) +static void outstyle_0(fclaw_global_t *glob) { int iframe; iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; /* Here is where we might include a call to a static solver, for, say, @@ -117,19 +117,19 @@ static void outstyle_0(fclaw2d_global_t *glob) Output times are at times [0,dT, 2*dT, 3*dT,...,Tfinal], where dT = tfinal/nout -------------------------------------------------------------------------------- */ static -void outstyle_1(fclaw2d_global_t *glob) +void outstyle_1(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; /* Set error to 0 */ int init_flag = 1; /* Store anything that needs to be stored */ - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double final_time = fclaw_opt->tfinal; int nout = fclaw_opt->nout; @@ -196,15 +196,15 @@ void outstyle_1(fclaw2d_global_t *glob) } } glob->curr_dt = dt_step; - double maxcfl_step = fclaw2d_advance_all_levels(glob, t_curr,dt_step); + double maxcfl_step = fclaw_advance_all_levels(glob, t_curr,dt_step); if (fclaw_opt->reduce_cfl) { /* If we are taking a variable time step, we have to reduce the maxcfl so that every processor takes the same size dt */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); - maxcfl_step = fclaw2d_domain_global_maximum (*domain, maxcfl_step); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_CFL_COMM]); + maxcfl_step = fclaw_domain_global_maximum (*domain, maxcfl_step); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_CFL_COMM]); } @@ -275,7 +275,7 @@ void outstyle_1(fclaw2d_global_t *glob) if (fclaw_opt->advance_one_step) { - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); } if (fclaw_opt->regrid_interval > 0) @@ -283,16 +283,16 @@ void outstyle_1(fclaw2d_global_t *glob) if (n_inner % fclaw_opt->regrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } } /* Output file at every outer loop iteration */ - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); glob->curr_time = t_curr; iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } @@ -305,19 +305,19 @@ static void outstyle_2(fclaw2d_global_t *glob) #endif static -void outstyle_3(fclaw2d_global_t *glob) +void outstyle_3(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; @@ -368,16 +368,16 @@ void outstyle_3(fclaw2d_global_t *glob) /* Get current domain data since it may change during regrid */ glob->curr_dt = dt_step; - double maxcfl_step = fclaw2d_advance_all_levels(glob, t_curr,dt_step); + double maxcfl_step = fclaw_advance_all_levels(glob, t_curr,dt_step); /* This is a collective communication - everybody needs to wait here. */ if (fclaw_opt->reduce_cfl) { /* If we are taking a variable time step, we have to reduce the maxcfl so that every processor takes the same size dt */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); - maxcfl_step = fclaw2d_domain_global_maximum (*domain, maxcfl_step); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_CFL_COMM]); + maxcfl_step = fclaw_domain_global_maximum (*domain, maxcfl_step); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_CFL_COMM]); } double tc = t_curr + dt_step; @@ -427,7 +427,7 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nregrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } @@ -439,26 +439,26 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { iframe++; - fclaw2d_diagnostics_gather(glob,init_flag); - fclaw2d_output_frame(glob,iframe); + fclaw_diagnostics_gather(glob,init_flag); + fclaw_output_frame(glob,iframe); } } } static -void outstyle_4(fclaw2d_global_t *glob) +void outstyle_4(fclaw_global_t *glob) { /* Write out an initial time file */ int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; int nstep_outer = fclaw_opt->nout; int nstep_inner = fclaw_opt->nstep; @@ -471,7 +471,7 @@ void outstyle_4(fclaw2d_global_t *glob) while (n < nstep_outer) { /* Get current domain data since it may change during regrid */ - fclaw2d_advance_all_levels(glob, t_curr, dt_minlevel); + fclaw_advance_all_levels(glob, t_curr, dt_minlevel); int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ? fclaw_opt->maxlevel : fclaw_opt->minlevel; @@ -491,7 +491,7 @@ void outstyle_4(fclaw2d_global_t *glob) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } else @@ -501,9 +501,9 @@ void outstyle_4(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -513,10 +513,10 @@ void outstyle_4(fclaw2d_global_t *glob) Public interface ---------------------------------------------------------------- */ -void fclaw2d_run(fclaw2d_global_t *glob) +void fclaw_run(fclaw_global_t *glob) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); switch (fclaw_opt->outstyle) { diff --git a/src/fclaw2d_time_sync.c b/src/fclaw_time_sync.c similarity index 69% rename from src/fclaw2d_time_sync.c rename to src/fclaw_time_sync.c index 1fda1bd4e..46e3ec02e 100644 --- a/src/fclaw2d_time_sync.c +++ b/src/fclaw_time_sync.c @@ -23,18 +23,19 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include typedef struct fclaw2d_time_sync_info { /** The type of reset to perform */ - fclaw2d_time_sync_type_t reset_mode; + fclaw_time_sync_type_t reset_mode; /** The type of reset to perform */ int coarse_level; /** The type of reset to perform */ @@ -45,84 +46,84 @@ typedef struct fclaw2d_time_sync_info static -void cb_time_sync_reset(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_time_sync_reset(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* g = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) g->glob; + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) g->glob; fclaw2d_time_sync_info_t *tstype = (fclaw2d_time_sync_info_t*) g->user; int reset_mode = tstype->reset_mode; int coarse_level = tstype->coarse_level; - fclaw2d_patch_time_sync_reset(glob,this_patch,coarse_level,reset_mode); + fclaw_patch_time_sync_reset(glob,this_patch,coarse_level,reset_mode); } static -void time_sync_reset (fclaw2d_global_t* glob, +void time_sync_reset (fclaw_global_t* glob, int coarse_level, int reset_mode) { fclaw2d_time_sync_info_t ts_info; - ts_info.reset_mode = (fclaw2d_time_sync_type_t) reset_mode; + ts_info.reset_mode = (fclaw_time_sync_type_t) reset_mode; ts_info.coarse_level = coarse_level; - fclaw2d_global_iterate_level(glob, coarse_level, + fclaw_global_iterate_level(glob, coarse_level, cb_time_sync_reset, &ts_info); - if (reset_mode == FCLAW2D_TIME_SYNC_RESET_F2C) + if (reset_mode == FCLAW_TIME_SYNC_RESET_F2C) { - fclaw2d_global_iterate_level(glob, coarse_level+1, + fclaw_global_iterate_level(glob, coarse_level+1, cb_time_sync_reset, &ts_info); } } static -void copy_at_blockbdry(fclaw2d_global_t *glob, +void copy_at_blockbdry(fclaw_global_t *glob, int level, int read_parallel_patches, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { - fclaw2d_exchange_info_t e_info; - e_info.exchange_type = FCLAW2D_TIME_SYNC_SAMESIZE; - e_info.grid_type = FCLAW2D_IS_COARSE; + fclaw_exchange_info_t e_info; + e_info.exchange_type = FCLAW_TIME_SYNC_SAMESIZE; + e_info.grid_type = FCLAW_IS_COARSE; e_info.time_interp = 0; e_info.read_parallel_patches = read_parallel_patches; - fclaw2d_global_iterate_level(glob, level, cb_face_fill, + fclaw_global_iterate_level(glob, level, fclaw_face_fill_cb, &e_info); } static -void fine2coarse(fclaw2d_global_t *glob, +void fine2coarse(fclaw_global_t *glob, int level, int read_parallel_patches, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { - fclaw2d_exchange_info_t e_info; - e_info.exchange_type = FCLAW2D_TIME_SYNC_F2C; - e_info.grid_type = FCLAW2D_IS_COARSE; + fclaw_exchange_info_t e_info; + e_info.exchange_type = FCLAW_TIME_SYNC_F2C; + e_info.grid_type = FCLAW_IS_COARSE; e_info.time_interp = 0; e_info.read_parallel_patches = read_parallel_patches; - fclaw2d_global_iterate_level(glob, level, cb_face_fill, &e_info); + fclaw_global_iterate_level(glob, level, fclaw_face_fill_cb, &e_info); } static -void correct_coarse_cells(fclaw2d_global_t *glob, +void correct_coarse_cells(fclaw_global_t *glob, int minlevel, int read_parallel_patches, - fclaw2d_ghost_fill_parallel_mode_t ghost_mode) + fclaw_ghost_fill_parallel_mode_t ghost_mode) { - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); /* This step accounts for any metric discontinuities at block boundaries between grids at the same level */ @@ -132,7 +133,7 @@ void correct_coarse_cells(fclaw2d_global_t *glob, copy_at_blockbdry(glob,level, read_parallel_patches,ghost_mode); - time_sync_reset(glob, level, FCLAW2D_TIME_SYNC_RESET_SAMESIZE); + time_sync_reset(glob, level, FCLAW_TIME_SYNC_RESET_SAMESIZE); /* Correct coarser grids with corrections from coarse/fine grids */ if (level < fclaw_opt->maxlevel) @@ -142,23 +143,23 @@ void correct_coarse_cells(fclaw2d_global_t *glob, read_parallel_patches,ghost_mode); /* Clear registers at coarse/fine interface */ - time_sync_reset(glob, level, FCLAW2D_TIME_SYNC_RESET_F2C); + time_sync_reset(glob, level, FCLAW_TIME_SYNC_RESET_F2C); } } for(int level = fclaw_opt->maxlevel; level >= minlevel; level--) { /* Clear registers at physical level; These are not used in sychronization, but will accumulate throughout simulation. */ - time_sync_reset(glob, level, FCLAW2D_TIME_SYNC_RESET_PHYS); + time_sync_reset(glob, level, FCLAW_TIME_SYNC_RESET_PHYS); } } -void fclaw2d_time_sync(fclaw2d_global_t *glob, int minlevel, int maxlevel) +void fclaw_time_sync(fclaw_global_t *glob, int minlevel, int maxlevel) { - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_TIMESYNC]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_TIMESYNC]); #if 0 int time_interp = 0; @@ -191,13 +192,13 @@ void fclaw2d_time_sync(fclaw2d_global_t *glob, int minlevel, int maxlevel) /* Indicates that we should read only interior, only boundary, or all patches on a local processor */ - fclaw2d_ghost_fill_parallel_mode_t parallel_mode = - FCLAW2D_BOUNDARY_ALL; + fclaw_ghost_fill_parallel_mode_t parallel_mode = + FCLAW_BOUNDARY_ALL; correct_coarse_cells(glob,minlevel,read_parallel_patches,parallel_mode); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_TIMESYNC]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_TIMESYNC]); } diff --git a/src/fclaw2d_time_sync.h b/src/fclaw_time_sync.h similarity index 85% rename from src/fclaw2d_time_sync.h rename to src/fclaw_time_sync.h index 7c6440465..d3d69ecb7 100644 --- a/src/fclaw2d_time_sync.h +++ b/src/fclaw_time_sync.h @@ -24,8 +24,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_TIME_SYNC_H -#define FCLAW2D_TIME_SYNC_H +#ifndef FCLAW_TIME_SYNC_H +#define FCLAW_TIME_SYNC_H #ifdef __cplusplus extern "C" @@ -36,7 +36,7 @@ extern "C" #endif -struct fclaw2d_global; +struct fclaw_global; /** * @file @@ -46,14 +46,14 @@ struct fclaw2d_global; /** * @brief The type of reset to perform */ -typedef enum fclaw2d_time_sync_type +typedef enum fclaw_time_sync_type { /** Reset registers at coarse-fine boundaries */ - FCLAW2D_TIME_SYNC_RESET_F2C = 1, + FCLAW_TIME_SYNC_RESET_F2C = 1, /** Reset registers between same size grids */ - FCLAW2D_TIME_SYNC_RESET_SAMESIZE, + FCLAW_TIME_SYNC_RESET_SAMESIZE, /** Reset registers at physical boundary */ - FCLAW2D_TIME_SYNC_RESET_PHYS -} fclaw2d_time_sync_type_t; + FCLAW_TIME_SYNC_RESET_PHYS +} fclaw_time_sync_type_t; /** @@ -67,7 +67,7 @@ typedef enum fclaw2d_time_sync_type * @param minlevel the minimum level * @param maxlevel the maximmum level */ -void fclaw2d_time_sync(struct fclaw2d_global *glob, int minlevel, int maxlevel); +void fclaw_time_sync(struct fclaw_global *glob, int minlevel, int maxlevel); #ifdef __cplusplus diff --git a/src/fclaw2d_timeinterp.c b/src/fclaw_timeinterp.c similarity index 80% rename from src/fclaw2d_timeinterp.c rename to src/fclaw_timeinterp.c index 2fd0e5c4a..36719eb04 100644 --- a/src/fclaw2d_timeinterp.c +++ b/src/fclaw_timeinterp.c @@ -23,22 +23,22 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include +#include +#include +#include static -void cb_setup_time_interp(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_setup_time_interp(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *s = (fclaw2d_global_iterate_t*) user; - if (fclaw2d_patch_has_finegrid_neighbors(this_patch)) + fclaw_global_iterate_t *s = (fclaw_global_iterate_t*) user; + if (fclaw_patch_has_finegrid_neighbors(this_patch)) { double alpha = *((double*) s->user); - fclaw2d_patch_setup_timeinterp(s->glob,this_patch,alpha); + fclaw_patch_setup_timeinterp(s->glob,this_patch,alpha); } } @@ -48,10 +48,10 @@ void cb_setup_time_interp(fclaw2d_domain_t *domain, via interpolating and averaging) ghost cell values. -------------------------------------------------------------------- */ -void fclaw2d_timeinterp(fclaw2d_global_t *glob, +void fclaw_timeinterp(fclaw_global_t *glob, int level,double alpha) { /* Store time interpolated data into m_griddata_time_sync. */ - fclaw2d_global_iterate_level(glob,level,cb_setup_time_interp, + fclaw_global_iterate_level(glob,level,cb_setup_time_interp, (void *) &alpha); } diff --git a/src/fclaw2d_timeinterp.h b/src/fclaw_timeinterp.h similarity index 93% rename from src/fclaw2d_timeinterp.h rename to src/fclaw_timeinterp.h index f096275cb..fc262b702 100644 --- a/src/fclaw2d_timeinterp.h +++ b/src/fclaw_timeinterp.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_TIMEINTERP_H -#define FCLAW2D_TIMEINTERP_H +#ifndef FCLAW_TIMEINTERP_H +#define FCLAW_TIMEINTERP_H #include /* Defines FCLAW_F77_FUNC */ @@ -36,9 +36,9 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; -void fclaw2d_timeinterp(struct fclaw2d_global *glob, +void fclaw_timeinterp(struct fclaw_global *glob, int level, double alpha); #define FCLAW2D_TIMEINTERP_FORT FCLAW_F77_FUNC (fclaw2d_timeinterp_fort, \ diff --git a/src/fclaw_timer.c b/src/fclaw_timer.c index 9eef79f97..0fd981b47 100644 --- a/src/fclaw_timer.c +++ b/src/fclaw_timer.c @@ -24,12 +24,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include -#include +#include +#include -#include +#include #include -#include +#include #define PRIORITY_WALL FCLAW_TIMER_PRIORITY_WALL #define PRIORITY_EXCLUSIVE1 FCLAW_TIMER_PRIORITY_SUMMARY @@ -47,15 +47,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define PRIORITY_EXTRA FCLAW_TIMER_PRIORITY_EXTRA -#define FCLAW2D_STATS_SET(stats,glob,NAME) do { \ - SC_CHECK_ABORT (!(glob)->timers[FCLAW2D_TIMER_ ## NAME].running, \ +#define FCLAW_STATS_SET(stats,glob,NAME) do { \ + SC_CHECK_ABORT (!(glob)->timers[FCLAW_TIMER_ ## NAME].running, \ "Timer " #NAME " still running in fclaw2d_domain_finalize"); \ - sc_stats_set1 ((stats) + FCLAW2D_TIMER_ ## NAME, \ - (glob)->timers[FCLAW2D_TIMER_ ## NAME].cumulative, #NAME); \ + sc_stats_set1 ((stats) + FCLAW_TIMER_ ## NAME, \ + (glob)->timers[FCLAW_TIMER_ ## NAME].cumulative, #NAME); \ } while (0) -#define FCLAW2D_STATS_SET_GROUP(stats,NAME,GROUP) do { \ - sc_stats_set_group_prio ((stats) + FCLAW2D_TIMER_ ## NAME, \ +#define FCLAW_STATS_SET_GROUP(stats,NAME,GROUP) do { \ + sc_stats_set_group_prio ((stats) + FCLAW_TIMER_ ## NAME, \ GROUP_ ## GROUP, PRIORITY_ ## GROUP); \ } while (0) @@ -66,23 +66,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------- */ double -fclaw2d_timer_wtime (void) +fclaw_timer_wtime (void) { return sc_MPI_Wtime (); } void -fclaw2d_timer_init (fclaw2d_timer_t *timer) +fclaw_timer_init (fclaw_timer_t *timer) { - memset (timer, 0, sizeof (fclaw2d_timer_t)); + memset (timer, 0, sizeof (fclaw_timer_t)); } void -fclaw2d_timer_start (fclaw2d_timer_t *timer) +fclaw_timer_start (fclaw_timer_t *timer) { if (!timer->running) { - timer->started = fclaw2d_timer_wtime (); + timer->started = fclaw_timer_wtime (); timer->stopped = 0.; timer->running = 1; } @@ -93,11 +93,11 @@ fclaw2d_timer_start (fclaw2d_timer_t *timer) } void -fclaw2d_timer_stop (fclaw2d_timer_t *timer) +fclaw_timer_stop (fclaw_timer_t *timer) { if (timer->running) { - timer->stopped = fclaw2d_timer_wtime (); + timer->stopped = fclaw_timer_wtime (); timer->cumulative += timer->stopped - timer->started; timer->running = 0; } @@ -108,67 +108,67 @@ fclaw2d_timer_stop (fclaw2d_timer_t *timer) } /* Don't put timers inside of any step update functions when using OPENMP */ -void fclaw2d_timer_start_threadsafe(fclaw2d_timer_t *timer) +void fclaw_timer_start_threadsafe(fclaw_timer_t *timer) { #if !defined(_OPENMP) - fclaw2d_timer_start(timer); + fclaw_timer_start(timer); #endif } -void fclaw2d_timer_stop_threadsafe(fclaw2d_timer_t *timer) +void fclaw_timer_stop_threadsafe(fclaw_timer_t *timer) { #if !defined(_OPENMP) - fclaw2d_timer_stop(timer); + fclaw_timer_stop(timer); #endif } void -fclaw2d_timer_report(fclaw2d_global_t *glob) +fclaw2d_timer_report(fclaw_global_t *glob) { - sc_statinfo_t stats[FCLAW2D_TIMER_COUNT]; - - - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_WALLTIME]); - - FCLAW2D_STATS_SET (stats, glob, INIT); - FCLAW2D_STATS_SET (stats, glob, OUTPUT); - FCLAW2D_STATS_SET (stats, glob, DIAGNOSTICS); - FCLAW2D_STATS_SET (stats, glob, REGRID); - FCLAW2D_STATS_SET (stats, glob, ADVANCE); - FCLAW2D_STATS_SET (stats, glob, GHOSTFILL); - FCLAW2D_STATS_SET (stats, glob, ADAPT_COMM); - FCLAW2D_STATS_SET (stats, glob, PARTITION_COMM); - FCLAW2D_STATS_SET (stats, glob, GHOSTPATCH_COMM); - FCLAW2D_STATS_SET (stats, glob, DIAGNOSTICS_COMM); - FCLAW2D_STATS_SET (stats, glob, CFL_COMM); - FCLAW2D_STATS_SET (stats, glob, WALLTIME); - FCLAW2D_STATS_SET (stats, glob, REGRID_BUILD); - FCLAW2D_STATS_SET (stats, glob, REGRID_TAGGING); - FCLAW2D_STATS_SET (stats, glob, TIMESYNC); - FCLAW2D_STATS_SET (stats, glob, PARTITION); - FCLAW2D_STATS_SET (stats, glob, PARTITION_BUILD); - FCLAW2D_STATS_SET (stats, glob, ADVANCE_STEP2); - FCLAW2D_STATS_SET (stats, glob, ADVANCE_B4STEP2); - FCLAW2D_STATS_SET (stats, glob, GHOSTPATCH_BUILD); - FCLAW2D_STATS_SET (stats, glob, GHOSTFILL_COPY); - FCLAW2D_STATS_SET (stats, glob, GHOSTFILL_AVERAGE); - FCLAW2D_STATS_SET (stats, glob, GHOSTFILL_INTERP); - FCLAW2D_STATS_SET (stats, glob, GHOSTFILL_PHYSBC); - FCLAW2D_STATS_SET (stats, glob, GHOSTFILL_STEP1); - FCLAW2D_STATS_SET (stats, glob, GHOSTFILL_STEP2); - FCLAW2D_STATS_SET (stats, glob, GHOSTFILL_STEP3); - FCLAW2D_STATS_SET (stats, glob, NEIGHBOR_SEARCH); - FCLAW2D_STATS_SET (stats, glob, CUDA_ALLOCATE); - FCLAW2D_STATS_SET (stats, glob, CUDA_MEMCOPY_H2H); - FCLAW2D_STATS_SET (stats, glob, CUDA_MEMCOPY_H2D); - FCLAW2D_STATS_SET (stats, glob, CUDA_MEMCOPY_D2H); - FCLAW2D_STATS_SET (stats, glob, ELLIPTIC_SOLVE); - FCLAW2D_STATS_SET (stats, glob, EXTRA1); - FCLAW2D_STATS_SET (stats, glob, EXTRA2); - FCLAW2D_STATS_SET (stats, glob, EXTRA3); - FCLAW2D_STATS_SET (stats, glob, EXTRA4); + sc_statinfo_t stats[FCLAW_TIMER_COUNT]; + + + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_WALLTIME]); + + FCLAW_STATS_SET (stats, glob, INIT); + FCLAW_STATS_SET (stats, glob, OUTPUT); + FCLAW_STATS_SET (stats, glob, DIAGNOSTICS); + FCLAW_STATS_SET (stats, glob, REGRID); + FCLAW_STATS_SET (stats, glob, ADVANCE); + FCLAW_STATS_SET (stats, glob, GHOSTFILL); + FCLAW_STATS_SET (stats, glob, ADAPT_COMM); + FCLAW_STATS_SET (stats, glob, PARTITION_COMM); + FCLAW_STATS_SET (stats, glob, GHOSTPATCH_COMM); + FCLAW_STATS_SET (stats, glob, DIAGNOSTICS_COMM); + FCLAW_STATS_SET (stats, glob, CFL_COMM); + FCLAW_STATS_SET (stats, glob, WALLTIME); + FCLAW_STATS_SET (stats, glob, REGRID_BUILD); + FCLAW_STATS_SET (stats, glob, REGRID_TAGGING); + FCLAW_STATS_SET (stats, glob, TIMESYNC); + FCLAW_STATS_SET (stats, glob, PARTITION); + FCLAW_STATS_SET (stats, glob, PARTITION_BUILD); + FCLAW_STATS_SET (stats, glob, ADVANCE_STEP2); + FCLAW_STATS_SET (stats, glob, ADVANCE_B4STEP2); + FCLAW_STATS_SET (stats, glob, GHOSTPATCH_BUILD); + FCLAW_STATS_SET (stats, glob, GHOSTFILL_COPY); + FCLAW_STATS_SET (stats, glob, GHOSTFILL_AVERAGE); + FCLAW_STATS_SET (stats, glob, GHOSTFILL_INTERP); + FCLAW_STATS_SET (stats, glob, GHOSTFILL_PHYSBC); + FCLAW_STATS_SET (stats, glob, GHOSTFILL_STEP1); + FCLAW_STATS_SET (stats, glob, GHOSTFILL_STEP2); + FCLAW_STATS_SET (stats, glob, GHOSTFILL_STEP3); + FCLAW_STATS_SET (stats, glob, NEIGHBOR_SEARCH); + FCLAW_STATS_SET (stats, glob, CUDA_ALLOCATE); + FCLAW_STATS_SET (stats, glob, CUDA_MEMCOPY_H2H); + FCLAW_STATS_SET (stats, glob, CUDA_MEMCOPY_H2D); + FCLAW_STATS_SET (stats, glob, CUDA_MEMCOPY_D2H); + FCLAW_STATS_SET (stats, glob, ELLIPTIC_SOLVE); + FCLAW_STATS_SET (stats, glob, EXTRA1); + FCLAW_STATS_SET (stats, glob, EXTRA2); + FCLAW_STATS_SET (stats, glob, EXTRA3); + FCLAW_STATS_SET (stats, glob, EXTRA4); int d = glob->count_grids_per_proc; glob->count_grids_per_proc = (d > 0) ? d : 1; /* To avoid division by zero */ @@ -181,41 +181,41 @@ fclaw2d_timer_report(fclaw2d_global_t *glob) double gint = gpp - glb; /* compute arithmetic mean of total advance steps per processor */ - sc_stats_set1 (&stats[FCLAW2D_TIMER_ADVANCE_STEPS_COUNTER], + sc_stats_set1 (&stats[FCLAW_TIMER_ADVANCE_STEPS_COUNTER], glob->count_single_step,"ADVANCE_STEPS_COUNTER"); - sc_stats_set1 (&stats[FCLAW2D_TIMER_ELLIPTIC_GRIDS_COUNTER], + sc_stats_set1 (&stats[FCLAW_TIMER_ELLIPTIC_GRIDS_COUNTER], glob->count_elliptic_grids,"ELLIPTIC_GRIDS_COUNTER"); /* Compute the arithmetic mean of grids per processor */ - sc_stats_set1 (&stats[FCLAW2D_TIMER_GRIDS_PER_PROC],gpp,"GRIDS_PER_PROC"); + sc_stats_set1 (&stats[FCLAW_TIMER_GRIDS_PER_PROC],gpp,"GRIDS_PER_PROC"); /* Compute the arithmetic mean of grids in the interior */ - sc_stats_set1 (&stats[FCLAW2D_TIMER_GRIDS_INTERIOR],gint, + sc_stats_set1 (&stats[FCLAW_TIMER_GRIDS_INTERIOR],gint, "GRIDS_INTERIOR"); /* Compute the arithmetic mean of local grids on the boundary */ - sc_stats_set1 (&stats[FCLAW2D_TIMER_GRIDS_LOCAL_BOUNDARY],glb, + sc_stats_set1 (&stats[FCLAW_TIMER_GRIDS_LOCAL_BOUNDARY],glb, "GRIDS_LOCAL_BOUNDARY"); /* Compute the arithmetic mean of remote grids on the boundary */ - sc_stats_set1 (&stats[FCLAW2D_TIMER_GRIDS_REMOTE_BOUNDARY],grb, + sc_stats_set1 (&stats[FCLAW_TIMER_GRIDS_REMOTE_BOUNDARY],grb, "GRIDS_REMOTE_BOUNDARY"); - int time_ex1 = glob->timers[FCLAW2D_TIMER_REGRID].cumulative + - glob->timers[FCLAW2D_TIMER_ADVANCE].cumulative + - glob->timers[FCLAW2D_TIMER_GHOSTFILL].cumulative + - glob->timers[FCLAW2D_TIMER_ADAPT_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_ELLIPTIC_SOLVE].cumulative + - glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM].cumulative; + int time_ex1 = glob->timers[FCLAW_TIMER_REGRID].cumulative + + glob->timers[FCLAW_TIMER_ADVANCE].cumulative + + glob->timers[FCLAW_TIMER_GHOSTFILL].cumulative + + glob->timers[FCLAW_TIMER_ADAPT_COMM].cumulative + + glob->timers[FCLAW_TIMER_ELLIPTIC_SOLVE].cumulative + + glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM].cumulative; - int time_ex2 = glob->timers[FCLAW2D_TIMER_INIT].cumulative + - glob->timers[FCLAW2D_TIMER_OUTPUT].cumulative + - glob->timers[FCLAW2D_TIMER_DIAGNOSTICS].cumulative + - glob->timers[FCLAW2D_TIMER_PARTITION_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_DIAGNOSTICS_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_CFL_COMM].cumulative; + int time_ex2 = glob->timers[FCLAW_TIMER_INIT].cumulative + + glob->timers[FCLAW_TIMER_OUTPUT].cumulative + + glob->timers[FCLAW_TIMER_DIAGNOSTICS].cumulative + + glob->timers[FCLAW_TIMER_PARTITION_COMM].cumulative + + glob->timers[FCLAW_TIMER_DIAGNOSTICS_COMM].cumulative + + glob->timers[FCLAW_TIMER_CFL_COMM].cumulative; /* Get a partial sum of timers not accounted for in reported summary */ int priority = fclaw_opt->report_timing_verbosity; /* Make this an option */ @@ -223,34 +223,34 @@ fclaw2d_timer_report(fclaw2d_global_t *glob) if (priority == FCLAW_TIMER_PRIORITY_SUMMARY) { - sc_stats_set1 (&stats[FCLAW2D_TIMER_UNACCOUNTED], - glob->timers[FCLAW2D_TIMER_WALLTIME].cumulative - time_ex1, + sc_stats_set1 (&stats[FCLAW_TIMER_UNACCOUNTED], + glob->timers[FCLAW_TIMER_WALLTIME].cumulative - time_ex1, "UNACCOUNTED"); } else { - sc_stats_set1 (&stats[FCLAW2D_TIMER_UNACCOUNTED], - glob->timers[FCLAW2D_TIMER_WALLTIME].cumulative - time_ex1 - time_ex2, + sc_stats_set1 (&stats[FCLAW_TIMER_UNACCOUNTED], + glob->timers[FCLAW_TIMER_WALLTIME].cumulative - time_ex1 - time_ex2, "UNACCOUNTED"); } - sc_stats_set1 (&stats[FCLAW2D_TIMER_GLOBAL_COMM], - glob->timers[FCLAW2D_TIMER_ADAPT_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_PARTITION_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_DIAGNOSTICS_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_CFL_COMM].cumulative, - "FCLAW2D_TIMER_GLOBAL_COMM"); - - /* Just subtracting FCLAW2D_TIMER_GLOBAL here doesn't work ... */ - sc_stats_set1 (&stats[FCLAW2D_TIMER_LOCAL_COMM], - glob->timers[FCLAW2D_TIMER_WALLTIME].cumulative - - (glob->timers[FCLAW2D_TIMER_ADAPT_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_GHOSTPATCH_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_PARTITION_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_DIAGNOSTICS_COMM].cumulative + - glob->timers[FCLAW2D_TIMER_CFL_COMM].cumulative), - "FCLAW2D_TIMER_LOCAL_COMM"); + sc_stats_set1 (&stats[FCLAW_TIMER_GLOBAL_COMM], + glob->timers[FCLAW_TIMER_ADAPT_COMM].cumulative + + glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM].cumulative + + glob->timers[FCLAW_TIMER_PARTITION_COMM].cumulative + + glob->timers[FCLAW_TIMER_DIAGNOSTICS_COMM].cumulative + + glob->timers[FCLAW_TIMER_CFL_COMM].cumulative, + "FCLAW_TIMER_GLOBAL_COMM"); + + /* Just subtracting FCLAW_TIMER_GLOBAL here doesn't work ... */ + sc_stats_set1 (&stats[FCLAW_TIMER_LOCAL_COMM], + glob->timers[FCLAW_TIMER_WALLTIME].cumulative - + (glob->timers[FCLAW_TIMER_ADAPT_COMM].cumulative + + glob->timers[FCLAW_TIMER_GHOSTPATCH_COMM].cumulative + + glob->timers[FCLAW_TIMER_PARTITION_COMM].cumulative + + glob->timers[FCLAW_TIMER_DIAGNOSTICS_COMM].cumulative + + glob->timers[FCLAW_TIMER_CFL_COMM].cumulative), + "FCLAW_TIMER_LOCAL_COMM"); /* --------------------------------- Set stats groups ------------------------------*/ @@ -275,104 +275,104 @@ fclaw2d_timer_report(fclaw2d_global_t *glob) GROUP_COUNT }; - FCLAW2D_STATS_SET_GROUP(stats,WALLTIME, WALL); + FCLAW_STATS_SET_GROUP(stats,WALLTIME, WALL); - FCLAW2D_STATS_SET_GROUP(stats,ADVANCE, EXCLUSIVE1); - FCLAW2D_STATS_SET_GROUP(stats,ELLIPTIC_SOLVE, EXCLUSIVE1); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTFILL, EXCLUSIVE1); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTPATCH_COMM, EXCLUSIVE1); - FCLAW2D_STATS_SET_GROUP(stats,REGRID, EXCLUSIVE1); - FCLAW2D_STATS_SET_GROUP(stats,ADAPT_COMM, EXCLUSIVE1); + FCLAW_STATS_SET_GROUP(stats,ADVANCE, EXCLUSIVE1); + FCLAW_STATS_SET_GROUP(stats,ELLIPTIC_SOLVE, EXCLUSIVE1); + FCLAW_STATS_SET_GROUP(stats,GHOSTFILL, EXCLUSIVE1); + FCLAW_STATS_SET_GROUP(stats,GHOSTPATCH_COMM, EXCLUSIVE1); + FCLAW_STATS_SET_GROUP(stats,REGRID, EXCLUSIVE1); + FCLAW_STATS_SET_GROUP(stats,ADAPT_COMM, EXCLUSIVE1); if (priority == FCLAW_TIMER_PRIORITY_SUMMARY) - FCLAW2D_STATS_SET_GROUP(stats,UNACCOUNTED, EXCLUSIVE1); + FCLAW_STATS_SET_GROUP(stats,UNACCOUNTED, EXCLUSIVE1); else - FCLAW2D_STATS_SET_GROUP(stats,UNACCOUNTED, EXCLUSIVE2); + FCLAW_STATS_SET_GROUP(stats,UNACCOUNTED, EXCLUSIVE2); - FCLAW2D_STATS_SET_GROUP(stats,INIT, EXCLUSIVE2); - FCLAW2D_STATS_SET_GROUP(stats,OUTPUT, EXCLUSIVE2); - FCLAW2D_STATS_SET_GROUP(stats,DIAGNOSTICS, EXCLUSIVE2); - FCLAW2D_STATS_SET_GROUP(stats,PARTITION_COMM, EXCLUSIVE2); - FCLAW2D_STATS_SET_GROUP(stats,DIAGNOSTICS_COMM, EXCLUSIVE2); - FCLAW2D_STATS_SET_GROUP(stats,CFL_COMM, EXCLUSIVE2); + FCLAW_STATS_SET_GROUP(stats,INIT, EXCLUSIVE2); + FCLAW_STATS_SET_GROUP(stats,OUTPUT, EXCLUSIVE2); + FCLAW_STATS_SET_GROUP(stats,DIAGNOSTICS, EXCLUSIVE2); + FCLAW_STATS_SET_GROUP(stats,PARTITION_COMM, EXCLUSIVE2); + FCLAW_STATS_SET_GROUP(stats,DIAGNOSTICS_COMM, EXCLUSIVE2); + FCLAW_STATS_SET_GROUP(stats,CFL_COMM, EXCLUSIVE2); - FCLAW2D_STATS_SET_GROUP(stats,LOCAL_COMM, COMM); - FCLAW2D_STATS_SET_GROUP(stats,GLOBAL_COMM, COMM); + FCLAW_STATS_SET_GROUP(stats,LOCAL_COMM, COMM); + FCLAW_STATS_SET_GROUP(stats,GLOBAL_COMM, COMM); - FCLAW2D_STATS_SET_GROUP(stats,ADVANCE_STEPS_COUNTER, COUNTERS1); - FCLAW2D_STATS_SET_GROUP(stats,ELLIPTIC_GRIDS_COUNTER, COUNTERS1); - FCLAW2D_STATS_SET_GROUP(stats,GRIDS_PER_PROC, COUNTERS1); + FCLAW_STATS_SET_GROUP(stats,ADVANCE_STEPS_COUNTER, COUNTERS1); + FCLAW_STATS_SET_GROUP(stats,ELLIPTIC_GRIDS_COUNTER, COUNTERS1); + FCLAW_STATS_SET_GROUP(stats,GRIDS_PER_PROC, COUNTERS1); - FCLAW2D_STATS_SET_GROUP(stats,GRIDS_INTERIOR, COUNTERS2); - FCLAW2D_STATS_SET_GROUP(stats,GRIDS_LOCAL_BOUNDARY, COUNTERS2); - FCLAW2D_STATS_SET_GROUP(stats,GRIDS_REMOTE_BOUNDARY, COUNTERS2); + FCLAW_STATS_SET_GROUP(stats,GRIDS_INTERIOR, COUNTERS2); + FCLAW_STATS_SET_GROUP(stats,GRIDS_LOCAL_BOUNDARY, COUNTERS2); + FCLAW_STATS_SET_GROUP(stats,GRIDS_REMOTE_BOUNDARY, COUNTERS2); - FCLAW2D_STATS_SET_GROUP(stats,REGRID_BUILD, REGRID); - FCLAW2D_STATS_SET_GROUP(stats,REGRID_TAGGING, REGRID); + FCLAW_STATS_SET_GROUP(stats,REGRID_BUILD, REGRID); + FCLAW_STATS_SET_GROUP(stats,REGRID_TAGGING, REGRID); - FCLAW2D_STATS_SET_GROUP(stats,PARTITION, PARTITION); - FCLAW2D_STATS_SET_GROUP(stats,PARTITION_BUILD, PARTITION); + FCLAW_STATS_SET_GROUP(stats,PARTITION, PARTITION); + FCLAW_STATS_SET_GROUP(stats,PARTITION_BUILD, PARTITION); - FCLAW2D_STATS_SET_GROUP(stats,ADVANCE_STEP2, ADVANCE); - FCLAW2D_STATS_SET_GROUP(stats,ADVANCE_B4STEP2, ADVANCE); + FCLAW_STATS_SET_GROUP(stats,ADVANCE_STEP2, ADVANCE); + FCLAW_STATS_SET_GROUP(stats,ADVANCE_B4STEP2, ADVANCE); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTPATCH_BUILD, GHOST); - FCLAW2D_STATS_SET_GROUP(stats,TIMESYNC, GHOST); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTFILL_COPY, GHOST); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTFILL_AVERAGE, GHOST); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTFILL_INTERP, GHOST); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTFILL_PHYSBC, GHOST); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTFILL_STEP1, GHOST); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTFILL_STEP2, GHOST); - FCLAW2D_STATS_SET_GROUP(stats,GHOSTFILL_STEP3, GHOST); + FCLAW_STATS_SET_GROUP(stats,GHOSTPATCH_BUILD, GHOST); + FCLAW_STATS_SET_GROUP(stats,TIMESYNC, GHOST); + FCLAW_STATS_SET_GROUP(stats,GHOSTFILL_COPY, GHOST); + FCLAW_STATS_SET_GROUP(stats,GHOSTFILL_AVERAGE, GHOST); + FCLAW_STATS_SET_GROUP(stats,GHOSTFILL_INTERP, GHOST); + FCLAW_STATS_SET_GROUP(stats,GHOSTFILL_PHYSBC, GHOST); + FCLAW_STATS_SET_GROUP(stats,GHOSTFILL_STEP1, GHOST); + FCLAW_STATS_SET_GROUP(stats,GHOSTFILL_STEP2, GHOST); + FCLAW_STATS_SET_GROUP(stats,GHOSTFILL_STEP3, GHOST); - FCLAW2D_STATS_SET_GROUP(stats,NEIGHBOR_SEARCH, SEARCH); + FCLAW_STATS_SET_GROUP(stats,NEIGHBOR_SEARCH, SEARCH); - FCLAW2D_STATS_SET_GROUP(stats,CUDA_ALLOCATE, CUDA); - FCLAW2D_STATS_SET_GROUP(stats,CUDA_MEMCOPY_H2H, CUDA); - FCLAW2D_STATS_SET_GROUP(stats,CUDA_MEMCOPY_H2D, CUDA); - FCLAW2D_STATS_SET_GROUP(stats,CUDA_MEMCOPY_D2H, CUDA); + FCLAW_STATS_SET_GROUP(stats,CUDA_ALLOCATE, CUDA); + FCLAW_STATS_SET_GROUP(stats,CUDA_MEMCOPY_H2H, CUDA); + FCLAW_STATS_SET_GROUP(stats,CUDA_MEMCOPY_H2D, CUDA); + FCLAW_STATS_SET_GROUP(stats,CUDA_MEMCOPY_D2H, CUDA); - FCLAW2D_STATS_SET_GROUP(stats,EXTRA1, EXTRA); - FCLAW2D_STATS_SET_GROUP(stats,EXTRA1, EXTRA); + FCLAW_STATS_SET_GROUP(stats,EXTRA1, EXTRA); + FCLAW_STATS_SET_GROUP(stats,EXTRA1, EXTRA); - FCLAW2D_STATS_SET_GROUP(stats,EXTRA1, EXTRA); - FCLAW2D_STATS_SET_GROUP(stats,EXTRA2, EXTRA); - FCLAW2D_STATS_SET_GROUP(stats,EXTRA3, EXTRA); - FCLAW2D_STATS_SET_GROUP(stats,EXTRA4, EXTRA); + FCLAW_STATS_SET_GROUP(stats,EXTRA1, EXTRA); + FCLAW_STATS_SET_GROUP(stats,EXTRA2, EXTRA); + FCLAW_STATS_SET_GROUP(stats,EXTRA3, EXTRA); + FCLAW_STATS_SET_GROUP(stats,EXTRA4, EXTRA); /* ----------------------------------- Compute timers ------------------------------*/ /* This does all-reduce, etc to set stats */ - sc_stats_compute (glob->mpicomm, FCLAW2D_TIMER_COUNT, stats); + sc_stats_compute (glob->mpicomm, FCLAW_TIMER_COUNT, stats); /* ------------------------------------ Print timers ------------------------------*/ - sc_stats_print_ext(sc_package_id, SC_LP_ESSENTIAL, FCLAW2D_TIMER_COUNT, + sc_stats_print_ext(sc_package_id, SC_LP_ESSENTIAL, FCLAW_TIMER_COUNT, stats,sc_stats_group_all,priority,1,0); SC_GLOBAL_ESSENTIALF ("Procs %d advance %d %g exchange %d %g " "regrid %d %d %g\n", glob->mpisize, glob->count_amr_advance, - stats[FCLAW2D_TIMER_ADVANCE].average, + stats[FCLAW_TIMER_ADVANCE].average, glob->count_ghost_exchange, - stats[FCLAW2D_TIMER_GHOSTFILL].average, + stats[FCLAW_TIMER_GHOSTFILL].average, glob->count_amr_regrid, glob->count_amr_new_domain, - stats[FCLAW2D_TIMER_REGRID].average); + stats[FCLAW_TIMER_REGRID].average); SC_GLOBAL_ESSENTIALF ("Max/P %d advance %d %g exchange %d %g " "regrid %d %d %g\n", glob->mpisize, glob->count_amr_advance, - stats[FCLAW2D_TIMER_ADVANCE].max, + stats[FCLAW_TIMER_ADVANCE].max, glob->count_ghost_exchange, - stats[FCLAW2D_TIMER_GHOSTFILL].max, + stats[FCLAW_TIMER_GHOSTFILL].max, glob->count_amr_regrid, glob->count_amr_new_domain, - stats[FCLAW2D_TIMER_REGRID].max); + stats[FCLAW_TIMER_REGRID].max); #if 0 /* Find out process rank */ @@ -383,13 +383,13 @@ fclaw2d_timer_report(fclaw2d_global_t *glob) /* Write out individual processor timers */ printf("%12s time on proc %d : %12.4f\n","ADVANCE", - domain->mpirank,glob->timers[FCLAW2D_TIMER_ADVANCE].cumulative); + domain->mpirank,glob->timers[FCLAW_TIMER_ADVANCE].cumulative); printf("%12s time on proc %d : %12.4f\n","GHOSTCOMM", - domain->mpirank,glob->timers[FCLAW2D_TIMER_GHOSTCOMM].cumulative); + domain->mpirank,glob->timers[FCLAW_TIMER_GHOSTCOMM].cumulative); printf("%12s time on proc %d : %12.4f\n","EXCHANGE", - domain->mpirank,glob->timers[FCLAW2D_TIMER_EXCHANGE].cumulative); + domain->mpirank,glob->timers[FCLAW_TIMER_EXCHANGE].cumulative); printf("%12s time on proc %d : %12.4f\n","REGRID", - domain->mpirank,glob->timers[FCLAW2D_TIMER_REGRID].cumulative); + domain->mpirank,glob->timers[FCLAW_TIMER_REGRID].cumulative); printf("\n"); #endif diff --git a/src/fclaw_timer.h b/src/fclaw_timer.h index 99485c126..5a3065b53 100644 --- a/src/fclaw_timer.h +++ b/src/fclaw_timer.h @@ -36,7 +36,7 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; /* ----------------------------------------------------------------- Work with timers @@ -52,55 +52,55 @@ struct fclaw2d_global; typedef enum { - FCLAW2D_TIMER_NONE = -1, - FCLAW2D_TIMER_INIT, - FCLAW2D_TIMER_ADVANCE, - FCLAW2D_TIMER_ELLIPTIC_SOLVE, - FCLAW2D_TIMER_GHOSTFILL, - FCLAW2D_TIMER_REGRID, - FCLAW2D_TIMER_DIAGNOSTICS, - FCLAW2D_TIMER_OUTPUT, - FCLAW2D_TIMER_GHOSTPATCH_COMM, - FCLAW2D_TIMER_ADAPT_COMM, - FCLAW2D_TIMER_PARTITION_COMM, - FCLAW2D_TIMER_DIAGNOSTICS_COMM, - FCLAW2D_TIMER_CFL_COMM, - FCLAW2D_TIMER_WALLTIME, - FCLAW2D_TIMER_UNACCOUNTED, - FCLAW2D_TIMER_ADVANCE_STEPS_COUNTER, - FCLAW2D_TIMER_ELLIPTIC_GRIDS_COUNTER, - FCLAW2D_TIMER_GRIDS_PER_PROC, - FCLAW2D_TIMER_GRIDS_INTERIOR, - FCLAW2D_TIMER_GRIDS_LOCAL_BOUNDARY, - FCLAW2D_TIMER_GRIDS_REMOTE_BOUNDARY, - FCLAW2D_TIMER_REGRID_BUILD, - FCLAW2D_TIMER_REGRID_TAGGING, - FCLAW2D_TIMER_TIMESYNC, - FCLAW2D_TIMER_GHOSTPATCH_BUILD, - FCLAW2D_TIMER_PARTITION, - FCLAW2D_TIMER_PARTITION_BUILD, - FCLAW2D_TIMER_ADVANCE_STEP2, - FCLAW2D_TIMER_ADVANCE_B4STEP2, - FCLAW2D_TIMER_GHOSTFILL_COPY, - FCLAW2D_TIMER_GHOSTFILL_AVERAGE, - FCLAW2D_TIMER_GHOSTFILL_INTERP, - FCLAW2D_TIMER_GHOSTFILL_PHYSBC, - FCLAW2D_TIMER_GHOSTFILL_STEP1, - FCLAW2D_TIMER_GHOSTFILL_STEP2, - FCLAW2D_TIMER_GHOSTFILL_STEP3, - FCLAW2D_TIMER_NEIGHBOR_SEARCH, - FCLAW2D_TIMER_LOCAL_COMM, - FCLAW2D_TIMER_GLOBAL_COMM, - FCLAW2D_TIMER_CUDA_ALLOCATE, - FCLAW2D_TIMER_CUDA_MEMCOPY_H2H, - FCLAW2D_TIMER_CUDA_MEMCOPY_H2D, - FCLAW2D_TIMER_CUDA_MEMCOPY_D2H, - FCLAW2D_TIMER_EXTRA1, - FCLAW2D_TIMER_EXTRA2, - FCLAW2D_TIMER_EXTRA3, - FCLAW2D_TIMER_EXTRA4, - FCLAW2D_TIMER_COUNT -} fclaw2d_timer_names_t; + FCLAW_TIMER_NONE = -1, + FCLAW_TIMER_INIT, + FCLAW_TIMER_ADVANCE, + FCLAW_TIMER_ELLIPTIC_SOLVE, + FCLAW_TIMER_GHOSTFILL, + FCLAW_TIMER_REGRID, + FCLAW_TIMER_DIAGNOSTICS, + FCLAW_TIMER_OUTPUT, + FCLAW_TIMER_GHOSTPATCH_COMM, + FCLAW_TIMER_ADAPT_COMM, + FCLAW_TIMER_PARTITION_COMM, + FCLAW_TIMER_DIAGNOSTICS_COMM, + FCLAW_TIMER_CFL_COMM, + FCLAW_TIMER_WALLTIME, + FCLAW_TIMER_UNACCOUNTED, + FCLAW_TIMER_ADVANCE_STEPS_COUNTER, + FCLAW_TIMER_ELLIPTIC_GRIDS_COUNTER, + FCLAW_TIMER_GRIDS_PER_PROC, + FCLAW_TIMER_GRIDS_INTERIOR, + FCLAW_TIMER_GRIDS_LOCAL_BOUNDARY, + FCLAW_TIMER_GRIDS_REMOTE_BOUNDARY, + FCLAW_TIMER_REGRID_BUILD, + FCLAW_TIMER_REGRID_TAGGING, + FCLAW_TIMER_TIMESYNC, + FCLAW_TIMER_GHOSTPATCH_BUILD, + FCLAW_TIMER_PARTITION, + FCLAW_TIMER_PARTITION_BUILD, + FCLAW_TIMER_ADVANCE_STEP2, + FCLAW_TIMER_ADVANCE_B4STEP2, + FCLAW_TIMER_GHOSTFILL_COPY, + FCLAW_TIMER_GHOSTFILL_AVERAGE, + FCLAW_TIMER_GHOSTFILL_INTERP, + FCLAW_TIMER_GHOSTFILL_PHYSBC, + FCLAW_TIMER_GHOSTFILL_STEP1, + FCLAW_TIMER_GHOSTFILL_STEP2, + FCLAW_TIMER_GHOSTFILL_STEP3, + FCLAW_TIMER_NEIGHBOR_SEARCH, + FCLAW_TIMER_LOCAL_COMM, + FCLAW_TIMER_GLOBAL_COMM, + FCLAW_TIMER_CUDA_ALLOCATE, + FCLAW_TIMER_CUDA_MEMCOPY_H2H, + FCLAW_TIMER_CUDA_MEMCOPY_H2D, + FCLAW_TIMER_CUDA_MEMCOPY_D2H, + FCLAW_TIMER_EXTRA1, + FCLAW_TIMER_EXTRA2, + FCLAW_TIMER_EXTRA3, + FCLAW_TIMER_EXTRA4, + FCLAW_TIMER_COUNT +} fclaw_timer_names_t; /* Priority levels for printing timer statistics */ @@ -122,22 +122,22 @@ typedef struct double started, stopped; double cumulative; } -fclaw2d_timer_t; +fclaw_timer_t; -double fclaw2d_timer_wtime (void); +double fclaw_timer_wtime (void); -void fclaw2d_timer_init (fclaw2d_timer_t *timer); +void fclaw_timer_init (fclaw_timer_t *timer); -void fclaw2d_timer_start (fclaw2d_timer_t *timer); +void fclaw_timer_start (fclaw_timer_t *timer); -void fclaw2d_timer_stop (fclaw2d_timer_t *timer); +void fclaw_timer_stop (fclaw_timer_t *timer); -void fclaw2d_timer_start_threadsafe(fclaw2d_timer_t *timer); +void fclaw_timer_start_threadsafe(fclaw_timer_t *timer); -void fclaw2d_timer_stop_threadsafe(fclaw2d_timer_t *timer); +void fclaw_timer_stop_threadsafe(fclaw_timer_t *timer); /* Use keyword 'struct' to avoid circular dependencies */ -void fclaw2d_timer_report(struct fclaw2d_global* glob); +void fclaw2d_timer_report(struct fclaw_global* glob); #ifdef __cplusplus #if 0 diff --git a/src/fclaw2d_update_single_step.c b/src/fclaw_update_single_step.c similarity index 76% rename from src/fclaw2d_update_single_step.c rename to src/fclaw_update_single_step.c index 07eb4345a..e9e0b9b7c 100644 --- a/src/fclaw2d_update_single_step.c +++ b/src/fclaw_update_single_step.c @@ -23,40 +23,40 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include -#include -#include +#include +#include +#include static -void cb_single_step_count(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_single_step_count(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*) user; int *count = (int*) g->user; (*count)++; } static -void cb_single_step(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_single_step(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*) user; double maxcfl; - fclaw2d_single_step_data_t *ss_data = (fclaw2d_single_step_data_t *) g->user; + fclaw_single_step_data_t *ss_data = (fclaw_single_step_data_t *) g->user; double dt = ss_data->dt; double t = ss_data->t; - maxcfl = fclaw2d_patch_single_step_update(g->glob,this_patch, + maxcfl = fclaw_patch_single_step_update(g->glob,this_patch, this_block_idx, this_patch_idx,t,dt, &ss_data->buffer_data); @@ -70,13 +70,13 @@ void cb_single_step(fclaw2d_domain_t *domain, } -double fclaw2d_update_single_step(fclaw2d_global_t *glob, +double fclaw_update_single_step(fclaw_global_t *glob, int level, double t, double dt) { /* Iterate over every patch at this level */ - fclaw2d_single_step_data_t ss_data; + fclaw_single_step_data_t ss_data; ss_data.t = t; ss_data.dt = dt; ss_data.maxcfl = 0; @@ -85,16 +85,16 @@ double fclaw2d_update_single_step(fclaw2d_global_t *glob, /* If there are not grids at this level, we return CFL = 0 */ #if defined(_OPENMP) - fclaw2d_global_iterate_level_mthread(glob, level, + fclaw_global_iterate_level_mthread(glob, level, cb_single_step,(void *) &ss_data); #else /* Count number of grids to be updated in this call; not sure how this works in OpenMP. */ int count = 0; - fclaw2d_global_iterate_level(glob, level, cb_single_step_count,&count); + fclaw_global_iterate_level(glob, level, cb_single_step_count,&count); ss_data.buffer_data.total_count = count; - fclaw2d_global_iterate_level(glob, level, + fclaw_global_iterate_level(glob, level, cb_single_step,(void *) &ss_data); #endif diff --git a/src/fclaw2d_update_single_step.h b/src/fclaw_update_single_step.h similarity index 89% rename from src/fclaw2d_update_single_step.h rename to src/fclaw_update_single_step.h index fdc6a7560..4ce021ed9 100644 --- a/src/fclaw2d_update_single_step.h +++ b/src/fclaw_update_single_step.h @@ -27,8 +27,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Single step routines */ -#ifndef AMR_SINGLE_STEP_H -#define AMR_SINGLE_STEP_H +#ifndef FCLAW_UPDATE_SINGLE_STEP_H +#define FCLAW_UPDATE_SINGLE_STEP_H #ifdef __cplusplus @@ -39,12 +39,12 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; /** * @brief Buffer data for cudaclaw */ -typedef struct fclaw2d_single_step_buffer_data +typedef struct fclaw_single_step_buffer_data { /** Number of patches in buffer */ int total_count; @@ -52,13 +52,13 @@ typedef struct fclaw2d_single_step_buffer_data int iter; /** Buffer pointer */ void* user; -} fclaw2d_single_step_buffer_data_t; +} fclaw_single_step_buffer_data_t; /** * @brief Struct for single step iteration over patches */ -typedef struct fclaw2d_single_step_data +typedef struct fclaw_single_step_data { /** The time */ double t; @@ -67,8 +67,8 @@ typedef struct fclaw2d_single_step_data /** The maxcfl */ double maxcfl; /** The buffer data */ - fclaw2d_single_step_buffer_data_t buffer_data; -} fclaw2d_single_step_data_t; + fclaw_single_step_buffer_data_t buffer_data; +} fclaw_single_step_data_t; /** * @brief Advance the level using a single explicit time step. @@ -90,7 +90,7 @@ typedef struct fclaw2d_single_step_data * @param dt the time step * @return double the maxcfl */ -double fclaw2d_update_single_step(struct fclaw2d_global *glob, +double fclaw_update_single_step(struct fclaw_global *glob, int level, double t, double dt); diff --git a/src/fclaw2d_vtable.c b/src/fclaw_vtable.c similarity index 74% rename from src/fclaw2d_vtable.c rename to src/fclaw_vtable.c index 50ff239f2..bb6cc2ac5 100644 --- a/src/fclaw2d_vtable.c +++ b/src/fclaw_vtable.c @@ -24,16 +24,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include -#include -#include +#include +#include +#include -#include +#include static -fclaw2d_vtable_t* vt_new() +fclaw_vtable_t* vt_new() { - return (fclaw2d_vtable_t*) FCLAW_ALLOC_ZERO (fclaw2d_vtable_t, 1); + return (fclaw_vtable_t*) FCLAW_ALLOC_ZERO (fclaw_vtable_t, 1); } static @@ -42,9 +42,9 @@ void vt_destroy(void* vt) FCLAW_FREE (vt); } -fclaw2d_vtable_t* fclaw2d_vt(fclaw2d_global_t *glob) +fclaw_vtable_t* fclaw_vt(fclaw_global_t *glob) { - fclaw2d_vtable_t* vt = (fclaw2d_vtable_t*) + fclaw_vtable_t* vt = (fclaw_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fclaw2d"); FCLAW_ASSERT(vt != NULL); FCLAW_ASSERT(vt->is_set != 0); @@ -52,20 +52,20 @@ fclaw2d_vtable_t* fclaw2d_vt(fclaw2d_global_t *glob) } -void fclaw2d_after_regrid(fclaw2d_global_t *glob, int have_new_refinement) +void fclaw_after_regrid(fclaw_global_t *glob, int have_new_refinement) { - fclaw2d_vtable_t *fclaw_vt = fclaw2d_vt(glob); - if (fclaw_vt->after_regrid != NULL) + fclaw_vtable_t *fc_vt = fclaw_vt(glob); + if (fc_vt->after_regrid != NULL) { - fclaw_vt->after_regrid(glob, have_new_refinement); + fc_vt->after_regrid(glob, have_new_refinement); } } /* Initialize any settings that can be set here */ -void fclaw2d_vtable_initialize(fclaw2d_global_t *glob) +void fclaw_vtable_initialize(fclaw_global_t *glob) { - fclaw2d_vtable_t *vt = vt_new(); + fclaw_vtable_t *vt = vt_new(); vt->is_set = 1; diff --git a/src/fclaw2d_vtable.h b/src/fclaw_vtable.h similarity index 78% rename from src/fclaw2d_vtable.h rename to src/fclaw_vtable.h index fa0ba7d23..d77ea91ec 100644 --- a/src/fclaw2d_vtable.h +++ b/src/fclaw_vtable.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_VTABLE_H -#define FCLAW2D_VTABLE_H +#ifndef FCLAW_VTABLE_H +#define FCLAW_VTABLE_H #ifdef __cplusplus extern "C" @@ -39,8 +39,8 @@ extern "C" * @brief ForestClaw vtable */ -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; /* ---------------------------------- Typedefs ---------------------------------------- */ /** @@ -48,7 +48,7 @@ struct fclaw2d_patch; * * @param glob the global context */ -typedef void (*fclaw2d_problem_setup_t)(struct fclaw2d_global *glob); +typedef void (*fclaw_problem_setup_t)(struct fclaw_global *glob); /** * @brief Sets up common blocks in Fortran @@ -56,7 +56,7 @@ typedef void (*fclaw2d_problem_setup_t)(struct fclaw2d_global *glob); * @param glob the global context * @param iframe frame number */ -typedef void (*fclaw2d_output_frame_t)(struct fclaw2d_global * glob, int iframe); +typedef void (*fclaw_output_frame_t)(struct fclaw_global * glob, int iframe); /** * @brief Called after each regridding @@ -64,27 +64,27 @@ typedef void (*fclaw2d_output_frame_t)(struct fclaw2d_global * glob, int iframe) * @param glob the global context * @param have_new_refinement true if there is a new refinement */ -typedef void (*fclaw2d_after_regrid_t)(struct fclaw2d_global *glob, int have_new_refinement); +typedef void (*fclaw_after_regrid_t)(struct fclaw_global *glob, int have_new_refinement); /* ------------------------------------ vtable ---------------------------------------- */ /** * @brief vtable for general ForestClaw functions */ -typedef struct fclaw2d_vtable +typedef struct fclaw_vtable { /** @brief sets up common blocks in Fortran */ - fclaw2d_problem_setup_t problem_setup; + fclaw_problem_setup_t problem_setup; /** @brief called after each regridding */ - fclaw2d_after_regrid_t after_regrid; + fclaw_after_regrid_t after_regrid; /** @brief called for output */ - fclaw2d_output_frame_t output_frame; + fclaw_output_frame_t output_frame; /** @brief true if vtable is set */ int is_set; -} fclaw2d_vtable_t; +} fclaw_vtable_t; /** @@ -92,14 +92,14 @@ typedef struct fclaw2d_vtable * * @param glob the global context */ -fclaw2d_vtable_t* fclaw2d_vt(struct fclaw2d_global* glob); +fclaw_vtable_t* fclaw_vt(struct fclaw_global* glob); /** * @brief Initialize fclaw2d vtable * * @param glob the global context */ -void fclaw2d_vtable_initialize(struct fclaw2d_global* glob); +void fclaw_vtable_initialize(struct fclaw_global* glob); /** * @brief Called after each regridding @@ -107,7 +107,7 @@ void fclaw2d_vtable_initialize(struct fclaw2d_global* glob); * @param glob the global context * @param have_new_refinement true if there is a new refinement */ -void fclaw2d_after_regrid(struct fclaw2d_global *glob, int have_new_refinement); +void fclaw_after_regrid(struct fclaw_global *glob, int have_new_refinement); #ifdef __cplusplus #if 0 diff --git a/src/fclaw2d_vtable.h.TEST.cpp b/src/fclaw_vtable.h.TEST.cpp similarity index 57% rename from src/fclaw2d_vtable.h.TEST.cpp rename to src/fclaw_vtable.h.TEST.cpp index 4bda372c2..cced16238 100644 --- a/src/fclaw2d_vtable.h.TEST.cpp +++ b/src/fclaw_vtable.h.TEST.cpp @@ -23,49 +23,49 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include -TEST_CASE("fclaw2d_vtable_initialize stores two seperate vtables in two seperate globs") +TEST_CASE("fclaw_vtable_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); - fclaw2d_vtable_initialize(glob1); - fclaw2d_vtable_initialize(glob2); + fclaw_vtable_initialize(glob1); + fclaw_vtable_initialize(glob2); - CHECK_NE(fclaw2d_vt(glob1), fclaw2d_vt(glob2)); + CHECK_NE(fclaw_vt(glob1), fclaw_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } -TEST_CASE("fclaw2d_vtable_initialize sets is_set flag") +TEST_CASE("fclaw_vtable_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_global_t* glob = fclaw_global_new(); - fclaw2d_vtable_initialize(glob); + fclaw_vtable_initialize(glob); - CHECK_UNARY(fclaw2d_vt(glob)->is_set); + CHECK_UNARY(fclaw_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG -TEST_CASE("fclaw2d_vtable_initialize fails if called twice on a glob") +TEST_CASE("fclaw_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); - fclaw2d_vtable_initialize(glob1); - CHECK_SC_ABORTED(fclaw2d_vtable_initialize(glob1)); - fclaw2d_vtable_initialize(glob2); - CHECK_SC_ABORTED(fclaw2d_vtable_initialize(glob2)); + fclaw_vtable_initialize(glob1); + CHECK_SC_ABORTED(fclaw_vtable_initialize(glob1)); + fclaw_vtable_initialize(glob2); + CHECK_SC_ABORTED(fclaw_vtable_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/fclaw_wrap.h b/src/fclaw_wrap.h new file mode 100644 index 000000000..9186dd5d2 --- /dev/null +++ b/src/fclaw_wrap.h @@ -0,0 +1,168 @@ +/* +Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/** + * @file + * @brief Types needed for underlying wrapped types + * Most users will not need to include the file, unless doing something more advanced. + */ + + +#ifndef FCLAW_WRAP_H +#define FCLAW_WRAP_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} /* need this because indent is dumb */ +#endif +#endif + +/** + * @brief Callback wrapper struct for patch callbacks. + * + * This allows callbacks with dimension independent types to be + * called from dimension dependent code. + * + * This type should be passed in as the user pointer alongside + * @ref fclaw2d_patch_wrap_cb or @ref fclaw3d_patch_wrap_cb + * to the function that takes a dimensioned callback. + * + * @ref fclaw2d_patch_wrap_cb or @ref fclaw3d_patch_wrap_cb + * will then call the dimension independent callback specified in the struct, + * passing the user pointer specified in the struct. + * + */ +typedef struct fclaw_patch_wrap_user +{ + /** Dimension independent patch callback to call */ + fclaw_patch_callback_t pcb; + /** User pointer to pass to dimension independent callback */ + void* user; +} fclaw_patch_wrap_user_t; + +/** + * @brief Callback wrapper struct for transfer callbacks. + * + * This allows callbacks with dimension independent types to be + * called from dimension dependent code. + * + * This type should be passed in as the user pointer alongside + * @ref fclaw2d_transfer_wrap_cb or @ref fclaw3d_transfer_wrap_cb + * to the function that takes a dimensioned callback. + * + * @ref fclaw2d_transfer_wrap_cb or @ref fclaw3d_transfer_wrap_cb + * will then call the dimension independent callback specified in the struct, + * passing the user pointer specified in the struct. + * + */ +typedef struct fclaw_transfer_wrap_user +{ + /** Dimension independent transfer callback to call */ + fclaw_transfer_callback_t tcb; + /** User pointer to pass to dimension independent callback */ + void *user; +} fclaw_transfer_wrap_user_t; + +/** + * @brief Callback wrapper struct for match callbacks. + * + * This allows callbacks with dimension independent types to be + * called from dimension dependent code. + * + * This type should be passed in as the user pointer alongside + * @ref fclaw2d_match_wrap_cb or @ref fclaw3d_match_wrap_cb + * to the function that takes a dimensioned callback. + * + * @ref fclaw2d_match_wrap_cb or @ref fclaw3d_match_wrap_cb + * will then call the dimension independent callback specified in the struct, + * passing the user pointer specified in the struct. + * + */ +typedef struct fclaw_match_wrap_user +{ + /** Dimension independent match callback to call */ + fclaw_match_callback_t mcb; + /** User pointer to pass to dimension independent callback */ + void *user; +} fclaw_match_wrap_user_t; + +/** + * @brief Callback wrapper struct for match callbacks. + * + * This allows callbacks with dimension independent types to be + * called from dimension dependent code. + * + * This type should be passed in as the user pointer alongside + * @ref fclaw2d_integrate_ray_wrap_cb or @ref fclaw3d_integrate_ray_wrap_cb + * to the function that takes a dimensioned callback. + * + * @ref fclaw2d_integrate_ray_wrap_cb or @ref fclaw3d_integrate_ray_wrap_cb + * will then call the dimension independent callback specified in the struct, + * passing the user pointer specified in the struct. + * + */ +typedef struct fclaw_intersect_wrap_user +{ + /** Dimension independent integrate ray callback to call */ + fclaw_integrate_ray_t intersect; + /** User pointer to pass to dimension independent callback */ + void *user; +} fclaw_intersect_wrap_user_t; + +/** + * @brief Callback wrapper struct for match callbacks. + * + * This allows callbacks with dimension independent types to be + * called from dimension dependent code. + * + * This type should be passed in as the user pointer alongside + * @ref fclaw2d_iterpolate_point_wrap_cb or @ref fclaw3d_iterpolate_point_wrap_cb + * to the function that takes a dimensioned callback. + * + * @ref fclaw2d_iterpolate_point_wrap_cb or @ref fclaw3d_iterpolate_point_wrap_cb + * will then call the dimension independent callback specified in the struct, + * passing the user pointer specified in the struct. + * + */ +typedef struct fclaw_interpolate_point_wrap_user +{ + /** Dimension independent interpolate callback to call */ + fclaw_interpolate_point_t interpolate; + /** User pointer to pass to dimension independent callback */ + void *user; +} fclaw_interpolate_point_wrap_user_t; + +#ifdef __cplusplus +#if 0 +{ +#endif +} +#endif + +#endif diff --git a/src/forestclaw.c b/src/forestclaw.c new file mode 100644 index 000000000..35031d05b --- /dev/null +++ b/src/forestclaw.c @@ -0,0 +1,1058 @@ +/* +Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include +#include + +int fclaw_patch_edge_neighbors (fclaw_domain_t * domain, + int blockno, int patchno, int edgeno, + int *rproc, int *rblockno, int *rpatchno, + int *redge, + fclaw_patch_relation_t * neighbor_size) +{ + FCLAW_ASSERT(domain->refine_dim == 3); + return fclaw3d_patch_edge_neighbors(domain->d3,blockno,patchno,edgeno, + rproc,rblockno,rpatchno,redge, + (fclaw3d_patch_relation_t*) neighbor_size); +} +int +fclaw_domain_dimension (const fclaw_domain_t * domain) +{ + return domain->refine_dim; +} + +int +fclaw_domain_refine_factor (const fclaw_domain_t * domain) +{ + return (domain->refine_dim == 2) ? P4EST_CHILDREN/2 : P8EST_CHILDREN/2; +} + +int +fclaw_domain_num_siblings (const fclaw_domain_t * domain) +{ + return (domain->refine_dim == 2) ? P4EST_CHILDREN : P8EST_CHILDREN; +} + +int +fclaw_domain_num_faces (const fclaw_domain_t * domain) +{ + return (domain->refine_dim == 2) ? P4EST_FACES : P8EST_FACES; +} + +int +fclaw_domain_num_edges (const fclaw_domain_t * domain) +{ + return (domain->refine_dim == 2) ? 0 : P8EST_EDGES; +} + +int +fclaw_domain_num_corners (const fclaw_domain_t * domain) +{ + return (domain->refine_dim == 2) ? P4EST_CHILDREN : P8EST_CHILDREN; +} + +int +fclaw_domain_num_face_corners (const fclaw_domain_t * domain) +{ + return (domain->refine_dim == 2) ? P4EST_HALF : P8EST_HALF; +} + +int +fclaw_domain_num_orientations (const fclaw_domain_t * domain) +{ + return (domain->refine_dim == 2) ? (P4EST_FACES * P4EST_HALF) : (P8EST_FACES * P8EST_HALF); +} + +void +fclaw_domain_edge_faces (const fclaw_domain_t * domain, + int iedge, int faces[2]) +{ + FCLAW_ASSERT (0 <= iedge && iedge < fclaw_domain_num_edges(domain)); + faces[0] = p8est_edge_faces[iedge][0]; + faces[1] = p8est_edge_faces[iedge][1]; +} + +void +fclaw_domain_corner_faces (const fclaw_domain_t * domain, + int icorner, int faces[3]) +{ + if(domain->refine_dim == 2) + { + return fclaw2d_domain_corner_faces(domain->d2, icorner, faces); + } + else if(domain->refine_dim == 3) + { + return fclaw3d_domain_corner_faces(domain->d3, icorner, faces); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +int +fclaw_patch_corner_dimension (const fclaw_patch_t * patch, int cornerno) +{ + if(patch->refine_dim == 2) + { + return fclaw2d_patch_corner_dimension(patch->d2, cornerno); + } + else if(patch->refine_dim == 3) + { + return fclaw3d_patch_corner_dimension(patch->d3, cornerno); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +int +fclaw_patch_childid (const fclaw_patch_t * patch) +{ + if(patch->refine_dim == 2) + { + return fclaw2d_patch_childid(patch->d2); + } + else if(patch->refine_dim == 3) + { + return fclaw3d_patch_childid(patch->d3); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +int +fclaw_patch_is_first_sibling (const fclaw_patch_t * patch) +{ + if(patch->refine_dim == 2) + { + return fclaw2d_patch_is_first_sibling(patch->d2); + } + else if(patch->refine_dim == 3) + { + return fclaw3d_patch_is_first_sibling(patch->d3); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +int +fclaw_patch_is_ghost (const fclaw_patch_t * patch) +{ + if(patch->refine_dim == 2) + { + return fclaw2d_patch_is_ghost(patch->d2); + } + else if(patch->refine_dim == 3) + { + return fclaw3d_patch_is_ghost(patch->d3); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +int +fclaw_patch_get_ghost_block(const fclaw_patch_t * patch) +{ + FCLAW_ASSERT(fclaw_patch_is_ghost(patch)); + if(patch->refine_dim == 2) + { + return patch->d2->u.blockno; + } + else if(patch->refine_dim == 3) + { + return patch->d3->u.blockno; + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +int +fclaw_patch_boundary_type(fclaw_domain_t *domain, int blockno, int patchno, int boundaries[]) +{ + if(domain->refine_dim == 2) + { + return fclaw2d_patch_boundary_type(domain->d2,blockno,patchno,boundaries); + } + else if (domain->refine_dim == 3) + { + return fclaw3d_patch_boundary_type(domain->d3,blockno,patchno,boundaries); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +int +fclaw_patch_normal_match(fclaw_domain_t *domain, int blockno, int patchno, int faceno) +{ + if(domain->refine_dim == 2) + { + return fclaw2d_patch_normal_match(domain->d2,blockno,patchno,faceno); + } + else if (domain->refine_dim == 3) + { + return fclaw3d_patch_normal_match(domain->d3,blockno,patchno,faceno); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +fclaw_patch_relation_t +fclaw_patch_face_neighbors(fclaw_domain_t *domain, int blockno, int patchno, int faceno, int rproc[], int *rblockno, int rpatchno[], int *rfaceno) +{ + if(domain->refine_dim == 2) + { + return (fclaw_patch_relation_t) fclaw2d_patch_face_neighbors(domain->d2,blockno,patchno,faceno,rproc,rblockno,rpatchno,rfaceno); + } + else if (domain->refine_dim == 3) + { + return (fclaw_patch_relation_t) fclaw3d_patch_face_neighbors(domain->d3,blockno,patchno,faceno,rproc,rblockno,rpatchno,rfaceno); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void +fclaw_patch_face_swap (int dim, int *faceno, int *rfaceno) +{ + if(dim == 2) + { + fclaw2d_patch_face_swap(faceno,rfaceno); + } + else if (dim == 3) + { + fclaw3d_patch_face_swap(faceno,rfaceno); + } + else + { + fclaw_abortf("fclaw_patch_face_swap : dim = %d not supported\n",dim); + } +} + +void +fclaw_patch_face_transformation (int dim, int faceno, int rfaceno, + int ftransform[]) +{ + if(dim == 2) + { + fclaw2d_patch_face_transformation(faceno,rfaceno,ftransform); + } + else if(dim == 3) + { + fclaw3d_patch_face_transformation(faceno,rfaceno,ftransform); + } + else + { + fclaw_abortf("fclaw_patch_face_transformation : dim = %d not supported\n",dim); + } +} + +void +fclaw_patch_face_transformation_block (int dim, int ftransform[], + int sameblock) +{ + if(dim == 2) + { + fclaw2d_patch_face_transformation_block(ftransform, sameblock); + } + else if(dim == 3) + { + fclaw3d_patch_face_transformation_block(ftransform, sameblock); + } + else + { + fclaw_abortf("fclaw_patch_face_transformation_block : dim = %d not supported\n",dim); + } +} + +void +fclaw_patch_face_transformation_intra (int dim, int ftransform[]) +{ + if(dim == 2) + { + fclaw2d_patch_face_transformation_intra(ftransform); + } + else if(dim == 3) + { + fclaw3d_patch_face_transformation_intra(ftransform); + } + else + { + fclaw_abortf("fclaw_patch_face_transformation_intra : dim = %d not supported\n",dim); + } +} + +int +fclaw_patch_face_transformation_valid (int dim, const int ftransform[]) +{ + if(dim == 2) + { + return fclaw2d_patch_face_transformation_valid(ftransform); + } + else if(dim == 3) + { + return fclaw3d_patch_face_transformation_valid(ftransform); + } + else + { + fclaw_abortf("fclaw_patch_face_transformation_valid : dim = %d not supported\n",dim); + } +} + +void +fclaw_patch_2d_transform_face (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + const int ftransform[], + int mx, int my, int based, int *i, int *j) +{ + FCLAW_ASSERT(ipatch->refine_dim == 2); + FCLAW_ASSERT(opatch->refine_dim == 2); + fclaw2d_patch_transform_face(ipatch->d2,opatch->d2,ftransform,mx,my,based,i,j); +} + +void +fclaw_patch_2d_transform_face2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + const int ftransform[], + int mx, int my, int based, int i[], + int j[]) +{ + FCLAW_ASSERT(ipatch->refine_dim == 2); + FCLAW_ASSERT(opatch->refine_dim == 2); + fclaw2d_patch_transform_face2(ipatch->d2,opatch->d2,ftransform,mx,my,based,i,j); +} + +void +fclaw_patch_3d_transform_face (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + const int ftransform[], + int mx, int my, int mz, int based, + int *i, int *j, int *k) +{ + FCLAW_ASSERT(ipatch->refine_dim == 3); + FCLAW_ASSERT(opatch->refine_dim == 3); + fclaw3d_patch_transform_face(ipatch->d3,opatch->d3,ftransform,mx,my,mz,based,i,j,k); +} + +void +fclaw_patch_3d_transform_face2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + const int ftransform[], + int mx, int my, int mz, int based, + int i[], int j[], int k[]) +{ + FCLAW_ASSERT(ipatch->refine_dim == 3); + FCLAW_ASSERT(opatch->refine_dim == 3); + fclaw3d_patch_transform_face2(ipatch->d3,opatch->d3,ftransform,mx,my,mz,based,i,j,k); +} + + +void fclaw_patch_3d_transform_edge (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int iedge, int is_block_boundary, + int mx, int my, int mz, + int based, int *i, int *j, int *k) +{ + FCLAW_ASSERT(ipatch->refine_dim == 3); + FCLAW_ASSERT(opatch->refine_dim == 3); + fclaw3d_patch_transform_edge(ipatch->d3,opatch->d3,iedge,is_block_boundary, + mx,my,mz,based,i,j,k); +} + +void fclaw_patch_3d_transform_edge2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int iedge, int is_block_boundary, + int mx, int my, int mz, int based, + int i[], int j[], int k[]) +{ + fclaw3d_patch_transform_edge2(ipatch->d3,opatch->d3,iedge,is_block_boundary, + mx,my,mz,based,i,j,k); +} + +int +fclaw_patch_corner_neighbors(fclaw_domain_t *domain, int blockno, int patchno, int cornerno, int *rproc, int *rblockno, int *rpatchno, int *rcorner, fclaw_patch_relation_t *neighbor_size) +{ + if(domain->refine_dim == 2) + { + fclaw2d_patch_relation_t neighbor_size2d; + int retval = fclaw2d_patch_corner_neighbors(domain->d2,blockno,patchno,cornerno,rproc,rblockno,rpatchno,rcorner,&neighbor_size2d); + *neighbor_size = (fclaw_patch_relation_t) neighbor_size2d; + return retval; + } + else if (domain->refine_dim == 3) + { + fclaw3d_patch_relation_t neighbor_size3d; + int retval = fclaw3d_patch_corner_neighbors(domain->d3,blockno,patchno,cornerno,rproc,rblockno,rpatchno,rcorner,&neighbor_size3d); + *neighbor_size = (fclaw_patch_relation_t) neighbor_size3d; + return retval; + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void fclaw_patch_corner_swap (int dim, int *cornerno, int *rcornerno) +{ + if(dim == 2) + { + fclaw2d_patch_corner_swap(cornerno, rcornerno); + } + else if(dim == 3) + { + fclaw3d_patch_corner_swap(cornerno, rcornerno); + } + else + { + fclaw_abortf("fclaw_patch_corner_swap : dim = %d not supported\n",dim); + } +} + +void fclaw_patch_2d_transform_corner (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int icorner, int is_block_boundary, + int mx, int my, + int based, int *i, int *j) +{ + FCLAW_ASSERT(ipatch->refine_dim == 2); + FCLAW_ASSERT(opatch->refine_dim == 2); + fclaw2d_patch_transform_corner(ipatch->d2,opatch->d2,icorner,is_block_boundary, + mx,my,based,i,j); +} + +void fclaw_patch_2d_transform_corner2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int icorner, int is_block_boundary, + int mx, int my, int based, + int i[], int j[]) +{ + FCLAW_ASSERT(ipatch->refine_dim == 2); + FCLAW_ASSERT(opatch->refine_dim == 2); + fclaw2d_patch_transform_corner2(ipatch->d2,opatch->d2,icorner,is_block_boundary, + mx,my,based,i,j); +} + +/** Transform a patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the two patches are of the SAME size and that the + * patches lie in coordinate systems with the same orientation. + * It is LEGAL to call this function for both local and ghost patches. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] icorner Corner number of this patch to transform across. + * This function assumes ocorner == icorner ^ 7, so + * ocorner is the opposite corner of icorner. + * \param [in] is_block_boundary Set to true for a block corner. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * \param [in] mz Number of cells along z direction of patch. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i Integer coordinate along x-axis in \a based .. \a mx. + * \param [in,out] j Integer coordinate along y-axis in \a based .. \a my. + * \param [in,out] k Integer coordinate along z-axis in \a based .. \a mz. + */ +void fclaw_patch_3d_transform_corner (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int icorner, int is_block_boundary, + int mx, int my, int mz, + int based, int *i, int *j, int *k) +{ + FCLAW_ASSERT(ipatch->refine_dim == 3); + FCLAW_ASSERT(opatch->refine_dim == 3); + fclaw3d_patch_transform_corner(ipatch->d3,opatch->d3,icorner,is_block_boundary, + mx,my,mz,based,i,j,k); +} + +void fclaw_patch_3d_transform_corner2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int icorner, int is_block_boundary, + int mx, int my, int mz, int based, + int i[], int j[], int k[]) +{ + FCLAW_ASSERT(ipatch->refine_dim == 3); + FCLAW_ASSERT(opatch->refine_dim == 3); + fclaw3d_patch_transform_corner2(ipatch->d3,opatch->d3,icorner,is_block_boundary, + mx,my,mz,based,i,j,k); +} + +void +fclaw_domain_iterate_level (fclaw_domain_t * domain, int level, + fclaw_patch_callback_t pcb, void *user) +{ + fclaw_patch_wrap_user_t wrap; + wrap.pcb = pcb; + wrap.user = user; + + if (domain->refine_dim == 2) + { + fclaw2d_domain_iterate_level(domain->d2,level,fclaw2d_patch_wrap_cb, + &wrap); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_iterate_level(domain->d3,level,fclaw3d_patch_wrap_cb, + &wrap); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void +fclaw_domain_iterate_patches (fclaw_domain_t * domain, + fclaw_patch_callback_t pcb, void *user) +{ + fclaw_patch_wrap_user_t wrap; + wrap.pcb = pcb; + wrap.user = user; + + if(domain->refine_dim == 2) + { + fclaw2d_domain_iterate_patches(domain->d2,fclaw2d_patch_wrap_cb, + &wrap); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_iterate_patches(domain->d3,fclaw3d_patch_wrap_cb, + &wrap); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void +fclaw_domain_iterate_families (fclaw_domain_t * domain, + fclaw_patch_callback_t pcb, void *user) +{ + fclaw_patch_wrap_user_t wrap; + wrap.pcb = pcb; + wrap.user = user; + + if(domain->refine_dim == 2) + { + fclaw2d_domain_iterate_families(domain->d2,fclaw2d_patch_wrap_cb, + &wrap); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_iterate_families(domain->d3,fclaw3d_patch_wrap_cb, + &wrap); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + + + + + +#define FCLAW2D_DOMAIN_TAG_SERIALIZE 4526 +#define FCLAW3D_DOMAIN_TAG_SERIALIZE 4527 + +int get_tag(int dim) +{ + if(dim == 2) + { + return FCLAW2D_DOMAIN_TAG_SERIALIZE; + } + else + { + return FCLAW3D_DOMAIN_TAG_SERIALIZE; + } +} + +double +fclaw_domain_global_maximum (fclaw_domain_t * domain, double d) +{ + int mpiret; + double gd; + + mpiret = sc_MPI_Allreduce (&d, &gd, 1, sc_MPI_DOUBLE, sc_MPI_MAX, + domain->mpicomm); + SC_CHECK_MPI (mpiret); + + return gd; +} + +double +fclaw_domain_global_sum (fclaw_domain_t * domain, double d) +{ + int mpiret; + double gd; + + mpiret = sc_MPI_Allreduce (&d, &gd, 1, sc_MPI_DOUBLE, sc_MPI_SUM, + domain->mpicomm); + SC_CHECK_MPI (mpiret); + + return gd; +} + +void +fclaw_domain_barrier (fclaw_domain_t * domain) +{ + int mpiret; + + mpiret = sc_MPI_Barrier (domain->mpicomm); + SC_CHECK_MPI (mpiret); +} + +void +fclaw_domain_serialization_enter (fclaw_domain_t * domain) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_serialization_enter(domain->d2); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_serialization_enter(domain->d3); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void +fclaw_domain_serialization_leave (fclaw_domain_t * domain) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_serialization_leave(domain->d2); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_serialization_leave(domain->d3); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void +fclaw_domain_set_refinement (fclaw_domain_t * domain, + int smooth_refine, int smooth_level, + int coarsen_delay) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_set_refinement(domain->d2,smooth_refine,smooth_level, + coarsen_delay); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_set_refinement(domain->d3,smooth_refine,smooth_level, + coarsen_delay); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void +fclaw_domain_set_partitioning(fclaw_domain_t *domain, int partition_for_coarsening) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_set_partitioning(domain->d2,partition_for_coarsening); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_set_partitioning(domain->d3,partition_for_coarsening); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void +fclaw_patch_mark_refine(fclaw_domain_t *domain, int blockno, int patchno) +{ + if(domain->refine_dim == 2) + { + fclaw2d_patch_mark_refine(domain->d2,blockno,patchno); + } + else if (domain->refine_dim == 3) + { + fclaw3d_patch_mark_refine(domain->d3,blockno,patchno); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void +fclaw_patch_mark_coarsen(fclaw_domain_t *domain, int blockno, int patchno) +{ + if(domain->refine_dim == 2) + { + fclaw2d_patch_mark_coarsen(domain->d2,blockno,patchno); + } + else if (domain->refine_dim == 3) + { + fclaw3d_patch_mark_coarsen(domain->d3,blockno,patchno); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void +fclaw_domain_iterate_adapted(fclaw_domain_t *old_domain, fclaw_domain_t *new_domain, fclaw_match_callback_t mcb, void *user) +{ + FCLAW_ASSERT(old_domain->refine_dim == new_domain->refine_dim); + + fclaw_match_wrap_user_t mcb_wrap_user; + mcb_wrap_user.mcb = mcb; + mcb_wrap_user.user = user; + + if(old_domain->refine_dim == 2) + { + fclaw2d_domain_iterate_adapted(old_domain->d2, + new_domain->d2, + fclaw2d_match_wrap_cb, + &mcb_wrap_user); + } + else if (old_domain->refine_dim == 3) + { + fclaw3d_domain_iterate_adapted(old_domain->d3, + new_domain->d3, + fclaw3d_match_wrap_cb, + &mcb_wrap_user); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void fclaw_domain_allocate_before_partition(fclaw_domain_t *domain, size_t data_size, void ***patch_data) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_allocate_before_partition(domain->d2,data_size,patch_data); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_allocate_before_partition(domain->d3,data_size,patch_data); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void fclaw_domain_retrieve_after_partition(fclaw_domain_t *domain, void ***patch_data) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_retrieve_after_partition(domain->d2,patch_data); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_retrieve_after_partition(domain->d3,patch_data); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void fclaw_domain_iterate_partitioned(fclaw_domain_t *old_domain, fclaw_domain_t *new_domain, fclaw_transfer_callback_t tcb, void *user) +{ + FCLAW_ASSERT(old_domain->refine_dim == new_domain->refine_dim); + + fclaw_transfer_wrap_user_t wrap; + wrap.tcb = tcb; + wrap.user = user; + + if(old_domain->refine_dim == 2) + { + fclaw2d_domain_iterate_partitioned(old_domain->d2, + new_domain->d2, + fclaw2d_transfer_wrap_cb, + &wrap); + } + else if(old_domain->refine_dim == 3) + { + fclaw3d_domain_iterate_partitioned(old_domain->d3, + new_domain->d3, + fclaw3d_transfer_wrap_cb, + &wrap); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void fclaw_domain_free_after_partition(fclaw_domain_t *domain, void ***patch_data) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_free_after_partition(domain->d2,patch_data); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_free_after_partition(domain->d3,patch_data); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +fclaw_domain_exchange_t * +fclaw_domain_allocate_before_exchange (fclaw_domain_t * domain, + size_t data_size) +{ + FCLAW_ASSERT(domain->refine_dim == 2 || domain->refine_dim == 3); + + fclaw_domain_exchange_t * e = FCLAW_ALLOC(fclaw_domain_exchange_t, 1); + e->refine_dim = domain->refine_dim; + + if(domain->refine_dim == 2) + { + e->d2 = fclaw2d_domain_allocate_before_exchange(domain->d2,data_size); + e->d3 = NULL; + } + else + { + e->d2 = NULL; + e->d3 = fclaw3d_domain_allocate_before_exchange(domain->d3,data_size); + } + + return e; +} + +void fclaw_domain_ghost_exchange (fclaw_domain_t * domain, + fclaw_domain_exchange_t *e, + int exchange_minlevel, + int exchange_maxlevel) +{ + FCLAW_ASSERT(domain->refine_dim == 2 || domain->refine_dim == 3); + FCLAW_ASSERT(e->refine_dim == domain->refine_dim); + + if(domain->refine_dim == 2) + { + fclaw2d_domain_ghost_exchange(domain->d2, + e->d2, + exchange_minlevel, + exchange_maxlevel); + } + else + { + fclaw3d_domain_ghost_exchange(domain->d3, + e->d3, + exchange_minlevel, + exchange_maxlevel); + } +} + +void fclaw_domain_ghost_exchange_begin (fclaw_domain_t * domain, + fclaw_domain_exchange_t * e, + int exchange_minlevel, + int exchange_maxlevel) +{ + FCLAW_ASSERT(domain->refine_dim == 2 || domain->refine_dim == 3); + FCLAW_ASSERT(e->refine_dim == domain->refine_dim); + + if(domain->refine_dim == 2) + { + fclaw2d_domain_ghost_exchange_begin(domain->d2, + e->d2, + exchange_minlevel, + exchange_maxlevel); + } + else + { + fclaw3d_domain_ghost_exchange_begin(domain->d3, + e->d3, + exchange_minlevel, + exchange_maxlevel); + } +} + +void fclaw_domain_ghost_exchange_end (fclaw_domain_t * domain, + fclaw_domain_exchange_t * e) +{ + FCLAW_ASSERT(domain->refine_dim == 2 || domain->refine_dim == 3); + FCLAW_ASSERT(e->refine_dim == domain->refine_dim); + + if(domain->refine_dim == 2) + { + fclaw2d_domain_ghost_exchange_end(domain->d2, + e->d2); + } + else + { + fclaw3d_domain_ghost_exchange_end(domain->d3, + e->d3); + } +} + +void fclaw_domain_free_after_exchange (fclaw_domain_t * domain, + fclaw_domain_exchange_t * e) +{ + FCLAW_ASSERT(domain->refine_dim == 2 || domain->refine_dim == 3); + FCLAW_ASSERT(e->refine_dim == domain->refine_dim); + + if(domain->refine_dim == 2) + { + fclaw2d_domain_free_after_exchange(domain->d2, + e->d2); + } + else + { + fclaw3d_domain_free_after_exchange(domain->d3, + e->d3); + } + + FCLAW_FREE(e); +} + +fclaw_domain_indirect_t + * fclaw_domain_indirect_begin (fclaw_domain_t * domain) +{ + if(domain->refine_dim == 2) + { + return (fclaw_domain_indirect_t*) fclaw2d_domain_indirect_begin(domain->d2); + } + else if (domain->refine_dim == 3) + { + return (fclaw_domain_indirect_t*) fclaw3d_domain_indirect_begin(domain->d3); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void fclaw_domain_indirect_end (fclaw_domain_t * domain, + fclaw_domain_indirect_t* indirect) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_indirect_end(domain->d2,(fclaw2d_domain_indirect_t*)indirect); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_indirect_end(domain->d3,(fclaw3d_domain_indirect_t*)indirect); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +fclaw_patch_relation_t +fclaw_domain_indirect_face_neighbors (fclaw_domain_t * domain, + fclaw_domain_indirect_t * indirect, + int ghostno, int faceno, int rproc[], + int *rblockno, int rpatchno[], + int *rfaceno) +{ + if(domain->refine_dim == 2) + { + return (fclaw_patch_relation_t) fclaw2d_domain_indirect_face_neighbors(domain->d2, + (fclaw2d_domain_indirect_t*)indirect, + ghostno,faceno,rproc,rblockno, + rpatchno,rfaceno); + } + else if (domain->refine_dim == 3) + { + return (fclaw_patch_relation_t) fclaw3d_domain_indirect_face_neighbors(domain->d3, + (fclaw3d_domain_indirect_t*)indirect, + ghostno,faceno,rproc,rblockno, + rpatchno,rfaceno); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + +void fclaw_domain_indirect_destroy (fclaw_domain_t * domain, + fclaw_domain_indirect_t * indirect) +{ + if(domain->refine_dim == 2) + { + fclaw2d_domain_indirect_destroy(domain->d2,(fclaw2d_domain_indirect_t*)indirect); + } + else if (domain->refine_dim == 3) + { + fclaw3d_domain_indirect_destroy(domain->d3,(fclaw3d_domain_indirect_t*)indirect); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} + + +int fclaw_domain_is_meta (fclaw_domain_t * domain) +{ + if(domain->refine_dim == 2) + { + return fclaw2d_domain_is_meta(domain->d2); + } + else if (domain->refine_dim == 3) + { + return fclaw3d_domain_is_meta(domain->d3); + } + else + { + SC_ABORT_NOT_REACHED(); + } +} diff --git a/src/forestclaw.h b/src/forestclaw.h new file mode 100644 index 000000000..218ac3106 --- /dev/null +++ b/src/forestclaw.h @@ -0,0 +1,1201 @@ +/* +Copyright (c) 2012-2024 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FORESTCLAW_H +#define FORESTCLAW_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} /* need this because indent is dumb */ +#endif +#endif + +/** + * @file + * Main dimension independent ForestClaw structures and routines + */ + +/* ---------------------------------------------------------------------- */ +/// @name Data Types +/* ---------------------------------------------------------------------- */ +///@{ + +typedef struct fclaw_domain_persist fclaw_domain_persist_t; +/** Typedef for fclaw_domain */ +typedef struct fclaw_domain fclaw_domain_t; +/** Typedef for fclaw_block */ +typedef struct fclaw_block fclaw_block_t; +/** Typedef for fclaw_patch */ +typedef struct fclaw_patch fclaw_patch_t; + +typedef struct fclaw_domain_exchange fclaw_domain_exchange_t; +/* Data structure for storing indirect parallel neighbor information */ +typedef struct fclaw_domain_indirect fclaw_domain_indirect_t; + +/* forward declare dimensioned patch types */ +struct fclaw2d_patch; +struct fclaw3d_patch; + +/** + * @brief The metadata structure for a forest leaf, which is a forestclaw patch. + * The patch may be either a process-local patch or a ghost patch. + */ +struct fclaw_patch +{ + int refine_dim; /**< dimension */ + struct fclaw2d_patch* d2; /**< 2D patch */ + struct fclaw3d_patch* d3; /**< 3D patch */ + + /** @{ @brief left/right coordinate */ + double xlower, xupper; + /** @} */ + /** @{ @brief front/back coordinate */ + double ylower, yupper; + /** @} */ + /** @{ @brief bottom/top coordinate. For 2D refinement, these are always set to 0,1 respectively. */ + double zlower, zupper; + /** @} */ + int level; /**< 0 is root, increases if refined */ + + void *user; /**< User Pointer */ +}; + +/* forward declare dimensioned block types */ +struct fclaw2d_block; +struct fclaw3d_block; + +/** + * @brief Data Structure for a block + */ +typedef struct fclaw_block +{ + int refine_dim; /**< dimension */ + struct fclaw2d_block *d2; /**< 2D block */ + struct fclaw3d_block *d3; /**< 3D block */ + + int num_patches; /**< local patches in this block */ + int num_patches_before; /**< in all previous blocks */ + double* vertices; /**< for each block corner, the xyz coordinates + of the connectivity structure */ + fclaw_patch_t *patches; /**< The patches for this block */ + void *user; /**< User pointer */ +} fclaw_block_t; + +/* forward declare dimensioned domain types */ +struct fclaw2d_domain; +struct fclaw3d_domain; + +/** + * @brief The domain structure is a collection of blocks + * + * The domain structure gives a processor local view of the grid hierarchy. + * Unless explicitly noted otherwise, all variables are processor local, + * i.e., they are generally different on each processor. + * Variables that are synchronized and shared between processors + * are denoted *global*. + */ +struct fclaw_domain +{ + int refine_dim; /**< dimension */ + struct fclaw2d_domain *d2; /**< 2D domain */ + struct fclaw3d_domain *d3; /**< 3D domain */ + + sc_MPI_Comm mpicomm; /**< MPI communicator */ + int mpisize; /**< MPI size */ + int mpirank; /**< MPI rank */ + + int local_num_patches; /**< sum of patches over all blocks on this proc */ + int local_max_patches; /**< maximum over all procs of local_num_patches */ + /** @{ */ + /** Local to proc. If this proc doesn't + store any patches at all, we set + local_maxlevel < 0 <= local_minlevel. */ + int local_minlevel; + int local_maxlevel; + /** @} */ + int64_t global_num_patches; /**< sum of local_num_patches over all procs */ + int64_t global_num_patches_before; /**< Number of patches on lower procs */ + int global_minlevel; /**< global min level */ + int global_maxlevel; /**< global max level */ + + int num_blocks; /**< Total number of blocks. */ + fclaw_block_t *blocks; /**< allocated storage */ + int num_exchange_patches; /**< number my patches relevant to other procs. + Identified by this expression to be true: + (patch->flags & + FCLAW2D_PATCH_ON_PARALLEL_BOUNDARY) */ + fclaw_patch_t **exchange_patches; /**< explicitly store exchange patches */ + int num_ghost_patches; /**< number of off-proc patches relevant to this proc */ + fclaw_patch_t *ghost_patches; /**< array of off-proc patches */ + + /* formerly in domain_data_t */ + + int count_set_patch; + int count_delete_patch; + + fclaw_domain_exchange_t* exchange; + fclaw_domain_indirect_t* indirect; + + void *user; /**< user data pointer */ +}; + +///@} +/* ---------------------------------------------------------------------- */ +/// @name Topological Properties +/* ---------------------------------------------------------------------- */ +///@{ + +/** Return the space dimension. */ +int fclaw_domain_dimension (const fclaw_domain_t * domain); + +/** Return the number of siblings a node has in a domain. + * 4 in 2d, 8 in 3d. */ +int fclaw_domain_num_siblings (const fclaw_domain_t * domain); + +/** Return the number of faces of a cube: 4 in 2D, 6 in 3D. */ +int fclaw_domain_num_faces (const fclaw_domain_t * domain); + +/** Return the number of edges of a cube: 0 in 2D, 12 in 3D. */ +int fclaw_domain_num_edges (const fclaw_domain_t * domain); + +/** Return the number of corners of a cube: 4 in 2D, 8 in 3D. + * This is the same as the number of siblings in a refined tree. */ +int fclaw_domain_num_corners (const fclaw_domain_t * domain); + +/** Return the number of corners of a cube face: 2 in 2D, 4 in 3D. + * This is the same as the number of refined (smaller) face neighbors. */ +int fclaw_domain_num_face_corners (const fclaw_domain_t * domain); + +/** Return the number of possible orientations of a cube face. + * This is mostly used for internal encodings. + */ +int fclaw_domain_num_orientations (const fclaw_domain_t * domain); + +/** Find the numbers of faces adjacent ot a cube edge: 0 in 2D, 3 in 3D */ +void fclaw_domain_edge_faces(const fclaw_domain_t *domain, int iedge, int faces[2]); +/** Find the numbers of faces adjacent to a cube corner: 2 in 2D, 3 in 3D. */ +void fclaw_domain_corner_faces (const fclaw_domain_t * domain, + int icorner, int faces[3]); + +///@} +/* ---------------------------------------------------------------------- */ +/// @name Patch Functions +/* ---------------------------------------------------------------------- */ +///@{ + +/** Return the dimension of a corner. + * This function is LEGAL to call for both local and ghost patches. + * \param [in] patch A patch with properly set member variables. + * \param [in] cornerno A corner number in 0..3 for 2D or 0..7 for 3D. + * \return 0 if the corner is always at a fourfold intersection, + * 1 if the corner would end up in the middle of a face + * when there is a coarser neighbor. + */ +int fclaw_patch_corner_dimension (const fclaw_patch_t * patch, + int cornerno); + +/** Return the number of a patch with respect to its parent in the tree. + * This function is LEGAL to call for both local and ghost patches. + * \param [in] patch A patch with properly set member variables. + * \return The child id is a number in 0..3 for 2D or 0..7 for 3D. + */ +int fclaw_patch_childid (const fclaw_patch_t * patch); + +/** Check if a patch is the first in a family of four siblings. + * For ghost patches, we always return false. + * \param [in] patch A patch with properly set member variables. + * \return True if patch is the first sibling. + */ +int fclaw_patch_is_first_sibling (const fclaw_patch_t * patch); + +/** Check whether a patch is a parallel ghost patch. + * \param [in] patch A patch with properly set member variables. + * \return True if patch is off-processor, false if local. + */ +int fclaw_patch_is_ghost (const fclaw_patch_t * patch); + +/** + * @brief The the block number of a ghost patch. + * + * This should only be called on a ghost patch. + * + * @param patch the patch + * @return int the block number. + */ +int fclaw_patch_get_ghost_block(const fclaw_patch_t *patch); + +///@} +/* ---------------------------------------------------------------------- */ +/// @name Patch Iterators +/* ---------------------------------------------------------------------- */ +///@{ + +/** Callback prototype for the patch iterators. + * We iterate over local patches only. + * \param [in] domain General domain structure. + * \param [in] patch The local patch currently processed by the iterator. + * \param [in] blockno Block number of processed patch. + * \param [in] patchno Patch number within block of processed patch. + * \param [in,out] user Data that was passed into the iterator functions. + */ +typedef void (*fclaw_patch_callback_t) + (fclaw_domain_t * domain, fclaw_patch_t * patch, + int blockno, int patchno, void *user); + +/** Iterate over all local patches on a given level. + * \param [in] domain General domain structure. + * \param [in] level Level to iterate. Ignore patches of other levels. + * \param [in] pcb Function called for each patch of matching level. + * \param [in,out] user Data is passed to the pcb callback. + */ +void fclaw_domain_iterate_level (fclaw_domain_t * domain, int level, + fclaw_patch_callback_t pcb, void *user); + +/** Iterate over all local patches of all levels. + * \param [in] domain General domain structure. + * \param [in] pcb Function called for each patch in the domain. + * \param [in,out] user Data is passed to the pcb callback. + */ +void fclaw_domain_iterate_patches (fclaw_domain_t * domain, + fclaw_patch_callback_t pcb, + void *user); + +/** Iterate over all families of local sibling patches. + * \param [in] domain General domain structure. + * \param [in] pcb Function called for each family in the domain. + * Its patch argument points to an array of four + * valid patches that constitute a family of siblings. + * Their patchnos are consecutive, blockno is the same. + * \param [in,out] user Data is passed to the pcb callback. + */ +void fclaw_domain_iterate_families (fclaw_domain_t * domain, + fclaw_patch_callback_t pcb, + void *user); + +///@} +/* ---------------------------------------------------------------------- */ +/// @name Patch Neighbors +/* ---------------------------------------------------------------------- */ +///@{ + +/** Determine physical boundary status as 1, or 0 for neighbor patches. + * This must ONLY be called for local patches. + * \param [in] domain Valid domain structure. + * \param [in] blockno Number of the block within the domain. + * \param [in] patchno Number of the patch within the block. + * \param [in,out] boundaries Domain boundary boolean flags + (length 4 for 2D, 6 for 3D). + * The order is left, right, front, back, bottom, top. + * \return True if at least one patch face is on a boundary. + */ +int fclaw_patch_boundary_type (fclaw_domain_t * domain, + int blockno, int patchno, int boundaries[]); + +/** Determine whether the normal to a face neighbor align. + * \param [in] domain Valid domain structure. + * \param [in] blockno Number of the block within the domain. + * \param [in] patchno Number of the patch within the block. + * \param [in] faceno Number of the face of the patch. + * \return True if normals match, false for mismatch. + */ +int fclaw_patch_normal_match (fclaw_domain_t * domain, + int blockno, int patchno, int faceno); + +/** + * @brief The type of face neighbor + */ +typedef enum fclaw_face_neighbor +{ + /** Physical boundary */ + FCLAW_PATCH_BOUNDARY, + /** Half-size (finer) neighbor */ + FCLAW_PATCH_HALFSIZE, + /** Same-size neighbor */ + FCLAW_PATCH_SAMESIZE, + /** Double-size (coarser) neighbor */ + FCLAW_PATCH_DOUBLESIZE +} +fclaw_patch_relation_t; + +/** Determine neighbor patch(es) and orientation across a given face. + * This must ONLY be called for local patches. + * \param [in] domain Valid domain structure. + * \param [in] blockno Number of the block within the domain. + * \param [in] patchno Number of the patch within the block. + * \param [in] faceno Number of the patch face: left, right, bottom, top. + * \param [out] rproc Processor number of neighbor patches (length 2 in 2D, 4 in 3D). + * Exception: + * If the neighbor is a bigger patch, rproc[1] contains + * the number of the small patch as one of the smaller faces. + * \param [out] rblockno Neighbor block number. + * \param [out] rpatchno Neighbor patch numbers (length 2 in 2D, 4 in 3D) + * The patch number is relative to its block. + * If the neighbor is off-processor, this is not + * a patch number but in [0, num_ghost_patches[. + * \param [out] rfaceno Neighbor face number and orientation. + * \return The relative patch size of the face neighbor. + */ +fclaw_patch_relation_t fclaw_patch_face_neighbors (fclaw_domain_t * + domain, int blockno, + int patchno, + int faceno, + int rproc[], + int *rblockno, + int rpatchno[], + int *rfaceno); + +/** Change perspective across a face neighbor situation. + * \param [in] dim Dimension [2, 3]. + * \param [in,out] faceno On input, valid face number for a patch. + * On output, valid face number seen from + * faceno's neighbor patch. + * \param [in,out] rfaceno On input, encoded neighbor face number as returned + * by fclaw_patch_face_neighbors. + * On output, encoded neighbor face number seen from + * faceno's neighbor patch. + */ +void fclaw_patch_face_swap (int dim, int *faceno, int *rfaceno); + +/** Fill an array with the axis combination of a face neighbor transform. + * \param [in] dim Dimension [2, 3]. + * \param [in] faceno The number of the originating face. + * \param [in] rfaceno In 2D: + * Encoded as rfaceno = r * 4 + nf, where nf = 0..3 is + * the neigbbor's connecting face number and r = 0..1 + * is the relative orientation to the neighbor's face. + * + * In 3D: + * Encoded as rfaceno = r * 6 + nf, where nf = 0..3 is + * the neigbbor's connecting face number and r = 0..1 + * is the relative orientation to the neighbor's face. + * \param [out] ftransform This array holds 9 integers. + * In 2D: + * [0,2] The coordinate axis sequence of the origin face, + * the first referring to the tangential and the second + * to the normal. A permutation of (0, 1). + * [3,5] The coordinate axis sequence of the target face. + * [6,8] Edge reversal flag for tangential axis (boolean); + * face code in [0, 3] for the normal coordinate q: + * 0: q' = -q + * 1: q' = q + 1 + * 2: q' = q - 1 + * 3: q' = 2 - q + * [8] & 4: Both patches are in the same block, + * the \a ftransform contents are ignored. + * [1,4,7] 0 (unused for compatibility with 3D). + * + * In 3D: + * [0..2] The coordinate axis sequence of the origin face, + * the first two referring to the tangentials and the + * third to the normal. A permutation of (0, 1, 2). + * [3..5] The coordinate axis sequence of the target face. + * [6..8] Edge reversal flags for tangential axes (boolean); + * face code in [0, 3] for the normal coordinate q: + * 0: q' = -q + * 1: q' = q + 1 + * 2: q' = q - 1 + * 3: q' = 2 - q + * [8] & 4: Both patches are in the same block, + * the \a ftransform contents are ignored. + */ +void fclaw_patch_face_transformation (int dim, int faceno, int rfaceno, + int ftransform[]); + +/** Modify an existing face transformation depending on intra-block usage. + * This function can be called any number of times on the same transform array. + * \param [in] dim Dimension [2, 3]. + * \param [in,out] ftransform Array of values necessarily created by \ref + * fclaw_patch_face_transformation. + * \param [in] sameblock Transformation supposed to work in same block? + */ +void fclaw_patch_face_transformation_block (int dim, int ftransform[], + int sameblock); + +/** Fill an array with the axis combination of a face neighbor transformation + * that operates on two patches in the same block (the trivial case). + * Use when there is no prior call to \ref fclaw_patch_face_transformation. + * Don't postprocess the result any further -- it's only useful intra-block. + * \param [in] dim Dimension [2, 3]. + * \param [out] ftransform Gets initialized to a same-block transform. + */ +void fclaw_patch_face_transformation_intra (int dim, int ftransform[]); + +/** Return whether a face transformation is valid. + * \param [in] dim Dimension [2, 3]. + * \param [in] ftransform Array of values as created by \ref + * fclaw_patch_face_transformation, + * possibly modified by \ref + * fclaw_patch_face_transformation_block. + * \return True if valid, false if not. + */ +int fclaw_patch_face_transformation_valid (int dim, const int ftransform[]); + +/** Transform a 2D patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the two patches are of the SAME size. + * If the neighbor patch is in the same block we must set (ftransform[8] & 4). + * Else we have an input patch in one block and on output patch across a face. + * It is LEGAL to call this function for both local and ghost patches. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] ftransform It must have room for NINE (9) integers and be + * computed by \a fclaw_patch_face_transformation. + * If \a ipatch and \a opatch are in the same block, + * we require \a ftransform[8] |= 4. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * The number of cells must match according to the face + * transformation. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i Integer coordinate along x-axis in \a based .. \a mx. + * \param [in,out] j Integer coordinate along y-axis in \a based .. \a my. + */ +void fclaw_patch_2d_transform_face (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + const int ftransform[], + int mx, int my, int based, int *i, int *j); + +/** Transform a 2D patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the neighbor patch is smaller (HALF size). + * If the neighbor patch is in the same block we must set (ftransform[8] & 4). + * Else we have an input patch in one block and on output patch across a face. + * It is LEGAL to call this function for both local and ghost patches. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] ftransform It must have room for NINE (9) integers and be + * computed by \a fclaw_patch_face_transformation. + * If \a ipatch and \a opatch are in the same block, + * we require \a ftransform[8] |= 4. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * The number of cells must match according to the face + * transformation. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i FOUR (4) integer coordinates along x-axis in + * \a based .. \a mx. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + * \param [in,out] j FOUR (4) integer coordinates along y-axis in + * \a based .. \a my. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + */ +void fclaw_patch_2d_transform_face2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + const int ftransform[], + int mx, int my, int based, int i[], + int j[]); + +/** Transform a 3D patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the two patches are of the SAME size. + * If the neighbor patch is in the same block we must set (ftransform[8] & 4). + * Else we have an input patch in one block and on output patch across a face. + * It is LEGAL to call this function for both local and ghost patches. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] ftransform It must have room for NINE (9) integers and be + * computed by \a fclaw3d_patch_face_transformation. + * If \a ipatch and \a opatch are in the same block, + * we require \a ftransform[8] |= 4. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * \param [in] mz Number of cells along z direction of patch. + * The number of cells must match according to the face + * transformation. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i Integer coordinate along x-axis in \a based .. \a mx. + * \param [in,out] j Integer coordinate along y-axis in \a based .. \a my. + * \param [in,out] k Integer coordinate along z-axis in \a based .. \a mz. + */ +void fclaw_patch_3d_transform_face (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + const int ftransform[], + int mx, int my, int mz, int based, + int *i, int *j, int *k); + +/** Transform a 3D patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the neighbor patch is smaller (HALF size). + * If the neighbor patch is in the same block we must set (ftransform[8] & 4). + * Else we have an input patch in one block and on output patch across a face. + * It is LEGAL to call this function for both local and ghost patches. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] ftransform It must have room for NINE (9) integers and be + * computed by \a fclaw3d_patch_face_transformation. + * If \a ipatch and \a opatch are in the same block, + * we require \a ftransform[8] |= 4. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * \param [in] mz Number of cells along z direction of patch. + * The number of cells must match according to the face + * transformation. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i EIGHT (8) integer coordinates along x-axis in + * \a based .. \a mx. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + * \param [in,out] j EIGHT (8) integer coordinates along y-axis in + * \a based .. \a my. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + * \param [in,out] k EIGHT (8) integer coordinates along z-axis in + * \a based .. \a mz. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + */ +void fclaw_patch_3d_transform_face2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + const int ftransform[], + int mx, int my, int mz, int based, + int i[], int j[], int k[]); + +/** Determine neighbor patch(es) and orientation across a given edge. + * The current version only supports one neighbor, i.e., no true multi-block. + * A query across an edge in the middle of a longer face returns the boundary. + * We only return edge neighbors that are not already face neighbors. + * Inter-tree edges are only returned if the number of meeting edges is + * exactly four. Five or more are currently not supported. + * This must ONLY be called for local patches. + * \param [in] domain Valid domain structure. + * \param [in] blockno Number of the block within the domain. + * \param [in] patchno Number of the patch within the block. + * \param [in] edgeno Number of the patch edge: 4 parallel to x axis, + then 4 parallel to y axis, then 4 parallel to z. + * \param [out] rproc Processor number of neighbor patch. + * \param [out] rblockno Neighbor block number. + * \param [out] rpatchno Neighbor patch number of up to 2 neighbors. + ` The patch number is relative to its block. + * If the neighbor is off-processor, this is not + * a patch number but in [0, num_ghosts_patches[. + * \param [out] redge Number of the edge from the other neighbor. + * \param [out] neighbor_size The relative patch size of the neighbor. + * \return True if at least one edge neighbor exists + * that is not already a face neighbor. + */ +int fclaw_patch_edge_neighbors (fclaw_domain_t * domain, + int blockno, int patchno, int edgeno, + int *rproc, int *rblockno, int *rpatchno, + int *redge, + fclaw_patch_relation_t * neighbor_size); + +/** Change perspective across an edge neighbor situation. + * \param [in,out] edgeno On input, valid edge number for a patch. + * On output, edge number seen from + * the edge neighbor patch. + * \param [in,out] redgeno On input, valid edge number as returned + * by fclaw_patch_edge_neighbors. + * On output, edge number seen from + * the edge neighbor patch. + */ +void fclaw_patch_edge_swap (int *edgeno, int *redgeno); + +/** Transform a patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the two patches are of the SAME size and that the + * patches lie in coordinate systems with the same orientation. + * It is LEGAL to call this function for both local and ghost patches. + * It is ILLEGAL to call this function for patches from face-neighboring blocks. + * Use \ref fclaw_patch_3d_transform_face for such patches instead. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] iedge Edge number of this patch to transform across. + * This function assumes oedge == iedge ^ 3, so + * oedge is the edge opposite of iedge. + * \param [in] is_block_boundary Set to true for a block edge. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * \param [in] mz Number of cells along z direction of patch. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i Integer coordinate along x-axis in \a based .. \a mx. + * \param [in,out] j Integer coordinate along y-axis in \a based .. \a my. + * \param [in,out] k Integer coordinate along z-axis in \a based .. \a mz. + */ +void fclaw_patch_3d_transform_edge (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int iedge, int is_block_boundary, + int mx, int my, int mz, + int based, int *i, int *j, int *k); + +/** Transform a patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the neighbor patch is smaller (HALF size) and that + * the patches lie in coordinate systems with the same orientation. + * It is LEGAL to call this function for both local and ghost patches. + * It is ILLEGAL to call this function for patches from face-neighboring blocks. + * Use \ref fclaw_patch_3d_transform_face for such patches instead. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] iedge Edge number of this patch to transform across. + * This function assumes oedge == iedge ^ 3, so + * oedge is the edge opposite of iedge. + * \param [in] is_block_boundary Set to true for a block edge. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * \param [in] mz Number of cells along z direction of patch. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i EIGHT (8) integer coordinates along x-axis in + * \a based .. \a mx. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + * \param [in,out] j EIGHT (8) integer coordinates along y-axis in + * \a based .. \a my. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + * \param [in,out] k EIGHT (8) integer coordinates along y-axis in + * \a based .. \a mz. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + */ +void fclaw_patch_3d_transform_edge2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int iedge, int is_block_boundary, + int mx, int my, int mz, int based, + int i[], int j[], int k[]); + +/** Determine neighbor patch(es) and orientation across a given corner. + * The current version only supports one neighbor, i.e., no true multi-block. + * A query across a corner in the middle of a longer face returns the boundary. + * We only return corner neighbors that are not already face neighbors. + * Inter-tree corners are only returned if the number of meeting corners is + * exactly four. Five or more are currently not supported. + * This must ONLY be called for local patches. + * \param [in] domain Valid domain structure. + * \param [in] blockno Number of the block within the domain. + * \param [in] patchno Number of the patch within the block. + * \param [in] cornerno Number of the patch corner: + * In 2D: 0=bl, 1=br, 2=tl, 3=tr. + * In 3D: 0=bfl, ..., 7=tbr. + * \param [out] rproc Processor number of neighbor patch. + * \param [out] rblockno Neighbor block number. + * \param [out] rpatchno Neighbor patch number relative to the block. + * If the neighbor is off-processor, this is not + * a patch number but in [0, num_ghosts_patches[. + * \param [out] rcorner Number of the corner from the other neigbor. + * \param [out] neighbor_size The relative patch size of the neighbor. + * \return True if at least one corner neighbor exists + * that is not already a face neighbor. + */ +int fclaw_patch_corner_neighbors (fclaw_domain_t * domain, + int blockno, int patchno, int cornerno, + int *rproc, int *rblockno, int *rpatchno, + int *rcorner, + fclaw_patch_relation_t * neighbor_size); + +/** Change perspective across a corner neighbor situation. + * \param [in] dim Dimension [2, 3]. + * \param [in,out] cornerno On input, valid corner number for a patch. + * On output, corner number seen from + * the corner neighbor patch. + * \param [in,out] rcornerno On input, valid corner number as returned + * by fclaw_patch_face_neighbors. + * On output, corner number seen from + * the corner neighbor patch. + */ +void fclaw_patch_corner_swap (int dim, int *cornerno, int *rcornerno); + +/** Transform a 2D patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the two patches are of the SAME size and that the + * patches lie in coordinate systems with the same orientation. + * It is LEGAL to call this function for both local and ghost patches. + * It is ILLEGAL to call this function for patches from face-neighboring blocks. + * Use \ref fclaw2d_patch_transform_face for such patches instead. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] icorner Corner number of this patch to transform across. + * This function assumes ocorner == icorner ^ 3, so + * ocorner is the opposite corner of icorner. + * \param [in] is_block_boundary Set to true for a block corner. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i Integer coordinate along x-axis in \a based .. \a mx. + * \param [in,out] j Integer coordinate along y-axis in \a based .. \a my. + */ +void fclaw_patch_2d_transform_corner (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int icorner, int is_block_boundary, + int mx, int my, + int based, int *i, int *j); + +/** Transform a 2D patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the neighbor patch is smaller (HALF size) and that + * the patches lie in coordinate systems with the same orientation. + * It is LEGAL to call this function for both local and ghost patches. + * It is ILLEGAL to call this function for patches from face-neighboring blocks. + * Use \ref fclaw2d_patch_transform_face2 for such patches instead. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] icorner Corner number of this patch to transform across. + * This function assumes ocorner == icorner ^ 3, so + * ocorner is the opposite corner of icorner. + * \param [in] is_block_boundary Set to true for a block corner. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i FOUR (4) integer coordinates along x-axis in + * \a based .. \a mx. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + * \param [in,out] j FOUR (4) integer coordinates along y-axis in + * \a based .. \a my. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + */ +void fclaw_patch_2d_transform_corner2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int icorner, int is_block_boundary, + int mx, int my, int based, + int i[], int j[]); + +/** Transform a 3D patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the two patches are of the SAME size and that the + * patches lie in coordinate systems with the same orientation. + * It is LEGAL to call this function for both local and ghost patches. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] icorner Corner number of this patch to transform across. + * This function assumes ocorner == icorner ^ 7, so + * ocorner is the opposite corner of icorner. + * \param [in] is_block_boundary Set to true for a block corner. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * \param [in] mz Number of cells along z direction of patch. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i Integer coordinate along x-axis in \a based .. \a mx. + * \param [in,out] j Integer coordinate along y-axis in \a based .. \a my. + * \param [in,out] k Integer coordinate along z-axis in \a based .. \a mz. + */ +void fclaw_patch_3d_transform_corner (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int icorner, int is_block_boundary, + int mx, int my, int mz, + int based, int *i, int *j, int *k); + +/** Transform a 3D patch coordinate into a neighbor patch's coordinate system. + * This function assumes that the neighbor patch is smaller (HALF size) and that + * the patches lie in coordinate systems with the same orientation. + * It is LEGAL to call this function for both local and ghost patches. + * It is ILLEGAL to call this function for patches from face- or + * edge-neighboring blocks. Use \ref fclaw3d_patch_transform_face2 or + * \ref fclaw_patch_3d_transform_edge2 for such patches instead. + * \param [in] ipatch The patch that the input coordinates are relative to. + * \param [in] opatch The patch that the output coordinates are relative to. + * \param [in] icorner Corner number of this patch to transform across. + * This function assumes ocorner == icorner ^ 7, so + * ocorner is the opposite corner of icorner. + * \param [in] is_block_boundary Set to true for a block corner. + * \param [in] mx Number of cells along x direction of patch. + * \param [in] my Number of cells along y direction of patch. + * \param [in] mz Number of cells along z direction of patch. + * \param [in] based Indices are 0-based for corners and 1-based for cells. + * \param [in,out] i EIGHT (8) integer coordinates along x-axis in + * \a based .. \a mx. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + * \param [in,out] j EIGHT (8) integer coordinates along y-axis in + * \a based .. \a my. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + * \param [in,out] k EIGHT (8) integer coordinates along y-axis in + * \a based .. \a mz. On input, only the first is used. + * On output, they are relative to the fine patch and + * stored in order of the children of the coarse patch. + */ +void fclaw_patch_3d_transform_corner2 (fclaw_patch_t * ipatch, + fclaw_patch_t * opatch, + int icorner, int is_block_boundary, + int mx, int my, int mz, int based, + int i[], int j[], int k[]); +///@} +/* ---------------------------------------------------------------------- */ +/// @name Adaptivity +/* ---------------------------------------------------------------------- */ +///@{ + +/** Set parameters of refinement strategy in a domain. + * This function only needs to be called once, and only for the first domain + * created in the program. The values of the parameters are automatically + * transferred on adaptation and partitioning. + * \param [in,out] domain This domain's refinement strategy is set. + * \param [in] smooth_refine Activate or deactivete refinement smoothing. + * A newly created domain has this set to false. + * \param [in] smooth_level If \b smooth_refine is true, denotes the + * lowest level that activates the smoothing. + * Use zero for smoothing across all levels. + * \param [in] coarsen_delay Non-negative number to set the delay for + * coarsening after a patch has been last refined. + * This number is a global threshold that is compared + * against each patch's individual counter. + */ +void fclaw_domain_set_refinement (fclaw_domain_t * domain, + int smooth_refine, int smooth_level, + int coarsen_delay); + +/** Set parameters of partitioning strategy in a domain. + * This function only needs to be called once, and only for the first domain + * created in the program. The values of the parameters are automatically + * transferred on adaptation and partitioning. + * \param [in,out] domain This domain's partitioning strategy is set. + * \param [in] partition_for_coarsening Boolean: If true, all future partitions + * of the domain allow one level of coarsening. + * Suggested default: 1. + */ +void fclaw_domain_set_partitioning (fclaw_domain_t * domain, + int partition_for_coarsening); + +/** Mark a patch for refinement. + * This must ONLY be called for local patches. + * It is safe to call this function from an iterator callback except + * \ref fclaw_domain_iterate_adapted. + */ +void fclaw_patch_mark_refine (fclaw_domain_t * domain, + int blockno, int patchno); + +/** Mark a patch for coarsening. + * This must ONLY be called for local patches. + * Coarsening will only happen if the patch family is not further refined + * and all sibling patches are marked as well. + * It is safe to call this function from an iterator callback except + * \ref fclaw_domain_iterate_adapted. + */ +void fclaw_patch_mark_coarsen (fclaw_domain_t * domain, + int blockno, int patchno); + +/** Callback prototype used in fclaw_domain_iterate_adapted. + * The newsize value informs on refine/coarsen/noop status. + * If refined (new patch is HALFSIZE), the old patch is old_patch[0] and the + * new patches are given by new_patch[0] through new_patch[3]. The new_patchno + * numbers are consecutive as well. + * If noop (new patch is SAMESIZE), only old_patch[0] and new_patch[0] matter. + * If coarsened (new patch is DOUBLESIZE), situation is the reverse of refine. + * We iterate over local patches only. + */ +typedef void (*fclaw_match_callback_t) (fclaw_domain_t * old_domain, + fclaw_patch_t * old_patch, + fclaw_domain_t * new_domain, + fclaw_patch_t * new_patch, + fclaw_patch_relation_t newsize, + int blockno, + int old_patchno, int new_patchno, + void *user); + +/** Iterate over the previous and the adapted domain simultaneously. + * We iterate over local patches only. + * \param [in,out] old_domain Domain before adaptation. + * \param [in,out] new_domain Domain after adaptation. + * \param [in] mcb Callback. + * \param [in,out] user This pointer is passed to the callback. + */ +void fclaw_domain_iterate_adapted (fclaw_domain_t * old_domain, + fclaw_domain_t * new_domain, + fclaw_match_callback_t mcb, + void *user); + +///@} +/* ---------------------------------------------------------------------- */ +/// @name Parititon +/* ---------------------------------------------------------------------- */ +///@{ + +/** Allocate data buffer for parallel transfer of all patches. + * \param [in,out] domain The memory lives inside this domain. + * \param [in] data_size Number of bytes per patch to transfer. + * \param [in,out] patch_data Address of an array of void pointers. + * Data is allocated by this function. After the + * call, *patch_data holds one pointer per patch + * that points to exactly data_size bytes of + * memory that can be written to by forestclaw. + * *patch_data must be NULL before the call. + */ +void fclaw_domain_allocate_before_partition (fclaw_domain_t * domain, + size_t data_size, + void ***patch_data); + +/** Reallocate data buffer to reflect patch data after partition. + * \param [in,out] domain The memory lives inside this domain. + * \param [in,out] patch_data Address of an array of void pointers. + * Data is reallocated by this function. After the + * call, *patch_data holds one pointer per patch + * that points to exactly data_size bytes of + * memory that can be read from by forestclaw. + */ +void fclaw_domain_retrieve_after_partition (fclaw_domain_t * domain, + void ***patch_data); + +/** Callback to iterate through the partitions. + * We traverse every patch in the new partition. If that patch was already + * on the local processor before the partition, we identify its memory. + * We iterate over local patches only. + * \param [in,out] old_domain Domain before partition. + * \param [in,out] old_patch If the patch stayed local, this is the pointer + * in reference to the old domain and partition. + * Otherwise, this patch pointer is set to NULL. + * \param [in,out] new_domain Domain after partition. + * \param [in,out] new_patch Patch in the new domain and partition. + * \param [in] blockno Number of the current block. + * \param [in] old_patchno Number of the patch that stayed local wrt. the + * old domain and partition. Minus one otherwise. + * \param [in] new_patchno Number of the iterated patch wrt. the new + * domain and partition. + * \param [in,out] user Pointer passed to \ref + * fclaw_domain_iterate_partitioned. + */ +typedef void (*fclaw_transfer_callback_t) (fclaw_domain_t * old_domain, + fclaw_patch_t * old_patch, + fclaw_domain_t * new_domain, + fclaw_patch_t * new_patch, + int blockno, + int old_patchno, int new_patchno, + void *user); + +/** Iterate over the previous and partitioned domain simultaneously. + * We iterate over local patches only. + * \param [in,out] old_domain Domain before partition. + * \param [in,out] new_domain Domain after partition. + * \param [in] tcb Callback. + * \param [in,out] user This pointer is passed to the callback. + */ +void fclaw_domain_iterate_partitioned (fclaw_domain_t * old_domain, + fclaw_domain_t * new_domain, + fclaw_transfer_callback_t tcb, + void *user); + +/** Free buffers that were used in transfering data during partition. + * \param [in,out] domain The memory lives inside this domain. + * \param [in,out] patch_data Address of an array of void pointers to free. + * *patch_data will be NULL after the call. + */ +void fclaw_domain_free_after_partition (fclaw_domain_t * domain, + void ***patch_data); + +///@} +/* ---------------------------------------------------------------------- */ +/// @name Communication +/* ---------------------------------------------------------------------- */ +///@{ + +/** Compute and return the maximum over all processors of a double value. + * The minimum can be computed by using this function on the negative value. + */ +double fclaw_domain_global_maximum (fclaw_domain_t * domain, double d); + +/** Compute and return the sum over all processors of a double value. + */ +double fclaw_domain_global_sum (fclaw_domain_t * domain, double d); + +/** Synchronize all processes. Avoid using if at all possible. + */ +void fclaw_domain_barrier (fclaw_domain_t * domain); + +/** Serialize a section of code. + * THIS IS NOT SCALABLE. + * WILL BE HORRIBLY SLOW FOR LARGE NUMBERS OF PROCESSORS. + * A processor returns from this function only after all lower-numbered + * processors have called fclaw_domain_serialization_leave. + * No collective communication routines must be called between the calls + * to this function and fclaw_domain_serialization_leave. + * \param [in] domain The domain is not modified. + */ +void fclaw_domain_serialization_enter (fclaw_domain_t * domain); + +/** Serialize a section of code. + * THIS IS NOT SCALABLE. + * WILL BE HORRIBLY SLOW FOR LARGE NUMBERS OF PROCESSORS. + * A processor must call this function to allow all higher-numbered + * processors to return from fclaw_domain_serialization_enter. + * \param [in] domain The domain is not modified. + */ +void fclaw_domain_serialization_leave (fclaw_domain_t * domain); + +///@} +/* ---------------------------------------------------------------------- */ +/// @name Exchange +/* ---------------------------------------------------------------------- */ +///@{ + +/** + * @brief Simple wrapper struct for fclaw2d_exchange_info_t + * and fclaw3d_exchange_info_t + */ +struct fclaw_domain_exchange +{ + int refine_dim; /**< refinement dimension */ + struct fclaw2d_domain_exchange *d2; /**< 2d exchange data */ + struct fclaw3d_domain_exchange *d3; /**< 3d exchange data */ +}; + +/** Allocate buffer to hold the data from off-processor patches. + * Free this by fclaw_domain_free_after_exchange before regridding. + * \param [in] domain The domain is not modified. + * \param [in] data_size Number of bytes per patch to exchange. + * \return Allocated data structure. + * The pointers in patch_data[i] need to be set + * after this call by forestclaw. + */ +fclaw_domain_exchange_t * +fclaw_domain_allocate_before_exchange (fclaw_domain_t * domain, + size_t data_size); + +/** Exchange data for parallel ghost neighbors. + * This function receives data from parallel neighbor (ghost) patches. + * It can be called multiple times on the same allocated buffers. + * We assume that the data size for all patches is the same. + * \param [in] domain Used to access forest and ghost metadata. + * #(sent patches) is domain->num_exchange_patches. + * #(received patches) is domain->num_ghost_patches. + * \param [in] e Allocated buffers whose e->patch_data[i] pointers + * must have been set properly by forestclaw. + * \param [in] exchange_minlevel The minimum quadrant level that is exchanged. + * \param [in] exchange_maxlevel The maximum quadrant level that is exchanged. + */ +void fclaw_domain_ghost_exchange (fclaw_domain_t * domain, + fclaw_domain_exchange_t * e, + int exchange_minlevel, + int exchange_maxlevel); + +/** Start asynchronous exchange of parallel ghost neighbors. + * The arguments are the same as for fclaw_domain_ghost_exchange. + * It must be followed by a call to fclaw_domain_ghost_exchange_end. + * Between begin and end, neither of \ref fclaw_domain_indirect_begin + * and _end must be called. + * \param [in,out] e Its ghost_data member must survive and not + * be written to until the completion of + * fclaw_domain_ghost_exchange_end. + * Its patch_data member may already be + * overwritten after this function returns. + */ +void fclaw_domain_ghost_exchange_begin (fclaw_domain_t * domain, + fclaw_domain_exchange_t * e, + int exchange_minlevel, + int exchange_maxlevel); + +/** Complete asynchronous exchange of parallel ghost neighbors. + * Must be called at some point after fclaw_domain_ghost_exchange_begin. + * Between begin and end, neither of \ref fclaw_domain_indirect_begin + * and _end must be called. + * \param [in,out] e Its ghost_data member must have survived. + */ +void fclaw_domain_ghost_exchange_end (fclaw_domain_t * domain, + fclaw_domain_exchange_t * e); + +/** Free buffers used in exchanging off-processor data during time stepping. + * This should be done just before regridding. + * \param [in] domain The domain is not modified. + * \param [in] e Allocated buffers. + */ +void fclaw_domain_free_after_exchange (fclaw_domain_t * domain, + fclaw_domain_exchange_t * e); + +///@} +/* ---------------------------------------------------------------------- */ +/// @name Indirect Parallel Neighbors +/* ---------------------------------------------------------------------- */ +///@{ + + +/** Begin sending messages to determine neighbors of ghost patches. + * This call must not be interleaved with any ghost_exchange calls. + * \param [in] domain This domain must remain valid until + * \ref fclaw_domain_indirect_destroy. + * \return A private data structure that will hold + * the context for indirect ghost neighbors. + */ +fclaw_domain_indirect_t + * fclaw_domain_indirect_begin (fclaw_domain_t * domain); + +/** End sending messages to determine neighbors of ghost patches. + * This call must not be interleaved with any ghost_exchange calls. + * When this function returns, the necessary information is complete + * and \ref fclaw_domain_indirect_neighbors may be called any number of times. + * \param [in] domain Must be the same domain used in the begin call. + * \param [in,out] ind Must be returned by an earlier call to + * \ref fclaw_domain_indirect_begin + * and will be completed with parallel information. + */ +void fclaw_domain_indirect_end (fclaw_domain_t * domain, + fclaw_domain_indirect_t * ind); + +/** Call this analogously to \ref fclaw_domain_face_neighbors. + * Return an indirect face neighbor patch: It is defined as a ghost patch + * that is face neighbor to the calling ghost patch and belongs to a process + * that is neither the owner of that ghost patch nor our own process. + * \param [in] domain Must be the same domain used in begin and end. + * \param [in] ind Must have been initialized by \ref + * fclaw_domain_indirect_end. + * \param [in] ghostno Number of the ghost patch whose neighbors we seek. + * \param [in] faceno Number of the ghost patch's face to look across. + * \param [out] rproc Processor number of neighbor patches. Exception 1: + * If the neighbor is a bigger patch, rproc[1] contains + * the number of the small patch as one the smaller faces, + * but only if the neighbor fits the above criteria. + * Exception 2: For non-indirect patches, set it to -1. + * \param [out] rblockno The number of the neighbor block. + * \param [out] rpatchno Only for indirect ghost patches, we store + * the number relative to our ghost patch array. + * For all other patches, this is -1. + * \param [out] faceno The face number and orientation of the neighbor(s). + * \return Only for indirect ghost patches, the size of the + * neighbor(s). For all others, we set this to + * \ref fclaw_PATCH_BOUNDARY. + */ +fclaw_patch_relation_t +fclaw_domain_indirect_face_neighbors (fclaw_domain_t * domain, + fclaw_domain_indirect_t * ind, + int ghostno, int faceno, int rproc[], + int *rblockno, int rpatchno[], + int *rfaceno); + +/** Destroy all context data for indirect ghost neighbor patches. + * \param [in] domain Must be the same domain used in begin and end. + * \param [in,out] ind Memory will be freed. + */ +void fclaw_domain_indirect_destroy (fclaw_domain_t * domain, + fclaw_domain_indirect_t * ind); + +///@} +/* ---------------------------------------------------------------------- */ +/// @name Meta Domains +/* ---------------------------------------------------------------------- */ +///@{ + +/** Return true if \a domain is an artifical domain. + * + * This function can be used in \ref fclaw_interpolate_point_t callbacks to + * distinguish domains that were created during a partition search (and only + * contain some meta information) from real domains in a local search. + */ +int fclaw_domain_is_meta (fclaw_domain_t * domain); + +///@} +#ifdef __cplusplus +#if 0 +{ /* need this because indent is dumb */ +#endif +} +#endif + +#endif /* !FORESTCLAW_H */ diff --git a/src/forestclaw2d.c b/src/forestclaw2d.c index b62f3b541..46c88511b 100644 --- a/src/forestclaw2d.c +++ b/src/forestclaw2d.c @@ -1052,7 +1052,7 @@ fclaw2d_patch_corner_neighbors (fclaw2d_domain_t * domain, *rcorner = cornerno ^ (P4EST_CHILDREN - 1); } } - + if (qid < 0) { /* The value -1 is expected for a corner on the physical boundary */ @@ -1396,6 +1396,15 @@ fclaw2d_domain_set_refinement (fclaw2d_domain_t * domain, p4est_wrap_set_coarsen_delay (wrap, coarsen_delay, 0); } +void +fclaw2d_domain_set_partitioning (fclaw2d_domain_t * domain, + int partition_for_coarsening) +{ + p4est_wrap_t *wrap = (p4est_wrap_t *) domain->pp; + + p4est_wrap_set_partitioning (wrap, partition_for_coarsening); +} + void fclaw2d_patch_mark_refine (fclaw2d_domain_t * domain, int blockno, int patchno) diff --git a/src/forestclaw2d.h b/src/forestclaw2d.h index 8fbbfe486..2fccb2e4f 100644 --- a/src/forestclaw2d.h +++ b/src/forestclaw2d.h @@ -667,6 +667,18 @@ void fclaw2d_domain_set_refinement (fclaw2d_domain_t * domain, int smooth_refine, int smooth_level, int coarsen_delay); +/** Set parameters of partitioning strategy in a domain. + * This function only needs to be called once, and only for the first domain + * created in the program. The values of the parameters are automatically + * transferred on adaptation and partitioning. + * \param [in,out] domain This domain's partitioning strategy is set. + * \param [in] partition_for_coarsening Boolean: If true, all future partitions + * of the domain allow one level of coarsening. + * Suggested default: 1. + */ +void fclaw2d_domain_set_partitioning (fclaw2d_domain_t * domain, + int partition_for_coarsening); + /** Mark a patch for refinement. * This must ONLY be called for local patches. * It is safe to call this function from an iterator callback except diff --git a/src/forestclaw3d.h b/src/forestclaw3d.h index a4e0dd647..92c7ecbf4 100644 --- a/src/forestclaw3d.h +++ b/src/forestclaw3d.h @@ -790,6 +790,18 @@ void fclaw3d_domain_set_refinement (fclaw3d_domain_t * domain, int smooth_refine, int smooth_level, int coarsen_delay); +/** Set parameters of partitioning strategy in a domain. + * This function only needs to be called once, and only for the first domain + * created in the program. The values of the parameters are automatically + * transferred on adaptation and partitioning. + * \param [in,out] domain This domain's partitioning strategy is set. + * \param [in] partition_for_coarsening Boolean: If true, all future partitions + * of the domain allow one level of coarsening. + * Suggested default: 1. + */ +void fclaw3d_domain_set_partitioning (fclaw3d_domain_t * domain, + int partition_for_coarsening); + /** Mark a patch for refinement. * This must ONLY be called for local patches. * It is safe to call this function from an iterator callback except diff --git a/src/mappings/annulus/mapc2m_annulus.f b/src/mappings/annulus/mapc2m_annulus.f index 84982819e..33430dbd7 100644 --- a/src/mappings/annulus/mapc2m_annulus.f +++ b/src/mappings/annulus/mapc2m_annulus.f @@ -1,4 +1,5 @@ - subroutine mapc2m_annulus(blockno,xc,yc,xp,yp,zp,beta,theta) + subroutine fclaw_map_2d_c2m_annulus( + & blockno,xc,yc,xp,yp,zp,beta,theta) implicit none integer blockno diff --git a/src/mappings/cart/mapc2m_cart.f b/src/mappings/cart/mapc2m_cart.f index 0aa67506c..530bfb424 100644 --- a/src/mappings/cart/mapc2m_cart.f +++ b/src/mappings/cart/mapc2m_cart.f @@ -1,4 +1,4 @@ - subroutine mapc2m_cart(blockno,xc,yc,xp,yp,zp) + subroutine fclaw_map_2d_c2m_cart(blockno,xc,yc,xp,yp,zp) implicit none double precision xc,yc,xp,yp,zp diff --git a/src/mappings/cubedsphere/mapc2m_cubedsphere.f b/src/mappings/cubedsphere/mapc2m_cubedsphere.f index 1eda24a1a..e80665579 100644 --- a/src/mappings/cubedsphere/mapc2m_cubedsphere.f +++ b/src/mappings/cubedsphere/mapc2m_cubedsphere.f @@ -1,4 +1,4 @@ - subroutine mapc2m_cubedsphere(blockno,xc,yc,xp,yp,zp) + subroutine fclaw_map_2d_c2m_cubedsphere(blockno,xc,yc,xp,yp,zp) implicit none double precision xc,yc,xp,yp,zp diff --git a/src/mappings/cylinder/mapc2m_cylinder.f b/src/mappings/cylinder/mapc2m_cylinder.f index 5856a6b8d..1061e2d06 100644 --- a/src/mappings/cylinder/mapc2m_cylinder.f +++ b/src/mappings/cylinder/mapc2m_cylinder.f @@ -1,4 +1,4 @@ - subroutine mapc2m_torus(xc,yc,xp,yp,zp,alpha, beta) + subroutine fclaw_map_2d_c2m_torus(xc,yc,xp,yp,zp,alpha, beta) implicit none double precision xc,yc,xp,yp,zp diff --git a/src/mappings/fclaw2d_map_nomap.c b/src/mappings/fclaw_map_nomap.c similarity index 61% rename from src/mappings/fclaw2d_map_nomap.c rename to src/mappings/fclaw_map_nomap.c index 3088c2040..8a3c5bf4b 100644 --- a/src/mappings/fclaw2d_map_nomap.c +++ b/src/mappings/fclaw_map_nomap.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -8,41 +8,41 @@ extern "C" #endif static int -fclaw2d_map_query_nomap (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_nomap (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 0; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 0; default: printf("\n"); @@ -57,7 +57,7 @@ fclaw2d_map_query_nomap (fclaw2d_map_context_t * cont, int query_identifier) static void -fclaw2d_map_c2m_nomap(fclaw2d_map_context_t * cont, int blockno, +fclaw2d_map_c2m_nomap(fclaw_map_context_t * cont, int blockno, double xc, double yc, double *xp, double *yp, double *zp) { @@ -69,7 +69,7 @@ fclaw2d_map_c2m_nomap(fclaw2d_map_context_t * cont, int blockno, } static void -fclaw3dx_map_c2m_nomap(fclaw2d_map_context_t * cont, int blockno, +fclaw3dx_map_c2m_nomap(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) { @@ -81,13 +81,13 @@ fclaw3dx_map_c2m_nomap(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_nomap() +fclaw_map_context_t* fclaw_map_new_nomap() { - fclaw2d_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + fclaw_map_context_t *cont; + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_nomap; cont->mapc2m = fclaw2d_map_c2m_nomap; - cont->mapc2m_3dx = fclaw3dx_map_c2m_nomap; + cont->mapc2m_3d = fclaw3dx_map_c2m_nomap; return cont; } diff --git a/src/mappings/fclaw2d_map_nomap_brick.c b/src/mappings/fclaw_map_nomap_brick.c similarity index 50% rename from src/mappings/fclaw2d_map_nomap_brick.c rename to src/mappings/fclaw_map_nomap_brick.c index 80eb4f9f9..b7a4355ee 100644 --- a/src/mappings/fclaw2d_map_nomap_brick.c +++ b/src/mappings/fclaw_map_nomap_brick.c @@ -1,6 +1,6 @@ /* Cartesian grid, tranformed to Ax + b */ -#include +#include #ifdef __cplusplus extern "C" @@ -13,41 +13,41 @@ extern "C" static int -fclaw2d_map_query_nomap_brick (fclaw2d_map_context_t * cont, int query_identifier) +fclaw2d_map_query_nomap_brick (fclaw_map_context_t * cont, int query_identifier) { switch (query_identifier) { - case FCLAW2D_MAP_QUERY_IS_USED: + case FCLAW_MAP_QUERY_IS_USED: return 0; - case FCLAW2D_MAP_QUERY_IS_SCALEDSHIFT: + case FCLAW_MAP_QUERY_IS_SCALEDSHIFT: return 1; - case FCLAW2D_MAP_QUERY_IS_AFFINE: + case FCLAW_MAP_QUERY_IS_AFFINE: return 1; - case FCLAW2D_MAP_QUERY_IS_NONLINEAR: + case FCLAW_MAP_QUERY_IS_NONLINEAR: return 0; - case FCLAW2D_MAP_QUERY_IS_GRAPH: + case FCLAW_MAP_QUERY_IS_GRAPH: return 0; - case FCLAW2D_MAP_QUERY_IS_PLANAR: + case FCLAW_MAP_QUERY_IS_PLANAR: return 1; - case FCLAW2D_MAP_QUERY_IS_ALIGNED: + case FCLAW_MAP_QUERY_IS_ALIGNED: return 0; - case FCLAW2D_MAP_QUERY_IS_FLAT: + case FCLAW_MAP_QUERY_IS_FLAT: return 1; - case FCLAW2D_MAP_QUERY_IS_DISK: + case FCLAW_MAP_QUERY_IS_DISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SPHERE: + case FCLAW_MAP_QUERY_IS_SPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWDISK: + case FCLAW_MAP_QUERY_IS_PILLOWDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_SQUAREDDISK: + case FCLAW_MAP_QUERY_IS_SQUAREDDISK: return 0; - case FCLAW2D_MAP_QUERY_IS_PILLOWSPHERE: + case FCLAW_MAP_QUERY_IS_PILLOWSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_CUBEDSPHERE: + case FCLAW_MAP_QUERY_IS_CUBEDSPHERE: return 0; - case FCLAW2D_MAP_QUERY_IS_FIVEPATCH: + case FCLAW_MAP_QUERY_IS_FIVEPATCH: return 0; - case FCLAW2D_MAP_QUERY_IS_BRICK: + case FCLAW_MAP_QUERY_IS_BRICK: return 1; default: printf("\n"); @@ -62,18 +62,26 @@ fclaw2d_map_query_nomap_brick (fclaw2d_map_context_t * cont, int query_identifie void - fclaw2d_map_c2m_nomap_brick(fclaw2d_map_context_t * cont, int blockno, - double xc, double yc, - double *xp, double *yp, double *zp) +fclaw_map_2d_c2m_nomap_brick(fclaw_map_context_t * cont, int blockno, + double xc, double yc, + double *xp, double *yp, double *zp) { /* Brick mapping to computational coordinates [0,1]x[0,1] */ - FCLAW2D_MAP_BRICK2C(&cont,&blockno,&xc,&yc,xp,yp,zp); + FCLAW_MAP_2D_BRICK2C(&cont,&blockno,&xc,&yc,xp,yp,zp); } +void +fclaw_map_3d_c2m_nomap_brick(fclaw_map_context_t * cont, int blockno, + double xc, double yc, double zc, + double *xp, double *yp, double *zp) +{ + /* Brick mapping to computational coordinates [0,1]x[0,1]x[0,1] */ + FCLAW_MAP_3D_BRICK2C(&cont,&blockno,&xc,&yc,&zc,xp,yp,zp); +} /* This shouldn't be called */ static void -fclaw3dx_map_c2m_nomap_brick(fclaw2d_map_context_t * cont, int blockno, +fclaw3dx_map_c2m_nomap_brick(fclaw_map_context_t * cont, int blockno, double xc, double yc, double zc, double *xp, double *yp, double *zp) { @@ -90,14 +98,14 @@ fclaw3dx_map_c2m_nomap_brick(fclaw2d_map_context_t * cont, int blockno, } -fclaw2d_map_context_t* fclaw2d_map_new_nomap_brick(fclaw2d_map_context_t* brick) +fclaw_map_context_t* fclaw_map_new_nomap_brick(fclaw_map_context_t* brick) { - fclaw2d_map_context_t *cont; - cont = FCLAW_ALLOC_ZERO (fclaw2d_map_context_t, 1); + fclaw_map_context_t *cont; + cont = FCLAW_ALLOC_ZERO (fclaw_map_context_t, 1); cont->query = fclaw2d_map_query_nomap_brick; - cont->mapc2m = fclaw2d_map_c2m_nomap_brick; + cont->mapc2m = fclaw_map_2d_c2m_nomap_brick; - cont->mapc2m_3dx = fclaw3dx_map_c2m_nomap_brick; + cont->mapc2m_3d = fclaw3dx_map_c2m_nomap_brick; cont->brick = brick; diff --git a/src/mappings/fivepatch/mapc2m_fivepatch.f b/src/mappings/fivepatch/mapc2m_fivepatch.f index 049e0bd83..60e429c89 100644 --- a/src/mappings/fivepatch/mapc2m_fivepatch.f +++ b/src/mappings/fivepatch/mapc2m_fivepatch.f @@ -1,5 +1,6 @@ C # This returns a unit square map in [-1,1]x[-1,1] - subroutine mapc2m_fivepatch(blockno,xc,yc,xp,yp,zp,alpha) + subroutine fclaw_map_2d_c2m_fivepatch( + & blockno,xc,yc,xp,yp,zp,alpha) implicit none integer blockno diff --git a/src/mappings/identity/mapc2m_identity.f b/src/mappings/identity/mapc2m_identity.f index 9b70bac77..e4d7bea79 100644 --- a/src/mappings/identity/mapc2m_identity.f +++ b/src/mappings/identity/mapc2m_identity.f @@ -1,4 +1,4 @@ - subroutine mapc2m_identity(blockno,xc,yc,xp,yp,zp) + subroutine fclaw_map_2d_c2m_identity(blockno,xc,yc,xp,yp,zp) implicit none double precision xc,yc,xp,yp,zp diff --git a/src/mappings/latlong/mapc2m_latlong.f b/src/mappings/latlong/mapc2m_latlong.f index 4fa5243e0..cbb1d5329 100644 --- a/src/mappings/latlong/mapc2m_latlong.f +++ b/src/mappings/latlong/mapc2m_latlong.f @@ -1,5 +1,5 @@ c # [xc,yc] are in [-180,180]x[0,360] - subroutine mapc2m_latlong(blockno,xc,yc,xp,yp,zp) + subroutine fclaw_map_2d_c2m_latlong(blockno,xc,yc,xp,yp,zp) implicit none integer blockno diff --git a/src/mappings/map_query.f b/src/mappings/map_query.f index 50001ca15..7b44a6f46 100644 --- a/src/mappings/map_query.f +++ b/src/mappings/map_query.f @@ -1,12 +1,12 @@ logical function ispillowsphere() implicit none - integer id, fclaw2d_map_is_pillowsphere + integer id, fclaw_map_is_pillowsphere integer*8 cont, fclaw_map_get_context cont = fclaw_map_get_context() - id = fclaw2d_map_is_pillowsphere(cont) + id = fclaw_map_is_pillowsphere(cont) ispillowsphere = id .ne. 0 end @@ -14,12 +14,12 @@ logical function ispillowsphere() logical function iscubedsphere() implicit none - integer id, fclaw2d_map_is_cubedsphere + integer id, fclaw_map_is_cubedsphere integer*8 cont, fclaw_map_get_context cont = fclaw_map_get_context() - id = fclaw2d_map_is_cubedsphere(cont) + id = fclaw_map_is_cubedsphere(cont) iscubedsphere = id .ne. 0 end @@ -27,12 +27,12 @@ logical function iscubedsphere() logical function issquareddisk() implicit none - integer id, fclaw2d_map_is_squareddisk + integer id, fclaw_map_is_squareddisk integer*8 cont, fclaw_map_get_context cont = fclaw_map_get_context() - id = fclaw2d_map_is_squareddisk(cont) + id = fclaw_map_is_squareddisk(cont) issquareddisk = id .ne. 0 end @@ -41,12 +41,12 @@ logical function issquareddisk() logical function isflat() implicit none - integer id, fclaw2d_map_is_flat + integer id, fclaw_map_is_flat integer*8 cont, fclaw_map_get_context cont = fclaw_map_get_context() - id = fclaw2d_map_is_flat(cont) + id = fclaw_map_is_flat(cont) isflat = id .ne. 0 end @@ -54,12 +54,12 @@ logical function isflat() logical function isaffine() implicit none - integer id, fclaw2d_map_is_affine + integer id, fclaw_map_is_affine integer*8 cont, fclaw_map_get_context cont = fclaw_map_get_context() - id = fclaw2d_map_is_affine(cont) + id = fclaw_map_is_affine(cont) isaffine = id .ne. 0 end @@ -69,12 +69,12 @@ logical function isaffine() logical function issphere() implicit none - integer id, fclaw2d_map_is_sphere + integer id, fclaw_map_is_sphere integer*8 cont, fclaw_map_get_context cont = fclaw_map_get_context() - id = fclaw2d_map_is_sphere(cont) + id = fclaw_map_is_sphere(cont) issphere = id .ne. 0 end @@ -83,12 +83,12 @@ logical function issphere() logical function ishemisphere() implicit none - integer id, fclaw2d_map_is_hemisphere + integer id, fclaw_map_is_hemisphere integer*8 cont, fclaw_map_get_context cont = fclaw_map_get_context() - id = fclaw2d_map_is_hemisphere(cont) + id = fclaw_map_is_hemisphere(cont) ishemisphere = id .ne. 0 end @@ -96,12 +96,12 @@ logical function ishemisphere() logical function iscart() implicit none - integer id, fclaw2d_map_is_cart + integer id, fclaw_map_is_cart integer*8 cont, fclaw_map_get_context cont = fclaw_map_get_context() - id = fclaw2d_map_is_cart(cont) + id = fclaw_map_is_cart(cont) iscart = id .ne. 0 end @@ -109,12 +109,12 @@ logical function iscart() logical function isdisk() implicit none - integer id, fclaw2d_map_is_disk + integer id, fclaw_map_is_disk integer*8 cont, fclaw_map_get_context cont = fclaw_map_get_context() - id = fclaw2d_map_is_disk(cont) + id = fclaw_map_is_disk(cont) isdisk = id .ne. 0 end diff --git a/src/mappings/pillowdisk/mapc2m_pillowdisk.f b/src/mappings/pillowdisk/mapc2m_pillowdisk.f index 38a41f070..60dc9c416 100644 --- a/src/mappings/pillowdisk/mapc2m_pillowdisk.f +++ b/src/mappings/pillowdisk/mapc2m_pillowdisk.f @@ -6,7 +6,7 @@ c # the unit disk. c # c # ------------------------------------------------------------------ - subroutine mapc2m_pillowdisk(blockno,xc1,yc1,xp,yp,zp) + subroutine fclaw_map_2d_c2m_pillowdisk(blockno,xc1,yc1,xp,yp,zp) implicit none double precision xc1,yc1,xp,yp,zp @@ -14,7 +14,7 @@ subroutine mapc2m_pillowdisk(blockno,xc1,yc1,xp,yp,zp) integer blockno c # Map to [-1,1]x[-1,1] - call mapc2m_cart(blockno,xc1,yc1,xc,yc,zc) + call fclaw_map_2d_c2m_cart(blockno,xc1,yc1,xc,yc,zc) c # Get circle of radius sqrt(2.d0) call mapc2p_disk_circle(xc,yc,xp,yp) diff --git a/src/mappings/pillowdisk5/mapc2m_pillowdisk5.f b/src/mappings/pillowdisk5/mapc2m_pillowdisk5.f index 333b1a6f7..d05ec14aa 100644 --- a/src/mappings/pillowdisk5/mapc2m_pillowdisk5.f +++ b/src/mappings/pillowdisk5/mapc2m_pillowdisk5.f @@ -1,4 +1,4 @@ - subroutine mapc2m_pillowdisk5(blockno,xc1,yc1, + subroutine fclaw_map_2d_c2m_pillowdisk5(blockno,xc1,yc1, & xp,yp,zp,alpha) implicit none @@ -6,12 +6,12 @@ subroutine mapc2m_pillowdisk5(blockno,xc1,yc1, double precision xc1, yc1 double precision xc,yc,zc,xp,yp,zp,alpha - call mapc2m_fivepatch(blockno,xc1,yc1,xc,yc,zc,alpha) + call fclaw_map_2d_c2m_fivepatch(blockno,xc1,yc1,xc,yc,zc,alpha) c # Map from [-1,1]x[-1,1] back to [0,1]x[0,1] xc = (xc + 1)/2.d0 yc = (yc + 1)/2.d0 - call mapc2m_pillowdisk(blockno,xc,yc,xp,yp,zp) + call fclaw_map_2d_c2m_pillowdisk(blockno,xc,yc,xp,yp,zp) end diff --git a/src/mappings/pillowsphere/mapc2m_pillowsphere.f b/src/mappings/pillowsphere/mapc2m_pillowsphere.f index af69bd5a5..b9a682a53 100644 --- a/src/mappings/pillowsphere/mapc2m_pillowsphere.f +++ b/src/mappings/pillowsphere/mapc2m_pillowsphere.f @@ -7,10 +7,11 @@ c # (blockno == 1). c # c # ------------------------------------------------------------------ - subroutine mapc2m_pillowsphere(blockno, xc1,yc1,xp,yp,zp) + subroutine fclaw_map_2d_c2m_pillowsphere( + & blockno, xc1,yc1,xp,yp,zp) implicit none - external mapc2m_cart + external fclaw_map_2d_c2m_cart double precision xc1,yc1, xp, yp, zp double precision x1, y1, d, rp2, xc, yc, zc @@ -19,7 +20,7 @@ subroutine mapc2m_pillowsphere(blockno, xc1,yc1,xp,yp,zp) logical ispillowsphere c # Map to [-1,1]x[-1,1] - call mapc2m_cart(blockno,xc1,yc1,xc,yc,zc) + call fclaw_map_2d_c2m_cart(blockno,xc1,yc1,xc,yc,zc) c # Map xc and yc from ghost cells to interior d = max(xc - 1.0,0.d0) + max(-1 - xc,0.d0) diff --git a/src/mappings/squareddisk/mapc2m_squareddisk.f b/src/mappings/squareddisk/mapc2m_squareddisk.f index a1471d598..b86febd9b 100644 --- a/src/mappings/squareddisk/mapc2m_squareddisk.f +++ b/src/mappings/squareddisk/mapc2m_squareddisk.f @@ -3,7 +3,8 @@ c # in fclaw2d_map.c (C. Burstedde) c # ------------------------------------------------------- - subroutine mapc2m_squareddisk(blockno,xc,yc,xp,yp,zp,alpha) + subroutine fclaw_map_2d_c2m_squareddisk( + & blockno,xc,yc,xp,yp,zp,alpha) implicit none double precision xc,yc,xp,yp,zp diff --git a/src/mappings/torus/mapc2m_torus.f b/src/mappings/torus/mapc2m_torus.f index 5856a6b8d..1061e2d06 100644 --- a/src/mappings/torus/mapc2m_torus.f +++ b/src/mappings/torus/mapc2m_torus.f @@ -1,4 +1,4 @@ - subroutine mapc2m_torus(xc,yc,xp,yp,zp,alpha, beta) + subroutine fclaw_map_2d_c2m_torus(xc,yc,xp,yp,zp,alpha, beta) implicit none double precision xc,yc,xp,yp,zp diff --git a/src/mappings/torus/mapc2m_twisted_torus.f b/src/mappings/torus/mapc2m_twisted_torus.f index 9e45a3773..3cce1bb0b 100644 --- a/src/mappings/torus/mapc2m_twisted_torus.f +++ b/src/mappings/torus/mapc2m_twisted_torus.f @@ -1,4 +1,5 @@ - subroutine mapc2m_twisted_torus(blockno,xc,yc,xp,yp,zp,alpha) + subroutine fclaw_map_2d_c2m_twisted_torus( + & blockno,xc,yc,xp,yp,zp,alpha) implicit none integer blockno diff --git a/src/patches/clawpatch/CMakeLists.txt b/src/patches/clawpatch/CMakeLists.txt index d70ee0355..6559e5c9c 100644 --- a/src/patches/clawpatch/CMakeLists.txt +++ b/src/patches/clawpatch/CMakeLists.txt @@ -4,15 +4,19 @@ set(metric ${PROJECT_SOURCE_DIR}/src/patches/metric) add_library(clawpatch_f OBJECT fclaw2d_clawpatch_utils.f + fclaw3d_clawpatch_utils.f90 fclaw3dx_clawpatch_utils.f + fort_user/fclaw2d_clawpatch_difference_exceeds_th.f90 fort_user/fclaw2d_clawpatch_value_exceeds_th.f90 fort_user/fclaw2d_clawpatch_minmax_exceeds_th.f90 fort_user/fclaw2d_clawpatch_gradient_exceeds_th.f90 - fort3_user/fclaw3dx_clawpatch_difference_exceeds_th.f90 - fort3_user/fclaw3dx_clawpatch_value_exceeds_th.f90 - fort3_user/fclaw3dx_clawpatch_minmax_exceeds_th.f90 - fort3_user/fclaw3dx_clawpatch_gradient_exceeds_th.f90 + + fort3_user/fclaw3d_clawpatch_difference_exceeds_th.f90 + fort3_user/fclaw3d_clawpatch_value_exceeds_th.f90 + fort3_user/fclaw3d_clawpatch_minmax_exceeds_th.f90 + fort3_user/fclaw3d_clawpatch_gradient_exceeds_th.f90 + fort_4.6/fclaw2d_clawpatch46_average.f fort_4.6/fclaw2d_clawpatch46_copy.f fort_4.6/fclaw2d_clawpatch46_interpolate.f @@ -33,16 +37,24 @@ add_library(clawpatch_f OBJECT fort_5.0/fclaw2d_clawpatch5_tag4refinement.f fort_5.0/fclaw2d_clawpatch5_tag4coarsening.f fort_5.0/fclaw2d_clawpatch5_timeinterp.f - fort3_4.6/fclaw3dx_clawpatch46_tag4refinement.f90 - fort3_4.6/fclaw3dx_clawpatch46_tag4coarsening.f90 - fort3_4.6/fclaw3dx_clawpatch46_average.f90 - fort3_4.6/fclaw3dx_clawpatch46_copy.f90 - fort3_4.6/fclaw3dx_clawpatch46_interpolate.f90 - fort3_4.6/fclaw3dx_clawpatch46_local_ghost_pack.f90 - fort3_4.6/fclaw3dx_clawpatch46_output_ascii.f90 - fort3_4.6/fclaw3dx_clawpatch46_timeinterp.f90 - fort3_4.6/fclaw3dx_clawpatch46_pillowsphere.f90 - fort3_4.6/fclaw3dx_clawpatch46_diagnostics.f90 + + fort3_4.6/fclaw3d_clawpatch46_diagnostics.f90 + fort3_4.6/fclaw3d_clawpatch46_local_ghost_pack.f90 + fort3_4.6/fclaw3d_clawpatch46_output_ascii.f90 + fort3_4.6/fclaw3d_clawpatch46_tag4coarsening.f90 + fort3_4.6/fclaw3d_clawpatch46_tag4refinement.f90 + fort3_4.6/fclaw3d_clawpatch46_timeinterp.f90 + + fort3_4.6/fclaw3d_clawpatch46_average.f90 + fort3_4.6/fclaw3d_clawpatch46_copy.f90 + fort3_4.6/fclaw3d_clawpatch46_interpolate.f90 + + fort3_4.6/fclaw3dx_clawpatch46_average.f90 + fort3_4.6/fclaw3dx_clawpatch46_copy.f90 + fort3_4.6/fclaw3dx_clawpatch46_interpolate.f90 + fort3_4.6/fclaw3dx_clawpatch46_local_ghost_pack.f90 + fort3_4.6/fclaw3dx_clawpatch46_pillowsphere.f90 + ${metric}/fortran_source2d/fclaw2d_metric_default_fort.f90 ${metric}/fortran_source3d/fclaw3d_metric_default_fort.f90 ) @@ -53,7 +65,7 @@ target_include_directories(clawpatch_f PRIVATE set_target_properties(clawpatch_f PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include) -target_include_directories(clawpatch_f INTERFACE +target_include_directories(clawpatch_f PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include ) @@ -61,31 +73,25 @@ target_include_directories(clawpatch_f INTERFACE add_library(clawpatch $ - fclaw2d_clawpatch.cpp - fclaw2d_clawpatch_options.c - fclaw2d_clawpatch_diagnostics.c - fclaw2d_clawpatch_diagnostics_default.c - fclaw2d_clawpatch_pillow.c + + fclaw_clawpatch.cpp + fclaw_clawpatch_diagnostics.c + fclaw_clawpatch_diagnostics_default.c + fclaw_clawpatch_options.c + fclaw_clawpatch_output_ascii.c + fclaw_clawpatch_output_vtk.c + fclaw_clawpatch_pillow.c + fclaw2d_clawpatch_transform.c - fclaw2d_clawpatch_output_ascii.c - fclaw2d_clawpatch_output_vtk.c fclaw2d_clawpatch_conservation.c - fclaw3dx_clawpatch.cpp - fclaw3dx_clawpatch_options.c - fclaw3dx_clawpatch_diagnostics.c - fclaw3dx_clawpatch_diagnostics_default.c - fclaw3dx_clawpatch_pillow.c - fclaw3dx_clawpatch_transform.c - fclaw3dx_clawpatch_output_ascii.c - fclaw3dx_clawpatch_output_vtk.c - fclaw3dx_clawpatch_conservation.c + fclaw3d_clawpatch_transform.c fort_user/fclaw2d_clawpatch_tag_criteria.c - fort3_user/fclaw3dx_clawpatch_tag_criteria.c + fort3_user/fclaw3d_clawpatch_tag_criteria.c ${metric}/fclaw2d_metric.cpp ${metric}/fclaw2d_metric_default.c - ${metric}/fclaw3d_metric.cpp + ${metric}/fclaw3d_metric.cpp ${metric}/fclaw3d_metric_default.c ) @@ -105,47 +111,36 @@ target_link_libraries(clawpatch PUBLIC forestclaw) install(FILES fclaw_clawpatch_enums.h - fclaw2d_clawpatch.h - fclaw2d_clawpatch.hpp - fclaw2d_clawpatch_options.h + fclaw_clawpatch.h + fclaw_clawpatch.hpp + fclaw_clawpatch_diagnostics.h + fclaw_clawpatch_options.h + fclaw_clawpatch_output_ascii.h + fclaw_clawpatch_output_vtk.h + fclaw_clawpatch_pillow.h + fclaw2d_clawpatch_conservation.h fclaw2d_clawpatch_transform.h - fclaw2d_clawpatch_diagnostics.h - fclaw2d_clawpatch_pillow.h fclaw2d_clawpatch_fort.h fclaw2d_clawpatch46_fort.h fclaw2d_clawpatch5_fort.h - fclaw2d_clawpatch_output_ascii.h - fclaw2d_clawpatch_output_vtk.h - - fclaw3dx_clawpatch.h - fclaw3dx_clawpatch.hpp - fclaw3dx_clawpatch_options.h - fclaw3dx_clawpatch_conservation.h - fclaw3dx_clawpatch_transform.h - fclaw3dx_clawpatch_diagnostics.h - fclaw3dx_clawpatch_pillow.h - fclaw3dx_clawpatch_fort.h - fclaw3dx_clawpatch46_fort.h - fclaw3dx_clawpatch_output_ascii.h - fclaw3dx_clawpatch_output_vtk.h + + fclaw3d_clawpatch_fort.h + fclaw3d_clawpatch46_fort.h ${metric}/fclaw2d_metric.h ${metric}/fclaw2d_metric.hpp ${metric}/fclaw2d_metric_default_fort.h - ${metric}/fortran_source2d/fclaw2d_metric_terms.i + ${metric}/fortran_source2d/fclaw2d_metric_terms.i ${metric}/fclaw3d_metric.h ${metric}/fclaw3d_metric.hpp ${metric}/fclaw3d_metric_default_fort.h - DESTINATION include + TYPE INCLUDE ) install(TARGETS clawpatch - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # -- export name set_target_properties(clawpatch PROPERTIES EXPORT_NAME CLAWPATCH) @@ -156,11 +151,15 @@ target_link_libraries(FORESTCLAW::CLAWPATCH INTERFACE clawpatch) if(BUILD_TESTING) add_executable(clawpatch.TEST - fclaw2d_clawpatch.h.TEST.cpp - fclaw2d_clawpatch_diagnostics.h.TEST.cpp + fclaw_clawpatch.h.2d.TEST.cpp + fclaw_clawpatch.h.3dx.TEST.cpp + fclaw_clawpatch.h.3d.TEST.cpp + fclaw_clawpatch.h.3d.ghostfill.TEST.cpp + fclaw_clawpatch.h.3d.interpolate.TEST.cpp + fclaw_clawpatch.h.3d.average.TEST.cpp + fclaw_clawpatch_options.h.TEST.cpp + fclaw_clawpatch_diagnostics.h.TEST.cpp fclaw2d_clawpatch_fort.h.TEST.cpp - fclaw2d_clawpatch_options.h.TEST.cpp - fclaw3dx_clawpatch.h.TEST.cpp ${metric}/fclaw2d_metric.h.TEST.cpp ) target_link_libraries(clawpatch.TEST testutils clawpatch forestclaw) diff --git a/src/patches/clawpatch/Makefile.am b/src/patches/clawpatch/Makefile.am index da31df8e2..4cf0fb208 100644 --- a/src/patches/clawpatch/Makefile.am +++ b/src/patches/clawpatch/Makefile.am @@ -4,28 +4,21 @@ libclawpatch_generated_headers = libclawpatch_installed_headers = \ src/patches/clawpatch/fclaw_clawpatch_enums.h \ \ - src/patches/clawpatch/fclaw2d_clawpatch.h \ - src/patches/clawpatch/fclaw2d_clawpatch.hpp \ - src/patches/clawpatch/fclaw2d_clawpatch_options.h \ + src/patches/clawpatch/fclaw_clawpatch.hpp \ + src/patches/clawpatch/fclaw_clawpatch.h \ + src/patches/clawpatch/fclaw_clawpatch_diagnostics.h \ + src/patches/clawpatch/fclaw_clawpatch_options.h \ + src/patches/clawpatch/fclaw_clawpatch_output_ascii.h \ + src/patches/clawpatch/fclaw_clawpatch_output_vtk.h \ + src/patches/clawpatch/fclaw_clawpatch_pillow.h \ + \ src/patches/clawpatch/fclaw2d_clawpatch_transform.h \ - src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.h \ - src/patches/clawpatch/fclaw2d_clawpatch_pillow.h \ src/patches/clawpatch/fclaw2d_clawpatch_fort.h \ src/patches/clawpatch/fclaw2d_clawpatch46_fort.h \ src/patches/clawpatch/fclaw2d_clawpatch5_fort.h \ - src/patches/clawpatch/fclaw2d_clawpatch_output_ascii.h \ - src/patches/clawpatch/fclaw2d_clawpatch_output_vtk.h \ \ - src/patches/clawpatch/fclaw3dx_clawpatch.h \ - src/patches/clawpatch/fclaw3dx_clawpatch.hpp \ - src/patches/clawpatch/fclaw3dx_clawpatch_options.h \ - src/patches/clawpatch/fclaw3dx_clawpatch_transform.h \ - src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics.h \ - src/patches/clawpatch/fclaw3dx_clawpatch_pillow.h \ - src/patches/clawpatch/fclaw3dx_clawpatch_fort.h \ - src/patches/clawpatch/fclaw3dx_clawpatch46_fort.h \ - src/patches/clawpatch/fclaw3dx_clawpatch_output_ascii.h \ - src/patches/clawpatch/fclaw3dx_clawpatch_output_vtk.h \ + src/patches/clawpatch/fclaw3d_clawpatch_fort.h \ + src/patches/clawpatch/fclaw3d_clawpatch46_fort.h \ \ src/patches/metric/fclaw2d_metric.h \ src/patches/metric/fclaw2d_metric.hpp \ @@ -35,50 +28,50 @@ libclawpatch_installed_headers = \ src/patches/metric/fclaw3d_metric_default_fort.h libclawpatch_compiled_sources = \ - src/patches/clawpatch/fclaw2d_clawpatch.cpp \ - src/patches/clawpatch/fclaw2d_clawpatch_options.c \ + src/patches/clawpatch/fclaw_clawpatch.cpp \ + src/patches/clawpatch/fclaw_clawpatch_diagnostics.c \ + src/patches/clawpatch/fclaw_clawpatch_diagnostics_default.c \ + src/patches/clawpatch/fclaw_clawpatch_options.c \ + src/patches/clawpatch/fclaw_clawpatch_output_ascii.c \ + src/patches/clawpatch/fclaw_clawpatch_output_vtk.c \ + src/patches/clawpatch/fclaw_clawpatch_pillow.c \ + \ src/patches/clawpatch/fclaw2d_clawpatch_conservation.c \ - src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.c \ - src/patches/clawpatch/fclaw2d_clawpatch_diagnostics_default.c \ - src/patches/clawpatch/fclaw2d_clawpatch_pillow.c \ src/patches/clawpatch/fclaw2d_clawpatch_transform.c \ - src/patches/clawpatch/fclaw2d_clawpatch_output_ascii.c \ - src/patches/clawpatch/fclaw2d_clawpatch_output_vtk.c \ src/patches/clawpatch/fclaw2d_clawpatch_utils.f \ \ - src/patches/clawpatch/fclaw3dx_clawpatch.cpp \ - src/patches/clawpatch/fclaw3dx_clawpatch_options.c \ - src/patches/clawpatch/fclaw3dx_clawpatch_conservation.c \ - src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics.c \ - src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics_default.c \ - src/patches/clawpatch/fclaw3dx_clawpatch_pillow.c \ - src/patches/clawpatch/fclaw3dx_clawpatch_transform.c \ - src/patches/clawpatch/fclaw3dx_clawpatch_output_ascii.c \ - src/patches/clawpatch/fclaw3dx_clawpatch_output_vtk.c \ src/patches/clawpatch/fclaw3dx_clawpatch_utils.f \ \ + src/patches/clawpatch/fclaw3d_clawpatch_transform.c \ + src/patches/clawpatch/fclaw3d_clawpatch_utils.f90 \ + \ src/patches/clawpatch/fort_user/fclaw2d_clawpatch_tag_criteria.c \ src/patches/clawpatch/fort_user/fclaw2d_clawpatch_difference_exceeds_th.f90 \ src/patches/clawpatch/fort_user/fclaw2d_clawpatch_value_exceeds_th.f90 \ src/patches/clawpatch/fort_user/fclaw2d_clawpatch_minmax_exceeds_th.f90 \ src/patches/clawpatch/fort_user/fclaw2d_clawpatch_gradient_exceeds_th.f90 \ \ - src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_tag_criteria.c \ - src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_difference_exceeds_th.f90 \ - src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_value_exceeds_th.f90 \ - src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_minmax_exceeds_th.f90 \ - src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_gradient_exceeds_th.f90 \ + src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_tag_criteria.c \ + src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_difference_exceeds_th.f90 \ + src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_value_exceeds_th.f90 \ + src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_minmax_exceeds_th.f90 \ + src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_gradient_exceeds_th.f90 \ + \ + src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_tag4refinement.f90 \ + src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_tag4coarsening.f90 \ + src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_average.f90 \ + src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_copy.f90 \ + src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_interpolate.f90 \ + src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_local_ghost_pack.f90 \ + src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_output_ascii.f90 \ + src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_timeinterp.f90 \ + src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_diagnostics.f90 \ \ - src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_tag4refinement.f90 \ - src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_tag4coarsening.f90 \ src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_average.f90 \ src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_copy.f90 \ src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_interpolate.f90 \ src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_local_ghost_pack.f90 \ - src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_output_ascii.f90 \ - src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_timeinterp.f90 \ src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_pillowsphere.f90 \ - src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_diagnostics.f90 \ \ src/patches/clawpatch/fort_4.6/fclaw2d_clawpatch46_tag4refinement.f \ src/patches/clawpatch/fort_4.6/fclaw2d_clawpatch46_tag4coarsening.f \ @@ -143,11 +136,13 @@ check_PROGRAMS += src/patches/clawpatch/clawpatch.TEST TESTS += src/patches/clawpatch/clawpatch.TEST src_patches_clawpatch_clawpatch_TEST_SOURCES = \ - src/patches/clawpatch/fclaw2d_clawpatch.h.TEST.cpp \ - src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.h.TEST.cpp \ + src/patches/clawpatch/fclaw_clawpatch.h.2d.TEST.cpp \ + src/patches/clawpatch/fclaw_clawpatch.h.3dx.TEST.cpp \ + src/patches/clawpatch/fclaw_clawpatch.h.3d.TEST.cpp \ + src/patches/clawpatch/fclaw_clawpatch.h.3d.ghostfill.TEST.cpp \ + src/patches/clawpatch/fclaw_clawpatch_options.h.TEST.cpp \ + src/patches/clawpatch/fclaw_clawpatch_diagnostics.h.TEST.cpp \ src/patches/clawpatch/fclaw2d_clawpatch_fort.h.TEST.cpp \ - src/patches/clawpatch/fclaw2d_clawpatch_options.h.TEST.cpp \ - src/patches/clawpatch/fclaw3dx_clawpatch.h.TEST.cpp \ src/patches/metric/fclaw2d_metric.h.TEST.cpp src_patches_clawpatch_clawpatch_TEST_CPPFLAGS = \ diff --git a/src/patches/clawpatch/fclaw2d_clawpatch.cpp b/src/patches/clawpatch/fclaw2d_clawpatch.cpp deleted file mode 100644 index f515914bf..000000000 --- a/src/patches/clawpatch/fclaw2d_clawpatch.cpp +++ /dev/null @@ -1,1843 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif - -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif - -#if REFINE_DIM == 2 && PATCH_DIM == 2 - -#define CLAWPATCH_VTABLE_NAME "fclaw2d_clawpatch" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#elif REFINE_DIM == 2 && PATCH_DIM == 3 - -#define CLAWPATCH_VTABLE_NAME "fclaw3dx_clawpatch" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include <_fclaw2d_to_fclaw3dx.h> -#include <_fclaw2d_to_fclaw3d.h> - -#endif - -#include /* Needed to get enum for build modes */ - -#include -#include -#include -#include - -#include -#include - -#include - -#include - - - -/* ------------------------------- Static function defs ------------------------------- */ - -/* Added to turn off time_interp */ -static int fill_ghost(fclaw2d_global_t* glob, int time_interp) -{ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); - if (fclaw_opt->timeinterp2fillghost) - /* This will always fill ghost cells using data from "qsync", which is either - coarse grid data at time step, or time interpolated data */ - return 1; - else - /* Only fill ghost cells with neighboring data if not doing time interpolation. - If doing time interpolation, then fine grid data at intermediate time steps - will be filled in some other way (.e.g. by advancing the solution in ghost - cells.) */ - return !time_interp; -} - - -/* Store virtual table for retrieval from anywhere */ - -static -fclaw2d_clawpatch_t* get_clawpatch(fclaw2d_patch_t *patch) -{ - fclaw2d_clawpatch_t *cp = (fclaw2d_clawpatch_t*) - fclaw2d_patch_get_user_patch(patch); - return cp; -} - -/* Needed for virtual patch function so that the metric class can be independent -of a clawpatch object */ -static -void* clawpatch_get_metric_patch(fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - return cp->mp; -} - - -static -fclaw2d_metric_patch_t* get_metric_patch(fclaw2d_patch_t *patch) -{ - return (fclaw2d_metric_patch_t*) clawpatch_get_metric_patch(patch); -} - -/* Return a pointer to either time interpolated data or regular grid data */ -static -double* q_time_sync(fclaw2d_patch_t* patch, int time_interp) -{ - fclaw2d_clawpatch_t* cp = get_clawpatch(patch); - if (time_interp) - return cp->griddata_time_interpolated.dataPtr(); - else - return cp->griddata.dataPtr(); -} - -static -double* clawpatch_get_area(struct fclaw2d_global* glob, - fclaw2d_patch_t* patch) -{ - return fclaw2d_metric_patch_get_area(glob, patch); -} - - -/* ----------------------------- Creating/deleting patches ---------------------------- */ - -static -void* clawpatch_new() -{ - fclaw2d_clawpatch_t *cp = new fclaw2d_clawpatch_t; - - /* This patch will only be defined if we are on a manifold. */ - cp->mp = fclaw2d_metric_patch_new(); - - return (void*) cp; -} - -static -void clawpatch_delete(void *patchcp) -{ - FCLAW_ASSERT(patchcp != NULL); - fclaw2d_clawpatch_t* cp = (fclaw2d_clawpatch_t*) patchcp; - fclaw2d_clawpatch_time_sync_delete(&cp->registers); - - FCLAW_ASSERT(cp->mp != NULL); - fclaw2d_metric_patch_delete(&cp->mp); - - delete cp; - patchcp = NULL; -} - -/* Maybe this should just be a 'build' function? */ -static -void clawpatch_define(fclaw2d_global_t* glob, - fclaw2d_patch_t *patch, - int blockno, int patchno, - fclaw2d_build_mode_t build_mode) -{ - /* We are getting closer to getting rid the class fclaw2d_clawpatch_t */ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - - cp->mx = clawpatch_opt->mx; - cp->my = clawpatch_opt->my; - cp->mbc = clawpatch_opt->mbc; - cp->blockno = blockno; - cp->meqn = clawpatch_opt->meqn; - cp->maux = clawpatch_opt->maux; - cp->mfields = clawpatch_opt->rhs_fields; - - for (int icorner=0; icorner < 4; icorner++) - { - fclaw2d_patch_set_block_corner_count(glob,patch,icorner,0); - } - - fclaw2d_map_context_t* cont = glob->cont; - - int is_brick = FCLAW2D_MAP_IS_BRICK(&cont); - - cp->manifold = fclaw_opt->manifold; - if (cp->manifold) - { - cp->xlower = patch->xlower; - cp->ylower = patch->ylower; - cp->xupper = patch->xupper; - cp->yupper = patch->yupper; - -#if PATCH_DIM == 3 -#if REFINE_DIM == 2 - cp->zlower = 0; - cp->zupper = 1; -#else -#error "clawpatch::define : Octrees not yet implemented." -#endif -#endif - } - else - { - double ax = fclaw_opt->ax; - double bx = fclaw_opt->bx; - double ay = fclaw_opt->ay; - double by = fclaw_opt->by; - - double xl = patch->xlower; - double yl = patch->ylower; - double xu = patch->xupper; - double yu = patch->yupper; - - double xlower, ylower, xupper, yupper; - - if (is_brick) - { - double z; - /* Scale to [0,1]x[0,1], based on blockno */ - fclaw2d_map_c2m_nomap_brick(cont,cp->blockno,xl,yl,&xlower,&ylower,&z); - fclaw2d_map_c2m_nomap_brick(cont,cp->blockno,xu,yu,&xupper,&yupper,&z); - } - else - { - xlower = xl; - ylower = yl; - xupper = xu; - yupper = yu; - } - cp->xlower = ax + (bx - ax)*xlower; - cp->xupper = ax + (bx - ax)*xupper; - cp->ylower = ay + (by - ay)*ylower; - cp->yupper = ay + (by - ay)*yupper; - -#if PATCH_DIM == 3 - /* Use [az,bz] to scale in z direction. This should work for - both extruded mesh and octree mesh. */ - double az = fclaw_opt->az; - double bz = fclaw_opt->bz; - -#if REFINE_DIM == 2 - double zlower = 0; - double zupper = 1; -#else -#error "clawpatch::define : Octrees not yet implemented." -#endif - cp->zlower = az + (bz - az)*zlower; - cp->zupper = az + (bz - az)*zupper; -#endif - - } - - cp->dx = (cp->xupper - cp->xlower)/cp->mx; - cp->dy = (cp->yupper - cp->ylower)/cp->my; - -#if PATCH_DIM == 3 -#if REFINE_DIM == 2 - /* For extruded mesh, we don't have any refinement in z */ - cp->mz = clawpatch_opt->mz; - cp->dz = (cp->zupper - cp->zlower)/cp->mz; - -#else -#error "clawpatch::define : Octrees not yet implemented." -#endif /* REFINE_DIM == 2 */ -#endif /* PATCH_DIM == 3 */ - - - int ll[PATCH_DIM]; - int ur[PATCH_DIM]; - for (int idir = 0; idir < PATCH_DIM; idir++) - { - ll[idir] = 1-cp->mbc; - } - ur[0] = cp->mx + cp->mbc; - ur[1] = cp->my + cp->mbc; -#if PATCH_DIM == 3 - ur[2] = cp->mz + cp->mbc; -#endif - - Box box(ll,ur,PATCH_DIM); - - // This will destroy any existing memory n griddata. - cp->griddata.define(box, cp->meqn); - if (fclaw_opt->subcycle) - cp->griddata_time_interpolated.define(box, cp->meqn); - - if (fclaw_opt->compute_error) - { - cp->griderror.define(box,cp->meqn); - cp->exactsolution.define(box,cp->meqn); - } - - if (clawpatch_opt->maux > 0) - { - cp->aux.define(box,cp->maux); - if (clawpatch_opt->save_aux) - cp->aux_save.define(box,cp->maux); - } - - if (clawpatch_opt->rhs_fields > 0) - { - cp->rhs.define(box,cp->mfields); - if (fclaw_opt->compute_error) - { - cp->elliptic_error.define(box,cp->mfields); - cp->elliptic_soln.define(box,cp->mfields); - } - } - - if (fclaw_opt->manifold) - { - /* - Allocate space for all metric terms. - - Note: We pass in detailed info so that the metric patch - doesn't have to know about a clawpatch - */ - -#if PATCH_DIM == 2 - fclaw2d_metric_patch_define(glob,patch, - cp->mx, cp->my, cp->mbc, - cp->dx, cp->dy, - cp->xlower,cp->ylower, cp->xupper, cp->yupper, - blockno, patchno, build_mode); -#elif PATCH_DIM == 3 - fclaw3d_metric_patch_define(glob,patch, - cp->mx, cp->my, cp->mz, cp->mbc, - cp->dx, cp->dy, cp->dz, - cp->xlower,cp->ylower, cp->zlower, - cp->xupper, cp->yupper, cp->zupper, - blockno, patchno, build_mode); -#endif - } - - /* Build interface registers needed for conservation */ - fclaw2d_clawpatch_time_sync_new(glob,patch, - blockno,patchno,&cp->registers); - - if (build_mode != FCLAW2D_BUILD_FOR_UPDATE) - /* If we are building ghost patches, we don't need all the patch memory */ - return; - - cp->griddata_last.define(box, cp->meqn); - cp->griddata_save.define(box, cp->meqn); - -} - -static -void clawpatch_build(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - int blockno, - int patchno, - void *user) -{ - fclaw2d_build_mode_t build_mode = *((fclaw2d_build_mode_t*) user); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - - /* Allocate space for all required arrays */ - clawpatch_define(glob,patch,blockno,patchno,build_mode); - - if (fclaw_opt->manifold) - { - /* Computes all metric terms : (xp,yp,zp,xd,yd,zd), - areas/volumes, basis vectors and (in 2d) curvatures - and surface normals. - - Note : Area/volume computations are expensive, since - they are all computed on finest levels - - Note : When building from fine, call routine below - where areas/volumes are averaged from fine patches */ - fclaw2d_metric_patch_build(glob,patch,blockno,patchno); - } - - /* Setup for conservation correction */ - fclaw2d_clawpatch_time_sync_setup(glob,patch,blockno,patchno); -} - -static -void clawpatch_build_from_fine(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, - fclaw2d_patch_t *coarse_patch, - int blockno, - int coarse_patchno, - int fine0_patchno, - fclaw2d_build_mode_t build_mode) -{ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - - clawpatch_define(glob,coarse_patch,blockno,coarse_patchno,build_mode); - - if (fclaw_opt->manifold) - { - /* Average areas/volume from fine grid to coarse grid */ - fclaw2d_metric_patch_build_from_fine(glob, fine_patches, - coarse_patch, - blockno, coarse_patchno, - fine0_patchno); - } - - /* Setup for conservation correction */ - fclaw2d_clawpatch_time_sync_setup(glob,coarse_patch,blockno,coarse_patchno); -} - - -/* -------------------------------- time stepping ------------------------------------- */ - -static -void clawpatch_save_step(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - cp->griddata_save = cp->griddata; - - /* Some aux arrays are time dependent, or contain part of the solution. In this case, - we should save the aux array in case we need to re-take a time step */ - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); - if (clawpatch_opt->save_aux) - cp->aux_save = cp->aux; -} - - -static -void clawpatch_restore_step(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - cp->griddata = cp->griddata_save; - - /* Restore the aux array after before retaking a time step */ - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); - if (clawpatch_opt->save_aux) - cp->aux = cp->aux_save; -} - -static -void clawpatch_setup_timeinterp(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - double alpha) -{ - /* We use the pack size here to make sure we are setting - everything correctly; it isn't needed for memory - allocation */ - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); - - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int meqn = clawpatch_opt->meqn; - int mbc = clawpatch_opt->mbc; - int mint = clawpatch_opt->interp_stencil_width/2+1; - - int hole = (mx - 2*mint)*(my - 2*mint); /* Hole in center */ - int wg = mx*my; /* Whole grid but no ghost cells. - Ghost cells will be averaged from finer level. */ -#if PATCH_DIM == 3 - int mz = clawpatch_opt->mz; - hole *= mz; - wg *= mz; -#endif - FCLAW_ASSERT(hole >= 0); - - int psize = (wg - hole)*meqn; - FCLAW_ASSERT(psize > 0); - - /* Store time interpolated data that will be use in coarse grid - exchanges */ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - double *qlast = cp->griddata_last.dataPtr(); - double *qcurr = cp->griddata.dataPtr(); - double *qinterp = cp->griddata_time_interpolated.dataPtr(); - - int ierror; - - /* Do interpolation only on interior, since ghost cells in qcurr - are invalid and will lead to floating point exceptions. - We do a ghost cell update at the intermediate time level. The - neighboring fine grid will average to ghost cells of the interpolated - level, then the interpolated level is used to interpolate to fine grid - ghost cells. */ - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); -#if PATCH_DIM == 2 - clawpatch_vt->fort_timeinterp(&mx,&my,&mbc,&meqn,&psize, - qcurr,qlast,qinterp,&alpha,&ierror); -#else - clawpatch_vt->fort_timeinterp(&mx,&my,&mz, &mbc,&meqn,&psize, - qcurr,qlast,qinterp,&alpha,&ierror); -#endif - -} - - -/* ------------------------------------- Ghost filling ------------------------------- */ - -static -void clawpatch_copy_face(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - fclaw2d_patch_t *neighbor_patch, - int iface, - int time_interp, - fclaw2d_patch_transform_data_t *transform_data) - -{ - - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - - /* This routine might be called between two time-sync patches */ - int meqn; - double *qthis; - fclaw2d_clawpatch_timesync_data(glob,patch,time_interp,&qthis,&meqn); - - double *qneighbor; - fclaw2d_clawpatch_timesync_data(glob,neighbor_patch,time_interp,&qneighbor,&meqn); - - if (fill_ghost(glob,time_interp)) - { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); -#if PATCH_DIM == 2 - clawpatch_vt->fort_copy_face(&mx,&my,&mbc,&meqn,qthis, - qneighbor,&iface,&transform_data); -#else - int mz = clawpatch_opt->mz; - clawpatch_vt->fort_copy_face(&mx,&my,&mz,&mbc,&meqn,qthis, - qneighbor,&iface,&transform_data); -#endif - } -} - -static -void clawpatch_average_face(fclaw2d_global_t *glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, - int idir, - int iface_coarse, - int p4est_refineFactor, - int refratio, - int time_interp, - int igrid, - fclaw2d_patch_transform_data_t* transform_data) -{ - int meqn; - double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); - double *qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); - - - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); - int manifold = fclaw_opt->manifold; - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); - - double *areacoarse = clawpatch_get_area(glob, coarse_patch); - double *areafine = clawpatch_get_area(glob, fine_patch); - -#if PATCH_DIM == 2 - /* These will be empty for non-manifolds cases */ - clawpatch_vt->fort_average_face(&mx,&my,&mbc,&meqn,qcoarse,qfine, - areacoarse,areafine, &idir,&iface_coarse, - &p4est_refineFactor, &refratio, - &igrid,&manifold,&transform_data); -#elif PATCH_DIM == 3 -#if 0 - double *volcoarse = clawpatch_get_volume(glob, coarse_patch); - double *volfine = clawpatch_get_volume(glob, fine_patch); -#endif - /* These will be empty for non-manifolds cases */ - double *volcoarse = areacoarse; - double *volfine = areafine; - int mz = clawpatch_opt->mz; - clawpatch_vt->fort_average_face(&mx,&my,&mz,&mbc,&meqn,qcoarse,qfine, - volcoarse,volfine, &idir,&iface_coarse, - &p4est_refineFactor, &refratio, - &igrid,&manifold,&transform_data); -#endif -} - -static -void clawpatch_interpolate_face(fclaw2d_global_t *glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, - int idir, - int iface_coarse, - int p4est_refineFactor, - int refratio, - int time_interp, - int igrid, - fclaw2d_patch_transform_data_t* transform_data) -{ - - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); - - int meqn; - double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); - double *qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); - - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - - if (fill_ghost(glob,time_interp)) - { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); -#if PATCH_DIM == 2 - clawpatch_vt->fort_interpolate_face(&mx,&my,&mbc,&meqn,qcoarse,qfine,&idir, - &iface_coarse, &p4est_refineFactor, - &refratio,&igrid,&transform_data); -#else - int mz = clawpatch_opt->mz; - clawpatch_vt->fort_interpolate_face(&mx,&my,&mz, &mbc,&meqn,qcoarse,qfine, - &idir,&iface_coarse, &p4est_refineFactor, - &refratio,&igrid,&transform_data); -#endif - } -} - -static -void clawpatch_copy_corner(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - fclaw2d_patch_t *corner_patch, - int coarse_blockno, - int fine_blockno, - int icorner, - int time_interp, - fclaw2d_patch_transform_data_t *transform_data) -{ - - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - - int meqn; - double *qthis; - fclaw2d_clawpatch_timesync_data(glob,patch,time_interp,&qthis,&meqn); - - double *qcorner; - fclaw2d_clawpatch_timesync_data(glob,corner_patch,time_interp,&qcorner,&meqn); - - if (fill_ghost(glob,time_interp)) - { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); -#if PATCH_DIM == 2 - clawpatch_vt->fort_copy_corner(&mx,&my,&mbc,&meqn,qthis,qcorner, - &icorner, &transform_data); -#else - int mz = clawpatch_opt->mz; - clawpatch_vt->fort_copy_corner(&mx,&my,&mz, &mbc,&meqn,qthis,qcorner, - &icorner, &transform_data); -#endif - } -} - - -static -void clawpatch_average_corner(fclaw2d_global_t *glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, - int coarse_blockno, - int fine_blockno, - int coarse_corner, - int time_interp, - fclaw2d_patch_transform_data_t* transform_data) -{ - int meqn; - double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); - - double *qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); - - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - int manifold = fclaw_opt->manifold; - if (fill_ghost(glob,time_interp)) - { - int refratio = 2; - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); - - double *areacoarse = clawpatch_get_area(glob, coarse_patch); - double *areafine = clawpatch_get_area(glob, fine_patch); - -#if PATCH_DIM == 2 - /* These will be empty for non-manifolds cases */ - clawpatch_vt->fort_average_corner(&mx,&my,&mbc,&meqn, - &refratio,qcoarse,qfine, - areacoarse,areafine, - &manifold,&coarse_corner,&transform_data); -#elif PATCH_DIM == 3 - /* These will be empty for non-manifolds cases */ -#if 0 - double *volcoarse = clawpatch_get_volume(glob, coarse_patch); - double *volfine = clawpatch_get_volume(glob, fine_patch); -#endif - double *volcoarse = areacoarse; - double *volfine = areafine; - int mz = clawpatch_opt->mz; - clawpatch_vt->fort_average_corner(&mx,&my,&mz,&mbc,&meqn, - &refratio,qcoarse,qfine, - volcoarse,volfine, - &manifold,&coarse_corner,&transform_data); -#endif - } -} - -static -void clawpatch_interpolate_corner(fclaw2d_global_t* glob, - fclaw2d_patch_t* coarse_patch, - fclaw2d_patch_t* fine_patch, - int coarse_blockno, - int fine_blockno, - int coarse_corner, - int time_interp, - fclaw2d_patch_transform_data_t* transform_data) - -{ - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - - int meqn; - double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); - - double *qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); - - if (fill_ghost(glob,time_interp)) - { - int refratio = 2; - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); -#if PATCH_DIM == 2 - clawpatch_vt->fort_interpolate_corner(&mx,&my,&mbc,&meqn, - &refratio,qcoarse,qfine, - &coarse_corner,&transform_data); -#else - int mz = clawpatch_opt->mz; - clawpatch_vt->fort_interpolate_corner(&mx,&my,&mz,&mbc,&meqn, - &refratio,qcoarse,qfine, - &coarse_corner,&transform_data); -#endif - - } - -} - - - -/* -------------------------------- Regridding functions ------------------------------ */ - -static -int clawpatch_tag4refinement(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - int blockno, int patchno, - int initflag) -{ - int meqn; - double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); - - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - double refine_threshold = fclaw_opt->refine_threshold; - - int tag_patch; - if (refine_threshold < 0) - { - /* Always refine */ - tag_patch = 1; - } - else - { - tag_patch = 0; - - /* This allows the user to specify a "exceeds_th" */ - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); - - int mx,my,mbc; - double xlower,ylower,dx,dy; - fclaw2d_global_set_global(glob); -#if PATCH_DIM == 2 - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, - &xlower,&ylower,&dx,&dy); - clawpatch_vt->fort_tag4refinement(&mx,&my,&mbc,&meqn,&xlower,&ylower, - &dx,&dy, &blockno, q, - &refine_threshold, - &initflag,&tag_patch); -#elif PATCH_DIM == 3 - int mz; - double zlower,dz; - fclaw3dx_clawpatch_grid_data(glob,patch,&mx,&my,&mz, &mbc, - &xlower,&ylower,&zlower, &dx,&dy,&dz); - - clawpatch_vt->fort_tag4refinement(&mx,&my,&mz, &mbc,&meqn, - &xlower,&ylower,&zlower, - &dx,&dy, &dz, &blockno, q, - &refine_threshold, - &initflag,&tag_patch); -#endif - fclaw2d_global_unset_global(); - } - return tag_patch; -} - -static -int clawpatch_tag4coarsening(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, - int blockno, - int patchno, - int initflag) -{ -#if REFINE_DIM == 3 - fclaw_global_essentialf("tag4coarsening : Not implemented for full 3d " \ - "refinement.\n"); - exit(0); -#endif - - int mx,my,mbc,meqn; - double xlower[4],ylower[4],dx,dy; -#if PATCH_DIM == 3 - int mz; - double zlower, dz; -#endif - - double *q[4]; /* Only need four grids, even for extruded mesh case */ - for (int igrid = 0; igrid < 4; igrid++) - { - fclaw2d_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); -#if PATCH_DIM == 2 - fclaw2d_clawpatch_grid_data(glob,&fine_patches[igrid],&mx,&my,&mbc, - &xlower[igrid],&ylower[igrid],&dx,&dy); -#elif PATCH_DIM == 3 - /* For extruded meshes, zlower is the same for all patches. */ - fclaw2d_clawpatch_grid_data(glob,&fine_patches[igrid],&mx,&my,&mz,&mbc, - &xlower[igrid],&ylower[igrid],&zlower,&dx,&dy,&dz); -#endif - } - - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - double coarsen_threshold = fclaw_opt->coarsen_threshold; - - int tag_patch = 0; - if (coarsen_threshold > 0) - { - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); - fclaw2d_global_set_global(glob); -#if PATCH_DIM == 2 - /* Get xlower,ylower for each grid. */ - clawpatch_vt->fort_tag4coarsening(&mx,&my,&mbc,&meqn, - xlower,ylower,&dx,&dy, - &blockno, q[0],q[1],q[2],q[3], - &coarsen_threshold,&initflag,&tag_patch); -#elif PATCH_DIM == 3 - - clawpatch_vt->fort_tag4coarsening(&mx,&my,&mz,&mbc,&meqn, - xlower,ylower,&zlower,&dx,&dy,&dz, - &blockno, q[0],q[1],q[2],q[3], - &coarsen_threshold,&initflag,&tag_patch); -#endif - fclaw2d_global_unset_global(); - } - else - { - /* Never coarsen */ - } - return tag_patch == 1; -} - -static -void clawpatch_interpolate2fine(fclaw2d_global_t* glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t* fine_patches, - int this_blockno, int coarse_patchno, - int fine0_patchno) -{ - - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - int meqn = clawpatch_opt->meqn; - - /* Loop over four siblings (z-ordering) */ - for (int igrid = 0; igrid < FCLAW2D_NUMSIBLINGS; igrid++) - { - fclaw2d_patch_t *fine_patch = &fine_patches[igrid]; - double *qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); - - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); - - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); - - double *areacoarse = clawpatch_get_area(glob, coarse_patch); - double *areafine = NULL; - - double *qcoarse = fclaw2d_clawpatch_get_q(glob,coarse_patch); - -#if PATCH_DIM == 2 - if (fclaw_opt->manifold) - areafine = clawpatch_get_area(glob, fine_patch); - - clawpatch_vt->fort_interpolate2fine(&mx,&my,&mbc,&meqn,qcoarse,qfine, - areacoarse, areafine, &igrid, - &fclaw_opt->manifold); -#elif PATCH_DIM == 3 - double *volfine = areafine; - if (fclaw_opt->manifold) - volfine = clawpatch_get_volume(glob, fine_patch); - double *volcoarse = areacoarse; - - int mz = clawpatch_opt->mz; - clawpatch_vt->fort_interpolate2fine(&mx,&my,&mz, &mbc,&meqn,qcoarse,qfine, - volcoarse, volfine, &igrid, - &fclaw_opt->manifold); -#endif - } -} - -static -void clawpatch_average2coarse(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, - fclaw2d_patch_t *coarse_patch, - int blockno, int fine0_patchno, - int coarse_patchno) - -{ - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - int meqn = clawpatch_opt->meqn; - - double *areacoarse = clawpatch_get_area(glob, coarse_patch); - - double *qcoarse = fclaw2d_clawpatch_get_q(glob,coarse_patch); - - for(int igrid = 0; igrid < FCLAW2D_NUMSIBLINGS; igrid++) - { - fclaw2d_patch_t *fine_patch = &fine_patches[igrid]; - double *qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); - - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); - - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); - - -#if PATCH_DIM == 2 - double *areafine = NULL; - if (fclaw_opt->manifold) - areafine = clawpatch_get_area(glob, fine_patch); - clawpatch_vt->fort_average2coarse(&mx,&my,&mbc,&meqn,qcoarse,qfine, - areacoarse, areafine, &igrid, - &fclaw_opt->manifold); -#elif PATCH_DIM == 3 - double *volfine = NULL; - double *volcoarse = areacoarse; - if (fclaw_opt->manifold) - volfine = clawpatch_get_volume(glob, fine_patch); - int mz = clawpatch_opt->mz; - clawpatch_vt->fort_average2coarse(&mx,&my,&mz, &mbc,&meqn,qcoarse,qfine, - volcoarse, volfine, &igrid, - &fclaw_opt->manifold); -#endif - - } -} - -/* ------------------------------ Parallel ghost patches ------------------------------ */ - -/* This is called just to get a count of how much to pack */ -static -size_t clawpatch_ghost_pack_elems(fclaw2d_global_t* glob) -{ - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - int meqn = clawpatch_opt->meqn; - - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - int refratio = fclaw_opt->refratio; - int packextra = fclaw_opt->ghost_patch_pack_numextrafields; - int packarea = fclaw_opt->ghost_patch_pack_area && fclaw_opt->manifold; - int packregisters = fclaw_opt->time_sync; - - int mint = refratio*mbc; - int nghost = mbc; - - /* Include size of conservation registers. Save fluxes on each size, - even though only one or two sides may be used. */ - // int frsize = 12*meqn*(mx + my); - - int frsize = packregisters ? 2*(4*meqn+2)*(mx + my) : 0; -#if PATCH_DIM == 3 - int mz = clawpatch_opt->mz; - if (packregisters) - { - fclaw_global_essentialf("clawpatch_ghost_comm: Conservation fix not yet " \ - "implemented in 3d\n"); - exit(0); - } -#endif - - int wg = (2*nghost + mx)*(2*nghost + my); /* Whole grid */ - int hole = (mx - 2*mint)*(my - 2*mint); /* Hole in center */ - -#if PATCH_DIM == 3 - wg *= (mz + 2*nghost); - hole *= (mz + 2*nghost); -#endif - FCLAW_ASSERT(hole >= 0); - - size_t psize = (wg - hole)*(meqn + packarea + packextra) + frsize; - FCLAW_ASSERT(psize >= 0); - - return psize; -} - - -static -void clawpatch_ghost_comm(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - void *unpack_from_here, int time_interp, - int packmode) -{ - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - int meqn = clawpatch_opt->meqn; - - int packarea = packmode/2; // (0,1)/2 = 0; (2,3)/2 = 1; - - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - int packextra = fclaw_opt->ghost_patch_pack_numextrafields; - int packregisters = fclaw_opt->time_sync; // For conservation - int refratio = fclaw_opt->refratio; - - int mint = refratio*mbc; /* # interior cells needed for averaging */ - int nghost = mbc; /* # ghost values needed for interpolation */ - - /* Include size of conservation registers. Save fluxes on each size, - even though only one or two sides may be used. - - y-face : gp,gm,f(qfront),f(qback) + edge-length + area : 4*meqn + 2 - x-face : fp,fm,f(ql),f(qr) + edge-length + area : 4*meqn + 2 - - Multiply everything by mz to get fluxes on each face of cube. - (Time sync not yet implemented in 3d, though). - - */ - int frsize = packregisters ? 2*(4*meqn+2)*(mx + my) : 0; - -#if PATCH_DIM == 3 - int mz = clawpatch_opt->mz; - if (packregisters) - { - fclaw_global_essentialf("clawpatch_ghost_comm: Conservation fix not yet " \ - "implemented in 3d\n"); - exit(0); - } -#endif - - /* wg : whole grid - hole : part we don't store */ - /* This is computed twice - here, and in fclaw2d_clawpatch_ghost_packsize */ - int wg = (2*nghost + mx)*(2*nghost + my); - int hole = (mx - 2*mint)*(my - 2*mint); /* Hole in center */ - -#if PATCH_DIM == 3 - wg *= (mz + 2*nghost); - hole *= (mz + 2*nghost); -#endif - FCLAW_ASSERT(hole >= 0); - - size_t psize = (wg - hole)*(meqn + packarea + packextra) + frsize; - FCLAW_ASSERT(psize > 0); - - size_t psize_check = clawpatch_ghost_pack_elems(glob); - - /* Check with routine that is used to allocate space */ - FCLAW_ASSERT(psize == psize_check); - - int ierror; - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); - - double *qthis; - fclaw2d_clawpatch_timesync_data(glob,patch,time_interp,&qthis,&meqn); - double *qpack = (double*) unpack_from_here; -#if PATCH_DIM == 2 - int qareasize = (wg - hole)*(meqn + packarea); - double *area = clawpatch_get_area(glob, patch); - clawpatch_vt->fort_local_ghost_pack(&mx,&my,&mbc,&meqn,&mint,qthis,area, - qpack,&qareasize,&packmode,&ierror); -#elif PATCH_DIM == 3 - int qvolsize = (wg - hole)*(meqn + packarea); - double *vol = clawpatch_get_volume(glob, patch); - clawpatch_vt->fort_local_ghost_pack(&mx,&my,&mz,&mbc,&meqn,&mint,qthis,vol, - qpack,&qvolsize,&packmode,&ierror); -#endif - FCLAW_ASSERT(ierror == 0); - -#if PATCH_DIM == 2 - qpack += qareasize; /* Advance pointer */ -#elif PATCH_DIM == 3 - qpack += qvolsize; /* Advance pointer */ -#endif - - int extrasize = (wg - hole)*(packextra); - if (packextra) - { - FCLAW_ASSERT(extrasize > 0); - FCLAW_ASSERT(clawpatch_vt->local_ghost_pack_aux != NULL); - clawpatch_vt->local_ghost_pack_aux(glob,patch,mint, - qpack,extrasize, - packmode,&ierror); - FCLAW_ASSERT(ierror == 0); - qpack += extrasize; /* Advance pointer */ - } - - FCLAW_ASSERT(ierror == 0); - if (packregisters) - { - FCLAW_ASSERT(frsize > 0); - FCLAW_ASSERT(clawpatch_vt->time_sync_pack_registers != NULL); - fclaw_clawpatch_packmode_t frpackmode = packmode % 2 == 0 ? - CLAWPATCH_REGISTER_PACK : - CLAWPATCH_REGISTER_UNPACK; - clawpatch_vt->time_sync_pack_registers(glob, patch, - qpack,frsize,frpackmode, - &ierror); - FCLAW_ASSERT(ierror == 0); - } - - - if (ierror > 0) - { - fclaw_global_essentialf("clawpatch_ghost_comm : ierror = %d\n",ierror); - exit(0); - } -} - - -static size_t clawpatch_ghost_packsize(fclaw2d_global_t* glob) -{ - size_t esize = clawpatch_ghost_pack_elems(glob); - return esize*sizeof(double); -} - -static -void clawpatch_local_ghost_pack(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - void *patch_data, - int time_interp) -{ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - int packarea = fclaw_opt->ghost_patch_pack_area && fclaw_opt->manifold; - int packmode = 2*packarea; // 0 or 2 (for pack) - - clawpatch_ghost_comm(glob,patch,patch_data, time_interp,packmode); -} - -static -void clawpatch_remote_ghost_unpack(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - int blockno, - int patchno, - void *qdata, int time_interp) -{ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - int packarea = fclaw_opt->ghost_patch_pack_area && fclaw_opt->manifold; - int packmode = 2*packarea + 1; // 1 or 3 (for unpack) - - clawpatch_ghost_comm(glob,patch,qdata,time_interp,packmode); -} - -static -void clawpatch_remote_ghost_build(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - int blockno, - int patchno, - fclaw2d_build_mode_t build_mode) -{ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - - clawpatch_define(glob,patch,blockno,patchno,build_mode); - - if (fclaw_opt->manifold) - { - if (build_mode != FCLAW2D_BUILD_FOR_GHOST_AREA_PACKED) - { - /* Cell areas/volumes are not sent as MPI messages and so must - be recomputed - */ - //fclaw2d_metric_patch_build(glob,patch,blockno,patchno); - fclaw2d_metric_patch_compute_area(glob,patch,blockno,patchno); - } - } - /* Any metric terms we might need for the registers are packed */ -#if 0 - /* Setup for conservation correction */ - fclaw2d_clawpatch_time_sync_setup(glob,this_patch,blockno,patchno); -#endif -} - -static -void clawpatch_remote_ghost_delete(void *patchcp) -{ - clawpatch_delete(patchcp); -} - -/* ---------------------------- Parallel partitioning --------------------------------- */ - -static -size_t clawpatch_partition_packsize(fclaw2d_global_t* glob) -{ - const fclaw2d_clawpatch_options_t *clawpatch_opt - = fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int mbc = clawpatch_opt->mbc; - int meqn = clawpatch_opt->meqn; - size_t psize = meqn*(2*mbc + mx)*(2*mbc + my); /* Store area */ - -#if PATCH_DIM == 3 - int mz = clawpatch_opt->mz; - psize *= (2*mbc + mz); -#endif - - return psize*sizeof(double); -} - -static -void clawpatch_partition_pack(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - int blockno, - int patchno, - void *pack_data_here) - { - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - FCLAW_ASSERT(cp != NULL); - - cp->griddata.copyToMemory((double*) pack_data_here); -} - -static -void clawpatch_partition_unpack(fclaw2d_global_t *glob, - fclaw2d_domain_t *new_domain, - fclaw2d_patch_t *patch, - int blockno, - int patchno, - void *unpack_data_from_here) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - - /* Time interp is false, since we only partition when all grids - are time synchronized and all flux registers are set to - zero. After copying data, we re-build patch with any - data needed. */ - cp->griddata.copyFromMemory((double*)unpack_data_from_here); -} - -/* ------------------------------------ Virtual table -------------------------------- */ - -static -fclaw2d_clawpatch_vtable_t* clawpatch_vt_new() -{ - return (fclaw2d_clawpatch_vtable_t*) FCLAW_ALLOC_ZERO (fclaw2d_clawpatch_vtable_t, 1); -} - -static -void clawpatch_vt_destroy(void* vt) -{ - FCLAW_FREE (vt); -} - -void fclaw2d_clawpatch_vtable_initialize(fclaw2d_global_t* glob, - int claw_version) -{ - fclaw2d_patch_vtable_t *patch_vt = fclaw2d_patch_vt(glob); - - fclaw2d_metric_vtable_initialize(glob); - - fclaw2d_clawpatch_vtable_t *clawpatch_vt = clawpatch_vt_new(); - - /* Patch setup */ - patch_vt->patch_new = clawpatch_new; - patch_vt->patch_delete = clawpatch_delete; - patch_vt->build = clawpatch_build; - patch_vt->build_from_fine = clawpatch_build_from_fine; - - /* Time stepping */ - patch_vt->restore_step = clawpatch_restore_step; - patch_vt->save_step = clawpatch_save_step; - patch_vt->setup_timeinterp = clawpatch_setup_timeinterp; - - /* Ghost filling */ - patch_vt->copy_face = clawpatch_copy_face; - patch_vt->average_face = clawpatch_average_face; - patch_vt->interpolate_face = clawpatch_interpolate_face; - - patch_vt->copy_corner = clawpatch_copy_corner; - patch_vt->average_corner = clawpatch_average_corner; - patch_vt->interpolate_corner = clawpatch_interpolate_corner; - - /* Assume regular block corners; Change by calling 'fclaw2d_clawpatch_use_pillowsphere' */ - patch_vt->copy_block_corner = clawpatch_copy_corner; - patch_vt->average_block_corner = clawpatch_average_corner; - patch_vt->interpolate_block_corner = clawpatch_interpolate_corner; - - /* Timing syncing module for conservation */ - patch_vt->time_sync_f2c = fclaw2d_clawpatch_time_sync_f2c; - patch_vt->time_sync_samesize = fclaw2d_clawpatch_time_sync_samesize; - patch_vt->time_sync_reset = fclaw2d_clawpatch_time_sync_reset; - - /* Transform functions (defined in forestclaw2d */ - patch_vt->transform_init_data = fclaw2d_clawpatch_transform_init_data; - patch_vt->transform_face = fclaw2d_clawpatch_face_transformation; /* forestclaw2d.c */ - patch_vt->transform_face_intra = fclaw2d_clawpatch_face_transformation_intra; /* forestclaw2d.c */ - - /* Regridding functions */ - patch_vt->tag4refinement = clawpatch_tag4refinement; - patch_vt->tag4coarsening = clawpatch_tag4coarsening; - - patch_vt->average2coarse = clawpatch_average2coarse; - patch_vt->interpolate2fine = clawpatch_interpolate2fine; - - /* ghost patch */ - patch_vt->ghost_packsize = clawpatch_ghost_packsize; - patch_vt->local_ghost_pack = clawpatch_local_ghost_pack; - patch_vt->remote_ghost_build = clawpatch_remote_ghost_build; - patch_vt->remote_ghost_unpack = clawpatch_remote_ghost_unpack; - patch_vt->remote_ghost_delete = clawpatch_remote_ghost_delete; - - - /* partitioning */ - patch_vt->partition_packsize = clawpatch_partition_packsize; - patch_vt->partition_pack = clawpatch_partition_pack; - patch_vt->partition_unpack = clawpatch_partition_unpack; - - /* output functions */ - clawpatch_vt->time_header_ascii = fclaw2d_clawpatch_time_header_ascii; - clawpatch_vt->cb_output_ascii = cb_clawpatch_output_ascii; - - /* Metric access */ - patch_vt->metric_patch = clawpatch_get_metric_patch; - - /* Ghost pack for registers (doesn't depend on clawpack version) */ - clawpatch_vt->time_sync_pack_registers = fclaw2d_clawpatch_time_sync_pack_registers; - - /* Tagging functions. The default uses option 'refinement_criteria'. */ - clawpatch_vt->fort_user_exceeds_threshold = NULL; - - /* Fortran functions that depend on data layout (version 4.6 or 5.0) */ - -#if PATCH_DIM == 2 - if (claw_version == 4) - { - /* Clawpatch settings functions */ - clawpatch_vt->fort_average2coarse = FCLAW2D_CLAWPATCH46_FORT_AVERAGE2COARSE; - clawpatch_vt->fort_interpolate2fine = FCLAW2D_CLAWPATCH46_FORT_INTERPOLATE2FINE; - - clawpatch_vt->fort_tag4refinement = FCLAW2D_CLAWPATCH46_FORT_TAG4REFINEMENT; - clawpatch_vt->fort_tag4coarsening = FCLAW2D_CLAWPATCH46_FORT_TAG4COARSENING; - - /* output functions */ - clawpatch_vt->fort_header_ascii = FCLAW2D_CLAWPATCH46_FORT_HEADER_ASCII; - clawpatch_vt->fort_output_ascii = FCLAW2D_CLAWPATCH46_FORT_OUTPUT_ASCII; - - /* Diagnostic functions */ - clawpatch_vt->conservation_check = fclaw2d_clawpatch_diagnostics_cons_default; - clawpatch_vt->compute_error = fclaw2d_clawpatch_diagnostics_error_default; - clawpatch_vt->fort_compute_patch_error = NULL; /* User defined */ - clawpatch_vt->fort_compute_error_norm = FCLAW2D_CLAWPATCH46_FORT_COMPUTE_ERROR_NORM; - clawpatch_vt->fort_compute_patch_area = FCLAW2D_CLAWPATCH46_FORT_COMPUTE_PATCH_AREA; - clawpatch_vt->fort_conservation_check = FCLAW2D_CLAWPATCH46_FORT_CONSERVATION_CHECK; - - /* Ghost cell exchange functions */ - clawpatch_vt->fort_copy_face = FCLAW2D_CLAWPATCH46_FORT_COPY_FACE; - clawpatch_vt->fort_average_face = FCLAW2D_CLAWPATCH46_FORT_AVERAGE_FACE; - clawpatch_vt->fort_interpolate_face = FCLAW2D_CLAWPATCH46_FORT_INTERPOLATE_FACE; - - clawpatch_vt->fort_copy_corner = FCLAW2D_CLAWPATCH46_FORT_COPY_CORNER; - clawpatch_vt->fort_average_corner = FCLAW2D_CLAWPATCH46_FORT_AVERAGE_CORNER; - clawpatch_vt->fort_interpolate_corner = FCLAW2D_CLAWPATCH46_FORT_INTERPOLATE_CORNER; - - clawpatch_vt->local_ghost_pack_aux = NULL; - clawpatch_vt->fort_local_ghost_pack = FCLAW2D_CLAWPATCH46_FORT_LOCAL_GHOST_PACK; - - clawpatch_vt->fort_timeinterp = FCLAW2D_CLAWPATCH46_FORT_TIMEINTERP; - } - else - { - /* Clawpatch settings functions */ - clawpatch_vt->fort_average2coarse = FCLAW2D_CLAWPATCH5_FORT_AVERAGE2COARSE; - clawpatch_vt->fort_interpolate2fine = FCLAW2D_CLAWPATCH5_FORT_INTERPOLATE2FINE; - - clawpatch_vt->fort_tag4refinement = FCLAW2D_CLAWPATCH5_FORT_TAG4REFINEMENT; - clawpatch_vt->fort_tag4coarsening = FCLAW2D_CLAWPATCH5_FORT_TAG4COARSENING; - - /* output functions */ - clawpatch_vt->fort_header_ascii = FCLAW2D_CLAWPATCH5_FORT_HEADER_ASCII; - clawpatch_vt->fort_output_ascii = FCLAW2D_CLAWPATCH5_FORT_OUTPUT_ASCII; - - /* Diagnostic functions */ - clawpatch_vt->conservation_check = fclaw2d_clawpatch_diagnostics_cons_default; - clawpatch_vt->compute_error = fclaw2d_clawpatch_diagnostics_error_default; - clawpatch_vt->fort_compute_patch_error = NULL; /* User defined */ - clawpatch_vt->fort_compute_error_norm = FCLAW2D_CLAWPATCH5_FORT_COMPUTE_ERROR_NORM; - clawpatch_vt->fort_compute_patch_area = FCLAW2D_CLAWPATCH5_FORT_COMPUTE_PATCH_AREA; - clawpatch_vt->fort_conservation_check = FCLAW2D_CLAWPATCH5_FORT_CONSERVATION_CHECK; - - /* Ghost cell exchange functions */ - clawpatch_vt->fort_copy_face = FCLAW2D_CLAWPATCH5_FORT_COPY_FACE; - clawpatch_vt->fort_average_face = FCLAW2D_CLAWPATCH5_FORT_AVERAGE_FACE; - clawpatch_vt->fort_interpolate_face = FCLAW2D_CLAWPATCH5_FORT_INTERPOLATE_FACE; - - clawpatch_vt->fort_copy_corner = FCLAW2D_CLAWPATCH5_FORT_COPY_CORNER; - clawpatch_vt->fort_average_corner = FCLAW2D_CLAWPATCH5_FORT_AVERAGE_CORNER; - clawpatch_vt->fort_interpolate_corner = FCLAW2D_CLAWPATCH5_FORT_INTERPOLATE_CORNER; - - clawpatch_vt->local_ghost_pack_aux = NULL; - clawpatch_vt->fort_local_ghost_pack = FCLAW2D_CLAWPATCH5_FORT_LOCAL_GHOST_PACK; - - clawpatch_vt->fort_timeinterp = FCLAW2D_CLAWPATCH5_FORT_TIMEINTERP; - } -#elif PATCH_DIM == 3 - /* Signatures (defined in 'typedefs') for 3d Fortran routines are different - those used in 2d routines above */ - if (claw_version == 4) - { - /* Clawpatch settings functions */ - clawpatch_vt->fort_average2coarse = FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE; - clawpatch_vt->fort_interpolate2fine = FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE; - - clawpatch_vt->fort_tag4refinement = FCLAW3DX_CLAWPATCH46_FORT_TAG4REFINEMENT; - clawpatch_vt->fort_tag4coarsening = FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING; - - /* output functions */ - clawpatch_vt->fort_header_ascii = FCLAW3DX_CLAWPATCH46_FORT_HEADER_ASCII; - clawpatch_vt->fort_output_ascii = FCLAW3DX_CLAWPATCH46_FORT_OUTPUT_ASCII; - - /* Ghost cell exchange functions */ - clawpatch_vt->fort_copy_face = FCLAW3DX_CLAWPATCH46_FORT_COPY_FACE; - clawpatch_vt->fort_average_face = FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE; - clawpatch_vt->fort_interpolate_face = FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE; - - clawpatch_vt->fort_copy_corner = FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER; - clawpatch_vt->fort_average_corner = FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER; - clawpatch_vt->fort_interpolate_corner = FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER; - - clawpatch_vt->local_ghost_pack_aux = NULL; - clawpatch_vt->fort_local_ghost_pack = FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK; - - clawpatch_vt->fort_timeinterp = FCLAW3DX_CLAWPATCH46_FORT_TIMEINTERP; - - } - else if (claw_version == 5) - { - fclaw_global_essentialf("clawpatch_vtable_initialize : Version 5 not yet " \ - "implemented\n"); - exit(0); - } -#endif - - - fclaw2d_clawpatch_diagnostics_vtable_initialize(glob); - - /* Set the virtual table, even if it isn't used */ - fclaw2d_clawpatch_pillow_vtable_initialize(glob, claw_version); - - clawpatch_vt->is_set = 1; - - FCLAW_ASSERT(fclaw_pointer_map_get(glob->vtables, CLAWPATCH_VTABLE_NAME) == NULL); - fclaw_pointer_map_insert(glob->vtables, CLAWPATCH_VTABLE_NAME, clawpatch_vt, clawpatch_vt_destroy); -} - - -/* ------------------------------- Public access functions ---------------------------- */ - -/* These functions are not virtualized and are not defined by the - patch interface */ - -fclaw2d_clawpatch_vtable_t* fclaw2d_clawpatch_vt(fclaw2d_global_t* glob) -{ - - fclaw2d_clawpatch_vtable_t* clawpatch_vt = (fclaw2d_clawpatch_vtable_t*) - fclaw_pointer_map_get(glob->vtables, CLAWPATCH_VTABLE_NAME); - FCLAW_ASSERT(clawpatch_vt != nullptr); - FCLAW_ASSERT(clawpatch_vt->is_set != 0); - return clawpatch_vt; -} - -/* Called from clawpack 4.6 and 5.0 */ -void fclaw2d_clawpatch_save_current_step(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - cp->griddata_last = cp->griddata; -} - - -fclaw2d_clawpatch_t* -fclaw2d_clawpatch_get_clawpatch(fclaw2d_patch_t* patch) -{ - return get_clawpatch(patch); -} - - -fclaw2d_metric_patch_t* -fclaw2d_clawpatch_get_metric_patch(fclaw2d_patch_t* patch) -{ - return get_metric_patch(patch); -} - -#if PATCH_DIM == 2 -void fclaw2d_clawpatch_grid_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - int* mx, int* my, int* mbc, - double* xlower, double* ylower, - double* dx, double* dy) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - *mx = cp->mx; - *my = cp->my; - *mbc = cp->mbc; - *xlower = cp->xlower; - *ylower = cp->ylower; - *dx = cp->dx; - *dy = cp->dy; -} -#elif PATCH_DIM == 3 -void fclaw3dx_clawpatch_grid_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - int* mx, int* my, int* mz, int* mbc, - double* xlower, double* ylower, - double* zlower, - double* dx, double* dy, double* dz) -{ - fclaw3dx_clawpatch_t *cp = get_clawpatch(patch); - *mx = cp->mx; - *my = cp->my; - *mz = cp->mz; - *mbc = cp->mbc; - *xlower = cp->xlower; - *ylower = cp->ylower; - *zlower = cp->zlower; - *dx = cp->dx; - *dy = cp->dy; - *dz = cp->dz; -} - -/* The metric terms only know about fclaw3d routines; not 3dx routines */ -void fclaw3d_clawpatch_grid_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - int* mx, int* my, int* mz, int* mbc, - double* xlower, double* ylower, - double* zlower, - double* dx, double* dy, double* dz) - -{ - fclaw3dx_clawpatch_grid_data(glob,patch,mx,my,mz,mbc, - xlower,ylower,zlower, - dx,dy,dz); -} - -#endif - - -void fclaw2d_clawpatch_aux_data(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - double **aux, int* maux) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch (patch); - - *maux = cp->maux; - *aux = cp->aux.dataPtr(); -} - -void fclaw2d_clawpatch_soln_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **q, int* meqn) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - *q = cp->griddata.dataPtr(); - *meqn = cp->meqn; -} - -void fclaw2d_clawpatch_rhs_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **rhs, int *mfields) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - *rhs = cp->rhs.dataPtr(); - *mfields = cp->mfields; -} - -void fclaw2d_clawpatch_elliptic_error_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **err, int *mfields) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - *err = cp->elliptic_error.dataPtr(); - *mfields = cp->mfields; -} - -void fclaw2d_clawpatch_elliptic_soln_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **soln, int *mfields) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - *soln = cp->elliptic_soln.dataPtr(); - *mfields = cp->mfields; -} - - -double *fclaw2d_clawpatch_get_q(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - return cp->griddata.dataPtr(); -} - -fclaw2d_clawpatch_registers_t* -fclaw2d_clawpatch_get_registers(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - return cp->registers; -} - - -double* fclaw2d_clawpatch_get_error(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - return cp->griderror.dataPtr(); -} - -double* fclaw2d_clawpatch_get_exactsoln(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - return cp->exactsolution.dataPtr(); -} - -void* fclaw2d_clawpatch_get_user_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - return cp->user_data; -} - -void fclaw2d_clawpatch_set_user_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - void *udata) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - cp->user_data = udata; -} - -void* fclaw2d_clawpatch_get_solver_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - return cp->solver_data; -} - -void fclaw2d_clawpatch_set_solver_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - void *sdata) -{ - fclaw2d_clawpatch_t *cp = get_clawpatch(patch); - cp->solver_data = sdata; -} - -size_t fclaw2d_clawpatch_size(fclaw2d_global_t *glob) -{ - const fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; - int meqn = clawpatch_opt->meqn; - int mbc = clawpatch_opt->mbc; - size_t size = (mx+2*mbc)*(my+2*mbc)*meqn; - -#if PATCH_DIM == 3 - int mz = clawpatch_opt->mz; - size *= (mz + 2*mbc); -#endif - - return size; -} - -void fclaw2d_clawpatch_timesync_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - int time_interp, - double **q, int* meqn) -{ - fclaw2d_clawpatch_t* cp = get_clawpatch(patch); - *q = q_time_sync(patch, time_interp); - *meqn = cp->meqn; -} - -double* fclaw2d_clawpatch_get_q_timesync(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - int time_interp) -{ - return q_time_sync(patch, time_interp); -} - -double* fclaw2d_clawpatch_get_area(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) -{ - return clawpatch_get_area(glob, patch); -} - -#if PATCH_DIM == 2 -void fclaw2d_clawpatch_metric_scalar(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **area, double** edgelengths, - double **curvature) -{ - fclaw2d_metric_patch_scalar(glob,patch,area,edgelengths, - curvature); -} - -void fclaw2d_clawpatch_metric_vector(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **xnormals, double **ynormals, - double **xtangents, double **ytangents, - double **surfnormals) -{ - fclaw2d_metric_patch_vector(glob,patch,xnormals,ynormals, - xtangents,ytangents,surfnormals); -} - - - - -void fclaw2d_clawpatch_metric_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **xp, double **yp, double **zp, - double **xd, double **yd, double **zd, - double **area) -{ - fclaw2d_metric_patch_mesh_data(glob,patch,xp,yp,zp,xd,yd,zd,area); -} - -void fclaw2d_clawpatch_metric_data2(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **xnormals, double **ynormals, - double **xtangents, double **ytangents, - double **surfnormals, - double **edgelengths, double **curvature) -{ - fclaw2d_metric_patch_mesh_data2(glob,patch,xnormals,ynormals, - xtangents,ytangents,surfnormals, - edgelengths,curvature); -} -#elif PATCH_DIM == 3 - -void fclaw3d_clawpatch_metric_scalar(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **volume, double** faceareas) -{ - fclaw3d_metric_patch_scalar(glob,patch,volume,faceareas); -} - -void fclaw2d_clawpatch_metric_basis(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **xrot, double** yrot, double** zrot) -{ - fclaw3d_metric_patch_basis(glob,patch,xrot, yrot, zrot); -} - - - - -void fclaw3d_clawpatch_mesh_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **xp, double **yp, double **zp, - double **xd, double **yd, double **zd, - double **volume, double **faceareas) -{ - fclaw3d_metric_patch_mesh_data(glob,patch,xp,yp,zp,xd,yd,zd, - volume, faceareas); -} - - -#endif - diff --git a/src/patches/clawpatch/fclaw2d_clawpatch.h.TEST.cpp b/src/patches/clawpatch/fclaw2d_clawpatch.h.TEST.cpp deleted file mode 100644 index 86c9f3557..000000000 --- a/src/patches/clawpatch/fclaw2d_clawpatch.h.TEST.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include - -TEST_CASE("fclaw2d_clawpatch_vtable_initialize stores two separate vtables in two separate globs") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - fclaw2d_vtables_initialize(glob1); - fclaw2d_vtables_initialize(glob2); - - fclaw2d_clawpatch_vtable_initialize(glob1,4); - fclaw2d_clawpatch_vtable_initialize(glob2,4); - - CHECK_NE(fclaw2d_clawpatch_vt(glob1), fclaw2d_clawpatch_vt(glob2)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw3dx_clawpatch_vtable_initialize stores two separate vtables in two separate globs") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - fclaw2d_vtables_initialize(glob1); - fclaw2d_vtables_initialize(glob2); - - fclaw3dx_clawpatch_vtable_initialize(glob1,4); - fclaw3dx_clawpatch_vtable_initialize(glob2,4); - - CHECK_NE(fclaw3dx_clawpatch_vt(glob1), fclaw3dx_clawpatch_vt(glob2)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw2d_clawpatch_vtable_initialize sets is_set flag") -{ - fclaw2d_global_t* glob = fclaw2d_global_new(); - - fclaw2d_vtables_initialize(glob); - fclaw2d_clawpatch_vtable_initialize(glob, 4); - - CHECK_UNARY(fclaw2d_clawpatch_vt(glob)->is_set); - - fclaw2d_global_destroy(glob); -} - -TEST_CASE("fclaw3dx_clawpatch_vtable_initialize sets is_set flag") -{ - fclaw2d_global_t* glob = fclaw2d_global_new(); - - fclaw2d_vtables_initialize(glob); - fclaw3dx_clawpatch_vtable_initialize(glob, 4); - - CHECK_UNARY(fclaw3dx_clawpatch_vt(glob)->is_set); - - fclaw2d_global_destroy(glob); -} - - - -#ifdef FCLAW_ENABLE_DEBUG - -TEST_CASE("fclaw2d_clawpatch_vtable_initialize fails if called twice on a glob") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - fclaw2d_vtables_initialize(glob1); - fclaw2d_vtables_initialize(glob2); - - fclaw2d_clawpatch_vtable_initialize(glob1,4); - CHECK_SC_ABORTED(fclaw2d_clawpatch_vtable_initialize(glob1,4)); - fclaw2d_clawpatch_vtable_initialize(glob2,4); - CHECK_SC_ABORTED(fclaw2d_clawpatch_vtable_initialize(glob2,4)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw3dx_clawpatch_vtable_initialize fails if called twice on a glob") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - fclaw2d_vtables_initialize(glob1); - fclaw2d_vtables_initialize(glob2); - - fclaw3dx_clawpatch_vtable_initialize(glob1,4); - CHECK_SC_ABORTED(fclaw3dx_clawpatch_vtable_initialize(glob1,4)); - fclaw3dx_clawpatch_vtable_initialize(glob2,4); - CHECK_SC_ABORTED(fclaw3dx_clawpatch_vtable_initialize(glob2,4)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw3dx_clawpatch_vt fails is fclaw2d_clawpatch_vt is set") -{ - fclaw2d_global_t* glob = fclaw2d_global_new(); - - fclaw2d_vtables_initialize(glob); - fclaw2d_clawpatch_vtable_initialize(glob, 4); - - CHECK_SC_ABORTED(fclaw3dx_clawpatch_vt(glob)); - - fclaw2d_global_destroy(glob); -} - -#endif \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw2d_clawpatch46_fort.h b/src/patches/clawpatch/fclaw2d_clawpatch46_fort.h index db8e09d7d..f4c0f85a8 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch46_fort.h +++ b/src/patches/clawpatch/fclaw2d_clawpatch46_fort.h @@ -40,7 +40,7 @@ extern "C" /* Fix syntax highlighting */ #endif -struct fclaw2d_patch_transform_data; /* Should be replaced by long int? */ +struct fclaw_patch_transform_data; /* Should be replaced by long int? */ /** @{ @name Time Stepping Functions *//*---------------------------------------------- */ @@ -135,7 +135,7 @@ void FCLAW2D_CLAWPATCH46_FORT_COPY_FACE(const int* mx, const int* my, const int* const int* meqn, double qthis[],double qneighbor[], const int* a_idir, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); @@ -152,7 +152,7 @@ void FCLAW2D_CLAWPATCH46_FORT_AVERAGE_FACE(const int* mx, const int* my, const i const int* num_neighbors, const int* refratio, const int* igrid, const int* manifold, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** Fortran subroutine name */ @@ -166,7 +166,7 @@ void FCLAW2D_CLAWPATCH46_FORT_INTERPOLATE_FACE(const int* mx, const int* my, const int* idir, const int* iside, const int* num_neighbors, const int* refratio, const int* igrid, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** Fortran subroutine name */ @@ -177,7 +177,7 @@ void FCLAW2D_CLAWPATCH46_FORT_INTERPOLATE_FACE(const int* mx, const int* my, void FCLAW2D_CLAWPATCH46_FORT_COPY_CORNER(const int* mx, const int* my, const int* mbc, const int* meqn, double this_q[], double neighbor_q[],const int* a_corner, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** Fortran subroutine name */ @@ -190,7 +190,7 @@ void FCLAW2D_CLAWPATCH46_FORT_AVERAGE_CORNER(const int* mx, const int* my, const double qcoarse[], double qfine[], double areacoarse[], double areafine[], const int* manifold,const int* a_corner, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** Fortran subroutine name */ @@ -202,7 +202,7 @@ void FCLAW2D_CLAWPATCH46_FORT_INTERPOLATE_CORNER(const int* mx, const int* my, const int* mbc,const int* meqn, const int* a_refratio, double this_q[], double neighbor_q[], const int* a_corner, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** @} */ diff --git a/src/patches/clawpatch/fclaw2d_clawpatch5_fort.h b/src/patches/clawpatch/fclaw2d_clawpatch5_fort.h index 4b9a4aacf..c84925eff 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch5_fort.h +++ b/src/patches/clawpatch/fclaw2d_clawpatch5_fort.h @@ -40,7 +40,7 @@ extern "C" /* Fix syntax highlighting */ #endif -struct fclaw2d_patch_transform_data; /* Should be replaced by long int? */ +struct fclaw_patch_transform_data; /* Should be replaced by long int? */ /* ------------------------------ Time stepping functions ----------------------------- */ /** Fortran subroutine name */ @@ -129,7 +129,7 @@ void FCLAW2D_CLAWPATCH5_FORT_AVERAGE2COARSE(const int* mx, const int* my, void FCLAW2D_CLAWPATCH5_FORT_COPY_FACE(const int* mx, const int* my, const int* mbc, const int* meqn, double qthis[],double qneighbor[], const int* a_idir, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); @@ -147,7 +147,7 @@ void FCLAW2D_CLAWPATCH5_FORT_AVERAGE_FACE(const int* mx, const int* my, const in const int* num_neighbors, const int* refratio, const int* igrid, const int* manifold, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** Fortran subroutine name */ @@ -162,7 +162,7 @@ void FCLAW2D_CLAWPATCH5_FORT_INTERPOLATE_FACE(const int* mx,const int* my,const const int* idir, const int* iside, const int* num_neighbors, const int* refratio, const int* igrid, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** Fortran subroutine name */ @@ -175,7 +175,7 @@ void FCLAW2D_CLAWPATCH5_FORT_COPY_CORNER(const int* mx, const int* my, const int const int* meqn, double this_q[], double neighbor_q[], const int* a_corner, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** Fortran subroutine name */ @@ -190,7 +190,7 @@ void FCLAW2D_CLAWPATCH5_FORT_AVERAGE_CORNER(const int* mx, const int* my, const double areacoarse[], double areafine[], const int* manifold, const int* a_corner, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** Fortran subroutine name */ @@ -204,7 +204,7 @@ void FCLAW2D_CLAWPATCH5_FORT_INTERPOLATE_CORNER(const int* mx, const int* my, const int* meqn, const int* a_refratio, double this_q[], double neighbor_q[], const int* a_corner, - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_conservation.c b/src/patches/clawpatch/fclaw2d_clawpatch_conservation.c index 7b85039f2..1b6e5a588 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_conservation.c +++ b/src/patches/clawpatch/fclaw2d_clawpatch_conservation.c @@ -24,41 +24,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif +#include -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif +#include +#include -#include - -#include -#include - -#include +#include #include -#if REFINE_DIM == 2 && PATCH_DIM == 2 - #include "fclaw2d_clawpatch_conservation.h" #include "fclaw2d_clawpatch_conservation_fort.h" -#include "fclaw2d_clawpatch.h" -#include "fclaw2d_clawpatch_options.h" - -#elif REFINE_DIM == 2 && PATCH_DIM == 3 - -#include "fclaw3dx_clawpatch_conservation.h" -#include "fclaw3dx_clawpatch_conservation_fort.h" - -#include "fclaw3dx_clawpatch.h" -#include "fclaw3dx_clawpatch_options.h" - -#include <_fclaw2d_to_fclaw3dx.h> - -#endif +#include "fclaw_clawpatch.h" +#include "fclaw_clawpatch_options.h" /* ------------------------------------------------------------- Four routines here : @@ -71,17 +49,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -void fclaw2d_clawpatch_time_sync_new (fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch, +void fclaw2d_clawpatch_time_sync_new (fclaw_global_t* glob, + fclaw_patch_t* this_patch, int blockno,int patchno, fclaw2d_clawpatch_registers_t **registers) { - fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_get_options(glob); int k; - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; + int mx; + int my; + + if (clawpatch_opt->patch_dim == 2) + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } + else + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } + int meqn = clawpatch_opt->meqn; fclaw2d_clawpatch_registers_t *cr = *registers; /* cr = clawpatch registers */ @@ -109,20 +99,32 @@ void fclaw2d_clawpatch_time_sync_new (fclaw2d_global_t* glob, } } -void fclaw2d_clawpatch_time_sync_pack_registers(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw2d_clawpatch_time_sync_pack_registers(fclaw_global_t *glob, + fclaw_patch_t *this_patch, double *qpack, int frsize, fclaw_clawpatch_packmode_t packmode, int *ierror) { - fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_get_options(glob); + + int mx; + int my; + + if (clawpatch_opt->patch_dim == 2) + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } + else + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } - int mx = clawpatch_opt->mx; - int my = clawpatch_opt->my; int meqn = clawpatch_opt->meqn; - fclaw2d_clawpatch_registers_t* cr = fclaw2d_clawpatch_get_registers(glob,this_patch); + fclaw2d_clawpatch_registers_t* cr = fclaw_clawpatch_get_2d_registers(glob,this_patch); int cnt = 0; /* Cycle over four edges */ @@ -204,22 +206,35 @@ void fclaw2d_clawpatch_time_sync_pack_registers(fclaw2d_global_t *glob, -void fclaw2d_clawpatch_time_sync_reset(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fclaw2d_clawpatch_time_sync_reset(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int coarse_level, int reset_mode) { - int mx,my,meqn; + int meqn; int i,j,k,idir; - fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_get_options(glob); - fclaw2d_clawpatch_registers_t* cr = fclaw2d_clawpatch_get_registers(glob,this_patch); - mx = clawpatch_opt->mx; - my = clawpatch_opt->my; + fclaw2d_clawpatch_registers_t* cr = fclaw_clawpatch_get_2d_registers(glob,this_patch); + + int mx; + int my; + + if (clawpatch_opt->patch_dim == 2) + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } + else + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } + meqn = clawpatch_opt->meqn; - fclaw2d_patch_data_t* pdata = fclaw2d_patch_get_patch_data(this_patch); + fclaw_patch_data_t* pdata = fclaw_patch_get_patch_data(this_patch); int fine_level = coarse_level+1; int reset_flux; @@ -228,27 +243,27 @@ void fclaw2d_clawpatch_time_sync_reset(fclaw2d_global_t *glob, { idir = k/2; reset_flux = 0; - if (reset_mode == FCLAW2D_TIME_SYNC_RESET_F2C) + if (reset_mode == FCLAW_TIME_SYNC_RESET_F2C) { /* Reset registers at interface between levels 'coarse_level' and 'fine_level' */ - int is_coarse = (pdata->face_neighbors[k] == FCLAW2D_PATCH_HALFSIZE) + int is_coarse = (pdata->face_neighbors[k] == FCLAW_PATCH_HALFSIZE) && (this_patch->level == coarse_level); - int is_fine = (pdata->face_neighbors[k] == FCLAW2D_PATCH_DOUBLESIZE) && + int is_fine = (pdata->face_neighbors[k] == FCLAW_PATCH_DOUBLESIZE) && (this_patch->level == fine_level); reset_flux = is_coarse || is_fine; } - else if (reset_mode == FCLAW2D_TIME_SYNC_RESET_SAMESIZE) + else if (reset_mode == FCLAW_TIME_SYNC_RESET_SAMESIZE) { /* Reset registers at interfaces between same size grids on coarse level */ - reset_flux = (pdata->face_neighbors[k] == FCLAW2D_PATCH_SAMESIZE) && + reset_flux = (pdata->face_neighbors[k] == FCLAW_PATCH_SAMESIZE) && (this_patch->level == coarse_level); } - else if (reset_mode == FCLAW2D_TIME_SYNC_RESET_PHYS) + else if (reset_mode == FCLAW_TIME_SYNC_RESET_PHYS) { /* Reset flux registers at physical boundaries (not actually used, but they are accumulated, so should be cleared out) */ - reset_flux = pdata->face_neighbors[k] == FCLAW2D_PATCH_BOUNDARY; + reset_flux = pdata->face_neighbors[k] == FCLAW_PATCH_BOUNDARY; } if (reset_flux) @@ -309,25 +324,24 @@ void fclaw2d_clawpatch_time_sync_delete (fclaw2d_clawpatch_registers_t **registe } -void fclaw2d_clawpatch_time_sync_setup(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch, +void fclaw2d_clawpatch_time_sync_setup(fclaw_global_t* glob, + fclaw_patch_t* this_patch, int blockno,int patchno) { -#if PATCH_DIM == 2 double *area, *edgelengths, *curvature; fclaw2d_clawpatch_registers_t *cr = - fclaw2d_clawpatch_get_registers(glob,this_patch); + fclaw_clawpatch_get_2d_registers(glob,this_patch); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_metric_scalar(glob,this_patch, + fclaw_clawpatch_2d_metric_scalar(glob,this_patch, &area, &edgelengths,&curvature); if (fclaw_opt->manifold) @@ -341,23 +355,20 @@ void fclaw2d_clawpatch_time_sync_setup(fclaw2d_global_t* glob, cr->edgelengths[0],cr->edgelengths[1], cr->edgelengths[2],cr->edgelengths[3], &fclaw_opt->manifold); -#elif PATCH_DIM == 3 - /* This routine is called, even if time-sync = F */ -#endif } /* This is a patch call-back */ -void fclaw2d_clawpatch_time_sync_f2c(fclaw2d_global_t* glob, - fclaw2d_patch_t* coarse_patch, - fclaw2d_patch_t* fine_patch, +void fclaw2d_clawpatch_time_sync_f2c(fclaw_global_t* glob, + fclaw_patch_t* coarse_patch, + fclaw_patch_t* fine_patch, int coarse_blockno, int fine_blockno, int coarse_patchno, int idir, int igrid, int iface_coarse, int time_interp, - fclaw2d_patch_transform_data_t + fclaw_patch_transform_data_t *transform_data) { /* We don't correct time interpolated grids, since we assume that the time @@ -366,69 +377,64 @@ void fclaw2d_clawpatch_time_sync_f2c(fclaw2d_global_t* glob, needed for copying and interpolation. */ -#if PATCH_DIM == 2 int meqn; double *qcoarse; - fclaw2d_clawpatch_soln_data(glob,coarse_patch,&qcoarse,&meqn); + fclaw_clawpatch_soln_data(glob,coarse_patch,&qcoarse,&meqn); double *qfine; - fclaw2d_clawpatch_soln_data(glob,fine_patch,&qfine,&meqn); + fclaw_clawpatch_soln_data(glob,fine_patch,&qfine,&meqn); int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,coarse_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); fclaw2d_clawpatch_registers_t* crcoarse = - fclaw2d_clawpatch_get_registers(glob,coarse_patch); + fclaw_clawpatch_get_2d_registers(glob,coarse_patch); fclaw2d_clawpatch_registers_t* crfine = - fclaw2d_clawpatch_get_registers(glob,fine_patch); + fclaw_clawpatch_get_2d_registers(glob,fine_patch); /* create dummy fine grid to handle indexing between blocks */ double *qneighbor_dummy = FCLAW_ALLOC_ZERO(double,meqn*(mx+4*mbc)*(my+4*mbc)); - int normal_match = fclaw2d_patch_normal_match(glob->domain, coarse_blockno, + int normal_match = fclaw_patch_normal_match(glob->domain, coarse_blockno, coarse_patchno, iface_coarse); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); /* This function is defined in fc2d_clawpack4.6 and fc2d_clawpack5 */ - clawpatch_vt->fort_time_sync_f2c(&mx,&my,&mbc,&meqn,&idir,&iface_coarse, - &coarse_blockno, &fine_blockno, - &normal_match, - crcoarse->area[0], crcoarse->area[1], - crcoarse->area[2], crcoarse->area[3], - qcoarse, - crcoarse->fp[0],crcoarse->fm[1], - crcoarse->gp[0],crcoarse->gm[1], - crfine->fm[0],crfine->fp[1], - crfine->gm[0],crfine->gp[1], - crcoarse->edge_fluxes[0], - crcoarse->edge_fluxes[1], - crcoarse->edge_fluxes[2], - crcoarse->edge_fluxes[3], - crfine->edge_fluxes[0], - crfine->edge_fluxes[1], - crfine->edge_fluxes[2], - crfine->edge_fluxes[3], - qneighbor_dummy, - &transform_data); + clawpatch_vt->d2->fort_time_sync_f2c(&mx,&my,&mbc,&meqn,&idir,&iface_coarse, + &coarse_blockno, &fine_blockno, + &normal_match, + crcoarse->area[0], crcoarse->area[1], + crcoarse->area[2], crcoarse->area[3], + qcoarse, + crcoarse->fp[0],crcoarse->fm[1], + crcoarse->gp[0],crcoarse->gm[1], + crfine->fm[0],crfine->fp[1], + crfine->gm[0],crfine->gp[1], + crcoarse->edge_fluxes[0], + crcoarse->edge_fluxes[1], + crcoarse->edge_fluxes[2], + crcoarse->edge_fluxes[3], + crfine->edge_fluxes[0], + crfine->edge_fluxes[1], + crfine->edge_fluxes[2], + crfine->edge_fluxes[3], + qneighbor_dummy, + &transform_data); FCLAW_FREE(qneighbor_dummy); -#elif PATCH_DIM == 3 - fclaw_global_essentialf("Conservation not yet implemented for 3d patches\n"); - exit(0); -#endif } -void fclaw2d_clawpatch_time_sync_samesize (struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - struct fclaw2d_patch* neighbor_patch, +void fclaw2d_clawpatch_time_sync_samesize (struct fclaw_global* glob, + struct fclaw_patch* this_patch, + struct fclaw_patch* neighbor_patch, int this_iface,int idir, - fclaw2d_patch_transform_data_t + fclaw_patch_transform_data_t *transform_data) { /* We don't correct time interpolated grids, since we assume that the time @@ -436,23 +442,22 @@ void fclaw2d_clawpatch_time_sync_samesize (struct fclaw2d_global* glob, n and n+1 patches. But we do correct ghost patches, since corrections will be needed for copying and interpolation. */ -#if PATCH_DIM == 2 - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); double *qthis; int meqn; - fclaw2d_clawpatch_soln_data(glob,this_patch,&qthis,&meqn); + fclaw_clawpatch_soln_data(glob,this_patch,&qthis,&meqn); int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); fclaw2d_clawpatch_registers_t* crthis = - fclaw2d_clawpatch_get_registers(glob,this_patch); + fclaw_clawpatch_get_2d_registers(glob,this_patch); fclaw2d_clawpatch_registers_t* crneighbor = - fclaw2d_clawpatch_get_registers(glob,neighbor_patch); + fclaw_clawpatch_get_2d_registers(glob,neighbor_patch); /* create dummy fine grid to handle indexing between blocks */ double *qneighbor_dummy = FCLAW_ALLOC_ZERO(double,meqn*(mx+2*mbc)*(my+2*mbc)); @@ -460,39 +465,35 @@ void fclaw2d_clawpatch_time_sync_samesize (struct fclaw2d_global* glob, /* Include this for debugging */ int this_blockno, this_patchno,globnum,level; int neighbor_blockno, neighbor_patchno; - fclaw2d_patch_get_info2(glob->domain,this_patch,&this_blockno, &this_patchno, + fclaw_patch_get_info2(glob->domain,this_patch,&this_blockno, &this_patchno, &globnum,&level); - fclaw2d_patch_get_info2(glob->domain,neighbor_patch,&neighbor_blockno, + fclaw_patch_get_info2(glob->domain,neighbor_patch,&neighbor_blockno, &neighbor_patchno,&globnum,&level); /* This function is defined in fc2d_clawpack4.6 and fc2d_clawpack5 */ /* Distribute 0.5 of each correction from each side */ - clawpatch_vt->fort_time_sync_samesize(&mx,&my,&mbc,&meqn,&idir,&this_iface, - &this_blockno, &neighbor_blockno, - crthis->area[0], crthis->area[1], - crthis->area[2], crthis->area[3], - qthis, - crthis->fp[0],crthis->fm[1], - crthis->gp[0],crthis->gm[1], - crneighbor->fm[0],crneighbor->fp[1], - crneighbor->gm[0],crneighbor->gp[1], - crthis->edge_fluxes[0], - crthis->edge_fluxes[1], - crthis->edge_fluxes[2], - crthis->edge_fluxes[3], - crneighbor->edge_fluxes[0], - crneighbor->edge_fluxes[1], - crneighbor->edge_fluxes[2], - crneighbor->edge_fluxes[3], - qneighbor_dummy, - &transform_data); + clawpatch_vt->d2->fort_time_sync_samesize(&mx,&my,&mbc,&meqn,&idir,&this_iface, + &this_blockno, &neighbor_blockno, + crthis->area[0], crthis->area[1], + crthis->area[2], crthis->area[3], + qthis, + crthis->fp[0],crthis->fm[1], + crthis->gp[0],crthis->gm[1], + crneighbor->fm[0],crneighbor->fp[1], + crneighbor->gm[0],crneighbor->gp[1], + crthis->edge_fluxes[0], + crthis->edge_fluxes[1], + crthis->edge_fluxes[2], + crthis->edge_fluxes[3], + crneighbor->edge_fluxes[0], + crneighbor->edge_fluxes[1], + crneighbor->edge_fluxes[2], + crneighbor->edge_fluxes[3], + qneighbor_dummy, + &transform_data); FCLAW_FREE(qneighbor_dummy); -#elif PATCH_DIM == 3 - fclaw_global_essentialf("Conservation not yet implemented for 3d patches\n"); - exit(0); -#endif } diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_conservation.h b/src/patches/clawpatch/fclaw2d_clawpatch_conservation.h index 1296eee56..be102554c 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_conservation.h +++ b/src/patches/clawpatch/fclaw2d_clawpatch_conservation.h @@ -41,9 +41,9 @@ extern "C" #endif #endif -struct fclaw2d_patch_transform_data; -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_patch_transform_data; +struct fclaw_global; +struct fclaw_patch; /** * @brief fclaw2d_clawpatch_registers type @@ -125,7 +125,7 @@ typedef void (*clawpatch_fort_time_sync_f2c_t)(const int* mx, double eff0[], double eff1[], double eff2[], double eff3[], double qfine_dummy[], - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /** @@ -177,7 +177,7 @@ typedef void (*clawpatch_fort_time_sync_samesize_t)(const int* mx, double efnbr0[], double efnbr1[], double efnbr2[], double efnbr3[], double qnbr_dummy[], - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); @@ -191,8 +191,8 @@ typedef void (*clawpatch_fort_time_sync_samesize_t)(const int* mx, * @param[in] patchno the patch number * @param[out] registers the newly allocated registers struct */ -void fclaw2d_clawpatch_time_sync_new(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_clawpatch_time_sync_new(struct fclaw_global* glob, + struct fclaw_patch* this_patch, int blockno,int patchno, fclaw2d_clawpatch_registers_t **registers); @@ -211,8 +211,8 @@ void fclaw2d_clawpatch_time_sync_delete(fclaw2d_clawpatch_registers_t **register * @param[in] blockno the block number * @param[in] patchno the patch number */ -void fclaw2d_clawpatch_time_sync_setup(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_clawpatch_time_sync_setup(struct fclaw_global* glob, + struct fclaw_patch* this_patch, int blockno,int patchno); /** @@ -231,16 +231,16 @@ void fclaw2d_clawpatch_time_sync_setup(struct fclaw2d_global* glob, * @param[in] time_interp NOT USED * @param[in] transform_data the transform for the neighbor's coordinates */ -void fclaw2d_clawpatch_time_sync_f2c(struct fclaw2d_global* glob, - struct fclaw2d_patch* coarse_patch, - struct fclaw2d_patch* fine_patch, +void fclaw2d_clawpatch_time_sync_f2c(struct fclaw_global* glob, + struct fclaw_patch* coarse_patch, + struct fclaw_patch* fine_patch, int coarse_blockno, int fine_blockno, int coarse_patchno, int idir, int igrid, int iface_coarse, int time_interp, - struct fclaw2d_patch_transform_data + struct fclaw_patch_transform_data *transform_data); /** @@ -254,11 +254,11 @@ void fclaw2d_clawpatch_time_sync_f2c(struct fclaw2d_global* glob, * 1 for left/right * @param[in] transform_data the transform for the neighbor's coordinates */ -void fclaw2d_clawpatch_time_sync_samesize(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - struct fclaw2d_patch* neighbor_patch, +void fclaw2d_clawpatch_time_sync_samesize(struct fclaw_global* glob, + struct fclaw_patch* this_patch, + struct fclaw_patch* neighbor_patch, int this_iface,int idir, - struct fclaw2d_patch_transform_data + struct fclaw_patch_transform_data *transform_data); /** @@ -269,8 +269,8 @@ void fclaw2d_clawpatch_time_sync_samesize(struct fclaw2d_global* glob, * @param[in] coarse_level the the level of the coarse patch * @param[in] reset_mode the reset mode ::fclaw2d_time_sync_type */ -void fclaw2d_clawpatch_time_sync_reset(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fclaw2d_clawpatch_time_sync_reset(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int coarse_level, int reset_mode); @@ -284,8 +284,8 @@ void fclaw2d_clawpatch_time_sync_reset(struct fclaw2d_global* glob, * @param[in] packmode the packing mode * @param[out] ierror the error value */ -void fclaw2d_clawpatch_time_sync_pack_registers(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fclaw2d_clawpatch_time_sync_pack_registers(struct fclaw_global *glob, + struct fclaw_patch *this_patch, double *qpack, int frsize, fclaw_clawpatch_packmode_t packmode, diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_diagnostics_default.c b/src/patches/clawpatch/fclaw2d_clawpatch_diagnostics_default.c deleted file mode 100644 index 2fe20c3ed..000000000 --- a/src/patches/clawpatch/fclaw2d_clawpatch_diagnostics_default.c +++ /dev/null @@ -1,154 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif - -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif - -#if REFINE_DIM == 2 && PATCH_DIM == 2 - -#include - -#include -#include - -#elif REFINE_DIM == 2 && PATCH_DIM == 3 - -#include - -#include -#include - -#include <_fclaw2d_to_fclaw3dx.h> -#include <_fclaw2d_to_fclaw3d.h> - -#endif - -#include -#include -#include -#include - -void fclaw2d_clawpatch_diagnostics_cons_default(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - int blockno, - int patchno, - void *user) -{ - error_info_t* error_data = (error_info_t*) user; - double* area = fclaw2d_clawpatch_get_area(glob,patch); /* Might be null */ - - int meqn; - double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); - - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - FCLAW_ASSERT(clawpatch_vt->fort_conservation_check != NULL); - - int mx, my, mbc; - double xlower,ylower,dx,dy; -#if PATCH_DIM == 2 - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, - &xlower,&ylower,&dx,&dy); - clawpatch_vt->fort_conservation_check(&mx, &my, &mbc, &meqn, &dx,&dy, - area, q, error_data->mass, - error_data->c_kahan); -#else - int mz; - double zlower, dz; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mz, &mbc, - &xlower,&ylower,&zlower, &dx,&dy, &dz); - clawpatch_vt->fort_conservation_check(&mx, &my, &mz, &mbc, &meqn, - &dx,&dy,&dz, - area, q, error_data->mass, - error_data->c_kahan); - -#endif - -} - -void fclaw2d_clawpatch_diagnostics_error_default(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, - int blockno, - int patchno, - void *user) -{ - error_info_t* error_data = (error_info_t*) user; - //const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - - double *area = fclaw2d_clawpatch_get_area(glob,patch); /* Might be null */ - double *q; - int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); - - if (clawpatch_vt->fort_compute_patch_error != NULL) - { - double t = glob->curr_time; - double* error = fclaw2d_clawpatch_get_error(glob,patch); - double* soln = fclaw2d_clawpatch_get_exactsoln(glob,patch); - - int mx, my, mbc; - double xlower,ylower,dx,dy; -#if PATCH_DIM == 2 - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); - - clawpatch_vt->fort_compute_patch_error(&blockno, &mx,&my,&mbc,&meqn,&dx,&dy, - &xlower,&ylower, &t, q, error, soln); - - /* Accumulate sums and maximums needed to compute error norms */ - FCLAW_ASSERT(clawpatch_vt->fort_compute_error_norm != NULL); - clawpatch_vt->fort_compute_error_norm(&blockno, &mx, &my, &mbc, &meqn, - &dx,&dy, area, error, - error_data->local_error); -#elif PATCH_DIM == 3 - int mz; - double zlower, dz; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mz, - &mbc,&xlower,&ylower,&zlower, - &dx,&dy,&dz); - clawpatch_vt->fort_compute_patch_error(&blockno, &mx,&my,&mz, - &mbc,&meqn, - &dx,&dy,&dz, - &xlower,&ylower, &zlower, - &t, q, error, soln); - - /* Accumulate sums and maximums needed to compute error norms */ - FCLAW_ASSERT(clawpatch_vt->fort_compute_error_norm != NULL); - clawpatch_vt->fort_compute_error_norm(&blockno, &mx, &my, &mz, - &mbc, &meqn, - &dx,&dy, &dz, area, error, - error_data->local_error); - - -#endif - } -} - - diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_fort.h b/src/patches/clawpatch/fclaw2d_clawpatch_fort.h index ebfbb15f1..426441905 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_fort.h +++ b/src/patches/clawpatch/fclaw2d_clawpatch_fort.h @@ -31,10 +31,10 @@ extern "C" { #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; -struct fclaw2d_patch_transform_data; /* Should be replaced by long int? */ +struct fclaw_patch_transform_data; /* Should be replaced by long int? */ /** * @file @@ -66,7 +66,7 @@ typedef void (*clawpatch_fort_copy_face_t)(const int* mx, const int* my, const int* meqn, double qthis[],double qneighbor[], const int* iface, - struct fclaw2d_patch_transform_data** transform_ptr); + struct fclaw_patch_transform_data** transform_ptr); /** * @brief Averages values from a face-neighboring fine grid @@ -94,7 +94,7 @@ typedef void (*clawpatch_fort_average_face_t)(const int* mx, const int* my, cons const int* num_neighbors, const int* refratio, const int* igrid, const int* manifold, - struct fclaw2d_patch_transform_data** transform_ptr); + struct fclaw_patch_transform_data** transform_ptr); /** * @brief Interpolates values from a face-neighboring coarse grid * @@ -118,7 +118,7 @@ typedef void (*clawpatch_fort_interpolate_face_t)(const int* mx, const int* my, const int* idir, const int* iface_coarse, const int* num_neighbors, const int* refratio, const int* igrid, - struct fclaw2d_patch_transform_data** transform_ptr); + struct fclaw_patch_transform_data** transform_ptr); /** * @brief Copies ghost data from a corner-neighboring grid on the same level @@ -134,7 +134,7 @@ typedef void (*clawpatch_fort_interpolate_face_t)(const int* mx, const int* my, typedef void (*clawpatch_fort_copy_corner_t)(const int* mx, const int* my, const int* mbc, const int* meqn, double qthis[],double qneighbor[], const int* icorner_coarse, - struct fclaw2d_patch_transform_data** transform_ptr); + struct fclaw_patch_transform_data** transform_ptr); /** * @brief Averages values from a corner neighboring fine grid @@ -156,7 +156,7 @@ typedef void (*clawpatch_fort_average_corner_t)(const int* mx, const int* my, co double areacoarse[], double areafine[], const int* manifold, const int* a_corner, - struct fclaw2d_patch_transform_data** transform_ptr); + struct fclaw_patch_transform_data** transform_ptr); /** * @brief Interpolates values form a corner-neighboring coarse grid @@ -174,7 +174,7 @@ typedef void (*clawpatch_fort_interpolate_corner_t)(const int* mx, const int* my const int* meqn, const int* refratio, double qcoarse[], double qfine[], const int* icorner_coarse, - struct fclaw2d_patch_transform_data** transform_ptr); + struct fclaw_patch_transform_data** transform_ptr); /** @} */ diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_fort.h.TEST.cpp b/src/patches/clawpatch/fclaw2d_clawpatch_fort.h.TEST.cpp index b25de3f21..c5a0d2033 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_fort.h.TEST.cpp +++ b/src/patches/clawpatch/fclaw2d_clawpatch_fort.h.TEST.cpp @@ -25,16 +25,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include -#include +#include +#include +#include -#include -#include +#include +#include #include - -#include -#include -#include +#include namespace{ struct exceeds_test_parameters @@ -65,12 +63,18 @@ TEST_CASE("FCLAW2D_CLAWPATCH_EXCEEDS_THRESHOLD calls user function") global_exceeds_test_parameters = exceeds_test_parameters(); exceeds_test_parameters& params = global_exceeds_test_parameters; - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); + + fclaw_clawpatch_options_t* clawpatch_opts = fclaw_clawpatch_options_new(2); + clawpatch_opts->refinement_criteria = FCLAW_REFINE_CRITERIA_USER; + fclaw_clawpatch_options_store(glob, clawpatch_opts); - fclaw2d_vtables_initialize(glob); - fclaw2d_clawpatch_vtable_initialize(glob, 4); + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); - fclaw2d_clawpatch_vt(glob)->fort_user_exceeds_threshold = + fclaw_clawpatch_vt(glob)->d2->fort_user_exceeds_threshold = [](const int *blockno, const int* meqn, const double *qval, @@ -104,11 +108,8 @@ TEST_CASE("FCLAW2D_CLAWPATCH_EXCEEDS_THRESHOLD calls user function") return params.return_value; }; - fclaw2d_clawpatch_options_t opts; - opts.refinement_criteria = FCLAW_REFINE_CRITERIA_USER; - fclaw2d_clawpatch_options_store(glob, &opts); - fclaw2d_global_set_global(glob); + fclaw_global_set_static(glob); int ret = FCLAW2D_CLAWPATCH_TAG_CRITERIA(params.blockno, params.qval, params.qmin, @@ -121,23 +122,32 @@ TEST_CASE("FCLAW2D_CLAWPATCH_EXCEEDS_THRESHOLD calls user function") params.tag_threshold, params.init_flag, params.is_ghost); - fclaw2d_global_unset_global(); + fclaw_global_clear_static(); CHECK_EQ(ret, params.return_value); - fclaw2d_global_destroy(glob); + fclaw_clawpatch_options_destroy(clawpatch_opts); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); } TEST_CASE("FCLAW3DX_CLAWPATCH_EXCEEDS_THRESHOLD calls user function") { global_exceeds_test_parameters = exceeds_test_parameters(); exceeds_test_parameters& params = global_exceeds_test_parameters; - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + opts->refinement_criteria = FCLAW_REFINE_CRITERIA_USER; + fclaw_clawpatch_options_store(glob, opts); + - fclaw2d_vtables_initialize(glob); - fclaw3dx_clawpatch_vtable_initialize(glob, 4); + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); - fclaw3dx_clawpatch_vt(glob)->fort_user_exceeds_threshold = + fclaw_clawpatch_vt(glob)->d3->fort_user_exceeds_threshold = [](const int *blockno, const int* meqn, const double *qval, @@ -175,28 +185,26 @@ TEST_CASE("FCLAW3DX_CLAWPATCH_EXCEEDS_THRESHOLD calls user function") return params.return_value; }; - fclaw3dx_clawpatch_options_t opts; - opts.refinement_criteria = FCLAW_REFINE_CRITERIA_USER; - fclaw3dx_clawpatch_options_store(glob, &opts); - - fclaw2d_global_set_global(glob); - int ret = FCLAW3DX_CLAWPATCH_TAG_CRITERIA(params.blockno, - params.qval, - params.qmin, - params.qmax, - params.quad, - params.dx, - params.dy, - params.dz, - params.xc, - params.yc, - params.zc, - params.tag_threshold, - params.init_flag, - params.is_ghost); - fclaw2d_global_unset_global(); + fclaw_global_set_static(glob); + int ret = FCLAW3D_CLAWPATCH_TAG_CRITERIA(params.blockno, + params.qval, + params.qmin, + params.qmax, + params.quad, + params.dx, + params.dy, + params.dz, + params.xc, + params.yc, + params.zc, + params.tag_threshold, + params.init_flag, + params.is_ghost); + fclaw_global_clear_static(); CHECK_EQ(ret, params.return_value); - fclaw2d_global_destroy(glob); + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); } \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_fort2.h b/src/patches/clawpatch/fclaw2d_clawpatch_fort2.h deleted file mode 100644 index b73e8eeda..000000000 --- a/src/patches/clawpatch/fclaw2d_clawpatch_fort2.h +++ /dev/null @@ -1,251 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW2D_CLAWPATCH_FORT2_H -#define FCLAW2D_CLAWPATCH_FORT2_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#if 0 -/* Fix syntax highlighting ... */ -#endif - -struct fclaw2d_global; -struct fclaw2d_patch; - -struct fclaw2d_patch_transform_data; /* Should be replaced by long int? */ - -/* Functions defined here are implemented in individual solvers (clawpack 4.6 and - clawpack 5.0) */ - - -/* --------------------------- Ghost filling - patch specific ------------------------- */ - -typedef void (*clawpatch_fort_copy_face_t)(const int* mx, const int* my, - const int* mbc, - const int* meqn, - double qthis[],double qneighbor[], - const int* a_idir, - struct fclaw2d_patch_transform_data** transform_cptr); - -typedef void (*clawpatch_fort_average_face_t)(const int* mx, const int* my, const int* mbc, - const int* meqn, - double qcoarse[],double qfine[], - double areacoarse[], double areafine[], - const int* idir, const int* iside, - const int* num_neighbors, - const int* refratio, const int* igrid, - const int* manifold, - struct fclaw2d_patch_transform_data** transform_cptr); - -typedef void (*clawpatch_fort_interpolate_face_t)(const int* mx, const int* my, const int* mbc, - const int* meqn, - double qcoarse[],double qfine[], - const int* idir, const int* iside, - const int* num_neighbors, - const int* refratio, const int* igrid, - struct fclaw2d_patch_transform_data** transform_cptr); - - - -typedef void (*clawpatch_fort_copy_corner_t)(const int* mx, const int* my, const int* mbc, - const int* meqn, double this_q[],double neighbor_q[], - const int* a_corner, - struct fclaw2d_patch_transform_data** transform_cptr); - -typedef void (*clawpatch_fort_average_corner_t)(const int* mx, const int* my, const int* mbc, - const int* meqn, const int* a_refratio, - double qcoarse[], double qfine[], - double areacoarse[], double areafine[], - const int* manifold, - const int* a_corner, - struct fclaw2d_patch_transform_data** transform_cptr); - -typedef void (*clawpatch_fort_interpolate_corner_t)(const int* mx, const int* my, const int* mbc, - const int* meqn, const int* a_refratio, - double this_q[], - double neighbor_q[], const int* a_corner, - struct fclaw2d_patch_transform_data** transform_cptr); - - -/* --------------------------------- Regridding functions ----------------------------- */ - -typedef void (*clawpatch_fort_tag4refinement_t)(const int* mx,const int* my, - const int* mbc,const int* meqn, - const double* xlower, const double* ylower, - const double* dx, const double* dy, - const int* blockno, - double q[], - const double* tag_threshold, - const int* init_flag, - int* tag_patch); - -typedef void (*clawpatch_fort_tag4coarsening_t)(const int* mx, const int* my, - const int* mbc, const int* meqn, - double xlower[], - double ylower[], - const double* dx, const double* dy, - const int* blockno, - double q0[],double q1[], - double q2[],double q3[], - const double* tag_threshold, - const int* init_flag, - int* tag_patch); - - -#if 0 -typedef int (*clawpatch_fort_exceeds_threshold_t)(int* blockno, - double qval[], - double* qmin, double *qmax, - double quad[], - double *dx, double *dy, - double *xc, double *yc, - int* tag_threshold, - int* init_flag, - int* is_ghost); -#endif - - -typedef void (*clawpatch_fort_interpolate2fine_t)(const int* mx, const int* my, - const int* mbc, const int* meqn, - double qcoarse[], double qfine[], - double areacoarse[], double areafine[], - const int* igrid, const int* manifold); - -typedef void (*clawpatch_fort_average2coarse_t)(const int* mx, const int* my, - const int* mbc, const int* meqn, - double qcoarse[],double qfine[], - double areacoarse[],double areafine[], - const int* igrid, const int* manifold); - - -/* ----------------------------------- time stepping ---------------------------------- */ - -typedef void (*clawpatch_fort_timeinterp_t)(const int *mx, const int* my, const int* mbc, - const int *meqn, const int* psize, - double qcurr[], double qlast[], - double qinterp[],const double* alpha, - const int* ierror); - -/* ------------------------------- Parallel ghost patches ----------------------------- */ - -typedef void (*clawpatch_fort_local_ghost_pack_t)(const int *mx, const int *my, - const int *mbc, - const int *meqn, const int *mint, - double qdata[], double area[], - double qpack[], const int *psize, - const int *packmode, int *ierror); - -/* ---------------------------------- Output functions -------------------------------- */ - -#if 0 -typedef void (*clawpatch_fort_header_ascii_t)(char* matname1,char* matname2, - double* time, int* meqn, int* maux, - int* ngrids); -#endif - -/* Write out data */ -typedef void (*clawpatch_fort_output_ascii_t)(char* matname1, - int* mx, int* my, - int* meqn, int* mbc, - double* xlower, double* ylower, - double* dx, double* dy, - double q[], - int* patch_num, int* level, - int* blockno, int* mpirank); - - -/* ----------------------------- Diagnostic functions --------------------------------- */ - -typedef void (*clawpatch_fort_error_t)(int* blockno, int *mx, int *my, - int *mbc,int *meqn, - double *dx, double *dy, double *xlower, - double *ylower, double *t, double q[], - double error[], double soln[]); - -typedef void (*clawpatch_fort_conscheck_t)(int *mx, int *my, int* mbc, int* meqn, - double *dx, double *dy, - double area[], double q[], double sum[], - double *c_kahan); - -typedef double (*clawpatch_fort_area_t)(int *mx, int* my, int*mbc, double* dx, - double* dy, double area[]); - -typedef void (*clawpatch_fort_norm_t)(int* blockno, int *mx, int *my, int *mbc,int *meqn, - double *dx, double *dy, double area[], - double error[], double error_norm[]); - - - -/* -------------------------- User convenience headers -------------------------------- */ - -#define TAG4REFINEMENT FCLAW_F77_FUNC(tag4refinement,TAG4REFINEMENT) -void TAG4REFINEMENT(const int* mx,const int* my, - const int* mbc,const int* meqn, - const double *xlower, const double *ylower, - const double* dx, const double* dy, - const int* blockno, - double q[], - const double* tag_threshold, - const int* init_flag, - int* tag_patch); - -#define TAG4COARSENING FCLAW_F77_FUNC(tag4coarsening,TAG4COARSENING) -void TAG4COARSENING(const int* mx, const int* my, - const int* mbc, const int* meqn, - double xlower[], double ylower[], - const double* dx, const double* dy, - const int* blockno, - double q0[],double q1[], - double q2[],double q3[], - const double* tag_threshold, - const int* initflag, - int* tag_patch); - - -/* ----------------------------- interpolation/coarsening ----------------------------- */ - -#define INTERPOLATE2FINE FCLAW_F77_FUNC(interpolate2fine, INTERPOLATE2FINE) -void INTERPOLATE2FINE(const int* mx,const int* my,const int* mbc, - const int* meqn, double qcoarse[], double qfine[], - double areacoarse[], double areafine[], - const int* igrid,const int* manifold); - -#define AVERAGE2COARSE FCLAW_F77_FUNC(average2coarse, AVERAGE2COARSE) -void AVERAGE2COARSE(const int* mx,const int* my,const int* mbc, - const int* meqn, - double qcoarse[],double qfine[], - double areacoarse[],double areafine[], - const int* igrid, const int* manifold); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_options.h b/src/patches/clawpatch/fclaw2d_clawpatch_options.h deleted file mode 100644 index 6aea4a67f..000000000 --- a/src/patches/clawpatch/fclaw2d_clawpatch_options.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW2D_CLAWPATCH_OPTIONS_H -#define FCLAW2D_CLAWPATCH_OPTIONS_H - -/** - * @file - * Routines for handling clawpatch input options. - */ - -#include - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - - - -/* Criteria for tagging patches */ -/** Refine based on value */ -#define FCLAW_REFINE_CRITERIA_VALUE 0 -/** Refine based on derivative */ -#define FCLAW_REFINE_CRITERIA_DIFFERENCE 1 -/** Refine based on difference between min and max */ -#define FCLAW_REFINE_CRITERIA_MINMAX 2 -/** Refine based on gradient */ -#define FCLAW_REFINE_CRITERIA_GRADIENT 3 -/** Refine based on user provided function */ -#define FCLAW_REFINE_CRITERIA_USER 4 - - -struct fclaw2d_global; - -/** Typedef for fclaw2d_clwaptch_opitons structure */ -typedef struct fclaw2d_clawpatch_options fclaw2d_clawpatch_options_t; - - -/** - * @brief Clawpatch options - */ -struct fclaw2d_clawpatch_options -{ - /* These are constant for all clawpatch's */ - int mx; /**< number of cells in the x direction */ - int my; /**< number of cells in the y direction */ - int maux; /**< number of aux equations */ - int mbc; /**< the number of ghost cells */ - - int meqn; /**< number fields in solution */ - int rhs_fields; /**< number of rhs fields for elliptic problems */ - - int refinement_criteria; /**< The refinement criteria */ - sc_keyvalue_t *kv_refinement_criteria; /**< The refinement criteria */ - int threshold_variable; - - /* Advanced options */ - int interp_stencil_width; /**< The width of the interpolation stencil */ - int ghost_patch_pack_aux; /**< True if aux equations should be packed */ - int save_aux; /**< Save the aux array when retaking a time step */ - - - int vtk_patch_threshold; /**< The buffer threshold for vtk output */ - - int is_registered; /**< true if options have been registered */ - -}; - -/** - * @brief Register options in SC - * - * @param app the app context - * @param name the name of the options group - * @param configfile the config file - * @return fclaw2d_clawpatch_options_t* a newly allocated options struct - */ -fclaw2d_clawpatch_options_t * -fclaw2d_clawpatch_options_register(fclaw_app_t* app, const char* name, const char* configfile); - - -/** - * @brief Store the options in the global context - * - * @param glob the global context - * @param clawpatch_options the options - */ -void fclaw2d_clawpatch_options_store (struct fclaw2d_global *glob, - fclaw2d_clawpatch_options_t* clawpatch_options); - -/** - * @brief Get the options from the global context - * - * @param glob the global context - * @return fclaw2d_clawpatch_options_t* the options - */ -fclaw2d_clawpatch_options_t* fclaw2d_clawpatch_get_options(struct fclaw2d_global* glob); - -/** - * @brief Get the packing vtable for fclaw2d_clawpatch_options_t - * - * @return const fclaw_packing_vtable_t* the vtable - */ -const fclaw_packing_vtable_t* fclaw2d_clawpatch_options_get_packing_vtable(); - - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - -#endif /* FCLAW2D_CLAWPATCH_OPTIONS_H */ diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_options.h.TEST.cpp b/src/patches/clawpatch/fclaw2d_clawpatch_options.h.TEST.cpp deleted file mode 100644 index d1d3c4a9c..000000000 --- a/src/patches/clawpatch/fclaw2d_clawpatch_options.h.TEST.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include -#include - -TEST_CASE("fclaw2d_clawpatch_options can store options in two seperate globs") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - fclaw2d_clawpatch_options_t* opts1 = FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1); - fclaw2d_clawpatch_options_t* opts2 = FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1); - - fclaw2d_clawpatch_options_store(glob1, opts1); - /* glob1 has one package glob2 has two */ - fclaw3dx_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1)); - fclaw2d_clawpatch_options_store(glob2, opts2); - - CHECK_EQ(fclaw2d_clawpatch_get_options(glob1), opts1); - CHECK_EQ(fclaw2d_clawpatch_get_options(glob2), opts2); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw3dx_clawpatch_options can store options in two seperate globs") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - fclaw3dx_clawpatch_options_t* opts1 = FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1); - fclaw3dx_clawpatch_options_t* opts2 = FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1); - - fclaw3dx_clawpatch_options_store(glob1, opts1); - /* glob1 has one package glob2 has two */ - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); - fclaw3dx_clawpatch_options_store(glob2, opts2); - - CHECK_EQ(fclaw3dx_clawpatch_get_options(glob1), opts1); - CHECK_EQ(fclaw3dx_clawpatch_get_options(glob2), opts2); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -#ifdef FCLAW_ENABLE_DEBUG - -TEST_CASE("fclaw2d_clawpatch_get_options fails if not intialized") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - CHECK_SC_ABORTED(fclaw2d_clawpatch_get_options(glob1)); - - CHECK_SC_ABORTED(fclaw2d_clawpatch_get_options(glob2)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw3dx_clawpatch_get_options fails if not intialized") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - CHECK_SC_ABORTED(fclaw3dx_clawpatch_get_options(glob1)); - - CHECK_SC_ABORTED(fclaw3dx_clawpatch_get_options(glob2)); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw2d_clawpatch_options_store fails if called twice on a glob") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); - CHECK_SC_ABORTED(fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1))); - - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); - CHECK_SC_ABORTED(fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1))); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw3dx_clawpatch_options_store fails if called twice on a glob") -{ - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - fclaw3dx_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1)); - CHECK_SC_ABORTED(fclaw3dx_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1))); - - fclaw3dx_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1)); - CHECK_SC_ABORTED(fclaw3dx_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1))); - - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); -} - -TEST_CASE("fclaw3dx_clawpatch_get_options fails is fclaw2d_clawpatch_options is set") -{ - fclaw2d_global_t* glob = fclaw2d_global_new(); - - fclaw2d_clawpatch_options_store(glob, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); - - CHECK_SC_ABORTED(fclaw3dx_clawpatch_get_options(glob)); - - fclaw2d_global_destroy(glob); -} - -TEST_CASE("fclaw2d_clawpatch_options packing/unpacking") -{ - fclaw2d_clawpatch_options_t* opts = FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1); - opts->mx = 5; - opts->my = 6; - opts->maux = 4; - opts->mbc = 3; - opts->meqn = 32; - opts->rhs_fields = 39; - opts->refinement_criteria = 1; - opts->interp_stencil_width = 3; - opts->ghost_patch_pack_aux = 7; - opts->save_aux = 1; - opts->is_registered = 1; - - const fclaw_packing_vtable_t* vt = fclaw2d_clawpatch_options_get_packing_vtable(); - - size_t size = vt->size(opts); - char buffer[size]; - size_t bytes_written = vt->pack(opts,buffer); - REQUIRE_EQ(bytes_written,size); - - fclaw2d_clawpatch_options_t* output_opts = nullptr; - size_t bytes_read = vt->unpack(buffer,(void**)&output_opts); - - REQUIRE_EQ(bytes_read,size); - REQUIRE_NE(output_opts,nullptr); - - CHECK_EQ(output_opts->mx,opts->mx); - CHECK_EQ(output_opts->my,opts->my); - CHECK_EQ(output_opts->maux,opts->maux); - CHECK_EQ(output_opts->mbc,opts->mbc); - CHECK_EQ(output_opts->meqn,opts->meqn); - CHECK_EQ(output_opts->rhs_fields,opts->rhs_fields); - CHECK_EQ(output_opts->refinement_criteria,opts->refinement_criteria); - CHECK_EQ(output_opts->interp_stencil_width,opts->interp_stencil_width); - CHECK_EQ(output_opts->ghost_patch_pack_aux,opts->ghost_patch_pack_aux); - CHECK_EQ(output_opts->save_aux,opts->save_aux); - CHECK_EQ(output_opts->is_registered,opts->is_registered); - - vt->destroy(output_opts); - FCLAW_FREE(opts); -} - -TEST_CASE("fclaw3dx_clawpatch_options packing/unpacking") -{ - fclaw3dx_clawpatch_options_t* opts = FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1); - opts->mx = 5; - opts->my = 6; - opts->mz = 3; - opts->maux = 4; - opts->mbc = 3; - opts->meqn = 32; - opts->rhs_fields = 39; - opts->refinement_criteria = 1; - opts->interp_stencil_width = 3; - opts->ghost_patch_pack_aux = 7; - opts->save_aux = 1; - opts->is_registered = 1; - - const fclaw_packing_vtable_t* vt = fclaw3dx_clawpatch_options_get_packing_vtable(); - - size_t size = vt->size(opts); - char buffer[size]; - size_t bytes_written = vt->pack(opts,buffer); - REQUIRE_EQ(bytes_written,size); - - fclaw3dx_clawpatch_options_t* output_opts = nullptr; - size_t bytes_read = vt->unpack(buffer,(void**)&output_opts); - - REQUIRE_EQ(bytes_read,size); - REQUIRE_NE(output_opts,nullptr); - - CHECK_EQ(output_opts->mx,opts->mx); - CHECK_EQ(output_opts->my,opts->my); - CHECK_EQ(output_opts->mz,opts->mz); - CHECK_EQ(output_opts->maux,opts->maux); - CHECK_EQ(output_opts->mbc,opts->mbc); - CHECK_EQ(output_opts->meqn,opts->meqn); - CHECK_EQ(output_opts->rhs_fields,opts->rhs_fields); - CHECK_EQ(output_opts->refinement_criteria,opts->refinement_criteria); - CHECK_EQ(output_opts->interp_stencil_width,opts->interp_stencil_width); - CHECK_EQ(output_opts->ghost_patch_pack_aux,opts->ghost_patch_pack_aux); - CHECK_EQ(output_opts->save_aux,opts->save_aux); - CHECK_EQ(output_opts->is_registered,opts->is_registered); - - vt->destroy(output_opts); - FCLAW_FREE(opts); -} -#endif \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_output_vtk.h b/src/patches/clawpatch/fclaw2d_clawpatch_output_vtk.h deleted file mode 100644 index 1247b0c36..000000000 --- a/src/patches/clawpatch/fclaw2d_clawpatch_output_vtk.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW2D_CLAWPATCH_OUTPUT_VTK_H -#define FCLAW2D_CLAWPATCH_OUTPUT_VTK_H - -/** - * @file - * Routines for vtk output - */ - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -struct fclaw2d_global; -struct fclaw2d_patch; - -/** - * Callback to access/compute patch data for visualization. - * @param[in] global the global context - * @param[in] this_patch the patch context - * @param[in] this_block_idx the block index - * @param[in] this_patch_ids the patch index - * @param[in,out] a The callback should write into this memory. - * For coordinate locations, it holds - * (my + 1) * (mx + 1) * 3 floats. - * For patch data, it holds my * mx * meqn floats. - * The vector index changes fastest, then mx, then my - * slowest. - */ -typedef void (*fclaw2d_vtk_patch_data_t) (struct fclaw2d_global * glob, - struct fclaw2d_patch * this_patch, - int this_block_idx, int this_patch_idx, - char *a); - -/** - * Write a file in VTK format for the whole domain in parallel. - * @param[in] glob the global context - * @param[in] basename the base filename - * @param[in] mx, my th enumber of cells in the x and y directions - * @param[in] meqn th enumber of equations - * @param[in] vtkspace Relative width of visual separation of patches. - * Between 0. (none) and 1. (patch width becomes 0). - * @param[in] vtkwrite Mode of writing: (unused; uses 1 by default) - * 0 for MPI_File_write_all (faster), - * 1 for MPI_File_write (less memory usage). - * @param[in] coordniate_cb the callback to write a patch's coordinate binary data - * @param[in] value_cb the callback to write a patch's value binary data - * @param[in] patch_threshold The maximal number of buffered patches. - * 0 means that an unlimited number of patches is - * buffered and flushed to disk at the end. - * @return 0 if successful, negative otherwise. - * Collective with identical value on all ranks. - */ -int -fclaw2d_vtk_write_file (struct fclaw2d_global * glob, const char *basename, - int mx, int my, -#if FCLAW2D_PATCHDIM == 3 - int mz, -#endif - int meqn, - double vtkspace, int vtkwrite, - fclaw2d_vtk_patch_data_t coordinate_cb, - fclaw2d_vtk_patch_data_t value_cb, - int patch_threshold); - -/** - * @brief Output vtu file - * - * @param glob the global context - * @param iframe the the frame index - */ -void fclaw2d_clawpatch_output_vtk (struct fclaw2d_global* glob, int iframe); - - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - -#endif /* !FCLAW2D_VTK_H */ diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_pillow.c b/src/patches/clawpatch/fclaw2d_clawpatch_pillow.c deleted file mode 100644 index bfc745d91..000000000 --- a/src/patches/clawpatch/fclaw2d_clawpatch_pillow.c +++ /dev/null @@ -1,298 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif - -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif - -#include -#include - -#if REFINE_DIM == 2 && PATCH_DIM == 2 - -#define PILLOW_VTABLE_NAME "fclaw2d_clawpatch_pillow" - -#include - -#include -#include -#include - -#elif REFINE_DIM == 2 && PATCH_DIM == 3 - -#define PILLOW_VTABLE_NAME "fclaw3dx_clawpatch_pillow" - - -#include - -#include -#include - -#include - -#include <_fclaw2d_to_fclaw3dx.h> -#include <_fclaw2d_to_fclaw3d.h> - -#endif - -#include - -//static fclaw2d_clawpatch_pillow_vtable_t s_clawpatch_pillow_vt; - -struct fclaw2d_patch_transform_data; /* Not used here, so we leave it incomplete */ - -static -void pillow_copy_block_corner(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - fclaw2d_patch_t *corner_patch, - int blockno, - int corner_blockno, - int icorner, - int time_interp, - struct fclaw2d_patch_transform_data *transform_data) -{ - int meqn; - double *qthis; - fclaw2d_clawpatch_timesync_data(glob,patch,time_interp,&qthis,&meqn); - - double *qcorner = fclaw2d_clawpatch_get_q(glob,corner_patch); - - fclaw2d_clawpatch_pillow_vtable_t* pillow_vt = fclaw2d_clawpatch_pillow_vt(glob); - FCLAW_ASSERT(pillow_vt != NULL); - - int mx,my,mbc; - double xlower,ylower,dx,dy; -#if PATCH_DIM == 2 - - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, - &xlower,&ylower,&dx,&dy); - - pillow_vt->fort_copy_block_corner(&mx, &my, &mbc, &meqn, - qthis, qcorner, - &icorner, &blockno); -#elif PATCH_DIM == 3 - int mz; - double zlower, dz; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mz,&mbc, - &xlower,&ylower,&zlower, &dx, &dy, &dz); - FCLAW_ASSERT(pillow_vt->fort_copy_block_corner != NULL); - - pillow_vt->fort_copy_block_corner(&mx, &my, &mz, &mbc, &meqn, - qthis, qcorner, - &icorner, &blockno); -#endif - -} - -static -void pillow_average_block_corner(fclaw2d_global_t *glob, - fclaw2d_patch_t* coarse_patch, - fclaw2d_patch_t *fine_patch, - int coarse_blockno, - int fine_blockno, - int icorner_coarse, - int time_interp, - struct fclaw2d_patch_transform_data* transform_data) -{ - - int refratio = 2; - - int meqn; - double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp, - &qcoarse,&meqn); - double* qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); - - double *areacoarse = fclaw2d_clawpatch_get_area(glob,coarse_patch); - double *areafine = fclaw2d_clawpatch_get_area(glob,fine_patch); - - fclaw2d_clawpatch_pillow_vtable_t* pillow_vt = fclaw2d_clawpatch_pillow_vt(glob); - int mx,my,mbc; - double xlower,ylower,dx,dy; -#if PATCH_DIM == 2 - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, - &xlower,&ylower,&dx,&dy); - - - pillow_vt->fort_average_block_corner(&mx,&my,&mbc,&meqn, - &refratio,qcoarse,qfine, - areacoarse,areafine, - &icorner_coarse,&coarse_blockno); -#elif PATCH_DIM == 3 - int mz; - double zlower, dz; - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mz, &mbc, - &xlower,&ylower, &zlower, &dx,&dy, &dz); - - pillow_vt->fort_average_block_corner(&mx,&my,&mz, &dz, &mbc,&meqn, - &refratio,qcoarse,qfine, - areacoarse,areafine, - &icorner_coarse,&coarse_blockno); -#endif -} - -static -void pillow_interpolate_block_corner(fclaw2d_global_t* glob, - fclaw2d_patch_t* coarse_patch, - fclaw2d_patch_t *fine_patch, - int coarse_blockno, - int fine_blockno, - int icoarse_corner, - int time_interp, - struct fclaw2d_patch_transform_data* transform_data) - -{ - int meqn; - double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp, - &qcoarse,&meqn); - - double* qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); - - fclaw2d_clawpatch_pillow_vtable_t* pillow_vt = fclaw2d_clawpatch_pillow_vt(glob); - int refratio = 2; - int mx,my,mbc; - double xlower,ylower,dx,dy; -#if PATCH_DIM == 2 - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, - &xlower,&ylower,&dx,&dy); - - pillow_vt->fort_interpolate_block_corner(&mx, &my, &mbc, &meqn, - &refratio, qcoarse, qfine, - &icoarse_corner, &coarse_blockno); -#elif PATCH_DIM == 3 - int mz; - double zlower, dz; - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mz, &mbc, - &xlower,&ylower,&zlower, &dx,&dy, &dz); - - pillow_vt->fort_interpolate_block_corner(&mx, &my, &mz, &mbc, &meqn, - &refratio, qcoarse, qfine, - &icoarse_corner, &coarse_blockno); - -#endif -} - -/* ----------------------------- Use pillow sphere ------------------------------------ */ - -void fclaw2d_clawpatch_use_pillowsphere(fclaw2d_global_t* glob) -{ - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); - - patch_vt->copy_block_corner = pillow_copy_block_corner; - patch_vt->average_block_corner = pillow_average_block_corner; - patch_vt->interpolate_block_corner = pillow_interpolate_block_corner; - -} - - -/* -------------------------------- Virtual table ------------------------------------- */ - -static -fclaw2d_clawpatch_pillow_vtable_t* pillow_vt_new() -{ - return (fclaw2d_clawpatch_pillow_vtable_t*) - FCLAW_ALLOC_ZERO (fclaw2d_clawpatch_pillow_vtable_t, 1); -} - -static -void pillow_vt_destroy(void* vt) -{ - FCLAW_FREE (vt); -} - -#if 0 -static -fclaw2d_clawpatch_pillow_vtable_t* pillow_vt_init() -{ - //FCLAW_ASSERT(s_clawpatch_pillow_vt.is_set == 0); - return &s_clawpatch_pillow_vt; -} -#endif - -void fclaw2d_clawpatch_pillow_vtable_initialize(fclaw2d_global_t* glob, - int claw_version) -{ - fclaw2d_clawpatch_pillow_vtable_t *pillow_vt = pillow_vt_new(); - -#if PATCH_DIM == 2 - if (claw_version == 4) - { - pillow_vt->fort_copy_block_corner = FCLAW2D_PILLOW46_COPY_BLOCK_CORNER; - pillow_vt->fort_average_block_corner = FCLAW2D_PILLOW46_AVERAGE_BLOCK_CORNER; - pillow_vt->fort_interpolate_block_corner = FCLAW2D_PILLOW46_INTERPOLATE_BLOCK_CORNER; - } - else if (claw_version == 5) - { - pillow_vt->fort_copy_block_corner = FCLAW2D_PILLOW5_COPY_BLOCK_CORNER; - pillow_vt->fort_average_block_corner = FCLAW2D_PILLOW5_AVERAGE_BLOCK_CORNER; - pillow_vt->fort_interpolate_block_corner = FCLAW2D_PILLOW5_INTERPOLATE_BLOCK_CORNER; - } -#elif PATCH_DIM == 3 - if (claw_version == 4) - { - pillow_vt->fort_copy_block_corner = FCLAW3DX_PILLOW46_COPY_BLOCK_CORNER; - pillow_vt->fort_average_block_corner = FCLAW3DX_PILLOW46_AVERAGE_BLOCK_CORNER; - pillow_vt->fort_interpolate_block_corner = FCLAW3DX_PILLOW46_INTERPOLATE_BLOCK_CORNER; - } -#endif - - pillow_vt->is_set = 1; - - FCLAW_ASSERT(fclaw_pointer_map_get(glob->vtables, PILLOW_VTABLE_NAME) == NULL); - fclaw_pointer_map_insert(glob->vtables, PILLOW_VTABLE_NAME, pillow_vt, pillow_vt_destroy); - -} - - -/* ------------------------------- Public access functions ---------------------------- */ - - -fclaw2d_clawpatch_pillow_vtable_t* fclaw2d_clawpatch_pillow_vt(fclaw2d_global_t* glob) -{ - - fclaw2d_clawpatch_pillow_vtable_t* pillow_vt = (fclaw2d_clawpatch_pillow_vtable_t*) - fclaw_pointer_map_get(glob->vtables, - PILLOW_VTABLE_NAME); - - FCLAW_ASSERT(pillow_vt != NULL); - FCLAW_ASSERT(pillow_vt->is_set != 0); - return pillow_vt; -} - -#if 0 -fclaw2d_clawpatch_pillow_vtable_t* fclaw2d_clawpatch_pillow_vt(fclaw2d_global_t* glob) -{ - FCLAW_ASSERT(s_clawpatch_pillow_vt.is_set != 0); - return &s_clawpatch_pillow_vt; -} -#endif - - diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_pillow.h b/src/patches/clawpatch/fclaw2d_clawpatch_pillow.h deleted file mode 100644 index 10d4f5e4d..000000000 --- a/src/patches/clawpatch/fclaw2d_clawpatch_pillow.h +++ /dev/null @@ -1,208 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef PILLOWSPHERE_H -#define PILLOWSPHERE_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -struct fclaw2d_glob; -struct fclaw2d_patch; -struct fclaw2d_patch_transform; - -/** - * @file - * @brief This handles the boundary conditions at the block - * corners for the pillow sphere. - */ - -/** typedef */ -typedef struct fclaw2d_clawpatch_pillow_vtable fclaw2d_clawpatch_pillow_vtable_t; - - -/* ----------------------------- Fortran typedefs ------------------------------------- */ - -/** - * @brief Handles the boundary condition at block corners - * - * @param[in] my, my the number of cells in the x and y directions - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in,out] qthis this solution - * @param[in,out] qneighbor the neighbor solution - * @param[in] icorner the corner that the neighbor is on - * @param[in] iblock the block number - */ -typedef void (*pillow_fort_copy_block_corner_t)(int* mx, int* my, - int* mbc, int* meqn, - double qthis[], - double qneighbor[], - int* icorner, - int* iblock); - -/** - * @brief Handles the boundary condition at block corners with finer neighbors - * - * @param[in] my, my the number of cells in the x and y directions - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] refratio the refinement ratio - * @param[in,out] qcoarse this solution - * @param[in] qfine the neighbor solution - * @param[in] areacoarse cell areas - * @param[in] areafine neighbor cell areas - * @param[in] icorner the corner that the fine neighbor is on - * @param[in] blockno the block number - */ -typedef void (*pillow_fort_average_block_corner_t)(int* mx, int* my, int* mbc, - int* meqn, - int* refratio, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - int* icorner, - int* blockno); - -/** - * @brief Handles the boundary condition at block corners with coarser neighbors - * - * @param[in] my, my the number of cells in the x and y directions - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] refratio the refinement ratio - * @param[in] qcoarse this solution - * @param[in,out] qfine the neighbor solution - * @param[in] icorner_coarse the corner that the fine neighbor is on - * @param[in] blockno the block number - */ -typedef void (*pillow_fort_interpolate_block_corner_t)(int* mx, int* my, int* mbc, - int* meqn, int* refratio, - double qcoarse[], - double qfine[], - int* icoarse_corner, - int* blockno); -#if 0 -typedef void (*pillow_fort_copy_block_corner_t)(const int* mx, - const int* my, - const int *mz, - const int* mbc, - const int* meqn, - double qthis[], - double qneighbor[], - const int* icorner, - const int* iblock); - -typedef void (*pillow_fort_average_block_corner_t)(const int* mx, - const int* my, - const int* mz, - const double *dz, - const int* mbc, - const int* meqn, - const int* refratio, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* coarse_corner, - const int* blockno); - -typedef void (*pillow_fort_interpolate_block_corner_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const int* refratio, - double qcoarse[], - double qfine[], - const int* icoarse_corner, - const int* blockno); - -#endif - -/* ----------------------------- Use pillow sphere ------------------------------------ */ - -/** - * @brief Sets global patch_vtable to use pollow sphere routines - */ -void fclaw2d_clawpatch_use_pillowsphere(struct fclaw2d_global* glob); - -/* --------------------------------- Virtual table ------------------------------------ */ - -/** - * @brief Initialize the pillow vtable - * - * @param glob the global context - * @param claw_version the clawaptck verstion 4 for v4.6, 5 for v5 - */ -void fclaw2d_clawpatch_pillow_vtable_initialize(struct fclaw2d_global* glob, - int claw_version); - -/** - * @brief vtable for handling block corners for pillow sphere - */ -struct fclaw2d_clawpatch_pillow_vtable -{ - /* Block corners */ - /** Handles the boundary condition at block corners */ - pillow_fort_copy_block_corner_t fort_copy_block_corner; - /** Handles the boundary condition at block corners with finer neighbors */ - pillow_fort_average_block_corner_t fort_average_block_corner; - /** Handles the boundary condition at block corners with coarser neighbors */ - pillow_fort_interpolate_block_corner_t fort_interpolate_block_corner; - - /** True if vtable is set */ - int is_set; -}; - - -/* ------------------------------- Public access functions ---------------------------- */ - -/** - * @brief Get the pillow vtable - * - * @param glob the global context - * @return fclaw2d_clawpatch_pillow_vtable_t* the vtable - */ -fclaw2d_clawpatch_pillow_vtable_t* fclaw2d_clawpatch_pillow_vt(struct fclaw2d_global* glob); - - -#ifdef __cplusplus -#if 0 -{ -#endif -} -#endif - - -#endif \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_transform.c b/src/patches/clawpatch/fclaw2d_clawpatch_transform.c index 2380d1ba3..d8063bf12 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_transform.c +++ b/src/patches/clawpatch/fclaw2d_clawpatch_transform.c @@ -31,69 +31,67 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define PATCH_DIM 2 #endif -#if REFINE_DIM == 2 && PATCH_DIM == 2 +#include +#include +#include #include -#include +#include -#elif REFINE_DIM == 2 && PATCH_DIM == 3 - -#include - -#include - -#include - -#include <_fclaw2d_to_fclaw3dx.h> - -#endif - -#include -#include - -void fclaw2d_clawpatch_transform_init_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* this_patch, +void fclaw2d_clawpatch_transform_init_data(fclaw_global_t* glob, + fclaw_patch_t* this_patch, int blockno, int patchno, - fclaw2d_patch_transform_data_t* transform) + fclaw_patch_transform_data_t* transform) { /* Cell centered data */ transform->based = 1; /* Store clawpatch_options in transform->user */ - transform->user = (void*) fclaw2d_clawpatch_get_options(glob); + transform->user = (void*) fclaw_clawpatch_get_options(glob); } void fclaw2d_clawpatch_face_transformation (int faceno, int rfaceno, int ftransform[]) { /* Defined in forestclaw2d.c */ - fclaw2d_patch_face_transformation (faceno, rfaceno, ftransform); + fclaw_patch_face_transformation (2, faceno, rfaceno, ftransform); } void fclaw2d_clawpatch_face_transformation_intra (int ftransform[]) { /* Defined in forestclaw2d.c */ - fclaw2d_patch_face_transformation_intra (ftransform); + fclaw_patch_face_transformation_intra (2, ftransform); } /* Same size neighbor across a face */ void FCLAW2D_CLAWPATCH_TRANSFORM_FACE (const int *i1, const int *j1, - int *i2, int *j2, fclaw2d_patch_transform_data_t** ptdata) + int *i2, int *j2, fclaw_patch_transform_data_t** ptdata) { - fclaw2d_patch_transform_data_t *tdata = *ptdata; - const fclaw2d_clawpatch_options_t *clawpatch_opt = - (fclaw2d_clawpatch_options_t*) tdata->user; + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx,my; + if(clawpatch_opt->patch_dim == 2) + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } + else + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } *i2 = *i1; *j2 = *j1; - fclaw2d_patch_transform_face (tdata->this_patch, - tdata->neighbor_patch, - tdata->transform, - clawpatch_opt->mx, - clawpatch_opt->my, - tdata->based, i2, j2); + fclaw_patch_2d_transform_face (tdata->this_patch, + tdata->neighbor_patch, + tdata->transform, + mx, my, + tdata->based, i2, j2); } @@ -101,31 +99,54 @@ FCLAW2D_CLAWPATCH_TRANSFORM_FACE (const int *i1, const int *j1, void FCLAW2D_CLAWPATCH_TRANSFORM_FACE_HALF (const int *i1, const int *j1, int i2[], int j2[], - fclaw2d_patch_transform_data_t** ptdata) + fclaw_patch_transform_data_t** ptdata) { - fclaw2d_patch_transform_data_t *tdata = *ptdata; - const fclaw2d_clawpatch_options_t *clawpatch_opt = - (fclaw2d_clawpatch_options_t*) tdata->user; + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx,my; + if(clawpatch_opt->patch_dim == 2) + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } + else + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } i2[0] = *i1; j2[0] = *j1; - fclaw2d_patch_transform_face2 (tdata->this_patch, - tdata->neighbor_patch, - tdata->transform, - clawpatch_opt->mx, - clawpatch_opt->my, - tdata->based, i2, j2); + fclaw_patch_2d_transform_face2 (tdata->this_patch, + tdata->neighbor_patch, + tdata->transform, + mx, my, + tdata->based, i2, j2); } void FCLAW2D_CLAWPATCH_TRANSFORM_CORNER (const int *i1, const int *j1, int *i2, int *j2, - fclaw2d_patch_transform_data_t** ptdata) + fclaw_patch_transform_data_t** ptdata) { - fclaw2d_patch_transform_data_t *tdata = *ptdata; - const fclaw2d_clawpatch_options_t *clawpatch_opt = - (fclaw2d_clawpatch_options_t*) tdata->user; + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx,my; + if(clawpatch_opt->patch_dim == 2) + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } + else + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } *i2 = *i1; *j2 = *j1; @@ -135,10 +156,10 @@ FCLAW2D_CLAWPATCH_TRANSFORM_CORNER (const int *i1, const int *j1, #if 0 FCLAW_ASSERT (tdata->block_iface < 4); #endif - fclaw2d_patch_transform_face (tdata->this_patch, - tdata->neighbor_patch, tdata->transform, - clawpatch_opt->mx, clawpatch_opt->my, - tdata->based, i2, j2); + fclaw_patch_2d_transform_face (tdata->this_patch, + tdata->neighbor_patch, tdata->transform, + mx, my, + tdata->based, i2, j2); } else { @@ -146,34 +167,45 @@ FCLAW2D_CLAWPATCH_TRANSFORM_CORNER (const int *i1, const int *j1, * corners, we assume both patches lie in coordinate systems with the * same orientation. */ FCLAW_ASSERT (tdata->block_iface == -1); - fclaw2d_patch_transform_corner (tdata->this_patch, - tdata->neighbor_patch, - tdata->icorner, tdata->is_block_corner, - clawpatch_opt->mx, clawpatch_opt->my, - tdata->based, i2, j2); + fclaw_patch_2d_transform_corner (tdata->this_patch, + tdata->neighbor_patch, + tdata->icorner, tdata->is_block_corner, + mx, my, + tdata->based, i2, j2); } } void FCLAW2D_CLAWPATCH_TRANSFORM_CORNER_HALF (const int *i1, const int *j1, int *i2, int *j2, - fclaw2d_patch_transform_data_t** ptdata) + fclaw_patch_transform_data_t** ptdata) { - fclaw2d_patch_transform_data_t *tdata = *ptdata; - const fclaw2d_clawpatch_options_t *clawpatch_opt = - (fclaw2d_clawpatch_options_t*) tdata->user; + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx,my; + if(clawpatch_opt->patch_dim == 2) + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } + else + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + } i2[0] = *i1; j2[0] = *j1; if (tdata->block_iface >= 0) { /* block-face but not a block-corner. */ - fclaw2d_patch_transform_face2 (tdata->this_patch, - tdata->neighbor_patch, - tdata->transform, - clawpatch_opt->mx, - clawpatch_opt->my, - tdata->based, i2, j2); + fclaw_patch_2d_transform_face2 (tdata->this_patch, + tdata->neighbor_patch, + tdata->transform, + mx, my, + tdata->based, i2, j2); } else { @@ -181,10 +213,10 @@ FCLAW2D_CLAWPATCH_TRANSFORM_CORNER_HALF (const int *i1, const int *j1, * corners, we assume both patches lie in coordinate systems with the * same orientation. */ FCLAW_ASSERT (tdata->block_iface == -1); - fclaw2d_patch_transform_corner2 (tdata->this_patch, - tdata->neighbor_patch, - tdata->icorner, tdata->is_block_corner, - clawpatch_opt->mx, clawpatch_opt->my, - tdata->based, i2, j2); + fclaw_patch_2d_transform_corner2 (tdata->this_patch, + tdata->neighbor_patch, + tdata->icorner, tdata->is_block_corner, + mx, my, + tdata->based, i2, j2); } } diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_transform.h b/src/patches/clawpatch/fclaw2d_clawpatch_transform.h index 92bf12889..acca0c8ad 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_transform.h +++ b/src/patches/clawpatch/fclaw2d_clawpatch_transform.h @@ -42,10 +42,10 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_patch; /* fclaw2d_patch.h includes this file */ +struct fclaw_global; +struct fclaw_patch; /* fclaw2d_patch.h includes this file */ /** Struture to store a patch's transform data */ -struct fclaw2d_patch_transform_data; +struct fclaw_patch_transform_data; /** * @brief Initialize the patch's tranform data @@ -56,10 +56,10 @@ struct fclaw2d_patch_transform_data; * @param[in] patchno the patch number * @param[in,out] transform the transform data */ -void fclaw2d_clawpatch_transform_init_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_clawpatch_transform_init_data(struct fclaw_global* glob, + struct fclaw_patch* this_patch, int blockno, int patchno, - struct fclaw2d_patch_transform_data* transform); + struct fclaw_patch_transform_data* transform); /** @copydoc fclaw2d_patch_face_transformation() */ void fclaw2d_clawpatch_face_transformation (int faceno, int rfaceno, int ftransform[]); @@ -82,7 +82,7 @@ void fclaw2d_clawpatch_face_transformation_intra (int ftransform[]); */ void FCLAW2D_CLAWPATCH_TRANSFORM_FACE (const int *i1, const int *j1, int *i2, int *j2, - struct fclaw2d_patch_transform_data** ptdata); + struct fclaw_patch_transform_data** ptdata); /** Fortran subroutine name */ #define FCLAW2D_CLAWPATCH_TRANSFORM_FACE_HALF FCLAW_F77_FUNC_(fclaw2d_clawpatch_transform_face_half, \ @@ -96,7 +96,7 @@ void FCLAW2D_CLAWPATCH_TRANSFORM_FACE (const int *i1, const int *j1, */ void FCLAW2D_CLAWPATCH_TRANSFORM_FACE_HALF (const int *i1, const int *j1, int i2[], int j2[], - struct fclaw2d_patch_transform_data** ptdata); + struct fclaw_patch_transform_data** ptdata); /** Fortran subroutine name */ #define FCLAW2D_CLAWPATCH_TRANSFORM_CORNER FCLAW_F77_FUNC_(fclaw2d_clawpatch_transform_corner, \ @@ -110,7 +110,7 @@ void FCLAW2D_CLAWPATCH_TRANSFORM_FACE_HALF (const int *i1, const int *j1, */ void FCLAW2D_CLAWPATCH_TRANSFORM_CORNER (const int *i1, const int *j1, int *i2, int *j2, - struct fclaw2d_patch_transform_data** ptdata); + struct fclaw_patch_transform_data** ptdata); /** Fortran subroutine name */ #define FCLAW2D_CLAWPATCH_TRANSFORM_CORNER_HALF FCLAW_F77_FUNC_(fclaw2d_clawpatch_transform_corner_half, \ @@ -125,7 +125,7 @@ void FCLAW2D_CLAWPATCH_TRANSFORM_CORNER (const int *i1, const int *j1, */ void FCLAW2D_CLAWPATCH_TRANSFORM_CORNER_HALF (const int *i1, const int *j1, int i2[], int j2[], - struct fclaw2d_patch_transform_data** ptdata); + struct fclaw_patch_transform_data** ptdata); #ifdef __cplusplus #if 0 diff --git a/src/patches/clawpatch/fclaw3d_clawpatch46_fort.h b/src/patches/clawpatch/fclaw3d_clawpatch46_fort.h new file mode 100644 index 000000000..4e4759539 --- /dev/null +++ b/src/patches/clawpatch/fclaw3d_clawpatch46_fort.h @@ -0,0 +1,775 @@ +/* +Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FCLAW3D_CLAWPATCH46_FORT_H +#define FCLAW3D_CLAWPATCH46_FORT_H + +/** + * @file + * C declarations of clawpatch 4.6 fortran subroutines + */ +#ifdef __cplusplus +extern "C" +{ +#endif + + +#if 0 +/* Fix syntax highlighting */ +#endif + +struct fclaw_patch_transform_data; /* Should be replaced by long int? */ + +/** @{ @name Time Stepping Functions *//*---------------------------------------------- */ + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_TIMEINTERP \ + FCLAW_F77_FUNC (fclaw3d_clawpatch46_fort_timeinterp, \ + FCLAW3D_CLAWPATCH46_FORT_TIMEINTERP) + +/** @copydoc fclaw3d_clawpatch46_fort_timeinterp() */ +void FCLAW3D_CLAWPATCH46_FORT_TIMEINTERP(const int *mx, + const int* my, + const int* mz, + const int* mbc, + const int *meqn, + const int* psize, + double qcurr[], + double qlast[], + double qinterp[], + const double* alpha, + const int* ierror); + +/** @} */ + +/** @{ @name Regridding Functions *//*------------------------------------------------- */ + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_TAG4REFINEMENT \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_tag4refinement, \ + FCLAW3D_CLAWPATCH46_FORT_TAG4REFINEMENT) + +/** @copydoc fclaw3d_clawpatch46_fort_tag4refinement() */ +void FCLAW3D_CLAWPATCH46_FORT_TAG4REFINEMENT(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const double* xlower, + const double* ylower, + const double* zlower, + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q[], + const double* tag_threshold, + const int* init_flag, + int* tag_patch); + + + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_tag4coarsening, \ + FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING) + +/** @copydoc fclaw3d_clawpatch46_fort_tag4coarsening() */ +void FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double xlower[], + double ylower[], + double zlower[], + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q0[], + double q1[], + double q2[], + double q3[], + const double* tag_threshold, + const int* initflag, + int* tag_patch); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_TAG4COARSENING \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_tag4coarsening, \ + FCLAW3D_CLAWPATCH46_FORT_TAG4COARSENING) + +/** @copydoc fclaw3d_clawpatch46_fort_tag4coarsening() */ +void FCLAW3D_CLAWPATCH46_FORT_TAG4COARSENING(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double xlower[], + double ylower[], + double zlower[], + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q0[], + double q1[], + double q2[], + double q3[], + double q4[], + double q5[], + double q6[], + double q7[], + const double* tag_threshold, + const int* initflag, + int* tag_patch); + + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE2FINE \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_interpolate2fine, \ + FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE2FINE) + +/** @copydoc fclaw3d_clawpatch46_fort_interpolate2fine() */ +void FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE2FINE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold); + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_interpolate2fine, \ + FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE) + +/** @copydoc fclaw3dx_clawpatch46_fort_interpolate2fine() */ +void FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold); + + /** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_AVERAGE2COARSE \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_average2coarse, \ + FCLAW3D_CLAWPATCH46_FORT_AVERAGE2COARSE) + +/** @copydoc fclaw3d_clawpatch46_fort_average2coarse() */ +void FCLAW3D_CLAWPATCH46_FORT_AVERAGE2COARSE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold); + + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_average2coarse, \ + FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE) + +/** @copydoc fclaw3dx_clawpatch46_fort_average2coarse() */ +void FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold); + + + +/** @} */ + +/** @{ @name Ghost Filling *//*-------------------------------------------------------- */ + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_COPY_FACE \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_copy_face, \ + FCLAW3D_CLAWPATCH46_FORT_COPY_FACE) + +/** @copydoc fclaw3d_clawpatch46_fort_copy_face() */ +void FCLAW3D_CLAWPATCH46_FORT_COPY_FACE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qthis[], + double qneighbor[], + const int* a_idir, + struct fclaw_patch_transform_data** + transform_cptr); + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_COPY_FACE \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_copy_face, \ + FCLAW3Dx_CLAWPATCH46_FORT_COPY_FACE) + +/** @copydoc fclaw3d_clawpatch46_fort_copy_face() */ +void FCLAW3DX_CLAWPATCH46_FORT_COPY_FACE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qthis[], + double qneighbor[], + const int* a_idir, + struct fclaw_patch_transform_data** + transform_cptr); + + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_AVERAGE_FACE \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_average_face, \ + FCLAW3D_CLAWPATCH46_FORT_AVERAGE_FACE) +/** @copydoc fclaw3d_clawpatch46_fort_average_face() */ +void FCLAW3D_CLAWPATCH46_FORT_AVERAGE_FACE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* idir, + const int* iside, + const int* num_neighbors, + const int* refratio, + const int* igrid, + const int* manifold, + struct fclaw_patch_transform_data** + transform_cptr); + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_average_face, \ + FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE) +/** @copydoc fclaw3dx_clawpatch46_fort_average_face() */ +void FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* idir, + const int* iside, + const int* num_neighbors, + const int* refratio, + const int* igrid, + const int* manifold, + struct fclaw_patch_transform_data** + transform_cptr); + /** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_FACE \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_interpolate_face, \ + FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_FACE) +/** @copydoc fclaw3d_clawpatch46_fort_interpolate_face() */ +void FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_FACE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + const int* idir, + const int* iside, + const int* num_neighbors, + const int* refratio, + const int* igrid, + struct fclaw_patch_transform_data** + transform_cptr); + + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_interpolate_face, \ + FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE) +/** @copydoc fclaw3dx_clawpatch46_fort_interpolate_face() */ +void FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + const int* idir, + const int* iside, + const int* num_neighbors, + const int* refratio, + const int* igrid, + struct fclaw_patch_transform_data** + transform_cptr); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_COPY_EDGE \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_copy_edge, \ + FCLAW3D_CLAWPATCH46_FORT_COPY_EDGE) + +/** @copydoc fclaw3d_clawpatch46_fort_copy_face() */ +void FCLAW3D_CLAWPATCH46_FORT_COPY_EDGE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qthis[], + double qneighbor[], + const int* iedge, + struct fclaw_patch_transform_data** + transform_cptr); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_AVERAGE_EDGE \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_average_edge, \ + FCLAW3D_CLAWPATCH46_FORT_AVERAGE_EDGE) +/** @copydoc fclaw3d_clawpatch46_fort_average_corner() */ +void FCLAW3D_CLAWPATCH46_FORT_AVERAGE_EDGE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* a_refratio, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* manifold, + const int* a_corner, + struct fclaw_patch_transform_data** + transform_cptr); + /** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_EDGE \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_interpolate_edge, \ + FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_EDGE) +/** @copydoc fclaw3d_clawpatch46_fort_interpolate_edge() */ +void FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_EDGE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* a_refratio, + double this_q[], + double neighbor_q[], + const int* a_edge, + struct fclaw_patch_transform_data** + transform_cptr); + + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_COPY_CORNER \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_copy_corner, \ + FCLAW3D_CLAWPATCH46_FORT_COPY_CORNER) +/** @copydoc fclaw3d_clawpatch46_fort_copy_corner() */ +void FCLAW3D_CLAWPATCH46_FORT_COPY_CORNER(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double this_q[], + double neighbor_q[], + const int* a_corner, + struct fclaw_patch_transform_data** + transform_cptr); + + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_copy_corner, \ + FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER) +/** @copydoc fclaw3dx_clawpatch46_fort_copy_corner() */ +void FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double this_q[], + double neighbor_q[], + const int* a_corner, + struct fclaw_patch_transform_data** + transform_cptr); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_AVERAGE_CORNER \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_average_corner, \ + FCLAW3D_CLAWPATCH46_FORT_AVERAGE_CORNER) +/** @copydoc fclaw3d_clawpatch46_fort_average_corner() */ +void FCLAW3D_CLAWPATCH46_FORT_AVERAGE_CORNER(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* a_refratio, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* manifold, + const int* a_corner, + struct fclaw_patch_transform_data** + transform_cptr); + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_average_corner, \ + FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER) +/** @copydoc fclaw3dx_clawpatch46_fort_average_corner() */ +void FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* a_refratio, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* manifold, + const int* a_corner, + struct fclaw_patch_transform_data** + transform_cptr); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_CORNER \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_interpolate_corner, \ + FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_CORNER) +/** @copydoc fclaw3d_clawpatch46_fort_interpolate_corner() */ +void FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_CORNER(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* a_refratio, + double this_q[], + double neighbor_q[], + const int* a_corner, + struct fclaw_patch_transform_data** + transform_cptr); + + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_interpolate_corner, \ + FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER) +/** @copydoc fclaw3dx_clawpatch46_fort_interpolate_corner() */ +void FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* a_refratio, + double this_q[], + double neighbor_q[], + const int* a_corner, + struct fclaw_patch_transform_data** + transform_cptr); + +/** @} */ + + +/* ------------------------- Pillow grid block corner routines ----------------------- */ + +/** Fortran subroutine name */ +#define FCLAW3DX_PILLOW46_COPY_BLOCK_CORNER \ + FCLAW_F77_FUNC(fclaw3dx_pillow46_copy_block_corner, \ + FCLAW3DX_PILLOW46_COPY_BLOCK_CORNER) + +/** @copydoc fclaw2d_pillow46_copy_block_corner() */ +void FCLAW3DX_PILLOW46_COPY_BLOCK_CORNER(int* mx, + int* my, + int* mz, + int* mbc, + int* meqn, + double qthis[], + double qneighbor[], + int* icorner, + int* iblock); + +/** Fortran subroutine name */ +#define FCLAW3DX_PILLOW46_AVERAGE_BLOCK_CORNER \ + FCLAW_F77_FUNC(fclaw3dx_pillow46_average_block_corner,\ + FCLAW3DX_PILLOW46_AVERAGE_BLOCK_CORNER) + +/** @copydoc fclaw2d_pillow46_average_block_corner() */ +void FCLAW3DX_PILLOW46_AVERAGE_BLOCK_CORNER(int* mx, + int* my, + int* mz, + double *dz, + int* mbc, + int* meqn, + int* refratio, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + int* coarse_corner, + int* blockno); + +/** Fortran subroutine name */ +#define FCLAW3DX_PILLOW46_INTERPOLATE_BLOCK_CORNER \ + FCLAW_F77_FUNC(fclaw3dx_pillow46_interpolate_block_corner, \ + FCLAW3DX_PILLOW46_INTERPOLATE_BLOCK_CORNER) + +/** @copydoc fclaw2d_pillow46_interpolate_block_corner() */ +void FCLAW3DX_PILLOW46_INTERPOLATE_BLOCK_CORNER(int* mx, + int* my, + int* mz, + int* mbc, + int* meqn, + int* refratio, + double qcoarse[], + double qfine[], + int* icoarse_corner, + int* blockno); + + + +/* ------------------------------------ Output functions ------------------------------ */ + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_OUTPUT_ASCII \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_output_ascii, \ + FCLAW3D_CLAWPATCH46_FORT_OUTPUT_ASCII) +/** @copydoc fclaw3d_clawpatch46_fort_output_ascii() */ +void FCLAW3D_CLAWPATCH46_FORT_OUTPUT_ASCII(char* matname1, + int* mx, + int* my, + int* mz, + int* meqn, + int* mbc, + double* xlower, + double* ylower, + double* zlower, + double* dx, + double* dy, + double* dz, + double q[], + int* patch_num, + int* level, + int* blockno, + int* mpirank); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_HEADER_ASCII \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_header_ascii, \ + FCLAW3D_CLAWPATCH46_FORT_HEADER_ASCII) +/** @copydoc fclaw3d_clawpatch46_fort_header_ascii() */ +void FCLAW3D_CLAWPATCH46_FORT_HEADER_ASCII(const char* matname1, + const char* matname2, + const double* time, + const int* meqn, + const int* maux, + const int* ngrids); + +/* ----------------------------- Diagnostics functions -------------------------------- */ + + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_CONSERVATION_CHECK \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_conservation_check, \ + FCLAW3D_CLAWPATCH46_FORT_CONSERVATION_CHECK) +/** @copydoc fclaw3d_clawpatch46_fort_conservation_check() */ +void FCLAW3D_CLAWPATCH46_FORT_CONSERVATION_CHECK(int *mx, + int *my, + int* mz, + int* mbc, + int* meqn, + double *dx, + double *dy, + double* dz, + double* area, + double *q, + double* sum, + double* c_kahan); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_COMPUTE_PATCH_AREA \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_compute_patch_area, \ + FCLAW3D_CLAWPATCH46_FORT_COMPUTE_PATCH_AREA) + +/** @copydoc fclaw3d_clawpatch46_fort_compute_patch_area() */ +double FCLAW3D_CLAWPATCH46_FORT_COMPUTE_PATCH_AREA(int *mx, + int* my, + int* mz, + int*mbc, + double* dx, + double* dy, + double* dz, + double area[]); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_COMPUTE_ERROR_NORM \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_compute_error_norm, \ + FCLAW3D_CLAWPATCH46_FORT_COMPUTE_ERROR_NORM) + +/** @copydoc fclaw3d_clawpatch46_fort_compute_error_norm() */ +void FCLAW3D_CLAWPATCH46_FORT_COMPUTE_ERROR_NORM (int* blockno, + int* mx, + int* my, + int* mz, + int* mbc, + int* meqn, + double* dx, + double* dy, + double* dz, + double area[], + double error[], + double* error_norm); + +/* ----------------------------- Parallel ghost patches ------------------------------ */ + +/** Fortran subroutine name */ +#define FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK \ + FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_local_ghost_pack, \ + FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK) +/** @copydoc fclaw3d_clawpatch46_fort_local_ghost_pack() */ +void FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK(const int *mx, + const int *my, + const int* mz, + const int *mbc, + const int *meqn, + const int *mint, + double qdata[], + double area[], + double qpack[], + const int *psize, + const int *packmode, + int *ierror); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH46_FORT_LOCAL_GHOST_PACK \ + FCLAW_F77_FUNC(fclaw3d_clawpatch46_fort_local_ghost_pack, \ + FCLAW3D_CLAWPATCH46_FORT_LOCAL_GHOST_PACK) +/** @copydoc fclaw3d_clawpatch46_fort_local_ghost_pack() */ +void FCLAW3D_CLAWPATCH46_FORT_LOCAL_GHOST_PACK(const int *mx, + const int *my, + const int* mz, + const int *mbc, + const int *meqn, + const int *mint, + double qdata[], + double area[], + double qpack[], + const int *psize, + const int *packmode, + int *ierror); + + + +/* ----------------------------- User convenience headers ----------------------------- */ +/** Fortran subroutine name */ +#define FCLAW2DX_CLAWPATCH46_TAG4REFINEMENT \ + FCLAW_F77_FUNC(fclaw2dx_clawpatch46_tag4refinement, \ + FCLAW2DX_CLAWPATCH46_TAG4REFINEMENT) + +/** + * @brief @copybrief ::clawpatch_fort_tag4refinement_t + * + * For user defined clawpatch46_tag4refinment subroutine + * + * @details @copydetails ::clawpatch_fort_tag4refinement_t + */ +void FCLAW2DX_CLAWPATCH46_TAG4REFINEMENT(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const double* xlower, + const double* ylower, + const double* zlower, + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q[], + const double* tag_threshold, + const int* init_flag, + int* tag_patch); + + + +/** Fortran subroutine name */ +#define FCLAW2DX_CLAWPATCH46_TAG4COARSENING \ + FCLAW_F77_FUNC(fclaw2dx_clawpatch46_tag4coarsening, \ + FCLAW2DX_CLAWPATCH46_TAG4COARSENING) + +/** + * @brief @copybrief ::clawpatch_fort_tag4coarsening_t + * + * For user defined clawpatch46_tag4coarsening subroutine + * + * @details @copydetails ::clawpatch_fort_tag4coarsening_t + */ +void FCLAW2DX_CLAWPATCH46_TAG4COARSENING(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const double* xlower, + const double* ylower, + const double* zlower, + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q0[], + double q1[], + double q2[], + double q3[], + const double* tag_threshold, + const int* initflag, + int* tag_patch); + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/patches/clawpatch/fclaw3d_clawpatch_fort.h b/src/patches/clawpatch/fclaw3d_clawpatch_fort.h new file mode 100644 index 000000000..310df8e2c --- /dev/null +++ b/src/patches/clawpatch/fclaw3d_clawpatch_fort.h @@ -0,0 +1,1014 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FCLAW3D_CLAWPATCH_FORT_H +#define FCLAW3D_CLAWPATCH_FORT_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +struct fclaw_global; +struct fclaw_patch; + +struct fclaw_patch_transform_data; /* Should be replaced by long int? */ + +/** + * @file + * Typedefs for clawpatch fortran functions + * + * Functions defined here are implemented in individual solvers (clawpack 4.6 and + * clawpack 5.0) + */ + +#if 0 +/* Fix syntax highlighting */ +#endif + +/** @{ @name Ghost filling - patch specific *//*----------------------------------------*/ + +/** + * @brief Copies ghost data from a face-neighboring grid on the same level + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in,out] qthis the solution of this patch + * @param[in] qneighbor the solution of the neighbor patch + * @param[in] iface the interface that the neighbor is on + * @param[in] transform_ptr Encoding for indices at block boundaries (C only). + */ +typedef void (*fclaw3d_clawpatch_fort_copy_face_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qthis[], + double qneighbor[], + const int* iface, + struct fclaw_patch_transform_data** transform_ptr); + +/** + * @brief Averages values from a face-neighboring fine grid + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in,out] qcoarse the solution of this patch + * @param[in] qfine the solution of the fine neighbor patch + * @param[in] areacoarse the area of cells in this patch + * @param[in] areafine the area of cells in the fine neighbor patch + * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] + * @param[in] iside the interface of the fine neighbor patch + * @param[in] num_neighbors the number of neighbors + * @param[in] refratio the refinement ratio + * @param[in] igrid the index of the fine neighbor in the child array + * @param[in] manifold true if using mainifold + * @param[in] transform_ptr Encoding for indices at block boundaries (C only). + */ +typedef void (*fclaw3d_clawpatch_fort_average_face_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* idir, + const int* iside, + const int* num_neighbors, + const int* refratio, + const int* igrid, + const int* manifold, + struct fclaw_patch_transform_data** transform_ptr); +/** + * @brief Interpolates values from a face-neighboring coarse grid + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] qcoarse the solution of the coarse neighbor patch + * @param[in,out] qfine the solution of this patch + * @param[in] areacoarse the area of cells in the coarse neighbor patch + * @param[in] arefine the area of cells in the this patch + * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] + * @param[in] iface_coarse the interface of the coarse neighbor patch + * @param[in] num_neighbors the number of neighbors + * @param[in] refratio the refinement ratio + * @param[in] igrid the index of this patch in the child array + * @param[in] transform_ptr Encoding for indices at block boundaries (C only). + */ +typedef void (*fclaw3d_clawpatch_fort_interpolate_face_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + const int* idir, + const int* iface_coarse, + const int* num_neighbors, + const int* refratio, + const int* igrid, + struct fclaw_patch_transform_data** transform_ptr); + +/** + * @brief Copies ghost data from a edge-neighboring grid on the same level + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in,out] qthis the solution of this patch + * @param[in] qneighbor the solution of the neighbor patch + * @param[in] iface the interface that the neighbor is on + * @param[in] transform_ptr Encoding for indices at block boundaries (C only). + */ +typedef void (*fclaw3d_clawpatch_fort_copy_edge_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qthis[], + double qneighbor[], + const int* iedge, + struct fclaw_patch_transform_data** transform_ptr); + +/** + * @brief Averages values from a edge neighboring fine grid + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in,out] qcoarse the solution of this patch + * @param[in] qfine the solution of the fine neighbor patch + * @param[in] areacoarse the area of cells in this patch + * @param[in] arefine the area of cells in the fine neighbor patch + * @param[in] manifold true if using mainifold + * @param[in] a_edge the edge that the fine neighbor is on + * @param[in] transform_ptr Encoding for indices at block boundaries (C only). + */ +typedef void (*fclaw3d_clawpatch_fort_average_edge_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* a_refratio, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* manifold, + const int* a_corner, + struct fclaw_patch_transform_data** transform_ptr); + +/** + * @brief Interpolates values form a edge-neighboring coarse grid + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] refratio the refinement ratio + * @param[in] qcoarse the solution of the coarse patch + * @param[in,out] qfine the solution of the fine patch + * @param[in] iedge_coarse the edge of the coarse neighbor that to interpolate from + * @param[in] transform_ptr Encoding for indices at block boundaries (C only). + */ +typedef void (*fclaw3d_clawpatch_fort_interpolate_edge_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* refratio, + double qcoarse[], + double qfine[], + const int* iedge_coarse, + struct fclaw_patch_transform_data** transform_ptr); + + +/** + * @brief Copies ghost data from a corner-neighboring grid on the same level + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in,out] qthis the solution of this patch + * @param[in] qneighbor the solution of the neighbor patch + * @param[in] icorner_coarse the corner of the coarse patch to copy from + * @param[in] transform_ptr Encoding for indices at block boundaries (C only). + */ +typedef void (*fclaw3d_clawpatch_fort_copy_corner_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qthis[], + double qneighbor[], + const int* icorner_coarse, + struct fclaw_patch_transform_data** transform_ptr); + +/** + * @brief Averages values from a corner neighboring fine grid + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in,out] qcoarse the solution of this patch + * @param[in] qfine the solution of the fine neighbor patch + * @param[in] areacoarse the area of cells in this patch + * @param[in] arefine the area of cells in the fine neighbor patch + * @param[in] manifold true if using mainifold + * @param[in] a_corner the corner that the neighbor is on + * @param[in] transform_ptr Encoding for indices at block boundaries (C only). + */ +typedef void (*fclaw3d_clawpatch_fort_average_corner_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* a_refratio, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* manifold, + const int* a_corner, + struct fclaw_patch_transform_data** transform_ptr); + +/** + * @brief Interpolates values form a corner-neighboring coarse grid + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] refratio the refinement ratio + * @param[in] qcoarse the solution of the coarse patch + * @param[in,out] qfine the solution of the fine patch + * @param[in] icorner_coarse the corner of the coarse neighbor that to interpolate from + * @param[in] transform_ptr Encoding for indices at block boundaries (C only). + */ +typedef void (*fclaw3d_clawpatch_fort_interpolate_corner_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const int* refratio, + double qcoarse[], + double qfine[], + const int* icorner_coarse, + struct fclaw_patch_transform_data** transform_ptr); + +/** @} */ + +/** @{ @name Regridding Functions *//*--------------------------------------------------*/ + +/** + * @brief Tags a patch for refinement. + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] xlower, ylower, zlower the coordinate of the lower bottom left corner + * @param[in] dx, dy, dz spacing of cells in the x, y, and z directions + * @param[in] blockno the block number + * @param[in] q the solution + * @param[in] tag_threshold the threshold for tagging + * @param[in] init_flag true if in initialization stage + * @param[out] tag_patch true if patch should be refined + */ +typedef void (*fclaw3d_clawpatch_fort_tag4refinement_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const double* xlower, + const double* ylower, + const double* zlower, + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q[], + const double* tag_threshold, + const int* init_flag, + int* tag_patch); +/** + * @brief Tags a quad of patches for coarsening. + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] xlower, ylower, zlower the coordinate of the lower bottom left corner + * @param[in] dx, dy, dz spacing of cells in the x, y, and z directions + * @param[in] blockno the block number + * @param[in] q1, q2, q3, q4 the solutions on the patches + * @param[in] tag_threshold the threshold for tagging + * @param[in] init_flag true if in initialization stage + * @param[out] tag_patch true if patches should be coarsened + */ +typedef void (*fclaw3dx_clawpatch_fort_tag4coarsening_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double xlower[], + double ylower[], + double zlower[], + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q0[], + double q1[], + double q2[], + double q3[], + const double* tag_threshold, + const int* init_flag, + int* tag_patch); + +/** + * @brief Tags a quad of patches for coarsening. + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] xlower, ylower, zlower the coordinate of the lower bottom left corner + * @param[in] dx, dy, dz spacing of cells in the x, y, and z directions + * @param[in] blockno the block number + * @param[in] q1,q3,q3,q4,q5,q6,q7,q8 the solutions on the patches + * @param[in] tag_threshold the threshold for tagging + * @param[in] init_flag true if in initialization stage + * @param[out] tag_patch true if patches should be coarsened + */ +typedef void (*fclaw3d_clawpatch_fort_tag4coarsening_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double xlower[], + double ylower[], + double zlower[], + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q0[], + double q1[], + double q2[], + double q3[], + double q4[], + double q5[], + double q6[], + double q7[], + const double* tag_threshold, + const int* init_flag, + int* tag_patch); + +/** + * @deprecated Checks if solution exceeds a threshold + */ +typedef int (*fclaw3d_clawpatch_fort_exceeds_threshold_t)(const int *blockno, + const int* meqn, + const double *qval, + const double *qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *dz, + const double *xc, + const double *yc, + const double *zc, + const int* ivar_variable, + const double *tag_threshold, + const int *init_flag, + const int *is_ghost); + +/** + * @brief Averages a fine patch to a coarse patch + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] qcoarse the coarse solution + * @param[out] qfine the fine solution + * @param[in] areacoarse the area of the coarse cells + * @param[in] areafine the area of the fine cells + * @param[in] igrid the index of the fine patch in the siblings array + * @param[in] manifold true if using manifold + */ +typedef void (*fclaw3d_clawpatch_fort_interpolate2fine_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold); + +/** + * @brief Interpolates from a coarse patch to a fine patche + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] qcoarse the coarse solution + * @param[out] qfine the fine solution + * @param[in] areacoarse the area of the coarse cells + * @param[in] areafine the area of the fine cells + * @param[in] igrid the index of the fine patch in the siblings array + * @param[in] manifold true if using manifold + */ +typedef void (*fclaw3d_clawpatch_fort_average2coarse_t)(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold); + + +/** @} */ + +/** @{ @name time stepping *//*---------------------------------------------------------*/ + +/** + * @brief Interpolates q between timesteps. + * + * This only needs to interpolate the interior cells that are needed for ghost cells on + * neighboring patches + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] psize the total number cells that should be interpolated + * @param[in] qcurr the current q + * @param[in] qlast the previous q + * @param[out] qinterp the inerpolated q + * @param[in] alpha where to interpolate between qlast and qcurr + * @param[out] ierror error value + */ +typedef void (*fclaw3d_clawpatch_fort_timeinterp_t)(const int *mx, + const int* my, + const int* mz, + const int* mbc, + const int *meqn, + const int* psize, + double qcurr[], + double qlast[], + double qinterp[], + const double* alpha, + const int* ierror); + +/** @} */ + +/** @{ @name Parallel ghost patches *//*------------------------------------------------*/ + +/** + * @brief Packs/Unpacks ghost cell data + * + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] mint the number of internal cells to include + * @param[in,out] qdata the solution + * @param[in,out] area the area of each cell + * @param[in,out] qpack the buffer to pack from/to + * @param[in] psize the size of qpack buffer + * @param[in] packmode the packing mode (0 for packing q, 1 for unpacking q, + * 2 for packing q and area, and 3 for unpacking q and area) + * @param[out] ierror the error value + */ +typedef void (*fclaw3d_clawpatch_fort_local_ghost_pack_t)(const int *mx, + const int *my, + const int *mz, + const int *mbc, + const int *meqn, + const int *mint, + double qdata[], + double area[], + double qpack[], + const int *psize, + const int *packmode, + int *ierror); + +/** @} */ + +/** @{ @name Output functions *//*------------------------------------------------------*/ + +/** + * @brief Outputs the header for the time file and leaves and empty data file + * + * @param[in] matname1 name of the data file + * @param[in] matname2 name of the time file + * @param[in] time the time + * @param[in] meqn the number of equations + * @param[in] maux the number of aux equations + * @param[in] ngrids the number of grids (patches) + */ +typedef void (*fclaw_clawpatch_fort_header_ascii_t)(const char* matname1, + const char* matname2, + const double* time, + const int* meqn, + const int* maux, + const int* ngrids); + +/** + * @brief Writes out patch data in ascii format. + * + * This should append the data to the file + * + * @param[in] matname1 the name of the data file + * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost + * @param[in] meqn the number of equations + * @param[in] mbc the number of ghost cells + * @param[in] xlower, ylower, zlower the coordinate of the lower bottom left corner + * @param[in] dx, dy spacing of cells in the x, y, and z directions + * @param[in] q the solution + * @param[in] pach_num the patch number + * @param[in] level the level of the patch + * @param[in] blockno the block number + * @param[in] mpirank the mpi rank of the patch + */ +typedef void (*fclaw3d_clawpatch_fort_output_ascii_t)(char* matname1, + int* mx, + int* my, + int* mz, + int* meqn, + int* mbc, + double* xlower, + double* ylower, + double* zlower, + double* dx, + double* dy, + double* dz, + double q[], + int* patch_num, + int* level, + int* blockno, + int* mpirank); + + +/** @} */ + +/** @{ @name Diagnostic functions *//*--------------------------------------------------*/ + +/** + * @brief Calculates the error for cells in a patch + * + * @param[in] blockno the block number + * @param[in] mx, my, mz the number cells in the x and y directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] dx, dy, dz spacing of cells in the x and y directions + * @param[in] xlower, ylower, zlower the coordinate of the lower left corner + * @param[in] q the computed solution + * @param[out] error the error for each meqn in each cell + * @param[in] soln the exact solution + */ +typedef void (*fclaw3d_clawpatch_fort_error_t)(int* blockno, + int *mx, + int *my, + int* mz, + int *mbc, + int *meqn, + double *dx, + double *dy, + double* dz, + double *xlower, + double *ylower, + double *zlower, + double *t, + double q[], + double error[], + double soln[]); +/** + * @brief Calculates a sum for each equation + * + * @param[in] mx, my, mz the number cells in the x and y directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] dx, dy, dz spacing of cells in the x and y directions + * @param[in] area the area for each cell + * @param[in] q the computed solution + * @param[in,out] sum the current sum for each equaiton + * @param[in,out] c_kahan the the current c values for the Kahan summation algorithm + */ +typedef void (*fclaw3d_clawpatch_fort_conscheck_t)(int *mx, + int *my, + int *mz, + int* mbc, + int* meqn, + double *dx, + double *dy, + double* dz, + double area[], + double q[], + double sum[], + double *c_kahan); + +/** + * @brief Calculates the area of a patch + * + * @param[in] mx, my, mz the number cells in the x and y directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] dx, dy, dz spacing of cells in the x and y directions + * @param[in] area array of area values for cells + * @return the total area of the patch + */ +typedef double (*fclaw3d_clawpatch_fort_area_t)(int *mx, + int* my, + int* mz, + int *mbc, + double *dx, + double** dy, + double *dz, + double area[]); + +/** + * @brief Calculates the error norms for a patch + * + * @param[in] blockno the block number + * @param[in] mx, my the number cells in the x and y directions, excluding ghost + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] dx, dy, dz spacing of cells in the x and y directions + * @param[in] area array of area values for cells + * @param[in] error error array + * @param[out] error_norm a 2d array of l1, l2, and inf norms for each eqn + */ +typedef void (*fclaw3d_clawpatch_fort_norm_t)(int* blockno, + int *mx, + int *my, + int* mz, + int *mbc, + int *meqn, + double *dx, + double *dy, + double *dz, + double area[], + double error[], + double error_norm[]); + +/** @} */ + +/** + * @brief Checks if solution exceeds a threshold + */ +typedef int (*fclaw3d_fort_exceeds_threshold_t)(const int *blockno, + const int* meqn, + const double *qval, + const double *qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *dz, + const double *xc, + const double *yc, + const double *zc, + const int* ivar_threshold, + const double *tag_threshold, + const int *init_flag, + const int *is_ghost); + + +/** @{ @name Fortran Headers *//*-------------------------------------------------------*/ + +/** @brief Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH_GET_REFINEMENT_CRITERIA \ + FCLAW_F77_FUNC(fclaw3d_clawpatch_get_refinement_criteria, \ + FCLAW3D_CLAWPATCH_GET_REFINEMENT_CRITERIA) +/** @brief C declaration of fclaw3d_clawpatch_get_refinement_critera() subroutine */ +int FCLAW3D_CLAWPATCH_GET_REFINEMENT_CRITERIA(); + + +/* ------------------------------- General threshold ---------------------------------- */ + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH_TAG_CRITERIA \ + FCLAW_F77_FUNC(fclaw3d_clawpatch_tag_criteria, \ + FCLAW3D_CLAWPATCH_TAG_CRITERIA) + +/** + * @brief Check if the refinment threshold is exceeded + * + * @param[in] blockno the block number + * @param[in] qval the + * @param[in] qmin the minimum q value + * @param[in] qmax the maximum q value + * @param[in] quad the value and adjacent values of q + * @param[in] dx, dy the spacing in the x and y directions + * @param[in] xc, yc the coordinate of the cell + * @param[in] threshold the threshold + * @param[in] init_flag true if in init stage + * @param[in] is_ghost true if cell is a ghost cell + * @return 1 if exceeds threshold, 0 if not, -1 if inconclusive. + */ +int FCLAW3D_CLAWPATCH_TAG_CRITERIA(const int *blockno, + const double *qval, + const double *qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *dz, + const double *xc, + const double *yc, + const double *zc, + const double *tag_threshold, + const int *init_flag, + const int *is_ghost); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH_EXCEEDS_THRESHOLD \ + FCLAW_F77_FUNC(fclaw3d_clawpatch_exceeds_threshold, \ + FCLAW3D_CLAWPATCH_EXCEEDS_THRESHOLD) + +/** + * @brief Check if the refinment threshold is exceeded + * + * @param[in] blockno the block number + * @param[in] qval the + * @param[in] qmin the minimum q value + * @param[in] qmax the maximum q value + * @param[in] quad the value and adjacent values of q + * @param[in] dx, dy the spacing in the x and y directions + * @param[in] xc, yc the coordinate of the cell + * @param[in] threshold the threshold + * @param[in] init_flag true if in init stage + * @param[in] is_ghost true if cell is a ghost cell + * @return 1 if exceeds threshold, 0 if not, -1 if inconclusive. + */ +int FCLAW3D_CLAWPATCH_EXCEEDS_THRESHOLD(const int *blockno, + const int* meqn, + const double *qval, + const double *qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *dz, + const double *xc, + const double *yc, + const double *zc, + const int* ivar_variable, + const double *tag_threshold, + const int *init_flag, + const int *is_ghost); + + +/* ----------------------------- Value threshold -------------------------------------- */ +/** @brief C declaration of fclaw2d_clawpatch_value_exceeds_th() subroutine */ +#define FCLAW3D_CLAWPATCH_VALUE_EXCEEDS_TH \ + FCLAW_F77_FUNC(fclaw3d_clawpatch_value_exceeds_th, \ + FCLAW3D_CLAWPATCH_VALUE_EXCEEDS_TH) + +/** @brief C declaration of fclaw3dx_clawpatch_value_exceeds_th() subroutine */ +int FCLAW3D_CLAWPATCH_VALUE_EXCEEDS_TH(const int* blockno, + const int* meqn, + const double *qval, + const double* qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *dz, + const double *xc, + const double *yc, + const double *zc, + const int* ivar_variable, + const double* tag_threshold, + const int* init_flag, + const int* is_ghost); + +/* ----------------------------- difference threshold --------------------------------- */ + +/** @brief C declaration of fclaw3dx_clawpatch_difference_exceeds_th() subroutine */ +#define FCLAW3D_CLAWPATCH_DIFFERENCE_EXCEEDS_TH \ + FCLAW_F77_FUNC(fclaw3d_clawpatch_difference_exceeds_th, \ + FCLAW3D_CLAWPATCH_DIFFERENCE_EXCEEDS_TH) + +/** @brief C declaration of fclaw3d_clawpatch_difference_exceeds_th() subroutine */ +int FCLAW3D_CLAWPATCH_DIFFERENCE_EXCEEDS_TH(const int *blockno, + const int *meqn, + const double *qval, + const double *qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *dz, + const double *xc, + const double *yc, + const double *zc, + const int* ivar_variable, + const double *tag_threshold, + const int *init_flag, + const int *is_ghost); + +/* --------------------------------- minmax threshold --------------------------------- */ + +/** @brief C declaration of fclaw3dx_clawpatch_minmax_exceeds_th() subroutine */ +#define FCLAW3D_CLAWPATCH_MINMAX_EXCEEDS_TH \ + FCLAW_F77_FUNC(fclaw3d_clawpatch_minmax_exceeds_th, \ + FCLAW3D_CLAWPATCH_MINMAX_EXCEEDS_TH) + +/** @brief C declaration of fclaw3dx_clawpatch_minmax_exceeds_th() subroutine */ +int FCLAW3D_CLAWPATCH_MINMAX_EXCEEDS_TH(const int *blockno, + const int* meqn, + const double *qval, + const double* qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *dz, + const double *xc, + const double *yc, + const double *zc, + const int* ivar_variable, + const double *tag_threshold, + const int *init_flag, + const int *is_ghost); + +/* ------------------------------- gradient threshold --------------------------------- */ +/** @brief C declaration of fclaw3dx_clawpatch_gradient_exceeds_th() subroutine */ +#define FCLAW3D_CLAWPATCH_GRADIENT_EXCEEDS_TH \ + FCLAW_F77_FUNC(fclaw3d_clawpatch_gradient_exceeds_th, \ + FCLAW3D_CLAWPATCH_GRADIENT_EXCEEDS_TH) + +/** @brief C declaration of fclaw3dx_clawpatch_gradient_exceeds_th() subroutine */ +int FCLAW3D_CLAWPATCH_GRADIENT_EXCEEDS_TH(const int *blockno, + const int* meqn, + const double *qval, + const double* qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *dz, + const double *xc, + const double *yc, + const double *zc, + const int* ivar_variable, + const double *tag_threshold, + const int *init_flag, + const int *is_ghost); + + +/* ------------------------------- user threshold --------------------------------- */ +/** Fortran subroutine name */ +#define FCLAW3D_USER_EXCEEDS_TH FCLAW_F77_FUNC( \ + fclaw3d_user_exceeds_th, \ + FCLAW3D_USER_EXCEEDS_TH) + +/** @brief C declaration of user_exceeds_th() subroutine */ +int FCLAW3D_USER_EXCEEDS_TH(const int *blockno, + const int* meqn, + const double *qval, + const double* qmin, + const double *qmax, + const double quad[], + const double *dx, + const double *dy, + const double *dz, + const double *xc, + const double *yc, + const double *zc, + const int* ivar_variable, + const double *tag_threshold, + const int *init_flag, + const int *is_ghost); + +/* -------------------------- User convenience headers -------------------------------- */ + +/** Fortran subroutine name */ +#define FCLAW3D_USER_TAG4REFINEMENT FCLAW_F77_FUNC( \ + fclaw3d_user_tag4refinement, FCLAW3D_USER_TAG4REFINEMENT) +/** + * @brief C declaration of user defined tag4refinement subroutine, see + * ::clawpatch_fort_tag4refinement_t + */ +void FCLAW3D_USER_TAG4REFINEMENT(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const double* xlower, + const double* ylower, + const double* zlower, + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q[], + const double* tag_threshold, + const int* init_flag, + int* tag_patch); + +/** Fortran subroutine name */ +#define FCLAW3D_USER_TAG4COARSENING FCLAW_F77_FUNC( \ + fclaw3d_user_tag4coarsening, FCLAW3D_USER_TAG4COARSENING) +/** + * @brief C declaration of user defined tag4coarsening subroutine, see + * ::clawpatch_fort_tag4coarsening_t + */ +void FCLAW3D_USER_TAG4COARSENING(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + const double* xlower, + const double* ylower, + const double* zlower, + const double* dx, + const double* dy, + const double* dz, + const int* blockno, + double q0[], + double q1[], + double q2[], + double q3[], + const double* tag_threshold, + const int* initflag, + int* tag_patch); + + +/* ----------------------------- interpolation/coarsening ----------------------------- */ + +/** Fortran subroutine name */ +#define FCLAW3D_USER_INTERPOLATE2FINE FCLAW_F77_FUNC(\ + fclaw3d_user_interpolate2fine, FCLAW3D_USER_INTERPOLATE2FINE) +/** + * @brief C declaration of user defined interpolate2fine subroutine, + * see ::clawpatch_fort_interpolate2fine_t + */ +void FCLAW3D_USER_INTERPOLATE2FINE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold); + +/** Fortran subroutine name */ +#define FCLAW3D_USER_AVERAGE2COARSE FCLAW_F77_FUNC(\ + fclaw3d_user_average2coarse, FCLAW3D_USER_AVERAGE2COARSE) +/** + * @brief C declaration of user defined average2coarse subroutine, + * see ::clawpatch_fort_average2coarse_t + */ +void FCLAW3D_USER_AVERAGE2COARSE(const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/patches/clawpatch/fclaw3d_clawpatch_transform.c b/src/patches/clawpatch/fclaw3d_clawpatch_transform.c new file mode 100644 index 000000000..800d49fc6 --- /dev/null +++ b/src/patches/clawpatch/fclaw3d_clawpatch_transform.c @@ -0,0 +1,278 @@ +/* +Copyright (c) 2012 Carsten Burstedde, Donna Calhoun +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include + +#include + +#include +#include + + +void fclaw3d_clawpatch_transform_init_data(fclaw_global_t* glob, + fclaw_patch_t* this_patch, + int blockno, int patchno, + fclaw_patch_transform_data_t* transform) +{ + /* Cell centered data */ + transform->based = 1; + + /* Store clawpatch_options in transform->user */ + transform->user = (void*) fclaw_clawpatch_get_options(glob); +} + +void fclaw3d_clawpatch_face_transformation (int faceno, int rfaceno, int ftransform[]) +{ + /* Defined in forestclaw2d.c */ + fclaw_patch_face_transformation (3, faceno, rfaceno, ftransform); +} + +void fclaw3d_clawpatch_face_transformation_intra (int ftransform[]) +{ + /* Defined in forestclaw2d.c */ + fclaw_patch_face_transformation_intra (3, ftransform); +} + + +/* Same size neighbor across a face */ +void +FCLAW3D_CLAWPATCH_TRANSFORM_FACE (const int *i1, const int *j1, + const int *k1, + int *i2, int *j2, + int *k2, + fclaw_patch_transform_data_t** ptdata) +{ + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + + *i2 = *i1; + *j2 = *j1; + *k2 = *k1; + fclaw_patch_3d_transform_face (tdata->this_patch, + tdata->neighbor_patch, + tdata->transform, + mx, my, mz, + tdata->based, i2, j2, k2); + +} + + +/* Half size neighbor across a face */ +void +FCLAW3D_CLAWPATCH_TRANSFORM_FACE_HALF (const int *i1, const int *j1, const int* k1, + int i2[], int j2[], int k2[], + fclaw_patch_transform_data_t** ptdata) +{ + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + + i2[0] = *i1; + j2[0] = *j1; + k2[0] = *k1; + fclaw_patch_3d_transform_face2 (tdata->this_patch, + tdata->neighbor_patch, + tdata->transform, + mx, my, mz, + tdata->based, i2, j2, k2); +} + + +void +FCLAW3D_CLAWPATCH_TRANSFORM_EDGE (const int *i1, const int *j1, const int *k1, + int *i2, int *j2, int *k2, + fclaw_patch_transform_data_t** ptdata) +{ + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + + *i2 = *i1; + *j2 = *j1; + *k2 = *k1; + if (tdata->is_block_face) + { + /* block-face but not a block-corner */ + fclaw_patch_3d_transform_face (tdata->this_patch, + tdata->neighbor_patch, tdata->transform, + mx, my, mz, + tdata->based, i2, j2, k2); + } + else + { + fclaw_patch_3d_transform_edge (tdata->this_patch, + tdata->neighbor_patch, + tdata->iedge, + tdata->is_block_edge, + mx, my, mz, + tdata->based, i2, j2, k2); + + } +} +void +FCLAW3D_CLAWPATCH_TRANSFORM_CORNER (const int *i1, const int *j1, const int *k1, + int *i2, int *j2, int *k2, + fclaw_patch_transform_data_t** ptdata) +{ + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + + *i2 = *i1; + *j2 = *j1; + *k2 = *k1; + if (tdata->is_block_face) + { + /* block-face but not a block-corner */ + fclaw_patch_3d_transform_face (tdata->this_patch, + tdata->neighbor_patch, tdata->transform, + mx, my, mz, + tdata->based, i2, j2, k2); + } + else if (tdata->is_block_edge) + { + fclaw_patch_3d_transform_edge (tdata->this_patch, + tdata->neighbor_patch, + tdata->block_iedge, + tdata->is_block_edge, + mx, my, mz, + tdata->based, i2, j2, k2); + + } + else + { + /* Corner within a block or a block-block corner. For block-block + * corners, we assume both patches lie in coordinate systems with the + * same orientation. */ + FCLAW_ASSERT (tdata->block_iface == -1); + fclaw_patch_3d_transform_corner (tdata->this_patch, + tdata->neighbor_patch, + tdata->icorner, tdata->is_block_corner, + mx, my, mz, + tdata->based, i2, j2, k2); + } +} + +void +FCLAW3D_CLAWPATCH_TRANSFORM_CORNER_HALF (const int *i1, const int *j1, const int* k1, + int *i2, int *j2, int *k2, + fclaw_patch_transform_data_t** ptdata) +{ + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + + i2[0] = *i1; + j2[0] = *j1; + k2[0] = *k1; + if (tdata->is_block_face) + { + /* block-face but not a block-corner. */ + fclaw_patch_3d_transform_face2 (tdata->this_patch, + tdata->neighbor_patch, + tdata->transform, + mx, my, mz, + tdata->based, i2, j2, k2); + } + else if (tdata->is_block_edge) + { + fclaw_patch_3d_transform_edge2 (tdata->this_patch, + tdata->neighbor_patch, + tdata->block_iedge, + tdata->is_block_edge, + mx, my, mz, + tdata->based, i2, j2, k2); + + } + else + { + /* Corner within a block or a block-block corner. For block-block + * corners, we assume both patches lie in coordinate systems with the + * same orientation. */ + FCLAW_ASSERT (tdata->block_iface == -1); + fclaw_patch_3d_transform_corner2 (tdata->this_patch, + tdata->neighbor_patch, + tdata->icorner, tdata->is_block_corner, + mx, my, mz, + tdata->based, i2, j2, k2); + } +} + +void +FCLAW3D_CLAWPATCH_TRANSFORM_EDGE_HALF (const int *i1, const int *j1, const int* k1, + int *i2, int *j2, int *k2, + fclaw_patch_transform_data_t** ptdata) +{ + fclaw_patch_transform_data_t *tdata = *ptdata; + const fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) tdata->user; + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + + *i2 = *i1; + *j2 = *j1; + *k2 = *k1; + if (tdata->is_block_face) + { + fclaw_patch_3d_transform_face2 (tdata->this_patch, + tdata->neighbor_patch, tdata->transform, + mx, my, mz, + tdata->based, i2, j2, k2); + } + else + { + fclaw_patch_3d_transform_edge2 (tdata->this_patch, + tdata->neighbor_patch, + tdata->iedge, + tdata->is_block_edge, + mx, my, mz, + tdata->based, i2, j2, k2); + + } +} diff --git a/src/patches/clawpatch/fclaw3d_clawpatch_transform.h b/src/patches/clawpatch/fclaw3d_clawpatch_transform.h new file mode 100644 index 000000000..0fed05919 --- /dev/null +++ b/src/patches/clawpatch/fclaw3d_clawpatch_transform.h @@ -0,0 +1,169 @@ +/* +Copyright (c) 2012 Carsten Burstedde, Donna Calhoun +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef FCLAW3D_CLAWPATCH_TRANSFORM_H +#define FCLAW3D_CLAWPATCH_TRANSFORM_H + +/** + * @file + * Transforms clawpatch indexes + */ + +#include /* Defines FCLAW_F77_FUNC */ + + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} /* need this because indent is dumb */ +#endif +#endif + +struct fclaw_global; +struct fclaw_patch; /* fclaw2d_patch.h includes this file */ +/** Struture to store a patch's transform data */ +struct fclaw_patch_transform_data; + +/** + * @brief Initialize the patch's tranform data + * + * @param[in] glob the global context + * @param[in] this_patch the patch context + * @param[in] blockno the block number + * @param[in] patchno the patch number + * @param[in,out] transform the transform data + */ +void fclaw3d_clawpatch_transform_init_data(struct fclaw_global* glob, + struct fclaw_patch* this_patch, + int blockno, int patchno, + struct fclaw_patch_transform_data* transform); + +/** @copydoc fclaw2d_patch_face_transformation() */ +void fclaw3d_clawpatch_face_transformation (int faceno, int rfaceno, int ftransform[]); + +/** @copydoc fclaw2d_patch_face_transformation_intra() */ +void fclaw3d_clawpatch_face_transformation_intra (int ftransform[]); + + +/* ----------------------------- Called from Fortran ---------------------------------- */ + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH_TRANSFORM_FACE FCLAW_F77_FUNC_(fclaw3d_clawpatch_transform_face, \ + FCLAW3D_CLAWPATCH_TRANSFORM_FACE) +/** + * @brief Tranform an index for a face-neighboring patch's coordinate system + * + * @param[in] i1, j1, k1 the input index + * @param[out] i2, j2, k2 the transformed equivalent index in the neighboring patch + * @param[in] ptdata the transform data + */ +void FCLAW3D_CLAWPATCH_TRANSFORM_FACE (const int *i1, const int *j1, const int *k1, + int *i2, int *j2, int *k2, + struct fclaw_patch_transform_data** ptdata); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH_TRANSFORM_FACE_HALF FCLAW_F77_FUNC_(fclaw3d_clawpatch_transform_face_half, \ + FCLAW3D_CLAWPATCH_TRANSFORM_FACE_HALF) +/** + * @brief Tranform an index for a face-neighboring finer patch's coordinate system + * + * @param[in] i1, j1, k1 the input index + * @param[out] i2, j2, k2 the eight equivalent indexes in the finer patch + * @param[in] ptdata the transform data + */ +void FCLAW3D_CLAWPATCH_TRANSFORM_FACE_HALF (const int *i1, const int *j1, const int *k1, + int i2[], int j2[], int k2[], + struct fclaw_patch_transform_data** ptdata); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH_TRANSFORM_EDGE FCLAW_F77_FUNC_(fclaw3d_clawpatch_transform_edge, \ + FCLAW3D_CLAWPATCH_TRANSFORM_EDGE) +/** + * @brief Tranform an index for a edge-neighboring patch's coordinate system + * + * @param[in] i1, j1, k1 the input index + * @param[out] i2, j2, k2 the transformed equivalent index in the neighboring patch + * @param[in] ptdata the transform data + */ +void FCLAW3D_CLAWPATCH_TRANSFORM_EDGE (const int *i1, const int *j1, const int *k1, + int *i2, int *j2, int *k2, + struct fclaw_patch_transform_data** ptdata); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH_TRANSFORM_EDGE_HALF FCLAW_F77_FUNC_(fclaw3d_clawpatch_transform_edge_half, \ + FCLAW3D_CLAWPATCH_TRANSFORM_EDGE_HALF) + +/** + * @brief Tranform an index for a edge-neighboring finer patch's coordinate system + * + * @param[in] i1, j1, k1 the input index + * @param[out] i2, j2, k2 the 8 transformed equivalent index in the neighboring patch + * @param[in] ptdata the transform data + */ +void FCLAW3D_CLAWPATCH_TRANSFORM_EDGE_HALF (const int *i1, const int *j1, const int *k1, + int *i2, int *j2, int *k2, + struct fclaw_patch_transform_data** ptdata); + + + + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH_TRANSFORM_CORNER FCLAW_F77_FUNC_(fclaw3d_clawpatch_transform_corner, \ + FCLAW3D_CLAWPATCH_TRANSFORM_CORNER) +/** + * @brief Tranform an index for a face-neighboring patch's coordinate system + * + * @param[in] i1, j1, k1 the input index + * @param[out] i2, j2, k2 the transformed equivalent index in the neighboring patch + * @param[in] ptdata the transform data + */ +void FCLAW3D_CLAWPATCH_TRANSFORM_CORNER (const int *i1, const int *j1, const int* k1, + int *i2, int *j2, int* k2, + struct fclaw_patch_transform_data** ptdata); + +/** Fortran subroutine name */ +#define FCLAW3D_CLAWPATCH_TRANSFORM_CORNER_HALF FCLAW_F77_FUNC_(fclaw3d_clawpatch_transform_corner_half, \ + FCLAW3D_CLAWPATCH_TRANSFORM_CORNER_HALF) + +/** + * @brief Tranform an index for a corner-neighboring finer patch's coordinate system + * + * @param[in] i1, j1, k1 the input index + * @param[out] i2, j2, k2 the four equivalent indexes in the finer patch + * @param[in] ptdata the transform data + */ +void FCLAW3D_CLAWPATCH_TRANSFORM_CORNER_HALF (const int *i1, const int *j1, const int *k1, + int i2[], int j2[], int k2[], + struct fclaw_patch_transform_data** ptdata); + +#ifdef __cplusplus +#if 0 +{ /* need this because indent is dumb */ +#endif +} +#endif + +#endif /* !FCLAW3DX_CLAWPATCH_TRANSFORM_H */ diff --git a/src/patches/clawpatch/fclaw3d_clawpatch_utils.f90 b/src/patches/clawpatch/fclaw3d_clawpatch_utils.f90 new file mode 100644 index 000000000..956ebdb15 --- /dev/null +++ b/src/patches/clawpatch/fclaw3d_clawpatch_utils.f90 @@ -0,0 +1,272 @@ +!> @file +!> Clawpatch utilities module + +module fclaw3d_clawpatch_utils +implicit none +contains + ! --------------------------------------------------------------- + !> @brief Determines the tranformation from a coarse patch to it's + !> half-sized neighbor's coordinate system + !> + !> @param[in] the pointer to the fclaw2d_patch_transform_data struct + !> @param[out] a the 2x2 tranform matrix for the i,j indexes of a patch + !> @param[out] f the transform vector + ! --------------------------------------------------------------- + subroutine build_transform(transform_ptr,a,f) + implicit none + + integer :: a(3,3) + integer*8 :: transform_ptr + integer :: f(3) + integer :: mi(8),mj(8),mk(8) + integer :: i1,j1,k1 + + ! # Assume index mapping fclaw2d_transform_face_half has the + ! # the form + ! # + ! # T(ic,jc) = A*(ic,jc) + F = (iff,jff) + ! # + ! # where (ic,jc) is the coarse grid index, and (iff,jff) + ! # is the first fine grid index. + ! # + ! # We can recover coefficients A(2,2) with the following + ! # calls to T. + + i1 = 0 + j1 = 0 + k1 = 0 + call fclaw3d_clawpatch_transform_face_half(i1,j1,k1,mi,mj,mk,transform_ptr) + f(1) = mi(1) + f(2) = mj(1) + f(3) = mk(1) + + i1 = 1 + j1 = 0 + k1 = 0 + call fclaw3d_clawpatch_transform_face_half(i1,j1,k1,mi,mj,mk,transform_ptr) + a(1,1) = mi(1) - f(1) + a(2,1) = mj(1) - f(2) + a(3,1) = mk(1) - f(3) + + i1 = 0 + j1 = 1 + k1 = 0 + call fclaw3d_clawpatch_transform_face_half(i1,j1,k1,mi,mj,mk,transform_ptr) + a(1,2) = mi(1) - f(1) + a(2,2) = mj(1) - f(2) + a(3,2) = mk(1) - f(3) + + i1 = 0 + j1 = 0 + k1 = 1 + call fclaw3d_clawpatch_transform_face_half(i1,j1,k1,mi,mj,mk,transform_ptr) + a(1,3) = mi(1) - f(1) + a(2,3) = mj(1) - f(2) + a(3,3) = mk(1) - f(3) + + end + + subroutine fclaw3d_clawpatch_build_transform_same(transform_ptr,a,f) + implicit none + + integer a(2,2) + integer*8 transform_ptr + integer f(2) + integer mi(4),mj(4) + integer i1,j1 + + i1 = 0 + j1 = 0 + call fclaw3d_clawpatch_transform_face(i1,j1,mi,mj,transform_ptr) + f(1) = mi(1) + f(2) = mj(1) + + i1 = 1 + j1 = 0 + call fclaw3d_clawpatch_transform_face(i1,j1,mi,mj,transform_ptr) + a(1,1) = mi(1) - f(1) + a(2,1) = mj(1) - f(2) + + i1 = 0 + j1 = 1 + call fclaw3d_clawpatch_transform_face(i1,j1,mi,mj,transform_ptr) + a(1,2) = mi(1) - f(1) + a(2,2) = mj(1) - f(2) + + end + ! -------------------------------------------------------------------- + !> @brief checks if the index is valid for averaging + !> + !> @param[in] i, j, k the idnex to check + !> @param[in] mx, my, mz the number of cells in the x, y, z directions + !> @return true if the index is valid + ! -------------------------------------------------------------------- + logical function is_valid_average(i,j,k,mx,my,mz) + implicit none + + integer :: i,j,k,mx,my,mz + logical :: i1, j1, k1 + + i1 = 1 .le. i .and. i .le. mx + j1 = 1 .le. j .and. j .le. my + k1 = 1 .le. k .and. k .le. mz + + is_valid_average = i1 .and. j1 .and. k1 + + end function is_valid_average + + logical function is_valid_interp(i,j,k,mx,my,mz,mbc) + implicit none + + integer i,j,k,mx,my,mz,mbc + logical i1, j1, k1 + + i1 = 1-mbc .le. i .and. i .le. mx+mbc + j1 = 1-mbc .le. j .and. j .le. my+mbc + k1 = 1-mbc .le. k .and. k .le. mz+mbc + + is_valid_interp = i1 .and. j1 .and. k1 + + end function is_valid_interp + + subroutine interior_face_bounds( & + iface,refratio,mx,my,mz,mbc, & + i_start, j_start, k_start, & + i_end, j_end, k_end) + implicit none + integer mx, my, mz, mbc, iface + integer i_start, j_start, k_start + integer i_end, j_end, k_end + integer axis, refratio, cmbc + logical upper + + axis = iface/2 + upper= btest(iface,0) + + cmbc = mbc/refratio + + if (axis .eq. 0) then + if (upper) then + i_start = mx-cmbc+1 + i_end = mx + else + i_start = 1 + i_end = cmbc + endif + j_start = 1 + j_end = my + k_start = 1 + k_end = mz + else if(axis .eq. 1) then + i_start = 1 + i_end = mx + if (upper) then + j_start = my-cmbc+1 + j_end = my + else + j_start = 1 + j_end = cmbc + endif + k_start = 1 + k_end = mz + else if(axis .eq. 2) then + i_start = 1 + i_end = mx + j_start = 1 + j_end = my + if (upper) then + k_start = mz-cmbc+1 + k_end = mz + else + k_start = 1 + k_end = cmbc + endif + endif + end subroutine interior_face_bounds + + subroutine interior_edge_bounds( & + iedge,refratio,mx,my,mz,mbc, & + i_start, j_start, k_start, & + i_end, j_end, k_end) + implicit none + integer mx, my, mz, mbc, iedge, refratio + integer i_start, j_start, k_start + integer i_end, j_end, k_end + integer axis, cmbc + logical upper_1, upper_2 + + axis = iedge/4; + upper_1 = btest(iedge,0); + upper_2 = btest(iedge,1); + + cmbc = mbc/refratio + + + if (axis .eq. 0) then + + i_start = 1; + i_end = mx; + + if(upper_1) then + j_start = my-cmbc+1; + j_end = my; + else + j_start = 1 + j_end = cmbc; + endif + + if(upper_2) then + k_start = mz-cmbc+1; + k_end = mz; + else + k_start = 1 + k_end = cmbc; + endif + + else if(axis .eq. 1) then + + if(upper_1) then + i_start = mx-cmbc+1; + i_end = mx; + else + i_start = 1; + i_end = cmbc; + endif + + j_start = 1; + j_end = my; + + if(upper_2) then + k_start = mz-cmbc+1; + k_end = mz; + else + k_start = 1; + k_end = cmbc; + endif + + else if(axis .eq. 2) then + + if(upper_1) then + i_start = mx-cmbc+1; + i_end = mx; + else + i_start = 1; + i_end = cmbc; + endif + + if(upper_2) then + j_start = my-cmbc+1; + j_end = my; + else + j_start = 1; + j_end = cmbc; + endif + + k_start = 1; + k_end = mz; + + endif + end subroutine interior_edge_bounds + + +end module fclaw3d_clawpatch_utils \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch.cpp b/src/patches/clawpatch/fclaw3dx_clawpatch.cpp deleted file mode 100644 index 179bb78c7..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define REFINE_DIM 2 -#define PATCH_DIM 3 - -#include \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch.h b/src/patches/clawpatch/fclaw3dx_clawpatch.h deleted file mode 100644 index 50f80d1ef..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch.h +++ /dev/null @@ -1,604 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3DX_CLAWPATCH_H -#define FCLAW3DX_CLAWPATCH_H - -#include /* Needed to get correction def. of PATCHDIM */ - -#include /* Need patch callback def */ - -#include -#include -#include - - -#ifdef __cplusplus -extern "C" -{ -#endif - -#if 0 -/* Fix syntax highlighting */ -#endif - -/** - * @file - * Clawpatch related structures and routines - */ - - -/** - * @brief fclaw3dx_clawpatch_vtable type - */ -typedef struct fclaw3dx_clawpatch_vtable fclaw3dx_clawpatch_vtable_t; - - -/* --------------------------------- Typedefs ----------------------------------------- */ -/** - * @brief Sets a pointer to user data for a specific patch - * - * @param[in] glob the global context - * @param[in] patch the patch context - * @param[in] user the pointer to the user data - */ -typedef void (*fclaw3dx_clawpatch_set_user_data_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - void* user); - -/** - * @brief Packs/Unpacks the fclaw3dx_clawpatch_registers struct for ghost patches - * - * @param[in] glob the global context - * @param[in] patch the patch context - * @param[in,out] qpack the buffer - * @param[in] frsize the size of the buffer - * @param[in] packmode enum fclaw3dx_clawpatch_packmode enum - * @param[out] ierror error value - */ -typedef void (*fclaw3dx_clawpatch_time_sync_pack_registers_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - double *qpack, - int frsize, - fclaw_clawpatch_packmode_t packmode, - int *ierror); - - -/** - * @brief Packs/Unpacks ghost cell data for an aux array - * - * @param[in] glob the global context - * @param[in] patch the patch context - * @param[in] mint the number of internal cells to pack - * @param[in,out] qpack the the buffer - * @param[in] extrasize the size of the buffer - * @param[in] packmode the packing mode (0 for packing aux, 1 for unpacking aux) - * @param[out] ierror error value - */ -typedef void (*fclaw3dx_clawpatch_local_ghost_pack_aux_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - const int mint, - double qpack[], - int extrasize, - int packmode, - int* ierror); - -/** - * @brief Packs/Unpacks the fclaw3dx_clawpatch_registers struct for ghost patches - * - * @param[in] glob the global context - * @param[in] patch the patch context - * @param[in,out] qpack the buffer - * @param[in] the size of the buffer - * @param[out] ierror error value - */ -typedef void (*fclaw3dx_clawpatch_fort_local_ghost_pack_registers_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - double qpack[], - int frsize, - int* ierror); -/* ------------------------------ typedefs - output ----------------------------------- */ - -/** - * @brief Outputs a time header - * - * @param[in] glob the global context - * @param[in] iframe the frame - */ -typedef void (*fclaw3dx_clawpatch_time_header_t)(struct fclaw2d_global* glob, int iframe); - - -/* ---------------------------- typedefs - diagnostics -------------------------------- */ - -/** - * @brief Fills in a user defined error_data structure for a specific patch. - * - * @param[in] glob glob the global context - * @param[in] patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in,out] error_data a user defined structure - * - */ -typedef void (*fclaw3dx_clawpatch_diagnostics_cons_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - int blockno, - int patchno, - void *error_data); - -/** - * @brief Fills in a user defined error_data structure for a specific patch. - * - * @param[in] glob glob the global context - * @param[in] patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in,out] error_data a user defined structure - * - */ -typedef void (*fclaw3dx_clawpatch_diagnostics_error_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - int blockno, - int patchno, - void *error_data); - - -/* ---------------------------- Virtual table ------------------------------------ */ -/* members of this structure provide the only access to above functions */ - -/** - * @brief Initialize the clawpatch vtable global variable - * - * @param claw_version the version of clawpack (4 for 4.6, 5 for 5) - */ -void fclaw3dx_clawpatch_vtable_initialize(struct fclaw2d_global *glob, int claw_version); - -/** - * @brief Get a pointer to a clawpatch vtable global variable - * - * @return fclaw3dx_clawpatch_vtable_t* the vtable - */ -fclaw3dx_clawpatch_vtable_t* fclaw3dx_clawpatch_vt(struct fclaw2d_global *glob); - -/** - * @brief vtable for clawpatch related functions - */ -struct fclaw3dx_clawpatch_vtable -{ - /** - * @brief Function that allows the user to set a user data pointer - */ - fclaw3dx_clawpatch_set_user_data_t set_user_data; - - /** @{ @name Ghost Filling Functions */ - - /** Copies ghost data from a face neighboring grid on the same level */ - fclaw3dx_clawpatch_fort_copy_face_t fort_copy_face; - /** Averages values from a face neighboring fine grid */ - fclaw3dx_clawpatch_fort_average_face_t fort_average_face; - /** Interpolates values form a face neighboring coarse grid */ - fclaw3dx_clawpatch_fort_interpolate_face_t fort_interpolate_face; - /** Copies ghost data from a corner neighboring grid on the same level */ - fclaw3dx_clawpatch_fort_copy_corner_t fort_copy_corner; - /** Averages values from a corner neighboring fine grid */ - fclaw3dx_clawpatch_fort_average_corner_t fort_average_corner; - /** Interpolates values form a corner neighboring coarse grid */ - fclaw3dx_clawpatch_fort_interpolate_corner_t fort_interpolate_corner; - - /** @} */ - - /** @{ @name Regridding Functions */ - - /** Tags a patch for refinement. */ - fclaw3dx_clawpatch_fort_tag4refinement_t fort_tag4refinement; - /** Tags a quad of patches for coarsening. */ - fclaw3dx_clawpatch_fort_tag4coarsening_t fort_tag4coarsening; - /** @deprecated Checks if solution exceeds a threshold */ - fclaw3dx_clawpatch_fort_exceeds_threshold_t fort_user_exceeds_threshold; - - /** Averages a fine patches to a coarse patch */ - fclaw3dx_clawpatch_fort_average2coarse_t fort_average2coarse; - /** Interpolates from a coarse patch to a fine patche */ - fclaw3dx_clawpatch_fort_interpolate2fine_t fort_interpolate2fine; - - /** @} */ - - /** @{ @name Conservation Update */ - - /** Adds fine grid corrections to coarse grid. */ - fclaw3dx_clawpatch_fort_time_sync_f2c_t fort_time_sync_f2c; - /** Adds wave corrections at same level interfaces. */ - fclaw3dx_clawpatch_fort_time_sync_samesize_t fort_time_sync_samesize; - /** Packs/Unpacks the fclaw3dx_clawpatch_registers struct for ghost patches */ - fclaw3dx_clawpatch_time_sync_pack_registers_t time_sync_pack_registers; - - /** @} */ - - /** @{ @name Output Functions (ascii) */ - - /** Outputs a time header */ - fclaw3dx_clawpatch_time_header_t time_header_ascii; - /** Outputs a time header */ - fclaw3dx_clawpatch_fort_header_ascii_t fort_header_ascii; - - /** Called for every patch when outputing ascii */ - fclaw2d_patch_callback_t cb_output_ascii; - /** Outputs patch data in ascii */ - fclaw3dx_clawpatch_fort_output_ascii_t fort_output_ascii; - - /** @} */ - - /** @{ @name Time interpolation functions */ - - /** Interpolates q between timesteps */ - fclaw3dx_clawpatch_fort_timeinterp_t fort_timeinterp; - - /** @} */ - - /** @{ @name Ghost Patch Functions */ - - /** Packs/Unpacks ghost cell data */ - fclaw3dx_clawpatch_fort_local_ghost_pack_t fort_local_ghost_pack; - /** Packs/Unpacks ghost cell data for an aux array */ - fclaw3dx_clawpatch_local_ghost_pack_aux_t local_ghost_pack_aux; - - /** @} */ - - /** @{ @name Diagnostic Functions */ - - /** Fills in a user defined error_data structure for a specific patch. */ - fclaw3dx_clawpatch_diagnostics_cons_t conservation_check; - /** Fills in a user defined error_data structure for a specific patch. */ - fclaw3dx_clawpatch_diagnostics_error_t compute_error; - - /** Calculates the error for cells in a patch */ - fclaw3dx_clawpatch_fort_error_t fort_compute_patch_error; - /** Calculates a sum for each equation */ - fclaw3dx_clawpatch_fort_conscheck_t fort_conservation_check; - /** Calculates the error norms for a patch */ - fclaw3dx_clawpatch_fort_norm_t fort_compute_error_norm; - /** Calculates the area of a patch */ - fclaw3dx_clawpatch_fort_area_t fort_compute_patch_area; - - /** @} */ - - /** @{ @name Diagnostics */ - - /** Whether or not this vtable is set */ - int is_set; - - /** @} */ -}; - - -/* -------------------------------- time stepping ----------------------------------- */ - -/* Called in step2 (clawpack 4.6 and clawpack 5.0) */ - -/** - * @brief Save the current timestep - * - * @param[in] glob glob the global context - * @param[in] patch the patch context - */ -void fclaw3dx_clawpatch_save_current_step(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - - -/* ------------------------------- Misc access functions ------------------------------ */ - -/** - * @brief Get the grid data for a specific patch - * - * @param[in] glob glob the global context - * @param[in] patch the patch context - * @param[out] mx, my, mz the number of cells in the x, y, and z directions - * @param[out] mbc the number of ghost cells - * @param[out] xlower, ylower, zlower the lower bottom left coordinate of the patch - * @param[out] dx, dy, dz the spacings in the x, y, and z directions - */ -void fclaw3dx_clawpatch_grid_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int* mx, - int* my, - int* mz, - int* mbc, - double* xlower, - double* ylower, - double* zlower, - double* dx, - double* dy, - double* dz); - - -void fclaw3d_clawpatch_grid_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int* mx, - int* my, - int* mz, - int* mbc, - double* xlower, - double* ylower, - double* zlower, - double* dx, - double* dy, - double* dz); - - -/** - * @brief Get the area for each cell of the patch - * - * @param this_patch the patch to get the are for - * @return double* the area array - */ -double* fclaw3d_clawpatch_get_volume(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch); - -/** - * @brief Get the scalar metrics of a patch - * - * @param[in] glob glob the global context - * @param[in] patch the patch context - * @param[out] area the area of each cell in the patch - * @param[out] edgelengths the edge lenghts for each cell. - * An array of dimension (-mbc:mx+mbc+2,-mbc:my+mbc+2,2). - * (i,j,1) contains the the bottom edge length for cell (i,j). - * (i,j,2) contains the the left edge length for cell (i,j). - * @param[out] curvature the curvature for each cell in the patch - */ -void fclaw3d_clawpatch_metric_scalar(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **volume, - double **faceareas); - -/** - * @brief Get the vector metrics of a patch - * - * @param[in] glob glob the global context - * @param[in] patch the patch context - * @param[out] xnormals, ynormals the normals of each face of the patch - * Arrays of dimension (-mbc:mx+mbc+2,-mbc:my+mbc+2,2). - * (i,j,1) contains the normal for the bottom edge of cell (i,j). - * (i,j,2) contains the normal for the left edge of cell (i,j). - * @param[out] xtangents, ytangents the tangents of each face of the patch - * Arrays of dimension (-mbc:mx+mbc+2,-mbc:my+mbc+2,2). - * (i,j,1) contains the tangent for the bottom edge of cell (i,j). - * (i,j,2) contains the tangent for the left edge of cell (i,j). - * @param[out] surfnormals the surface normal for each cell center of the patch - * An array of dimension(-mbc:mx+mbc+1,-mbc:my+mbc+1,3) - */ -void fclaw3d_clawpatch_metric_basis(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **xrot, - double **yrot, - double **zrot); - -/** - * @brief Get the mesh metrics of a patch - * - * @param[in] glob glob the global context - * @param[in] patch the patch context - * @param[out] xp, yp, zp the coordinates of the cell centers - * @param[out] xd, yd, zd the coordinates of the nodes - * @param[out] area the area of each cell - */ -void fclaw3d_clawpatch_mesh_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **xp, - double **yp, - double **zp, - double **xd, - double **yd, - double **zd, - double **volume, - double **faceareas); - -/** - * @brief Get the solution data for a patch - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[out] q the solution array - * @param[out] meqn the number of equations - */ -void fclaw3dx_clawpatch_soln_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **q, - int* meqn); -/** - * @brief Get the aux data for a patch - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[out] aux the aux array - * @param[out] maux the number of equations - */ -void fclaw3dx_clawpatch_aux_data(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - double **aux, - int* maux); - -/** - * @brief Get the rhs data for a patch - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[out] rhs the rhs array - * @param[out] mfields the number fields - */ -void fclaw3dx_clawpatch_rhs_data(struct fclaw2d_global* glob, - fclaw2d_patch_t* patch, - double **rhs, - int *mfields); -/** - * @brief Get the error data for elliptic problems - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[out] err the error array - * @param[out] mfields the number fields - */ -void fclaw3dx_clawpatch_elliptic_error_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **err, - int *mfields); -/** - * @brief Get the solution data for elliptic problems - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[out] soln the solution array - * @param[out] mfields the number fields - */ -void fclaw3dx_clawpatch_elliptic_soln_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **soln, - int *mfields); - -/** - * @brief Get the solution data for a patch - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @return double* the solution array - */ -double* fclaw3dx_clawpatch_get_q(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - -/** - * @brief Get the error data for a patch - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @return double* the error array - */ -double* fclaw3dx_clawpatch_get_error(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - -/** - * @brief Get the exact solution data for a patch - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @return double* the exact solution array - */ -double* fclaw3dx_clawpatch_get_exactsoln(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - -/** - * @brief Get the size of a solution array for a patch - * - * @param glob the global context - * @return size_t the size - */ -size_t fclaw3dx_clawpatch_size(struct fclaw2d_global *glob); - - -/** - * @brief Get the user data pointer for a patch - * - * @param glob the global context - * @param patch the patch context - * @return void* the pointer - */ -void* fclaw3dx_clawpatch_get_user_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - -/** - * @brief Set the user data pointer for a patch - * - * @param glob the global context - * @param patch the patch context - * @param udata the user data pointer - */ -void fclaw3dx_clawpatch_set_user_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - void* udata); -/** - * @brief Get the solver data pointer for a patch - * - * @param glob the global context - * @param patch the patch context - * @return void* the pointer - */ -void* fclaw3dx_clawpatch_get_solver_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - -/** - * @brief Set the solver data pointer for a patch - * - * @param glob the global context - * @param patch the patch context - * @param sdata the solver data pointer - */ -void fclaw3dx_clawpatch_set_solver_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - void* sdata); - - -/* These should be renamed to time_interp data */ - -/** - * @brief Get an interpolated solution - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] time_interp true if interpolated grid data should be returned - * @param[out] q the interpolated solution - * @param[out] meqn the number of equations - */ -void fclaw3dx_clawpatch_timesync_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int time_interp, - double **q, - int* meqn); - -/** - * @brief Get an interpolated solution - * - * @param glob the global context - * @param this_patch the patch context - * @param time_interp true if interpolated grid data should be returned - * @return the interpolated solution - */ -double* fclaw3dx_clawpatch_get_q_timesync(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int time_interp); -/** - * @brief Get the registers for a patch - * - * @param glob the global context - * @param patch the patch context - * @return the registers - */ -struct fclaw3dx_clawpatch_registers* -fclaw3dx_clawpatch_get_registers(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); - -#ifdef __cplusplus -} -#endif - -#endif /* !FCLAW2D_CLAWPATCH_H */ diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch.h.TEST.cpp b/src/patches/clawpatch/fclaw3dx_clawpatch.h.TEST.cpp deleted file mode 100644 index 11e85b423..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch.h.TEST.cpp +++ /dev/null @@ -1,1030 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define CHECK_BOX_DIMENSIONS(abox, mbc, mx, my, mz, mfields)\ -{\ - CHECK(abox.fields() == mfields);\ - CHECK(abox.box().boxDim() == 3);\ - CHECK(abox.box().smallEnd(0) == 1-mbc);\ - CHECK(abox.box().smallEnd(1) == 1-mbc);\ - CHECK(abox.box().smallEnd(2) == 1-mbc);\ - CHECK(abox.box().bigEnd(0) == mx+mbc);\ - CHECK(abox.box().bigEnd(1) == my+mbc);\ - CHECK(abox.box().bigEnd(2) == mz+mbc);\ -} -#define CHECK_BOX_EMPTY(abox)\ -{\ - CHECK(abox.fields() == 0);\ - CHECK(abox.box().boxDim() == 0);\ -} - -namespace{ -struct SinglePatchDomain { - fclaw2d_global_t* glob; - fclaw_options_t fopts; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t* map; - fclaw3dx_clawpatch_options_t opts; - - SinglePatchDomain(){ - int rank; - int size; - sc_MPI_Comm_rank(sc_MPI_COMM_WORLD, &rank); - sc_MPI_Comm_size(sc_MPI_COMM_WORLD, &size); - glob = fclaw2d_global_new_comm(sc_MPI_COMM_WORLD, rank, size); - - fclaw2d_vtables_initialize(glob); - fclaw3dx_clawpatch_vtable_initialize(glob, 4); - memset(&fopts, 0, sizeof(fopts)); - fopts.mi=1; - fopts.mj=1; - fopts.minlevel=0; - fopts.manifold=false; - fopts.bx = 1; - fopts.by = 2; - fopts.bz = 3; - fopts.compute_error = true; - fopts.subcycle = true; - - domain = fclaw2d_domain_new_unitsquare(glob->mpicomm, fopts.minlevel); - map = fclaw2d_map_new_nomap(); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, map); - - fclaw2d_options_store(glob, &fopts); - - memset(&opts, 0, sizeof(opts)); - opts.mx = 5; - opts.my = 6; - opts.mz = 7; - opts.mbc = 2; - opts.meqn = 1; - opts.maux = 1; - opts.rhs_fields = 1; - fclaw3dx_clawpatch_options_store(glob, &opts); - - fclaw2d_domain_data_new(glob->domain); - } - void setup(){ - fclaw2d_build_mode_t build_mode = FCLAW2D_BUILD_FOR_UPDATE; - fclaw2d_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); - } - ~SinglePatchDomain(){ - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[0]); - fclaw2d_global_destroy(glob); - } -}; -struct QuadDomain { - fclaw2d_global_t* glob; - fclaw_options_t fopts; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t* map; - fclaw3dx_clawpatch_options_t opts; - - QuadDomain(){ - int rank; - int size; - sc_MPI_Comm_rank(sc_MPI_COMM_WORLD, &rank); - sc_MPI_Comm_size(sc_MPI_COMM_WORLD, &size); - glob = fclaw2d_global_new_comm(sc_MPI_COMM_WORLD, rank, size); - fclaw2d_vtables_initialize(glob); - fclaw3dx_clawpatch_vtable_initialize(glob, 4); - memset(&fopts, 0, sizeof(fopts)); - fopts.mi=1; - fopts.mj=1; - fopts.minlevel=1; - fopts.maxlevel=1; - fopts.manifold=false; - fopts.bx = 1; - fopts.by = 2; - fopts.bz = 3; - fopts.compute_error = true; - fopts.subcycle = true; - - domain = fclaw2d_domain_new_unitsquare(glob->mpicomm, fopts.minlevel); - map = fclaw2d_map_new_nomap(); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, map); - - fclaw2d_options_store(glob, &fopts); - - memset(&opts, 0, sizeof(opts)); - opts.mx = 5; - opts.my = 6; - opts.mz = 7; - opts.mbc = 2; - opts.meqn = 1; - opts.maux = 1; - opts.rhs_fields = 1; - fclaw3dx_clawpatch_options_store(glob, &opts); - - fclaw2d_domain_data_new(glob->domain); - } - void setup(){ - fclaw2d_build_mode_t build_mode = FCLAW2D_BUILD_FOR_UPDATE; - fclaw2d_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); - fclaw2d_patch_build(glob, &domain->blocks[0].patches[1], 0, 1, &build_mode); - fclaw2d_patch_build(glob, &domain->blocks[0].patches[2], 0, 2, &build_mode); - fclaw2d_patch_build(glob, &domain->blocks[0].patches[3], 0, 3, &build_mode); - } - ~QuadDomain(){ - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[0]); - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[1]); - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[2]); - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[3]); - fclaw2d_global_destroy(glob); - } -}; -} -TEST_CASE("fclaw3dx_clawpatch_vtable_initialize") -{ - fclaw2d_global_t* glob = fclaw2d_global_new(); - fclaw2d_vtables_initialize(glob); - - fclaw3dx_clawpatch_vtable_initialize(glob, 4); - - fclaw3dx_clawpatch_vtable_t * clawpatch_vt = fclaw3dx_clawpatch_vt(glob); - - CHECK(clawpatch_vt->set_user_data == NULL); - - //ghost filling - CHECK(clawpatch_vt->fort_copy_face == &FCLAW3DX_CLAWPATCH46_FORT_COPY_FACE); - CHECK(clawpatch_vt->fort_average_face == &FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE); - CHECK(clawpatch_vt->fort_interpolate_face == &FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE); - CHECK(clawpatch_vt->fort_copy_corner == &FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER); - CHECK(clawpatch_vt->fort_average_corner == &FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER); - CHECK(clawpatch_vt->fort_interpolate_corner == &FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER); - - //regridding - CHECK(clawpatch_vt->fort_tag4refinement == &FCLAW3DX_CLAWPATCH46_FORT_TAG4REFINEMENT); - CHECK(clawpatch_vt->fort_tag4coarsening == &FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING); - CHECK(clawpatch_vt->fort_user_exceeds_threshold == NULL); - CHECK(clawpatch_vt->fort_interpolate2fine == &FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE); - CHECK(clawpatch_vt->fort_average2coarse == &FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE); - - //ascii output - CHECK(clawpatch_vt->time_header_ascii == &fclaw3dx_clawpatch_time_header_ascii); - CHECK(clawpatch_vt->fort_header_ascii == &FCLAW3DX_CLAWPATCH46_FORT_HEADER_ASCII); - CHECK(clawpatch_vt->cb_output_ascii == &fclaw3dx_clawpatch_output_ascii_cb); - CHECK(clawpatch_vt->fort_output_ascii == &FCLAW3DX_CLAWPATCH46_FORT_OUTPUT_ASCII); - - //time interpolation - CHECK(clawpatch_vt->fort_timeinterp == &FCLAW3DX_CLAWPATCH46_FORT_TIMEINTERP); - - //ghot packing - CHECK(clawpatch_vt->fort_local_ghost_pack == &FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK); - CHECK(clawpatch_vt->local_ghost_pack_aux == NULL); - - //diagnostics - CHECK(clawpatch_vt->conservation_check == NULL); - CHECK(clawpatch_vt->compute_error == NULL); - CHECK(clawpatch_vt->fort_compute_patch_error == NULL); - CHECK(clawpatch_vt->fort_conservation_check == NULL); - CHECK(clawpatch_vt->fort_compute_error_norm == NULL); - CHECK(clawpatch_vt->fort_compute_patch_area == NULL); - - CHECK(clawpatch_vt->is_set == 1); - - fclaw2d_patch_vtable_t * patch_vt = fclaw2d_patch_vt(glob); - //create delete build - //TODO document patch_vt and expose these as part to public api - CHECK(patch_vt->patch_new != NULL); - CHECK(patch_vt->patch_delete != NULL); - CHECK(patch_vt->build != NULL); - CHECK(patch_vt->build_from_fine != NULL); - CHECK(patch_vt->setup == NULL); - fclaw2d_global_destroy(glob); -} -TEST_CASE("fclaw3dx_clawpatch patch_build") -{ - for(const int& compute_error : {0,1}) - for(const int& subcycle : {0,1}) - for(const int& mx : {4,5,6}) - for(const int& my : {4,5,6}) - for(const int& mz : {4,5,6}) - for(const int& mbc : {1,2}) - for(const int& meqn : {1,2}) - for(const int& maux : {0,2}) - for(const int& rhs_fields : {0,2}) - for(fclaw2d_build_mode_t build_mode : {FCLAW2D_BUILD_FOR_GHOST_AREA_COMPUTED, FCLAW2D_BUILD_FOR_UPDATE}) - { - int rank; - int size; - sc_MPI_Comm_rank(sc_MPI_COMM_WORLD, &rank); - sc_MPI_Comm_size(sc_MPI_COMM_WORLD, &size); - fclaw2d_global_t* glob = fclaw2d_global_new_comm(sc_MPI_COMM_WORLD, rank, size); - - fclaw2d_vtables_initialize(glob); - - fclaw3dx_clawpatch_vtable_initialize(glob, 4); - - fclaw_options_t fopts; - memset(&fopts, 0, sizeof(fopts)); - fopts.mi=1; - fopts.mj=1; - fopts.minlevel=0; - fopts.manifold=false; - fopts.bx = 1; - fopts.by = 2; - fopts.bz = 3; - fopts.compute_error = compute_error; - fopts.subcycle = subcycle; - - fclaw2d_domain_t *domain = fclaw2d_domain_new_unitsquare(glob->mpicomm, fopts.minlevel); - fclaw2d_map_context_t* map = fclaw2d_map_new_nomap(); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, map); - fclaw2d_options_store(glob, &fopts); - - fclaw3dx_clawpatch_options_t opts; - memset(&opts, 0, sizeof(opts)); - opts.mx = mx; - opts.my = my; - opts.mz = mz; - opts.mbc = mbc; - opts.meqn = meqn; - opts.maux = maux; - opts.rhs_fields = rhs_fields; - fclaw3dx_clawpatch_options_store(glob, &opts); - - fclaw2d_domain_data_new(glob->domain); - CHECK(domain->blocks[0].patches[0].user == nullptr); - fclaw2d_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); - CHECK(domain->blocks[0].patches[0].user != nullptr); - - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&domain->blocks[0].patches[0]); - - CHECK(cp->meqn == opts.meqn); - CHECK(cp->mx == opts.mx); - CHECK(cp->my == opts.my); - CHECK(cp->mz == opts.mz); - CHECK(cp->mbc == opts.mbc); - CHECK(cp->manifold == fopts.manifold); - CHECK(cp->mp != nullptr); - CHECK(cp->registers != nullptr); - - CHECK(cp->xlower == fopts.ax); - CHECK(cp->ylower == fopts.ay); - CHECK(cp->zlower == fopts.az); - CHECK(cp->xupper == fopts.bx); - CHECK(cp->yupper == fopts.by); - CHECK(cp->zupper == fopts.bz); - CHECK(cp->dx == doctest::Approx((cp->xupper-cp->xlower)/opts.mx)); - CHECK(cp->dy == doctest::Approx((cp->yupper-cp->ylower)/opts.my)); - CHECK(cp->dz == doctest::Approx((cp->zupper-cp->zlower)/opts.mz)); - - //BOX DIEMSIONS - - CHECK_BOX_DIMENSIONS(cp->griddata, opts.mbc, opts.mx, opts.my, opts.mz, opts.meqn); - if(build_mode == FCLAW2D_BUILD_FOR_UPDATE){ - CHECK_BOX_DIMENSIONS(cp->griddata_last, opts.mbc, opts.mx, opts.my, opts.mz, opts.meqn); - CHECK_BOX_DIMENSIONS(cp->griddata_save, opts.mbc, opts.mx, opts.my, opts.mz, opts.meqn); - }else{ - CHECK_BOX_EMPTY(cp->griddata_last); - CHECK_BOX_EMPTY(cp->griddata_save); - } - if(fopts.subcycle){ - CHECK_BOX_DIMENSIONS(cp->griddata_time_interpolated, opts.mbc, opts.mx, opts.my, opts.mz, opts.meqn); - }else{ - CHECK_BOX_EMPTY(cp->griddata_time_interpolated); - } - if(fopts.compute_error) { - CHECK_BOX_DIMENSIONS(cp->griderror, opts.mbc, opts.mx, opts.my, opts.mz, opts.meqn); - CHECK_BOX_DIMENSIONS(cp->exactsolution, opts.mbc, opts.mx, opts.my, opts.mz, opts.meqn); - }else{ - CHECK_BOX_EMPTY(cp->griderror); - CHECK_BOX_EMPTY(cp->exactsolution); - } - if(opts.rhs_fields == 0){ - CHECK_BOX_EMPTY(cp->rhs); - }else{ - CHECK_BOX_DIMENSIONS(cp->rhs, opts.mbc, opts.mx, opts.my, opts.mz, opts.rhs_fields); - } - if(opts.rhs_fields == 0 || !fopts.compute_error) { - CHECK_BOX_EMPTY(cp->elliptic_error); - CHECK_BOX_EMPTY(cp->elliptic_soln); - }else{ - CHECK_BOX_DIMENSIONS(cp->elliptic_error, opts.mbc, opts.mx, opts.my, opts.mz, opts.rhs_fields); - CHECK_BOX_DIMENSIONS(cp->elliptic_soln, opts.mbc, opts.mx, opts.my, opts.mz, opts.rhs_fields); - } - - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[0]); - fclaw2d_global_destroy(glob); - } -} - -TEST_CASE("fclaw3dx_clawpatch save_step") -{ - SinglePatchDomain test_data; - test_data.setup(); - - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - cp->griddata.dataPtr()[0] = 1234; - fclaw2d_patch_save_step(test_data.glob,&test_data.domain->blocks[0].patches[0]); - CHECK(cp->griddata_save.dataPtr()[0] == 1234); -} - -TEST_CASE("fclaw3dx_clawpatch_save_current_step") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - cp->griddata.dataPtr()[0] = 1234; - fclaw3dx_clawpatch_save_current_step(test_data.glob,&test_data.domain->blocks[0].patches[0]); - CHECK(cp->griddata_last.dataPtr()[0] == 1234); -} - -TEST_CASE("fclaw3dx_clawpatch restore_step") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - cp->griddata_save.dataPtr()[0] = 1234; - fclaw2d_patch_restore_step(test_data.glob,&test_data.domain->blocks[0].patches[0]); - CHECK(cp->griddata.dataPtr()[0] == 1234); -} - -#if 0 -TEST_CASE("fclaw3dx_clawpatch get_metric_patch") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - CHECK(fclaw3d_patch_metric_patch(test_data.glob, &test_data.domain->blocks[0].patches[0]) == cp->mp); -} -#endif - - -#if 0 -TEST_CASE("fclaw3dx_clawpatch_get_metric_patch") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = - fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - CHECK(fclaw3d_clawpatch_get_metric_patch(&test_data.domain->blocks[0].patches[0]) == cp->mp); -} -#endif - -#if 0 -TEST_CASE("fclaw3dx_clawpatch_get_volume") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3d_metric_patch_t* mp = fclaw3dx_clawpatch_get_metric_patch(&test_data.domain->blocks[0].patches[0]); - CHECK(fclaw3d_clawpatch_get_volume(test_data.glob, - &test_data.domain->blocks[0].patches[0]) == mp->volume.dataPtr()); -} -#endif - -TEST_CASE("fclaw3dx_clawpatch_grid_data") -{ - for(int mx : {4,5,6}) - for(int my : {4,5,6}) - for(int mz : {4,5,6}) - for(int mbc : {1,2}) - { - - SinglePatchDomain test_data; - test_data.opts.mx = mx; - test_data.opts.my = my; - test_data.opts.mz = mz; - test_data.opts.mbc = mbc; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - int mx_out,my_out,mz_out,mbc_out; - double xlower,ylower,zlower,dx,dy,dz; - fclaw3dx_clawpatch_grid_data(test_data.glob, &test_data.domain->blocks[0].patches[0], - &mx_out, &my_out, &mz_out, &mbc_out, &xlower, &ylower, &zlower, &dx, &dy, &dz); - - CHECK(mx_out == test_data.opts.mx); - CHECK(my_out == test_data.opts.my); - CHECK(mz_out == test_data.opts.mz); - CHECK(mbc_out == test_data.opts.mbc); - CHECK(xlower == cp->xlower); - CHECK(ylower == cp->ylower); - CHECK(zlower == cp->zlower); - CHECK(dx == cp->dx); - CHECK(dy == cp->dy); - CHECK(dz == cp->dz); - - } -} - -TEST_CASE("fclaw3dx_clawpatch_aux_data") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - double* aux; - int maux; - fclaw3dx_clawpatch_aux_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &aux, &maux); - - CHECK(aux == cp->aux.dataPtr()); - CHECK(maux == test_data.opts.maux); -} - -TEST_CASE("fclaw3dx_clawpatch_soln_data") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - double* q; - int meqn; - fclaw3dx_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &q, &meqn); - - CHECK(q == cp->griddata.dataPtr()); - CHECK(meqn == test_data.opts.meqn); -} - -TEST_CASE("fclaw3dx_clawpatch_rhs_data") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - double* rhs; - int mfields; - fclaw3dx_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &rhs, &mfields); - - CHECK(rhs == cp->rhs.dataPtr()); - CHECK(mfields == test_data.opts.rhs_fields); -} - -TEST_CASE("fclaw3dx_clawpatch_elliptic_error_data") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - double* rhs; - int mfields; - fclaw3dx_clawpatch_elliptic_error_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &rhs, &mfields); - - CHECK(rhs == cp->elliptic_error.dataPtr()); - CHECK(mfields == test_data.opts.rhs_fields); -} - -TEST_CASE("fclaw3dx_clawpatch_elliptic_soln_data") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - double* rhs; - int mfields; - fclaw3dx_clawpatch_elliptic_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &rhs, &mfields); - - CHECK(rhs == cp->elliptic_soln.dataPtr()); - CHECK(mfields == test_data.opts.rhs_fields); -} - -TEST_CASE("fclaw3dx_clawpatch_get_q") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - - CHECK(fclaw3dx_clawpatch_get_q(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->griddata.dataPtr()); -} - -TEST_CASE("fclaw3dx_clawpatch_get_registers") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - - CHECK(fclaw3dx_clawpatch_get_registers(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->registers); -} - -TEST_CASE("fclaw3dx_clawpatch_get_error") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - - CHECK(fclaw3dx_clawpatch_get_error(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->griderror.dataPtr()); -} - -TEST_CASE("fclaw3dx_clawpatch_get_exact_soln") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - - CHECK(fclaw3dx_clawpatch_get_exactsoln(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->exactsolution.dataPtr()); -} -TEST_CASE("fclaw3dx_clawpatch_timesync_data") -{ - for(int time_interp : {true,false}) - { - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - double* q; - int meqn; - fclaw3dx_clawpatch_timesync_data(test_data.glob, &test_data.domain->blocks[0].patches[0], time_interp, &q, &meqn); - - if(time_interp){ - CHECK(q == cp->griddata_time_interpolated.dataPtr()); - } else { - CHECK(q == cp->griddata.dataPtr()); - } - CHECK(meqn == test_data.opts.meqn); - } -} -TEST_CASE("fclaw3dx_clawpatch_get_q_timesync") -{ - for(int time_interp : {true,false}) - { - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - fclaw3dx_clawpatch_t* cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - - if(time_interp){ - CHECK(fclaw3dx_clawpatch_get_q_timesync(test_data.glob,&test_data.domain->blocks[0].patches[0],time_interp) == cp->griddata_time_interpolated.dataPtr()); - } else { - CHECK(fclaw3dx_clawpatch_get_q_timesync(test_data.glob,&test_data.domain->blocks[0].patches[0],time_interp) == cp->griddata.dataPtr()); - } - } -} -TEST_CASE("fclaw3dx_clawpatch user_data") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - void* user_data = (void *) 1234; - fclaw3dx_clawpatch_set_user_data(test_data.glob, &test_data.domain->blocks[0].patches[0],user_data); - CHECK(fclaw3dx_clawpatch_get_user_data(test_data.glob,&test_data.domain->blocks[0].patches[0]) == user_data); -} -TEST_CASE("fclaw3dx_clawpatch solver_data") -{ - SinglePatchDomain test_data; - test_data.setup(); - - //CHECK - void* user_data = (void *) 1234; - fclaw3dx_clawpatch_set_solver_data(test_data.glob, &test_data.domain->blocks[0].patches[0],user_data); - CHECK(fclaw3dx_clawpatch_get_solver_data(test_data.glob,&test_data.domain->blocks[0].patches[0]) == user_data); -} - -TEST_CASE("fclaw3dx_clawpatch_size") -{ - for(int mx : {4,5,6}) - for(int my : {4,5,6}) - for(int mz : {4,5,6}) - for(int mbc : {1,2}) - for(int meqn : {1,2}) - { - SinglePatchDomain test_data; - test_data.opts.mx = mx; - test_data.opts.my = my; - test_data.opts.mz = mz; - test_data.opts.mbc = mbc; - test_data.opts.meqn = meqn; - test_data.setup(); - - //CHECK - CHECK(fclaw3dx_clawpatch_size(test_data.glob) == (size_t) (mx+2*mbc)*(my+2*mbc)*(mz+2*mbc)*meqn); - } -} - -#if 0 -TEST_CASE("fclaw3dx_clawpatch_metric_scalar") -{ - SinglePatchDomain test_data; - test_data.setup(); - - double *mp_volume, *mp_faceareas; - double *volume, *faceareas; - - /* DAC : What is the right test here? */ - fclaw3d_metric_patch_scalar(test_data.glob, - &test_data.domain->blocks[0].patches[0], - &mp_volume, &mp_faceareas); - - fclaw3dx_clawpatch_metric_scalar(test_data.glob, - &test_data.domain->blocks[0].patches[0], - &volume, &faceareas); - - CHECK(mp_volume == volume); - CHECK(mp_faceareas == faceareas); -} -#endif - -#if 0 -/* DAC : Fix this test for fclaw3d_metric? */ -TEST_CASE("fclaw3dx_clawpatch_metric_vector") -{ - fclaw2d_global_t* glob = fclaw2d_global_new(); - fclaw2d_vtables_initialize(glob); - - SinglePatchDomain test_data; - test_data.setup(); - - double *mp_xnormals, *mp_ynormals, *mp_xtangents, *mp_ytangents, *mp_curvature; - double *xnormals, *ynormals, *xtangents, *ytangents, *curvature; - - fclaw3d_metric_patch_vector(test_data.glob, &test_data.domain->blocks[0].patches[0], - &mp_xnormals, &mp_ynormals, - &mp_xtangents, &mp_ytangents, - &mp_curvature); - - fclaw3dx_clawpatch_metric_vector(test_data.glob, &test_data.domain->blocks[0].patches[0], - &xnormals, &ynormals, - &xtangents, &ytangents, - &curvature); - - CHECK(mp_xnormals == xnormals); - CHECK(mp_ynormals == ynormals); - CHECK(mp_xtangents == xtangents); - CHECK(mp_ytangents == ytangents); - CHECK(mp_curvature == curvature); - - fclaw2d_global_destroy(glob); -} -#endif - -#if 0 -TEST_CASE("fclaw3dx_clawpatch_metric_data") -{ - SinglePatchDomain test_data; - test_data.setup(); - - double *mp_xp, *mp_yp, *mp_zp, *mp_xd, *mp_yd, *mp_zd, *mp_area; - double *xp, *yp, *zp, *xd, *yd, *zd, *area; - - fclaw3d_metric_patch_mesh_data(test_data.glob, &test_data.domain->blocks[0].patches[0], - &mp_xp, &mp_yp, &mp_zp, - &mp_xd, &mp_yd, &mp_zd, - &mp_area); - - fclaw3dx_clawpatch_metric_data(test_data.glob, &test_data.domain->blocks[0].patches[0], - &xp, &yp, &zp, - &xd, &yd, &zd, - &area); - - CHECK(mp_xp == xp); - CHECK(mp_yp == yp); - CHECK(mp_zp == zp); - CHECK(mp_xd == xd); - CHECK(mp_yd == yd); - CHECK(mp_zd == zd); - CHECK(mp_area == area); -} -#endif - -#if 0 -TEST_CASE("fclaw3dx_clawpatch_metric_data2") -{ - SinglePatchDomain test_data; - test_data.setup(); - - double *mp_xnormals, *mp_ynormals, *mp_xtangents, *mp_ytangents, *mp_surfnormals, *mp_edgelengths, *mp_curvature; - double *xnormals, *ynormals, *xtangents, *ytangents, *surfnormals, *edgelengths, *curvature; - - fclaw3d_metric_patch_mesh_data2(test_data.glob, &test_data.domain->blocks[0].patches[0], - &mp_xnormals, &mp_ynormals, - &mp_xtangents, &mp_ytangents, - &mp_surfnormals, &mp_edgelengths, &mp_curvature); - - fclaw3dx_clawpatch_metric_data2(test_data.glob, &test_data.domain->blocks[0].patches[0], - &xnormals, &ynormals, - &xtangents, &ytangents, - &surfnormals, &edgelengths, &curvature); - - CHECK(mp_xnormals == xnormals); - CHECK(mp_ynormals == ynormals); - CHECK(mp_xtangents == xtangents); - CHECK(mp_ytangents == ytangents); - CHECK(mp_surfnormals == surfnormals); - CHECK(mp_edgelengths == edgelengths); - CHECK(mp_curvature == curvature); -} -#endif - -namespace{ - double timeinterp_alpha; - int timeinterp_mint; - fclaw3dx_clawpatch_t* timeinterp_cp; -} - - -TEST_CASE("fclaw3dx_clawpatch setup_timeinterp") -{ - SinglePatchDomain test_data; - test_data.opts.interp_stencil_width=2; - timeinterp_mint = 2; - test_data.setup(); - - - timeinterp_cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - timeinterp_alpha = 0.90210; - - - fclaw3dx_clawpatch_vtable_t * clawpatch_vt = fclaw3dx_clawpatch_vt(test_data.glob); - clawpatch_vt->fort_timeinterp = [] (const int *mx, const int *my, const int *mz, - const int *mbc, const int *meqn, const int *psize, - double qcurr[], double qlast[], double qinterp[], - const double *alpha, const int *ierror) - { - CHECK(*mx == timeinterp_cp->mx); - CHECK(*my == timeinterp_cp->my); - CHECK(*mz == timeinterp_cp->mz); - CHECK(*mbc == timeinterp_cp->mbc); - CHECK(*meqn == timeinterp_cp->meqn); - CHECK(*psize == (*mx)*(*my)*(*mz) - - (*mx-2*timeinterp_mint)*(*my-2*timeinterp_mint)*(*mz)); - CHECK(qcurr == timeinterp_cp->griddata.dataPtr()); - CHECK(qlast == timeinterp_cp->griddata_last.dataPtr()); - CHECK(qinterp == timeinterp_cp->griddata_time_interpolated.dataPtr()); - CHECK(*alpha == timeinterp_alpha); - }; - - fclaw2d_patch_setup_timeinterp(test_data.glob, &test_data.domain->blocks[0].patches[0], - timeinterp_alpha); -} -namespace{ - fclaw3dx_clawpatch_t* t4r_cp; - int t4r_tag_patch; - int t4r_init_flag; -} -TEST_CASE("fclaw3dx_clawpatch tag4refinement") -{ - for(int tag_patch : {true,false}) - for(int init_flag : {true,false}) - { - SinglePatchDomain test_data; - test_data.fopts.refine_threshold = 0.90210; - test_data.setup(); - - - t4r_cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - - fclaw3dx_clawpatch_vtable_t * clawpatch_vt = fclaw3dx_clawpatch_vt(test_data.glob); - - t4r_tag_patch = tag_patch; - t4r_init_flag = init_flag; - clawpatch_vt->fort_tag4refinement = [](const int *mx, const int *my, const int *mz, - const int *mbc, const int *meqn, - const double *xlower, const double *ylower, const double *zlower, - const double *dx, const double *dy, const double *dz, - const int *blockno, - double q[], const double *tag_threshold, const int *init_flag, - int *tag_patch) - { - CHECK(*mx == t4r_cp->mx); - CHECK(*my == t4r_cp->my); - CHECK(*mz == t4r_cp->mz); - CHECK(*mbc == t4r_cp->mbc); - CHECK(*meqn == t4r_cp->meqn); - CHECK(*xlower == t4r_cp->xlower); - CHECK(*ylower == t4r_cp->ylower); - CHECK(*zlower == t4r_cp->zlower); - CHECK(*dx == t4r_cp->dx); - CHECK(*dy == t4r_cp->dy); - CHECK(*dz == t4r_cp->dz); - CHECK(*blockno == t4r_cp->blockno); - CHECK(q == t4r_cp->griddata.dataPtr()); - CHECK(*tag_threshold == .90210); - CHECK(*init_flag == t4r_init_flag); - *tag_patch = t4r_tag_patch; - }; - - CHECK(fclaw2d_patch_tag4refinement(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4r_init_flag) == t4r_tag_patch); - } -} -TEST_CASE("fclaw3dx_clawpatch tag4refinement negative refine threshold") -{ - for(int init_flag : {true,false}) - { - SinglePatchDomain test_data; - test_data.fopts.refine_threshold = -0.90210; - test_data.setup(); - - t4r_init_flag = init_flag; - - CHECK(fclaw2d_patch_tag4refinement(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4r_init_flag) == true); - } -} -namespace{ - fclaw3dx_clawpatch_t* t4c_cp; - fclaw3dx_clawpatch_t* t4c_cp1; - fclaw3dx_clawpatch_t* t4c_cp2; - fclaw3dx_clawpatch_t* t4c_cp3; - int t4c_tag_patch; - int t4c_init_flag; -} -TEST_CASE("fclaw3dx_clawpatch tag4coarsening") -{ - for(int tag_patch : {true,false}) - { - t4c_tag_patch= tag_patch; - for(int init_flag : {true,false}) - { - t4c_init_flag = init_flag; - - QuadDomain test_data; - test_data.fopts.coarsen_threshold = 0.90210; - test_data.setup(); - - - t4c_cp = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); - t4c_cp1 = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[1]); - t4c_cp2 = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[2]); - t4c_cp3 = fclaw3dx_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[3]); - - fclaw3dx_clawpatch_vtable_t * clawpatch_vt = fclaw3dx_clawpatch_vt(test_data.glob); - - clawpatch_vt->fort_tag4coarsening = [](const int *mx, const int *my, const int *mz, - const int *mbc, const int *meqn, - double xlower[], double ylower[], double zlower[], - const double *dx, const double *dy, const double *dz, - const int *blockno, - double q0[], double q1[], double q2[], double q3[], - const double *tag_threshold, const int *init_flag, int *tag_patch) - { - CHECK(*mx == t4c_cp->mx); - CHECK(*my == t4c_cp->my); - CHECK(*mz == t4c_cp->mz); - CHECK(*mbc == t4c_cp->mbc); - CHECK(*meqn == t4c_cp->meqn); - CHECK(*xlower == t4c_cp->xlower); - CHECK(*ylower == t4c_cp->ylower); - CHECK(*zlower == t4c_cp->zlower); - CHECK(*dx == t4c_cp->dx); - CHECK(*dy == t4c_cp->dy); - CHECK(*dz == t4c_cp->dz); - CHECK(*blockno == t4c_cp->blockno); - CHECK(q0 == t4c_cp->griddata.dataPtr()); - CHECK(q1 == t4c_cp1->griddata.dataPtr()); - CHECK(q2 == t4c_cp2->griddata.dataPtr()); - CHECK(q3 == t4c_cp3->griddata.dataPtr()); - CHECK(*tag_threshold == .90210); - CHECK(*init_flag == t4c_init_flag); - *tag_patch = t4c_tag_patch; - }; - - CHECK(fclaw2d_patch_tag4coarsening(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4c_init_flag) == t4c_tag_patch); - } - } -} -TEST_CASE("fclaw3dx_clawpatch tag4coarsening negative coarsen threshold") -{ - for(int init_flag : {true,false}) - { - t4c_init_flag = init_flag; - - QuadDomain test_data; - test_data.fopts.coarsen_threshold = -0.90210; - test_data.setup(); - - CHECK(fclaw2d_patch_tag4coarsening(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4c_init_flag) == false); - } -} -namespace{ - fclaw3dx_clawpatch_t* i2f_ccp; - fclaw3dx_clawpatch_t* i2f_cp; - fclaw3dx_clawpatch_t* i2f_cp1; - fclaw3dx_clawpatch_t* i2f_cp2; - fclaw3dx_clawpatch_t* i2f_cp3; - std::bitset<4> i2f_igrids; - int i2f_manifold; -} -TEST_CASE("fclaw3dx_clawpatch interpolate2fine") -{ - i2f_manifold = false; - - QuadDomain fine_test_data; - fine_test_data.fopts.manifold = i2f_manifold; - fine_test_data.setup(); - SinglePatchDomain coarse_test_data; - coarse_test_data.fopts.manifold = i2f_manifold; - coarse_test_data.setup(); - - - i2f_ccp = fclaw3dx_clawpatch_get_clawpatch(&coarse_test_data.domain->blocks[0].patches[0]); - i2f_cp = fclaw3dx_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[0]); - i2f_cp1 = fclaw3dx_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[1]); - i2f_cp2 = fclaw3dx_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[2]); - i2f_cp3 = fclaw3dx_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[3]); - - fclaw3dx_clawpatch_vtable_t * clawpatch_vt = fclaw3dx_clawpatch_vt(coarse_test_data.glob); - - clawpatch_vt->fort_interpolate2fine = [](const int *mx, const int *my, const int *mz, - const int *mbc, const int *meqn, - double qcoarse[], double qfine[], double areacoarse[], double areafine[], - const int *igrid, const int *manifold) - { - CHECK(*mx == i2f_cp->mx); - CHECK(*my == i2f_cp->my); - CHECK(*mz == i2f_cp->mz); - CHECK(*mbc == i2f_cp->mbc); - CHECK(*meqn == i2f_cp->meqn); - - CHECK(qcoarse == i2f_ccp->griddata.dataPtr()); -#if PATCH_DIM == 2 - CHECK(areacoarse == i2f_ccp->mp->area.dataPtr()); - - if(*igrid==0){ - CHECK(qfine == i2f_cp->griddata.dataPtr()); - CHECK(areafine == i2f_cp->mp->area.dataPtr()); - }else if(*igrid==1){ - CHECK(qfine == i2f_cp1->griddata.dataPtr()); - CHECK(areafine == i2f_cp1->mp->area.dataPtr()); - }else if(*igrid==2){ - CHECK(qfine == i2f_cp2->griddata.dataPtr()); - CHECK(areafine == i2f_cp2->mp->area.dataPtr()); - }else if(*igrid==3){ - CHECK(qfine == i2f_cp3->griddata.dataPtr()); - CHECK(areafine == i2f_cp3->mp->area.dataPtr()); - }else{ - REQUIRE(false); - } -#endif - - CHECK(i2f_igrids[*igrid] == false); - i2f_igrids[*igrid] = true; - CHECK(*manifold == i2f_manifold); - }; - - fclaw2d_patch_interpolate2fine(coarse_test_data.glob, - &coarse_test_data.domain->blocks[0].patches[0], - &fine_test_data.domain->blocks[0].patches[0], - 0, 0, 0); - - CHECK(i2f_igrids.all()); -} \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch.hpp b/src/patches/clawpatch/fclaw3dx_clawpatch.hpp deleted file mode 100644 index bae7e42d2..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3DX_CLAWPATCH_HPP -#define FCLAW3DX_CLAWPATCH_HPP - -/** - * @file - * C++ structures for clawpatch - */ -#include /* Needed for FArray boxes */ - -struct fclaw2d_patch; -struct fclaw2d_global; -struct fclaw3d_metric_patch_t; - -/** - * @brief Stores data for each patch - */ -class fclaw3dx_clawpatch_t -{ -public : - /* Solution data */ - int meqn; /**< number of equations */ - FArrayBox griddata; /**< the current solution */ - FArrayBox griddata_last; /**< the solution at the last timestep */ - FArrayBox griddata_save; /**< the saved solution */ - FArrayBox griddata_time_interpolated; /**< the time interpolated solution */ - FArrayBox griderror; /**< the error */ - - /** Exact solution for diagnostics */ - FArrayBox exactsolution; - - int mfields; /**< Number of fields in the rhs */ - FArrayBox rhs; /**< RHS for elliptic problems */ - - FArrayBox elliptic_error; /**< Error for elliptic problems */ - FArrayBox elliptic_soln; /**< Solution for elliptic problems */ - - /** Registers for accumulating mismatches at coarse/fine interfaces */ - struct fclaw3dx_clawpatch_registers *registers; - - /* Grid info */ - int mx; /**< number of cells in the x direction */ - int my; /**< number of cells in the y direction */ - int mz; /**< number of cells in the z direction */ - int mbc; /**< number ghost cells */ - int maux; /**< number aux equations */ - - double dx; /**< cell spacing in the x direction */ - double dy; /**< cell spacing in the y direction */ - double dz; /**< cell spacing in the z direction */ - - double xlower; /**< x coordinate of the left face of the patch */ - double ylower; /**< y coordinate of the bottom face of the patch */ - double zlower; /**< z coordinate of the lower face of the patch */ - double xupper; /**< x coordinate of the right face of the patch */ - double yupper; /**< y coordinate of the top face of the patch */ - double zupper; /**< z coordinate of the upper face of the patch */ - - /** Auxilliary array (used by Clawpack 4.6 and 5.0) */ - FArrayBox aux; - FArrayBox aux_save; - - /* Mapping and metric info */ - int manifold; /**< true if using manifold */ - int blockno; /**< the block number of a patch */ - - fclaw3d_metric_patch_t *mp; /**< the metric data for a patch */ - - /** Extra storage needed by the solver(s) */ - void* solver_data; - - /** User data*/ - void* user_data; -}; - -/** - * @brief Get the clawpatch structure for a patch - * - * @param this_patch the patch context - * @return fclaw3dx_clawpatch_t* the clawpatch structure - */ -fclaw3dx_clawpatch_t* -fclaw3dx_clawpatch_get_clawpatch(struct fclaw2d_patch* this_patch); - -/** - * @brief Get the metrix structure for a patch - * - * @param this_patch the patch context - * @return fclaw2d_metric_patch_t* the metric structure - */ - -struct fclaw3d_metric_patch_t* -fclaw3dx_clawpatch_get_metric_patch(struct fclaw2d_patch* this_patch); - - - - -#endif /* !FCLAW2D_CLAWPATCH_HPP */ diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch46_fort.h b/src/patches/clawpatch/fclaw3dx_clawpatch46_fort.h deleted file mode 100644 index 89da85cf5..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch46_fort.h +++ /dev/null @@ -1,521 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3DX_CLAWPATCH46_FORT_H -#define FCLAW3DX_CLAWPATCH46_FORT_H - -/** - * @file - * C declarations of clawpatch 4.6 fortran subroutines - */ -#ifdef __cplusplus -extern "C" -{ -#endif - - -#if 0 -/* Fix syntax highlighting */ -#endif - -struct fclaw2d_patch_transform_data; /* Should be replaced by long int? */ - -/** @{ @name Time Stepping Functions *//*---------------------------------------------- */ - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_TIMEINTERP \ - FCLAW_F77_FUNC (fclaw3dx_clawpatch46_fort_timeinterp, \ - FCLAW3DX_CLAWPATCH46_FORT_TIMEINTERP) - -/** @copydoc fclaw3dx_clawpatch46_fort_timeinterp() */ -void FCLAW3DX_CLAWPATCH46_FORT_TIMEINTERP(const int *mx, - const int* my, - const int* mz, - const int* mbc, - const int *meqn, - const int* psize, - double qcurr[], - double qlast[], - double qinterp[], - const double* alpha, - const int* ierror); - -/** @} */ - -/** @{ @name Regridding Functions *//*------------------------------------------------- */ - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_TAG4REFINEMENT \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_tag4refinement, \ - FCLAW3DX_CLAWPATCH46_FORT_TAG4REFINEMENT) - -/** @copydoc fclaw3dx_clawpatch46_fort_tag4refinement() */ -void FCLAW3DX_CLAWPATCH46_FORT_TAG4REFINEMENT(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const double* xlower, - const double* ylower, - const double* zlower, - const double* dx, - const double* dy, - const double* dz, - const int* blockno, - double q[], - const double* tag_threshold, - const int* init_flag, - int* tag_patch); - - - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_tag4coarsening, \ - FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING) - -/** @copydoc fclaw3dx_clawpatch46_fort_tag4coarsening() */ -void FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double xlower[], - double ylower[], - double zlower[], - const double* dx, - const double* dy, - const double* dz, - const int* blockno, - double q0[], - double q1[], - double q2[], - double q3[], - const double* tag_threshold, - const int* initflag, - int* tag_patch); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_interpolate2fine, \ - FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE) - -/** @copydoc fclaw3dx_clawpatch46_fort_interpolate2fine() */ -void FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* igrid, - const int* manifold); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_average2coarse, \ - FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE) - -/** @copydoc fclaw3dx_clawpatch46_fort_average2coarse() */ -void FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* igrid, - const int* manifold); - - - -/** @} */ - -/** @{ @name Ghost Filling *//*-------------------------------------------------------- */ - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_COPY_FACE \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_copy_face, \ - FCLAW3DX_CLAWPATCH46_FORT_COPY_FACE) - -/** @copydoc fclaw3dx_clawpatch46_fort_copy_face() */ -void FCLAW3DX_CLAWPATCH46_FORT_COPY_FACE(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qthis[], - double qneighbor[], - const int* a_idir, - struct fclaw2d_patch_transform_data** - transform_cptr); - - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_average_face, \ - FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE) -/** @copydoc fclaw3dx_clawpatch46_fort_average_face() */ -void FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* idir, - const int* iside, - const int* num_neighbors, - const int* refratio, - const int* igrid, - const int* manifold, - struct fclaw2d_patch_transform_data** - transform_cptr); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_interpolate_face, \ - FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE) -/** @copydoc fclaw3dx_clawpatch46_fort_interpolate_face() */ -void FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - const int* idir, - const int* iside, - const int* num_neighbors, - const int* refratio, - const int* igrid, - struct fclaw2d_patch_transform_data** - transform_cptr); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_copy_corner, \ - FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER) -/** @copydoc fclaw3dx_clawpatch46_fort_copy_corner() */ -void FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double this_q[], - double neighbor_q[], - const int* a_corner, - struct fclaw2d_patch_transform_data** - transform_cptr); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_average_corner, \ - FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER) -/** @copydoc fclaw3dx_clawpatch46_fort_average_corner() */ -void FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const int* a_refratio, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* manifold, - const int* a_corner, - struct fclaw2d_patch_transform_data** - transform_cptr); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_interpolate_corner, \ - FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER) -/** @copydoc fclaw3dx_clawpatch46_fort_interpolate_corner() */ -void FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const int* a_refratio, - double this_q[], - double neighbor_q[], - const int* a_corner, - struct fclaw2d_patch_transform_data** - transform_cptr); - -/** @} */ - - -/* ------------------------- Pillow grid block corner routines ----------------------- */ - -/** Fortran subroutine name */ -#define FCLAW3DX_PILLOW46_COPY_BLOCK_CORNER \ - FCLAW_F77_FUNC(fclaw3dx_pillow46_copy_block_corner, \ - FCLAW3DX_PILLOW46_COPY_BLOCK_CORNER) - -/** @copydoc fclaw2d_pillow46_copy_block_corner() */ -void FCLAW3DX_PILLOW46_COPY_BLOCK_CORNER(int* mx, - int* my, - int* mz, - int* mbc, - int* meqn, - double qthis[], - double qneighbor[], - int* icorner, - int* iblock); - -/** Fortran subroutine name */ -#define FCLAW3DX_PILLOW46_AVERAGE_BLOCK_CORNER \ - FCLAW_F77_FUNC(fclaw3dx_pillow46_average_block_corner,\ - FCLAW3DX_PILLOW46_AVERAGE_BLOCK_CORNER) - -/** @copydoc fclaw2d_pillow46_average_block_corner() */ -void FCLAW3DX_PILLOW46_AVERAGE_BLOCK_CORNER(int* mx, - int* my, - int* mz, - double *dz, - int* mbc, - int* meqn, - int* refratio, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - int* coarse_corner, - int* blockno); - -/** Fortran subroutine name */ -#define FCLAW3DX_PILLOW46_INTERPOLATE_BLOCK_CORNER \ - FCLAW_F77_FUNC(fclaw3dx_pillow46_interpolate_block_corner, \ - FCLAW3DX_PILLOW46_INTERPOLATE_BLOCK_CORNER) - -/** @copydoc fclaw2d_pillow46_interpolate_block_corner() */ -void FCLAW3DX_PILLOW46_INTERPOLATE_BLOCK_CORNER(int* mx, - int* my, - int* mz, - int* mbc, - int* meqn, - int* refratio, - double qcoarse[], - double qfine[], - int* icoarse_corner, - int* blockno); - - - -/* ------------------------------------ Output functions ------------------------------ */ - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_OUTPUT_ASCII \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_output_ascii, \ - FCLAW3DX_CLAWPATCH46_FORT_OUTPUT_ASCII) -/** @copydoc fclaw3dx_clawpatch46_fort_output_ascii() */ -void FCLAW3DX_CLAWPATCH46_FORT_OUTPUT_ASCII(char* matname1, - int* mx, - int* my, - int* mz, - int* meqn, - int* mbc, - double* xlower, - double* ylower, - double* zlower, - double* dx, - double* dy, - double* dz, - double q[], - int* patch_num, - int* level, - int* blockno, - int* mpirank); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_HEADER_ASCII \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_header_ascii, \ - FCLAW3DX_CLAWPATCH46_FORT_HEADER_ASCII) -/** @copydoc fclaw3dx_clawpatch46_fort_header_ascii() */ -void FCLAW3DX_CLAWPATCH46_FORT_HEADER_ASCII(const char* matname1, - const char* matname2, - const double* time, - const int* meqn, - const int* maux, - const int* ngrids); - -/* ----------------------------- Diagnostics functions -------------------------------- */ - - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_CONSERVATION_CHECK \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_conservation_check, \ - FCLAW3DX_CLAWPATCH46_FORT_CONSERVATION_CHECK) -/** @copydoc fclaw3dx_clawpatch46_fort_conservation_check() */ -void FCLAW3DX_CLAWPATCH46_FORT_CONSERVATION_CHECK(int *mx, - int *my, - int* mz, - int* mbc, - int* meqn, - double *dx, - double *dy, - double* dz, - double* area, - double *q, - double* sum, - double* c_kahan); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_COMPUTE_PATCH_AREA \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_compute_patch_area, \ - FCLAW3DX_CLAWPATCH46_FORT_COMPUTE_PATCH_AREA) - -/** @copydoc fclaw3dx_clawpatch46_fort_compute_patch_area() */ -double FCLAW3DX_CLAWPATCH46_FORT_COMPUTE_PATCH_AREA(int *mx, - int* my, - int* mz, - int*mbc, - double* dx, - double* dy, - double* dz, - double area[]); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_COMPUTE_ERROR_NORM \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_compute_error_norm, \ - FCLAW3DX_CLAWPATCH46_FORT_COMPUTE_ERROR_NORM) - -/** @copydoc fclaw3dx_clawpatch46_fort_compute_error_norm() */ -void FCLAW3DX_CLAWPATCH46_FORT_COMPUTE_ERROR_NORM (int* blockno, - int* mx, - int* my, - int* mz, - int* mbc, - int* meqn, - double* dx, - double* dy, - double* dz, - double area[], - double error[], - double* error_norm); - -/* ----------------------------- Parallel ghost patches ------------------------------ */ - - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch46_fort_local_ghost_pack, \ - FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK) -/** @copydoc fclaw3dx_clawpatch46_fort_local_ghost_pack() */ -void FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK(const int *mx, - const int *my, - const int* mz, - const int *mbc, - const int *meqn, - const int *mint, - double qdata[], - double area[], - double qpack[], - const int *psize, - const int *packmode, - int *ierror); - - - -/* ----------------------------- User convenience headers ----------------------------- */ -/** Fortran subroutine name */ -#define FCLAW2DX_CLAWPATCH46_TAG4REFINEMENT \ - FCLAW_F77_FUNC(fclaw2dx_clawpatch46_tag4refinement, \ - FCLAW2DX_CLAWPATCH46_TAG4REFINEMENT) - -/** - * @brief @copybrief ::clawpatch_fort_tag4refinement_t - * - * For user defined clawpatch46_tag4refinment subroutine - * - * @details @copydetails ::clawpatch_fort_tag4refinement_t - */ -void FCLAW2DX_CLAWPATCH46_TAG4REFINEMENT(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const double* xlower, - const double* ylower, - const double* zlower, - const double* dx, - const double* dy, - const double* dz, - const int* blockno, - double q[], - const double* tag_threshold, - const int* init_flag, - int* tag_patch); - - - -/** Fortran subroutine name */ -#define FCLAW2DX_CLAWPATCH46_TAG4COARSENING \ - FCLAW_F77_FUNC(fclaw2dx_clawpatch46_tag4coarsening, \ - FCLAW2DX_CLAWPATCH46_TAG4COARSENING) - -/** - * @brief @copybrief ::clawpatch_fort_tag4coarsening_t - * - * For user defined clawpatch46_tag4coarsening subroutine - * - * @details @copydetails ::clawpatch_fort_tag4coarsening_t - */ -void FCLAW2DX_CLAWPATCH46_TAG4COARSENING(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const double* xlower, - const double* ylower, - const double* zlower, - const double* dx, - const double* dy, - const double* dz, - const int* blockno, - double q0[], - double q1[], - double q2[], - double q3[], - const double* tag_threshold, - const int* initflag, - int* tag_patch); - - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_conservation.c b/src/patches/clawpatch/fclaw3dx_clawpatch_conservation.c deleted file mode 100644 index 9d5f9cec7..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_conservation.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define REFINE_DIM 2 -#define PATCH_DIM 3 - -#include diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_conservation.h b/src/patches/clawpatch/fclaw3dx_clawpatch_conservation.h deleted file mode 100644 index 78997b587..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_conservation.h +++ /dev/null @@ -1,296 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3DX_CLAWPATCH_CONSERVATION_H -#define FCLAW3DX_CLAWPATCH_CONSERVATION_H - -#include - -/** - * @file - * Clawpatch conservation related structures and routines - */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct fclaw2d_patch_transform_data; -struct fclaw2d_global; -struct fclaw2d_patch; - -/** - * @brief fclaw3dx_clawpatch_registers type - */ -typedef struct fclaw3dx_clawpatch_registers fclaw3dx_clawpatch_registers_t; - -/** - * @brief Stores flux information for the edges of patch - */ -struct fclaw3dx_clawpatch_registers -{ - /** Stores the value of the flux function at cell centers along the edges */ - double *edge_fluxes[4]; - - /* Scaling factors */ - /** Array of edge lengths for each edge of the patch */ - double *edgelengths[4]; - /** Array of areas for each edge of the patch */ - double *area[4]; - - /* 1d arrays stored on left/right faces (fp/fm) and top/bottom faces (gp/gm) */ - - /** Fluxes along the left face */ - double *fp[2]; - /** Fluxes along the right face */ - double *fm[2]; - /** Fluxes along the bottom face */ - double *gp[2]; - /** Fluxes along the top face */ - double *gm[2]; -}; - -/** - * @brief Adds fine grid corrections to coarse grid. - * - * @param[in] mx, my the number of cells in the x and y directions - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of ghost cells - * @param[in] idir the direction of the interface 0 for bottom/top - * 1 for left/right - * @param[in] iface_coarse the interface on the coarse patch - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] normal_match true if normals on coarse and fine patches match - * @param[in] area0, area1, area2, area3 area of cells along the - * edges - * @param[in,out] qcoarse the solution on the coarse patch - * @param[in] fpthis0, fmthis1, gpthis2, gmthis3 the fluxes along - * the edges of the coarse patch - * @param[in] fmfine0, fmfine1, gpfine2, fpfine3 the fluxes along - * the dges of the fine patch - * @param[in] efthis0, efthis1, efthis2, efthis3 the values of the - * flux function along the coarse patch edges - * @param[in] eff0, eff1, eff2, eff3 the values of the flux - * function along the fine patch edges - * @param[in,out] qfine_dummy work vector for determining values in the fine patch - * @param[in] transform_cptr the pointer to the fclaw2d_patch_transform_data struct - */ -typedef void (*fclaw3dx_clawpatch_fort_time_sync_f2c_t)(const int* mx, - const int* my, - const int *mbc, - const int *meqn, - const int* idir, - const int* iface_coarse, - const int* coarse_blockno, - const int* fine_blockno, - const int* normal_mismatch, - double area0[], double area1[], - double area2[], double area3[], - double qcoarse[], - double fmthis0[], - double fpthis1[], - double gmthis2[], - double gpthis3[], - double fmfine0[], double fpfine1[], - double gmfine2[], double gpfine3[], - double efthis0[], double efthis1[], - double efthis2[], double efthis3[], - double eff0[], double eff1[], - double eff2[], double eff3[], - double qfine_dummy[], - struct fclaw2d_patch_transform_data** - transform_cptr); - -/** - * @brief Adds wave corrections at same level interfaces. - * - * This accounts for metric mismatches that can occur at block boundaries. - * - * @param[in] mx, my the number of cells in the x and y directions - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of ghost cells - * @param[in] idir the direction of the interface 0 for bottom/top - * 1 for left/right - * @param[in] iface_this the interface on the this patch - * @param[in] this_blockno the block number of the coarse patch - * @param[in] nbr_blockno the block number of the fine patch - * @param[in] area0, area1, area2, area3 area of cells along the - * edges on this patch - * @param[in,out] qthis the solution on this patch - * @param[in] fpthis0, fmthis1, gpthis2, gmthis3 the fluxes along - * the edges of the this patch - * @param[in] fmfine0, fmfine1, gpfine2, fpfine3 the fluxes along - * the dges of the neighbor patch - * @param[in] efthis0, efthis1, efthis2, efthis3 the values of the - * flux function along the this patch edges - * @param[in] efnbr0, efnbr1, efnbr2, efnbr3 the values of the flux - * function along the neighbor patch edges - * @param[in,out] qnbr_dummy work vector for determining values in the fine patch - * @param[in] transform_cptr the pointer to the fclaw2d_patch_transform_data struct - */ -typedef void (*fclaw3dx_clawpatch_fort_time_sync_samesize_t)(const int* mx, - const int* my, - const int *mbc, - const int *meqn, - const int* idir, - const int* iface_this, - const int* this_blockno, - const int* nbr_blockno, - double area0[], double area1[], - double area2[], double area3[], - double qthis[], - double fmthis0[], - double fpthis1[], - double gmthis2[], - double gpthis3[], - double fmnbr0[], double fpnbr1[], - double gmnbr2[], double gpnbr3[], - double efthis0[], double efthis1[], - double efthis2[], double efthis3[], - double efnbr0[], double efnbr1[], - double efnbr2[], double efnbr3[], - double qnbr_dummy[], - struct fclaw2d_patch_transform_data** - transform_cptr); - - - -/** - * @brief Allocate a new registers struct - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[out] registers the newly allocated registers struct - */ -void fclaw3dx_clawpatch_time_sync_new(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - int blockno,int patchno, - fclaw3dx_clawpatch_registers_t **registers); - -/** - * @brief Deallocate the registers struct - * - * @param[in,out] registers the registers, set to NULL on return - */ -void fclaw3dx_clawpatch_time_sync_delete(fclaw3dx_clawpatch_registers_t **registers); - -/** - * @brief Inialize the area and edgelength arrays of the registers - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - */ -void fclaw3dx_clawpatch_time_sync_setup(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - int blockno,int patchno); - -/** - * @brief Adds fine grid corrections to coarse grid. - * - * @param[in] glob the global context - * @param[in,out] coarse_patch the coarse patch context - * @param[in] fine_patch the fine patch context - * @param[in] coarse_blockno the block number of the coarse patch - * @param[in] fine_blockno the block number of the fine patch - * @param[in] coarse_patchno the patch number of the coarse patch - * @param[in] idir the direction of the interface 0 for bottom/top - * 1 for left/right - * @param[in] igrid the index of the fine grid in the child array - * @param[in] iface_coarse the interface on the coarse patch - * @param[in] time_interp NOT USED - * @param[in] transform_data the transform for the neighbor's coordinates - */ -void fclaw3dx_clawpatch_time_sync_f2c(struct fclaw2d_global* glob, - struct fclaw2d_patch* coarse_patch, - struct fclaw2d_patch* fine_patch, - int coarse_blockno, int fine_blockno, - int coarse_patchno, - int idir, - int igrid, - int iface_coarse, - int time_interp, - struct fclaw2d_patch_transform_data - *transform_data); - -/** - * @brief Adds corrections to patches that are at the same levle and are at block boundaries. - * - * @param[in] glob the global context - * @param[in,out] this_patch this patch - * @param[in] neighbor_patch the neighbor patch - * @param[in] this_iface the interface that the neighbor patch is on - * @param[in] idir the direction of the interface 0 for bottom/top - * 1 for left/right - * @param[in] transform_data the transform for the neighbor's coordinates - */ -void fclaw3dx_clawpatch_time_sync_samesize(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - struct fclaw2d_patch* neighbor_patch, - int this_iface,int idir, - struct fclaw2d_patch_transform_data - *transform_data); - -/** - * @brief Resets arrays in the registers - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in] coarse_level the the level of the coarse patch - * @param[in] reset_mode the reset mode ::fclaw2d_time_sync_type - */ -void fclaw3dx_clawpatch_time_sync_reset(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, - int coarse_level, - int reset_mode); - -/** - * @brief Packs/Unpacks the registers to/from a buffer - * - * @param[in] glob the global context - * @param[in,out] this_patch the patch context - * @param[in,out] qpack the buffer - * @param[in] frsize the size of the buffer - * @param[in] packmode the packing mode - * @param[out] ierror the error value - */ -void fclaw3dx_clawpatch_time_sync_pack_registers(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, - double *qpack, - int frsize, - fclaw_clawpatch_packmode_t packmode, - int *ierror); - -#ifdef __cplusplus -} -#endif - -#endif /* !FCLAW2D_CLAWPATCH_CONSERVATION_H */ - diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_conservation_fort.h b/src/patches/clawpatch/fclaw3dx_clawpatch_conservation_fort.h deleted file mode 100644 index ec36831a5..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_conservation_fort.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3DX_CLAWPATCH_CONSERVATION_FORT_H -#define FCLAW3DX_CLAWPATCH_CONSERVATION_FORT_H - -#include - -/** - * @file - * C declarations of Fortran subroutines - */ -#ifdef __cplusplus -extern "C" -{ -#if 0 -} -#endif -#endif - -#if 0 -/* To fix syntax highlighting below */ -#endif - -/** Fortran subroutine name */ -#define CLAWPATCH_TIME_SYNC_SETUP FCLAW_F77_FUNC(clawpatch_time_sync_setup, \ - CLAWPATCH_TIME_SYNC_SETUP) - -/** @copydoc clawpatch_time_sync_setup() */ -void CLAWPATCH_TIME_SYNC_SETUP(const int* mx,const int *my, const int* mbc, - const double* dx, const double *dy, - double area[], double edge_lengths[], - double area0[], double area1[], - double area2[], double area3[], - double el0[], double el1[], - double el2[], double el3[], - const int* manifold); - - -#ifdef __cplusplus -#if 0 -{ -#endif -} -#endif - -#endif - diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics.c b/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics.c deleted file mode 100644 index 399d6aaa1..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define REFINE_DIM 2 -#define PATCH_DIM 3 - -#include diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics.h b/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics.h deleted file mode 100644 index b57f653e9..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics.h +++ /dev/null @@ -1,148 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3DX_CLAWPATCH_DIAGNOSTICS_H -#define FCLAW3DX_CLAWPATCH_DIAGNOSTICS_H - -/** - * @file - * Clawpatch diagnostics related structures and routines - */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct fclaw2d_global; -struct fclaw2d_patch; - -/** - * @brief Data structure for default diagnostic routines - */ -typedef struct { - double* local_error; /**< meqn x 3 array of errors on a patch */ - double* global_error; /**< meqn x 3 array of errors after gather */ - double area; /**< the area */ - double *mass; /**< the mass per eqn */ - double *mass0; /**< Mass at initial time per eqn */ - double *c_kahan; /**< c value in Kahan summation algorithm per eqn */ -} fclaw3dx_clawpatch_error_info_t; - -/*------------------------------------ typedefs -----------------------------*/ - -/*-------------------------------- virtualized functions ----------------------------*/ - -/** - * @brief Initialize a user defined data structer - * - * @param glob the global context - * @param patch_acc the data structure - */ -void fclaw3dx_clawpatch_diagnostics_initialize(struct fclaw2d_global *glob, - void** patch_acc); - -/** - * @brief Iterate over patches and perform computations - * - * @param glob the global context - * @param patch_acc the user defined data structure - */ -void fclaw3dx_clawpatch_diagnostics_compute(struct fclaw2d_global *glob, - void* patch_acc); - -/** - * @brief Perform final computations after fclaw3dx_clawpatch_diagnostics_computer() has been called - * - * @param glob the glboal context - * @param patch_acc the user defined data structure - * @param init_flag true if in init stage - */ -void fclaw3dx_clawpatch_diagnostics_gather(struct fclaw2d_global *glob, - void* patch_acc, int init_flag); - -/** - * @brief reset the user defined data structure - * - * @param glob the global context - * @param patch_acc the user defined data structure - */ -void fclaw3dx_clawpatch_diagnostics_reset(struct fclaw2d_global *glob, - void* patch_acc); - -/** - * @brief Deallocate the user defined data structure - * - * @param glob the global context - * @param patch_acc the user defined data structure - */ -void fclaw3dx_clawpatch_diagnostics_finalize(struct fclaw2d_global *glob, - void** patch_acc); - -/** - * @brief Initialize a global vtable - * - * fclaw2d_diagnotistcs_vtable has to be initialized first - * - * @param glob the global context - */ -void fclaw3dx_clawpatch_diagnostics_vtable_initialize(struct fclaw2d_global *glob); - -/** - * @brief Calls the function in fclaw3dx_clawpatch_vtable.fort_conservation_check - * - * @param glob the global context - * @param patch the patch context - * @param blockno the block number - * @param patchno the patch number - * @param error_data user data pointer - */ -void fclaw3dx_clawpatch_diagnostics_cons_default(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - int blockno, - int patchno, - void *error_data); - -/** - * @brief Calls the function in fclaw3dx_clawpatch_vtable.fort_compute_patch_error - * - * @param glob the global context - * @param patch the patch context - * @param blockno the block number - * @param patchno the patch number - * @param error_data user data pointer - */ -void fclaw3dx_clawpatch_diagnostics_error_default(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - int blockno, - int patchno, - void *error_data); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics_default.c b/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics_default.c deleted file mode 100644 index 1240e499e..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics_default.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define REFINE_DIM 2 -#define PATCH_DIM 3 - -#include diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_fort.h b/src/patches/clawpatch/fclaw3dx_clawpatch_fort.h deleted file mode 100644 index abc3ea3c3..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_fort.h +++ /dev/null @@ -1,903 +0,0 @@ -/* -Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3DX_CLAWPATCH_FORT_H -#define FCLAW3DX_CLAWPATCH_FORT_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct fclaw2d_global; -struct fclaw2d_patch; - -struct fclaw2d_patch_transform_data; /* Should be replaced by long int? */ - -/** - * @file - * Typedefs for clawpatch fortran functions - * - * Functions defined here are implemented in individual solvers (clawpack 4.6 and - * clawpack 5.0) - */ - -#if 0 -/* Fix syntax highlighting */ -#endif - -/** @{ @name Ghost filling - patch specific *//*----------------------------------------*/ - -/** - * @brief Copies ghost data from a face-neighboring grid on the same level - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in,out] qthis the solution of this patch - * @param[in] qneighbor the solution of the neighbor patch - * @param[in] iface the interface that the neighbor is on - * @param[in] transform_ptr Encoding for indices at block boundaries (C only). - */ -typedef void (*fclaw3dx_clawpatch_fort_copy_face_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qthis[], - double qneighbor[], - const int* iface, - struct fclaw2d_patch_transform_data** transform_ptr); - -/** - * @brief Averages values from a face-neighboring fine grid - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in,out] qcoarse the solution of this patch - * @param[in] qfine the solution of the fine neighbor patch - * @param[in] areacoarse the area of cells in this patch - * @param[in] areafine the area of cells in the fine neighbor patch - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] iside the interface of the fine neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refratio the refinement ratio - * @param[in] igrid the index of the fine neighbor in the child array - * @param[in] manifold true if using mainifold - * @param[in] transform_ptr Encoding for indices at block boundaries (C only). - */ -typedef void (*fclaw3dx_clawpatch_fort_average_face_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* idir, - const int* iside, - const int* num_neighbors, - const int* refratio, - const int* igrid, - const int* manifold, - struct fclaw2d_patch_transform_data** transform_ptr); -/** - * @brief Interpolates values from a face-neighboring coarse grid - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] qcoarse the solution of the coarse neighbor patch - * @param[in,out] qfine the solution of this patch - * @param[in] areacoarse the area of cells in the coarse neighbor patch - * @param[in] arefine the area of cells in the this patch - * @param[in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] - * @param[in] iface_coarse the interface of the coarse neighbor patch - * @param[in] num_neighbors the number of neighbors - * @param[in] refratio the refinement ratio - * @param[in] igrid the index of this patch in the child array - * @param[in] transform_ptr Encoding for indices at block boundaries (C only). - */ -typedef void (*fclaw3dx_clawpatch_fort_interpolate_face_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - const int* idir, - const int* iface_coarse, - const int* num_neighbors, - const int* refratio, - const int* igrid, - struct fclaw2d_patch_transform_data** transform_ptr); - -/** - * @brief Copies ghost data from a corner-neighboring grid on the same level - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in,out] qthis the solution of this patch - * @param[in] qneighbor the solution of the neighbor patch - * @param[in] icorner_coarse the corner of the coarse patch to copy from - * @param[in] transform_ptr Encoding for indices at block boundaries (C only). - */ -typedef void (*fclaw3dx_clawpatch_fort_copy_corner_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qthis[], - double qneighbor[], - const int* icorner_coarse, - struct fclaw2d_patch_transform_data** transform_ptr); - -/** - * @brief Averages values from a corner neighboring fine grid - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in,out] qcoarse the solution of this patch - * @param[in] qfine the solution of the fine neighbor patch - * @param[in] areacoarse the area of cells in this patch - * @param[in] arefine the area of cells in the fine neighbor patch - * @param[in] manifold true if using mainifold - * @param[in] a_corner the corner that the neighbor is on - * @param[in] transform_ptr Encoding for indices at block boundaries (C only). - */ -typedef void (*fclaw3dx_clawpatch_fort_average_corner_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const int* a_refratio, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* manifold, - const int* a_corner, - struct fclaw2d_patch_transform_data** transform_ptr); - -/** - * @brief Interpolates values form a corner-neighboring coarse grid - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] refratio the refinement ratio - * @param[in] qcoarse the solution of the coarse patch - * @param[in,out] qfine the solution of the fine patch - * @param[in] icorner_coarse the corner of the coarse neighbor that to interpolate from - * @param[in] transform_ptr Encoding for indices at block boundaries (C only). - */ -typedef void (*fclaw3dx_clawpatch_fort_interpolate_corner_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const int* refratio, - double qcoarse[], - double qfine[], - const int* icorner_coarse, - struct fclaw2d_patch_transform_data** transform_ptr); - -/** @} */ - -/** @{ @name Regridding Functions *//*--------------------------------------------------*/ - -/** - * @brief Tags a patch for refinement. - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] xlower, ylower, zlower the coordinate of the lower bottom left corner - * @param[in] dx, dy, dz spacing of cells in the x, y, and z directions - * @param[in] blockno the block number - * @param[in] q the solution - * @param[in] tag_threshold the threshold for tagging - * @param[in] init_flag true if in initialization stage - * @param[out] tag_patch true if patch should be refined - */ -typedef void (*fclaw3dx_clawpatch_fort_tag4refinement_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const double* xlower, - const double* ylower, - const double* zlower, - const double* dx, - const double* dy, - const double* dz, - const int* blockno, - double q[], - const double* tag_threshold, - const int* init_flag, - int* tag_patch); -/** - * @brief Tags a quad of patches for coarsening. - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] xlower, ylower, zlower the coordinate of the lower bottom left corner - * @param[in] dx, dy, dz spacing of cells in the x, y, and z directions - * @param[in] blockno the block number - * @param[in] q1, q2, q3, q4 the solutions on the patches - * @param[in] tag_threshold the threshold for tagging - * @param[in] init_flag true if in initialization stage - * @param[out] tag_patch true if patches should be coarsened - */ -typedef void (*fclaw3dx_clawpatch_fort_tag4coarsening_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double xlower[], - double ylower[], - double zlower[], - const double* dx, - const double* dy, - const double* dz, - const int* blockno, - double q0[], - double q1[], - double q2[], - double q3[], - const double* tag_threshold, - const int* init_flag, - int* tag_patch); - -/** - * @deprecated Checks if solution exceeds a threshold - */ -typedef int (*fclaw3dx_clawpatch_fort_exceeds_threshold_t)(const int *blockno, - const int* meqn, - const double *qval, - const double *qmin, - const double *qmax, - const double quad[], - const double *dx, - const double *dy, - const double *dz, - const double *xc, - const double *yc, - const double *zc, - const int* ivar_variable, - const double *tag_threshold, - const int *init_flag, - const int *is_ghost); - -/** - * @brief Averages a fine patch to a coarse patch - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] qcoarse the coarse solution - * @param[out] qfine the fine solution - * @param[in] areacoarse the area of the coarse cells - * @param[in] areafine the area of the fine cells - * @param[in] igrid the index of the fine patch in the siblings array - * @param[in] manifold true if using manifold - */ -typedef void (*fclaw3dx_clawpatch_fort_interpolate2fine_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* igrid, - const int* manifold); - -/** - * @brief Interpolates from a coarse patch to a fine patche - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] qcoarse the coarse solution - * @param[out] qfine the fine solution - * @param[in] areacoarse the area of the coarse cells - * @param[in] areafine the area of the fine cells - * @param[in] igrid the index of the fine patch in the siblings array - * @param[in] manifold true if using manifold - */ -typedef void (*fclaw3dx_clawpatch_fort_average2coarse_t)(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* igrid, - const int* manifold); - - -/** @} */ - -/** @{ @name time stepping *//*---------------------------------------------------------*/ - -/** - * @brief Interpolates q between timesteps. - * - * This only needs to interpolate the interior cells that are needed for ghost cells on - * neighboring patches - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] psize the total number cells that should be interpolated - * @param[in] qcurr the current q - * @param[in] qlast the previous q - * @param[out] qinterp the inerpolated q - * @param[in] alpha where to interpolate between qlast and qcurr - * @param[out] ierror error value - */ -typedef void (*fclaw3dx_clawpatch_fort_timeinterp_t)(const int *mx, - const int* my, - const int* mz, - const int* mbc, - const int *meqn, - const int* psize, - double qcurr[], - double qlast[], - double qinterp[], - const double* alpha, - const int* ierror); - -/** @} */ - -/** @{ @name Parallel ghost patches *//*------------------------------------------------*/ - -/** - * @brief Packs/Unpacks ghost cell data - * - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] mint the number of internal cells to include - * @param[in,out] qdata the solution - * @param[in,out] area the area of each cell - * @param[in,out] qpack the buffer to pack from/to - * @param[in] psize the size of qpack buffer - * @param[in] packmode the packing mode (0 for packing q, 1 for unpacking q, - * 2 for packing q and area, and 3 for unpacking q and area) - * @param[out] ierror the error value - */ -typedef void (*fclaw3dx_clawpatch_fort_local_ghost_pack_t)(const int *mx, - const int *my, - const int *mz, - const int *mbc, - const int *meqn, - const int *mint, - double qdata[], - double area[], - double qpack[], - const int *psize, - const int *packmode, - int *ierror); - -/** @} */ - -/** @{ @name Output functions *//*------------------------------------------------------*/ - -/** - * @brief Outputs the header for the time file and leaves and empty data file - * - * @param[in] matname1 name of the data file - * @param[in] matname2 name of the time file - * @param[in] time the time - * @param[in] meqn the number of equations - * @param[in] maux the number of aux equations - * @param[in] ngrids the number of grids (patches) - */ -typedef void (*fclaw3dx_clawpatch_fort_header_ascii_t)(const char* matname1, - const char* matname2, - const double* time, - const int* meqn, - const int* maux, - const int* ngrids); - -/** - * @brief Writes out patch data in ascii format. - * - * This should append the data to the file - * - * @param[in] matname1 the name of the data file - * @param[in] mx, my, mz the number cells in the x, y, and z directions, excluding ghost - * @param[in] meqn the number of equations - * @param[in] mbc the number of ghost cells - * @param[in] xlower, ylower, zlower the coordinate of the lower bottom left corner - * @param[in] dx, dy spacing of cells in the x, y, and z directions - * @param[in] q the solution - * @param[in] pach_num the patch number - * @param[in] level the level of the patch - * @param[in] blockno the block number - * @param[in] mpirank the mpi rank of the patch - */ -typedef void (*fclaw3dx_clawpatch_fort_output_ascii_t)(char* matname1, - int* mx, - int* my, - int* mz, - int* meqn, - int* mbc, - double* xlower, - double* ylower, - double* zlower, - double* dx, - double* dy, - double* dz, - double q[], - int* patch_num, - int* level, - int* blockno, - int* mpirank); - - -/** @} */ - -/** @{ @name Diagnostic functions *//*--------------------------------------------------*/ - -/** - * @brief Calculates the error for cells in a patch - * - * @param[in] blockno the block number - * @param[in] mx, my, mz the number cells in the x and y directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] dx, dy, dz spacing of cells in the x and y directions - * @param[in] xlower, ylower, zlower the coordinate of the lower left corner - * @param[in] q the computed solution - * @param[out] error the error for each meqn in each cell - * @param[in] soln the exact solution - */ -typedef void (*fclaw3dx_clawpatch_fort_error_t)(int* blockno, - int *mx, - int *my, - int* mz, - int *mbc, - int *meqn, - double *dx, - double *dy, - double* dz, - double *xlower, - double *ylower, - double *zlower, - double *t, - double q[], - double error[], - double soln[]); -/** - * @brief Calculates a sum for each equation - * - * @param[in] mx, my, mz the number cells in the x and y directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] dx, dy, dz spacing of cells in the x and y directions - * @param[in] area the area for each cell - * @param[in] q the computed solution - * @param[in,out] sum the current sum for each equaiton - * @param[in,out] c_kahan the the current c values for the Kahan summation algorithm - */ -typedef void (*fclaw3dx_clawpatch_fort_conscheck_t)(int *mx, - int *my, - int *mz, - int* mbc, - int* meqn, - double *dx, - double *dy, - double* dz, - double area[], - double q[], - double sum[], - double *c_kahan); - -/** - * @brief Calculates the area of a patch - * - * @param[in] mx, my, mz the number cells in the x and y directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] dx, dy, dz spacing of cells in the x and y directions - * @param[in] area array of area values for cells - * @return the total area of the patch - */ -typedef double (*fclaw3dx_clawpatch_fort_area_t)(int *mx, - int* my, - int* mz, - int *mbc, - double *dx, - double** dy, - double *dz, - double area[]); - -/** - * @brief Calculates the error norms for a patch - * - * @param[in] blockno the block number - * @param[in] mx, my the number cells in the x and y directions, excluding ghost - * @param[in] mbc the number of ghost cells - * @param[in] meqn the number of equations - * @param[in] dx, dy, dz spacing of cells in the x and y directions - * @param[in] area array of area values for cells - * @param[in] error error array - * @param[out] error_norm a 2d array of l1, l2, and inf norms for each eqn - */ -typedef void (*fclaw3dx_clawpatch_fort_norm_t)(int* blockno, - int *mx, - int *my, - int* mz, - int *mbc, - int *meqn, - double *dx, - double *dy, - double *dz, - double area[], - double error[], - double error_norm[]); - -/** @} */ - -/** - * @brief Checks if solution exceeds a threshold - */ -typedef int (*fclaw3dx_fort_exceeds_threshold_t)(const int *blockno, - const int* meqn, - const double *qval, - const double *qmin, - const double *qmax, - const double quad[], - const double *dx, - const double *dy, - const double *dz, - const double *xc, - const double *yc, - const double *zc, - const int* ivar_threshold, - const double *tag_threshold, - const int *init_flag, - const int *is_ghost); - - -/** @{ @name Fortran Headers *//*-------------------------------------------------------*/ - -/** @brief Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH_GET_REFINEMENT_CRITERIA \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch_get_refinement_criteria, \ - FCLAW3DX_CLAWPATCH_GET_REFINEMENT_CRITERIA) -/** @brief C declaration of fclaw3dx_clawpatch_get_refinement_critera() subroutine */ -int FCLAW3DX_CLAWPATCH_GET_REFINEMENT_CRITERIA(); - - -/* ------------------------------- General threshold ---------------------------------- */ - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH_TAG_CRITERIA \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch_tag_criteria, \ - FCLAW3DX_CLAWPATCH_TAG_CRITERIA) - -/** - * @brief Check if the refinment threshold is exceeded - * - * @param[in] blockno the block number - * @param[in] qval the - * @param[in] qmin the minimum q value - * @param[in] qmax the maximum q value - * @param[in] quad the value and adjacent values of q - * @param[in] dx, dy the spacing in the x and y directions - * @param[in] xc, yc the coordinate of the cell - * @param[in] threshold the threshold - * @param[in] init_flag true if in init stage - * @param[in] is_ghost true if cell is a ghost cell - * @return 1 if exceeds threshold, 0 if not, -1 if inconclusive. - */ -int FCLAW3DX_CLAWPATCH_TAG_CRITERIA(const int *blockno, - const double *qval, - const double *qmin, - const double *qmax, - const double quad[], - const double *dx, - const double *dy, - const double *dz, - const double *xc, - const double *yc, - const double *zc, - const double *tag_threshold, - const int *init_flag, - const int *is_ghost); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH_EXCEEDS_THRESHOLD \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch_exceeds_threshold, \ - FCLAW3DX_CLAWPATCH_EXCEEDS_THRESHOLD) - -/** - * @brief Check if the refinment threshold is exceeded - * - * @param[in] blockno the block number - * @param[in] qval the - * @param[in] qmin the minimum q value - * @param[in] qmax the maximum q value - * @param[in] quad the value and adjacent values of q - * @param[in] dx, dy the spacing in the x and y directions - * @param[in] xc, yc the coordinate of the cell - * @param[in] threshold the threshold - * @param[in] init_flag true if in init stage - * @param[in] is_ghost true if cell is a ghost cell - * @return 1 if exceeds threshold, 0 if not, -1 if inconclusive. - */ -int FCLAW3DX_CLAWPATCH_EXCEEDS_THRESHOLD(const int *blockno, - const int* meqn, - const double *qval, - const double *qmin, - const double *qmax, - const double quad[], - const double *dx, - const double *dy, - const double *dz, - const double *xc, - const double *yc, - const double *zc, - const int* ivar_variable, - const double *tag_threshold, - const int *init_flag, - const int *is_ghost); - - -/* ----------------------------- Value threshold -------------------------------------- */ -/** @brief C declaration of fclaw2d_clawpatch_value_exceeds_th() subroutine */ -#define FCLAW3DX_CLAWPATCH_VALUE_EXCEEDS_TH \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch_value_exceeds_th, \ - FCLAW3DX_CLAWPATCH_VALUE_EXCEEDS_TH) - -/** @brief C declaration of fclaw3dx_clawpatch_value_exceeds_th() subroutine */ -int FCLAW3DX_CLAWPATCH_VALUE_EXCEEDS_TH(const int* blockno, - const int* meqn, - const double *qval, - const double* qmin, - const double *qmax, - const double quad[], - const double *dx, - const double *dy, - const double *dz, - const double *xc, - const double *yc, - const double *zc, - const int* ivar_variable, - const double* tag_threshold, - const int* init_flag, - const int* is_ghost); - -/* ----------------------------- difference threshold --------------------------------- */ - -/** @brief C declaration of fclaw3dx_clawpatch_difference_exceeds_th() subroutine */ -#define FCLAW3DX_CLAWPATCH_DIFFERENCE_EXCEEDS_TH \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch_difference_exceeds_th, \ - FCLAW3DX_CLAWPATCH_DIFFERENCE_EXCEEDS_TH) - -/** @brief C declaration of fclaw3dx_clawpatch_difference_exceeds_th() subroutine */ -int FCLAW3DX_CLAWPATCH_DIFFERENCE_EXCEEDS_TH(const int *blockno, - const int *meqn, - const double *qval, - const double *qmin, - const double *qmax, - const double quad[], - const double *dx, - const double *dy, - const double *dz, - const double *xc, - const double *yc, - const double *zc, - const int* ivar_variable, - const double *tag_threshold, - const int *init_flag, - const int *is_ghost); - -/* --------------------------------- minmax threshold --------------------------------- */ - -/** @brief C declaration of fclaw3dx_clawpatch_minmax_exceeds_th() subroutine */ -#define FCLAW3DX_CLAWPATCH_MINMAX_EXCEEDS_TH \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch_minmax_exceeds_th, \ - FCLAW3DX_CLAWPATCH_MINMAX_EXCEEDS_TH) - -/** @brief C declaration of fclaw3dx_clawpatch_minmax_exceeds_th() subroutine */ -int FCLAW3DX_CLAWPATCH_MINMAX_EXCEEDS_TH(const int *blockno, - const int* meqn, - const double *qval, - const double* qmin, - const double *qmax, - const double quad[], - const double *dx, - const double *dy, - const double *dz, - const double *xc, - const double *yc, - const double *zc, - const int* ivar_variable, - const double *tag_threshold, - const int *init_flag, - const int *is_ghost); - -/* ------------------------------- gradient threshold --------------------------------- */ -/** @brief C declaration of fclaw3dx_clawpatch_gradient_exceeds_th() subroutine */ -#define FCLAW3DX_CLAWPATCH_GRADIENT_EXCEEDS_TH \ - FCLAW_F77_FUNC(fclaw3dx_clawpatch_gradient_exceeds_th, \ - FCLAW3DX_CLAWPATCH_GRADIENT_EXCEEDS_TH) - -/** @brief C declaration of fclaw3dx_clawpatch_gradient_exceeds_th() subroutine */ -int FCLAW3DX_CLAWPATCH_GRADIENT_EXCEEDS_TH(const int *blockno, - const int* meqn, - const double *qval, - const double* qmin, - const double *qmax, - const double quad[], - const double *dx, - const double *dy, - const double *dz, - const double *xc, - const double *yc, - const double *zc, - const int* ivar_variable, - const double *tag_threshold, - const int *init_flag, - const int *is_ghost); - - -/* ------------------------------- user threshold --------------------------------- */ -/** Fortran subroutine name */ -#define FCLAW3DX_USER_EXCEEDS_TH FCLAW_F77_FUNC( \ - fclaw3dx_user_exceeds_th, \ - FCLAW3DX_USER_EXCEEDS_TH) - -/** @brief C declaration of user_exceeds_th() subroutine */ -int FCLAW3DX_USER_EXCEEDS_TH(const int *blockno, - const int* meqn, - const double *qval, - const double* qmin, - const double *qmax, - const double quad[], - const double *dx, - const double *dy, - const double *dz, - const double *xc, - const double *yc, - const double *zc, - const int* ivar_variable, - const double *tag_threshold, - const int *init_flag, - const int *is_ghost); - -/* -------------------------- User convenience headers -------------------------------- */ - -/** Fortran subroutine name */ -#define FCLAW3DX_USER_TAG4REFINEMENT FCLAW_F77_FUNC( \ - fclaw3dx_user_tag4refinement, FCLAW3DX_USER_TAG4REFINEMENT) -/** - * @brief C declaration of user defined tag4refinement subroutine, see - * ::clawpatch_fort_tag4refinement_t - */ -void FCLAW3DX_USER_TAG4REFINEMENT(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const double* xlower, - const double* ylower, - const double* zlower, - const double* dx, - const double* dy, - const double* dz, - const int* blockno, - double q[], - const double* tag_threshold, - const int* init_flag, - int* tag_patch); - -/** Fortran subroutine name */ -#define FCLAW3DX_USER_TAG4COARSENING FCLAW_F77_FUNC( \ - fclaw3dx_user_tag4coarsening, FCLAW3DX_USER_TAG4COARSENING) -/** - * @brief C declaration of user defined tag4coarsening subroutine, see - * ::clawpatch_fort_tag4coarsening_t - */ -void FCLAW3DX_USER_TAG4COARSENING(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - const double* xlower, - const double* ylower, - const double* zlower, - const double* dx, - const double* dy, - const double* dz, - const int* blockno, - double q0[], - double q1[], - double q2[], - double q3[], - const double* tag_threshold, - const int* initflag, - int* tag_patch); - - -/* ----------------------------- interpolation/coarsening ----------------------------- */ - -/** Fortran subroutine name */ -#define FCLAW3DX_USER_INTERPOLATE2FINE FCLAW_F77_FUNC(\ - fclaw3dx_user_interpolate2fine, FCLAW3DX_USER_INTERPOLATE2FINE) -/** - * @brief C declaration of user defined interpolate2fine subroutine, - * see ::clawpatch_fort_interpolate2fine_t - */ -void FCLAW3DX_USER_INTERPOLATE2FINE(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* igrid, - const int* manifold); - -/** Fortran subroutine name */ -#define FCLAW3DX_USER_AVERAGE2COARSE FCLAW_F77_FUNC(\ - fclaw3dx_user_average2coarse, FCLAW3DX_USER_AVERAGE2COARSE) -/** - * @brief C declaration of user defined average2coarse subroutine, - * see ::clawpatch_fort_average2coarse_t - */ -void FCLAW3DX_USER_AVERAGE2COARSE(const int* mx, - const int* my, - const int* mz, - const int* mbc, - const int* meqn, - double qcoarse[], - double qfine[], - double areacoarse[], - double areafine[], - const int* igrid, - const int* manifold); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_options.c b/src/patches/clawpatch/fclaw3dx_clawpatch_options.c deleted file mode 100644 index c4b4c0aba..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_options.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define REFINE_DIM 2 -#define PATCH_DIM 3 - -#include \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_output_ascii.c b/src/patches/clawpatch/fclaw3dx_clawpatch_output_ascii.c deleted file mode 100644 index 6bd53136f..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_output_ascii.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define REFINE_DIM 2 -#define PATCH_DIM 3 - -#include diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_output_ascii.h b/src/patches/clawpatch/fclaw3dx_clawpatch_output_ascii.h deleted file mode 100644 index 07b1f48ba..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_output_ascii.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3DX_CLAWPATCH_OUTPUT_ASCII_H -#define FCLAW3DX_CLAWPATCH_OUTPUT_ASCII_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct fclaw2d_global; -struct fclaw2d_patch; -struct fclaw2d_domain; - -/** - * @file - * Routines for ascii output - */ - -/** - * @brief Callback called on each patch - * - * @param domain the domain context - * @param patch the patch context - * @param blockno the block number - * @param patchno the patch number - * @param user the user data pointer - */ -void fclaw3dx_clawpatch_output_ascii_cb (struct fclaw2d_domain * domain, - struct fclaw2d_patch * patch, - int blockno, int patchno, - void *user); - -/** - * @brief output ascii data - * - * @param glob the global context - * @param iframe the frame index - */ -void fclaw3dx_clawpatch_output_ascii(struct fclaw2d_global* glob,int iframe); - -/** - * @brief output ascii time header - * - * @param glob the global context - * @param iframe the frame index - */ -void fclaw3dx_clawpatch_time_header_ascii(struct fclaw2d_global* glob, int iframe); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_output_vtk.c b/src/patches/clawpatch/fclaw3dx_clawpatch_output_vtk.c deleted file mode 100644 index c13a2de64..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_output_vtk.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define REFINE_DIM 2 -#define PATCH_DIM 3 - -#include diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_pillow.c b/src/patches/clawpatch/fclaw3dx_clawpatch_pillow.c deleted file mode 100644 index c084e7bf5..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_pillow.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define REFINE_DIM 2 -#define PATCH_DIM 3 - -#include diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_transform.c b/src/patches/clawpatch/fclaw3dx_clawpatch_transform.c deleted file mode 100644 index 4065994e4..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_transform.c +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun, Scott Aiton -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define REFINE_DIM 2 -#define PATCH_DIM 3 - -#include diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_transform.h b/src/patches/clawpatch/fclaw3dx_clawpatch_transform.h deleted file mode 100644 index 1552c6418..000000000 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_transform.h +++ /dev/null @@ -1,137 +0,0 @@ -/* -Copyright (c) 2012 Carsten Burstedde, Donna Calhoun -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef FCLAW3DX_CLAWPATCH_TRANSFORM_H -#define FCLAW3DX_CLAWPATCH_TRANSFORM_H - -/** - * @file - * Transforms clawpatch indexes - */ - -#include /* Defines FCLAW_F77_FUNC */ - - -#ifdef __cplusplus -extern "C" -{ -#if 0 -} /* need this because indent is dumb */ -#endif -#endif - -struct fclaw2d_global; -struct fclaw2d_patch; /* fclaw2d_patch.h includes this file */ -/** Struture to store a patch's transform data */ -struct fclaw2d_patch_transform_data; - -/** - * @brief Initialize the patch's tranform data - * - * @param[in] glob the global context - * @param[in] this_patch the patch context - * @param[in] blockno the block number - * @param[in] patchno the patch number - * @param[in,out] transform the transform data - */ -void fclaw3dx_clawpatch_transform_init_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, - int blockno, int patchno, - struct fclaw2d_patch_transform_data* transform); - -/** @copydoc fclaw2d_patch_face_transformation() */ -void fclaw3dx_clawpatch_face_transformation (int faceno, int rfaceno, int ftransform[]); - -/** @copydoc fclaw2d_patch_face_transformation_intra() */ -void fclaw3dx_clawpatch_face_transformation_intra (int ftransform[]); - - -/* ----------------------------- Called from Fortran ---------------------------------- */ - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH_TRANSFORM_FACE FCLAW_F77_FUNC_(fclaw3dx_clawpatch_transform_face, \ - FCLAW3DX_CLAWPATCH_TRANSFORM_FACE) -/** - * @brief Tranform an index for a face-neighboring patch's coordinate system - * - * @param[in] i1, j1 the input index - * @param[out] i2, j2 the transformed equivalent index in the neighboring patch - * @param[in] ptdata the transform data - */ -void FCLAW3DX_CLAWPATCH_TRANSFORM_FACE (const int *i1, const int *j1, - int *i2, int *j2, - struct fclaw2d_patch_transform_data** ptdata); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH_TRANSFORM_FACE_HALF FCLAW_F77_FUNC_(fclaw3dx_clawpatch_transform_face_half, \ - FCLAW3DX_CLAWPATCH_TRANSFORM_FACE_HALF) -/** - * @brief Tranform an index for a face-neighboring finer patch's coordinate system - * - * @param[in] i1, j1 the input index - * @param[out] i2, j2 the four equivalent indexes in the finer patch - * @param[in] ptdata the transform data - */ -void FCLAW3DX_CLAWPATCH_TRANSFORM_FACE_HALF (const int *i1, const int *j1, - int i2[], int j2[], - struct fclaw2d_patch_transform_data** ptdata); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER FCLAW_F77_FUNC_(fclaw3dx_clawpatch_transform_corner, \ - FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER) -/** - * @brief Tranform an index for a face-neighboring patch's coordinate system - * - * @param[in] i1, j1 the input index - * @param[out] i2, j2 the transformed equivalent index in the neighboring patch - * @param[in] ptdata the transform data - */ -void FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER (const int *i1, const int *j1, - int *i2, int *j2, - struct fclaw2d_patch_transform_data** ptdata); - -/** Fortran subroutine name */ -#define FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER_HALF FCLAW_F77_FUNC_(fclaw3dx_clawpatch_transform_corner_half, \ - FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER_HALF) - -/** - * @brief Tranform an index for a corner-neighboring finer patch's coordinate system - * - * @param[in] i1, j1 the input index - * @param[out] i2, j2 the four equivalent indexes in the finer patch - * @param[in] ptdata the transform data - */ -void FCLAW3DX_CLAWPATCH_TRANSFORM_CORNER_HALF (const int *i1, const int *j1, - int i2[], int j2[], - struct fclaw2d_patch_transform_data** ptdata); - -#ifdef __cplusplus -#if 0 -{ /* need this because indent is dumb */ -#endif -} -#endif - -#endif /* !FCLAW3DX_CLAWPATCH_TRANSFORM_H */ diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_utils.f b/src/patches/clawpatch/fclaw3dx_clawpatch_utils.f index 06a804630..081370245 100644 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_utils.f +++ b/src/patches/clawpatch/fclaw3dx_clawpatch_utils.f @@ -31,21 +31,21 @@ subroutine fclaw3dx_clawpatch_build_transform(transform_ptr,a,f) i1 = 0 j1 = 0 - call fclaw3dx_clawpatch_transform_face_half(i1,j1,mi,mj, + call fclaw2d_clawpatch_transform_face_half(i1,j1,mi,mj, & transform_ptr) f(1) = mi(1) f(2) = mj(1) i1 = 1 j1 = 0 - call fclaw3dx_clawpatch_transform_face_half(i1,j1,mi,mj, + call fclaw2d_clawpatch_transform_face_half(i1,j1,mi,mj, & transform_ptr) a(1,1) = mi(1) - f(1) a(2,1) = mj(1) - f(2) i1 = 0 j1 = 1 - call fclaw3dx_clawpatch_transform_face_half(i1,j1,mi,mj, + call fclaw2d_clawpatch_transform_face_half(i1,j1,mi,mj, & transform_ptr) a(1,2) = mi(1) - f(1) a(2,2) = mj(1) - f(2) @@ -64,21 +64,21 @@ subroutine fclaw3dx_clawpatch_build_transform_same(transform_ptr,a i1 = 0 j1 = 0 - call fclaw3dx_clawpatch_transform_face(i1,j1,mi,mj, + call fclaw2d_clawpatch_transform_face(i1,j1,mi,mj, & transform_ptr) f(1) = mi(1) f(2) = mj(1) i1 = 1 j1 = 0 - call fclaw3dx_clawpatch_transform_face(i1,j1,mi,mj, + call fclaw2d_clawpatch_transform_face(i1,j1,mi,mj, & transform_ptr) a(1,1) = mi(1) - f(1) a(2,1) = mj(1) - f(2) i1 = 0 j1 = 1 - call fclaw3dx_clawpatch_transform_face(i1,j1,mi,mj, + call fclaw2d_clawpatch_transform_face(i1,j1,mi,mj, & transform_ptr) a(1,2) = mi(1) - f(1) a(2,2) = mj(1) - f(2) diff --git a/src/patches/clawpatch/fclaw_clawpatch.cpp b/src/patches/clawpatch/fclaw_clawpatch.cpp new file mode 100644 index 000000000..6e5daa438 --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch.cpp @@ -0,0 +1,2222 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include + +#include + +#include +#include + + +#include /* Needed to get enum for build modes */ + +#include +#include +#include +#include + +#include +#include + +#include + +#include + + + +/* ------------------------------- Static function defs ------------------------------- */ + +/* Added to turn off time_interp */ +static int fill_ghost(fclaw_global_t* glob, int time_interp) +{ + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); + if (fclaw_opt->timeinterp2fillghost) + /* This will always fill ghost cells using data from "qsync", which is either + coarse grid data at time step, or time interpolated data */ + return 1; + else + /* Only fill ghost cells with neighboring data if not doing time interpolation. + If doing time interpolation, then fine grid data at intermediate time steps + will be filled in some other way (.e.g. by advancing the solution in ghost + cells.) */ + return !time_interp; +} + + +/* Store virtual table for retrieval from anywhere */ + +static +fclaw_clawpatch_t* get_clawpatch(fclaw_patch_t *patch) +{ + fclaw_clawpatch_t *cp = (fclaw_clawpatch_t*) + fclaw_patch_get_user_patch(patch); + return cp; +} + +/* Needed for virtual patch function so that the metric class can be independent +of a clawpatch object */ +static +void* clawpatch_get_metric_patch_2d(fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + return cp->d2->mp; +} + +static +void* clawpatch_get_metric_patch_3d(fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + return cp->d3->mp; +} + +static +fclaw2d_metric_patch_t* get_metric_patch_2d(fclaw_patch_t *patch) +{ + return (fclaw2d_metric_patch_t*) clawpatch_get_metric_patch_2d(patch); +} + +static +fclaw3d_metric_patch_t* get_metric_patch_3d(fclaw_patch_t *patch) +{ + return (fclaw3d_metric_patch_t*) clawpatch_get_metric_patch_3d(patch); +} + +/* Return a pointer to either time interpolated data or regular grid data */ +static +double* q_time_sync(fclaw_patch_t* patch, int time_interp) +{ + fclaw_clawpatch_t* cp = get_clawpatch(patch); + if (time_interp) + return cp->griddata_time_interpolated.dataPtr(); + else + return cp->griddata.dataPtr(); +} + +static +double* clawpatch_get_area(struct fclaw_global* glob, + fclaw_patch_t* patch) +{ + return fclaw2d_metric_patch_get_area(glob, patch); +} + +static +double* clawpatch_get_volume(struct fclaw_global* glob, + fclaw_patch_t* patch) +{ + return fclaw3d_metric_patch_get_volume(glob, patch); +} + +/* ----------------------------- Creating/deleting patches ---------------------------- */ + +static +void* clawpatch_new(int dim) +{ + fclaw_clawpatch_t *cp = new fclaw_clawpatch_t; + if(dim == 2) + { + cp->patch_dim = 2; + cp->d2 = new fclaw_clawpatch_2d_t; + /* This patch will only be defined if we are on a manifold. */ + cp->d2->mp = fclaw2d_metric_patch_new(); + } + else + { + cp->patch_dim = 3; + cp->d3 = new fclaw_clawpatch_3d_t; + /* This patch will only be defined if we are on a manifold. */ + cp->d3->mp = fclaw3d_metric_patch_new(); + } + + return (void*) cp; +} + +static +void* clawpatch_new_2d() +{ + return clawpatch_new(2); +} + +static +void* clawpatch_new_3d() +{ + return clawpatch_new(3); +} + +static +void clawpatch_delete(void *patchcp) +{ + FCLAW_ASSERT(patchcp != NULL); + fclaw_clawpatch_t* cp = (fclaw_clawpatch_t*) patchcp; + + if(cp->patch_dim == 2) + { + fclaw2d_clawpatch_time_sync_delete(&cp->d2->registers); + + FCLAW_ASSERT(cp->d2->mp != NULL); + fclaw2d_metric_patch_delete(&cp->d2->mp); + + delete cp->d2; + } + else + { + FCLAW_ASSERT(cp->d3->mp != NULL); + fclaw3d_metric_patch_delete(&cp->d3->mp); + + delete cp->d3; + } + + delete cp; + patchcp = NULL; +} + +/* Maybe this should just be a 'build' function? */ +static +void clawpatch_define(fclaw_global_t* glob, + fclaw_patch_t *patch, + int blockno, int patchno, + fclaw_build_mode_t build_mode) +{ + /* We are getting closer to getting rid the class fclaw_clawpatch_t */ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + + cp->mx = clawpatch_opt->mx; + cp->my = clawpatch_opt->my; + cp->mz = clawpatch_opt->mz; + + cp->mbc = clawpatch_opt->mbc; + cp->blockno = blockno; + cp->meqn = clawpatch_opt->meqn; + cp->maux = clawpatch_opt->maux; + cp->mfields = clawpatch_opt->rhs_fields; + + for (int icorner=0; icorner < 4; icorner++) + { + fclaw_patch_set_block_corner_count(glob,patch,icorner,0); + } + + fclaw_map_context_t* cont = fclaw_map_get(glob); + + int is_brick = FCLAW_MAP_IS_BRICK(&cont); + + cp->manifold = fclaw_opt->manifold; + if (cp->manifold) + { + cp->xlower = patch->xlower; + cp->ylower = patch->ylower; + cp->zlower = patch->zlower; + cp->xupper = patch->xupper; + cp->yupper = patch->yupper; + cp->zupper = patch->zupper; + } + else + { + double ax = fclaw_opt->ax; + double bx = fclaw_opt->bx; + double ay = fclaw_opt->ay; + double by = fclaw_opt->by; + double az = fclaw_opt->az; + double bz = fclaw_opt->bz; + + double xl = patch->xlower; + double yl = patch->ylower; + double zl = patch->zlower; + double xu = patch->xupper; + double yu = patch->yupper; + double zu = patch->zupper; + + double xlower, ylower, zlower, xupper, yupper, zupper; + + if (is_brick) + { + if(glob->domain->refine_dim == 2) + { + /* Scale to [0,1]x[0,1], based on blockno */ + double z; + fclaw_map_2d_c2m_nomap_brick(cont,cp->blockno,xl,yl,&xlower,&ylower,&z); + fclaw_map_2d_c2m_nomap_brick(cont,cp->blockno,xu,yu,&xupper,&yupper,&z); + zlower = 0; + zupper = 1; + } + else + { + fclaw_map_3d_c2m_nomap_brick(cont,cp->blockno,xl,yl,zl,&xlower,&ylower,&zlower); + fclaw_map_3d_c2m_nomap_brick(cont,cp->blockno,xu,yu,zu,&xupper,&yupper,&zupper); + } + } + else + { + xlower = xl; + ylower = yl; + zlower = zl; + xupper = xu; + yupper = yu; + zupper = zu; + } + + cp->xlower = ax + (bx - ax)*xlower; + cp->xupper = ax + (bx - ax)*xupper; + cp->ylower = ay + (by - ay)*ylower; + cp->yupper = ay + (by - ay)*yupper; + cp->zlower = az + (bz - az)*zlower; + cp->zupper = az + (bz - az)*zupper; + } + + cp->dx = (cp->xupper - cp->xlower)/cp->mx; + cp->dy = (cp->yupper - cp->ylower)/cp->my; + cp->dz = (cp->zupper - cp->zlower)/cp->mz; + + + // bounds for 3d, even if 2d, z bounds will be ignored by Box constructor in 2d + int ll[3]; + int ur[3]; + for (int idir = 0; idir < 3; idir++) + { + ll[idir] = 1-cp->mbc; + } + ur[0] = cp->mx + cp->mbc; + ur[1] = cp->my + cp->mbc; + ur[2] = cp->mz + cp->mbc; + + Box box(ll,ur,cp->patch_dim); + + // This will destroy any existing memory n griddata. + cp->griddata.define(box, cp->meqn); + if (fclaw_opt->subcycle) + cp->griddata_time_interpolated.define(box, cp->meqn); + + if (fclaw_opt->compute_error) + { + cp->griderror.define(box,cp->meqn); + cp->exactsolution.define(box,cp->meqn); + } + + if (clawpatch_opt->maux > 0) + { + cp->aux.define(box,cp->maux); + if (clawpatch_opt->save_aux) + cp->aux_save.define(box,cp->maux); + } + + if (clawpatch_opt->rhs_fields > 0) + { + cp->rhs.define(box,cp->mfields); + if (fclaw_opt->compute_error) + { + cp->elliptic_error.define(box,cp->mfields); + cp->elliptic_soln.define(box,cp->mfields); + } + } + + if (fclaw_opt->manifold) + { + /* + Allocate space for all metric terms. + + Note: We pass in detailed info so that the metric patch + doesn't have to know about a clawpatch + */ + + if(cp->patch_dim == 2) + { + fclaw2d_metric_patch_define(glob,patch, + cp->mx, cp->my, cp->mbc, + cp->dx, cp->dy, + cp->xlower,cp->ylower, cp->xupper, cp->yupper, + blockno, patchno, build_mode); + } + else + { + fclaw3d_metric_patch_define(glob,patch, + cp->mx, cp->my, cp->mz, cp->mbc, + cp->dx, cp->dy, cp->dz, + cp->xlower,cp->ylower, cp->zlower, + cp->xupper, cp->yupper, cp->zupper, + blockno, patchno, build_mode); + } + } + + /* Build interface registers needed for conservation */ + if(cp->patch_dim == 2) + { + fclaw2d_clawpatch_time_sync_new(glob,patch, + blockno,patchno,&cp->d2->registers); + } + + if (build_mode != FCLAW_BUILD_FOR_UPDATE) + /* If we are building ghost patches, we don't need all the patch memory */ + return; + + cp->griddata_last.define(box, cp->meqn); + cp->griddata_save.define(box, cp->meqn); + +} + +static +void clawpatch_build(fclaw_global_t *glob, + fclaw_patch_t *patch, + int blockno, + int patchno, + void *user) +{ + fclaw_build_mode_t build_mode = *((fclaw_build_mode_t*) user); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t* clawpatch_opt = + fclaw_clawpatch_get_options(glob); + + /* Allocate space for all required arrays */ + clawpatch_define(glob,patch,blockno,patchno,build_mode); + + if (fclaw_opt->manifold) + { + /* Computes all metric terms : (xp,yp,zp,xd,yd,zd), + areas/volumes, basis vectors and (in 2d) curvatures + and surface normals. + + Note : Area/volume computations are expensive, since + they are all computed on finest levels + + Note : When building from fine, call routine below + where areas/volumes are averaged from fine patches */ + if(clawpatch_opt->patch_dim == 2) + { + fclaw2d_metric_patch_build(glob,patch,blockno,patchno); + } + else + { + fclaw3d_metric_patch_build(glob,patch,blockno,patchno); + } + } + + if(clawpatch_opt->patch_dim == 2) + { + /* Setup for conservation correction */ + fclaw2d_clawpatch_time_sync_setup(glob,patch,blockno,patchno); + } +} + +static +void clawpatch_build_from_fine(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + fclaw_patch_t *coarse_patch, + int blockno, + int coarse_patchno, + int fine0_patchno, + fclaw_build_mode_t build_mode) +{ + const fclaw_clawpatch_options_t* clawpatch_opt = + fclaw_clawpatch_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + clawpatch_define(glob,coarse_patch,blockno,coarse_patchno,build_mode); + + if (fclaw_opt->manifold) + { + /* Average areas/volume from fine grid to coarse grid */ + if(clawpatch_opt->patch_dim == 2) + { + fclaw2d_metric_patch_build_from_fine(glob,fine_patches,coarse_patch, + blockno,coarse_patchno, + fine0_patchno); + } + else + { + fclaw3d_metric_patch_build_from_fine(glob,fine_patches,coarse_patch, + blockno,coarse_patchno, + fine0_patchno); + } + } + + if(clawpatch_opt->patch_dim == 2) + { + /* Setup for conservation correction */ + fclaw2d_clawpatch_time_sync_setup(glob,coarse_patch,blockno,coarse_patchno); + } +} + + +/* -------------------------------- time stepping ------------------------------------- */ + +static +void clawpatch_save_step(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + cp->griddata_save = cp->griddata; + + /* Some aux arrays are time dependent, or contain part of the solution. In this case, + we should save the aux array in case we need to re-take a time step */ + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + if (clawpatch_opt->save_aux) + cp->aux_save = cp->aux; +} + + +static +void clawpatch_restore_step(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + cp->griddata = cp->griddata_save; + + /* Restore the aux array after before retaking a time step */ + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + if (clawpatch_opt->save_aux) + cp->aux = cp->aux_save; +} + +static +void clawpatch_setup_timeinterp(fclaw_global_t *glob, + fclaw_patch_t *patch, + double alpha) +{ + /* We use the pack size here to make sure we are setting + everything correctly; it isn't needed for memory + allocation */ + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + + int meqn = clawpatch_opt->meqn; + int mbc = clawpatch_opt->mbc; + int mint = clawpatch_opt->interp_stencil_width/2+1; + + int hole = (mx - 2*mint)*(my - 2*mint); /* Hole in center */ + int wg = mx*my; /* Whole grid but no ghost cells. + Ghost cells will be averaged from finer level. */ + if(clawpatch_opt->patch_dim == 3) + { + hole *= mz; + wg *= mz; + } + + FCLAW_ASSERT(hole >= 0); + + int psize = (wg - hole)*meqn; + FCLAW_ASSERT(psize > 0); + + /* Store time interpolated data that will be use in coarse grid + exchanges */ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + double *qlast = cp->griddata_last.dataPtr(); + double *qcurr = cp->griddata.dataPtr(); + double *qinterp = cp->griddata_time_interpolated.dataPtr(); + + int ierror; + + /* Do interpolation only on interior, since ghost cells in qcurr + are invalid and will lead to floating point exceptions. + We do a ghost cell update at the intermediate time level. The + neighboring fine grid will average to ghost cells of the interpolated + level, then the interpolated level is used to interpolate to fine grid + ghost cells. */ + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + if(clawpatch_opt->patch_dim == 2) + { + clawpatch_vt->d2->fort_timeinterp(&mx,&my,&mbc,&meqn,&psize, + qcurr,qlast,qinterp,&alpha,&ierror); + } + else + { + clawpatch_vt->d3->fort_timeinterp(&mx,&my,&mz, &mbc,&meqn,&psize, + qcurr,qlast,qinterp,&alpha,&ierror); + } +} + + +/* ------------------------------------- Ghost filling ------------------------------- */ + +static +void clawpatch_copy_face(fclaw_global_t *glob, + fclaw_patch_t *patch, + fclaw_patch_t *neighbor_patch, + int iface, + int time_interp, + fclaw_patch_transform_data_t *transform_data) + +{ + + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + + int mbc = clawpatch_opt->mbc; + + /* This routine might be called between two time-sync patches */ + int meqn; + double *qthis; + fclaw_clawpatch_timesync_data(glob,patch,time_interp,&qthis,&meqn); + + double *qneighbor; + fclaw_clawpatch_timesync_data(glob,neighbor_patch,time_interp,&qneighbor,&meqn); + + if (fill_ghost(glob,time_interp)) + { + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + if(clawpatch_opt->patch_dim == 2) + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + clawpatch_vt->d2->fort_copy_face(&mx,&my,&mbc,&meqn,qthis, + qneighbor,&iface,&transform_data); + + } + else + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_copy_face(&mx,&my,&mz,&mbc,&meqn,qthis, + qneighbor,&iface,&transform_data); + } + } +} + +static +void clawpatch_average_face(fclaw_global_t *glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, + int idir, + int iface_coarse, + int p4est_refineFactor, + int refratio, + int time_interp, + int igrid, + fclaw_patch_transform_data_t* transform_data) +{ + int meqn; + double *qcoarse; + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); + + + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); + int manifold = fclaw_opt->manifold; + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + + + if(clawpatch_opt->patch_dim == 2) + { + double *areacoarse = clawpatch_get_area(glob, coarse_patch); + double *areafine = clawpatch_get_area(glob, fine_patch); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + /* These will be empty for non-manifolds cases */ + clawpatch_vt->d2->fort_average_face(&mx,&my,&mbc,&meqn,qcoarse,qfine, + areacoarse,areafine, &idir,&iface_coarse, + &p4est_refineFactor, &refratio, + &igrid,&manifold,&transform_data); + } + else + { + double *volcoarse = clawpatch_get_volume(glob, coarse_patch); + double *volfine = clawpatch_get_volume(glob, fine_patch); + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_average_face(&mx,&my,&mz,&mbc,&meqn,qcoarse,qfine, + volcoarse,volfine, &idir,&iface_coarse, + &p4est_refineFactor, &refratio, + &igrid,&manifold,&transform_data); + } +} + +static +void clawpatch_interpolate_face(fclaw_global_t *glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, + int idir, + int iface_coarse, + int p4est_refineFactor, + int refratio, + int time_interp, + int igrid, + fclaw_patch_transform_data_t* transform_data) +{ + + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + + int meqn; + double *qcoarse; + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); + + int mbc = clawpatch_opt->mbc; + + if (fill_ghost(glob,time_interp)) + { + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + if(clawpatch_opt->patch_dim == 2) + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + clawpatch_vt->d2->fort_interpolate_face(&mx,&my,&mbc,&meqn,qcoarse,qfine,&idir, + &iface_coarse, &p4est_refineFactor, + &refratio,&igrid,&transform_data); + } + else + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_interpolate_face(&mx,&my,&mz, &mbc,&meqn,qcoarse,qfine, + &idir,&iface_coarse, &p4est_refineFactor, + &refratio,&igrid,&transform_data); + } + } +} + +static +void clawpatch_copy_edge(fclaw_global_t *glob, + fclaw_patch_t *patch, + fclaw_patch_t *edge_patch, + int coarse_blockno, + int fine_blockno, + int iedge, + int time_interp, + fclaw_patch_transform_data_t *transform_data) +{ + + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + + int meqn; + double *qthis; + fclaw_clawpatch_timesync_data(glob,patch,time_interp,&qthis,&meqn); + + double *qedge; + fclaw_clawpatch_timesync_data(glob,edge_patch,time_interp,&qedge,&meqn); + + if (fill_ghost(glob,time_interp)) + { + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + FCLAW_ASSERT(clawpatch_opt->patch_dim == 3); + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_copy_edge(&mx,&my,&mz, &mbc,&meqn,qthis,qedge, + &iedge, &transform_data); + } +} + +static +void clawpatch_average_edge(fclaw_global_t *glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, + int coarse_edge, + int time_interp, + fclaw_patch_transform_data_t* transform_data) +{ + int meqn; + double *qcoarse; + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); + + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + int manifold = fclaw_opt->manifold; + if (fill_ghost(glob,time_interp)) + { + int refratio = 2; + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + FCLAW_ASSERT(clawpatch_opt->patch_dim == 3); + /* These will be empty for non-manifolds cases */ + double *volcoarse = clawpatch_get_volume(glob, coarse_patch); + double *volfine = clawpatch_get_volume(glob, fine_patch); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_average_edge(&mx,&my,&mz,&mbc,&meqn, + &refratio,qcoarse,qfine, + volcoarse,volfine, + &manifold,&coarse_edge,&transform_data); + } +} + +static +void clawpatch_interpolate_edge(fclaw_global_t *glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, + int coarse_edge, + int time_interp, + fclaw_patch_transform_data_t* transform_data) +{ + int meqn; + double *qcoarse; + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); + + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + + if (fill_ghost(glob,time_interp)) + { + int refratio = 2; + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + FCLAW_ASSERT(clawpatch_opt->patch_dim == 3); + /* These will be empty for non-manifolds cases */ + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_interpolate_edge(&mx,&my,&mz,&mbc,&meqn, + &refratio,qcoarse,qfine, + &coarse_edge,&transform_data); + } +} + +static +void clawpatch_copy_corner(fclaw_global_t *glob, + fclaw_patch_t *patch, + fclaw_patch_t *corner_patch, + int coarse_blockno, + int fine_blockno, + int icorner, + int time_interp, + fclaw_patch_transform_data_t *transform_data) +{ + + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + + int meqn; + double *qthis; + fclaw_clawpatch_timesync_data(glob,patch,time_interp,&qthis,&meqn); + + double *qcorner; + fclaw_clawpatch_timesync_data(glob,corner_patch,time_interp,&qcorner,&meqn); + + if (fill_ghost(glob,time_interp)) + { + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + if(clawpatch_opt->patch_dim == 2) + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + clawpatch_vt->d2->fort_copy_corner(&mx,&my,&mbc,&meqn,qthis,qcorner, + &icorner, &transform_data); + } + else + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_copy_corner(&mx,&my,&mz, &mbc,&meqn,qthis,qcorner, + &icorner, &transform_data); + } + } +} + + +static +void clawpatch_average_corner(fclaw_global_t *glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, + int coarse_blockno, + int fine_blockno, + int coarse_corner, + int time_interp, + fclaw_patch_transform_data_t* transform_data) +{ + int meqn; + double *qcoarse; + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); + + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + int manifold = fclaw_opt->manifold; + if (fill_ghost(glob,time_interp)) + { + int refratio = 2; + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + + if(clawpatch_opt->patch_dim == 2) + { + double *areacoarse = clawpatch_get_area(glob, coarse_patch); + double *areafine = clawpatch_get_area(glob, fine_patch); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + /* These will be empty for non-manifolds cases */ + clawpatch_vt->d2->fort_average_corner(&mx,&my,&mbc,&meqn, + &refratio,qcoarse,qfine, + areacoarse,areafine, + &manifold,&coarse_corner,&transform_data); + } + else + { + /* These will be empty for non-manifolds cases */ + double *volcoarse = clawpatch_get_volume(glob, coarse_patch); + double *volfine = clawpatch_get_volume(glob, fine_patch); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_average_corner(&mx,&my,&mz,&mbc,&meqn, + &refratio,qcoarse,qfine, + volcoarse,volfine, + &manifold,&coarse_corner,&transform_data); + } + } +} + +static +void clawpatch_interpolate_corner(fclaw_global_t* glob, + fclaw_patch_t* coarse_patch, + fclaw_patch_t* fine_patch, + int coarse_blockno, + int fine_blockno, + int coarse_corner, + int time_interp, + fclaw_patch_transform_data_t* transform_data) + +{ + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + + int meqn; + double *qcoarse; + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); + + if (fill_ghost(glob,time_interp)) + { + int refratio = 2; + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + if(clawpatch_opt->patch_dim == 2) + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + clawpatch_vt->d2->fort_interpolate_corner(&mx,&my,&mbc,&meqn, + &refratio,qcoarse,qfine, + &coarse_corner,&transform_data); + } + else + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_interpolate_corner(&mx,&my,&mz,&mbc,&meqn, + &refratio,qcoarse,qfine, + &coarse_corner,&transform_data); + } + } + +} + + + +/* -------------------------------- Regridding functions ------------------------------ */ + +static +int clawpatch_tag4refinement(fclaw_global_t *glob, + fclaw_patch_t *patch, + int blockno, int patchno, + int initflag) +{ + int meqn; + double *q; + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); + + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + double refine_threshold = fclaw_opt->refine_threshold; + + int tag_patch; + if (refine_threshold < 0) + { + /* Always refine */ + tag_patch = 1; + } + else + { + tag_patch = 0; + + /* This allows the user to specify a "exceeds_th" */ + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + + fclaw_global_set_static(glob); + if(clawpatch_vt->patch_dim == 2) + { + + int mx,my,mbc; + double xlower,ylower,dx,dy; + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, + &xlower,&ylower,&dx,&dy); + clawpatch_vt->d2->fort_tag4refinement(&mx,&my,&mbc,&meqn,&xlower,&ylower, + &dx,&dy, &blockno, q, + &refine_threshold, + &initflag,&tag_patch); + } + else + { + int mx,my,mz,mbc; + double xlower,ylower,zlower,dx,dy,dz; + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, &mbc, + &xlower,&ylower,&zlower, &dx,&dy,&dz); + + clawpatch_vt->d3->fort_tag4refinement(&mx,&my,&mz, &mbc,&meqn, + &xlower,&ylower,&zlower, + &dx,&dy, &dz, &blockno, q, + &refine_threshold, + &initflag,&tag_patch); + } + fclaw_global_clear_static(); + } + return tag_patch; +} + +static +int clawpatch_tag4coarsening(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + int blockno, + int patchno, + int initflag) +{ + const int num_children = fclaw_domain_num_siblings(glob->domain); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + int mx,my,mz,mbc,meqn; + double xlower[num_children],ylower[num_children],zlower[num_children]; + double dx,dy,dz; + + double *q[num_children]; + for (int igrid = 0; igrid < num_children; igrid++) + { + fclaw_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); + if(clawpatch_vt->patch_dim == 2) + { + fclaw_clawpatch_2d_grid_data(glob,&fine_patches[igrid],&mx,&my,&mbc, + &xlower[igrid],&ylower[igrid],&dx,&dy); + } + else + { + /* For extruded meshes, zlower is the same for all patches. */ + fclaw_clawpatch_3d_grid_data(glob,&fine_patches[igrid],&mx,&my,&mz,&mbc, + &xlower[igrid],&ylower[igrid],&zlower[igrid],&dx,&dy,&dz); + } + } + + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + double coarsen_threshold = fclaw_opt->coarsen_threshold; + + int tag_patch = 0; + if (coarsen_threshold > 0) + { + fclaw_global_set_static(glob); + if(clawpatch_vt->patch_dim == 2) + { + /* Get xlower,ylower for each grid. */ + clawpatch_vt->d2->fort_tag4coarsening(&mx,&my,&mbc,&meqn, + xlower,ylower,&dx,&dy, + &blockno, q[0],q[1],q[2],q[3], + &coarsen_threshold,&initflag,&tag_patch); + } + else if(glob->domain->refine_dim == 2) + { + clawpatch_vt->d3->fort_tag4coarsening_3dx(&mx,&my,&mz,&mbc,&meqn, + xlower,ylower,zlower,&dx,&dy,&dz, + &blockno, q[0],q[1],q[2],q[3], + &coarsen_threshold,&initflag,&tag_patch); + } + else + { + clawpatch_vt->d3->fort_tag4coarsening(&mx,&my,&mz,&mbc,&meqn, + xlower,ylower,zlower,&dx,&dy,&dz, + &blockno, q[0],q[1],q[2],q[3], + q[4],q[5],q[6],q[7], + &coarsen_threshold,&initflag,&tag_patch); + } + fclaw_global_clear_static(); + } + else + { + /* Never coarsen */ + } + return tag_patch == 1; +} + +static +void clawpatch_interpolate2fine(fclaw_global_t* glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t* fine_patches, + int this_blockno, int coarse_patchno, + int fine0_patchno) +{ + + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + int meqn = clawpatch_opt->meqn; + + /* Loop over four siblings (z-ordering) */ + for (int igrid = 0; igrid < fclaw_domain_num_siblings(glob->domain); igrid++) + { + fclaw_patch_t *fine_patch = &fine_patches[igrid]; + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); + + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); + + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + + + double *qcoarse = fclaw_clawpatch_get_q(glob,coarse_patch); + + if(clawpatch_opt->patch_dim == 2) + { + double *areacoarse = clawpatch_get_area(glob, coarse_patch); + double *areafine = NULL; + if (fclaw_opt->manifold) + areafine = clawpatch_get_area(glob, fine_patch); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + clawpatch_vt->d2->fort_interpolate2fine(&mx,&my,&mbc,&meqn,qcoarse,qfine, + areacoarse, areafine, &igrid, + &fclaw_opt->manifold); + } + else + { + double *volcoarse = clawpatch_get_volume(glob, coarse_patch); + double *volfine = NULL; + if (fclaw_opt->manifold) + volfine = clawpatch_get_volume(glob, fine_patch); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_interpolate2fine(&mx,&my,&mz, &mbc,&meqn,qcoarse,qfine, + volcoarse, volfine, &igrid, + &fclaw_opt->manifold); + } + } +} + +static +void clawpatch_average2coarse(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + fclaw_patch_t *coarse_patch, + int blockno, int fine0_patchno, + int coarse_patchno) + +{ + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + int meqn = clawpatch_opt->meqn; + + + for(int igrid = 0; igrid < fclaw_domain_num_siblings(glob->domain); igrid++) + { + fclaw_patch_t *fine_patch = &fine_patches[igrid]; + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); + double *qcoarse = fclaw_clawpatch_get_q(glob,coarse_patch); + + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); + + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + + + if(clawpatch_opt->patch_dim == 2) + { + double *areacoarse = clawpatch_get_area(glob, coarse_patch); + + double *areafine = NULL; + if (fclaw_opt->manifold) + areafine = clawpatch_get_area(glob, fine_patch); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + clawpatch_vt->d2->fort_average2coarse(&mx,&my,&mbc,&meqn,qcoarse,qfine, + areacoarse, areafine, &igrid, + &fclaw_opt->manifold); + } + else + { + double *volcoarse = clawpatch_get_volume(glob, coarse_patch); + + double *volfine = NULL; + if (fclaw_opt->manifold) + volfine = clawpatch_get_volume(glob, fine_patch); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + clawpatch_vt->d3->fort_average2coarse(&mx,&my,&mz, &mbc,&meqn,qcoarse,qfine, + volcoarse, volfine, &igrid, + &fclaw_opt->manifold); + } + + } +} + +/* ------------------------------ Parallel ghost patches ------------------------------ */ + +/* This is called just to get a count of how much to pack */ +static +size_t clawpatch_ghost_pack_elems(fclaw_global_t* glob) +{ + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + + int mx,my,mz; + if(clawpatch_opt->patch_dim == 2) + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + mz = 1; + } + else + { + mx = clawpatch_opt->mx; + my = clawpatch_opt->my; + mz = clawpatch_opt->mz; + } + int mbc = clawpatch_opt->mbc; + int meqn = clawpatch_opt->meqn; + + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + int refratio = fclaw_opt->refratio; + int packextra = fclaw_opt->ghost_patch_pack_numextrafields; + int packarea = fclaw_opt->ghost_patch_pack_area && fclaw_opt->manifold; + int packregisters = fclaw_opt->time_sync; + + int mint = refratio*mbc; + int nghost = mbc; + + /* Include size of conservation registers. Save fluxes on each size, + even though only one or two sides may be used. */ + // int frsize = 12*meqn*(mx + my); + + int frsize = packregisters ? 2*(4*meqn+2)*(mx + my) : 0; + + if (clawpatch_opt->patch_dim == 3 && packregisters) + { + fclaw_global_essentialf("clawpatch_ghost_comm: Conservation fix not yet " \ + "implemented in 3d\n"); + exit(0); + } + + int wg = (2*nghost + mx)*(2*nghost + my); /* Whole grid */ + int hole = (mx - 2*mint)*(my - 2*mint); /* Hole in center */ + + if(glob->domain->refine_dim == 2 && clawpatch_opt->patch_dim == 3) + { + wg *= (mz + 2*nghost); + hole *= (mz + 2*nghost); + } + else if (clawpatch_opt->patch_dim == 3) + { + wg *= (mz + 2*nghost); + hole *= (mz - 2*mint); + } + + FCLAW_ASSERT(hole >= 0); + + size_t psize = (wg - hole)*(meqn + packarea + packextra) + frsize; + FCLAW_ASSERT(psize >= 0); + + return psize; +} + + +static +void clawpatch_ghost_comm(fclaw_global_t* glob, + fclaw_patch_t* patch, + void *unpack_from_here, int time_interp, + int packmode) +{ + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + + int mbc = clawpatch_opt->mbc; + int meqn = clawpatch_opt->meqn; + + int packarea = packmode/2; // (0,1)/2 = 0; (2,3)/2 = 1; + + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + int packextra = fclaw_opt->ghost_patch_pack_numextrafields; + int packregisters = fclaw_opt->time_sync; // For conservation + int refratio = fclaw_opt->refratio; + + int mint = refratio*mbc; /* # interior cells needed for averaging */ + int nghost = mbc; /* # ghost values needed for interpolation */ + + /* Include size of conservation registers. Save fluxes on each size, + even though only one or two sides may be used. + + y-face : gp,gm,f(qfront),f(qback) + edge-length + area : 4*meqn + 2 + x-face : fp,fm,f(ql),f(qr) + edge-length + area : 4*meqn + 2 + + Multiply everything by mz to get fluxes on each face of cube. + (Time sync not yet implemented in 3d, though). + + */ + int frsize = packregisters ? 2*(4*meqn+2)*(mx + my) : 0; + + if (clawpatch_opt->patch_dim == 3 && packregisters) + { + fclaw_global_essentialf("clawpatch_ghost_comm: Conservation fix not yet " \ + "implemented in 3d\n"); + exit(0); + } + + /* wg : whole grid + hole : part we don't store */ + /* This is computed twice - here, and in fclaw2d_clawpatch_ghost_packsize */ + int wg = (2*nghost + mx)*(2*nghost + my); + int hole = (mx - 2*mint)*(my - 2*mint); /* Hole in center */ + + if(patch->refine_dim == 2 && clawpatch_opt->patch_dim == 3) + { + wg *= (mz + 2*nghost); + hole *= (mz + 2*nghost); + } + else if(clawpatch_opt->patch_dim == 3) + { + wg *= (mz + 2*nghost); + hole *= (mz - 2*mint); + } + + FCLAW_ASSERT(hole >= 0); + + size_t psize = (wg - hole)*(meqn + packarea + packextra) + frsize; + FCLAW_ASSERT(psize > 0); + + size_t psize_check = clawpatch_ghost_pack_elems(glob); + + /* Check with routine that is used to allocate space */ + FCLAW_ASSERT(psize == psize_check); + + int ierror; + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + + double *qthis; + fclaw_clawpatch_timesync_data(glob,patch,time_interp,&qthis,&meqn); + double *qpack = (double*) unpack_from_here; + int size; + if(clawpatch_opt->patch_dim == 2) + { + size = (wg - hole)*(meqn + packarea); + double *area = clawpatch_get_area(glob, patch); + clawpatch_vt->d2->fort_local_ghost_pack(&mx,&my,&mbc,&meqn,&mint,qthis,area, + qpack,&size,&packmode,&ierror); + } + else + { + size = (wg - hole)*(meqn + packarea); + double *vol = clawpatch_get_volume(glob, patch); + clawpatch_vt->d3->fort_local_ghost_pack(&mx,&my,&mz,&mbc,&meqn,&mint,qthis,vol, + qpack,&size,&packmode,&ierror); + } + FCLAW_ASSERT(ierror == 0); + + /* Advance pointer */ + qpack += size; + + int extrasize = (wg - hole)*(packextra); + if (packextra) + { + FCLAW_ASSERT(extrasize > 0); + FCLAW_ASSERT(clawpatch_vt->local_ghost_pack_aux != NULL); + clawpatch_vt->local_ghost_pack_aux(glob,patch,mint, + qpack,extrasize, + packmode,&ierror); + FCLAW_ASSERT(ierror == 0); + qpack += extrasize; /* Advance pointer */ + } + + FCLAW_ASSERT(ierror == 0); + if (packregisters) + { + FCLAW_ASSERT(frsize > 0); + FCLAW_ASSERT(clawpatch_vt->time_sync_pack_registers != NULL); + fclaw_clawpatch_packmode_t frpackmode = packmode % 2 == 0 ? + CLAWPATCH_REGISTER_PACK : + CLAWPATCH_REGISTER_UNPACK; + clawpatch_vt->time_sync_pack_registers(glob, patch, + qpack,frsize,frpackmode, + &ierror); + FCLAW_ASSERT(ierror == 0); + } + + + if (ierror > 0) + { + fclaw_global_essentialf("clawpatch_ghost_comm : ierror = %d\n",ierror); + exit(0); + } +} + + +static size_t clawpatch_ghost_packsize(fclaw_global_t* glob) +{ + size_t esize = clawpatch_ghost_pack_elems(glob); + return esize*sizeof(double); +} + +static +void clawpatch_local_ghost_pack(fclaw_global_t *glob, + fclaw_patch_t *patch, + void *patch_data, + int time_interp) +{ + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + int packarea = fclaw_opt->ghost_patch_pack_area && fclaw_opt->manifold; + int packmode = 2*packarea; // 0 or 2 (for pack) + + clawpatch_ghost_comm(glob,patch,patch_data, time_interp,packmode); +} + +static +void clawpatch_remote_ghost_unpack(fclaw_global_t* glob, + fclaw_patch_t* patch, + int blockno, + int patchno, + void *qdata, int time_interp) +{ + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + int packarea = fclaw_opt->ghost_patch_pack_area && fclaw_opt->manifold; + int packmode = 2*packarea + 1; // 1 or 3 (for unpack) + + clawpatch_ghost_comm(glob,patch,qdata,time_interp,packmode); +} + +static +void clawpatch_remote_ghost_build(fclaw_global_t *glob, + fclaw_patch_t *patch, + int blockno, + int patchno, + fclaw_build_mode_t build_mode) +{ + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t* clawpatch_opt = + fclaw_clawpatch_get_options(glob); + + clawpatch_define(glob,patch,blockno,patchno,build_mode); + + if (fclaw_opt->manifold) + { + if (build_mode != FCLAW_BUILD_FOR_GHOST_AREA_PACKED) + { + /* Cell areas/volumes are not sent as MPI messages and so must + be recomputed + */ + //fclaw2d_metric_patch_build(glob,patch,blockno,patchno); + if(clawpatch_opt->patch_dim == 2) + { + fclaw2d_metric_patch_compute_area(glob,patch,blockno,patchno); + } + else + { + fclaw3d_metric_patch_compute_volume(glob,patch,blockno,patchno); + } + } + } + /* Any metric terms we might need for the registers are packed */ +#if 0 + /* Setup for conservation correction */ + fclaw2d_clawpatch_time_sync_setup(glob,this_patch,blockno,patchno); +#endif +} + +static +void clawpatch_remote_ghost_delete(void *patchcp) +{ + clawpatch_delete(patchcp); +} + +/* ---------------------------- Parallel partitioning --------------------------------- */ + +static +size_t clawpatch_partition_packsize(fclaw_global_t* glob) +{ + const fclaw_clawpatch_options_t *clawpatch_opt + = fclaw_clawpatch_get_options(glob); + int mbc = clawpatch_opt->mbc; + int meqn = clawpatch_opt->meqn; + + size_t psize; + if(clawpatch_opt->patch_dim == 2) + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + psize = meqn*(2*mbc + mx)*(2*mbc + my); /* Store area */ + } + else + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + psize = meqn*(2*mbc + mx)*(2*mbc + my)*(2*mbc + mz); + } + + return psize*sizeof(double); +} + +static +void clawpatch_partition_pack(fclaw_global_t *glob, + fclaw_patch_t *patch, + int blockno, + int patchno, + void *pack_data_here) + { + fclaw_clawpatch_t *cp = get_clawpatch(patch); + FCLAW_ASSERT(cp != NULL); + + cp->griddata.copyToMemory((double*) pack_data_here); +} + +static +void clawpatch_partition_unpack(fclaw_global_t *glob, + fclaw_domain_t *new_domain, + fclaw_patch_t *patch, + int blockno, + int patchno, + void *unpack_data_from_here) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + + /* Time interp is false, since we only partition when all grids + are time synchronized and all flux registers are set to + zero. After copying data, we re-build patch with any + data needed. */ + cp->griddata.copyFromMemory((double*)unpack_data_from_here); +} + +/* ------------------------------------ Virtual table -------------------------------- */ + +static +fclaw_clawpatch_vtable_t* clawpatch_vt_new(int dim) +{ + fclaw_clawpatch_vtable_t * vt = FCLAW_ALLOC_ZERO (fclaw_clawpatch_vtable_t, 1); + if(dim == 2) + { + vt->patch_dim = 2; + vt->d2 = FCLAW_ALLOC_ZERO (struct fclaw_clawpatch_vtable_2d, 1); + } + else + { + vt->patch_dim = 3; + vt->d3 = FCLAW_ALLOC_ZERO (struct fclaw_clawpatch_vtable_3d, 1); + } + return vt; +} + +static +void clawpatch_vt_destroy(void* vt) +{ + fclaw_clawpatch_vtable_t* clawpatch_vt = (fclaw_clawpatch_vtable_t*) vt; + if(clawpatch_vt->patch_dim == 2) + { + FCLAW_FREE (clawpatch_vt->d2); + }else{ + FCLAW_FREE (clawpatch_vt->d3); + } + FCLAW_FREE (clawpatch_vt); +} + +static +void initialize_2d_claw46_fort_vt(fclaw_clawpatch_vtable_t* clawpatch_vt) +{ + /* Clawpatch settings functions */ + clawpatch_vt->d2->fort_average2coarse = FCLAW2D_CLAWPATCH46_FORT_AVERAGE2COARSE; + clawpatch_vt->d2->fort_interpolate2fine = FCLAW2D_CLAWPATCH46_FORT_INTERPOLATE2FINE; + + clawpatch_vt->d2->fort_tag4refinement = FCLAW2D_CLAWPATCH46_FORT_TAG4REFINEMENT; + clawpatch_vt->d2->fort_tag4coarsening = FCLAW2D_CLAWPATCH46_FORT_TAG4COARSENING; + + /* output functions */ + clawpatch_vt->fort_header_ascii = FCLAW2D_CLAWPATCH46_FORT_HEADER_ASCII; + clawpatch_vt->d2->fort_output_ascii = FCLAW2D_CLAWPATCH46_FORT_OUTPUT_ASCII; + + /* Diagnostic functions */ + clawpatch_vt->conservation_check = fclaw_clawpatch_diagnostics_cons_default; + clawpatch_vt->compute_error = fclaw_clawpatch_diagnostics_error_default; + clawpatch_vt->d2->fort_compute_patch_error = NULL; /* User defined */ + clawpatch_vt->d2->fort_compute_error_norm = FCLAW2D_CLAWPATCH46_FORT_COMPUTE_ERROR_NORM; + clawpatch_vt->d2->fort_compute_patch_area = FCLAW2D_CLAWPATCH46_FORT_COMPUTE_PATCH_AREA; + clawpatch_vt->d2->fort_conservation_check = FCLAW2D_CLAWPATCH46_FORT_CONSERVATION_CHECK; + + /* Ghost cell exchange functions */ + clawpatch_vt->d2->fort_copy_face = FCLAW2D_CLAWPATCH46_FORT_COPY_FACE; + clawpatch_vt->d2->fort_average_face = FCLAW2D_CLAWPATCH46_FORT_AVERAGE_FACE; + clawpatch_vt->d2->fort_interpolate_face = FCLAW2D_CLAWPATCH46_FORT_INTERPOLATE_FACE; + + clawpatch_vt->d2->fort_copy_corner = FCLAW2D_CLAWPATCH46_FORT_COPY_CORNER; + clawpatch_vt->d2->fort_average_corner = FCLAW2D_CLAWPATCH46_FORT_AVERAGE_CORNER; + clawpatch_vt->d2->fort_interpolate_corner = FCLAW2D_CLAWPATCH46_FORT_INTERPOLATE_CORNER; + + clawpatch_vt->local_ghost_pack_aux = NULL; + clawpatch_vt->d2->fort_local_ghost_pack = FCLAW2D_CLAWPATCH46_FORT_LOCAL_GHOST_PACK; + + clawpatch_vt->d2->fort_timeinterp = FCLAW2D_CLAWPATCH46_FORT_TIMEINTERP; +} + +static +void initialize_2d_claw5_fort_vt(fclaw_clawpatch_vtable_t* clawpatch_vt) +{ + /* Clawpatch settings functions */ + clawpatch_vt->d2->fort_average2coarse = FCLAW2D_CLAWPATCH5_FORT_AVERAGE2COARSE; + clawpatch_vt->d2->fort_interpolate2fine = FCLAW2D_CLAWPATCH5_FORT_INTERPOLATE2FINE; + + clawpatch_vt->d2->fort_tag4refinement = FCLAW2D_CLAWPATCH5_FORT_TAG4REFINEMENT; + clawpatch_vt->d2->fort_tag4coarsening = FCLAW2D_CLAWPATCH5_FORT_TAG4COARSENING; + + /* output functions */ + clawpatch_vt->fort_header_ascii = FCLAW2D_CLAWPATCH5_FORT_HEADER_ASCII; + clawpatch_vt->d2->fort_output_ascii = FCLAW2D_CLAWPATCH5_FORT_OUTPUT_ASCII; + + /* Diagnostic functions */ + clawpatch_vt->conservation_check = fclaw_clawpatch_diagnostics_cons_default; + clawpatch_vt->compute_error = fclaw_clawpatch_diagnostics_error_default; + clawpatch_vt->d2->fort_compute_patch_error = NULL; /* User defined */ + clawpatch_vt->d2->fort_compute_error_norm = FCLAW2D_CLAWPATCH5_FORT_COMPUTE_ERROR_NORM; + clawpatch_vt->d2->fort_compute_patch_area = FCLAW2D_CLAWPATCH5_FORT_COMPUTE_PATCH_AREA; + clawpatch_vt->d2->fort_conservation_check = FCLAW2D_CLAWPATCH5_FORT_CONSERVATION_CHECK; + + /* Ghost cell exchange functions */ + clawpatch_vt->d2->fort_copy_face = FCLAW2D_CLAWPATCH5_FORT_COPY_FACE; + clawpatch_vt->d2->fort_average_face = FCLAW2D_CLAWPATCH5_FORT_AVERAGE_FACE; + clawpatch_vt->d2->fort_interpolate_face = FCLAW2D_CLAWPATCH5_FORT_INTERPOLATE_FACE; + + clawpatch_vt->d2->fort_copy_corner = FCLAW2D_CLAWPATCH5_FORT_COPY_CORNER; + clawpatch_vt->d2->fort_average_corner = FCLAW2D_CLAWPATCH5_FORT_AVERAGE_CORNER; + clawpatch_vt->d2->fort_interpolate_corner = FCLAW2D_CLAWPATCH5_FORT_INTERPOLATE_CORNER; + + clawpatch_vt->local_ghost_pack_aux = NULL; + clawpatch_vt->d2->fort_local_ghost_pack = FCLAW2D_CLAWPATCH5_FORT_LOCAL_GHOST_PACK; + + clawpatch_vt->d2->fort_timeinterp = FCLAW2D_CLAWPATCH5_FORT_TIMEINTERP; +} + +static +void initialize_3dx_claw46_fort_vt(fclaw_clawpatch_vtable_t* clawpatch_vt) +{ + /* Clawpatch settings functions */ + clawpatch_vt->d3->fort_average2coarse = FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE; + clawpatch_vt->d3->fort_interpolate2fine = FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE; + + clawpatch_vt->d3->fort_tag4refinement = FCLAW3D_CLAWPATCH46_FORT_TAG4REFINEMENT; + clawpatch_vt->d3->fort_tag4coarsening_3dx = FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING; + + /* output functions */ + clawpatch_vt->fort_header_ascii = FCLAW3D_CLAWPATCH46_FORT_HEADER_ASCII; + clawpatch_vt->d3->fort_output_ascii = FCLAW3D_CLAWPATCH46_FORT_OUTPUT_ASCII; + + /* Ghost cell exchange functions */ + clawpatch_vt->d3->fort_copy_face = FCLAW3DX_CLAWPATCH46_FORT_COPY_FACE; + clawpatch_vt->d3->fort_average_face = FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE; + clawpatch_vt->d3->fort_interpolate_face = FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE; + + clawpatch_vt->d3->fort_copy_corner = FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER; + clawpatch_vt->d3->fort_average_corner = FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER; + clawpatch_vt->d3->fort_interpolate_corner = FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER; + + clawpatch_vt->local_ghost_pack_aux = NULL; + clawpatch_vt->d3->fort_local_ghost_pack = FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK; + + clawpatch_vt->d3->fort_timeinterp = FCLAW3D_CLAWPATCH46_FORT_TIMEINTERP; +} + +static +void initialize_3d_claw46_fort_vt(fclaw_clawpatch_vtable_t* clawpatch_vt) +{ + /* Clawpatch settings functions */ + clawpatch_vt->d3->fort_average2coarse = FCLAW3D_CLAWPATCH46_FORT_AVERAGE2COARSE; + clawpatch_vt->d3->fort_interpolate2fine = FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE2FINE; + + clawpatch_vt->d3->fort_tag4refinement = FCLAW3D_CLAWPATCH46_FORT_TAG4REFINEMENT; + clawpatch_vt->d3->fort_tag4coarsening = FCLAW3D_CLAWPATCH46_FORT_TAG4COARSENING; + + /* output functions */ + clawpatch_vt->fort_header_ascii = FCLAW3D_CLAWPATCH46_FORT_HEADER_ASCII; + clawpatch_vt->d3->fort_output_ascii = FCLAW3D_CLAWPATCH46_FORT_OUTPUT_ASCII; + + /* Ghost cell exchange functions */ + clawpatch_vt->d3->fort_copy_face = FCLAW3D_CLAWPATCH46_FORT_COPY_FACE; + clawpatch_vt->d3->fort_average_face = FCLAW3D_CLAWPATCH46_FORT_AVERAGE_FACE; + clawpatch_vt->d3->fort_interpolate_face = FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_FACE; + + clawpatch_vt->d3->fort_copy_edge = FCLAW3D_CLAWPATCH46_FORT_COPY_EDGE; + clawpatch_vt->d3->fort_average_edge = FCLAW3D_CLAWPATCH46_FORT_AVERAGE_EDGE; + clawpatch_vt->d3->fort_interpolate_edge = FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_EDGE; + + clawpatch_vt->d3->fort_copy_corner = FCLAW3D_CLAWPATCH46_FORT_COPY_CORNER; + clawpatch_vt->d3->fort_average_corner = FCLAW3D_CLAWPATCH46_FORT_AVERAGE_CORNER; + clawpatch_vt->d3->fort_interpolate_corner = FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_CORNER; + + clawpatch_vt->local_ghost_pack_aux = NULL; + clawpatch_vt->d3->fort_local_ghost_pack = FCLAW3D_CLAWPATCH46_FORT_LOCAL_GHOST_PACK; + + clawpatch_vt->d3->fort_timeinterp = FCLAW3D_CLAWPATCH46_FORT_TIMEINTERP; +} + +static +void initialize_2d_patch_vt(fclaw_patch_vtable_t* patch_vt, int patch_dim) +{ + /* Ghost filling */ + patch_vt->copy_face = clawpatch_copy_face; + patch_vt->average_face = clawpatch_average_face; + patch_vt->interpolate_face = clawpatch_interpolate_face; + + patch_vt->copy_corner = clawpatch_copy_corner; + patch_vt->average_corner = clawpatch_average_corner; + patch_vt->interpolate_corner = clawpatch_interpolate_corner; + + /* Assume regular block corners; Change by calling 'fclaw2d_clawpatch_use_pillowsphere' */ + patch_vt->copy_block_corner = clawpatch_copy_corner; + patch_vt->average_block_corner = clawpatch_average_corner; + patch_vt->interpolate_block_corner = clawpatch_interpolate_corner; + + if(patch_dim == 2) + { + /* Timing syncing module for conservation */ + patch_vt->time_sync_f2c = fclaw2d_clawpatch_time_sync_f2c; + patch_vt->time_sync_samesize = fclaw2d_clawpatch_time_sync_samesize; + patch_vt->time_sync_reset = fclaw2d_clawpatch_time_sync_reset; + } + + patch_vt->transform_init_data = fclaw2d_clawpatch_transform_init_data; + patch_vt->transform_face = fclaw2d_clawpatch_face_transformation; + patch_vt->transform_face_intra = fclaw2d_clawpatch_face_transformation_intra; + +} + +static +void initialize_3d_patch_vt(fclaw_patch_vtable_t* patch_vt) +{ + /* Ghost filling */ + patch_vt->copy_face = clawpatch_copy_face; + patch_vt->average_face = clawpatch_average_face; + patch_vt->interpolate_face = clawpatch_interpolate_face; + + patch_vt->copy_edge = clawpatch_copy_edge; + patch_vt->average_edge = clawpatch_average_edge; + patch_vt->interpolate_edge = clawpatch_interpolate_edge; + + patch_vt->copy_corner = clawpatch_copy_corner; + patch_vt->average_corner = clawpatch_average_corner; + patch_vt->interpolate_corner = clawpatch_interpolate_corner; + + /* Assume regular block corners; Change by calling 'fclaw2d_clawpatch_use_pillowsphere' */ + patch_vt->copy_block_corner = clawpatch_copy_corner; + patch_vt->average_block_corner = clawpatch_average_corner; + patch_vt->interpolate_block_corner = clawpatch_interpolate_corner; + + patch_vt->transform_init_data = fclaw3d_clawpatch_transform_init_data; + patch_vt->transform_face = fclaw3d_clawpatch_face_transformation; + patch_vt->transform_face_intra = fclaw3d_clawpatch_face_transformation_intra; + +} + +void fclaw_clawpatch_vtable_initialize(fclaw_global_t* glob, + int claw_version) +{ + fclaw_domain_t* domain = glob->domain; + fclaw_clawpatch_options_t * clawpatch_opt = + fclaw_clawpatch_get_options(glob); + fclaw_patch_vtable_t *patch_vt = fclaw_patch_vt(glob); + + if(clawpatch_opt->patch_dim == 2 && domain->refine_dim == 3) + { + fclaw_abortf("fclaw_clawpatch_vtable_initialize : " \ + "2d patches not supported with 3d oct-tree refinement\n"); + } + + if(clawpatch_opt->patch_dim == 2) + { + fclaw2d_metric_vtable_initialize(glob); + } + else + { + fclaw3d_metric_vtable_initialize(glob); + + } + + fclaw_clawpatch_vtable_t *clawpatch_vt = clawpatch_vt_new(clawpatch_opt->patch_dim); + + /* Patch setup */ + patch_vt->patch_new = (clawpatch_vt->patch_dim == 2) ? clawpatch_new_2d : clawpatch_new_3d; + patch_vt->patch_delete = clawpatch_delete; + patch_vt->build = clawpatch_build; + patch_vt->build_from_fine = clawpatch_build_from_fine; + + /* Time stepping */ + patch_vt->restore_step = clawpatch_restore_step; + patch_vt->save_step = clawpatch_save_step; + patch_vt->setup_timeinterp = clawpatch_setup_timeinterp; + + if(domain->refine_dim == 2) + { + initialize_2d_patch_vt(patch_vt, clawpatch_opt->patch_dim); + } + else + { + initialize_3d_patch_vt(patch_vt); + } + if(clawpatch_opt->patch_dim == 2) + { + patch_vt->metric_patch = clawpatch_get_metric_patch_2d; + } + else + { + patch_vt->metric_patch = clawpatch_get_metric_patch_3d; + } + + /* Regridding functions */ + patch_vt->tag4refinement = clawpatch_tag4refinement; + patch_vt->tag4coarsening = clawpatch_tag4coarsening; + + patch_vt->average2coarse = clawpatch_average2coarse; + patch_vt->interpolate2fine = clawpatch_interpolate2fine; + + /* ghost patch */ + patch_vt->ghost_packsize = clawpatch_ghost_packsize; + patch_vt->local_ghost_pack = clawpatch_local_ghost_pack; + patch_vt->remote_ghost_build = clawpatch_remote_ghost_build; + patch_vt->remote_ghost_unpack = clawpatch_remote_ghost_unpack; + patch_vt->remote_ghost_delete = clawpatch_remote_ghost_delete; + + + /* partitioning */ + patch_vt->partition_packsize = clawpatch_partition_packsize; + patch_vt->partition_pack = clawpatch_partition_pack; + patch_vt->partition_unpack = clawpatch_partition_unpack; + + /* output functions */ + clawpatch_vt->time_header_ascii = fclaw_clawpatch_time_header_ascii; + clawpatch_vt->cb_output_ascii = cb_clawpatch_output_ascii; + + if(clawpatch_opt->patch_dim == 2) + { + /* Ghost pack for registers (doesn't depend on clawpack version) */ + clawpatch_vt->time_sync_pack_registers = fclaw2d_clawpatch_time_sync_pack_registers; + } + + /* Fortran functions that depend on data layout (version 4.6 or 5.0) */ + + if (clawpatch_vt->patch_dim == 2 && claw_version == 4) + { + initialize_2d_claw46_fort_vt(clawpatch_vt); + } + else if (clawpatch_vt->patch_dim == 2 && claw_version == 5) + { + initialize_2d_claw5_fort_vt(clawpatch_vt); + } + else if (domain->refine_dim == 2 && clawpatch_vt->patch_dim == 3 && claw_version == 4) + { + initialize_3dx_claw46_fort_vt(clawpatch_vt); + } + else if (domain->refine_dim == 2 && clawpatch_vt->patch_dim == 3 && claw_version == 5) + { + fclaw_global_essentialf("clawpatch_vtable_initialize : Version 5 not yet " \ + "implemented\n"); + exit(0); + } + else if (domain->refine_dim == 3 && clawpatch_vt->patch_dim == 3 && claw_version == 4) + { + initialize_3d_claw46_fort_vt(clawpatch_vt); + } + else if (domain->refine_dim == 3 && clawpatch_vt->patch_dim == 3 && claw_version == 5) + { + fclaw_global_essentialf("clawpatch_vtable_initialize : Version 5 not yet " \ + "implemented\n"); + exit(0); + } + + + fclaw_clawpatch_diagnostics_vtable_initialize(glob); + + /* Set the virtual table, even if it isn't used */ + fclaw_clawpatch_pillow_vtable_initialize(glob, claw_version); + + clawpatch_vt->is_set = 1; + + if(fclaw_pointer_map_get(glob->vtables, "fclaw_clawpatch") != NULL) + { + fclaw_abortf("fclaw_clawpatch_vtable_initialize : " \ + "fclaw_clawpatch already initialized\n"); + } + fclaw_pointer_map_insert(glob->vtables, "fclaw_clawpatch", clawpatch_vt, clawpatch_vt_destroy); +} + +/* ------------------------------- Public access functions ---------------------------- */ + +/* These functions are not virtualized and are not defined by the + patch interface */ + +int fclaw_clawpatch_dim(fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + return cp->patch_dim; +} + +fclaw_clawpatch_vtable_t* fclaw_clawpatch_vt(fclaw_global_t* glob) +{ + + fclaw_clawpatch_vtable_t* clawpatch_vt = (fclaw_clawpatch_vtable_t*) + fclaw_pointer_map_get(glob->vtables, "fclaw_clawpatch"); + FCLAW_ASSERT(clawpatch_vt != nullptr); + FCLAW_ASSERT(clawpatch_vt->is_set != 0); + return clawpatch_vt; +} + +/* Called from clawpack 4.6 and 5.0 */ +void fclaw_clawpatch_save_current_step(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + cp->griddata_last = cp->griddata; +} + + +fclaw_clawpatch_t* +fclaw_clawpatch_get_clawpatch(fclaw_patch_t* patch) +{ + return get_clawpatch(patch); +} + + +fclaw2d_metric_patch_t* +fclaw_clawpatch_get_2d_metric_patch(fclaw_patch_t* patch) +{ + return get_metric_patch_2d(patch); +} + +fclaw3d_metric_patch_t* +fclaw3d_clawpatch_get_metric_patch(fclaw_patch_t* patch) +{ + return get_metric_patch_3d(patch); +} + +void fclaw_clawpatch_2d_grid_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + int* mx, int* my, int* mbc, + double* xlower, double* ylower, + double* dx, double* dy) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + *mx = cp->mx; + *my = cp->my; + *mbc = cp->mbc; + *xlower = cp->xlower; + *ylower = cp->ylower; + *dx = cp->dx; + *dy = cp->dy; +} + +void fclaw_clawpatch_3d_grid_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + int* mx, int* my, int* mz, int* mbc, + double* xlower, double* ylower, + double* zlower, + double* dx, double* dy, double* dz) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + *mx = cp->mx; + *my = cp->my; + *mz = cp->mz; + *mbc = cp->mbc; + *xlower = cp->xlower; + *ylower = cp->ylower; + *zlower = cp->zlower; + *dx = cp->dx; + *dy = cp->dy; + *dz = cp->dz; +} + +void fclaw_clawpatch_aux_data(fclaw_global_t *glob, + fclaw_patch_t *patch, + double **aux, int* maux) +{ + fclaw_clawpatch_t *cp = get_clawpatch (patch); + + *maux = cp->maux; + *aux = cp->aux.dataPtr(); +} + +void fclaw_clawpatch_soln_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **q, int* meqn) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + *q = cp->griddata.dataPtr(); + *meqn = cp->meqn; +} + +void fclaw_clawpatch_rhs_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **rhs, int *mfields) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + *rhs = cp->rhs.dataPtr(); + *mfields = cp->mfields; +} + +void fclaw_clawpatch_elliptic_error_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **err, int *mfields) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + *err = cp->elliptic_error.dataPtr(); + *mfields = cp->mfields; +} + +void fclaw_clawpatch_elliptic_soln_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **soln, int *mfields) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + *soln = cp->elliptic_soln.dataPtr(); + *mfields = cp->mfields; +} + + +double *fclaw_clawpatch_get_q(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + return cp->griddata.dataPtr(); +} + +fclaw2d_clawpatch_registers_t* +fclaw_clawpatch_get_2d_registers(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + return cp->d2->registers; +} + + +double* fclaw_clawpatch_get_error(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + return cp->griderror.dataPtr(); +} + +double* fclaw_clawpatch_get_exactsoln(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + return cp->exactsolution.dataPtr(); +} + +void* fclaw_clawpatch_get_user_data(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + return cp->user_data; +} + +void fclaw_clawpatch_set_user_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + void *udata) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + cp->user_data = udata; +} + +void* fclaw_clawpatch_get_solver_data(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + return cp->solver_data; +} + +void fclaw_clawpatch_set_solver_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + void *sdata) +{ + fclaw_clawpatch_t *cp = get_clawpatch(patch); + cp->solver_data = sdata; +} + +size_t fclaw_clawpatch_size(fclaw_global_t *glob) +{ + const fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + int meqn = clawpatch_opt->meqn; + int mbc = clawpatch_opt->mbc; + + if(clawpatch_opt->patch_dim == 2) + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + return (mx+2*mbc)*(my+2*mbc)*meqn; + } + else + { + int mx = clawpatch_opt->mx; + int my = clawpatch_opt->my; + int mz = clawpatch_opt->mz; + return (mx+2*mbc)*(my+2*mbc)*(mz+2*mbc)*meqn; + } +} + +void fclaw_clawpatch_timesync_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + int time_interp, + double **q, int* meqn) +{ + fclaw_clawpatch_t* cp = get_clawpatch(patch); + *q = q_time_sync(patch, time_interp); + *meqn = cp->meqn; +} + +double* fclaw_clawpatch_get_q_timesync(fclaw_global_t* glob, + fclaw_patch_t* patch, + int time_interp) +{ + return q_time_sync(patch, time_interp); +} + +double* fclaw_clawpatch_get_2d_area(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + return clawpatch_get_area(glob, patch); +} + +double* fclaw_clawpatch_get_3d_volume(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + return clawpatch_get_volume(glob, patch); +} + +void fclaw_clawpatch_2d_metric_scalar(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **area, double** edgelengths, + double **curvature) +{ + fclaw2d_metric_patch_scalar(glob,patch,area,edgelengths, + curvature); +} + +void fclaw_clawpatch_2d_metric_vector(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **xnormals, double **ynormals, + double **xtangents, double **ytangents, + double **surfnormals) +{ + fclaw2d_metric_patch_vector(glob,patch,xnormals,ynormals, + xtangents,ytangents,surfnormals); +} + + + + +void fclaw_clawpatch_2d_metric_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **xp, double **yp, double **zp, + double **xd, double **yd, double **zd, + double **area) +{ + fclaw2d_metric_patch_mesh_data(glob,patch,xp,yp,zp,xd,yd,zd,area); +} + +void fclaw_clawpatch_2d_metric_data2(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **xnormals, double **ynormals, + double **xtangents, double **ytangents, + double **surfnormals, + double **edgelengths, double **curvature) +{ + fclaw2d_metric_patch_mesh_data2(glob,patch,xnormals,ynormals, + xtangents,ytangents,surfnormals, + edgelengths,curvature); +} + +void fclaw_clawpatch_3d_metric_scalar(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **volume, double** faceareas) +{ + fclaw3d_metric_patch_scalar(glob,patch,volume,faceareas); +} + +void fclaw2d_clawpatch_metric_basis(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **xrot, double** yrot, double** zrot) +{ + fclaw3d_metric_patch_basis(glob,patch,xrot, yrot, zrot); +} + + + + +void fclaw_clawpatch_3d_mesh_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **xp, double **yp, double **zp, + double **xd, double **yd, double **zd, + double **volume, double **faceareas) +{ + fclaw3d_metric_patch_mesh_data(glob,patch,xp,yp,zp,xd,yd,zd, + volume, faceareas); +} + diff --git a/src/patches/clawpatch/fclaw2d_clawpatch.h b/src/patches/clawpatch/fclaw_clawpatch.h similarity index 54% rename from src/patches/clawpatch/fclaw2d_clawpatch.h rename to src/patches/clawpatch/fclaw_clawpatch.h index 625440132..82ba43f0e 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch.h +++ b/src/patches/clawpatch/fclaw_clawpatch.h @@ -23,16 +23,17 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_CLAWPATCH_H -#define FCLAW2D_CLAWPATCH_H +#ifndef FCLAW_CLAWPATCH_H +#define FCLAW_CLAWPATCH_H #include /* Needed to get correction def. of PATCHDIM */ -#include /* Need patch callback def */ +#include /* Need patch callback def */ #include +#include #include -#include +#include #ifdef __cplusplus @@ -51,9 +52,9 @@ extern "C" /** - * @brief fclaw2d_clawpatch_vtable type + * @brief fclaw_clawpatch_vtable type */ -typedef struct fclaw2d_clawpatch_vtable fclaw2d_clawpatch_vtable_t; +typedef struct fclaw_clawpatch_vtable fclaw_clawpatch_vtable_t; /* --------------------------------- Typedefs ----------------------------------------- */ /** @@ -63,8 +64,8 @@ typedef struct fclaw2d_clawpatch_vtable fclaw2d_clawpatch_vtable_t; * @param[in] patch the patch context * @param[in] user the pointer to the user data */ -typedef void (*clawpatch_set_user_data_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*clawpatch_set_user_data_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, void* user); /** @@ -77,8 +78,8 @@ typedef void (*clawpatch_set_user_data_t)(struct fclaw2d_global *glob, * @param[in] packmode enum fclaw2d_clawpatch_packmode enum * @param[out] ierror error value */ -typedef void (*clawpatch_time_sync_pack_registers_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +typedef void (*clawpatch_time_sync_pack_registers_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, double *qpack, int frsize, fclaw_clawpatch_packmode_t packmode, @@ -96,8 +97,8 @@ typedef void (*clawpatch_time_sync_pack_registers_t)(struct fclaw2d_global *glob * @param[in] packmode the packing mode (0 for packing aux, 1 for unpacking aux) * @param[out] ierror error value */ -typedef void (*clawpatch_local_ghost_pack_aux_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*clawpatch_local_ghost_pack_aux_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, const int mint, double qpack[], int extrasize, int packmode, int* ierror); @@ -111,8 +112,8 @@ typedef void (*clawpatch_local_ghost_pack_aux_t)(struct fclaw2d_global *glob, * @param[in] the size of the buffer * @param[out] ierror error value */ -typedef void (*clawpatch_fort_local_ghost_pack_registers_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*clawpatch_fort_local_ghost_pack_registers_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, double qpack[], int frsize, int* ierror); /* ------------------------------ typedefs - output ----------------------------------- */ @@ -123,7 +124,7 @@ typedef void (*clawpatch_fort_local_ghost_pack_registers_t)(struct fclaw2d_globa * @param[in] glob the global context * @param[in] iframe the frame */ -typedef void (*clawpatch_time_header_t)(struct fclaw2d_global* glob, int iframe); +typedef void (*clawpatch_time_header_t)(struct fclaw_global* glob, int iframe); /* ---------------------------- typedefs - diagnostics -------------------------------- */ @@ -138,8 +139,8 @@ typedef void (*clawpatch_time_header_t)(struct fclaw2d_global* glob, int iframe) * @param[in,out] error_data a user defined structure * */ -typedef void (*clawpatch_diagnostics_cons_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*clawpatch_diagnostics_cons_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno, void *error_data); @@ -154,8 +155,8 @@ typedef void (*clawpatch_diagnostics_cons_t)(struct fclaw2d_global *glob, * @param[in,out] error_data a user defined structure * */ -typedef void (*clawpatch_diagnostics_error_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*clawpatch_diagnostics_error_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno, void *error_data); @@ -167,28 +168,26 @@ typedef void (*clawpatch_diagnostics_error_t)(struct fclaw2d_global *glob, /** * @brief Initialize the clawpatch vtable global variable * + * Vtable will be initialize to the correct dimension (2d, 3dx, 3d) based on the + * the dimension of the fclaw_patch_vtable and the dimension of the fclaw_clawpatch_options + * * @param claw_version the version of clawpack (4 for 4.6, 5 for 5) */ -void fclaw2d_clawpatch_vtable_initialize(struct fclaw2d_global *global, - int claw_version); +void fclaw_clawpatch_vtable_initialize(struct fclaw_global *global, + int claw_version); /** * @brief Get a pointer to a clawpatch vtable global variable * - * @return fclaw2d_clawpatch_vtable_t* the vtable + * @return fclaw_clawpatch_vtable_t* the vtable */ -fclaw2d_clawpatch_vtable_t* fclaw2d_clawpatch_vt(struct fclaw2d_global* glob); +fclaw_clawpatch_vtable_t* fclaw_clawpatch_vt(struct fclaw_global* glob); /** - * @brief vtable for clawpatch related functions + * @brief vtable for 2d clawpatch related functions */ -struct fclaw2d_clawpatch_vtable +struct fclaw_clawpatch_vtable_2d { - /** - * @brief Function that allows the user to set a user data pointer - */ - clawpatch_set_user_data_t set_user_data; - /** @{ @name Ghost Filling Functions */ /** Copies ghost data from a face neighboring grid on the same level */ @@ -235,13 +234,9 @@ struct fclaw2d_clawpatch_vtable /** @{ @name Output Functions (ascii) */ - /** Outputs a time header */ - clawpatch_time_header_t time_header_ascii; /** Outputs a time header */ clawpatch_fort_header_ascii_t fort_header_ascii; - /** Called for every patch when outputing ascii */ - fclaw2d_patch_callback_t cb_output_ascii; /** Outputs patch data in ascii */ clawpatch_fort_output_ascii_t fort_output_ascii; @@ -249,7 +244,7 @@ struct fclaw2d_clawpatch_vtable /** @{ @name Time interpolation functions */ - /** Interpolates q between timesteps */ + /** Interpolates q between time steps */ clawpatch_fort_timeinterp_t fort_timeinterp; /** @} */ @@ -258,18 +253,11 @@ struct fclaw2d_clawpatch_vtable /** Packs/Unpacks ghost cell data */ clawpatch_fort_local_ghost_pack_t fort_local_ghost_pack; - /** Packs/Unpacks ghost cell data for an aux array */ - clawpatch_local_ghost_pack_aux_t local_ghost_pack_aux; /** @} */ /** @{ @name Diagnostic Functions */ - /** Fills in a user defined error_data structure for a specific patch. */ - clawpatch_diagnostics_cons_t conservation_check; - /** Fills in a user defined error_data structure for a specific patch. */ - clawpatch_diagnostics_error_t compute_error; - /** Calculates the error for cells in a patch */ clawpatch_fort_error_t fort_compute_patch_error; /** Calculates a sum for each equation */ @@ -281,6 +269,139 @@ struct fclaw2d_clawpatch_vtable /** @} */ +}; + +/** + * @brief Vtable for 3d clawpatch related functions + */ +struct fclaw_clawpatch_vtable_3d +{ + /** @{ @name Ghost Filling Functions */ + + /** Copies ghost data from a face neighboring grid on the same level */ + fclaw3d_clawpatch_fort_copy_face_t fort_copy_face; + /** Averages values from a face neighboring fine grid */ + fclaw3d_clawpatch_fort_average_face_t fort_average_face; + /** Interpolates values form a face neighboring coarse grid */ + fclaw3d_clawpatch_fort_interpolate_face_t fort_interpolate_face; + + /** Copies ghost data from a edge neighboring grid on the same level */ + fclaw3d_clawpatch_fort_copy_edge_t fort_copy_edge; + /** Averages values from a edge neighboring fine grid */ + fclaw3d_clawpatch_fort_average_edge_t fort_average_edge; + /** Interpolates values form an edge neighboring coarse grid */ + fclaw3d_clawpatch_fort_interpolate_edge_t fort_interpolate_edge; + + /** Copies ghost data from a corner neighboring grid on the same level */ + fclaw3d_clawpatch_fort_copy_corner_t fort_copy_corner; + /** Averages values from a corner neighboring fine grid */ + fclaw3d_clawpatch_fort_average_corner_t fort_average_corner; + /** Interpolates values form a corner neighboring coarse grid */ + fclaw3d_clawpatch_fort_interpolate_corner_t fort_interpolate_corner; + + /** @} */ + + /** @{ @name Regridding Functions */ + + /** Tags a patch for refinement. */ + fclaw3d_clawpatch_fort_tag4refinement_t fort_tag4refinement; + /** Tags a quad of patches for coarsening. */ + fclaw3dx_clawpatch_fort_tag4coarsening_t fort_tag4coarsening_3dx; + /** Tags 8 patches for coarsening. */ + fclaw3d_clawpatch_fort_tag4coarsening_t fort_tag4coarsening; + /** @deprecated Checks if solution exceeds a threshold */ + fclaw3d_clawpatch_fort_exceeds_threshold_t fort_user_exceeds_threshold; + + /** Averages a fine patches to a coarse patch */ + fclaw3d_clawpatch_fort_average2coarse_t fort_average2coarse; + /** Interpolates from a coarse patch to a fine patches */ + fclaw3d_clawpatch_fort_interpolate2fine_t fort_interpolate2fine; + + /** @} */ + + /** @{ @name Output Functions (ascii) */ + + /** Outputs patch data in ascii */ + fclaw3d_clawpatch_fort_output_ascii_t fort_output_ascii; + + /** @} */ + + /** @{ @name Time interpolation functions */ + + /** Interpolates q between timesteps */ + fclaw3d_clawpatch_fort_timeinterp_t fort_timeinterp; + + /** @} */ + + /** @{ @name Ghost Patch Functions */ + + /** Packs/Unpacks ghost cell data */ + fclaw3d_clawpatch_fort_local_ghost_pack_t fort_local_ghost_pack; + + /** @} */ + + /** @{ @name Diagnostic Functions */ + + /** Calculates the error for cells in a patch */ + fclaw3d_clawpatch_fort_error_t fort_compute_patch_error; + /** Calculates a sum for each equation */ + fclaw3d_clawpatch_fort_conscheck_t fort_conservation_check; + /** Calculates the error norms for a patch */ + fclaw3d_clawpatch_fort_norm_t fort_compute_error_norm; + /** Calculates the area of a patch */ + fclaw3d_clawpatch_fort_area_t fort_compute_patch_area; + + /** @} */ +}; +/** + * @brief vtable for clawpatch related functions + */ +struct fclaw_clawpatch_vtable +{ + int patch_dim; + struct fclaw_clawpatch_vtable_2d* d2; + struct fclaw_clawpatch_vtable_3d* d3; + + /** + * @brief Function that allows the user to set a user data pointer + */ + clawpatch_set_user_data_t set_user_data; + + /** @{ @name Conservation Update */ + + /** Packs/Unpacks the fclaw2d_clawpatch_registers struct for ghost patches */ + clawpatch_time_sync_pack_registers_t time_sync_pack_registers; + + /** @} */ + + /** @{ @name Output Functions (ascii) */ + + /** Outputs a time header */ + clawpatch_time_header_t time_header_ascii; + /** Outputs a time header */ + clawpatch_fort_header_ascii_t fort_header_ascii; + + /** Called for every patch when outputing ascii */ + fclaw_patch_callback_t cb_output_ascii; + + /** @} */ + + /** @{ @name Ghost Patch Functions */ + + /** Packs/Unpacks ghost cell data for an aux array */ + clawpatch_local_ghost_pack_aux_t local_ghost_pack_aux; + + /** @} */ + + /** @{ @name Diagnostic Functions */ + + /** Fills in a user defined error_data structure for a specific patch. */ + clawpatch_diagnostics_cons_t conservation_check; + /** Fills in a user defined error_data structure for a specific patch. */ + clawpatch_diagnostics_error_t compute_error; + + /** @} */ + /** @{ @name Diagnostics */ /** Whether or not this vtable is set */ @@ -300,12 +421,20 @@ struct fclaw2d_clawpatch_vtable * @param[in] glob glob the global context * @param[in] patch the patch context */ -void fclaw2d_clawpatch_save_current_step(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch); +void fclaw_clawpatch_save_current_step(struct fclaw_global* glob, + struct fclaw_patch* this_patch); /* ------------------------------- Misc access functions ------------------------------ */ +/** + * @brief Get the dimension of the clawpatch + * + * @param patch the clawpatch + * @return int the dimension + */ +int fclaw_clawpatch_dim(struct fclaw_patch * patch); + /** * @brief Get the grid data for a specific patch * @@ -316,24 +445,38 @@ void fclaw2d_clawpatch_save_current_step(struct fclaw2d_global* glob, * @param[out] xlower, ylower the lower left coordinate of the patch * @param[out] dx, dy the spacings in the x and y directions */ -void fclaw2d_clawpatch_grid_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int* mx, - int* my, - int* mbc, - double* xlower, - double* ylower, - double* dx, - double* dy); -#if 0 -void fclaw2d_clawpatch_grid_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int* mx, int* my, int* mz, - int* mbc, - double* xlower, double* ylower, - double* zlower, - double* dx, double* dy, double* dz); -#endif +void fclaw_clawpatch_2d_grid_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + int* mx, + int* my, + int* mbc, + double* xlower, + double* ylower, + double* dx, + double* dy); + +/** + * @brief Get the grid data for a specific patch + * + * @param[in] glob glob the global context + * @param[in] patch the patch context + * @param[out] mx, my, mz the number of cells in the x, y, and z directions + * @param[out] mbc the number of ghost cells + * @param[out] xlower, ylower, zlower the lower bottom left coordinate of the patch + * @param[out] dx, dy, dz the spacings in the x, y, and z directions + */ +void fclaw_clawpatch_3d_grid_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + int* mx, + int* my, + int* mz, + int* mbc, + double* xlower, + double* ylower, + double* zlower, + double* dx, + double* dy, + double* dz); /** * @brief Get the scalar metrics of a patch @@ -347,11 +490,11 @@ void fclaw2d_clawpatch_grid_data(struct fclaw2d_global* glob, * (i,j,2) contains the the left edge length for cell (i,j). * @param[out] curvature the curvature for each cell in the patch */ -void fclaw2d_clawpatch_metric_scalar(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **area, - double **edgelengths, - double **curvature); +void fclaw_clawpatch_2d_metric_scalar(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **area, + double **edgelengths, + double **curvature); /** * @brief Get the vector metrics of a patch @@ -369,13 +512,13 @@ void fclaw2d_clawpatch_metric_scalar(struct fclaw2d_global* glob, * @param[out] surfnormals the surface normal for each cell center of the patch * An array of dimension(-mbc:mx+mbc+1,-mbc:my+mbc+1,3) */ -void fclaw2d_clawpatch_metric_vector(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **xnormals, - double **ynormals, - double **xtangents, - double **ytangents, - double **surfnormals); +void fclaw_clawpatch_2d_metric_vector(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **xnormals, + double **ynormals, + double **xtangents, + double **ytangents, + double **surfnormals); /** * @brief Get the mesh metrics of a patch @@ -386,15 +529,15 @@ void fclaw2d_clawpatch_metric_vector(struct fclaw2d_global* glob, * @param[out] xd, yd, zd the coordinates of the nodes * @param[out] area the area of each cell */ -void fclaw2d_clawpatch_metric_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **xp, - double **yp, - double **zp, - double **xd, - double **yd, - double **zd, - double **area); +void fclaw_clawpatch_2d_metric_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **xp, + double **yp, + double **zp, + double **xd, + double **yd, + double **zd, + double **area); /** * @brief Get the mesh metrics of a patch * @@ -416,15 +559,75 @@ void fclaw2d_clawpatch_metric_data(struct fclaw2d_global* glob, * (i,j,2) contains the the left edge length for cell (i,j). * @param[out] curvature the curvature for each cell in the patch */ -void fclaw2d_clawpatch_metric_data2(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **xnormals, - double **ynormals, - double **xtangents, - double **ytangents, - double **surfnormals, - double ** edgelengths, - double **curvature); +void fclaw_clawpatch_2d_metric_data2(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **xnormals, + double **ynormals, + double **xtangents, + double **ytangents, + double **surfnormals, + double ** edgelengths, + double **curvature); + +/** + * @brief Get the scalar metrics of a patch + * + * @param[in] glob glob the global context + * @param[in] patch the patch context + * @param[out] area the area of each cell in the patch + * @param[out] edgelengths the edge lenghts for each cell. + * An array of dimension (-mbc:mx+mbc+2,-mbc:my+mbc+2,2). + * (i,j,1) contains the the bottom edge length for cell (i,j). + * (i,j,2) contains the the left edge length for cell (i,j). + * @param[out] curvature the curvature for each cell in the patch + */ +void fclaw_clawpatch_3d_metric_scalar(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **volume, + double **faceareas); + +/** + * @brief Get the vector metrics of a patch + * + * @param[in] glob glob the global context + * @param[in] patch the patch context + * @param[out] xnormals, ynormals the normals of each face of the patch + * Arrays of dimension (-mbc:mx+mbc+2,-mbc:my+mbc+2,2). + * (i,j,1) contains the normal for the bottom edge of cell (i,j). + * (i,j,2) contains the normal for the left edge of cell (i,j). + * @param[out] xtangents, ytangents the tangents of each face of the patch + * Arrays of dimension (-mbc:mx+mbc+2,-mbc:my+mbc+2,2). + * (i,j,1) contains the tangent for the bottom edge of cell (i,j). + * (i,j,2) contains the tangent for the left edge of cell (i,j). + * @param[out] surfnormals the surface normal for each cell center of the patch + * An array of dimension(-mbc:mx+mbc+1,-mbc:my+mbc+1,3) + */ +void fclaw_clawpatch_3d_metric_basis(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **xrot, + double **yrot, + double **zrot); + +/** + * @brief Get the mesh metrics of a patch + * + * @param[in] glob glob the global context + * @param[in] patch the patch context + * @param[out] xp, yp, zp the coordinates of the cell centers + * @param[out] xd, yd, zd the coordinates of the nodes + * @param[out] area the area of each cell + */ +void fclaw_clawpatch_3d_mesh_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **xp, + double **yp, + double **zp, + double **xd, + double **yd, + double **zd, + double **volume, + double **faceareas); + /** * @brief Get the area for each cell of the patch @@ -432,8 +635,19 @@ void fclaw2d_clawpatch_metric_data2(struct fclaw2d_global* glob, * @param this_patch the patch to get the are for * @return double* the area array */ -double* fclaw2d_clawpatch_get_area(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +double* fclaw_clawpatch_get_2d_area(struct fclaw_global* glob, + struct fclaw_patch* patch); + +/** + * @brief Get the area for each cell of the patch + * + * @param this_patch the patch to get the are for + * @return double* the area array + */ +double* fclaw_clawpatch_get_3d_volume(struct fclaw_global* glob, + struct fclaw_patch* this_patch); + + /** * @brief Get the solution data for a patch * @@ -442,10 +656,10 @@ double* fclaw2d_clawpatch_get_area(struct fclaw2d_global* glob, * @param[out] q the solution array * @param[out] meqn the number of equations */ -void fclaw2d_clawpatch_soln_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **q, - int* meqn); +void fclaw_clawpatch_soln_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **q, + int* meqn); /** * @brief Get the aux data for a patch * @@ -454,10 +668,10 @@ void fclaw2d_clawpatch_soln_data(struct fclaw2d_global* glob, * @param[out] aux the aux array * @param[out] maux the number of equations */ -void fclaw2d_clawpatch_aux_data(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - double **aux, - int* maux); +void fclaw_clawpatch_aux_data(struct fclaw_global *glob, + struct fclaw_patch *patch, + double **aux, + int* maux); /** * @brief Get the rhs data for a patch @@ -467,10 +681,10 @@ void fclaw2d_clawpatch_aux_data(struct fclaw2d_global *glob, * @param[out] rhs the rhs array * @param[out] mfields the number fields */ -void fclaw2d_clawpatch_rhs_data(struct fclaw2d_global* glob, - fclaw2d_patch_t* patch, - double **rhs, - int *mfields); +void fclaw_clawpatch_rhs_data(struct fclaw_global* glob, + fclaw_patch_t* patch, + double **rhs, + int *mfields); /** * @brief Get the error data for elliptic problems * @@ -479,10 +693,10 @@ void fclaw2d_clawpatch_rhs_data(struct fclaw2d_global* glob, * @param[out] err the error array * @param[out] mfields the number fields */ -void fclaw2d_clawpatch_elliptic_error_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **err, - int *mfields); +void fclaw_clawpatch_elliptic_error_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **err, + int *mfields); /** * @brief Get the solution data for elliptic problems * @@ -491,10 +705,10 @@ void fclaw2d_clawpatch_elliptic_error_data(struct fclaw2d_global* glob, * @param[out] soln the solution array * @param[out] mfields the number fields */ -void fclaw2d_clawpatch_elliptic_soln_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - double **soln, - int *mfields); +void fclaw_clawpatch_elliptic_soln_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + double **soln, + int *mfields); /** * @brief Get the solution data for a patch @@ -503,8 +717,8 @@ void fclaw2d_clawpatch_elliptic_soln_data(struct fclaw2d_global* glob, * @param[in] this_patch the patch context * @return double* the solution array */ -double* fclaw2d_clawpatch_get_q(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +double* fclaw_clawpatch_get_q(struct fclaw_global* glob, + struct fclaw_patch* patch); /** * @brief Get the error data for a patch @@ -513,8 +727,8 @@ double* fclaw2d_clawpatch_get_q(struct fclaw2d_global* glob, * @param[in] this_patch the patch context * @return double* the error array */ -double* fclaw2d_clawpatch_get_error(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +double* fclaw_clawpatch_get_error(struct fclaw_global* glob, + struct fclaw_patch* patch); /** * @brief Get the exact solution data for a patch @@ -523,8 +737,8 @@ double* fclaw2d_clawpatch_get_error(struct fclaw2d_global* glob, * @param[in] this_patch the patch context * @return double* the exact solution array */ -double* fclaw2d_clawpatch_get_exactsoln(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +double* fclaw_clawpatch_get_exactsoln(struct fclaw_global* glob, + struct fclaw_patch* patch); /** * @brief Get the size of a solution array for a patch @@ -532,7 +746,7 @@ double* fclaw2d_clawpatch_get_exactsoln(struct fclaw2d_global* glob, * @param glob the global context * @return size_t the size */ -size_t fclaw2d_clawpatch_size(struct fclaw2d_global *glob); +size_t fclaw_clawpatch_size(struct fclaw_global *glob); /** @@ -542,8 +756,8 @@ size_t fclaw2d_clawpatch_size(struct fclaw2d_global *glob); * @param patch the patch context * @return void* the pointer */ -void* fclaw2d_clawpatch_get_user_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +void* fclaw_clawpatch_get_user_data(struct fclaw_global* glob, + struct fclaw_patch* patch); /** * @brief Set the user data pointer for a patch @@ -552,9 +766,9 @@ void* fclaw2d_clawpatch_get_user_data(struct fclaw2d_global* glob, * @param patch the patch context * @param udata the user data pointer */ -void fclaw2d_clawpatch_set_user_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - void* udata); +void fclaw_clawpatch_set_user_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + void* udata); /** * @brief Get the solver data pointer for a patch * @@ -562,8 +776,8 @@ void fclaw2d_clawpatch_set_user_data(struct fclaw2d_global* glob, * @param patch the patch context * @return void* the pointer */ -void* fclaw2d_clawpatch_get_solver_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +void* fclaw_clawpatch_get_solver_data(struct fclaw_global* glob, + struct fclaw_patch* patch); /** * @brief Set the solver data pointer for a patch @@ -572,9 +786,9 @@ void* fclaw2d_clawpatch_get_solver_data(struct fclaw2d_global* glob, * @param patch the patch context * @param sdata the solver data pointer */ -void fclaw2d_clawpatch_set_solver_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - void* sdata); +void fclaw_clawpatch_set_solver_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + void* sdata); /* These should be renamed to time_interp data */ @@ -588,11 +802,11 @@ void fclaw2d_clawpatch_set_solver_data(struct fclaw2d_global* glob, * @param[out] q the interpolated solution * @param[out] meqn the number of equations */ -void fclaw2d_clawpatch_timesync_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int time_interp, - double **q, - int* meqn); +void fclaw_clawpatch_timesync_data(struct fclaw_global* glob, + struct fclaw_patch* patch, + int time_interp, + double **q, + int* meqn); /** * @brief Get an interpolated solution @@ -602,9 +816,9 @@ void fclaw2d_clawpatch_timesync_data(struct fclaw2d_global* glob, * @param time_interp true if interpolated grid data should be returned * @return the interpolated solution */ -double* fclaw2d_clawpatch_get_q_timesync(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, - int time_interp); +double* fclaw_clawpatch_get_q_timesync(struct fclaw_global* glob, + struct fclaw_patch* patch, + int time_interp); /** * @brief Get the registers for a patch * @@ -613,8 +827,8 @@ double* fclaw2d_clawpatch_get_q_timesync(struct fclaw2d_global* glob, * @return the registers */ struct fclaw2d_clawpatch_registers* -fclaw2d_clawpatch_get_registers(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +fclaw_clawpatch_get_2d_registers(struct fclaw_global* glob, + struct fclaw_patch* patch); #ifdef __cplusplus } diff --git a/src/patches/clawpatch/fclaw_clawpatch.h.2d.TEST.cpp b/src/patches/clawpatch/fclaw_clawpatch.h.2d.TEST.cpp new file mode 100644 index 000000000..d4f8860c6 --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch.h.2d.TEST.cpp @@ -0,0 +1,177 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include + +TEST_CASE("2d fclaw_clawpatch_vtable_initialize stores two separate vtables in two separate globs") +{ + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_store_domain(glob1, domain); + fclaw_global_t* glob2 = fclaw_global_new(); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, opts); + fclaw_clawpatch_options_store(glob2, opts); + + fclaw_vtables_initialize(glob1); + fclaw_vtables_initialize(glob2); + + fclaw_clawpatch_vtable_initialize(glob1,4); + fclaw_clawpatch_vtable_initialize(glob2,4); + + CHECK_NE(fclaw_clawpatch_vt(glob1), fclaw_clawpatch_vt(glob2)); + + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +TEST_CASE("3dx fclaw_clawpatch_vtable_initialize stores two separate vtables in two separate globs") +{ + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_store_domain(glob1, domain); + fclaw_global_t* glob2 = fclaw_global_new(); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + fclaw_clawpatch_options_store(glob1, opts); + fclaw_clawpatch_options_store(glob2, opts); + + fclaw_vtables_initialize(glob1); + fclaw_vtables_initialize(glob2); + + fclaw_clawpatch_vtable_initialize(glob1,4); + fclaw_clawpatch_vtable_initialize(glob2,4); + + CHECK_NE(fclaw_clawpatch_vt(glob1), fclaw_clawpatch_vt(glob2)); + + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +TEST_CASE("2d fclaw_clawpatch_vtable_initialize sets is_set flag") +{ + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob, opts); + + fclaw_vtables_initialize(glob); + + fclaw_clawpatch_vtable_initialize(glob, 4); + + CHECK_UNARY(fclaw_clawpatch_vt(glob)->is_set); + + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); +} + +TEST_CASE("3dx fclaw_clawpatch_vtable_initialize sets is_set flag") +{ + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + fclaw_clawpatch_options_store(glob, opts); + + fclaw_vtables_initialize(glob); + + fclaw_clawpatch_vtable_initialize(glob, 4); + + CHECK_UNARY(fclaw_clawpatch_vt(glob)->is_set); + + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); +} + + + +TEST_CASE("2d fclaw_clawpatch_vtable_initialize fails if called twice on a glob") +{ + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_store_domain(glob1, domain); + fclaw_global_t* glob2 = fclaw_global_new(); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, opts); + fclaw_clawpatch_options_store(glob2, opts); + + fclaw_vtables_initialize(glob1); + fclaw_vtables_initialize(glob2); + + fclaw_clawpatch_vtable_initialize(glob1,4); + CHECK_SC_ABORTED(fclaw_clawpatch_vtable_initialize(glob1,4)); + fclaw_clawpatch_vtable_initialize(glob2,4); + CHECK_SC_ABORTED(fclaw_clawpatch_vtable_initialize(glob2,4)); + + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +TEST_CASE("3dx fclaw_clawpatch_vtable_initialize fails if called twice on a glob") +{ + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_store_domain(glob1, domain); + fclaw_global_t* glob2 = fclaw_global_new(); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + fclaw_clawpatch_options_store(glob1, opts); + fclaw_clawpatch_options_store(glob2, opts); + + fclaw_vtables_initialize(glob1); + fclaw_vtables_initialize(glob2); + + fclaw_clawpatch_vtable_initialize(glob1,4); + CHECK_SC_ABORTED(fclaw_clawpatch_vtable_initialize(glob1,4)); + fclaw_clawpatch_vtable_initialize(glob2,4); + CHECK_SC_ABORTED(fclaw_clawpatch_vtable_initialize(glob2,4)); + + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw_clawpatch.h.3d.TEST.cpp b/src/patches/clawpatch/fclaw_clawpatch.h.3d.TEST.cpp new file mode 100644 index 000000000..1a0e23a0d --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch.h.3d.TEST.cpp @@ -0,0 +1,1037 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define CHECK_BOX_DIMENSIONS(abox, mbc, mx, my, mz, mfields)\ +{\ + CHECK(abox.fields() == mfields);\ + CHECK(abox.box().boxDim() == 3);\ + CHECK(abox.box().smallEnd(0) == 1-mbc);\ + CHECK(abox.box().smallEnd(1) == 1-mbc);\ + CHECK(abox.box().smallEnd(2) == 1-mbc);\ + CHECK(abox.box().bigEnd(0) == mx+mbc);\ + CHECK(abox.box().bigEnd(1) == my+mbc);\ + CHECK(abox.box().bigEnd(2) == mz+mbc);\ +} +#define CHECK_BOX_EMPTY(abox)\ +{\ + CHECK(abox.fields() == 0);\ + CHECK(abox.box().boxDim() == 0);\ +} + +namespace{ +struct SinglePatchDomain { + fclaw_global_t* glob; + fclaw_options_t fopts; + fclaw_domain_t *domain; + fclaw_clawpatch_options_t* opts; + + SinglePatchDomain(){ + glob = fclaw_global_new(); + opts = fclaw_clawpatch_options_new(3); + memset(&fopts, 0, sizeof(fopts)); + fopts.mi=1; + fopts.mj=1; + fopts.minlevel=0; + fopts.manifold=false; + fopts.bx = 1; + fopts.by = 2; + fopts.bz = 3; + fopts.compute_error = true; + fopts.subcycle = true; + fclaw_options_store(glob, &fopts); + + opts->mx = 5; + opts->my = 6; + opts->mz = 7; + opts->mbc = 2; + opts->meqn = 1; + opts->maux = 1; + opts->rhs_fields = 1; + fclaw_clawpatch_options_store(glob, opts); + + domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob, domain); + + fclaw_map_store(glob, fclaw_map_new_nomap()); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + + } + void setup(){ + fclaw_build_mode_t build_mode = FCLAW_BUILD_FOR_UPDATE; + fclaw_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); + } + ~SinglePatchDomain(){ + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[0]); + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + //fclaw2d_map_destroy(map); + fclaw_global_destroy(glob); + } +}; +struct OctDomain { + fclaw_global_t* glob; + fclaw_options_t fopts; + fclaw_domain_t *domain; + fclaw_clawpatch_options_t* opts; + + OctDomain(){ + glob = fclaw_global_new(); + opts = fclaw_clawpatch_options_new(3); + memset(&fopts, 0, sizeof(fopts)); + fopts.mi=1; + fopts.mj=1; + fopts.minlevel=1; + fopts.maxlevel=1; + fopts.manifold=false; + fopts.bx = 1; + fopts.by = 2; + fopts.bz = 3; + fopts.compute_error = true; + fopts.subcycle = true; + fclaw_options_store(glob, &fopts); + + opts->mx = 5; + opts->my = 6; + opts->mz = 7; + opts->mbc = 2; + opts->meqn = 1; + opts->maux = 1; + opts->rhs_fields = 1; + fclaw_clawpatch_options_store(glob, opts); + + domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, 1); + fclaw_global_store_domain(glob, domain); + + //map = fclaw3d_map_new_nomap(); + //fclaw_global_store_map_3d(glob, map); + fclaw_map_store(glob, fclaw_map_new_nomap()); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + + } + void setup(){ + fclaw_build_mode_t build_mode = FCLAW_BUILD_FOR_UPDATE; + for(int i=0; i<8; i++) + { + fclaw_patch_build(glob, &domain->blocks[0].patches[i], 0, i, &build_mode); + } + } + ~OctDomain(){ + for(int i=0; i<8; i++) + { + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[i]); + } + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + //fclaw3d_map_destroy(map); + fclaw_global_destroy(glob); + } +}; +} +TEST_CASE("3d fclaw_clawpatch_vtable_initialize") +{ + fclaw_domain_t* domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + fclaw_clawpatch_options_store(glob, opts); + + fclaw_vtables_initialize(glob); + + fclaw_clawpatch_vtable_initialize(glob, 4); + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(glob); + + CHECK(clawpatch_vt->set_user_data == NULL); + + //ghost filling + CHECK(clawpatch_vt->d3->fort_copy_face == &FCLAW3D_CLAWPATCH46_FORT_COPY_FACE); + CHECK(clawpatch_vt->d3->fort_average_face == &FCLAW3D_CLAWPATCH46_FORT_AVERAGE_FACE); + CHECK(clawpatch_vt->d3->fort_interpolate_face == &FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_FACE); + + CHECK(clawpatch_vt->d3->fort_copy_edge == &FCLAW3D_CLAWPATCH46_FORT_COPY_EDGE); + + CHECK(clawpatch_vt->d3->fort_copy_corner == &FCLAW3D_CLAWPATCH46_FORT_COPY_CORNER); + CHECK(clawpatch_vt->d3->fort_average_corner == &FCLAW3D_CLAWPATCH46_FORT_AVERAGE_CORNER); + CHECK(clawpatch_vt->d3->fort_interpolate_corner == &FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE_CORNER); + + //regridding + CHECK(clawpatch_vt->d3->fort_tag4refinement == &FCLAW3D_CLAWPATCH46_FORT_TAG4REFINEMENT); + CHECK(clawpatch_vt->d3->fort_tag4coarsening_3dx == NULL); + CHECK(clawpatch_vt->d3->fort_tag4coarsening == &FCLAW3D_CLAWPATCH46_FORT_TAG4COARSENING); + CHECK(clawpatch_vt->d3->fort_user_exceeds_threshold == NULL); + CHECK(clawpatch_vt->d3->fort_interpolate2fine == &FCLAW3D_CLAWPATCH46_FORT_INTERPOLATE2FINE); + CHECK(clawpatch_vt->d3->fort_average2coarse == &FCLAW3D_CLAWPATCH46_FORT_AVERAGE2COARSE); + + //ascii output + CHECK(clawpatch_vt->time_header_ascii == &fclaw_clawpatch_time_header_ascii); + CHECK(clawpatch_vt->fort_header_ascii == &FCLAW3D_CLAWPATCH46_FORT_HEADER_ASCII); + CHECK(clawpatch_vt->cb_output_ascii == &cb_clawpatch_output_ascii); + CHECK(clawpatch_vt->d3->fort_output_ascii == &FCLAW3D_CLAWPATCH46_FORT_OUTPUT_ASCII); + + //time interpolation + CHECK(clawpatch_vt->d3->fort_timeinterp == &FCLAW3D_CLAWPATCH46_FORT_TIMEINTERP); + + //ghot packing + CHECK(clawpatch_vt->d3->fort_local_ghost_pack == &FCLAW3D_CLAWPATCH46_FORT_LOCAL_GHOST_PACK); + CHECK(clawpatch_vt->local_ghost_pack_aux == NULL); + + //diagnostics + CHECK(clawpatch_vt->conservation_check == NULL); + CHECK(clawpatch_vt->compute_error == NULL); + CHECK(clawpatch_vt->d3->fort_compute_patch_error == NULL); + CHECK(clawpatch_vt->d3->fort_conservation_check == NULL); + CHECK(clawpatch_vt->d3->fort_compute_error_norm == NULL); + CHECK(clawpatch_vt->d3->fort_compute_patch_area == NULL); + + CHECK(clawpatch_vt->is_set == 1); + + fclaw_patch_vtable_t * patch_vt = fclaw_patch_vt(glob); + //create delete build + CHECK(patch_vt->patch_new != NULL); + CHECK(patch_vt->patch_delete != NULL); + CHECK(patch_vt->build != NULL); + CHECK(patch_vt->build_from_fine != NULL); + CHECK(patch_vt->setup == NULL); + + //ghost filling + CHECK(patch_vt->copy_edge != NULL); + + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); +} +TEST_CASE("3d fclaw_clawpatch patch_build") +{ + for(const int& compute_error : {0,1}) + for(const int& subcycle : {0,1}) + for(const int& mx : {4,5,6}) + for(const int& my : {4,5,6}) + for(const int& mz : {4,5,6}) + for(const int& mbc : {1,2}) + for(const int& meqn : {1,2}) + for(const int& maux : {0,2}) + for(const int& rhs_fields : {0,2}) + for(fclaw_build_mode_t build_mode : {FCLAW_BUILD_FOR_GHOST_AREA_COMPUTED, FCLAW_BUILD_FOR_UPDATE}) + { + fclaw_global_t* glob = fclaw_global_new(); + + fclaw_options_t fopts; + memset(&fopts, 0, sizeof(fopts)); + fopts.mi=1; + fopts.mj=1; + fopts.minlevel=0; + fopts.manifold=false; + fopts.bx = 1; + fopts.by = 2; + fopts.bz = 3; + fopts.compute_error = compute_error; + fopts.subcycle = subcycle; + fclaw_options_store(glob, &fopts); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + opts->mx = mx; + opts->my = my; + opts->mz = mz; + opts->mbc = mbc; + opts->meqn = meqn; + opts->maux = maux; + opts->rhs_fields = rhs_fields; + fclaw_clawpatch_options_store(glob, opts); + + fclaw_domain_t* domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob, domain); + + fclaw_map_context_t* map = fclaw_map_new_nomap(); + fclaw_map_store(glob, map); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + + CHECK(domain->blocks[0].patches[0].user == nullptr); + fclaw_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); + CHECK(domain->blocks[0].patches[0].user != nullptr); + + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&domain->blocks[0].patches[0]); + + CHECK(cp->meqn == opts->meqn); + CHECK(cp->mx == opts->mx); + CHECK(cp->my == opts->my); + CHECK(cp->mz == opts->mz); + CHECK(cp->mbc == opts->mbc); + CHECK(cp->manifold == fopts.manifold); + CHECK(cp->d3->mp != nullptr); + + CHECK(cp->xlower == fopts.ax); + CHECK(cp->ylower == fopts.ay); + CHECK(cp->zlower == fopts.az); + CHECK(cp->xupper == fopts.bx); + CHECK(cp->yupper == fopts.by); + CHECK(cp->zupper == fopts.bz); + CHECK(cp->dx == doctest::Approx((cp->xupper-cp->xlower)/opts->mx)); + CHECK(cp->dy == doctest::Approx((cp->yupper-cp->ylower)/opts->my)); + CHECK(cp->dz == doctest::Approx((cp->zupper-cp->zlower)/opts->mz)); + + //BOX DIMENSIONS + + CHECK_BOX_DIMENSIONS(cp->griddata, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + if(build_mode == FCLAW_BUILD_FOR_UPDATE){ + CHECK_BOX_DIMENSIONS(cp->griddata_last, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + CHECK_BOX_DIMENSIONS(cp->griddata_save, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + }else{ + CHECK_BOX_EMPTY(cp->griddata_last); + CHECK_BOX_EMPTY(cp->griddata_save); + } + if(fopts.subcycle){ + CHECK_BOX_DIMENSIONS(cp->griddata_time_interpolated, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + }else{ + CHECK_BOX_EMPTY(cp->griddata_time_interpolated); + } + if(fopts.compute_error) { + CHECK_BOX_DIMENSIONS(cp->griderror, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + CHECK_BOX_DIMENSIONS(cp->exactsolution, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + }else{ + CHECK_BOX_EMPTY(cp->griderror); + CHECK_BOX_EMPTY(cp->exactsolution); + } + if(opts->rhs_fields == 0){ + CHECK_BOX_EMPTY(cp->rhs); + }else{ + CHECK_BOX_DIMENSIONS(cp->rhs, opts->mbc, opts->mx, opts->my, opts->mz, opts->rhs_fields); + } + if(opts->rhs_fields == 0 || !fopts.compute_error) { + CHECK_BOX_EMPTY(cp->elliptic_error); + CHECK_BOX_EMPTY(cp->elliptic_soln); + }else{ + CHECK_BOX_DIMENSIONS(cp->elliptic_error, opts->mbc, opts->mx, opts->my, opts->mz, opts->rhs_fields); + CHECK_BOX_DIMENSIONS(cp->elliptic_soln, opts->mbc, opts->mx, opts->my, opts->mz, opts->rhs_fields); + } + + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[0]); + fclaw_domain_destroy(domain); + fclaw_map_destroy(map); + fclaw_global_destroy(glob); + } +} + +TEST_CASE("3d fclaw_clawpatch save_step") +{ + SinglePatchDomain test_data; + test_data.setup(); + + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + cp->griddata.dataPtr()[0] = 1234; + fclaw_patch_save_step(test_data.glob,&test_data.domain->blocks[0].patches[0]); + CHECK(cp->griddata_save.dataPtr()[0] == 1234); +} + +TEST_CASE("3d fclaw_clawpatch_save_current_step") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + cp->griddata.dataPtr()[0] = 1234; + fclaw_clawpatch_save_current_step(test_data.glob,&test_data.domain->blocks[0].patches[0]); + CHECK(cp->griddata_last.dataPtr()[0] == 1234); +} + +TEST_CASE("3d fclaw_clawpatch restore_step") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + cp->griddata_save.dataPtr()[0] = 1234; + fclaw_patch_restore_step(test_data.glob,&test_data.domain->blocks[0].patches[0]); + CHECK(cp->griddata.dataPtr()[0] == 1234); +} + +#if 0 +TEST_CASE("3d fclaw_clawpatch get_metric_patch") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw2d_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + CHECK(fclaw3d_patch_metric_patch(test_data.glob, &test_data.domain->blocks[0].patches[0]) == cp->mp); +} +#endif + + +#if 0 +TEST_CASE("3d fclaw_clawpatch_get_metric_patch") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = + fclaw2d_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + CHECK(fclaw3d_clawpatch_get_metric_patch(&test_data.domain->blocks[0].patches[0]) == cp->mp); +} +#endif + +#if 0 +TEST_CASE("3d fclaw_clawpatch_get_volume") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw3d_metric_patch_t* mp = fclaw3dx_clawpatch_get_metric_patch(&test_data.domain->blocks[0].patches[0]); + CHECK(fclaw_clawpatch_get_3d_volume(test_data.glob, + &test_data.domain->blocks[0].patches[0]) == mp->volume.dataPtr()); +} +#endif + +TEST_CASE("3d fclaw_clawpatch_grid_data") +{ + for(int mx : {4,5,6}) + for(int my : {4,5,6}) + for(int mz : {4,5,6}) + for(int mbc : {1,2}) + { + + SinglePatchDomain test_data; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + int mx_out,my_out,mz_out,mbc_out; + double xlower,ylower,zlower,dx,dy,dz; + fclaw_clawpatch_3d_grid_data(test_data.glob, &test_data.domain->blocks[0].patches[0], + &mx_out, &my_out, &mz_out, &mbc_out, &xlower, &ylower, &zlower, &dx, &dy, &dz); + + CHECK(mx_out == test_data.opts->mx); + CHECK(my_out == test_data.opts->my); + CHECK(mz_out == test_data.opts->mz); + CHECK(mbc_out == test_data.opts->mbc); + CHECK(xlower == cp->xlower); + CHECK(ylower == cp->ylower); + CHECK(zlower == cp->zlower); + CHECK(dx == cp->dx); + CHECK(dy == cp->dy); + CHECK(dz == cp->dz); + + } +} + +TEST_CASE("3d fclaw_clawpatch_aux_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* aux; + int maux; + fclaw_clawpatch_aux_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &aux, &maux); + + CHECK(aux == cp->aux.dataPtr()); + CHECK(maux == test_data.opts->maux); +} + +TEST_CASE("3d fclaw_clawpatch_soln_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* q; + int meqn; + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &q, &meqn); + + CHECK(q == cp->griddata.dataPtr()); + CHECK(meqn == test_data.opts->meqn); +} + +TEST_CASE("3d fclaw_clawpatch_rhs_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* rhs; + int mfields; + fclaw_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &rhs, &mfields); + + CHECK(rhs == cp->rhs.dataPtr()); + CHECK(mfields == test_data.opts->rhs_fields); +} + +TEST_CASE("3d fclaw_clawpatch_elliptic_error_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* rhs; + int mfields; + fclaw_clawpatch_elliptic_error_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &rhs, &mfields); + + CHECK(rhs == cp->elliptic_error.dataPtr()); + CHECK(mfields == test_data.opts->rhs_fields); +} + +TEST_CASE("3d fclaw_clawpatch_elliptic_soln_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* rhs; + int mfields; + fclaw_clawpatch_elliptic_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &rhs, &mfields); + + CHECK(rhs == cp->elliptic_soln.dataPtr()); + CHECK(mfields == test_data.opts->rhs_fields); +} + +TEST_CASE("3d fclaw_clawpatch_get_q") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + CHECK(fclaw_clawpatch_get_q(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->griddata.dataPtr()); +} + +TEST_CASE("3d fclaw_clawpatch_get_error") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + CHECK(fclaw_clawpatch_get_error(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->griderror.dataPtr()); +} + +TEST_CASE("3d fclaw_clawpatch_get_exact_soln") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + CHECK(fclaw_clawpatch_get_exactsoln(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->exactsolution.dataPtr()); +} +TEST_CASE("3d fclaw_clawpatch_timesync_data") +{ + for(int time_interp : {true,false}) + { + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* q; + int meqn; + fclaw_clawpatch_timesync_data(test_data.glob, &test_data.domain->blocks[0].patches[0], time_interp, &q, &meqn); + + if(time_interp){ + CHECK(q == cp->griddata_time_interpolated.dataPtr()); + } else { + CHECK(q == cp->griddata.dataPtr()); + } + CHECK(meqn == test_data.opts->meqn); + } +} +TEST_CASE("3d fclaw_clawpatch_get_q_timesync") +{ + for(int time_interp : {true,false}) + { + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + if(time_interp){ + CHECK(fclaw_clawpatch_get_q_timesync(test_data.glob,&test_data.domain->blocks[0].patches[0],time_interp) == cp->griddata_time_interpolated.dataPtr()); + } else { + CHECK(fclaw_clawpatch_get_q_timesync(test_data.glob,&test_data.domain->blocks[0].patches[0],time_interp) == cp->griddata.dataPtr()); + } + } +} +TEST_CASE("3d fclaw_clawpatch user_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + void* user_data = (void *) 1234; + fclaw_clawpatch_set_user_data(test_data.glob, &test_data.domain->blocks[0].patches[0],user_data); + CHECK(fclaw_clawpatch_get_user_data(test_data.glob,&test_data.domain->blocks[0].patches[0]) == user_data); +} +TEST_CASE("3d fclaw_clawpatch solver_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + void* user_data = (void *) 1234; + fclaw_clawpatch_set_solver_data(test_data.glob, &test_data.domain->blocks[0].patches[0],user_data); + CHECK(fclaw_clawpatch_get_solver_data(test_data.glob,&test_data.domain->blocks[0].patches[0]) == user_data); +} + +TEST_CASE("3d fclaw_clawpatch_size") +{ + for(int mx : {4,5,6}) + for(int my : {4,5,6}) + for(int mz : {4,5,6}) + for(int mbc : {1,2}) + for(int meqn : {1,2}) + { + SinglePatchDomain test_data; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = meqn; + test_data.setup(); + + //CHECK + CHECK(fclaw_clawpatch_size(test_data.glob) == (size_t) (mx+2*mbc)*(my+2*mbc)*(mz+2*mbc)*meqn); + } +} + +#if 0 +TEST_CASE("3d fclaw_clawpatch_metric_scalar") +{ + SinglePatchDomain test_data; + test_data.setup(); + + double *mp_volume, *mp_faceareas; + double *volume, *faceareas; + + /* DAC : What is the right test here? */ + fclaw3d_metric_patch_scalar(test_data.glob, + &test_data.domain->blocks[0].patches[0], + &mp_volume, &mp_faceareas); + + fclaw3dx_clawpatch_metric_scalar(test_data.glob, + &test_data.domain->blocks[0].patches[0], + &volume, &faceareas); + + CHECK(mp_volume == volume); + CHECK(mp_faceareas == faceareas); +} +#endif + +#if 0 +/* DAC : Fix this test for fclaw3d_metric? */ +TEST_CASE("3d fclaw_clawpatch_metric_vector") +{ + fclaw_global_t* glob = fclaw_global_new(); + fclaw_vtables_initialize(glob); + + SinglePatchDomain test_data; + test_data.setup(); + + double *mp_xnormals, *mp_ynormals, *mp_xtangents, *mp_ytangents, *mp_curvature; + double *xnormals, *ynormals, *xtangents, *ytangents, *curvature; + + fclaw3d_metric_patch_vector(test_data.glob, &test_data.domain->blocks[0].patches[0], + &mp_xnormals, &mp_ynormals, + &mp_xtangents, &mp_ytangents, + &mp_curvature); + + fclaw3dx_clawpatch_metric_vector(test_data.glob, &test_data.domain->blocks[0].patches[0], + &xnormals, &ynormals, + &xtangents, &ytangents, + &curvature); + + CHECK(mp_xnormals == xnormals); + CHECK(mp_ynormals == ynormals); + CHECK(mp_xtangents == xtangents); + CHECK(mp_ytangents == ytangents); + CHECK(mp_curvature == curvature); + + fclaw_global_destroy(glob); +} +#endif + +#if 0 +TEST_CASE("3d fclaw_clawpatch_metric_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + double *mp_xp, *mp_yp, *mp_zp, *mp_xd, *mp_yd, *mp_zd, *mp_area; + double *xp, *yp, *zp, *xd, *yd, *zd, *area; + + fclaw3d_metric_patch_mesh_data(test_data.glob, &test_data.domain->blocks[0].patches[0], + &mp_xp, &mp_yp, &mp_zp, + &mp_xd, &mp_yd, &mp_zd, + &mp_area); + + fclaw3dx_clawpatch_metric_data(test_data.glob, &test_data.domain->blocks[0].patches[0], + &xp, &yp, &zp, + &xd, &yd, &zd, + &area); + + CHECK(mp_xp == xp); + CHECK(mp_yp == yp); + CHECK(mp_zp == zp); + CHECK(mp_xd == xd); + CHECK(mp_yd == yd); + CHECK(mp_zd == zd); + CHECK(mp_area == area); +} +#endif + +#if 0 +TEST_CASE("3d fclaw_clawpatch_metric_data2") +{ + SinglePatchDomain test_data; + test_data.setup(); + + double *mp_xnormals, *mp_ynormals, *mp_xtangents, *mp_ytangents, *mp_surfnormals, *mp_edgelengths, *mp_curvature; + double *xnormals, *ynormals, *xtangents, *ytangents, *surfnormals, *edgelengths, *curvature; + + fclaw3d_metric_patch_mesh_data2(test_data.glob, &test_data.domain->blocks[0].patches[0], + &mp_xnormals, &mp_ynormals, + &mp_xtangents, &mp_ytangents, + &mp_surfnormals, &mp_edgelengths, &mp_curvature); + + fclaw3dx_clawpatch_metric_data2(test_data.glob, &test_data.domain->blocks[0].patches[0], + &xnormals, &ynormals, + &xtangents, &ytangents, + &surfnormals, &edgelengths, &curvature); + + CHECK(mp_xnormals == xnormals); + CHECK(mp_ynormals == ynormals); + CHECK(mp_xtangents == xtangents); + CHECK(mp_ytangents == ytangents); + CHECK(mp_surfnormals == surfnormals); + CHECK(mp_edgelengths == edgelengths); + CHECK(mp_curvature == curvature); +} +#endif + +namespace{ + double timeinterp_alpha; + int timeinterp_mint; + fclaw_clawpatch_t* timeinterp_cp; +} + + +TEST_CASE("3d fclaw_clawpatch setup_timeinterp") +{ + SinglePatchDomain test_data; + test_data.opts->interp_stencil_width=2; + timeinterp_mint = 2; + test_data.setup(); + + + timeinterp_cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + timeinterp_alpha = 0.90210; + + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(test_data.glob); + clawpatch_vt->d3->fort_timeinterp = [] (const int *mx, const int *my, const int *mz, + const int *mbc, const int *meqn, const int *psize, + double qcurr[], double qlast[], double qinterp[], + const double *alpha, const int *ierror) + { + CHECK(*mx == timeinterp_cp->mx); + CHECK(*my == timeinterp_cp->my); + CHECK(*mz == timeinterp_cp->mz); + CHECK(*mbc == timeinterp_cp->mbc); + CHECK(*meqn == timeinterp_cp->meqn); + CHECK(*psize == (*mx)*(*my)*(*mz) + - (*mx-2*timeinterp_mint)*(*my-2*timeinterp_mint)*(*mz)); + CHECK(qcurr == timeinterp_cp->griddata.dataPtr()); + CHECK(qlast == timeinterp_cp->griddata_last.dataPtr()); + CHECK(qinterp == timeinterp_cp->griddata_time_interpolated.dataPtr()); + CHECK(*alpha == timeinterp_alpha); + }; + + fclaw_patch_setup_timeinterp(test_data.glob, &test_data.domain->blocks[0].patches[0], + timeinterp_alpha); +} +namespace{ + fclaw_clawpatch_t* t4r_cp; + int t4r_tag_patch; + int t4r_init_flag; +} +TEST_CASE("3d fclaw_clawpatch tag4refinement") +{ + for(int tag_patch : {true,false}) + for(int init_flag : {true,false}) + { + SinglePatchDomain test_data; + test_data.fopts.refine_threshold = 0.90210; + test_data.setup(); + + + t4r_cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(test_data.glob); + + t4r_tag_patch = tag_patch; + t4r_init_flag = init_flag; + clawpatch_vt->d3->fort_tag4refinement = [](const int *mx, const int *my, const int *mz, + const int *mbc, const int *meqn, + const double *xlower, const double *ylower, const double *zlower, + const double *dx, const double *dy, const double *dz, + const int *blockno, + double q[], const double *tag_threshold, const int *init_flag, + int *tag_patch) + { + CHECK(*mx == t4r_cp->mx); + CHECK(*my == t4r_cp->my); + CHECK(*mz == t4r_cp->mz); + CHECK(*mbc == t4r_cp->mbc); + CHECK(*meqn == t4r_cp->meqn); + CHECK(*xlower == t4r_cp->xlower); + CHECK(*ylower == t4r_cp->ylower); + CHECK(*zlower == t4r_cp->zlower); + CHECK(*dx == t4r_cp->dx); + CHECK(*dy == t4r_cp->dy); + CHECK(*dz == t4r_cp->dz); + CHECK(*blockno == t4r_cp->blockno); + CHECK(q == t4r_cp->griddata.dataPtr()); + CHECK(*tag_threshold == .90210); + CHECK(*init_flag == t4r_init_flag); + *tag_patch = t4r_tag_patch; + }; + + CHECK(fclaw_patch_tag4refinement(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4r_init_flag) == t4r_tag_patch); + } +} +TEST_CASE("3d fclaw_clawpatch tag4refinement negative refine threshold") +{ + for(int init_flag : {true,false}) + { + SinglePatchDomain test_data; + test_data.fopts.refine_threshold = -0.90210; + test_data.setup(); + + t4r_init_flag = init_flag; + + CHECK(fclaw_patch_tag4refinement(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4r_init_flag) == true); + } +} +namespace{ + fclaw_clawpatch_t* t4c_cp; + fclaw_clawpatch_t* t4c_cp1; + fclaw_clawpatch_t* t4c_cp2; + fclaw_clawpatch_t* t4c_cp3; + fclaw_clawpatch_t* t4c_cp4; + fclaw_clawpatch_t* t4c_cp5; + fclaw_clawpatch_t* t4c_cp6; + fclaw_clawpatch_t* t4c_cp7; + int t4c_tag_patch; + int t4c_init_flag; +} +TEST_CASE("3d fclaw_clawpatch tag4coarsening") +{ + for(int tag_patch : {true,false}) + { + t4c_tag_patch= tag_patch; + for(int init_flag : {true,false}) + { + t4c_init_flag = init_flag; + + OctDomain test_data; + test_data.fopts.coarsen_threshold = 0.90210; + test_data.setup(); + + + t4c_cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + t4c_cp1 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[1]); + t4c_cp2 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[2]); + t4c_cp3 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[3]); + t4c_cp4 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[4]); + t4c_cp5 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[5]); + t4c_cp6 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[6]); + t4c_cp7 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[7]); + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(test_data.glob); + + clawpatch_vt->d3->fort_tag4coarsening = [](const int *mx, const int *my, const int *mz, + const int *mbc, const int *meqn, + double xlower[], double ylower[], double zlower[], + const double *dx, const double *dy, const double *dz, + const int *blockno, + double q0[], double q1[], double q2[], double q3[], + double q4[], double q5[], double q6[], double q7[], + const double *tag_threshold, const int *init_flag, int *tag_patch) + { + CHECK(*mx == t4c_cp->mx); + CHECK(*my == t4c_cp->my); + CHECK(*mz == t4c_cp->mz); + CHECK(*mbc == t4c_cp->mbc); + CHECK(*meqn == t4c_cp->meqn); + CHECK(*xlower == t4c_cp->xlower); + CHECK(*ylower == t4c_cp->ylower); + CHECK(*zlower == t4c_cp->zlower); + CHECK(*dx == t4c_cp->dx); + CHECK(*dy == t4c_cp->dy); + CHECK(*dz == t4c_cp->dz); + CHECK(*blockno == t4c_cp->blockno); + CHECK(q0 == t4c_cp->griddata.dataPtr()); + CHECK(q1 == t4c_cp1->griddata.dataPtr()); + CHECK(q2 == t4c_cp2->griddata.dataPtr()); + CHECK(q3 == t4c_cp3->griddata.dataPtr()); + CHECK(q4 == t4c_cp4->griddata.dataPtr()); + CHECK(q5 == t4c_cp5->griddata.dataPtr()); + CHECK(q6 == t4c_cp6->griddata.dataPtr()); + CHECK(q7 == t4c_cp7->griddata.dataPtr()); + CHECK(*tag_threshold == .90210); + CHECK(*init_flag == t4c_init_flag); + *tag_patch = t4c_tag_patch; + }; + + CHECK(fclaw_patch_tag4coarsening(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4c_init_flag) == t4c_tag_patch); + } + } +} +TEST_CASE("3d fclaw_clawpatch tag4coarsening negative coarsen threshold") +{ + for(int init_flag : {true,false}) + { + t4c_init_flag = init_flag; + + OctDomain test_data; + test_data.fopts.coarsen_threshold = -0.90210; + test_data.setup(); + + CHECK(fclaw_patch_tag4coarsening(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4c_init_flag) == false); + } +} +namespace{ + fclaw_clawpatch_t* i2f_ccp; + fclaw_clawpatch_t* i2f_cp; + fclaw_clawpatch_t* i2f_cp1; + fclaw_clawpatch_t* i2f_cp2; + fclaw_clawpatch_t* i2f_cp3; + std::bitset<8> i2f_igrids; + int i2f_manifold; +} +TEST_CASE("3d fclaw_clawpatch interpolate2fine") +{ + i2f_manifold = false; + + OctDomain fine_test_data; + fine_test_data.fopts.manifold = i2f_manifold; + fine_test_data.setup(); + SinglePatchDomain coarse_test_data; + coarse_test_data.fopts.manifold = i2f_manifold; + coarse_test_data.setup(); + + + i2f_ccp = fclaw_clawpatch_get_clawpatch(&coarse_test_data.domain->blocks[0].patches[0]); + i2f_cp = fclaw_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[0]); + i2f_cp1 = fclaw_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[1]); + i2f_cp2 = fclaw_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[2]); + i2f_cp3 = fclaw_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[3]); + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(coarse_test_data.glob); + + clawpatch_vt->d3->fort_interpolate2fine = [](const int *mx, const int *my, const int *mz, + const int *mbc, const int *meqn, + double qcoarse[], double qfine[], double areacoarse[], double areafine[], + const int *igrid, const int *manifold) + { + CHECK(*mx == i2f_cp->mx); + CHECK(*my == i2f_cp->my); + CHECK(*mz == i2f_cp->mz); + CHECK(*mbc == i2f_cp->mbc); + CHECK(*meqn == i2f_cp->meqn); + + CHECK(qcoarse == i2f_ccp->griddata.dataPtr()); +#if PATCH_DIM == 2 + CHECK(areacoarse == i2f_ccp->mp->area.dataPtr()); + + if(*igrid==0){ + CHECK(qfine == i2f_cp->griddata.dataPtr()); + CHECK(areafine == i2f_cp->mp->area.dataPtr()); + }else if(*igrid==1){ + CHECK(qfine == i2f_cp1->griddata.dataPtr()); + CHECK(areafine == i2f_cp1->mp->area.dataPtr()); + }else if(*igrid==2){ + CHECK(qfine == i2f_cp2->griddata.dataPtr()); + CHECK(areafine == i2f_cp2->mp->area.dataPtr()); + }else if(*igrid==3){ + CHECK(qfine == i2f_cp3->griddata.dataPtr()); + CHECK(areafine == i2f_cp3->mp->area.dataPtr()); + }else{ + REQUIRE(false); + } +#endif + + CHECK(i2f_igrids[*igrid] == false); + i2f_igrids[*igrid] = true; + CHECK(*manifold == i2f_manifold); + }; + + fclaw_patch_interpolate2fine(coarse_test_data.glob, + &coarse_test_data.domain->blocks[0].patches[0], + &fine_test_data.domain->blocks[0].patches[0], + 0, 0, 0); + + CHECK(i2f_igrids.all()); +} \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw_clawpatch.h.3d.average.TEST.cpp b/src/patches/clawpatch/fclaw_clawpatch.h.3d.average.TEST.cpp new file mode 100644 index 000000000..1e18f54a8 --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch.h.3d.average.TEST.cpp @@ -0,0 +1,321 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace { +struct CubeDomain { + fclaw_global_t* glob; + fclaw_options_t fopts; + fclaw_domain_t *domain; + fclaw_clawpatch_options_t* opts; + + CubeDomain(int minlevel, int maxlevel){ + glob = fclaw_global_new_comm(sc_MPI_COMM_WORLD, 1, 0); + opts = fclaw_clawpatch_options_new(3); + memset(&fopts, 0, sizeof(fopts)); + fopts.mi=1; + fopts.mj=1; + fopts.minlevel=minlevel; + fopts.maxlevel=maxlevel; + fopts.manifold=false; + fopts.bx = 1; + fopts.by = 1; + fopts.bz = 1; + fopts.compute_error = true; + fopts.subcycle = true; + fopts.init_ghostcell = false; + fclaw_options_store(glob, &fopts); + + opts->mx = 5; + opts->my = 6; + opts->mz = 7; + opts->mbc = 2; + opts->meqn = 1; + opts->maux = 1; + opts->rhs_fields = 1; + fclaw_clawpatch_options_store(glob, opts); + + domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + fclaw_global_store_domain(glob, domain); + + //map = fclaw3d_map_new_nomap(); + //fclaw_global_store_map_3d(glob, map); + fclaw_map_store(glob, fclaw_map_new_nomap()); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + + } + void setup(){ + fclaw_initialize(glob); + } + ~CubeDomain(){ + fclaw_clawpatch_options_destroy(opts); + //fclaw_domain_destroy(domain); + //fclaw3d_map_destroy(map); + fclaw_global_destroy(glob); + } +}; + +int clawpatch_idx(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + int mx = clawpatch->mx; + int my = clawpatch->my; + int mz = clawpatch->mz; + int mbc = clawpatch->mbc; + int idx = (i+mbc) + (j+mbc)*(mx+2*mbc) + (k+mbc)*(mx+2*mbc)*(my+2*mbc) + m*(mx+2*mbc)*(my+2*mbc)*(mz+2*mbc); + return idx; +} +double fill_function(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + double x = clawpatch->xlower + (i+0.5)*clawpatch->dx; + double y = clawpatch->ylower + (j+0.5)*clawpatch->dy; + double z = clawpatch->zlower + (k+0.5)*clawpatch->dz; + switch(m) + { + case 0: + return 1; + case 1: + return 8*x + 2*y + 3*z+1; + case 2: + return 9*x + 10*y + 2*z+1; + } + return 0; +} + +}// end anonymous namespace + + +TEST_CASE("3d clawpatch average") +{ + int test_no= 0; + for(int mx : {8}) + for(int my : {8}) + for(int mz : {8}) + for(int mbc : {2}) + { + CubeDomain cube(0,1); + + cube.opts->mx = mx; + cube.opts->my = my; + cube.opts->mz = mz; + cube.opts->mbc = mbc; + cube.opts->meqn = 3; + + //refine on initialization + fclaw_patch_vtable_t* cube_patch_vt = fclaw_patch_vt(cube.glob); + fclaw_clawpatch_vtable_t* cube_clawpatch_vt = fclaw_clawpatch_vt(cube.glob); + cube_patch_vt->tag4refinement = + [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return initflag; + }; + // don't want to test interpolation + cube_clawpatch_vt->d3->fort_interpolate2fine = + [](const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold) + { + //do nothing + }; + cube_patch_vt->tag4coarsening = + [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return (int) !initflag; + }; + cube_patch_vt->physical_bc = + [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + double t, + double dt, + int intersects_phys_bdry[], + int time_interp) + { + //do nothing + }; + + cube.setup(); + CHECK_EQ(cube.glob->domain->global_num_patches, 8); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + CubeDomain cube_output(0,0); + + cube_output.opts->mx = mx+2*mbc; + cube_output.opts->my = my+2*mbc; + cube_output.opts->mz = mz+2*mbc; + cube_output.opts->mbc = mbc; + cube_output.opts->meqn = 3; + + cube_output.setup(); + + //initialize patches + fclaw_global_iterate_patches( + cube.glob, + [](fclaw_domain_t * domain, fclaw_patch_t * patch, + int blockno, int patchno, void *user) + { + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*)user; + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_get_options(g->glob); + fclaw_clawpatch_t* clawpatch = fclaw_clawpatch_get_clawpatch(patch); + // clear q + double* q = fclaw_clawpatch_get_q(g->glob, patch); + int size = fclaw_clawpatch_size(g->glob); + memset(q, 0, sizeof(double)*size); + //loop over interior + for(int m = 0; m < opts->meqn; m++) + for(int k = -opts->mbc; k < opts->mz+opts->mbc; k++) + for(int j = -opts->mbc; j < opts->my+opts->mbc; j++) + for(int i = -opts->mbc; i < opts->mx+opts->mbc; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + //fill with some different linear functions + q[idx] = fill_function(clawpatch, i, j, k, m); + } + + }, + nullptr + ); + + CHECK_EQ(cube.glob->domain->global_num_patches, 8); + fclaw_regrid(cube.glob); + CHECK_EQ(cube.glob->domain->global_num_patches, 1); + + //check ghost cells + //fill output domain with error + struct iterate_t { + fclaw_global_t* error_glob; + int num_incorrect_interior_cells; + }; + iterate_t iterate = {cube_output.glob, 0}; + fclaw_global_iterate_patches( + cube.glob, + [](fclaw_domain_t * domain, fclaw_patch_t * patch, + int blockno, int patchno, void *user) + { + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*)user; + iterate_t* iterate = (iterate_t*)g->user; + //clawpatch to store error in + fclaw_patch_t* error_patch = &iterate->error_glob->domain->blocks[blockno].patches[patchno]; + fclaw_clawpatch_t* error_clawpatch = fclaw_clawpatch_get_clawpatch(error_patch); + int mbc = error_clawpatch->mbc; + + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_get_options(g->glob); + fclaw_clawpatch_t* clawpatch = fclaw_clawpatch_get_clawpatch(patch); + + // get q + double* q = fclaw_clawpatch_get_q(g->glob, patch); + double* error_q = fclaw_clawpatch_get_q(iterate->error_glob, error_patch); + + //get physical boundaries + int intersects_bc[fclaw_domain_num_faces(domain)]; + for(int i=0;ierror_glob); + memset(error_q, 0, sizeof(double)*size); + + for(int m = 0; m < opts->meqn; m++) + for(int k = 0; k < clawpatch->mz; k++) + for(int j = 0; j < clawpatch->my; j++) + for(int i = 0; i < clawpatch->mx; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + int error_idx = clawpatch_idx(error_clawpatch, i+mbc,j+mbc,k+mbc,m); + //get expected value + double expected = fill_function(clawpatch, i, j, k, m); + error_q[error_idx] = expected - q[idx]; + if(q[idx] != doctest::Approx(expected)) + { + iterate->num_incorrect_interior_cells++; + } + } + + }, + &iterate + ); + + //check that patch was filled correctly + CHECK_EQ(iterate.num_incorrect_interior_cells, 0); + + //if not write output + if(test_output_vtk()) + { + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_average_"+std::string(test_no_str); + INFO("Test failed output error to " << filename << ".vtu"); + fclaw_clawpatch_output_vtk_to_file(cube_output.glob,filename.c_str()); + } + test_no++; + + } + +} + diff --git a/src/patches/clawpatch/fclaw_clawpatch.h.3d.ghostfill.TEST.cpp b/src/patches/clawpatch/fclaw_clawpatch.h.3d.ghostfill.TEST.cpp new file mode 100644 index 000000000..ffd4d0a7b --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch.h.3d.ghostfill.TEST.cpp @@ -0,0 +1,1261 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace { +struct TestData { + fclaw_global_t* glob; + fclaw_options_t fopts; + fclaw_domain_t *domain; + fclaw_map_context_t* map; + fclaw_clawpatch_options_t* opts; + fclaw_patch_vtable_t* patch_vt; + fclaw_clawpatch_vtable_t * clawpatch_vt; + + TestData(fclaw_domain_t* domain, fclaw_map_context_t* map, int minlevel, int maxlevel){ + glob = fclaw_global_new(); + opts = fclaw_clawpatch_options_new(3); + memset(&fopts, 0, sizeof(fopts)); + fopts.mi=1; + fopts.mj=1; + fopts.mk=1; + fopts.minlevel=minlevel; + fopts.maxlevel=maxlevel; + fopts.manifold=false; + fopts.refratio=2; + fopts.bx = 1; + fopts.by = 1; + fopts.bz = 1; + fopts.compute_error = true; + fopts.subcycle = true; + fopts.init_ghostcell = false; + fclaw_options_store(glob, &fopts); + + opts->mx = 5; + opts->my = 6; + opts->mz = 7; + opts->mbc = 2; + opts->meqn = 1; + opts->maux = 1; + opts->rhs_fields = 1; + fclaw_clawpatch_options_store(glob, opts); + + fclaw_global_store_domain(glob, domain); + + fclaw_map_store(glob, map); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + patch_vt = fclaw_patch_vt(glob); + patch_vt->physical_bc = + [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + double t, + double dt, + int intersects_phys_bdry[], + int time_interp) + { + //do nothing + }; + + clawpatch_vt = fclaw_clawpatch_vt(glob); + + } + void setup(){ + fclaw_initialize(glob); + } + ~TestData(){ + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_reset(glob); + //fclaw_domain_destroy(glob->domain); + //fclaw3d_map_destroy(map); + fclaw_global_destroy(glob); + } +}; + +int clawpatch_idx(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + int mx = clawpatch->mx; + int my = clawpatch->my; + int mz = clawpatch->mz; + int mbc = clawpatch->mbc; + int idx = (i+mbc) + (j+mbc)*(mx+2*mbc) + (k+mbc)*(mx+2*mbc)*(my+2*mbc) + m*(mx+2*mbc)*(my+2*mbc)*(mz+2*mbc); + return idx; +} +double fill_function(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + double x = clawpatch->xlower + (i+0.5)*clawpatch->dx; + double y = clawpatch->ylower + (j+0.5)*clawpatch->dy; + double z = clawpatch->zlower + (k+0.5)*clawpatch->dz; + switch(m) + { + case 0: + return 1; + case 1: + return 8*x + 2*y + 3*z+1; + case 2: + return 9*x + 10*y + 2*z+1; + } + return 0; +} +void get_bounds_with_ghost(fclaw_clawpatch_t* clawpatch, + int *intersects_bc, + int *i_start, + int *i_stop, + int *j_start, + int *j_stop, + int *k_start, + int *k_stop) +{ + *i_start = intersects_bc[0] ? 0 : -clawpatch->mbc; + *i_stop = intersects_bc[1] ? clawpatch->mx : clawpatch->mx + clawpatch->mbc; + + *j_start = intersects_bc[2] ? 0 : -clawpatch->mbc; + *j_stop = intersects_bc[3] ? clawpatch->my : clawpatch->my + clawpatch->mbc; + + *k_start = intersects_bc[4] ? 0 : -clawpatch->mbc; + *k_stop = intersects_bc[5] ? clawpatch->mz : clawpatch->mz + clawpatch->mbc; +} +bool interior_cell(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + int mx = clawpatch->mx; + int my = clawpatch->my; + int mz = clawpatch->mz; + return i >= 0 && i < mx && j >= 0 && j < my && k >= 0 && k < mz; +} +bool face_ghost_cell(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + int mx = clawpatch->mx; + int my = clawpatch->my; + int mz = clawpatch->mz; + return ((i < 0 || i >= mx) && j >= 0 && j < my && k >= 0 && k < mz) || + (i >= 0 && i < mx && (j < 0 || j >= my) && k >= 0 && k < mz) || + (i >= 0 && i < mx && j >= 0 && j < my && (k < 0 || k >= mz)); +} +bool edge_ghost_cell(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + int mx = clawpatch->mx; + int my = clawpatch->my; + int mz = clawpatch->mz; + return ((i < 0 || i >= mx) && (j < 0 || j >= my) && k >= 0 && k < mz) || + ((i < 0 || i >= mx) && j >= 0 && j < my && (k < 0 || k >= mz)) || + (i >= 0 && i < mx && (j < 0 || j >= my) && (k < 0 || k >= mz)); +} +bool corner_ghost_cell(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + int mx = clawpatch->mx; + int my = clawpatch->my; + int mz = clawpatch->mz; + return (i < 0 || i >= mx) && (j < 0 || j >= my) && (k < 0 || k >= mz); +} + +void init_patch(fclaw_global_t* glob, fclaw_patch_t* patch) +{ + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_get_options(glob); + fclaw_clawpatch_t* clawpatch = fclaw_clawpatch_get_clawpatch(patch); + // clear q + double* q = fclaw_clawpatch_get_q(glob, patch); + int size = fclaw_clawpatch_size(glob); + memset(q, 0, sizeof(double)*size); + //fill entire patch + for(int m = 0; m < opts->meqn; m++) + for(int k = -opts->mbc; k < opts->mz+opts->mbc; k++) + for(int j = -opts->mbc; j < opts->my+opts->mbc; j++) + for(int i = -opts->mbc; i < opts->mx+opts->mbc; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + //fill with some different linear functions + q[idx] = fill_function(clawpatch, i, j, k, m); + } + + //get physical boundaries + int intersects_bc[fclaw_domain_num_faces(glob->domain)]; + for(int i=0;idomain);i++) + { + fclaw_patch_relation_t type = fclaw_patch_get_face_type(patch, i); + intersects_bc[i] = type == FCLAW_PATCH_BOUNDARY; + } + + //zero out bounds with ghost + int i_start, i_stop, j_start, j_stop, k_start, k_stop; + get_bounds_with_ghost(clawpatch, intersects_bc,&i_start,&i_stop,&j_start,&j_stop,&k_start,&k_stop); + for(int m = 0; m < opts->meqn; m++) + for(int k = k_start; k < k_stop; k++) + for(int j = j_start; j < j_stop; j++) + for(int i = i_start; i < i_stop; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + q[idx]=0; + } + + //fill interior + for(int m = 0; m < opts->meqn; m++) + for(int k = 0; k < opts->mz; k++) + for(int j = 0; j < opts->my; j++) + for(int i = 0; i < opts->mx; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + //fill with some different linear functions + q[idx] = fill_function(clawpatch, i, j, k, m); + } +} +void test_ghost_fill(TestData& tdata, TestData& tdata_out, std::string output_filename) +{ + //initialize patches + fclaw_global_iterate_patches( + tdata.glob, + [](fclaw_domain_t * domain, fclaw_patch_t * patch, + int blockno, int patchno, void *user) + { + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*)user; + init_patch(g->glob, patch); + }, + nullptr + ); + + fclaw_ghost_update(tdata.glob, tdata.fopts.minlevel, tdata.fopts.maxlevel, 0, 0, FCLAW_TIMER_NONE); + + //check ghost cells + //fill output domain with error + struct iterate_t { + fclaw_global_t* error_glob; + int num_incorrect_interior_cells; + int num_incorrect_face_ghost_cells; + int num_incorrect_edge_ghost_cells; + int num_incorrect_corner_ghost_cells; + }; + iterate_t iterate = {tdata_out.glob, 0, 0, 0, 0}; + fclaw_global_iterate_patches( + tdata.glob, + [](fclaw_domain_t * domain, fclaw_patch_t * patch, + int blockno, int patchno, void *user) + { + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*)user; + iterate_t* iterate = (iterate_t*)g->user; + //clawpatch to store error in + fclaw_patch_t* error_patch = &iterate->error_glob->domain->blocks[blockno].patches[patchno]; + fclaw_clawpatch_t* error_clawpatch = fclaw_clawpatch_get_clawpatch(error_patch); + int mbc = error_clawpatch->mbc; + + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_get_options(g->glob); + fclaw_clawpatch_t* clawpatch = fclaw_clawpatch_get_clawpatch(patch); + + // get q + double* q = fclaw_clawpatch_get_q(g->glob, patch); + double* error_q = fclaw_clawpatch_get_q(iterate->error_glob, error_patch); + + //get physical boundaries + int intersects_bc[fclaw_domain_num_faces(domain)]; + for(int i=0;ierror_glob); + memset(error_q, 0, sizeof(double)*size); + + //loop over all cells + int i_start, i_stop, j_start, j_stop, k_start, k_stop; + get_bounds_with_ghost(clawpatch, intersects_bc,&i_start,&i_stop,&j_start,&j_stop,&k_start,&k_stop); + for(int m = 0; m < opts->meqn; m++) + for(int k = k_start; k < k_stop; k++) + for(int j = j_start; j < j_stop; j++) + for(int i = i_start; i < i_stop; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + int error_idx = clawpatch_idx(error_clawpatch, i+mbc,j+mbc,k+mbc,m); + //get expected value + double expected = fill_function(clawpatch, i, j, k, m); + error_q[error_idx] = expected - q[idx]; + if(q[idx] != doctest::Approx(expected)) + { + if(interior_cell(clawpatch, i,j,k,m)) + { + iterate->num_incorrect_interior_cells++; + } + else if(face_ghost_cell(clawpatch, i,j,k,m)) + { + iterate->num_incorrect_face_ghost_cells++; + } + else if(edge_ghost_cell(clawpatch, i,j,k,m)) + { + iterate->num_incorrect_edge_ghost_cells++; + } + else if(corner_ghost_cell(clawpatch, i,j,k,m)) + { + iterate->num_incorrect_corner_ghost_cells++; + } + else{ + SC_ABORT_NOT_REACHED(); + } + } + } + + }, + &iterate + ); + + //check that patch was filled correctly + CHECK_EQ(iterate.num_incorrect_interior_cells, 0); + CHECK_EQ(iterate.num_incorrect_face_ghost_cells, 0); + CHECK_EQ(iterate.num_incorrect_edge_ghost_cells, 0); + CHECK_EQ(iterate.num_incorrect_corner_ghost_cells, 0); + + //write output if --vtk option passed to test runner + if(test_output_vtk()) + { + INFO("Test failed output error to " << output_filename << ".vtu"); + fclaw_clawpatch_output_vtk_to_file(tdata_out.glob,output_filename.c_str()); + } +} + +}// end anonymous namespace + +//TODO move this somewhere else +TEST_CASE("3d clawpatch ghost pack/unpack") +{ + for(int mx : {8,9,10}) + for(int my : {8,9,10}) + for(int mz : {8,9,10}) + for(int mbc : {1,2}) + { + int minlevel = 1; + int maxlevel = 1; + fclaw_domain_t* domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + fclaw_map_context_t* map = fclaw_map_new_nomap(); + TestData test_data(domain, map, minlevel, maxlevel); + + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + test_data.setup(); + + size_t expected_packsize = + ((mx+2*mbc)*(my+2*mbc)*(mz+2*mbc) -(mx-2*mbc*2)*(my-2*mbc*2)*(mz-2*mbc*2)) //1-interior + *3*sizeof(double); + + REQUIRE_EQ(fclaw_patch_ghost_packsize(test_data.glob), expected_packsize); + + fclaw_patch_t * patch = &test_data.glob->domain->blocks[0].patches[0]; + fclaw_clawpatch_t* clawpatch = fclaw_clawpatch_get_clawpatch(patch); + double * q = fclaw_clawpatch_get_q(test_data.glob, patch); + + for(int m = 0; m < 3; m++) + for(int k = -mbc; k < mz+mbc; k++) + for(int j = -mbc; j < my+mbc; j++) + for(int i = -mbc; i < mx+mbc; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + //fill with some different linear functions + q[idx] = fill_function(clawpatch, i, j, k, m); + } + + double pack_buffer[expected_packsize/sizeof(double)]; + fclaw_patch_local_ghost_pack(test_data.glob, patch, pack_buffer,0); + + memset(q, 0, sizeof(double)*fclaw_clawpatch_size(test_data.glob)); + + fclaw_patch_remote_ghost_unpack(test_data.glob,patch, 0,0,pack_buffer,0); + + for(int m = 0; m < test_data.opts->meqn; m++) + for(int k = -mbc; k < test_data.opts->mz+mbc; k++) + for(int j = -mbc; j < test_data.opts->my+mbc; j++) + for(int i = -mbc; i < test_data.opts->mx+mbc; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + if((i>=2*mbc && i < mx-2*mbc) && (j>=2*mbc && j < my-2*mbc)&& (k>=2*mbc && k < mz-2*mbc)) + { + CHECK_EQ(q[idx], 0); + } + else + { + CHECK_EQ(q[idx], fill_function(clawpatch, i, j, k, m)); + } + } + } +} +TEST_CASE("3dx clawpatch ghost pack/unpack") +{ + for(int mx : {8,9,10}) + for(int my : {8,9,10}) + for(int mz : {8,9,10}) + for(int mbc : {1,2}) + { + int minlevel = 1; + int maxlevel = 1; + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, minlevel); + fclaw_map_context_t* map = fclaw_map_new_nomap(); + TestData test_data(domain, map, minlevel, maxlevel); + + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + test_data.setup(); + + INFO("mx="<mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + test_data.setup(); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + fclaw_domain_t* domain_out = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + TestData test_data_out(domain_out, map, minlevel, maxlevel); + + test_data_out.opts->mx = mx+2*mbc; + test_data_out.opts->my = my+2*mbc; + test_data_out.opts->mz = mz+2*mbc; + test_data_out.opts->mbc = mbc; + test_data_out.opts->meqn = 3; + + test_data_out.setup(); + + + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_ghost_fill_on_uniform_cube_"+std::string(test_no_str); + + test_ghost_fill(test_data, test_data_out, filename); + + test_no++; + + } + +} + +TEST_CASE("3d clawpatch ghost fill on cube with refinement") +{ + int test_no= 0; + for(int mx : {8}) + for(int my : {8}) + for(int mz : {8}) + for(int mbc : {2}) + { + int minlevel = 2; + int maxlevel = 4; + fclaw_domain_t* domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + fclaw_map_context_t* map = fclaw_map_new_nomap(); + TestData test_data(domain, map, minlevel, maxlevel); + + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + //refine on if interior patch + auto tag4refinement + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + if(patch->xlower == doctest::Approx(0.5)&& + patch->ylower == doctest::Approx(0.5)&& + patch->zlower == doctest::Approx(0.5)) + { + return 1; + } + else + { + return 0; + } + }; + auto tag4coarsening + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return 0; + }; + auto fort_interpolate2fine + =[](const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold) + { + //do nothing + }; + + test_data.patch_vt->tag4refinement = tag4refinement; + test_data.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data.glob->domain->global_num_patches, 64); + test_data.setup(); + CHECK_EQ(test_data.glob->domain->global_num_patches, 127); + domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + fclaw_domain_t* domain_out = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + TestData test_data_out(domain_out, map, minlevel, maxlevel); + + test_data_out.opts->mx = mx+2*mbc; + test_data_out.opts->my = my+2*mbc; + test_data_out.opts->mz = mz+2*mbc; + test_data_out.opts->mbc = mbc; + test_data_out.opts->meqn = 3; + + test_data_out.patch_vt->tag4refinement = tag4refinement; + test_data_out.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data_out.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 64); + test_data_out.setup(); + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 127); + + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_ghost_fill_on_cube_with_refinement_"+std::string(test_no_str); + + test_ghost_fill(test_data, test_data_out, filename); + + test_no++; + } + +} +TEST_CASE("3d clawpatch ghost fill on cube with refinement coarse interior") +{ + int test_no= 0; + for(int mx : {8}) + for(int my : {8}) + for(int mz : {8}) + for(int mbc : {2}) + { + int minlevel = 2; + int maxlevel = 3; + fclaw_domain_t* domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + fclaw_map_context_t* map = fclaw_map_new_nomap(); + TestData test_data(domain, map, minlevel, maxlevel); + + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + //refine on if interior patch + auto tag4refinement + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + if(patch->xlower == 0 || + patch->ylower == 0 || + patch->zlower == 0 || + patch->xupper == 1 || + patch->yupper == 1 || + patch->zupper == 1) + { + return 1; + } + else + { + return 0; + } + }; + auto tag4coarsening + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return 0; + }; + auto fort_interpolate2fine + =[](const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold) + { + //do nothing + }; + + test_data.patch_vt->tag4refinement = tag4refinement; + test_data.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data.glob->domain->global_num_patches, 64); + test_data.setup(); + CHECK_EQ(test_data.glob->domain->global_num_patches, 456); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + fclaw_domain_t* domain_out = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + TestData test_data_out(domain_out, map, minlevel, maxlevel); + + test_data_out.opts->mx = mx+2*mbc; + test_data_out.opts->my = my+2*mbc; + test_data_out.opts->mz = mz+2*mbc; + test_data_out.opts->mbc = mbc; + test_data_out.opts->meqn = 3; + + test_data_out.patch_vt->tag4refinement = tag4refinement; + test_data_out.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data_out.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 64); + test_data_out.setup(); + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 456); + + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_ghost_fill_on_cube_with_refinement_coarse_interior_"+std::string(test_no_str); + + test_ghost_fill(test_data, test_data_out, filename); + + test_no++; + + } + +} + +TEST_CASE("3d clawpatch ghost fill on uniform brick") +{ + int test_no= 0; + for(int mi : {1,2,3}) + for(int mj : {1,2,3}) + for(int mk : {1,2,3}) + for(int mx : {10}) + for(int my : {10}) + for(int mz : {10}) + for(int mbc : {1,2}) + { + int minlevel = 2; + int maxlevel = 2; + fclaw_domain_t* domain = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, mi, mj, mk, 0, 0, 0, minlevel); + fclaw_map_context_t* brick = fclaw_map_new_3d_brick(domain, mi, mj, mk, 0, 0, 0); + fclaw_map_context_t* map = fclaw_map_new_nomap_brick(brick); + TestData test_data(domain, map, minlevel, maxlevel); + + test_data.fopts.mi = mi; + test_data.fopts.mj = mj; + test_data.fopts.mk = mk; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + test_data.setup(); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + fclaw_domain_t* domain_out = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, mi, mj, mk, 0, 0, 0, minlevel); + TestData test_data_out(domain_out, map, minlevel, maxlevel); + + test_data_out.fopts.mi = mi; + test_data_out.fopts.mj = mj; + test_data_out.fopts.mk = mk; + test_data_out.opts->mx = mx+2*mbc; + test_data_out.opts->my = my+2*mbc; + test_data_out.opts->mz = mz+2*mbc; + test_data_out.opts->mbc = mbc; + test_data_out.opts->meqn = 3; + + test_data_out.setup(); + + + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_ghost_fill_on_uniform_2x2x2_brick_" + std::string(test_no_str); + + test_ghost_fill(test_data, test_data_out, filename); + + test_no++; + + } + +} +TEST_CASE("3d clawpatch ghost fill on 2x2x2 brick with refinement on one block") +{ + int test_no= 0; + for(int mx : {8}) + for(int my : {8}) + for(int mz : {8}) + for(int mbc : {2}) + for(int block_to_refine = 0; block_to_refine < 8; block_to_refine++) + { + int minlevel = 1; + int maxlevel = 2; + fclaw_domain_t* domain = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, 2, 2, 2, 0, 0, 0, minlevel); + fclaw_map_context_t* brick = fclaw_map_new_3d_brick(domain, 2, 2, 2, 0, 0, 0); + fclaw_map_context_t* map = fclaw_map_new_nomap_brick(brick); + TestData test_data(domain, map, minlevel, maxlevel); + + test_data.fopts.mi = 2; + test_data.fopts.mj = 2; + test_data.fopts.mk = 2; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + test_data.glob->user = &block_to_refine; + + //refine on if interior patch + auto tag4refinement + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + int* block_to_refine = (int*)glob->user; + return (int) (blockno == *block_to_refine); + }; + auto tag4coarsening + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return 0; + }; + auto fort_interpolate2fine + =[](const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold) + { + //do nothing + }; + + test_data.patch_vt->tag4refinement = tag4refinement; + test_data.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data.glob->domain->global_num_patches, (8*8)); + test_data.setup(); + CHECK_EQ(test_data.glob->domain->global_num_patches, (8*7 + 8*8)); + domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + fclaw_domain_t* domain_out = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, 2, 2, 2, 0, 0, 0, minlevel); + TestData test_data_out(domain_out, map, minlevel, maxlevel); + + test_data_out.fopts.mi = 2; + test_data_out.fopts.mj = 2; + test_data_out.fopts.mk = 2; + test_data_out.opts->mx = mx+2*mbc; + test_data_out.opts->my = my+2*mbc; + test_data_out.opts->mz = mz+2*mbc; + test_data_out.opts->mbc = mbc; + test_data_out.opts->meqn = 3; + + test_data_out.glob->user = &block_to_refine; + + test_data_out.patch_vt->tag4refinement = tag4refinement; + test_data_out.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data_out.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data_out.glob->domain->global_num_patches, (8*8)); + test_data_out.setup(); + CHECK_EQ(test_data_out.glob->domain->global_num_patches, (8*7 + 8*8)); + + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_ghost_fill_on_2x2x2_brick_with_refinement_on_one_block_"+std::string(test_no_str); + + test_ghost_fill(test_data, test_data_out, filename); + + test_no++; + } + +} + +TEST_CASE("3d clawpatch ghost fill on 2x2x2 brick with refinement on all but one block") +{ + // This test will catch hanging edge case across block edge + int test_no= 0; + for(int mx : {8}) + for(int my : {8}) + for(int mz : {8}) + for(int mbc : {2}) + for(int block_to_leave_coarse = 0; block_to_leave_coarse < 8; block_to_leave_coarse++) + { + int minlevel = 1; + int maxlevel = 2; + fclaw_domain_t* domain = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, 2, 2, 2, 0, 0, 0, minlevel); + fclaw_map_context_t* brick = fclaw_map_new_3d_brick(domain, 2, 2, 2, 0, 0, 0); + fclaw_map_context_t* map = fclaw_map_new_nomap_brick(brick); + TestData test_data(domain, map, minlevel, maxlevel); + + test_data.fopts.mi = 2; + test_data.fopts.mj = 2; + test_data.fopts.mk = 2; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + test_data.glob->user = &block_to_leave_coarse; + + //refine on if interior patch + auto tag4refinement + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + int* block_to_leave_coarse = (int*)glob->user; + return (int) (blockno != *block_to_leave_coarse); + }; + auto tag4coarsening + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return 0; + }; + auto fort_interpolate2fine + =[](const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold) + { + //do nothing + }; + + test_data.patch_vt->tag4refinement = tag4refinement; + test_data.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data.glob->domain->global_num_patches, 8*8); + test_data.setup(); + CHECK_EQ(test_data.glob->domain->global_num_patches, 8*1 + 8*8*7); + domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + fclaw_domain_t* domain_out = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, 2, 2, 2, 0, 0, 0, minlevel); + TestData test_data_out(domain_out, map, minlevel, maxlevel); + + test_data_out.fopts.mi = 2; + test_data_out.fopts.mj = 2; + test_data_out.fopts.mk = 2; + test_data_out.opts->mx = mx+2*mbc; + test_data_out.opts->my = my+2*mbc; + test_data_out.opts->mz = mz+2*mbc; + test_data_out.opts->mbc = mbc; + test_data_out.opts->meqn = 3; + + test_data_out.glob->user = &block_to_leave_coarse; + + test_data_out.patch_vt->tag4refinement = tag4refinement; + test_data_out.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data_out.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 8*8); + test_data_out.setup(); + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 8*1 + 8*8*7); + + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_ghost_fill_on_2x2x2_brick_with_refinement_on_all_but_one_block_"+std::string(test_no_str); + + test_ghost_fill(test_data, test_data_out, filename); + + test_no++; + } + +} + +TEST_CASE("3d clawpatch ghost fill on 2x2x2 brick with refinement coarse interior") +{ + // This test will catch hanging edge case across block faces also + int test_no= 0; + for(int mx : {8}) + for(int my : {8}) + for(int mz : {8}) + for(int mbc : {2}) + for(int block_to_leave_coarse = 0; block_to_leave_coarse < 8; block_to_leave_coarse++) + { + int minlevel = 1; + int maxlevel = 2; + fclaw_domain_t* domain = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, 2, 2, 2, 0, 0, 0, minlevel); + fclaw_map_context_t* brick = fclaw_map_new_3d_brick(domain, 2, 2, 2, 0, 0, 0); + fclaw_map_context_t* map = fclaw_map_new_nomap_brick(brick); + TestData test_data(domain, map, minlevel, maxlevel); + + test_data.fopts.mi = 2; + test_data.fopts.mj = 2; + test_data.fopts.mk = 2; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + test_data.glob->user = &block_to_leave_coarse; + + //refine on if interior patch + auto tag4refinement + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(patch); + int* block_to_leave_coarse = (int*)glob->user; + int retval = (blockno != *block_to_leave_coarse) + ||!((cp->xlower == doctest::Approx(0.5) || cp->xupper == doctest::Approx(0.5)) + && (cp->ylower == doctest::Approx(0.5) || cp->yupper == doctest::Approx(0.5)) + && (cp->zlower == doctest::Approx(0.5) || cp->zupper == doctest::Approx(0.5))); + return retval; + }; + auto tag4coarsening + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return 0; + }; + auto fort_interpolate2fine + =[](const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold) + { + //do nothing + }; + + test_data.patch_vt->tag4refinement = tag4refinement; + test_data.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data.glob->domain->global_num_patches, 8*8); + test_data.setup(); + CHECK_EQ(test_data.glob->domain->global_num_patches, 505); + domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + fclaw_domain_t* domain_out = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, 2, 2, 2, 0, 0, 0, minlevel); + TestData test_data_out(domain_out, map, minlevel, maxlevel); + + test_data_out.fopts.mi = 2; + test_data_out.fopts.mj = 2; + test_data_out.fopts.mk = 2; + test_data_out.opts->mx = mx+2*mbc; + test_data_out.opts->my = my+2*mbc; + test_data_out.opts->mz = mz+2*mbc; + test_data_out.opts->mbc = mbc; + test_data_out.opts->meqn = 3; + + test_data_out.glob->user = &block_to_leave_coarse; + + test_data_out.patch_vt->tag4refinement = tag4refinement; + test_data_out.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data_out.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 8*8); + test_data_out.setup(); + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 505); + + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_ghost_fill_on_2x2x2_brick_with_refinement_coarse_interior_"+std::string(test_no_str); + + test_ghost_fill(test_data, test_data_out, filename); + + test_no++; + } + +} + +TEST_CASE("3d clawpatch ghost fill on 2x2x2 brick with refinement 2") +{ + // This test will catch hanging edge case across block faces also + int test_no= 0; + for(int mx : {8}) + for(int my : {8}) + for(int mz : {8}) + for(int mbc : {2}) + for(int block_to_leave_coarse = 0; block_to_leave_coarse < 8; block_to_leave_coarse++) + { + int minlevel = 1; + int maxlevel = 2; + fclaw_domain_t* domain = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, 2, 2, 2, 0, 0, 0, minlevel); + fclaw_map_context_t* brick = fclaw_map_new_3d_brick(domain, 2, 2, 2, 0, 0, 0); + fclaw_map_context_t* map = fclaw_map_new_nomap_brick(brick); + TestData test_data(domain, map, minlevel, maxlevel); + + test_data.fopts.mi = 2; + test_data.fopts.mj = 2; + test_data.fopts.mk = 2; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = 3; + + test_data.glob->user = &block_to_leave_coarse; + + //refine on if interior patch + auto tag4refinement + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(patch); + int* block_to_leave_coarse = (int*)glob->user; + int retval = (blockno != *block_to_leave_coarse) + && (cp->xlower == doctest::Approx(0.5) || cp->xupper == doctest::Approx(0.5)) + && (cp->ylower == doctest::Approx(0.5) || cp->yupper == doctest::Approx(0.5)) + && (cp->zlower == doctest::Approx(0.5) || cp->zupper == doctest::Approx(0.5)); + return retval; + }; + auto tag4coarsening + = [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return 0; + }; + auto fort_interpolate2fine + =[](const int* mx, + const int* my, + const int* mz, + const int* mbc, + const int* meqn, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + const int* igrid, + const int* manifold) + { + //do nothing + }; + + test_data.patch_vt->tag4refinement = tag4refinement; + test_data.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data.glob->domain->global_num_patches, 8*8); + test_data.setup(); + CHECK_EQ(test_data.glob->domain->global_num_patches, 113); + domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + fclaw_domain_t* domain_out = fclaw_domain_new_3d_brick(sc_MPI_COMM_WORLD, 2, 2, 2, 0, 0, 0, minlevel); + TestData test_data_out(domain_out, map, minlevel, maxlevel); + + test_data_out.fopts.mi = 2; + test_data_out.fopts.mj = 2; + test_data_out.fopts.mk = 2; + test_data_out.opts->mx = mx+2*mbc; + test_data_out.opts->my = my+2*mbc; + test_data_out.opts->mz = mz+2*mbc; + test_data_out.opts->mbc = mbc; + test_data_out.opts->meqn = 3; + + test_data_out.glob->user = &block_to_leave_coarse; + + test_data_out.patch_vt->tag4refinement = tag4refinement; + test_data_out.patch_vt->tag4coarsening = tag4coarsening; + // don't want to test interpolation + test_data_out.clawpatch_vt->d3->fort_interpolate2fine = fort_interpolate2fine; + + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 8*8); + test_data_out.setup(); + CHECK_EQ(test_data_out.glob->domain->global_num_patches, 113); + + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_ghost_fill_on_2x2x2_brick_with_refinement_2_"+std::string(test_no_str); + + test_ghost_fill(test_data, test_data_out, filename); + + test_no++; + } + +} \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw_clawpatch.h.3d.interpolate.TEST.cpp b/src/patches/clawpatch/fclaw_clawpatch.h.3d.interpolate.TEST.cpp new file mode 100644 index 000000000..a41629166 --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch.h.3d.interpolate.TEST.cpp @@ -0,0 +1,302 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace { +struct CubeDomain { + fclaw_global_t* glob; + fclaw_options_t fopts; + fclaw_domain_t *domain; + fclaw_clawpatch_options_t* opts; + + CubeDomain(int minlevel, int maxlevel){ + glob = fclaw_global_new_comm(sc_MPI_COMM_WORLD, 1,0); + opts = fclaw_clawpatch_options_new(3); + memset(&fopts, 0, sizeof(fopts)); + fopts.mi=1; + fopts.mj=1; + fopts.minlevel=minlevel; + fopts.maxlevel=maxlevel; + fopts.manifold=false; + fopts.bx = 1; + fopts.by = 1; + fopts.bz = 1; + fopts.compute_error = true; + fopts.subcycle = true; + fopts.init_ghostcell = false; + fclaw_options_store(glob, &fopts); + + opts->mx = 5; + opts->my = 6; + opts->mz = 7; + opts->mbc = 2; + opts->meqn = 1; + opts->maux = 1; + opts->rhs_fields = 1; + fclaw_clawpatch_options_store(glob, opts); + + domain = fclaw_domain_new_unitcube(sc_MPI_COMM_WORLD, minlevel); + fclaw_global_store_domain(glob, domain); + + fclaw_map_store(glob, fclaw_map_new_nomap()); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + + } + void setup(){ + fclaw_initialize(glob); + } + ~CubeDomain(){ + fclaw_clawpatch_options_destroy(opts); + //fclaw_domain_destroy(domain); + //fclaw3d_map_destroy(map); + fclaw_global_destroy(glob); + } +}; + +int clawpatch_idx(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + int mx = clawpatch->mx; + int my = clawpatch->my; + int mz = clawpatch->mz; + int mbc = clawpatch->mbc; + int idx = (i+mbc) + (j+mbc)*(mx+2*mbc) + (k+mbc)*(mx+2*mbc)*(my+2*mbc) + m*(mx+2*mbc)*(my+2*mbc)*(mz+2*mbc); + return idx; +} +double fill_function(fclaw_clawpatch_t* clawpatch, int i, int j, int k, int m) +{ + double x = clawpatch->xlower + (i+0.5)*clawpatch->dx; + double y = clawpatch->ylower + (j+0.5)*clawpatch->dy; + double z = clawpatch->zlower + (k+0.5)*clawpatch->dz; + switch(m) + { + case 0: + return 1; + case 1: + return 8*x + 2*y + 3*z+1; + case 2: + return 9*x + 10*y + 2*z+1; + } + return 0; +} + +}// end anonymous namespace + + +TEST_CASE("3d clawpatch interpolate") +{ + int test_no= 0; + for(int mx : {8}) + for(int my : {8}) + for(int mz : {8}) + for(int mbc : {2}) + { + CubeDomain cube(1,2); + + cube.opts->mx = mx; + cube.opts->my = my; + cube.opts->mz = mz; + cube.opts->mbc = mbc; + cube.opts->meqn = 3; + + //don't refine on initialize + fclaw_patch_vtable_t* cube_patch_vt = fclaw_patch_vt(cube.glob); + cube_patch_vt->tag4refinement = + [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return (int) !initflag; + }; + cube_patch_vt->tag4coarsening = + [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + int initflag) + { + return 0; + }; + cube_patch_vt->physical_bc = + [](fclaw_global_t* glob, + fclaw_patch_t * patch, + int blockno, + int patchno, + double t, + double dt, + int intersects_phys_bdry[], + int time_interp) + { + //do nothing + }; + + cube.setup(); + CHECK_EQ(cube.glob->domain->global_num_patches, 8); + + //create output domain with bigger size, so that we can see ghost cells + //in the vtk output + CubeDomain cube_output(2,2); + + cube_output.opts->mx = mx+2*mbc; + cube_output.opts->my = my+2*mbc; + cube_output.opts->mz = mz+2*mbc; + cube_output.opts->mbc = mbc; + cube_output.opts->meqn = 3; + + cube_output.setup(); + + //initialize patches + fclaw_global_iterate_patches( + cube.glob, + [](fclaw_domain_t * domain, fclaw_patch_t * patch, + int blockno, int patchno, void *user) + { + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*)user; + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_get_options(g->glob); + fclaw_clawpatch_t* clawpatch = fclaw_clawpatch_get_clawpatch(patch); + // clear q + double* q = fclaw_clawpatch_get_q(g->glob, patch); + int size = fclaw_clawpatch_size(g->glob); + memset(q, 0, sizeof(double)*size); + //loop over interior + for(int m = 0; m < opts->meqn; m++) + for(int k = -opts->mbc; k < opts->mz+opts->mbc; k++) + for(int j = -opts->mbc; j < opts->my+opts->mbc; j++) + for(int i = -opts->mbc; i < opts->mx+opts->mbc; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + //fill with some different linear functions + q[idx] = fill_function(clawpatch, i, j, k, m); + } + + }, + nullptr + ); + + fclaw_regrid(cube.glob); + CHECK_EQ(cube.glob->domain->global_num_patches, 64); + + //check ghost cells + //fill output domain with error + struct iterate_t { + fclaw_global_t* error_glob; + int num_incorrect_interior_cells; + }; + iterate_t iterate = {cube_output.glob, 0}; + fclaw_global_iterate_patches( + cube.glob, + [](fclaw_domain_t * domain, fclaw_patch_t * patch, + int blockno, int patchno, void *user) + { + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*)user; + iterate_t* iterate = (iterate_t*)g->user; + //clawpatch to store error in + fclaw_patch_t* error_patch = &iterate->error_glob->domain->blocks[blockno].patches[patchno]; + fclaw_clawpatch_t* error_clawpatch = fclaw_clawpatch_get_clawpatch(error_patch); + int mbc = error_clawpatch->mbc; + + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_get_options(g->glob); + fclaw_clawpatch_t* clawpatch = fclaw_clawpatch_get_clawpatch(patch); + + // get q + double* q = fclaw_clawpatch_get_q(g->glob, patch); + double* error_q = fclaw_clawpatch_get_q(iterate->error_glob, error_patch); + + //get physical boundaries + int intersects_bc[fclaw_domain_num_faces(domain)]; + for(int i=0;ierror_glob); + memset(error_q, 0, sizeof(double)*size); + + for(int m = 0; m < opts->meqn; m++) + for(int k = 0; k < clawpatch->mz; k++) + for(int j = 0; j < clawpatch->my; j++) + for(int i = 0; i < clawpatch->mx; i++) + { + int idx = clawpatch_idx(clawpatch, i,j,k,m); + int error_idx = clawpatch_idx(error_clawpatch, i+mbc,j+mbc,k+mbc,m); + //get expected value + double expected = fill_function(clawpatch, i, j, k, m); + error_q[error_idx] = expected - q[idx]; + if(q[idx] != doctest::Approx(expected)) + { + iterate->num_incorrect_interior_cells++; + } + } + + }, + &iterate + ); + + //check that patch was filled correctly + CHECK_EQ(iterate.num_incorrect_interior_cells, 0); + + int num_incorrect_cells = iterate.num_incorrect_interior_cells; + //if not write output + if(test_output_vtk() && num_incorrect_cells >0) + { + char test_no_str[5]; + snprintf(test_no_str, 5, "%04d", test_no); + std::string filename = "3d_clawpatch_interpolate_"+std::string(test_no_str); + INFO("Test failed output error to " << filename << ".vtu"); + fclaw_clawpatch_output_vtk_to_file(cube_output.glob,filename.c_str()); + } + test_no++; + + } + +} + diff --git a/src/patches/clawpatch/fclaw_clawpatch.h.3dx.TEST.cpp b/src/patches/clawpatch/fclaw_clawpatch.h.3dx.TEST.cpp new file mode 100644 index 000000000..99911f0bc --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch.h.3dx.TEST.cpp @@ -0,0 +1,1021 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define CHECK_BOX_DIMENSIONS(abox, mbc, mx, my, mz, mfields)\ +{\ + CHECK(abox.fields() == mfields);\ + CHECK(abox.box().boxDim() == 3);\ + CHECK(abox.box().smallEnd(0) == 1-mbc);\ + CHECK(abox.box().smallEnd(1) == 1-mbc);\ + CHECK(abox.box().smallEnd(2) == 1-mbc);\ + CHECK(abox.box().bigEnd(0) == mx+mbc);\ + CHECK(abox.box().bigEnd(1) == my+mbc);\ + CHECK(abox.box().bigEnd(2) == mz+mbc);\ +} +#define CHECK_BOX_EMPTY(abox)\ +{\ + CHECK(abox.fields() == 0);\ + CHECK(abox.box().boxDim() == 0);\ +} + +namespace{ +struct SinglePatchDomain { + fclaw_global_t* glob; + fclaw_options_t fopts; + fclaw_domain_t *domain; + fclaw_map_context_t* map; + fclaw_clawpatch_options_t* opts; + + SinglePatchDomain(){ + glob = fclaw_global_new(); + opts = fclaw_clawpatch_options_new(3); + memset(&fopts, 0, sizeof(fopts)); + fopts.mi=1; + fopts.mj=1; + fopts.minlevel=0; + fopts.manifold=false; + fopts.bx = 1; + fopts.by = 2; + fopts.bz = 3; + fopts.compute_error = true; + fopts.subcycle = true; + fclaw_options_store(glob, &fopts); + + opts->mx = 5; + opts->my = 6; + opts->mz = 7; + opts->mbc = 2; + opts->meqn = 1; + opts->maux = 1; + opts->rhs_fields = 1; + fclaw_clawpatch_options_store(glob, opts); + + domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob, domain); + + map = fclaw_map_new_nomap(); + fclaw_map_store(glob, map); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + + } + void setup(){ + fclaw_build_mode_t build_mode = FCLAW_BUILD_FOR_UPDATE; + fclaw_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); + } + ~SinglePatchDomain(){ + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[0]); + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_map_destroy(map); + fclaw_global_destroy(glob); + } +}; +struct QuadDomain { + fclaw_global_t* glob; + fclaw_options_t fopts; + fclaw_domain_t *domain; + fclaw_map_context_t* map; + fclaw_clawpatch_options_t* opts; + + QuadDomain(){ + glob = fclaw_global_new(); + opts = fclaw_clawpatch_options_new(3); + memset(&fopts, 0, sizeof(fopts)); + fopts.mi=1; + fopts.mj=1; + fopts.minlevel=1; + fopts.maxlevel=1; + fopts.manifold=false; + fopts.bx = 1; + fopts.by = 2; + fopts.bz = 3; + fopts.compute_error = true; + fopts.subcycle = true; + fclaw_options_store(glob, &fopts); + + opts->mx = 5; + opts->my = 6; + opts->mz = 7; + opts->mbc = 2; + opts->meqn = 1; + opts->maux = 1; + opts->rhs_fields = 1; + fclaw_clawpatch_options_store(glob, opts); + + domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_store_domain(glob, domain); + + map = fclaw_map_new_nomap(); + fclaw_map_store(glob, map); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + + } + void setup(){ + fclaw_build_mode_t build_mode = FCLAW_BUILD_FOR_UPDATE; + fclaw_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); + fclaw_patch_build(glob, &domain->blocks[0].patches[1], 0, 1, &build_mode); + fclaw_patch_build(glob, &domain->blocks[0].patches[2], 0, 2, &build_mode); + fclaw_patch_build(glob, &domain->blocks[0].patches[3], 0, 3, &build_mode); + } + ~QuadDomain(){ + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[0]); + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[1]); + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[2]); + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[3]); + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_map_destroy(map); + fclaw_global_destroy(glob); + } +}; +} +TEST_CASE("3dx fclaw_clawpatch_vtable_initialize") +{ + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + fclaw_clawpatch_options_store(glob, opts); + + fclaw_vtables_initialize(glob); + + fclaw_clawpatch_vtable_initialize(glob, 4); + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(glob); + + CHECK(clawpatch_vt->set_user_data == NULL); + + //ghost filling + CHECK(clawpatch_vt->d3->fort_copy_face == &FCLAW3DX_CLAWPATCH46_FORT_COPY_FACE); + CHECK(clawpatch_vt->d3->fort_average_face == &FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_FACE); + CHECK(clawpatch_vt->d3->fort_interpolate_face == &FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_FACE); + CHECK(clawpatch_vt->d3->fort_copy_corner == &FCLAW3DX_CLAWPATCH46_FORT_COPY_CORNER); + CHECK(clawpatch_vt->d3->fort_average_corner == &FCLAW3DX_CLAWPATCH46_FORT_AVERAGE_CORNER); + CHECK(clawpatch_vt->d3->fort_interpolate_corner == &FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE_CORNER); + + //regridding + CHECK(clawpatch_vt->d3->fort_tag4refinement == &FCLAW3D_CLAWPATCH46_FORT_TAG4REFINEMENT); + CHECK(clawpatch_vt->d3->fort_tag4coarsening_3dx == &FCLAW3DX_CLAWPATCH46_FORT_TAG4COARSENING); + CHECK(clawpatch_vt->d3->fort_tag4coarsening == NULL); + CHECK(clawpatch_vt->d3->fort_user_exceeds_threshold == NULL); + CHECK(clawpatch_vt->d3->fort_interpolate2fine == &FCLAW3DX_CLAWPATCH46_FORT_INTERPOLATE2FINE); + CHECK(clawpatch_vt->d3->fort_average2coarse == &FCLAW3DX_CLAWPATCH46_FORT_AVERAGE2COARSE); + + //ascii output + CHECK(clawpatch_vt->time_header_ascii == &fclaw_clawpatch_time_header_ascii); + CHECK(clawpatch_vt->fort_header_ascii == &FCLAW3D_CLAWPATCH46_FORT_HEADER_ASCII); + CHECK(clawpatch_vt->cb_output_ascii == &cb_clawpatch_output_ascii); + CHECK(clawpatch_vt->d3->fort_output_ascii == &FCLAW3D_CLAWPATCH46_FORT_OUTPUT_ASCII); + + //time interpolation + CHECK(clawpatch_vt->d3->fort_timeinterp == &FCLAW3D_CLAWPATCH46_FORT_TIMEINTERP); + + //ghot packing + CHECK(clawpatch_vt->d3->fort_local_ghost_pack == &FCLAW3DX_CLAWPATCH46_FORT_LOCAL_GHOST_PACK); + CHECK(clawpatch_vt->local_ghost_pack_aux == NULL); + + //diagnostics + CHECK(clawpatch_vt->conservation_check == NULL); + CHECK(clawpatch_vt->compute_error == NULL); + CHECK(clawpatch_vt->d3->fort_compute_patch_error == NULL); + CHECK(clawpatch_vt->d3->fort_conservation_check == NULL); + CHECK(clawpatch_vt->d3->fort_compute_error_norm == NULL); + CHECK(clawpatch_vt->d3->fort_compute_patch_area == NULL); + + CHECK(clawpatch_vt->is_set == 1); + + fclaw_patch_vtable_t * patch_vt = fclaw_patch_vt(glob); + //create delete build + //TODO document patch_vt and expose these as part to public api + CHECK(patch_vt->patch_new != NULL); + CHECK(patch_vt->patch_delete != NULL); + CHECK(patch_vt->build != NULL); + CHECK(patch_vt->build_from_fine != NULL); + CHECK(patch_vt->setup == NULL); + + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); +} +TEST_CASE("3dx fclaw_clawpatch patch_build") +{ + for(const int& compute_error : {0,1}) + for(const int& subcycle : {0,1}) + for(const int& mx : {4,5,6}) + for(const int& my : {4,5,6}) + for(const int& mz : {4,5,6}) + for(const int& mbc : {1,2}) + for(const int& meqn : {1,2}) + for(const int& maux : {0,2}) + for(const int& rhs_fields : {0,2}) + for(fclaw_build_mode_t build_mode : {FCLAW_BUILD_FOR_GHOST_AREA_COMPUTED, FCLAW_BUILD_FOR_UPDATE}) + { + fclaw_global_t* glob = fclaw_global_new(); + + fclaw_options_t fopts; + memset(&fopts, 0, sizeof(fopts)); + fopts.mi=1; + fopts.mj=1; + fopts.minlevel=0; + fopts.manifold=false; + fopts.bx = 1; + fopts.by = 2; + fopts.bz = 3; + fopts.compute_error = compute_error; + fopts.subcycle = subcycle; + fclaw_options_store(glob, &fopts); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + opts->mx = mx; + opts->my = my; + opts->mz = mz; + opts->mbc = mbc; + opts->meqn = meqn; + opts->maux = maux; + opts->rhs_fields = rhs_fields; + fclaw_clawpatch_options_store(glob, opts); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob, domain); + + fclaw_map_context_t* map = fclaw_map_new_nomap(); + fclaw_map_store(glob, map); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + + CHECK(domain->blocks[0].patches[0].user == nullptr); + fclaw_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); + CHECK(domain->blocks[0].patches[0].user != nullptr); + + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&domain->blocks[0].patches[0]); + + CHECK(cp->meqn == opts->meqn); + CHECK(cp->mx == opts->mx); + CHECK(cp->my == opts->my); + CHECK(cp->mz == opts->mz); + CHECK(cp->mbc == opts->mbc); + CHECK(cp->manifold == fopts.manifold); + CHECK(cp->d3->mp != nullptr); + + CHECK(cp->xlower == fopts.ax); + CHECK(cp->ylower == fopts.ay); + CHECK(cp->zlower == fopts.az); + CHECK(cp->xupper == fopts.bx); + CHECK(cp->yupper == fopts.by); + CHECK(cp->zupper == fopts.bz); + CHECK(cp->dx == doctest::Approx((cp->xupper-cp->xlower)/opts->mx)); + CHECK(cp->dy == doctest::Approx((cp->yupper-cp->ylower)/opts->my)); + CHECK(cp->dz == doctest::Approx((cp->zupper-cp->zlower)/opts->mz)); + + //BOX DIEMSIONS + + CHECK_BOX_DIMENSIONS(cp->griddata, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + if(build_mode == FCLAW_BUILD_FOR_UPDATE){ + CHECK_BOX_DIMENSIONS(cp->griddata_last, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + CHECK_BOX_DIMENSIONS(cp->griddata_save, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + }else{ + CHECK_BOX_EMPTY(cp->griddata_last); + CHECK_BOX_EMPTY(cp->griddata_save); + } + if(fopts.subcycle){ + CHECK_BOX_DIMENSIONS(cp->griddata_time_interpolated, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + }else{ + CHECK_BOX_EMPTY(cp->griddata_time_interpolated); + } + if(fopts.compute_error) { + CHECK_BOX_DIMENSIONS(cp->griderror, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + CHECK_BOX_DIMENSIONS(cp->exactsolution, opts->mbc, opts->mx, opts->my, opts->mz, opts->meqn); + }else{ + CHECK_BOX_EMPTY(cp->griderror); + CHECK_BOX_EMPTY(cp->exactsolution); + } + if(opts->rhs_fields == 0){ + CHECK_BOX_EMPTY(cp->rhs); + }else{ + CHECK_BOX_DIMENSIONS(cp->rhs, opts->mbc, opts->mx, opts->my, opts->mz, opts->rhs_fields); + } + if(opts->rhs_fields == 0 || !fopts.compute_error) { + CHECK_BOX_EMPTY(cp->elliptic_error); + CHECK_BOX_EMPTY(cp->elliptic_soln); + }else{ + CHECK_BOX_DIMENSIONS(cp->elliptic_error, opts->mbc, opts->mx, opts->my, opts->mz, opts->rhs_fields); + CHECK_BOX_DIMENSIONS(cp->elliptic_soln, opts->mbc, opts->mx, opts->my, opts->mz, opts->rhs_fields); + } + + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[0]); + fclaw_domain_destroy(domain); + fclaw_map_destroy(map); + fclaw_global_destroy(glob); + } +} + +TEST_CASE("3dx fclaw_clawpatch save_step") +{ + SinglePatchDomain test_data; + test_data.setup(); + + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + cp->griddata.dataPtr()[0] = 1234; + fclaw_patch_save_step(test_data.glob,&test_data.domain->blocks[0].patches[0]); + CHECK(cp->griddata_save.dataPtr()[0] == 1234); +} + +TEST_CASE("3dx fclaw_clawpatch_save_current_step") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + cp->griddata.dataPtr()[0] = 1234; + fclaw_clawpatch_save_current_step(test_data.glob,&test_data.domain->blocks[0].patches[0]); + CHECK(cp->griddata_last.dataPtr()[0] == 1234); +} + +TEST_CASE("3dx fclaw_clawpatch restore_step") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + cp->griddata_save.dataPtr()[0] = 1234; + fclaw_patch_restore_step(test_data.glob,&test_data.domain->blocks[0].patches[0]); + CHECK(cp->griddata.dataPtr()[0] == 1234); +} + +#if 0 +TEST_CASE("3dx fclaw_clawpatch get_metric_patch") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw2d_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + CHECK(fclaw3d_patch_metric_patch(test_data.glob, &test_data.domain->blocks[0].patches[0]) == cp->mp); +} +#endif + + +#if 0 +TEST_CASE("3dx fclaw_clawpatch_get_metric_patch") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = + fclaw2d_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + CHECK(fclaw3d_clawpatch_get_metric_patch(&test_data.domain->blocks[0].patches[0]) == cp->mp); +} +#endif + +#if 0 +TEST_CASE("3dx fclaw_clawpatch_get_volume") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw3d_metric_patch_t* mp = fclaw3dx_clawpatch_get_metric_patch(&test_data.domain->blocks[0].patches[0]); + CHECK(fclaw_clawpatch_get_3d_volume(test_data.glob, + &test_data.domain->blocks[0].patches[0]) == mp->volume.dataPtr()); +} +#endif + +TEST_CASE("3dx fclaw_clawpatch_grid_data") +{ + for(int mx : {4,5,6}) + for(int my : {4,5,6}) + for(int mz : {4,5,6}) + for(int mbc : {1,2}) + { + + SinglePatchDomain test_data; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + int mx_out,my_out,mz_out,mbc_out; + double xlower,ylower,zlower,dx,dy,dz; + fclaw_clawpatch_3d_grid_data(test_data.glob, &test_data.domain->blocks[0].patches[0], + &mx_out, &my_out, &mz_out, &mbc_out, &xlower, &ylower, &zlower, &dx, &dy, &dz); + + CHECK(mx_out == test_data.opts->mx); + CHECK(my_out == test_data.opts->my); + CHECK(mz_out == test_data.opts->mz); + CHECK(mbc_out == test_data.opts->mbc); + CHECK(xlower == cp->xlower); + CHECK(ylower == cp->ylower); + CHECK(zlower == cp->zlower); + CHECK(dx == cp->dx); + CHECK(dy == cp->dy); + CHECK(dz == cp->dz); + + } +} + +TEST_CASE("3dx fclaw_clawpatch_aux_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* aux; + int maux; + fclaw_clawpatch_aux_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &aux, &maux); + + CHECK(aux == cp->aux.dataPtr()); + CHECK(maux == test_data.opts->maux); +} + +TEST_CASE("3dx fclaw_clawpatch_soln_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* q; + int meqn; + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &q, &meqn); + + CHECK(q == cp->griddata.dataPtr()); + CHECK(meqn == test_data.opts->meqn); +} + +TEST_CASE("3dx fclaw_clawpatch_rhs_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* rhs; + int mfields; + fclaw_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &rhs, &mfields); + + CHECK(rhs == cp->rhs.dataPtr()); + CHECK(mfields == test_data.opts->rhs_fields); +} + +TEST_CASE("3dx fclaw_clawpatch_elliptic_error_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* rhs; + int mfields; + fclaw_clawpatch_elliptic_error_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &rhs, &mfields); + + CHECK(rhs == cp->elliptic_error.dataPtr()); + CHECK(mfields == test_data.opts->rhs_fields); +} + +TEST_CASE("3dx fclaw_clawpatch_elliptic_soln_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* rhs; + int mfields; + fclaw_clawpatch_elliptic_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[0], &rhs, &mfields); + + CHECK(rhs == cp->elliptic_soln.dataPtr()); + CHECK(mfields == test_data.opts->rhs_fields); +} + +TEST_CASE("3dx fclaw_clawpatch_get_q") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + CHECK(fclaw_clawpatch_get_q(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->griddata.dataPtr()); +} + +TEST_CASE("3dx fclaw_clawpatch_get_error") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + CHECK(fclaw_clawpatch_get_error(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->griderror.dataPtr()); +} + +TEST_CASE("3dx fclaw_clawpatch_get_exact_soln") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + CHECK(fclaw_clawpatch_get_exactsoln(test_data.glob,&test_data.domain->blocks[0].patches[0]) == cp->exactsolution.dataPtr()); +} +TEST_CASE("3dx fclaw_clawpatch_timesync_data") +{ + for(int time_interp : {true,false}) + { + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + double* q; + int meqn; + fclaw_clawpatch_timesync_data(test_data.glob, &test_data.domain->blocks[0].patches[0], time_interp, &q, &meqn); + + if(time_interp){ + CHECK(q == cp->griddata_time_interpolated.dataPtr()); + } else { + CHECK(q == cp->griddata.dataPtr()); + } + CHECK(meqn == test_data.opts->meqn); + } +} +TEST_CASE("3dx fclaw_clawpatch_get_q_timesync") +{ + for(int time_interp : {true,false}) + { + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + fclaw_clawpatch_t* cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + if(time_interp){ + CHECK(fclaw_clawpatch_get_q_timesync(test_data.glob,&test_data.domain->blocks[0].patches[0],time_interp) == cp->griddata_time_interpolated.dataPtr()); + } else { + CHECK(fclaw_clawpatch_get_q_timesync(test_data.glob,&test_data.domain->blocks[0].patches[0],time_interp) == cp->griddata.dataPtr()); + } + } +} +TEST_CASE("3dx fclaw_clawpatch user_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + void* user_data = (void *) 1234; + fclaw_clawpatch_set_user_data(test_data.glob, &test_data.domain->blocks[0].patches[0],user_data); + CHECK(fclaw_clawpatch_get_user_data(test_data.glob,&test_data.domain->blocks[0].patches[0]) == user_data); +} +TEST_CASE("3dx fclaw_clawpatch solver_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + //CHECK + void* user_data = (void *) 1234; + fclaw_clawpatch_set_solver_data(test_data.glob, &test_data.domain->blocks[0].patches[0],user_data); + CHECK(fclaw_clawpatch_get_solver_data(test_data.glob,&test_data.domain->blocks[0].patches[0]) == user_data); +} + +TEST_CASE("3dx fclaw_clawpatch_size") +{ + for(int mx : {4,5,6}) + for(int my : {4,5,6}) + for(int mz : {4,5,6}) + for(int mbc : {1,2}) + for(int meqn : {1,2}) + { + SinglePatchDomain test_data; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mz = mz; + test_data.opts->mbc = mbc; + test_data.opts->meqn = meqn; + test_data.setup(); + + //CHECK + CHECK(fclaw_clawpatch_size(test_data.glob) == (size_t) (mx+2*mbc)*(my+2*mbc)*(mz+2*mbc)*meqn); + } +} + +#if 0 +TEST_CASE("3dx fclaw_clawpatch_metric_scalar") +{ + SinglePatchDomain test_data; + test_data.setup(); + + double *mp_volume, *mp_faceareas; + double *volume, *faceareas; + + /* DAC : What is the right test here? */ + fclaw3d_metric_patch_scalar(test_data.glob, + &test_data.domain->blocks[0].patches[0], + &mp_volume, &mp_faceareas); + + fclaw3dx_clawpatch_metric_scalar(test_data.glob, + &test_data.domain->blocks[0].patches[0], + &volume, &faceareas); + + CHECK(mp_volume == volume); + CHECK(mp_faceareas == faceareas); +} +#endif + +#if 0 +/* DAC : Fix this test for fclaw3d_metric? */ +TEST_CASE("3dx fclaw_clawpatch_metric_vector") +{ + fclaw_global_t* glob = fclaw_global_new(); + fclaw_vtables_initialize(glob); + + SinglePatchDomain test_data; + test_data.setup(); + + double *mp_xnormals, *mp_ynormals, *mp_xtangents, *mp_ytangents, *mp_curvature; + double *xnormals, *ynormals, *xtangents, *ytangents, *curvature; + + fclaw3d_metric_patch_vector(test_data.glob, &test_data.domain->blocks[0].patches[0], + &mp_xnormals, &mp_ynormals, + &mp_xtangents, &mp_ytangents, + &mp_curvature); + + fclaw3dx_clawpatch_metric_vector(test_data.glob, &test_data.domain->blocks[0].patches[0], + &xnormals, &ynormals, + &xtangents, &ytangents, + &curvature); + + CHECK(mp_xnormals == xnormals); + CHECK(mp_ynormals == ynormals); + CHECK(mp_xtangents == xtangents); + CHECK(mp_ytangents == ytangents); + CHECK(mp_curvature == curvature); + + fclaw_global_destroy(glob); +} +#endif + +#if 0 +TEST_CASE("3dx fclaw_clawpatch_metric_data") +{ + SinglePatchDomain test_data; + test_data.setup(); + + double *mp_xp, *mp_yp, *mp_zp, *mp_xd, *mp_yd, *mp_zd, *mp_area; + double *xp, *yp, *zp, *xd, *yd, *zd, *area; + + fclaw3d_metric_patch_mesh_data(test_data.glob, &test_data.domain->blocks[0].patches[0], + &mp_xp, &mp_yp, &mp_zp, + &mp_xd, &mp_yd, &mp_zd, + &mp_area); + + fclaw3dx_clawpatch_metric_data(test_data.glob, &test_data.domain->blocks[0].patches[0], + &xp, &yp, &zp, + &xd, &yd, &zd, + &area); + + CHECK(mp_xp == xp); + CHECK(mp_yp == yp); + CHECK(mp_zp == zp); + CHECK(mp_xd == xd); + CHECK(mp_yd == yd); + CHECK(mp_zd == zd); + CHECK(mp_area == area); +} +#endif + +#if 0 +TEST_CASE("3dx fclaw_clawpatch_metric_data2") +{ + SinglePatchDomain test_data; + test_data.setup(); + + double *mp_xnormals, *mp_ynormals, *mp_xtangents, *mp_ytangents, *mp_surfnormals, *mp_edgelengths, *mp_curvature; + double *xnormals, *ynormals, *xtangents, *ytangents, *surfnormals, *edgelengths, *curvature; + + fclaw3d_metric_patch_mesh_data2(test_data.glob, &test_data.domain->blocks[0].patches[0], + &mp_xnormals, &mp_ynormals, + &mp_xtangents, &mp_ytangents, + &mp_surfnormals, &mp_edgelengths, &mp_curvature); + + fclaw3dx_clawpatch_metric_data2(test_data.glob, &test_data.domain->blocks[0].patches[0], + &xnormals, &ynormals, + &xtangents, &ytangents, + &surfnormals, &edgelengths, &curvature); + + CHECK(mp_xnormals == xnormals); + CHECK(mp_ynormals == ynormals); + CHECK(mp_xtangents == xtangents); + CHECK(mp_ytangents == ytangents); + CHECK(mp_surfnormals == surfnormals); + CHECK(mp_edgelengths == edgelengths); + CHECK(mp_curvature == curvature); +} +#endif + +namespace{ + double timeinterp_alpha; + int timeinterp_mint; + fclaw_clawpatch_t* timeinterp_cp; +} + + +TEST_CASE("3dx fclaw_clawpatch setup_timeinterp") +{ + SinglePatchDomain test_data; + test_data.opts->interp_stencil_width=2; + timeinterp_mint = 2; + test_data.setup(); + + + timeinterp_cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + timeinterp_alpha = 0.90210; + + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(test_data.glob); + clawpatch_vt->d3->fort_timeinterp = [] (const int *mx, const int *my, const int *mz, + const int *mbc, const int *meqn, const int *psize, + double qcurr[], double qlast[], double qinterp[], + const double *alpha, const int *ierror) + { + CHECK(*mx == timeinterp_cp->mx); + CHECK(*my == timeinterp_cp->my); + CHECK(*mz == timeinterp_cp->mz); + CHECK(*mbc == timeinterp_cp->mbc); + CHECK(*meqn == timeinterp_cp->meqn); + CHECK(*psize == (*mx)*(*my)*(*mz) + - (*mx-2*timeinterp_mint)*(*my-2*timeinterp_mint)*(*mz)); + CHECK(qcurr == timeinterp_cp->griddata.dataPtr()); + CHECK(qlast == timeinterp_cp->griddata_last.dataPtr()); + CHECK(qinterp == timeinterp_cp->griddata_time_interpolated.dataPtr()); + CHECK(*alpha == timeinterp_alpha); + }; + + fclaw_patch_setup_timeinterp(test_data.glob, &test_data.domain->blocks[0].patches[0], + timeinterp_alpha); +} +namespace{ + fclaw_clawpatch_t* t4r_cp; + int t4r_tag_patch; + int t4r_init_flag; +} +TEST_CASE("3dx fclaw_clawpatch tag4refinement") +{ + for(int tag_patch : {true,false}) + for(int init_flag : {true,false}) + { + SinglePatchDomain test_data; + test_data.fopts.refine_threshold = 0.90210; + test_data.setup(); + + + t4r_cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(test_data.glob); + + t4r_tag_patch = tag_patch; + t4r_init_flag = init_flag; + clawpatch_vt->d3->fort_tag4refinement = [](const int *mx, const int *my, const int *mz, + const int *mbc, const int *meqn, + const double *xlower, const double *ylower, const double *zlower, + const double *dx, const double *dy, const double *dz, + const int *blockno, + double q[], const double *tag_threshold, const int *init_flag, + int *tag_patch) + { + CHECK(*mx == t4r_cp->mx); + CHECK(*my == t4r_cp->my); + CHECK(*mz == t4r_cp->mz); + CHECK(*mbc == t4r_cp->mbc); + CHECK(*meqn == t4r_cp->meqn); + CHECK(*xlower == t4r_cp->xlower); + CHECK(*ylower == t4r_cp->ylower); + CHECK(*zlower == t4r_cp->zlower); + CHECK(*dx == t4r_cp->dx); + CHECK(*dy == t4r_cp->dy); + CHECK(*dz == t4r_cp->dz); + CHECK(*blockno == t4r_cp->blockno); + CHECK(q == t4r_cp->griddata.dataPtr()); + CHECK(*tag_threshold == .90210); + CHECK(*init_flag == t4r_init_flag); + *tag_patch = t4r_tag_patch; + }; + + CHECK(fclaw_patch_tag4refinement(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4r_init_flag) == t4r_tag_patch); + } +} +TEST_CASE("3dx fclaw_clawpatch tag4refinement negative refine threshold") +{ + for(int init_flag : {true,false}) + { + SinglePatchDomain test_data; + test_data.fopts.refine_threshold = -0.90210; + test_data.setup(); + + t4r_init_flag = init_flag; + + CHECK(fclaw_patch_tag4refinement(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4r_init_flag) == true); + } +} +namespace{ + fclaw_clawpatch_t* t4c_cp; + fclaw_clawpatch_t* t4c_cp1; + fclaw_clawpatch_t* t4c_cp2; + fclaw_clawpatch_t* t4c_cp3; + int t4c_tag_patch; + int t4c_init_flag; +} +TEST_CASE("3dx fclaw_clawpatch tag4coarsening") +{ + for(int tag_patch : {true,false}) + { + t4c_tag_patch= tag_patch; + for(int init_flag : {true,false}) + { + t4c_init_flag = init_flag; + + QuadDomain test_data; + test_data.fopts.coarsen_threshold = 0.90210; + test_data.setup(); + + + t4c_cp = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[0]); + t4c_cp1 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[1]); + t4c_cp2 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[2]); + t4c_cp3 = fclaw_clawpatch_get_clawpatch(&test_data.domain->blocks[0].patches[3]); + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(test_data.glob); + + clawpatch_vt->d3->fort_tag4coarsening_3dx = [](const int *mx, const int *my, const int *mz, + const int *mbc, const int *meqn, + double xlower[], double ylower[], double zlower[], + const double *dx, const double *dy, const double *dz, + const int *blockno, + double q0[], double q1[], double q2[], double q3[], + const double *tag_threshold, const int *init_flag, int *tag_patch) + { + CHECK(*mx == t4c_cp->mx); + CHECK(*my == t4c_cp->my); + CHECK(*mz == t4c_cp->mz); + CHECK(*mbc == t4c_cp->mbc); + CHECK(*meqn == t4c_cp->meqn); + CHECK(*xlower == t4c_cp->xlower); + CHECK(*ylower == t4c_cp->ylower); + CHECK(*zlower == t4c_cp->zlower); + CHECK(*dx == t4c_cp->dx); + CHECK(*dy == t4c_cp->dy); + CHECK(*dz == t4c_cp->dz); + CHECK(*blockno == t4c_cp->blockno); + CHECK(q0 == t4c_cp->griddata.dataPtr()); + CHECK(q1 == t4c_cp1->griddata.dataPtr()); + CHECK(q2 == t4c_cp2->griddata.dataPtr()); + CHECK(q3 == t4c_cp3->griddata.dataPtr()); + CHECK(*tag_threshold == .90210); + CHECK(*init_flag == t4c_init_flag); + *tag_patch = t4c_tag_patch; + }; + + CHECK(fclaw_patch_tag4coarsening(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4c_init_flag) == t4c_tag_patch); + } + } +} +TEST_CASE("3dx fclaw_clawpatch tag4coarsening negative coarsen threshold") +{ + for(int init_flag : {true,false}) + { + t4c_init_flag = init_flag; + + QuadDomain test_data; + test_data.fopts.coarsen_threshold = -0.90210; + test_data.setup(); + + CHECK(fclaw_patch_tag4coarsening(test_data.glob, &test_data.domain->blocks[0].patches[0], 0, 0, t4c_init_flag) == false); + } +} +namespace{ + fclaw_clawpatch_t* i2f_ccp; + fclaw_clawpatch_t* i2f_cp; + fclaw_clawpatch_t* i2f_cp1; + fclaw_clawpatch_t* i2f_cp2; + fclaw_clawpatch_t* i2f_cp3; + std::bitset<4> i2f_igrids; + int i2f_manifold; +} +TEST_CASE("3dx fclaw_clawpatch interpolate2fine") +{ + i2f_manifold = false; + + QuadDomain fine_test_data; + fine_test_data.fopts.manifold = i2f_manifold; + fine_test_data.setup(); + SinglePatchDomain coarse_test_data; + coarse_test_data.fopts.manifold = i2f_manifold; + coarse_test_data.setup(); + + + i2f_ccp = fclaw_clawpatch_get_clawpatch(&coarse_test_data.domain->blocks[0].patches[0]); + i2f_cp = fclaw_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[0]); + i2f_cp1 = fclaw_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[1]); + i2f_cp2 = fclaw_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[2]); + i2f_cp3 = fclaw_clawpatch_get_clawpatch(&fine_test_data.domain->blocks[0].patches[3]); + + fclaw_clawpatch_vtable_t * clawpatch_vt = fclaw_clawpatch_vt(coarse_test_data.glob); + + clawpatch_vt->d3->fort_interpolate2fine = [](const int *mx, const int *my, const int *mz, + const int *mbc, const int *meqn, + double qcoarse[], double qfine[], double areacoarse[], double areafine[], + const int *igrid, const int *manifold) + { + CHECK(*mx == i2f_cp->mx); + CHECK(*my == i2f_cp->my); + CHECK(*mz == i2f_cp->mz); + CHECK(*mbc == i2f_cp->mbc); + CHECK(*meqn == i2f_cp->meqn); + + CHECK(qcoarse == i2f_ccp->griddata.dataPtr()); +#if PATCH_DIM == 2 + CHECK(areacoarse == i2f_ccp->mp->area.dataPtr()); + + if(*igrid==0){ + CHECK(qfine == i2f_cp->griddata.dataPtr()); + CHECK(areafine == i2f_cp->mp->area.dataPtr()); + }else if(*igrid==1){ + CHECK(qfine == i2f_cp1->griddata.dataPtr()); + CHECK(areafine == i2f_cp1->mp->area.dataPtr()); + }else if(*igrid==2){ + CHECK(qfine == i2f_cp2->griddata.dataPtr()); + CHECK(areafine == i2f_cp2->mp->area.dataPtr()); + }else if(*igrid==3){ + CHECK(qfine == i2f_cp3->griddata.dataPtr()); + CHECK(areafine == i2f_cp3->mp->area.dataPtr()); + }else{ + REQUIRE(false); + } +#endif + + CHECK(i2f_igrids[*igrid] == false); + i2f_igrids[*igrid] = true; + CHECK(*manifold == i2f_manifold); + }; + + fclaw_patch_interpolate2fine(coarse_test_data.glob, + &coarse_test_data.domain->blocks[0].patches[0], + &fine_test_data.domain->blocks[0].patches[0], + 0, 0, 0); + + CHECK(i2f_igrids.all()); +} \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw2d_clawpatch.hpp b/src/patches/clawpatch/fclaw_clawpatch.hpp similarity index 73% rename from src/patches/clawpatch/fclaw2d_clawpatch.hpp rename to src/patches/clawpatch/fclaw_clawpatch.hpp index c3e47e1cd..89b0ff8bf 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch.hpp +++ b/src/patches/clawpatch/fclaw_clawpatch.hpp @@ -23,25 +23,57 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_CLAWPATCH_HPP -#define FCLAW2D_CLAWPATCH_HPP +#ifndef FCLAW_CLAWPATCH_HPP +#define FCLAW_CLAWPATCH_HPP /** * @file * C++ structures for clawpatch */ -#include /* Needed for FArray boxes */ +#include /* Needed for FArray boxes */ -struct fclaw2d_patch; -struct fclaw2d_global; -struct fclaw2d_metric_patch_t; +struct fclaw_patch; +struct fclaw_global; +struct fclaw2d_metric_patch_t; +struct fclaw3d_metric_patch_t; +struct fclaw_clawpatch_2d_t +{ + /** Registers for accumulating mismatches at coarse/fine interfaces */ + struct fclaw2d_clawpatch_registers *registers; + + fclaw2d_metric_patch_t *mp; /**< the metric data for a patch */ +}; +struct fclaw_clawpatch_3d_t +{ + /** Registers for accumulating mismatches at coarse/fine interfaces */ + struct fclaw2d_clawpatch_registers *registers; + + fclaw3d_metric_patch_t *mp; /**< the metric data for a patch */ +}; /** * @brief Stores data for each patch */ -class fclaw2d_clawpatch_t +struct fclaw_clawpatch_t { -public : + int patch_dim; + fclaw_clawpatch_2d_t* d2; + fclaw_clawpatch_3d_t* d3; + + int mx; /**< number of cells in the x direction */ + int my; /**< number of cells in the y direction */ + int mz; /**< number of cells in the z direction */ + + double dx; /**< cell spacing in the x direction */ + double dy; /**< cell spacing in the y direction */ + double dz; /**< cell spacing in the z direction */ + + double xlower; /**< x coordinate of the left edge of the patch */ + double ylower; /**< y coordinate of the bottom edge of the patch */ + double zlower; /**< z coordinate of the bottom edge of the patch */ + double xupper; /**< x coordinate of the right edge of the patch */ + double yupper; /**< y coordinate of the top edge of the patch */ + double zupper; /**< z coordinate of the top edge of the patch */ /* Solution data */ int meqn; /**< number of equations */ FArrayBox griddata; /**< the current solution */ @@ -59,23 +91,11 @@ public : FArrayBox elliptic_error; /**< Error for elliptic problems */ FArrayBox elliptic_soln; /**< Solution for elliptic problems */ - /** Registers for accumulating mismatches at coarse/fine interfaces */ - struct fclaw2d_clawpatch_registers *registers; /* Grid info */ - int mx; /**< number of cells in the x direction */ - int my; /**< number of cells in the y direction */ int mbc; /**< number ghost cells */ int maux; /**< number aux equations */ - double dx; /**< cell spacing in the x direction */ - double dy; /**< cell spacing in the y direction */ - - double xlower; /**< x coordinate of the left edge of the patch */ - double ylower; /**< y coordinate of the bottom edge of the patch */ - double xupper; /**< x coordinate of the right edge of the patch */ - double yupper; /**< y coordinate of the top edge of the patch */ - /** Auxilliary array (used by Clawpack 4.6 and 5.0) */ FArrayBox aux; FArrayBox aux_save; @@ -84,8 +104,6 @@ public : int manifold; /**< true if using manifold */ int blockno; /**< the block number of a patch */ - fclaw2d_metric_patch_t *mp; /**< the metric data for a patch */ - /** Extra storage needed by the solver(s) */ void* solver_data; @@ -97,10 +115,10 @@ public : * @brief Get the clawpatch structure for a patch * * @param this_patch the patch context - * @return fclaw2d_clawpatch_t* the clawpatch structure + * @return fclaw_clawpatch_t* the clawpatch structure */ -fclaw2d_clawpatch_t* -fclaw2d_clawpatch_get_clawpatch(struct fclaw2d_patch* this_patch); +fclaw_clawpatch_t* +fclaw_clawpatch_get_clawpatch(struct fclaw_patch* this_patch); /** * @brief Get the metrix structure for a patch @@ -109,9 +127,16 @@ fclaw2d_clawpatch_get_clawpatch(struct fclaw2d_patch* this_patch); * @return fclaw2d_metric_patch_t* the metric structure */ fclaw2d_metric_patch_t* -fclaw2d_clawpatch_get_metric_patch(struct fclaw2d_patch* this_patch); - +fclaw_clawpatch_get_2d_metric_patch(struct fclaw_patch* this_patch); +/** + * @brief Get the metrix structure for a patch + * + * @param this_patch the patch context + * @return fclaw2d_metric_patch_t* the metric structure + */ +struct fclaw3d_metric_patch_t* +fclaw_clawpatch_get_3d_metric_patch(struct fclaw_patch* this_patch); #endif /* !FCLAW2D_CLAWPATCH_HPP */ diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.c b/src/patches/clawpatch/fclaw_clawpatch_diagnostics.c similarity index 59% rename from src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.c rename to src/patches/clawpatch/fclaw_clawpatch_diagnostics.c index 23751c937..3ef277c4f 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.c +++ b/src/patches/clawpatch/fclaw_clawpatch_diagnostics.c @@ -23,45 +23,22 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif +#include +#include +#include +#include -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif +#include -#include -#include -#include -#include +#include +#include -#if REFINE_DIM == 2 && PATCH_DIM == 2 - -#include - -#include -#include - -#elif REFINE_DIM == 2 && PATCH_DIM == 3 - -#include - -#include -#include - -#include <_fclaw2d_to_fclaw3dx.h> -#include <_fclaw2d_to_fclaw3d.h> - -#endif - - -void fclaw2d_clawpatch_diagnostics_initialize(fclaw2d_global_t *glob, - void **acc_patch) +void fclaw_clawpatch_diagnostics_initialize(fclaw_global_t *glob, + void **acc_patch) { fclaw_debugf("Initializing diagnostics\n"); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int meqn = clawpatch_opt->meqn; /* Clawpatch */ @@ -79,12 +56,12 @@ void fclaw2d_clawpatch_diagnostics_initialize(fclaw2d_global_t *glob, } -void fclaw2d_clawpatch_diagnostics_reset(fclaw2d_global_t *glob, - void* patch_acc) +void fclaw_clawpatch_diagnostics_reset(fclaw_global_t *glob, + void* patch_acc) { fclaw_debugf("Resetting diagnostics\n"); error_info_t *error_data = (error_info_t*) patch_acc; - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int meqn = clawpatch_opt->meqn; @@ -105,37 +82,38 @@ void fclaw2d_clawpatch_diagnostics_reset(fclaw2d_global_t *glob, /* Gather statistics (error, mass, area) in this callback, called from fclaw2d_diagnostics_gather */ static -void cb_compute_diagnostics(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void cb_compute_diagnostics(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void* user) //void *patch_acc) { - fclaw2d_global_iterate_t *s = (fclaw2d_global_iterate_t *) user; + fclaw_global_iterate_t *s = (fclaw_global_iterate_t *) user; error_info_t *error_data = (error_info_t*) s->user; /* Accumulate area for final computation of error */ - int mx, my, mbc; - double xlower,ylower,dx,dy; - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(s->glob); -#if PATCH_DIM == 2 - double *area = fclaw2d_clawpatch_get_area(s->glob,patch); - FCLAW_ASSERT(clawpatch_vt->fort_compute_patch_area != NULL); - fclaw2d_clawpatch_grid_data(s->glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); - error_data->area += clawpatch_vt->fort_compute_patch_area(&mx,&my,&mbc,&dx,&dy,area); -#else - int mz; - double zlower, dz; - fclaw2d_clawpatch_grid_data(s->glob,patch,&mx,&my,&mz, - &mbc,&xlower,&ylower,&zlower, &dx,&dy,&dz); - - // double *volume = fclaw3dx_clawpatch_get_area(s->glob,patch); - // error_data->area += clawpatch_vt->fort_compute_patch_area(&mx,&my,&mz, &mbc,&dx,&dy,&dz,volume); -#endif + int mx, my, mz, mbc; + double xlower,ylower,zlower,dx,dy,dz; + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(s->glob); + if(clawpatch_vt->patch_dim == 2) + { + double *area = fclaw_clawpatch_get_2d_area(s->glob,patch); + FCLAW_ASSERT(clawpatch_vt->d2->fort_compute_patch_area != NULL); + fclaw_clawpatch_2d_grid_data(s->glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); + error_data->area += clawpatch_vt->d2->fort_compute_patch_area(&mx,&my,&mbc,&dx,&dy,area); + } + else + { + fclaw_clawpatch_3d_grid_data(s->glob,patch,&mx,&my,&mz, + &mbc,&xlower,&ylower,&zlower, &dx,&dy,&dz); + + // double *volume = fclaw3dx_clawpatch_get_area(s->glob,patch); + // error_data->area += clawpatch_vt->fort_compute_patch_area(&mx,&my,&mz, &mbc,&dx,&dy,&dz,volume); + } /* Compute error */ - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(s->glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(s->glob); if (fclaw_opt->compute_error) clawpatch_vt->compute_error(s->glob, patch, blockno, patchno, error_data); @@ -143,35 +121,35 @@ void cb_compute_diagnostics(fclaw2d_domain_t *domain, clawpatch_vt->conservation_check(s->glob, patch, blockno, patchno, error_data); } -void fclaw2d_clawpatch_diagnostics_compute(fclaw2d_global_t* glob, - void* patch_acc) +void fclaw_clawpatch_diagnostics_compute(fclaw_global_t* glob, + void* patch_acc) { fclaw_debugf("Computing diagnostics\n"); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int check = fclaw_opt->compute_error || fclaw_opt->conservation_check; if (!check) return; - fclaw2d_global_iterate_patches(glob, cb_compute_diagnostics, patch_acc); + fclaw_global_iterate_patches(glob, cb_compute_diagnostics, patch_acc); } /* Accumulate the errors computed above */ -void fclaw2d_clawpatch_diagnostics_gather(fclaw2d_global_t *glob, - void* patch_acc, - int init_flag) +void fclaw_clawpatch_diagnostics_gather(fclaw_global_t *glob, + void* patch_acc, + int init_flag) { fclaw_debugf("Gathering diagnostics\n"); - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; error_info_t *error_data = (error_info_t*) patch_acc; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int meqn = clawpatch_opt->meqn; /* clawpatch->meqn */ if (fclaw_opt->compute_error != 0) { - double total_area = fclaw2d_domain_global_sum(domain, error_data->area); + double total_area = fclaw_domain_global_sum(domain, error_data->area); FCLAW_ASSERT(total_area != 0); double *error_norm = FCLAW_ALLOC_ZERO(double,3*meqn); @@ -181,14 +159,14 @@ void fclaw2d_clawpatch_diagnostics_gather(fclaw2d_global_t *glob, int i2 = meqn + m; /* 2-norm */ int i3 = 2*meqn + m; /* inf-norm */ - error_norm[i1] = fclaw2d_domain_global_sum(domain, error_data->local_error[i1]); + error_norm[i1] = fclaw_domain_global_sum(domain, error_data->local_error[i1]); error_norm[i1] /= total_area; - error_norm[i2] = fclaw2d_domain_global_sum(domain, error_data->local_error[i2]); + error_norm[i2] = fclaw_domain_global_sum(domain, error_data->local_error[i2]); error_norm[i2] /= total_area; error_norm[i2] = sqrt(error_norm[i2]); - error_norm[i3] = fclaw2d_domain_global_maximum(domain, + error_norm[i3] = fclaw_domain_global_maximum(domain, error_data->local_error[i3]); error_data->global_error[i1] = error_norm[i1]; @@ -207,7 +185,7 @@ void fclaw2d_clawpatch_diagnostics_gather(fclaw2d_global_t *glob, double *total_mass = FCLAW_ALLOC_ZERO(double,meqn); for(int m = 0; m < meqn; m++) { - total_mass[m] = fclaw2d_domain_global_sum(domain, error_data->mass[m]); + total_mass[m] = fclaw_domain_global_sum(domain, error_data->mass[m]); /* Store mass for future checks */ if (init_flag) @@ -223,8 +201,8 @@ void fclaw2d_clawpatch_diagnostics_gather(fclaw2d_global_t *glob, } } -void fclaw2d_clawpatch_diagnostics_finalize(fclaw2d_global_t *glob, - void** patch_acc) +void fclaw_clawpatch_diagnostics_finalize(fclaw_global_t *glob, + void** patch_acc) { error_info_t *error_data = *((error_info_t**) patch_acc); FCLAW_FREE(error_data->mass); @@ -236,15 +214,15 @@ void fclaw2d_clawpatch_diagnostics_finalize(fclaw2d_global_t *glob, *patch_acc = NULL; } -void fclaw2d_clawpatch_diagnostics_vtable_initialize(fclaw2d_global_t* glob) +void fclaw_clawpatch_diagnostics_vtable_initialize(fclaw_global_t* glob) { /* diagnostic functions that apply to patches (error, conservation) */ - fclaw2d_diagnostics_vtable_t *diag_vt = fclaw2d_diagnostics_vt(glob); + fclaw_diagnostics_vtable_t *diag_vt = fclaw_diagnostics_vt(glob); - diag_vt->patch_init_diagnostics = fclaw2d_clawpatch_diagnostics_initialize; - diag_vt->patch_compute_diagnostics = fclaw2d_clawpatch_diagnostics_compute; - diag_vt->patch_gather_diagnostics = fclaw2d_clawpatch_diagnostics_gather; - diag_vt->patch_reset_diagnostics = fclaw2d_clawpatch_diagnostics_reset; - diag_vt->patch_finalize_diagnostics = fclaw2d_clawpatch_diagnostics_finalize; + diag_vt->patch_init_diagnostics = fclaw_clawpatch_diagnostics_initialize; + diag_vt->patch_compute_diagnostics = fclaw_clawpatch_diagnostics_compute; + diag_vt->patch_gather_diagnostics = fclaw_clawpatch_diagnostics_gather; + diag_vt->patch_reset_diagnostics = fclaw_clawpatch_diagnostics_reset; + diag_vt->patch_finalize_diagnostics = fclaw_clawpatch_diagnostics_finalize; } diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.h b/src/patches/clawpatch/fclaw_clawpatch_diagnostics.h similarity index 69% rename from src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.h rename to src/patches/clawpatch/fclaw_clawpatch_diagnostics.h index 65a912a94..bf40b0dda 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_diagnostics.h +++ b/src/patches/clawpatch/fclaw_clawpatch_diagnostics.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_CLAWPATCH_DIAGNOSTICS_H -#define FCLAW2D_CLAWPATCH_DIAGNOSTICS_H +#ifndef FCLAW_CLAWPATCH_DIAGNOSTICS_H +#define FCLAW_CLAWPATCH_DIAGNOSTICS_H /** * @file @@ -39,8 +39,8 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; /** * @brief Data structure for default diagnostic routines @@ -64,8 +64,8 @@ typedef struct { * @param glob the global context * @param patch_acc the data structure */ -void fclaw2d_clawpatch_diagnostics_initialize(struct fclaw2d_global *glob, - void** patch_acc); +void fclaw_clawpatch_diagnostics_initialize(struct fclaw_global *glob, + void** patch_acc); /** * @brief Iterate over patches and perform computations @@ -73,8 +73,8 @@ void fclaw2d_clawpatch_diagnostics_initialize(struct fclaw2d_global *glob, * @param glob the global context * @param patch_acc the user defined data structure */ -void fclaw2d_clawpatch_diagnostics_compute(struct fclaw2d_global *glob, - void* patch_acc); +void fclaw_clawpatch_diagnostics_compute(struct fclaw_global *glob, + void* patch_acc); /** * @brief Perform final computations after fclaw2d_clawpatch_diagnostics_computer() has been called @@ -83,8 +83,8 @@ void fclaw2d_clawpatch_diagnostics_compute(struct fclaw2d_global *glob, * @param patch_acc the user defined data structure * @param init_flag true if in init stage */ -void fclaw2d_clawpatch_diagnostics_gather(struct fclaw2d_global *glob, - void* patch_acc, int init_flag); +void fclaw_clawpatch_diagnostics_gather(struct fclaw_global *glob, + void* patch_acc, int init_flag); /** * @brief reset the user defined data structure @@ -92,8 +92,8 @@ void fclaw2d_clawpatch_diagnostics_gather(struct fclaw2d_global *glob, * @param glob the global context * @param patch_acc the user defined data structure */ -void fclaw2d_clawpatch_diagnostics_reset(struct fclaw2d_global *glob, - void* patch_acc); +void fclaw_clawpatch_diagnostics_reset(struct fclaw_global *glob, + void* patch_acc); /** * @brief Deallocate the user defined data structure @@ -101,8 +101,8 @@ void fclaw2d_clawpatch_diagnostics_reset(struct fclaw2d_global *glob, * @param glob the global context * @param patch_acc the user defined data structure */ -void fclaw2d_clawpatch_diagnostics_finalize(struct fclaw2d_global *glob, - void** patch_acc); +void fclaw_clawpatch_diagnostics_finalize(struct fclaw_global *glob, + void** patch_acc); /** * @brief Initialize a global vtable @@ -111,10 +111,10 @@ void fclaw2d_clawpatch_diagnostics_finalize(struct fclaw2d_global *glob, * * @param glob the global context */ -void fclaw2d_clawpatch_diagnostics_vtable_initialize(struct fclaw2d_global* glob); +void fclaw_clawpatch_diagnostics_vtable_initialize(struct fclaw_global* glob); /** - * @brief Calls the function in fclaw2d_clawpatch_vtable.fort_conservation_check + * @brief Calls the function in fclaw_clawpatch_vtable.fort_conservation_check * * @param glob the global context * @param patch the patch context @@ -122,14 +122,14 @@ void fclaw2d_clawpatch_diagnostics_vtable_initialize(struct fclaw2d_global* glob * @param patchno the patch number * @param error_data user data pointer */ -void fclaw2d_clawpatch_diagnostics_cons_default(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - int blockno, - int patchno, - void *error_data); +void fclaw_clawpatch_diagnostics_cons_default(struct fclaw_global *glob, + struct fclaw_patch *patch, + int blockno, + int patchno, + void *error_data); /** - * @brief Calls the function in fclaw2d_clawpatch_vtable.fort_compute_patch_error + * @brief Calls the function in fclaw_clawpatch_vtable.fort_compute_patch_error * * @param glob the global context * @param patch the patch context @@ -137,11 +137,11 @@ void fclaw2d_clawpatch_diagnostics_cons_default(struct fclaw2d_global *glob, * @param patchno the patch number * @param error_data user data pointer */ -void fclaw2d_clawpatch_diagnostics_error_default(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, - int blockno, - int patchno, - void *error_data); +void fclaw_clawpatch_diagnostics_error_default(struct fclaw_global *glob, + struct fclaw_patch *patch, + int blockno, + int patchno, + void *error_data); #ifdef __cplusplus diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics_TEST.cpp b/src/patches/clawpatch/fclaw_clawpatch_diagnostics.h.TEST.cpp similarity index 75% rename from src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics_TEST.cpp rename to src/patches/clawpatch/fclaw_clawpatch_diagnostics.h.TEST.cpp index 9f612e036..544492821 100644 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_diagnostics_TEST.cpp +++ b/src/patches/clawpatch/fclaw_clawpatch_diagnostics.h.TEST.cpp @@ -23,12 +23,19 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include +#include +#include #include -#include -TEST_CASE("fclaw2d_clawpatch_initialize_vt") +#ifdef FCLAW_ENABLE_DEBUG + +TEST_CASE("2d fclaw_clawpatch_diagnostics_vtable_initialize fails if fclaw2d_diagnostics_vtable_initialize is not called first") { - fclaw3dx_clawpatch_set_refinement_criteria(r); -} \ No newline at end of file + fclaw_global_t* glob = fclaw_global_new(); + CHECK_SC_ABORTED(fclaw_clawpatch_diagnostics_vtable_initialize(glob)); + fclaw_global_destroy(glob); +} + +#endif \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw_clawpatch_diagnostics_default.c b/src/patches/clawpatch/fclaw_clawpatch_diagnostics_default.c new file mode 100644 index 000000000..9f5608df0 --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch_diagnostics_default.c @@ -0,0 +1,138 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include + +#include +#include +#include +#include + +void fclaw_clawpatch_diagnostics_cons_default(fclaw_global_t *glob, + fclaw_patch_t *patch, + int blockno, + int patchno, + void *user) +{ + error_info_t* error_data = (error_info_t*) user; + double* area = fclaw_clawpatch_get_2d_area(glob,patch); /* Might be null */ + + int meqn; + double *q; + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); + + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + + int mx, my, mbc; + double xlower,ylower,dx,dy; + if(clawpatch_vt->patch_dim == 2) + { + FCLAW_ASSERT(clawpatch_vt->d2->fort_conservation_check != NULL); + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, + &xlower,&ylower,&dx,&dy); + clawpatch_vt->d2->fort_conservation_check(&mx, &my, &mbc, &meqn, &dx,&dy, + area, q, error_data->mass, + error_data->c_kahan); + } + else + { + FCLAW_ASSERT(clawpatch_vt->d3->fort_conservation_check != NULL); + int mz; + double zlower, dz; + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, &mbc, + &xlower,&ylower,&zlower, &dx,&dy, &dz); + clawpatch_vt->d3->fort_conservation_check(&mx, &my, &mz, &mbc, &meqn, + &dx,&dy,&dz, + area, q, error_data->mass, + error_data->c_kahan); + } +} + +void fclaw_clawpatch_diagnostics_error_default(fclaw_global_t *glob, + fclaw_patch_t *patch, + int blockno, + int patchno, + void *user) +{ + error_info_t* error_data = (error_info_t*) user; + //const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + + double *area = fclaw_clawpatch_get_2d_area(glob,patch); /* Might be null */ + double *q; + int meqn; + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); + + if (clawpatch_vt->patch_dim == 2 && clawpatch_vt->d2->fort_compute_patch_error != NULL) + { + double t = glob->curr_time; + double* error = fclaw_clawpatch_get_error(glob,patch); + double* soln = fclaw_clawpatch_get_exactsoln(glob,patch); + + int mx, my, mbc; + double xlower,ylower,dx,dy; + + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc,&xlower,&ylower,&dx,&dy); + + clawpatch_vt->d2->fort_compute_patch_error(&blockno, &mx,&my,&mbc,&meqn,&dx,&dy, + &xlower,&ylower, &t, q, error, soln); + + /* Accumulate sums and maximums needed to compute error norms */ + FCLAW_ASSERT(clawpatch_vt->d2->fort_compute_error_norm != NULL); + clawpatch_vt->d2->fort_compute_error_norm(&blockno, &mx, &my, &mbc, &meqn, + &dx,&dy, area, error, + error_data->local_error); + } + else if (clawpatch_vt->patch_dim == 3 && clawpatch_vt->d3->fort_compute_patch_error != NULL) + { + double t = glob->curr_time; + double* error = fclaw_clawpatch_get_error(glob,patch); + double* soln = fclaw_clawpatch_get_exactsoln(glob,patch); + + int mx, my, mz, mbc; + double xlower,ylower,zlower,dx,dy,dz; + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, + &mbc,&xlower,&ylower,&zlower, + &dx,&dy,&dz); + clawpatch_vt->d3->fort_compute_patch_error(&blockno, &mx,&my,&mz, + &mbc,&meqn, + &dx,&dy,&dz, + &xlower,&ylower, &zlower, + &t, q, error, soln); + + /* Accumulate sums and maximums needed to compute error norms */ + FCLAW_ASSERT(clawpatch_vt->d3->fort_compute_error_norm != NULL); + clawpatch_vt->d3->fort_compute_error_norm(&blockno, &mx, &my, &mz, + &mbc, &meqn, + &dx,&dy, &dz, area, error, + error_data->local_error); + + + } +} + + diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_options.c b/src/patches/clawpatch/fclaw_clawpatch_options.c similarity index 66% rename from src/patches/clawpatch/fclaw2d_clawpatch_options.c rename to src/patches/clawpatch/fclaw_clawpatch_options.c index 1998f924a..1c027c67d 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_options.c +++ b/src/patches/clawpatch/fclaw_clawpatch_options.c @@ -23,32 +23,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "fclaw_base.h" -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif +#include -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif - -#if REFINE_DIM == 2 && PATCH_DIM == 2 - -#define CLAWPATCH_OPTION_NAME "fclaw2d_clawpatch" - -#include - -#elif REFINE_DIM == 2 && PATCH_DIM == 3 - -#define CLAWPATCH_OPTION_NAME "fclaw3dx_clawpatch" - -#include -#include <_fclaw2d_to_fclaw3dx.h> - -#endif -#include -#include +#include #include +#include static sc_keyvalue_t * kv_refinement_criterea_new() @@ -62,21 +41,31 @@ kv_refinement_criterea_new() return kv; } - static void * -clawpatch_register(fclaw2d_clawpatch_options_t *clawpatch_options, +clawpatch_register(fclaw_clawpatch_options_t *clawpatch_options, sc_options_t * opt) { + int original_patch_dim = clawpatch_options->patch_dim; + if(clawpatch_options->patch_dim == 0) + { + sc_options_add_int (opt, 0, "patch-dim", &clawpatch_options->patch_dim, 2, + "Dimension of the patch (2 or 3) [2]"); + } sc_options_add_int (opt, 0, "mx", &clawpatch_options->mx, 8, "Number of grid cells per patch in x [8]"); sc_options_add_int (opt, 0, "my", &clawpatch_options->my, 8, "Number of grid cells per patch in y [8]"); -#if PATCH_DIM == 3 - sc_options_add_int (opt, 0, "mz", &clawpatch_options->mz, 1, - "Number of grid cells per patch in z [1]"); -#endif + if(original_patch_dim == 2) + { + clawpatch_options->mz = 1; + } + else + { + sc_options_add_int (opt, 0, "mz", &clawpatch_options->mz, 8, + "Number of grid cells per patch in z [1]"); + } sc_options_add_int (opt, 0, "maux", &clawpatch_options->maux, 0, "Number of auxilliary variables [0]"); @@ -109,7 +98,7 @@ clawpatch_register(fclaw2d_clawpatch_options_t *clawpatch_options, "Number of patches to buffer before each write in vtk output. 0 means buffer all patches before writing [0]"); /* Set verbosity level for reporting timing */ - sc_keyvalue_t *kv = clawpatch_options->kv_refinement_criteria = kv_refinement_criterea_new(); + sc_keyvalue_t *kv = clawpatch_options->kv_refinement_criteria; sc_options_add_keyvalue (opt, 0, "refinement-criteria", &clawpatch_options->refinement_criteria, "minmax", kv, "Refinement criteria [minmax]"); @@ -125,22 +114,20 @@ clawpatch_register(fclaw2d_clawpatch_options_t *clawpatch_options, } static fclaw_exit_type_t -clawpatch_postprocess(fclaw2d_clawpatch_options_t *clawpatch_opt) +clawpatch_postprocess(fclaw_clawpatch_options_t *clawpatch_opt) { /* Convert strings to arrays (no strings to process here) */ return FCLAW_NOEXIT; } static fclaw_exit_type_t -clawpatch_check(fclaw2d_clawpatch_options_t *clawpatch_opt) +clawpatch_check(fclaw_clawpatch_options_t *clawpatch_opt) { -#if 0 - if (clawpatch_opt->mx != clawpatch_opt->my) + if (clawpatch_opt->patch_dim != 2 && clawpatch_opt->patch_dim != 3) { - fclaw_global_essentialf("Clawpatch error : mx != my\n"); - return FCLAW_EXIT_ERROR; + fclaw_global_essentialf("Clawpatch error : patch_dim must be 2 or 3\n"); + return FCLAW_EXIT_ERROR; } -#endif if (2*clawpatch_opt->mbc > clawpatch_opt->mx) { @@ -174,51 +161,66 @@ clawpatch_check(fclaw2d_clawpatch_options_t *clawpatch_opt) return FCLAW_NOEXIT; } -static void -clawpatch_destroy (fclaw2d_clawpatch_options_t *clawpatch_opt) +fclaw_clawpatch_options_t* +fclaw_clawpatch_options_new (int dim) { - FCLAW_ASSERT (clawpatch_opt->kv_refinement_criteria != NULL); - sc_keyvalue_destroy (clawpatch_opt->kv_refinement_criteria); + fclaw_clawpatch_options_t* clawpatch_options = FCLAW_ALLOC_ZERO(fclaw_clawpatch_options_t,1); + + clawpatch_options->patch_dim = dim; + + clawpatch_options->kv_refinement_criteria = kv_refinement_criterea_new(); + + return clawpatch_options; +} + +void +fclaw_clawpatch_options_destroy (fclaw_clawpatch_options_t *clawpatch_opt) +{ + if(clawpatch_opt->kv_refinement_criteria != NULL) + { + sc_keyvalue_destroy (clawpatch_opt->kv_refinement_criteria); + } + FCLAW_FREE(clawpatch_opt); } static void clawpatch_destroy_void(void *clawpatch_opt) { - clawpatch_destroy ((fclaw2d_clawpatch_options_t *) clawpatch_opt); + fclaw_clawpatch_options_destroy ((fclaw_clawpatch_options_t *) clawpatch_opt); } static size_t options_packsize(void* user) { - return sizeof(fclaw2d_clawpatch_options_t); + return sizeof(fclaw_clawpatch_options_t); } static size_t options_pack(void* user, char* buffer) { - fclaw2d_clawpatch_options_t* opts = (fclaw2d_clawpatch_options_t*) user; + char* buffer_start = buffer; + fclaw_clawpatch_options_t* opts = (fclaw_clawpatch_options_t*) user; //pack entire struct - return FCLAW_PACK(*opts,buffer); + buffer += FCLAW_PACK(*opts,buffer); + + return buffer - buffer_start; } static size_t options_unpack(char* buffer, void** user) { - fclaw2d_clawpatch_options_t** opts_ptr = (fclaw2d_clawpatch_options_t**) user; - - *opts_ptr = FCLAW_ALLOC(fclaw2d_clawpatch_options_t,1); + char* buffer_start = buffer; + fclaw_clawpatch_options_t** opts_ptr = (fclaw_clawpatch_options_t**) user; - FCLAW_UNPACK(buffer,*opts_ptr); + *opts_ptr = FCLAW_ALLOC(fclaw_clawpatch_options_t,1); - fclaw2d_clawpatch_options_t* opts = *opts_ptr; + buffer += FCLAW_UNPACK(buffer,*opts_ptr); - *opts = *(fclaw2d_clawpatch_options_t*) buffer; + (*opts_ptr)->kv_refinement_criteria = kv_refinement_criterea_new(); - opts->kv_refinement_criteria = kv_refinement_criterea_new(); - - return sizeof(fclaw2d_clawpatch_options_t); + return buffer - buffer_start; } static fclaw_packing_vtable_t packing_vt = @@ -230,7 +232,7 @@ static fclaw_packing_vtable_t packing_vt = }; const fclaw_packing_vtable_t* -fclaw2d_clawpatch_options_get_packing_vtable() +fclaw_clawpatch_options_get_packing_vtable() { return &packing_vt; } @@ -246,10 +248,10 @@ options_register(fclaw_app_t * a, void *optpkg, sc_options_t * opt) FCLAW_ASSERT (optpkg != NULL); FCLAW_ASSERT (opt != NULL); - fclaw2d_clawpatch_options_t *clawpatch_opt = - (fclaw2d_clawpatch_options_t *) optpkg; + fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t *) optpkg; - fclaw_app_register_options_packing_vtable(CLAWPATCH_OPTION_NAME, &packing_vt); + fclaw_app_register_options_packing_vtable("clawpatch", &packing_vt); return clawpatch_register(clawpatch_opt,opt); } @@ -261,8 +263,8 @@ options_postprocess(fclaw_app_t * a, void *optpkg, void *registered) FCLAW_ASSERT (optpkg != NULL); FCLAW_ASSERT (registered == NULL); - fclaw2d_clawpatch_options_t *clawpatch_opt = - (fclaw2d_clawpatch_options_t *) optpkg; + fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t *) optpkg; FCLAW_ASSERT (clawpatch_opt->is_registered); @@ -276,8 +278,8 @@ options_check (fclaw_app_t * app, void *package, void *registered) FCLAW_ASSERT (package != NULL); FCLAW_ASSERT (registered == NULL); - fclaw2d_clawpatch_options_t *clawpatch_opt = - (fclaw2d_clawpatch_options_t *) package; + fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t *) package; FCLAW_ASSERT(clawpatch_opt->is_registered); @@ -291,18 +293,18 @@ options_destroy (fclaw_app_t * a, void *package, void *registered) FCLAW_ASSERT (package != NULL); FCLAW_ASSERT (registered == NULL); - fclaw2d_clawpatch_options_t *clawpatch_opt = - (fclaw2d_clawpatch_options_t*) package; + fclaw_clawpatch_options_t *clawpatch_opt = + (fclaw_clawpatch_options_t*) package; FCLAW_ASSERT (clawpatch_opt->is_registered); /* Destroy option arrays created in post-process */ - clawpatch_destroy (clawpatch_opt); + fclaw_clawpatch_options_destroy (clawpatch_opt); } static -const fclaw_app_options_vtable_t fclaw2d_clawpatch_options_vtable = { +const fclaw_app_options_vtable_t fclaw_clawpatch_options_vtable = { options_register, options_postprocess, options_check, @@ -314,36 +316,54 @@ const fclaw_app_options_vtable_t fclaw2d_clawpatch_options_vtable = { Public interface to clawpatch options --------------------------------------------------------- */ -fclaw2d_clawpatch_options_t * -fclaw2d_clawpatch_options_register(fclaw_app_t* app, const char* name, const char* configfile) +static +fclaw_clawpatch_options_t * +fclaw_clawpatch_options_register(int dim, fclaw_app_t* app, const char* name, const char* configfile) { - fclaw2d_clawpatch_options_t* clawpatch_options; FCLAW_ASSERT (app != NULL); /* allocate storage for fclaw_options */ - clawpatch_options = FCLAW_ALLOC(fclaw2d_clawpatch_options_t,1); + fclaw_clawpatch_options_t* clawpatch_options = fclaw_clawpatch_options_new(dim); fclaw_app_options_register (app, name, configfile, - &fclaw2d_clawpatch_options_vtable, + &fclaw_clawpatch_options_vtable, clawpatch_options); fclaw_app_set_attribute(app, name, clawpatch_options); return clawpatch_options; } +fclaw_clawpatch_options_t * +fclaw_clawpatch_2d_options_register(fclaw_app_t* app, const char* name, const char* configfile) +{ + return fclaw_clawpatch_options_register(2,app,name,configfile); +} + +fclaw_clawpatch_options_t * +fclaw_clawpatch_3d_options_register(fclaw_app_t* app, const char* name, const char* configfile) +{ + return fclaw_clawpatch_options_register(3,app,name,configfile); +} + +fclaw_clawpatch_options_t * +fclaw_clawpatch_dim_ind_options_register(fclaw_app_t* app, const char* name, const char* configfile) +{ + return fclaw_clawpatch_options_register(0,app,name,configfile); +} + void -fclaw2d_clawpatch_options_store (fclaw2d_global_t *glob, - fclaw2d_clawpatch_options_t* clawpatch_options) +fclaw_clawpatch_options_store (fclaw_global_t *glob, + fclaw_clawpatch_options_t* clawpatch_options) { - fclaw2d_global_options_store(glob, CLAWPATCH_OPTION_NAME, clawpatch_options); + fclaw_global_options_store(glob, "fclaw_clawpatch", clawpatch_options); } -fclaw2d_clawpatch_options_t* -fclaw2d_clawpatch_get_options(fclaw2d_global_t* glob) +fclaw_clawpatch_options_t* +fclaw_clawpatch_get_options(fclaw_global_t* glob) { - return (fclaw2d_clawpatch_options_t*) - fclaw2d_global_get_options(glob, CLAWPATCH_OPTION_NAME); + return (fclaw_clawpatch_options_t*) + fclaw_global_get_options(glob, "fclaw_clawpatch"); } diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_options.h b/src/patches/clawpatch/fclaw_clawpatch_options.h similarity index 60% rename from src/patches/clawpatch/fclaw3dx_clawpatch_options.h rename to src/patches/clawpatch/fclaw_clawpatch_options.h index 3af5fb7a0..f05415e41 100644 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_options.h +++ b/src/patches/clawpatch/fclaw_clawpatch_options.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW3DX_CLAWPATCH_OPTIONS_H -#define FCLAW3DX_CLAWPATCH_OPTIONS_H +#ifndef FCLAW_CLAWPATCH_OPTIONS_H +#define FCLAW_CLAWPATCH_OPTIONS_H /** * @file @@ -56,18 +56,19 @@ extern "C" #define FCLAW_REFINE_CRITERIA_USER 4 -struct fclaw2d_global; +struct fclaw_global; -/** Typedef for ::fclaw3dx_clawpatch_options structure */ -typedef struct fclaw3dx_clawpatch_options fclaw3dx_clawpatch_options_t; +/** Typedef for fclaw_clawpatch_options structure */ +typedef struct fclaw_clawpatch_options fclaw_clawpatch_options_t; /** * @brief Clawpatch options */ -struct fclaw3dx_clawpatch_options +struct fclaw_clawpatch_options { /* These are constant for all clawpatch's */ + int patch_dim; /**< dimension of clawpatch */ int mx; /**< number of cells in the x direction */ int my; /**< number of cells in the y direction */ int mz; /**< number of cells in the z direction */ @@ -86,6 +87,7 @@ struct fclaw3dx_clawpatch_options int ghost_patch_pack_aux; /**< True if aux equations should be packed */ int save_aux; /**< Save the aux array when retaking a time step */ + int vtk_patch_threshold; /**< The buffer threshold for vtk output */ int is_registered; /**< true if options have been registered */ @@ -93,15 +95,61 @@ struct fclaw3dx_clawpatch_options }; /** - * @brief Register options in SC + * @brief Allocate a new fclaw_clawpatch_options_t structure with the given dimension. + * + * This shouldn't have be called by the user. + * Used mainly for testing. + * + * @param dim The dimension of the clawpatch. + * @return fclaw_clawpatch_options_t* A newly allocated fclaw_clawpatch_options_t structure. + */ +fclaw_clawpatch_options_t* fclaw_clawpatch_options_new (int dim); + +/** + * @brief Deallocate the given fclaw_clawpatch_options_t structure. + * + * This shouldn't have be called by the user. + * Used mainly for testing. + * + * @param clawpatch_opt The fclaw_clawpatch_options_t structure to deallocate. + */ +void fclaw_clawpatch_options_destroy (fclaw_clawpatch_options_t *clawpatch_opt); + +/** + * @brief Register 2d options in SC * * @param app the app context * @param name the name of the options group * @param configfile the config file - * @return fclaw3dx_clawpatch_options_t* a newly allocated options struct + * @return fclaw_clawpatch_options_t* a newly allocated options struct */ -fclaw3dx_clawpatch_options_t * -fclaw3dx_clawpatch_options_register(fclaw_app_t* app, const char* name, const char* configfile); +fclaw_clawpatch_options_t * +fclaw_clawpatch_2d_options_register(fclaw_app_t* app, const char* name, const char* configfile); + +/** + * @brief Register 3d options in SC + * + * @param app the app context + * @param name the name of the options group + * @param configfile the config file + * @return fclaw_clawpatch_options_t* a newly allocated options struct + */ +fclaw_clawpatch_options_t * +fclaw_clawpatch_3d_options_register(fclaw_app_t* app, const char* name, const char* configfile); + +/** + * @brief Register dimension independent options. + * This will expose a dim option in the clawpatch options. + * + * @param app the app context + * @param name the name of the options group + * @param configfile the config file + * @return fclaw_clawpatch_options_t* a newly allocated options struct + */ +fclaw_clawpatch_options_t * +fclaw_clawpatch_dim_ind_options_register(fclaw_app_t* app, const char* name, const char* configfile); + + /** * @brief Store the options in the global context @@ -109,23 +157,23 @@ fclaw3dx_clawpatch_options_register(fclaw_app_t* app, const char* name, const ch * @param glob the global context * @param clawpatch_options the options */ -void fclaw3dx_clawpatch_options_store (struct fclaw2d_global *glob, - fclaw3dx_clawpatch_options_t* clawpatch_options); +void fclaw_clawpatch_options_store (struct fclaw_global *glob, + fclaw_clawpatch_options_t* clawpatch_options); /** * @brief Get the options from the global context * * @param glob the global context - * @return fclaw3dx_clawpatch_options_t* the options + * @return fclaw_clawpatch_options_t* the options */ -fclaw3dx_clawpatch_options_t* fclaw3dx_clawpatch_get_options(struct fclaw2d_global* glob); +fclaw_clawpatch_options_t* fclaw_clawpatch_get_options(struct fclaw_global* glob); /** - * @brief Get the packing vtable for fclaw3dx_clawpatch_options_t + * @brief Get the packing vtable for fclaw_clawpatch_options_t * * @return const fclaw_packing_vtable_t* the vtable */ -const fclaw_packing_vtable_t* fclaw3dx_clawpatch_options_get_packing_vtable(); +const fclaw_packing_vtable_t* fclaw_clawpatch_options_get_packing_vtable(); #ifdef __cplusplus diff --git a/src/patches/clawpatch/fclaw_clawpatch_options.h.TEST.cpp b/src/patches/clawpatch/fclaw_clawpatch_options.h.TEST.cpp new file mode 100644 index 000000000..ae80d663f --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch_options.h.TEST.cpp @@ -0,0 +1,200 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include + +TEST_CASE("fclaw_clawpatch_options_new 2d") +{ + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(2); + + CHECK_EQ(opts->patch_dim, 2); + CHECK_EQ(opts->mx, 0); + + fclaw_clawpatch_options_destroy(opts); +} + +TEST_CASE("fclaw_clawpatch_options_new 3d") +{ + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + + CHECK_EQ(opts->patch_dim, 3); + CHECK_EQ(opts->mx, 0); + + fclaw_clawpatch_options_destroy(opts); +} + +TEST_CASE("fclaw_clawpatch_options can store options in two seperate globs") +{ + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_clawpatch_options_t* opts1 = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_t* opts2 = fclaw_clawpatch_options_new(3); + + fclaw_clawpatch_options_store(glob1, opts1); + /* glob1 has one package glob2 has two */ + fclaw_clawpatch_options_store(glob2, opts2); + + CHECK_EQ(fclaw_clawpatch_get_options(glob1), opts1); + CHECK_EQ(fclaw_clawpatch_get_options(glob2), opts2); + + fclaw_clawpatch_options_destroy(opts1); + fclaw_clawpatch_options_destroy(opts2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +#ifdef FCLAW_ENABLE_DEBUG + +TEST_CASE("fclaw_clawpatch_get_options fails if not intialized") +{ + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + CHECK_SC_ABORTED(fclaw_clawpatch_get_options(glob1)); + + CHECK_SC_ABORTED(fclaw_clawpatch_get_options(glob2)); + + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +TEST_CASE("fclaw_clawpatch_options_store fails if called twice on a glob") +{ + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_clawpatch_options_t* opts1 = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_t* opts2 = fclaw_clawpatch_options_new(3); + + fclaw_clawpatch_options_store(glob1, opts1); + CHECK_SC_ABORTED(fclaw_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_clawpatch_options_t,1))); + + fclaw_clawpatch_options_store(glob2, opts2); + CHECK_SC_ABORTED(fclaw_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_clawpatch_options_t,1))); + + fclaw_clawpatch_options_destroy(opts1); + fclaw_clawpatch_options_destroy(opts2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); +} + +#endif +TEST_CASE("2d fclaw_clawpatch_options packing/unpacking") +{ + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(2); + opts->mx = 5; + opts->my = 6; + opts->maux = 4; + opts->mbc = 3; + opts->meqn = 32; + opts->rhs_fields = 39; + opts->refinement_criteria = 1; + opts->interp_stencil_width = 3; + opts->ghost_patch_pack_aux = 7; + opts->save_aux = 1; + opts->is_registered = 1; + + const fclaw_packing_vtable_t* vt = fclaw_clawpatch_options_get_packing_vtable(); + + size_t size = vt->size(opts); + char buffer[size]; + size_t bytes_written = vt->pack(opts,buffer); + REQUIRE_EQ(bytes_written,size); + + fclaw_clawpatch_options_t* output_opts = nullptr; + size_t bytes_read = vt->unpack(buffer,(void**)&output_opts); + + REQUIRE_EQ(bytes_read,size); + REQUIRE_NE(output_opts,nullptr); + + CHECK_EQ(output_opts->patch_dim,2); + CHECK_EQ(output_opts->mx,opts->mx); + CHECK_EQ(output_opts->my,opts->my); + CHECK_EQ(output_opts->maux,opts->maux); + CHECK_EQ(output_opts->mbc,opts->mbc); + CHECK_EQ(output_opts->meqn,opts->meqn); + CHECK_EQ(output_opts->rhs_fields,opts->rhs_fields); + CHECK_EQ(output_opts->refinement_criteria,opts->refinement_criteria); + CHECK_EQ(output_opts->interp_stencil_width,opts->interp_stencil_width); + CHECK_EQ(output_opts->ghost_patch_pack_aux,opts->ghost_patch_pack_aux); + CHECK_EQ(output_opts->save_aux,opts->save_aux); + CHECK_EQ(output_opts->is_registered,opts->is_registered); + + vt->destroy(output_opts); + FCLAW_FREE(opts); +} + +TEST_CASE("3d fclaw_clawpatch_options packing/unpacking") +{ + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); + opts->mx = 5; + opts->my = 6; + opts->mz = 3; + opts->maux = 4; + opts->mbc = 3; + opts->meqn = 32; + opts->rhs_fields = 39; + opts->refinement_criteria = 1; + opts->interp_stencil_width = 3; + opts->ghost_patch_pack_aux = 7; + opts->save_aux = 1; + opts->is_registered = 1; + + const fclaw_packing_vtable_t* vt = fclaw_clawpatch_options_get_packing_vtable(); + + size_t size = vt->size(opts); + char buffer[size]; + size_t bytes_written = vt->pack(opts,buffer); + REQUIRE_EQ(bytes_written,size); + + fclaw_clawpatch_options_t* output_opts = nullptr; + size_t bytes_read = vt->unpack(buffer,(void**)&output_opts); + + REQUIRE_EQ(bytes_read,size); + REQUIRE_NE(output_opts,nullptr); + + CHECK_EQ(output_opts->patch_dim,3); + CHECK_EQ(output_opts->mx,opts->mx); + CHECK_EQ(output_opts->my,opts->my); + CHECK_EQ(output_opts->mz,opts->mz); + CHECK_EQ(output_opts->maux,opts->maux); + CHECK_EQ(output_opts->mbc,opts->mbc); + CHECK_EQ(output_opts->meqn,opts->meqn); + CHECK_EQ(output_opts->rhs_fields,opts->rhs_fields); + CHECK_EQ(output_opts->refinement_criteria,opts->refinement_criteria); + CHECK_EQ(output_opts->interp_stencil_width,opts->interp_stencil_width); + CHECK_EQ(output_opts->ghost_patch_pack_aux,opts->ghost_patch_pack_aux); + CHECK_EQ(output_opts->save_aux,opts->save_aux); + CHECK_EQ(output_opts->is_registered,opts->is_registered); + + vt->destroy(output_opts); + FCLAW_FREE(opts); +} \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_output_ascii.c b/src/patches/clawpatch/fclaw_clawpatch_output_ascii.c similarity index 53% rename from src/patches/clawpatch/fclaw2d_clawpatch_output_ascii.c rename to src/patches/clawpatch/fclaw_clawpatch_output_ascii.c index c8895b9d8..e8ad9a980 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_output_ascii.c +++ b/src/patches/clawpatch/fclaw_clawpatch_output_ascii.c @@ -23,56 +23,37 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif +#include -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif +#include +#include -#if REFINE_DIM == 2 && PATCH_DIM == 2 -#include +#include +#include +#include -#include -#include -#elif REFINE_DIM ==2 && PATCH_DIM == 3 - -#include - -#include -#include - -#include <_fclaw2d_to_fclaw3dx.h> - -#endif -#include -#include -#include - - -void cb_clawpatch_output_ascii (fclaw2d_domain_t * domain, - fclaw2d_patch_t * patch, +void cb_clawpatch_output_ascii (fclaw_domain_t * domain, + fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) s->glob; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) s->glob; /* Get info not readily available to user */ int global_num, local_num, level; - fclaw2d_patch_get_info(glob->domain,patch, + fclaw_patch_get_info(glob->domain,patch, blockno,patchno, &global_num,&local_num, &level); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int iframe = *((int *) s->user); char fname[BUFSIZ]; snprintf (fname, BUFSIZ, "%s.q%04d", fclaw_opt->prefix, iframe); @@ -80,39 +61,45 @@ void cb_clawpatch_output_ascii (fclaw2d_domain_t * domain, /* The fort routine is defined by a clawpack solver and handles the layout of q in memory (i,j,m) or (m,i,j), etc */ - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - FCLAW_ASSERT(clawpatch_vt->fort_output_ascii); - - int mx,my,mbc; - double xlower,ylower,dx,dy; -#if PATCH_DIM == 2 - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, - &xlower,&ylower,&dx,&dy); - clawpatch_vt->fort_output_ascii(fname,&mx,&my,&meqn,&mbc, - &xlower,&ylower,&dx,&dy,q, - &global_num,&level,&blockno, - &glob->mpirank); -#else - int mz; - double zlower, dz; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mz,&mbc, - &xlower,&ylower,&zlower, - &dx,&dy,&dz); - clawpatch_vt->fort_output_ascii(fname,&mx,&my,&mz,&meqn,&mbc, - &xlower,&ylower,&zlower, - &dx,&dy,&dz,q, - &global_num,&level,&blockno, - &glob->mpirank); -#endif + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); + + if(clawpatch_vt->patch_dim == 2) + { + int mx,my,mbc; + double xlower,ylower,dx,dy; + FCLAW_ASSERT(clawpatch_vt->d2->fort_output_ascii); + + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, + &xlower,&ylower,&dx,&dy); + clawpatch_vt->d2->fort_output_ascii(fname,&mx,&my,&meqn,&mbc, + &xlower,&ylower,&dx,&dy,q, + &global_num,&level,&blockno, + &glob->mpirank); + } + else + { + int mx,my,mz,mbc; + double xlower,ylower,zlower,dx,dy,dz; + FCLAW_ASSERT(clawpatch_vt->d3->fort_output_ascii); + + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz,&mbc, + &xlower,&ylower,&zlower, + &dx,&dy,&dz); + clawpatch_vt->d3->fort_output_ascii(fname,&mx,&my,&mz,&meqn,&mbc, + &xlower,&ylower,&zlower, + &dx,&dy,&dz,q, + &global_num,&level,&blockno, + &glob->mpirank); + } } /* This function isn't virtualized; should it be? */ -void fclaw2d_clawpatch_time_header_ascii(fclaw2d_global_t* glob, int iframe) +void fclaw_clawpatch_time_header_ascii(fclaw_global_t* glob, int iframe) { - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); char matname1[11]; char matname2[11]; @@ -136,15 +123,15 @@ void fclaw2d_clawpatch_time_header_ascii(fclaw2d_global_t* glob, int iframe) vt->output_frame = &fclaw2d_clawpatch_output_ascii; -------------------------------------------------------------------- */ -void fclaw2d_clawpatch_output_ascii(fclaw2d_global_t* glob,int iframe) +void fclaw_clawpatch_output_ascii(fclaw_global_t* glob,int iframe) { - fclaw2d_domain_t *domain = glob->domain; - fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_domain_t *domain = glob->domain; + fclaw_clawpatch_vtable_t *clawpatch_vt = fclaw_clawpatch_vt(glob); /* BEGIN NON-SCALABLE CODE */ /* Write the file contents in serial. Use only for small numbers of processors. */ - fclaw2d_domain_serialization_enter (domain); + fclaw_domain_serialization_enter (domain); if (glob->mpirank == 0) { @@ -152,9 +139,9 @@ void fclaw2d_clawpatch_output_ascii(fclaw2d_global_t* glob,int iframe) } /* Write out each patch to fort.qXXXX */ - fclaw2d_global_iterate_patches (glob, clawpatch_vt->cb_output_ascii, &iframe); + fclaw_global_iterate_patches (glob, clawpatch_vt->cb_output_ascii, &iframe); - fclaw2d_domain_serialization_leave (domain); + fclaw_domain_serialization_leave (domain); /* END OF NON-SCALABLE CODE */ } diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_output_ascii.h b/src/patches/clawpatch/fclaw_clawpatch_output_ascii.h similarity index 82% rename from src/patches/clawpatch/fclaw2d_clawpatch_output_ascii.h rename to src/patches/clawpatch/fclaw_clawpatch_output_ascii.h index c73adb935..b9bd22836 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_output_ascii.h +++ b/src/patches/clawpatch/fclaw_clawpatch_output_ascii.h @@ -23,17 +23,17 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW2D_CLAWPATCH_OUTPUT_ASCII_H -#define FCLAW2D_CLAWPATCH_OUTPUT_ASCII_H +#ifndef FCLAW_CLAWPATCH_OUTPUT_ASCII_H +#define FCLAW_CLAWPATCH_OUTPUT_ASCII_H #ifdef __cplusplus extern "C" { #endif -struct fclaw2d_global; -struct fclaw2d_patch; -struct fclaw2d_domain; +struct fclaw_global; +struct fclaw_patch; +struct fclaw_domain; /** * @file @@ -49,8 +49,8 @@ struct fclaw2d_domain; * @param patchno the patch number * @param user the user data pointer */ -void cb_clawpatch_output_ascii (struct fclaw2d_domain * domain, - struct fclaw2d_patch * patch, +void cb_clawpatch_output_ascii (struct fclaw_domain * domain, + struct fclaw_patch * patch, int blockno, int patchno, void *user); @@ -60,7 +60,7 @@ void cb_clawpatch_output_ascii (struct fclaw2d_domain * domain, * @param glob the global context * @param iframe the frame index */ -void fclaw2d_clawpatch_output_ascii(struct fclaw2d_global* glob,int iframe); +void fclaw_clawpatch_output_ascii(struct fclaw_global* glob,int iframe); /** * @brief output ascii time header @@ -68,7 +68,7 @@ void fclaw2d_clawpatch_output_ascii(struct fclaw2d_global* glob,int iframe); * @param glob the global context * @param iframe the frame index */ -void fclaw2d_clawpatch_time_header_ascii(struct fclaw2d_global* glob, int iframe); +void fclaw_clawpatch_time_header_ascii(struct fclaw_global* glob, int iframe); #ifdef __cplusplus diff --git a/src/patches/clawpatch/fclaw2d_clawpatch_output_vtk.c b/src/patches/clawpatch/fclaw_clawpatch_output_vtk.c similarity index 75% rename from src/patches/clawpatch/fclaw2d_clawpatch_output_vtk.c rename to src/patches/clawpatch/fclaw_clawpatch_output_vtk.c index 51e5d1115..b8cf55b79 100644 --- a/src/patches/clawpatch/fclaw2d_clawpatch_output_vtk.c +++ b/src/patches/clawpatch/fclaw_clawpatch_output_vtk.c @@ -23,13 +23,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif +#include -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif +#include +#include +#include /** Round up quotient x / y. */ #define FCLAW_VTK_CEIL(x, y) (((x) + (y) - 1) / (y)) /**< round up the quotient @@ -38,42 +36,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. computations regarding the VTK patch buffering */ -#if REFINE_DIM == 2 && PATCH_DIM == 2 - -#include - -#include -#include - -#define PATCH_CHILDREN 4 - -#elif REFINE_DIM == 2 && PATCH_DIM == 3 - -#include - -#include -#include - -#include <_fclaw2d_to_fclaw3dx.h> - -#define PATCH_CHILDREN 8 - -#else -#error "This combination of REFINE_DIM and PATCH_DIM is unsupported" -#endif - -#include - -#include -#include +#include +#include #include typedef struct fclaw2d_vtk_state { - int mx, my; -#if PATCH_DIM == 3 - int mz; -#endif + int dim; + int patch_children; + int mx, my, mz; int meqn; int points_per_patch, cells_per_patch; int intsize, ndsize; @@ -91,8 +62,8 @@ typedef struct fclaw2d_vtk_state int64_t offset_meqn, psize_meqn; int64_t offset_end; const char *inttype; - fclaw2d_vtk_patch_data_t coordinate_cb; - fclaw2d_vtk_patch_data_t value_cb; + fclaw_vtk_patch_data_t coordinate_cb; + fclaw_vtk_patch_data_t value_cb; FILE *file; #ifdef P4EST_ENABLE_MPIIO MPI_File mpifile; @@ -120,7 +91,7 @@ typedef struct fclaw2d_vtk_state fclaw2d_vtk_state_t; static int -fclaw2d_vtk_write_header (fclaw2d_domain_t * domain, fclaw2d_vtk_state_t * s) +fclaw2d_vtk_write_header (fclaw_domain_t * domain, fclaw2d_vtk_state_t * s) { int retval; FILE *file; @@ -287,10 +258,10 @@ add_to_buffer (fclaw2d_vtk_state_t * s, int64_t psize_field) } static void -write_position_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +write_position_cb (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t*) user; fclaw2d_vtk_state_t *s = (fclaw2d_vtk_state_t *) g->user; s->coordinate_cb (g->glob, patch, blockno, patchno, s->buf); @@ -298,10 +269,10 @@ write_position_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, } static void -write_connectivity_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +write_2d_connectivity_cb (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t*) user; fclaw2d_vtk_state_t *s = (fclaw2d_vtk_state_t *) g->user; int i, j; const int64_t pbefore = s->points_per_patch * @@ -313,91 +284,105 @@ write_connectivity_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, int32_t *idata = (int32_t *) s->buf; int32_t l; -#if PATCH_DIM == 3 - int k; - for (k = 0; k < s->mz; ++k) - { -#if 0 - } -#endif -#endif for (j = 0; j < s->my; ++j) { for (i = 0; i < s->mx; ++i) { - l = (int32_t) pbefore + i + j * (s->mx + 1) -#if PATCH_DIM == 3 - + k * (s->my + 1) * (s->mx + 1) -#endif - + 0; + l = (int32_t) pbefore + i + j * (s->mx + 1); *idata++ = l; *idata++ = l + 1; *idata++ = l + (s->mx + 2); *idata++ = l + (s->mx + 1); -#if PATCH_DIM == 3 - *idata++ = l + (s->mx + 1) * (s->my + 1); - *idata++ = l + (s->mx + 1) * (s->my + 1) + 1; - *idata++ = l + (s->mx + 1) * (s->my + 1) + (s->mx + 2); - *idata++ = l + (s->mx + 1) * (s->my + 1) + (s->mx + 1); -#endif } } -#if PATCH_DIM == 3 -#if 0 - { -#endif - } -#endif } else { int64_t *idata = (int64_t *) s->buf; int64_t l; - -#if PATCH_DIM == 3 - int k; - for (k = 0; k < s->mz; ++k) - { -#if 0 - } -#endif -#endif for (j = 0; j < s->my; ++j) { for (i = 0; i < s->mx; ++i) { - l = pbefore + i + j * (s->mx + 1) -#if PATCH_DIM == 3 - + k * (s->my + 1) * (s->mx + 1) -#endif - + 0; + l = pbefore + i + j * (s->mx + 1); *idata++ = l; *idata++ = l + 1; *idata++ = l + (s->mx + 2); *idata++ = l + (s->mx + 1); -#if PATCH_DIM == 3 - *idata++ = l + (s->mx + 1) * (s->my + 1); - *idata++ = l + (s->mx + 1) * (s->my + 1) + 1; - *idata++ = l + (s->mx + 1) * (s->my + 1) + (s->mx + 2); - *idata++ = l + (s->mx + 1) * (s->my + 1) + (s->mx + 1); -#endif } } -#if PATCH_DIM == 3 -#if 0 + } + add_to_buffer (s, s->psize_connectivity); +} +static void +write_3d_connectivity_cb (fclaw_domain_t * domain, fclaw_patch_t * patch, + int blockno, int patchno, void *user) +{ + fclaw_global_iterate_t *g = (fclaw_global_iterate_t*) user; + fclaw2d_vtk_state_t *s = (fclaw2d_vtk_state_t *) g->user; + int i, j, k; + const int64_t pbefore = s->points_per_patch * + (domain->global_num_patches_before + + domain->blocks[blockno].num_patches_before + patchno); + + if (s->fits32) + { + int32_t *idata = (int32_t *) s->buf; + int32_t l; + + for (k = 0; k < s->mz; ++k) { -#endif + for (j = 0; j < s->my; ++j) + { + for (i = 0; i < s->mx; ++i) + { + l = (int32_t) pbefore + i + j * (s->mx + 1) + + k * (s->my + 1) * (s->mx + 1); + *idata++ = l; + *idata++ = l + 1; + *idata++ = l + (s->mx + 2); + *idata++ = l + (s->mx + 1); + *idata++ = l + (s->mx + 1) * (s->my + 1); + *idata++ = l + (s->mx + 1) * (s->my + 1) + 1; + *idata++ = l + (s->mx + 1) * (s->my + 1) + (s->mx + 2); + *idata++ = l + (s->mx + 1) * (s->my + 1) + (s->mx + 1); + } + } + } + } + else + { + int64_t *idata = (int64_t *) s->buf; + int64_t l; + + for (k = 0; k < s->mz; ++k) + { + for (j = 0; j < s->my; ++j) + { + for (i = 0; i < s->mx; ++i) + { + l = pbefore + i + j * (s->mx + 1) + + k * (s->my + 1) * (s->mx + 1); + *idata++ = l; + *idata++ = l + 1; + *idata++ = l + (s->mx + 2); + *idata++ = l + (s->mx + 1); + *idata++ = l + (s->mx + 1) * (s->my + 1); + *idata++ = l + (s->mx + 1) * (s->my + 1) + 1; + *idata++ = l + (s->mx + 1) * (s->my + 1) + (s->mx + 2); + *idata++ = l + (s->mx + 1) * (s->my + 1) + (s->mx + 1); + } + } } -#endif } add_to_buffer (s, s->psize_connectivity); } static void -write_offsets_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +write_offsets_cb (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t*) user; fclaw2d_vtk_state_t *s = (fclaw2d_vtk_state_t *) g->user; int c; const int64_t cbefore = s->cells_per_patch * @@ -407,8 +392,8 @@ write_offsets_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, if (s->fits32) { int32_t *idata = (int32_t *) s->buf; - int32_t k = PATCH_CHILDREN * (int32_t) (cbefore + 1); - for (c = 0; c < s->cells_per_patch; k += PATCH_CHILDREN, ++c) + int32_t k = s->patch_children * (int32_t) (cbefore + 1); + for (c = 0; c < s->cells_per_patch; k += s->patch_children, ++c) { *idata++ = k; } @@ -416,8 +401,8 @@ write_offsets_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, else { int64_t *idata = (int64_t *) s->buf; - int64_t k = PATCH_CHILDREN * (cbefore + 1); - for (c = 0; c < s->cells_per_patch; k += PATCH_CHILDREN, ++c) + int64_t k = s->patch_children * (cbefore + 1); + for (c = 0; c < s->cells_per_patch; k += s->patch_children, ++c) { *idata++ = k; } @@ -426,30 +411,36 @@ write_offsets_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, } static void -write_types_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +write_types_cb (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t*) user; fclaw2d_vtk_state_t *s = (fclaw2d_vtk_state_t *) g->user; int c; char *cdata = s->buf; - for (c = 0; c < s->cells_per_patch; ++c) + if(s->dim == 2) { -#if PATCH_DIM == 2 - *cdata++ = 9; -#else - *cdata++ = 12; -#endif + for (c = 0; c < s->cells_per_patch; ++c) + { + *cdata++ = 9; + } + } + else + { + for (c = 0; c < s->cells_per_patch; ++c) + { + *cdata++ = 12; + } } add_to_buffer (s, s->psize_types); } static void -write_mpirank_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +write_mpirank_cb (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t*) user; fclaw2d_vtk_state_t *s = (fclaw2d_vtk_state_t *) g->user; int c; @@ -462,10 +453,10 @@ write_mpirank_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, } static void -write_blockno_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +write_blockno_cb (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t*) user; fclaw2d_vtk_state_t *s = (fclaw2d_vtk_state_t *) g->user; int c; @@ -478,10 +469,10 @@ write_blockno_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, } static void -write_patchno_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +write_patchno_cb (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t *g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t *g = (fclaw_global_iterate_t*) user; fclaw2d_vtk_state_t *s = (fclaw2d_vtk_state_t *) g->user; int c; const int64_t gpno = @@ -509,10 +500,10 @@ write_patchno_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, } static void -write_meqn_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, +write_meqn_cb (fclaw_domain_t * domain, fclaw_patch_t * patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* g = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t* g = (fclaw_global_iterate_t*) user; fclaw2d_vtk_state_t *s = (fclaw2d_vtk_state_t *) g->user; @@ -521,11 +512,11 @@ write_meqn_cb (fclaw2d_domain_t * domain, fclaw2d_patch_t * patch, } static void -fclaw2d_vtk_write_field (fclaw2d_global_t * glob, fclaw2d_vtk_state_t * s, +fclaw2d_vtk_write_field (fclaw_global_t * glob, fclaw2d_vtk_state_t * s, int64_t offset_field, int64_t psize_field, - fclaw2d_patch_callback_t cb) + fclaw_patch_callback_t cb) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; int64_t bcount; sc_array_t buffer; @@ -577,7 +568,7 @@ fclaw2d_vtk_write_field (fclaw2d_global_t * glob, fclaw2d_vtk_state_t * s, SC_CHECK_MPI (mpiret); #endif } - fclaw2d_global_iterate_patches (glob, cb, s); + fclaw_global_iterate_patches (glob, cb, s); #ifdef P4EST_ENABLE_MPIIO if (s->num_buffered_patches > 0 || s->patch_threshold == 0) @@ -642,7 +633,7 @@ fclaw2d_vtk_write_field (fclaw2d_global_t * glob, fclaw2d_vtk_state_t * s, } static void -fclaw2d_vtk_write_data (fclaw2d_global_t * glob, fclaw2d_vtk_state_t * s) +fclaw2d_vtk_write_data (fclaw_global_t * glob, fclaw2d_vtk_state_t * s) { #ifdef P4EST_ENABLE_MPIIO int mpiret; @@ -664,7 +655,7 @@ fclaw2d_vtk_write_data (fclaw2d_global_t * glob, fclaw2d_vtk_state_t * s) fclaw2d_vtk_write_field (glob, s, s->offset_position, s->psize_position, write_position_cb); fclaw2d_vtk_write_field (glob, s, s->offset_connectivity, - s->psize_connectivity, write_connectivity_cb); + s->psize_connectivity, (s->dim == 2) ? write_2d_connectivity_cb : write_3d_connectivity_cb); fclaw2d_vtk_write_field (glob, s, s->offset_offsets, s->psize_offsets, write_offsets_cb); fclaw2d_vtk_write_field (glob, s, s->offset_types, s->psize_types, @@ -686,7 +677,7 @@ fclaw2d_vtk_write_data (fclaw2d_global_t * glob, fclaw2d_vtk_state_t * s) } static int -fclaw2d_vtk_write_footer (fclaw2d_domain_t * domain, fclaw2d_vtk_state_t * s) +fclaw2d_vtk_write_footer (fclaw_domain_t * domain, fclaw2d_vtk_state_t * s) { int retval; FILE *file; @@ -714,19 +705,16 @@ fclaw2d_vtk_write_footer (fclaw2d_domain_t * domain, fclaw2d_vtk_state_t * s) return retval ? -1 : 0; } -int -fclaw2d_vtk_write_file (fclaw2d_global_t * glob, const char *basename, - int mx, int my, -#if PATCH_DIM == 3 - int mz, -#endif - int meqn, - double vtkspace, int vtkwrite, - fclaw2d_vtk_patch_data_t coordinate_cb, - fclaw2d_vtk_patch_data_t value_cb, - int patch_threshold) +static int +fclaw_vtk_write_file (int dim, fclaw_global_t * glob, const char *basename, + int mx, int my, int mz, + int meqn, + double vtkspace, int vtkwrite, + fclaw_vtk_patch_data_t coordinate_cb, + fclaw_vtk_patch_data_t value_cb, + int patch_threshold) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; FCLAW_ASSERT (patch_threshold >= 0); @@ -735,22 +723,26 @@ fclaw2d_vtk_write_file (fclaw2d_global_t * glob, const char *basename, fclaw2d_vtk_state_t ps, *s = &ps; /* set up VTK internal information */ + s->dim = dim; + s->patch_children = (dim == 2) ? 4 : 8; s->mx = mx; s->my = my; -#if PATCH_DIM == 3 - s->mz = mz; -#endif + if(dim == 3) + { + s->mz = mz; + } s->meqn = meqn; s->points_per_patch = (mx + 1) * (my + 1); s->cells_per_patch = mx * my; -#if PATCH_DIM == 3 - s->points_per_patch *= (mz + 1); - s->cells_per_patch *= mz; -#endif + if(dim == 3) + { + s->points_per_patch *= (mz + 1); + s->cells_per_patch *= mz; + } snprintf (s->filename, BUFSIZ, "%s.vtu", basename); s->global_num_points = s->points_per_patch * domain->global_num_patches; s->global_num_cells = s->cells_per_patch * domain->global_num_patches; - s->global_num_connectivity = PATCH_CHILDREN * (s->global_num_cells + 1); + s->global_num_connectivity = s->patch_children * (s->global_num_cells + 1); s->fits32 = s->global_num_points <= INT32_MAX && s->global_num_connectivity <= INT32_MAX; s->inttype = s->fits32 ? "Int32" : "Int64"; @@ -761,7 +753,7 @@ fclaw2d_vtk_write_file (fclaw2d_global_t * glob, const char *basename, /* compute data size per patch for the various VTK data arrays */ s->psize_position = s->points_per_patch * 3 * sizeof (double); - s->psize_connectivity = s->cells_per_patch * PATCH_CHILDREN * s->intsize; + s->psize_connectivity = s->cells_per_patch * s->patch_children * s->intsize; s->psize_offsets = s->cells_per_patch * s->intsize; s->psize_types = s->cells_per_patch * 1; s->psize_mpirank = s->cells_per_patch * 4; @@ -829,19 +821,45 @@ fclaw2d_vtk_write_file (fclaw2d_global_t * glob, const char *basename, return 0; } +int +fclaw_vtk_write_2d_file (fclaw_global_t * glob, const char *basename, + int mx, int my, + int meqn, + double vtkspace, int vtkwrite, + fclaw_vtk_patch_data_t coordinate_cb, + fclaw_vtk_patch_data_t value_cb, + int patch_threshold) +{ + return fclaw_vtk_write_file(2,glob,basename,mx,my,0,meqn,vtkspace,vtkwrite, + coordinate_cb,value_cb, patch_threshold); +} + +int +fclaw_vtk_write_3d_file (fclaw_global_t * glob, const char *basename, + int mx, int my, int mz, + int meqn, + double vtkspace, int vtkwrite, + fclaw_vtk_patch_data_t coordinate_cb, + fclaw_vtk_patch_data_t value_cb, + int patch_threshold) +{ + return fclaw_vtk_write_file(3,glob,basename,mx,my,mz,meqn,vtkspace,vtkwrite, + coordinate_cb,value_cb, patch_threshold); +} + static void -fclaw2d_output_vtk_coordinate_cb (fclaw2d_global_t * glob, - fclaw2d_patch_t * patch, +fclaw2d_output_vtk_coordinate_cb (fclaw_global_t * glob, + fclaw_patch_t * patch, int blockno, int patchno, char *a) { int mx,my,mbc; double dx,dy,xlower,ylower; -#if PATCH_DIM == 2 - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + fclaw_map_context_t* cont = fclaw_map_get(glob); /* Enumerate point coordinates in the patch */ double *d = (double *) a; @@ -855,8 +873,7 @@ fclaw2d_output_vtk_coordinate_cb (fclaw2d_global_t * glob, const double x = xlower + i * dx; if (fclaw_opt->manifold) { - fclaw2d_map_context_t *cont = glob->cont; - FCLAW2D_MAP_C2M(&cont,&blockno,&x,&y,&xpp,&ypp,&zpp); + FCLAW_MAP_2D_C2M(&cont,&blockno,&x,&y,&xpp,&ypp,&zpp); *d++ = xpp; *d++ = ypp; *d++ = zpp; @@ -869,13 +886,21 @@ fclaw2d_output_vtk_coordinate_cb (fclaw2d_global_t * glob, } } } -#elif PATCH_DIM == 3 - int mz; - double zlower, dz; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mz, &mbc, +} + +static void +fclaw3d_output_vtk_coordinate_cb (fclaw_global_t * glob, + fclaw_patch_t * patch, + int blockno, int patchno, + char *a) +{ + int mx,my,mz,mbc; + double dx,dy,dz,xlower,ylower,zlower; + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, &mbc, &xlower,&ylower,&zlower, &dx,&dy, &dz); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + fclaw_map_context_t* cont = fclaw_map_get(glob); /* Enumerate point coordinates in the patch */ double *d = (double *) a; int i, j, k; @@ -891,8 +916,7 @@ fclaw2d_output_vtk_coordinate_cb (fclaw2d_global_t * glob, const double x = xlower + i * dx; if (fclaw_opt->manifold) { - fclaw2d_map_context_t *cont = glob->cont; - FCLAW3D_MAP_C2M(&cont,&blockno,&x,&y,&z,&xpp,&ypp,&zpp); + FCLAW_MAP_3D_C2M(&cont,&blockno,&x,&y,&z,&xpp,&ypp,&zpp); *d++ = xpp; *d++ = ypp; *d++ = zpp; @@ -906,28 +930,23 @@ fclaw2d_output_vtk_coordinate_cb (fclaw2d_global_t * glob, } } } -#endif } static void -fclaw2d_output_vtk_value_cb (fclaw2d_global_t * glob, - fclaw2d_patch_t * patch, +fclaw2d_output_vtk_value_cb (fclaw_global_t * glob, + fclaw_patch_t * patch, int blockno, int patchno, char *a) { - -// fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(glob); - int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int mx,my,mbc; double xlower,ylower,dx,dy; -#if PATCH_DIM == 2 - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); const int xlane = mx + 2 * mbc; @@ -950,11 +969,23 @@ fclaw2d_output_vtk_value_cb (fclaw2d_global_t * glob, } } } -#elif PATCH_DIM == 3 - int mz; - double zlower, dz; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mz, &mbc, - &xlower,&ylower,&zlower, &dx,&dy, &dz); +} + +static void +fclaw3d_output_vtk_value_cb (fclaw_global_t * glob, + fclaw_patch_t * patch, + int blockno, int patchno, + char *a) +{ + + int meqn; + double *q; + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); + + int mx,my,mz,mbc; + double xlower,ylower,zlower,dx,dy,dz; + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz, &mbc, + &xlower,&ylower,&zlower, &dx,&dy, &dz); const int xlane = mx + 2 * mbc; const int ylane = my + 2 * mbc; @@ -980,7 +1011,6 @@ fclaw2d_output_vtk_value_cb (fclaw2d_global_t * glob, } } } -#endif } /* -------------------------------------------------------------------------- @@ -988,10 +1018,10 @@ fclaw2d_output_vtk_value_cb (fclaw2d_global_t * glob, ------------------------------------------------------------------------- */ #if 0 static void -fclaw2d_output_write_vtk_debug (fclaw2d_global_t * glob, const char *basename) +fclaw2d_output_write_vtk_debug (fclaw_global_t * glob, const char *basename) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); (void) fclaw2d_vtk_write_file (glob, basename, clawpatch_opt->mx, clawpatch_opt->my, @@ -1010,27 +1040,46 @@ fclaw2d_output_write_vtk_debug (fclaw2d_global_t * glob, const char *basename) Public interface --------------------------------------------------------------------------- */ -void fclaw2d_clawpatch_output_vtk (fclaw2d_global_t * glob, int iframe) +void fclaw_clawpatch_output_vtk_to_file (fclaw_global_t * glob, const char* filename) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); + + + if(clawpatch_opt->patch_dim == 2) + { + fclaw_vtk_write_2d_file (glob, filename, + clawpatch_opt->mx, + clawpatch_opt->my, + clawpatch_opt->meqn, + fclaw_opt->vtkspace, 0, + fclaw2d_output_vtk_coordinate_cb, + fclaw2d_output_vtk_value_cb, + clawpatch_opt->vtk_patch_threshold); + } + else + { + fclaw_vtk_write_3d_file (glob, filename, + clawpatch_opt->mx, + clawpatch_opt->my, + clawpatch_opt->mz, + clawpatch_opt->meqn, + fclaw_opt->vtkspace, 0, + fclaw3d_output_vtk_coordinate_cb, + fclaw3d_output_vtk_value_cb, + clawpatch_opt->vtk_patch_threshold); + } +} +void fclaw_clawpatch_output_vtk (fclaw_global_t * glob, int iframe) +{ + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); char basename[BUFSIZ]; snprintf (basename, BUFSIZ, "%s_frame_%04d", fclaw_opt->prefix, iframe); - /* The last parameter of the call of fclaw2d_vtk_write_file can be replaced - * by a value from flcaw_opt or clawpatch_opt. - */ - (void) fclaw2d_vtk_write_file (glob, basename, - clawpatch_opt->mx, clawpatch_opt->my, -#if PATCH_DIM == 3 - clawpatch_opt->mz, -#endif - clawpatch_opt->meqn, - fclaw_opt->vtkspace, 0, - fclaw2d_output_vtk_coordinate_cb, - fclaw2d_output_vtk_value_cb, clawpatch_opt->vtk_patch_threshold); + fclaw_clawpatch_output_vtk_to_file(glob,basename); } + diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_output_vtk.h b/src/patches/clawpatch/fclaw_clawpatch_output_vtk.h similarity index 58% rename from src/patches/clawpatch/fclaw3dx_clawpatch_output_vtk.h rename to src/patches/clawpatch/fclaw_clawpatch_output_vtk.h index ea8412072..ffa121873 100644 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_output_vtk.h +++ b/src/patches/clawpatch/fclaw_clawpatch_output_vtk.h @@ -23,8 +23,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW3DX_CLAWPATCH_OUTPUT_VTK_H -#define FCLAW3DX_CLAWPATCH_OUTPUT_VTK_H +#ifndef FCLAW_CLAWPATCH_OUTPUT_VTK_H +#define FCLAW_CLAWPATCH_OUTPUT_VTK_H /** * @file @@ -39,8 +39,8 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; /** * Callback to access/compute patch data for visualization. @@ -55,10 +55,10 @@ struct fclaw2d_patch; * The vector index changes fastest, then mx, then my * slowest. */ -typedef void (*fclaw3dx_vtk_patch_data_t) (struct fclaw2d_global * glob, - struct fclaw2d_patch * this_patch, - int this_block_idx, int this_patch_idx, - char *a); +typedef void (*fclaw_vtk_patch_data_t) (struct fclaw_global * glob, + struct fclaw_patch * this_patch, + int this_block_idx, int this_patch_idx, + char *a); /** * Write a file in VTK format for the whole domain in parallel. @@ -80,13 +80,48 @@ typedef void (*fclaw3dx_vtk_patch_data_t) (struct fclaw2d_global * glob, * Collective with identical value on all ranks. */ int -fclaw3dx_vtk_write_file (struct fclaw2d_global * glob, const char *basename, +fclaw_vtk_write_2d_file (struct fclaw_global * glob, const char *basename, + int mx, int my, + int meqn, + double vtkspace, int vtkwrite, + fclaw_vtk_patch_data_t coordinate_cb, + fclaw_vtk_patch_data_t value_cb, + int patch_threshold); +/** + * Write a file in VTK format for the whole domain in parallel. + * @param[in] glob the global context + * @param[in] basename the base filename + * @param[in] mx, my, mz th enumber of cells in the x, y, and z directions + * @param[in] meqn th enumber of equations + * @param[in] vtkspace Relative width of visual separation of patches. + * Between 0. (none) and 1. (patch width becomes 0). + * @param[in] vtkwrite Mode of writing: (unused; uses 1 by default) + * 0 for MPI_File_write_all (faster), + * 1 for MPI_File_write (less memory usage). + * @param[in] coordniate_cb the callback to write a patch's coordinate binary data + * @param[in] value_cb the callback to write a patch's value binary data + * @param[in] patch_threshold The maximal number of buffered patches. + * 0 means that an unlimited number of patches is + * buffered and flushed to disk at the end. + * @return 0 if successful, negative otherwise. + * Collective with identical value on all ranks. + */ +int +fclaw_vtk_write_3d_file (struct fclaw_global * glob, const char *basename, int mx, int my, int mz, - int meqn, - double vtkspace, int vtkwrite, - fclaw3dx_vtk_patch_data_t coordinate_cb, - fclaw3dx_vtk_patch_data_t value_cb, - int patch_threshold); + int meqn, + double vtkspace, int vtkwrite, + fclaw_vtk_patch_data_t coordinate_cb, + fclaw_vtk_patch_data_t value_cb, + int patch_threshold); + +/** + * @brief Output vtu file + * + * @param glob the global context + * @param filename the filename to output to + */ +void fclaw_clawpatch_output_vtk_to_file (struct fclaw_global* glob, const char* filename); /** * @brief Output vtu file @@ -94,7 +129,7 @@ fclaw3dx_vtk_write_file (struct fclaw2d_global * glob, const char *basename, * @param glob the global context * @param iframe the the frame index */ -void fclaw3dx_clawpatch_output_vtk (struct fclaw2d_global* glob, int iframe); +void fclaw_clawpatch_output_vtk (struct fclaw_global* glob, int iframe); #ifdef __cplusplus diff --git a/src/patches/clawpatch/fclaw_clawpatch_pillow.c b/src/patches/clawpatch/fclaw_clawpatch_pillow.c new file mode 100644 index 000000000..0b66d0116 --- /dev/null +++ b/src/patches/clawpatch/fclaw_clawpatch_pillow.c @@ -0,0 +1,288 @@ +/* +Copyright (c) 2012-2022 Carsten Burstedde, Donna Calhoun, Scott Aiton +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include + +#include +#include +#include +#include +#include + + +#include + +#include + +struct fclaw_patch_transform_data; /* Not used here, so we leave it incomplete */ + +static +void pillow_copy_block_corner(fclaw_global_t* glob, + fclaw_patch_t* patch, + fclaw_patch_t *corner_patch, + int blockno, + int corner_blockno, + int icorner, + int time_interp, + struct fclaw_patch_transform_data *transform_data) +{ + int meqn; + double *qthis; + fclaw_clawpatch_timesync_data(glob,patch,time_interp,&qthis,&meqn); + + double *qcorner = fclaw_clawpatch_get_q(glob,corner_patch); + + fclaw_clawpatch_pillow_vtable_t* pillow_vt = fclaw_clawpatch_pillow_vt(glob); + FCLAW_ASSERT(pillow_vt != NULL); + + if(pillow_vt->dim == 2) + { + int mx,my,mbc; + double xlower,ylower,dx,dy; + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, + &xlower,&ylower,&dx,&dy); + + pillow_vt->d2->fort_copy_block_corner(&mx, &my, &mbc, &meqn, + qthis, qcorner, + &icorner, &blockno); + } + else + { + int mx,my,mz,mbc; + double xlower,ylower,zlower,dx,dy,dz; + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz,&mbc, + &xlower,&ylower,&zlower, &dx, &dy, &dz); + FCLAW_ASSERT(pillow_vt->d3->fort_copy_block_corner != NULL); + + pillow_vt->d3->fort_copy_block_corner(&mx, &my, &mz, &mbc, &meqn, + qthis, qcorner, + &icorner, &blockno); + } + +} + +static +void pillow_average_block_corner(fclaw_global_t *glob, + fclaw_patch_t* coarse_patch, + fclaw_patch_t *fine_patch, + int coarse_blockno, + int fine_blockno, + int icorner_coarse, + int time_interp, + struct fclaw_patch_transform_data* transform_data) +{ + + int refratio = 2; + + int meqn; + double *qcoarse; + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp, + &qcoarse,&meqn); + double* qfine = fclaw_clawpatch_get_q(glob,fine_patch); + + + fclaw_clawpatch_pillow_vtable_t* pillow_vt = fclaw_clawpatch_pillow_vt(glob); + + if(pillow_vt->dim == 2) + { + int mx,my,mbc; + double xlower,ylower,dx,dy; + + fclaw_clawpatch_2d_grid_data(glob,coarse_patch,&mx,&my,&mbc, + &xlower,&ylower,&dx,&dy); + + + double *areacoarse = fclaw_clawpatch_get_2d_area(glob,coarse_patch); + double *areafine = fclaw_clawpatch_get_2d_area(glob,fine_patch); + + pillow_vt->d2->fort_average_block_corner(&mx,&my,&mbc,&meqn, + &refratio,qcoarse,qfine, + areacoarse,areafine, + &icorner_coarse,&coarse_blockno); + } + else + { + int mx,my,mz,mbc; + double xlower,ylower,zlower,dx,dy,dz; + fclaw_clawpatch_3d_grid_data(glob,coarse_patch,&mx,&my,&mz, &mbc, + &xlower,&ylower, &zlower, &dx,&dy, &dz); + + double *volcoarse = fclaw_clawpatch_get_3d_volume(glob,coarse_patch); + double *volfine = fclaw_clawpatch_get_3d_volume(glob,fine_patch); + + pillow_vt->d3->fort_average_block_corner(&mx,&my,&mz, &dz, &mbc,&meqn, + &refratio,qcoarse,qfine, + volcoarse,volfine, + &icorner_coarse,&coarse_blockno); + } +} + +static +void pillow_interpolate_block_corner(fclaw_global_t* glob, + fclaw_patch_t* coarse_patch, + fclaw_patch_t *fine_patch, + int coarse_blockno, + int fine_blockno, + int icoarse_corner, + int time_interp, + struct fclaw_patch_transform_data* transform_data) + +{ + int meqn; + double *qcoarse; + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp, + &qcoarse,&meqn); + + double* qfine = fclaw_clawpatch_get_q(glob,fine_patch); + + fclaw_clawpatch_pillow_vtable_t* pillow_vt = fclaw_clawpatch_pillow_vt(glob); + int refratio = 2; + if(pillow_vt->dim == 2) + { + int mx,my,mbc; + double xlower,ylower,dx,dy; + fclaw_clawpatch_2d_grid_data(glob,coarse_patch,&mx,&my,&mbc, + &xlower,&ylower,&dx,&dy); + + pillow_vt->d2->fort_interpolate_block_corner(&mx, &my, &mbc, &meqn, + &refratio, qcoarse, qfine, + &icoarse_corner, &coarse_blockno); + } + else + { + int mx,my,mz,mbc; + double xlower,ylower,zlower,dx,dy,dz; + fclaw_clawpatch_3d_grid_data(glob,coarse_patch,&mx,&my,&mz, &mbc, + &xlower,&ylower,&zlower, &dx,&dy, &dz); + + pillow_vt->d3->fort_interpolate_block_corner(&mx, &my, &mz, &mbc, &meqn, + &refratio, qcoarse, qfine, + &icoarse_corner, &coarse_blockno); + } +} + +/* ----------------------------- Use pillow sphere ------------------------------------ */ + +void fclaw_clawpatch_use_pillowsphere(fclaw_global_t* glob) +{ + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); + + patch_vt->copy_block_corner = pillow_copy_block_corner; + patch_vt->average_block_corner = pillow_average_block_corner; + patch_vt->interpolate_block_corner = pillow_interpolate_block_corner; + +} + + +/* -------------------------------- Virtual table ------------------------------------- */ + +static +fclaw_clawpatch_pillow_vtable_t* pillow_vt_new(int dim) +{ + fclaw_clawpatch_pillow_vtable_t* pillow_vt = + FCLAW_ALLOC_ZERO (fclaw_clawpatch_pillow_vtable_t, 1); + pillow_vt->dim = dim; + if(dim == 2) + { + pillow_vt->d2 = FCLAW_ALLOC_ZERO(struct fclaw_clawpatch_pillow_vtable_d2,1); + } + else + { + pillow_vt->d3 = FCLAW_ALLOC_ZERO(struct fclaw_clawpatch_pillow_vtable_d3,1); + } + return pillow_vt; +} + +static +void pillow_vt_destroy(void* vt) +{ + fclaw_clawpatch_pillow_vtable_t *pillow_vt = (fclaw_clawpatch_pillow_vtable_t*) vt; + if (pillow_vt->dim == 2) + { + FCLAW_FREE (pillow_vt->d2); + } + else + { + FCLAW_FREE (pillow_vt->d3); + } + FCLAW_FREE (pillow_vt); +} + +void fclaw_clawpatch_pillow_vtable_initialize(fclaw_global_t* glob, + int claw_version) +{ + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_get_options(glob); + fclaw_clawpatch_pillow_vtable_t *pillow_vt = pillow_vt_new(clawpatch_opt->patch_dim); + + if(clawpatch_opt->patch_dim == 2) + { + if (claw_version == 4) + { + pillow_vt->d2->fort_copy_block_corner = FCLAW2D_PILLOW46_COPY_BLOCK_CORNER; + pillow_vt->d2->fort_average_block_corner = FCLAW2D_PILLOW46_AVERAGE_BLOCK_CORNER; + pillow_vt->d2->fort_interpolate_block_corner = FCLAW2D_PILLOW46_INTERPOLATE_BLOCK_CORNER; + } + else if (claw_version == 5) + { + pillow_vt->d2->fort_copy_block_corner = FCLAW2D_PILLOW5_COPY_BLOCK_CORNER; + pillow_vt->d2->fort_average_block_corner = FCLAW2D_PILLOW5_AVERAGE_BLOCK_CORNER; + pillow_vt->d2->fort_interpolate_block_corner = FCLAW2D_PILLOW5_INTERPOLATE_BLOCK_CORNER; + } + } + else + { + if (claw_version == 4) + { + pillow_vt->d3->fort_copy_block_corner = FCLAW3DX_PILLOW46_COPY_BLOCK_CORNER; + pillow_vt->d3->fort_average_block_corner = FCLAW3DX_PILLOW46_AVERAGE_BLOCK_CORNER; + pillow_vt->d3->fort_interpolate_block_corner = FCLAW3DX_PILLOW46_INTERPOLATE_BLOCK_CORNER; + } + } + + pillow_vt->is_set = 1; + + FCLAW_ASSERT(fclaw_pointer_map_get(glob->vtables, "fclaw_clawpatch_pillow_vtable") == NULL); + fclaw_pointer_map_insert(glob->vtables, "fclaw_clawpatch_pillow_vtable", pillow_vt, pillow_vt_destroy); + +} + +/* ------------------------------- Public access functions ---------------------------- */ + + +fclaw_clawpatch_pillow_vtable_t* fclaw_clawpatch_pillow_vt(fclaw_global_t* glob) +{ + + fclaw_clawpatch_pillow_vtable_t* pillow_vt = (fclaw_clawpatch_pillow_vtable_t*) + fclaw_pointer_map_get(glob->vtables, + "fclaw_clawpatch_pillow_vtable"); + + FCLAW_ASSERT(pillow_vt != NULL); + FCLAW_ASSERT(pillow_vt->is_set != 0); + return pillow_vt; +} \ No newline at end of file diff --git a/src/patches/clawpatch/fclaw3dx_clawpatch_pillow.h b/src/patches/clawpatch/fclaw_clawpatch_pillow.h similarity index 61% rename from src/patches/clawpatch/fclaw3dx_clawpatch_pillow.h rename to src/patches/clawpatch/fclaw_clawpatch_pillow.h index fedd88c96..67b093114 100644 --- a/src/patches/clawpatch/fclaw3dx_clawpatch_pillow.h +++ b/src/patches/clawpatch/fclaw_clawpatch_pillow.h @@ -23,18 +23,21 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FCLAW3DX_CLAWPATCH_PILLOW_H -#define FCLAW3DX_CLAWPATCH_PILLOW_H +#ifndef FCLAW_CLAWPATCH_PILLOW_H +#define FCLAW_CLAWPATCH_PILLOW_H #include #ifdef __cplusplus extern "C" { +#if 0 +} /* need this because indent is dumb */ +#endif #endif struct fclaw2d_glob; -struct fclaw2d_patch; +struct fclaw_patch; struct fclaw2d_patch_transform; /** @@ -44,9 +47,72 @@ struct fclaw2d_patch_transform; */ /** typedef */ -typedef struct fclaw3dx_clawpatch_pillow_vtable fclaw3dx_clawpatch_pillow_vtable_t; +typedef struct fclaw_clawpatch_pillow_vtable fclaw_clawpatch_pillow_vtable_t; +/* ----------------------------- Fortran typedefs ------------------------------------- */ + +/** + * @brief Handles the boundary condition at block corners + * + * @param[in] my, my the number of cells in the x and y directions + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in,out] qthis this solution + * @param[in,out] qneighbor the neighbor solution + * @param[in] icorner the corner that the neighbor is on + * @param[in] iblock the block number + */ +typedef void (*pillow_fort_copy_block_corner_t)(int* mx, int* my, + int* mbc, int* meqn, + double qthis[], + double qneighbor[], + int* icorner, + int* iblock); + +/** + * @brief Handles the boundary condition at block corners with finer neighbors + * + * @param[in] my, my the number of cells in the x and y directions + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] refratio the refinement ratio + * @param[in,out] qcoarse this solution + * @param[in] qfine the neighbor solution + * @param[in] areacoarse cell areas + * @param[in] areafine neighbor cell areas + * @param[in] icorner the corner that the fine neighbor is on + * @param[in] blockno the block number + */ +typedef void (*pillow_fort_average_block_corner_t)(int* mx, int* my, int* mbc, + int* meqn, + int* refratio, + double qcoarse[], + double qfine[], + double areacoarse[], + double areafine[], + int* icorner, + int* blockno); + +/** + * @brief Handles the boundary condition at block corners with coarser neighbors + * + * @param[in] my, my the number of cells in the x and y directions + * @param[in] mbc the number of ghost cells + * @param[in] meqn the number of equations + * @param[in] refratio the refinement ratio + * @param[in] qcoarse this solution + * @param[in,out] qfine the neighbor solution + * @param[in] icorner_coarse the corner that the fine neighbor is on + * @param[in] blockno the block number + */ +typedef void (*pillow_fort_interpolate_block_corner_t)(int* mx, int* my, int* mbc, + int* meqn, int* refratio, + double qcoarse[], + double qfine[], + int* icoarse_corner, + int* blockno); + /* ----------------------------- Fortran typedefs ------------------------------------- */ /** @@ -121,29 +187,42 @@ typedef void (*fclaw3dx_clawpatch_pillow_fort_interpolate_block_corner_t)(int* double qfine[], int* icoarse_corner, int* blockno); - + /* ----------------------------- Use pillow sphere ------------------------------------ */ /** * @brief Sets global patch_vtable to use pollow sphere routines */ -void fclaw3dx_clawpatch_use_pillowsphere(struct fclaw2d_global* glob); +void fclaw_clawpatch_use_pillowsphere(struct fclaw_global* glob); /* --------------------------------- Virtual table ------------------------------------ */ /** - * @brief Initialize a global variable vtable + * @brief Initialize the pillow vtable for clawpatch * * @param glob the global context * @param claw_version the clawaptck verstion 4 for v4.6, 5 for v5 */ -void fclaw3dx_clawpatch_pillow_vtable_initialize(struct fclaw2d_global* glob, - int claw_version); +void fclaw_clawpatch_pillow_vtable_initialize(struct fclaw_global* glob, + int claw_version); /** * @brief vtable for handling block corners for pillow sphere */ -struct fclaw3dx_clawpatch_pillow_vtable +struct fclaw_clawpatch_pillow_vtable_d2 +{ + /* Block corners */ + /** Handles the boundary condition at block corners */ + pillow_fort_copy_block_corner_t fort_copy_block_corner; + /** Handles the boundary condition at block corners with finer neighbors */ + pillow_fort_average_block_corner_t fort_average_block_corner; + /** Handles the boundary condition at block corners with coarser neighbors */ + pillow_fort_interpolate_block_corner_t fort_interpolate_block_corner; +}; +/** + * @brief vtable for handling block corners for pillow sphere + */ +struct fclaw_clawpatch_pillow_vtable_d3 { /* Block corners */ /** Handles the boundary condition at block corners */ @@ -152,6 +231,13 @@ struct fclaw3dx_clawpatch_pillow_vtable fclaw3dx_clawpatch_pillow_fort_average_block_corner_t fort_average_block_corner; /** Handles the boundary condition at block corners with coarser neighbors */ fclaw3dx_clawpatch_pillow_fort_interpolate_block_corner_t fort_interpolate_block_corner; +}; + +struct fclaw_clawpatch_pillow_vtable +{ + int dim; + struct fclaw_clawpatch_pillow_vtable_d2* d2; + struct fclaw_clawpatch_pillow_vtable_d3* d3; /** True if vtable is set */ int is_set; @@ -161,15 +247,18 @@ struct fclaw3dx_clawpatch_pillow_vtable /* ------------------------------- Public access functions ---------------------------- */ /** - * @brief Get the global vtable variable + * @brief Get the pillow vtable * * @param glob the global context - * @return fclaw3dx_clawpatch_pillow_vtable_t* the vtable + * @return fclaw2d_clawpatch_pillow_vtable_t* the vtable */ -fclaw3dx_clawpatch_pillow_vtable_t* fclaw3dx_clawpatch_pillow_vt(struct fclaw2d_global* glob); +fclaw_clawpatch_pillow_vtable_t* fclaw_clawpatch_pillow_vt(struct fclaw_global* glob); #ifdef __cplusplus +#if 0 +{ +#endif } #endif diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_average.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_average.f90 new file mode 100644 index 000000000..d4ec39c1d --- /dev/null +++ b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_average.f90 @@ -0,0 +1,446 @@ +!!> \file +!!> \defgroup Averaging Average fine grids to a coarse grid +!!> Average cells from coarse grid to fine grid. +!!> +!!> Routines described here average are used to fill coarse grid ghost +!!> cells, and average sibling grids onto a parent grid. Indices +!!> for cells at block boundaries are transformed using encodings +!!> stored in `transform_cptr`. +!!> +!!> \param [in] mx,my Number of cells in x,y direction +!!> \param [in] mbc Number of ghost cells +!!> \param [in] meqn Number of equations +!!> \param [in] qcoarse,qfine Solution on coarse,fine grid +!!> \param [in] areacoarse,area Area of mesh cells on coarse,fine grids. +!!> \param [in] idir Face orientation - 0 for x-faces; 1 for y-faces [0-1] +!!> \param [in] iface Face number of fine grid [0-3]. +!!> \param [in] iface_coarse Face number of coarse grid [0-3]. +!!> \param [in] num_neighbors Number of fine grid neighbors [2]. +!!> \param [in] refratio Refinement ratio between coarse and fine grids [2]. +!!> \param [in] manifold Flag indicating whether we are on mapped grid [0-1]. +!!> \param [in] transform_cptr Encoding for indices at block boundaries (C only). + +!!> \ingroup Averaging +!!> Average fine ghost cell values. +!!> +!!> Average fine grid interior values to neighboring ghost cell values of +!!> the coarse grid. + +subroutine fclaw3d_clawpatch_face_ghost_bounds( & + iface,mx,my,mz,mbc, & + i_start, j_start, k_start, & + i_end, j_end, k_end) + implicit none + integer mx, my, mz, mbc, iface + integer i_start, j_start, k_start + integer i_end, j_end, k_end + integer axis + logical upper + + axis = iface/2 + upper= btest(iface,0) + + + if (axis .eq. 0) then + if (upper) then + i_start = mx+1 + i_end = mx+mbc + else + i_start = 1-mbc + i_end = 0 + endif + j_start = 1 + j_end = my + k_start = 1 + k_end = mz + else if(axis .eq. 1) then + i_start = 1 + i_end = mx + if (upper) then + j_start = my+1 + j_end = my+mbc + else + j_start = 1-mbc + j_end = 0 + endif + k_start = 1 + k_end = mz + else if(axis .eq. 2) then + i_start = 1 + i_end = mx + j_start = 1 + j_end = my + if (upper) then + k_start = mz+1 + k_end = mz+mbc + else + k_start = 1-mbc + k_end = 0 + endif + endif +end subroutine fclaw3d_clawpatch_face_ghost_bounds + + +SUBROUTINE fclaw3d_clawpatch46_fort_average_face(mx,my,mz,mbc,meqn, & + qcoarse,qfine,volcoarse, volfine, & + idir,iface_coarse,num_neighbors,refratio,igrid, & + manifold, transform_cptr) + USE fclaw3d_clawpatch_utils + IMPLICIT NONE + + INTEGER :: mx,my,mz,mbc,meqn,refratio,igrid,idir,iface_coarse + INTEGER :: manifold + INTEGER*8 :: transform_cptr + INTEGER :: num_neighbors + DOUBLE PRECISION :: qfine(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + DOUBLE PRECISION :: qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + !! # these will be empty if we are not on a manifold. + DOUBLE PRECISION :: volcoarse(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + DOUBLE PRECISION :: volfine(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + + INTEGER :: mq,r3, m + INTEGER :: ic, jc, kc + INTEGER :: i_start, i_end, j_start, j_end, k_start, k_end + + !! # For the extruded mesh, this is still only rr2 + INTEGER :: rr3 + PARAMETER(rr3 = 8) + INTEGER, DIMENSION(0:rr3-1) :: i2, j2, k2 + !! DOUBLE PRECISION :: kc + + LOGICAL :: skip_this_grid + DOUBLE PRECISION :: vf_sum + DOUBLE PRECISION :: sum, qf, kf + LOGICAL :: is_manifold + + + is_manifold = manifold .eq. 1 + + r3 = refratio**3 + if (r3 .ne. rr3) then + write(6,*) 'average_face_ghost (fclaw3d_clawpatch46_average.f90) ', & + ' Refratio**3 is not equal to rr3' + stop + endif + + !! # Average fine grid onto coarse grid + call fclaw3d_clawpatch_face_ghost_bounds( & + iface_coarse,mx,my,mz,mbc, & + i_start, j_start, k_start, & + i_end, j_end, k_end) + + meqn_loop : do mq = 1,meqn + k_loop : do kc = k_start,k_end + j_loop : do jc = j_start,j_end + i_loop : do ic = i_start,i_end + call fclaw3d_clawpatch_transform_face_half(ic,jc,kc,i2,j2,k2,transform_cptr) + !! # --------------------------------------------- + !! # Two 'half-size' neighbors will be passed into + !! # this routine. Only half of the coarse grid ghost + !! # indices will be valid for the particular grid + !! # passed in. We skip those ghost cells that will + !! # have to be filled in by the other half-size + !! # grid. + !! # --------------------------------------------- + skip_this_grid = .false. + do m = 0,r3-1 + if (.not. is_valid_average(i2(m),j2(m),k2(m),mx,my,mz)) then + skip_this_grid = .true. + exit + endif + end do + if (.not. skip_this_grid) then + if (is_manifold) then + sum = 0 + vf_sum = 0 + do m = 0,r3-1 + qf = qfine(i2(m),j2(m),k2(m),mq) + kf = volfine(i2(m),j2(m),k2(m)) + sum = sum + qf*kf + vf_sum = vf_sum + kf + end do + !! # Use vols of the fine grid mesh cells instead. + qcoarse(ic,jc,kc,mq) = sum/vf_sum + else + sum = 0 + do m = 0,r3-1 + sum = sum + qfine(i2(m),j2(m),k2(m),mq) + end do + qcoarse(ic,jc,kc,mq) = sum/dble(r3) + endif + endif + enddo i_loop + end do j_loop + end do k_loop + end do meqn_loop +end subroutine fclaw3d_clawpatch46_fort_average_face + +!!> \ingroup Averaging +!!> Average across edge. + +subroutine fclaw3d_clawpatch46_fort_average_edge(mx,my,mz,mbc,meqn, & + refratio,qcoarse,qfine,volcoarse,volfine, & + manifold,iedge_coarse,transform_cptr) + USE fclaw3d_clawpatch_utils + IMPLICIT NONE + + INTEGER :: mx,my,mz,mbc,meqn,refratio,iedge_coarse, manifold + INTEGER*8 :: transform_cptr + DOUBLE PRECISION :: qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + DOUBLE PRECISION :: qfine(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + !! # these will be empty if we are not on a manifold. + DOUBLE PRECISION :: volcoarse(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + DOUBLE PRECISION :: volfine(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + + INTEGER :: ibc,jbc,kbc,mq,r3 + LOGICAL :: is_manifold + DOUBLE PRECISION :: qf,kf, sum + + !! # This should be refratio*refratio. + INTEGER :: rr3 + PARAMETER(rr3 = 8) + INTEGER :: i2(0:rr3-1),j2(0:rr3-1),k2(0:rr3-1) + + INTEGER :: m + INTEGER :: i_start, j_start, k_start, i_end, j_end, k_end + DOUBLE PRECISION :: vf_sum + + LOGICAL :: skip_this_grid + + + r3 = refratio**3 + if (r3 .ne. rr3) then + write(6,*) 'average_corner_ghost (claw2d_utils.f) ', & + ' Refratio**3 is not equal to rr3' + stop + endif + + is_manifold = manifold .eq. 1 + + !! get lower-bottom-left corner of coarse ghost cells + call fclaw3d_clawpatch46_fort_get_edge_bounds(iedge_coarse, & + mx,my,mz,mbc, & + i_start,j_start,k_start, & + i_end, j_end, k_end) + + meqn_loop : do mq = 1,meqn + kbc_loop : do kbc = k_start,k_end + jbc_loop : do jbc = j_start,j_end + ibc_loop : do ibc = i_start,i_end + !! # Average fine grid corners onto coarse grid ghost corners + call fclaw3d_clawpatch_transform_edge_half(ibc,jbc,kbc,i2,j2,k2, transform_cptr) + skip_this_grid = .false. + do m = 0,r3-1 + if (.not. is_valid_average(i2(m),j2(m),k2(m),mx,my,mz)) then + skip_this_grid = .true. + exit + endif + end do + if (.not. skip_this_grid) then + if (is_manifold) then + sum = 0 + vf_sum = 0 + do m = 0,r3-1 + qf = qfine(i2(m),j2(m),k2(m),mq) + kf = volfine(i2(m),j2(m),k2(m)) + sum = sum + kf*qf + vf_sum = vf_sum + kf + enddo + qcoarse(ibc,jbc,kbc,mq) = sum/vf_sum + else + sum = 0 + do m = 0,r3-1 + qf = qfine(i2(m),j2(m),k2(m),mq) + sum = sum + qf + end do + qcoarse(ibc,jbc,kbc,mq) = sum/dble(r3) + endif + endif + enddo ibc_loop + enddo jbc_loop + enddo kbc_loop + end do meqn_loop + +end subroutine fclaw3d_clawpatch46_fort_average_edge + + + +!!> \ingroup Averaging +!!> Average across corners. + +subroutine fclaw3d_clawpatch46_fort_average_corner(mx,my,mz,mbc,meqn, & + refratio,qcoarse,qfine,volcoarse,volfine, & + manifold,icorner_coarse,transform_cptr) + IMPLICIT NONE + + INTEGER :: mx,my,mz,mbc,meqn,refratio,icorner_coarse, manifold + INTEGER*8 :: transform_cptr + DOUBLE PRECISION :: qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + DOUBLE PRECISION :: qfine(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + !! # these will be empty if we are not on a manifold. + DOUBLE PRECISION :: volcoarse(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + DOUBLE PRECISION :: volfine(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + + INTEGER :: ibc,jbc,kbc,mq,r3 + LOGICAL :: is_manifold + DOUBLE PRECISION :: qf,kf, sum + + !! # This should be refratio*refratio. + INTEGER :: rr3 + PARAMETER(rr3 = 8) + INTEGER :: i2(0:rr3-1),j2(0:rr3-1),k2(0:rr3-1) + + INTEGER :: m + INTEGER :: i_start, j_start, k_start + DOUBLE PRECISION :: vf_sum + + + r3 = refratio**3 + if (r3 .ne. rr3) then + write(6,*) 'average_corner_ghost (claw2d_utils.f) ', & + ' Refratio**3 is not equal to rr3' + stop + endif + + is_manifold = manifold .eq. 1 + + !! get lower-bottom-left corner of coarse ghost cells + call fclaw3d_clawpatch46_fort_get_corner_start(icorner_coarse, & + mx,my,mz,mbc, & + i_start,j_start,k_start) + + meqn_loop : do mq = 1,meqn + kbc_loop : do kbc = k_start,k_start+mbc-1 + jbc_loop : do jbc = j_start,j_start+mbc-1 + ibc_loop : do ibc = i_start,i_start+mbc-1 + !! # Average fine grid corners onto coarse grid ghost corners + call fclaw3d_clawpatch_transform_corner_half(ibc,jbc,kbc,i2,j2,k2, transform_cptr) + if (is_manifold) then + sum = 0 + vf_sum = 0 + do m = 0,r3-1 + qf = qfine(i2(m),j2(m),k2(m),mq) + kf = volfine(i2(m),j2(m),k2(m)) + sum = sum + kf*qf + vf_sum = vf_sum + kf + enddo + qcoarse(ibc,jbc,kbc,mq) = sum/vf_sum + else + sum = 0 + do m = 0,r3-1 + qf = qfine(i2(m),j2(m),k2(m),mq) + sum = sum + qf + end do + qcoarse(ibc,jbc,kbc,mq) = sum/dble(r3) + endif + enddo ibc_loop + enddo jbc_loop + enddo kbc_loop + end do meqn_loop + +end subroutine fclaw3d_clawpatch46_fort_average_corner + + +!!> \ingroup Averaging +!!> Average fine grid siblings to parent coarse grid. +subroutine fclaw3d_clawpatch46_fort_average2coarse(mx,my,mz,mbc,meqn, & + qcoarse,qfine,volcoarse,volfine, igrid,manifold) + IMPLICIT NONE + + INTEGER :: mx,my,mz,mbc,meqn + INTEGER :: manifold + DOUBLE PRECISION :: qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + DOUBLE PRECISION :: qfine(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + !! # these will be empty if we are not on a manifold, and so shouldn't + !! # be referenced. + DOUBLE PRECISION :: volcoarse(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + DOUBLE PRECISION :: volfine(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + + !! # This should be refratio**3 + INTEGER :: rr3 + PARAMETER(rr3 = 8) + INTEGER :: ifine(0:rr3-1),jfine(0:rr3-1),kfine(0:rr3-1) + + + INTEGER :: i,j,k,mq, ii,jj,kk, ic, jc, kc, r3, m + INTEGER :: ig, jg, kg, ic_add, jc_add, kc_add + INTEGER :: refratio, igrid + LOGICAL :: is_manifold + DOUBLE PRECISION :: sum, kf, qf, vf_sum + + refratio = 2 + + is_manifold = manifold .eq. 1 + + !! # 'iface' is relative to the coarse grid + + r3 = refratio**3 + if (r3 .ne. rr3) then + write(6,*) 'average_face_ghost (claw2d_utils.f) ', & + ' Refratio**2 is not equal to rr2' + stop + endif + + + !! Get (ig,jg,kg) for grid from linear (igrid) coordinates + !! igrid = ig + refratio*jg + refratio*refratio*kg + ig = mod(igrid,refratio) + jg = mod((igrid-ig)/refratio,refratio) + kg = (igrid-ig-refratio*jg)/(refratio**2) + + !! Get rectangle in coarse grid for fine grid. + ic_add = ig*mx/refratio + jc_add = jg*my/refratio + kc_add = kg*mz/refratio + + r3 = refratio**3 + !! this assumes mz,my,mz are divisible by refratio + !! should probably add a check to clawpatch_options + meqn_loop : do mq = 1,meqn + k_loop : do k = 1,mz/refratio + j_loop : do j = 1,my/refratio + i_loop : do i = 1,mx/refratio + ic = i+ic_add + jc = j+jc_add + kc = k+kc_add + m = 0 + do kk = 1,refratio + do jj = 1,refratio + do ii = 1,refratio + ifine(m) = (i-1)*refratio + ii + jfine(m) = (j-1)*refratio + jj + kfine(m) = (k-1)*refratio + kk + m = m + 1 + enddo + enddo + enddo + if (is_manifold) then + sum = 0 + vf_sum = 0 + do m = 0,r3-1 + qf = qfine(ifine(m),jfine(m),kfine(m),mq) + kf = volfine(ifine(m),jfine(m),kfine(m)) + sum = sum + kf*qf + vf_sum = vf_sum + kf + enddo + !!vc = volcoarse(ic,jc,kc) + qcoarse(ic,jc,kc,mq) = sum/vf_sum + else + sum = 0 + do m = 0,r3-1 + qf = qfine(ifine(m),jfine(m),kfine(m),mq) + sum = sum + qf + enddo + qcoarse(ic,jc,kc,mq) = sum/r3 + endif + end do i_loop + enddo j_loop + enddo k_loop + enddo meqn_loop +end subroutine fclaw3d_clawpatch46_fort_average2coarse + + diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_copy.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_copy.f90 new file mode 100644 index 000000000..37c8cc113 --- /dev/null +++ b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_copy.f90 @@ -0,0 +1,286 @@ +!! # ---------------------------------------------------------- +!! # Exchange routines - (i,j,mq) ordering +!! # ---------------------------------------------------------- +!! # exchange_face_ghost +!! # exchange_corner_ghost +!! # exchange_phys_corner_ghost +!! # ---------------------------------------------------------- + + +!! # Exchange edge ghost data with neighboring grid at same level. + +subroutine fclaw3d_clawpatch46_fort_copy_face(mx,my,mz,mbc, & + meqn,qthis, qneighbor, iface, transform_ptr) + + implicit none + + integer mx,my,mz,mbc,meqn,iface + integer*8 transform_ptr + double precision qthis(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision qneighbor(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + integer mq, k + integer i,j + + integer a(2,2), f(2) + + !!call fclaw3d_clawpatch_build_transform_same(transform_ptr, a, f) + + if (iface .eq. 0) then + do mq = 1,meqn + do k = 1,mz + do j = 1,my + do i = 1-mbc,0 + ! Lower side + qthis(i,j,k,mq) = qneighbor(i+mx,j,k,mq); + enddo + enddo + enddo + enddo + else if (iface .eq. 1) then + do mq = 1,meqn + do k = 1,mz + do j = 1,my + do i = mx+1,mx+mbc + ! Upper side + qthis(i,j,k,mq) = qneighbor(i-mx,j,k,mq); + enddo + enddo + enddo + enddo + else if (iface .eq. 2) then + do mq = 1,meqn + do k = 1,mz + do j = 1-mbc,0 + do i = 1,mx + ! left side + qthis(i,j,k,mq) = qneighbor(i,j+my,k,mq); + enddo + enddo + enddo + enddo + else if (iface .eq. 3) then + do mq = 1,meqn + do k = 1,mz + do j = my+1,my+mbc + do i = 1,mx + ! right side + qthis(i,j,k,mq) = qneighbor(i,j-my,k,mq); + enddo + enddo + enddo + enddo + else if (iface .eq. 4) then + do mq = 1,meqn + do k = 1-mbc,0 + do j = 1,my + do i = 1,mx + ! bottom + qthis(i,j,k,mq) = qneighbor(i,j,k+mz,mq); + enddo + enddo + enddo + enddo + else if (iface .eq. 5) then + do mq = 1,meqn + do k = mz+1,mz+mbc + do j = 1,my + do i = 1,mx + ! top + qthis(i,j,k,mq) = qneighbor(i,j,k-mz,mq); + enddo + enddo + enddo + enddo + endif + + + +end subroutine fclaw3d_clawpatch46_fort_copy_face + +subroutine fclaw3d_clawpatch46_fort_get_edge_bounds( & + iedge,mx,my,mz,mbc, & + i_start, j_start, k_start, & + i_end, j_end, k_end) + implicit none + integer mx, my, mz, mbc, iedge + integer i_start, j_start, k_start + integer i_end, j_end, k_end + integer axis + logical upper_1, upper_2 + + axis = iedge/4; + upper_1 = btest(iedge,0); + upper_2 = btest(iedge,1); + + + if (axis .eq. 0) then + i_start = 1; + i_end = mx; + if(upper_1) then + j_start = my+1; + j_end = my+mbc; + else + j_start = 1-mbc; + j_end = 0; + endif + if(upper_2) then + k_start = mz+1; + k_end = mz+mbc; + else + k_start = 1-mbc; + k_end = 0; + endif + else if(axis .eq. 1) then + j_start = 1; + j_end = my; + if(upper_1) then + i_start = mx+1; + i_end = mx+mbc; + else + i_start = 1-mbc; + i_end = 0; + endif + if(upper_2) then + k_start = mz+1; + k_end = mz+mbc; + else + k_start = 1-mbc; + k_end = 0; + endif + else if(axis .eq. 2) then + k_start = 1; + k_end = mz; + if(upper_1) then + i_start = mx+1; + i_end = mx+mbc; + else + i_start = 1-mbc; + i_end = 0; + endif + if(upper_2) then + j_start = my+1; + j_end = my+mbc; + else + j_start = 1-mbc; + j_end = 0; + endif + endif +end subroutine fclaw3d_clawpatch46_fort_get_edge_bounds + +subroutine fclaw3d_clawpatch46_fort_copy_edge(mx,my,mz,mbc,meqn, & + qthis, qneighbor, this_iedge,transform_ptr) + implicit none + + integer mx, my, mz, mbc, meqn, this_iedge + integer*8 transform_ptr + double precision qthis(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision qneighbor(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + integer mq + integer i_start, j_start, k_start + integer i_end, j_end, k_end + integer i1,i2, j1,j2, k1,k2 + call fclaw3d_clawpatch46_fort_get_edge_bounds(this_iedge, & + mx,my,mz,mbc, & + i_start,j_start,k_start, & + i_end, j_end, k_end) + + !! # Do exchanges for edge + mq_loop : do mq = 1,meqn + do k1 = k_start,k_end + do j1 = j_start,j_end + do i1 = i_start,i_end + call fclaw3d_clawpatch_transform_edge(i1,j1,k1,i2,j2,k2, transform_ptr) + qthis(i1,j1,k1,mq) = qneighbor(i2,j2,k2,mq) + end do + end do + end do + end do mq_loop + +end subroutine fclaw3d_clawpatch46_fort_copy_edge + +subroutine fclaw3d_clawpatch46_fort_get_corner_start( & + icorner,mx,my,mz,mbc, & + i1, j1, k1) + implicit none + integer mx, my, mz, mbc, icorner + integer i1, j1, k1 + + if (btest(icorner,0)) then + i1 = mx+1 + else + i1 = 1-mbc + endif + + if (btest(icorner,1)) then + j1 = my+1 + else + j1 = 1-mbc + endif + + if (btest(icorner,2)) then + k1 = mz+1 + else + k1 = 1-mbc + endif + +end subroutine fclaw3d_clawpatch46_fort_get_corner_start + + +subroutine fclaw3d_clawpatch46_fort_get_corner_start_coarse_to_fine( & + icorner,refratio,mx,my,mz,mbc, & + i1, j1, k1) + implicit none + integer mx, my, mz, mbc, icorner,refratio + integer i1, j1, k1 + + if (btest(icorner,0)) then + i1 = mx+1-mbc/refratio + else + i1 = 1 + endif + + if (btest(icorner,1)) then + j1 = my+1-mbc/refratio + else + j1 = 1 + endif + + if (btest(icorner,2)) then + k1 = mz+1-mbc/refratio + else + k1 = 1 + endif + +end subroutine fclaw3d_clawpatch46_fort_get_corner_start_coarse_to_fine + +subroutine fclaw3d_clawpatch46_fort_copy_corner(mx,my,mz,mbc,meqn, & + qthis, qneighbor, this_icorner,transform_ptr) + implicit none + + integer mx, my, mz, mbc, meqn, this_icorner + integer*8 transform_ptr + double precision qthis(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision qneighbor(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + integer mq + integer i_start, j_start, k_start + integer i1,i2, j1,j2, k1,k2 + call fclaw3d_clawpatch46_fort_get_corner_start(this_icorner, & + mx,my,mz,mbc, & + i_start,j_start,k_start) + + !! # Do exchanges for all corners + mq_loop : do mq = 1,meqn + do k1 = k_start,k_start+mbc-1 + do j1 = j_start,j_start+mbc-1 + do i1 = i_start,i_start+mbc-1 + call fclaw3d_clawpatch_transform_corner(i1,j1,k1,i2,j2,k2, transform_ptr) + qthis(i1,j1,k1,mq) = qneighbor(i2,j2,k2,mq) + end do + end do + end do + end do mq_loop + +end subroutine fclaw3d_clawpatch46_fort_copy_corner diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_diagnostics.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_diagnostics.f90 similarity index 84% rename from src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_diagnostics.f90 rename to src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_diagnostics.f90 index a28613ed1..ee8a08115 100644 --- a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_diagnostics.f90 +++ b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_diagnostics.f90 @@ -1,7 +1,7 @@ !! # ---------------------------------------------------------------------------------- !! # Output and diagnostics !! # ---------------------------------------------------------------------------------- -subroutine fclaw3dx_clawpatch46_fort_conservation_check(mx,my,mz, & +subroutine fclaw3d_clawpatch46_fort_conservation_check(mx,my,mz, & mbc,mfields,dx,dy,dz,area,q,sum,c_kahan) implicit none @@ -14,7 +14,7 @@ subroutine fclaw3dx_clawpatch46_fort_conservation_check(mx,my,mz, & integer :: i,j,k,m double precision :: t, y, area_ij, vol_ij integer*8 :: cont, fclaw_map_get_context - logical :: fclaw2d_map_is_used + logical :: fclaw_map_is_used logical :: use_kahan @@ -27,7 +27,7 @@ subroutine fclaw3dx_clawpatch46_fort_conservation_check(mx,my,mz, & do k = 1,mz do j = 1,my do i = 1,mx - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then area_ij = area(i,j) !! Area varies endif vol_ij = area_ij*dz @@ -43,10 +43,10 @@ subroutine fclaw3dx_clawpatch46_fort_conservation_check(mx,my,mz, & enddo end do end do -end subroutine fclaw3dx_clawpatch46_fort_conservation_check +end subroutine fclaw3d_clawpatch46_fort_conservation_check !! # Compute area of a patch -double precision function fclaw3dx_clawpatch46_fort_compute_patch_area( & +double precision function fclaw3d_clawpatch46_fort_compute_patch_area( & mx,my, mz, mbc,dx,dy,dz, area) implicit none @@ -56,12 +56,12 @@ double precision function fclaw3dx_clawpatch46_fort_compute_patch_area( & integer :: i,j integer*8 :: cont, fclaw_map_get_context - logical :: fclaw2d_map_is_used + logical :: fclaw_map_is_used double precision :: sum cont = fclaw_map_get_context() - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then sum = 0 do j = 1,my do i = 1,mx @@ -72,12 +72,12 @@ double precision function fclaw3dx_clawpatch46_fort_compute_patch_area( & sum = dx*dy*mx*my endif - fclaw3dx_clawpatch46_fort_compute_patch_area = sum + fclaw3d_clawpatch46_fort_compute_patch_area = sum -end function fclaw3dx_clawpatch46_fort_compute_patch_area +end function fclaw3d_clawpatch46_fort_compute_patch_area -subroutine fclaw3dx_clawpatch46_fort_compute_error_norm( & +subroutine fclaw3d_clawpatch46_fort_compute_error_norm( & blockno, mx,my,mz,mbc,mfields,dx,dy,dz,area,error,error_norm) implicit none @@ -91,14 +91,14 @@ subroutine fclaw3dx_clawpatch46_fort_compute_error_norm( & double precision :: dxdydz, eij, vol_ij integer*8 :: cont, fclaw_map_get_context - logical :: fclaw2d_map_is_used + logical :: fclaw_map_is_used cont = fclaw_map_get_context() !! # error_norm(:) comes in with values; do not initialize it here! dxdydz = dx*dy*dz do m = 1,mfields - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do k = 1,mz do j = 1,my do i = 1,mx @@ -128,4 +128,4 @@ subroutine fclaw3dx_clawpatch46_fort_compute_error_norm( & endif end do -end subroutine fclaw3dx_clawpatch46_fort_compute_error_norm +end subroutine fclaw3d_clawpatch46_fort_compute_error_norm diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_interpolate.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_interpolate.f90 new file mode 100644 index 000000000..0d1c33fdf --- /dev/null +++ b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_interpolate.f90 @@ -0,0 +1,552 @@ +!! # ---------------------------------------------------------- +!! # Interpolation routines - (i,j,mq) ordering +!! # ---------------------------------------------------------- +!! # interpolate_face_ghost +!! # interpolate_corner_ghost +!! # interpolate_to_fine_patch +!! # +!! # Other routines : +!! # fclaw2d_clawpatch_compute_slopes +!! # (for limited function reconstruction) +!! # fixcapaq (to preserve conservation) +!! # +!! # Note that fixcapaq is only used when regridding; ghost +!! # cell interpolation is not conservative in the mapped case. +!! # (Should it be? We are going to correct the flux mixmatch +!! # anyhow, so maybe the accuracy of the ghost cell values is +!! # more important.) +!! # ---------------------------------------------------------- + + + +!! # ---------------------------------------------------------- +!! # This routine is used for both mapped and non-mapped +!! # cases. +!! # ---------------------------------------------------------- +subroutine fclaw3d_clawpatch46_fort_interpolate_face & + (mx,my,mz,mbc,meqn,qcoarse,qfine, & + idir,iface_coarse,num_neighbors,refratio,igrid, & + transform_ptr) + use fclaw3d_clawpatch_utils + + implicit none + integer :: mx,my,mz,mbc,meqn,refratio,igrid,idir,iface_coarse + integer :: num_neighbors + integer*8 :: transform_ptr + double precision :: qfine(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + integer :: mq,r3, m + integer :: ic, jc, kc, mth + integer :: i_start, j_start, k_start, i_end, j_end, k_end + double precision :: gradx, grady, gradz, qc, sl, sr, value + double precision :: fclaw2d_clawpatch_compute_slopes + + !! # This should be refratio*refratio. + integer :: rr3 + parameter(rr3 = 8) + integer :: i2(0:rr3-1),j2(0:rr3-1),k2(0:rr3-1) + logical :: fclaw3d_clawpatch_is_valid_interp + logical :: skip_this_grid + + integer :: a(3,3), f(3) + integer :: ii,jj,kk,dc(3),df(3,0:rr3-1),iff,jff,kff + double precision :: shiftx(0:rr3-1),shifty(0:rr3-1),shiftz(0:rr3-1) + + mth = 5 + r3 = refratio**3 + if (r3 .ne. rr3) then + write(6,*) 'average_face_ghost (claw2d_utils.f) ', & + ' Refratio**2 is not equal to rr2' + stop + endif + + call build_transform(transform_ptr,a,f) + + !! # This needs to be written for refratios .ne. 2. + m = 0 + do kk = 0,1 + do jj = 0,1 + do ii = 0,1 + !! # Direction on coarse grid + dc(1) = ii + dc(2) = jj + dc(3) = kk + + !! # Direction on fine grid (converted using metric). Divide + !! # by refratio to scale length to unit vector + df(1,m) = (a(1,1)*dc(1) + a(1,2)*dc(2) + a(1,3)*dc(3))/refratio + df(2,m) = (a(2,1)*dc(1) + a(2,2)*dc(2) + a(2,3)*dc(3))/refratio + df(3,m) = (a(3,1)*dc(1) + a(3,2)*dc(2) + a(3,3)*dc(3))/refratio + + !! # Map (0,1) to (-1/4,1/4) (locations of fine grid points) + shiftx(m) = (ii-0.5d0)/2.d0 + shifty(m) = (jj-0.5d0)/2.d0 + shiftz(m) = (kk-0.5d0)/2.d0 + m = m + 1 + enddo + enddo + enddo + !! # Create map : + + !! loop over coarse iface interior + call interior_face_bounds( & + iface_coarse,refratio,mx,my,mz,mbc, & + i_start, j_start, k_start, & + i_end, j_end, k_end) + + mq_loop : do mq = 1,meqn + k_loop : do kc = k_start,k_end + j_loop : do jc = j_start,j_end + i_loop : do ic = i_start,i_end + call fclaw3d_clawpatch_transform_face_half(ic,jc,kc,i2,j2,k2,transform_ptr) + skip_this_grid = .false. + do m = 0,r3-1 + if (.not. is_valid_interp(i2(m),j2(m),k2(m),mx,my,mz,mbc)) then + skip_this_grid = .true. + exit + endif + enddo + if (.not. skip_this_grid) then + qc = qcoarse(ic,jc,kc, mq) + !! # Compute limited slopes in both x and y. Note we are not + !! # really computing slopes, but rather just differences. + !! # Scaling is accounted for in 'shiftx' and 'shifty', below. + sl = (qc - qcoarse(ic-1,jc,kc,mq)) + sr = (qcoarse(ic+1,jc,kc,mq) - qc) + gradx = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + sl = (qc - qcoarse(ic,jc-1,kc,mq)) + sr = (qcoarse(ic,jc+1,kc,mq) - qc) + grady = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + sl = (qc - qcoarse(ic,jc,kc-1,mq)) + sr = (qcoarse(ic,jc,kc+1,mq) - qc) + gradz = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + do m = 0,rr3-1 + iff = i2(0) + df(1,m) + jff = j2(0) + df(2,m) + kff = k2(0) + df(3,m) + value = qc + gradx*shiftx(m) + grady*shifty(m) + gradz*shiftz(m) + qfine(iff,jff,kff,mq) = value + enddo + endif + enddo i_loop + enddo j_loop + enddo k_loop + enddo mq_loop + +end subroutine fclaw3d_clawpatch46_fort_interpolate_face + +subroutine fclaw3d_clawpatch46_fort_interpolate_edge & + (mx,my,mz, mbc,meqn,refratio, & + qcoarse,qfine,iedge_coarse,transform_ptr) + use fclaw3d_clawpatch_utils + implicit none + + integer mx,my,mz,mbc,meqn,iedge_coarse,refratio + integer*8 transform_ptr + double precision qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision qfine(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + integer mq, ic,jc,kc, mth + double precision qc, sl, sr, gradx, grady, gradz + double precision fclaw2d_clawpatch_compute_slopes, value + integer i_start, j_start, k_start, i_end, j_end, k_end + + !! # This should be refratio*refratio. + integer m, r3 + integer rr3 + parameter(rr3 = 8) + integer i2(0:rr3-1),j2(0:rr3-1),k2(0:rr3-1) + + integer a(3,3), f(3) + integer ii,jj,kk,iff,jff,kff,dc(3),df(3,0:rr3-1) + double precision shiftx(0:rr3-1), shifty(0:rr3-1), shiftz(0:rr3-1) + + logical skip_this_grid + + r3 = refratio**3 + if (r3 .ne. rr3) then + write(6,*) 'average_corner_ghost (claw2d_utils.f) ', & + ' Refratio**3 is not equal to rr3' + stop + endif + + call build_transform(transform_ptr,a,f) + + m = 0 + do kk = 0,1 + do jj = 0,1 + do ii = 0,1 + !! # Direction on coarse grid + dc(1) = ii + dc(2) = jj + dc(3) = kk + + !! # Direction on fine grid (converted using metric). Divide + !! # by 2 (refratio) to scale length to unit vector + df(1,m) = (a(1,1)*dc(1) + a(1,2)*dc(2) + a(1,3)*dc(3))/2 + df(2,m) = (a(2,1)*dc(1) + a(2,2)*dc(2) + a(2,3)*dc(3))/2 + df(3,m) = (a(3,1)*dc(1) + a(3,2)*dc(2) + a(3,3)*dc(3))/2 + + !! # Map (0,1) to (-1/4,1/4) (locations of fine grid points) + shiftx(m) = (ii-0.5d0)/2.d0 + shifty(m) = (jj-0.5d0)/2.d0 + shiftz(m) = (kk-0.5d0)/2.d0 + m = m + 1 + enddo + enddo + enddo + + + mth = 5 + + !! get lower-bottom-left corner of coarse ghost cells that + !! we are interpolating from + call interior_edge_bounds( & + iedge_coarse,refratio, & + mx,my,mz,mbc, & + i_start,j_start,k_start, & + i_end,j_end,k_end) + + mq_loop : do mq = 1,meqn + kc_loop : do kc = k_start,k_end + jc_loop : do jc = j_start,j_end + ic_loop : do ic = i_start,i_end + !! # Interpolate coarse grid corners to fine grid corner ghost cells + call fclaw3d_clawpatch_transform_edge_half(ic,jc,kc,i2,j2,k2, transform_ptr) + skip_this_grid = .false. + do m = 0,r3-1 + if (.not. is_valid_interp(i2(m),j2(m),k2(m),mx,my,mz,mbc)) then + skip_this_grid = .true. + exit + endif + enddo + if(.not. skip_this_grid) then + + qc = qcoarse(ic,jc,kc,mq) + + !! # Compute limited slopes in both x and y. Note we are not + !! # really computing slopes, but rather just differences. + !! # Scaling is accounted for in 'shiftx' and 'shifty', below. + sl = (qc - qcoarse(ic-1,jc,kc,mq)) + sr = (qcoarse(ic+1,jc,kc,mq) - qc) + gradx = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + sl = (qc - qcoarse(ic,jc-1,kc,mq)) + sr = (qcoarse(ic,jc+1,kc,mq) - qc) + grady = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + sl = (qc - qcoarse(ic,jc,kc-1,mq)) + sr = (qcoarse(ic,jc,kc+1,mq) - qc) + gradz = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + do m = 0,rr3-1 + iff = i2(0) + df(1,m) + jff = j2(0) + df(2,m) + kff = k2(0) + df(3,m) + value = qc + gradx*shiftx(m) + grady*shifty(m) + gradz*shiftz(m) + qfine(iff,jff,kff,mq) = value + end do + + endif + end do ic_loop + end do jc_loop + end do kc_loop + end do mq_loop + +end subroutine fclaw3d_clawpatch46_fort_interpolate_edge + + +subroutine fclaw3d_clawpatch46_fort_interpolate_corner & + (mx,my,mz, mbc,meqn,refratio, & + qcoarse,qfine,icorner_coarse,transform_ptr) + use fclaw3d_clawpatch_utils + implicit none + + integer mx,my,mz,mbc,meqn,icorner_coarse,refratio + integer*8 transform_ptr + double precision qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision qfine(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + integer mq, ic,jc,kc, mth + double precision qc, sl, sr, gradx, grady, gradz + double precision fclaw2d_clawpatch_compute_slopes, value + integer i_start, j_start, k_start + + !! # This should be refratio*refratio. + integer m, r3 + integer rr3 + parameter(rr3 = 8) + integer i2(0:rr3-1),j2(0:rr3-1),k2(0:rr3-1) + + integer a(3,3), f(3) + integer ii,jj,kk,iff,jff,kff,dc(3),df(3,0:rr3-1) + double precision shiftx(0:rr3-1), shifty(0:rr3-1), shiftz(0:rr3-1) + + r3 = refratio**3 + if (r3 .ne. rr3) then + write(6,*) 'average_corner_ghost (claw2d_utils.f) ', & + ' Refratio**3 is not equal to rr3' + stop + endif + + call build_transform(transform_ptr,a,f) + + m = 0 + do kk = 0,1 + do jj = 0,1 + do ii = 0,1 + !! # Direction on coarse grid + dc(1) = ii + dc(2) = jj + dc(3) = kk + + !! # Direction on fine grid (converted using metric). Divide + !! # by 2 (refratio) to scale length to unit vector + df(1,m) = (a(1,1)*dc(1) + a(1,2)*dc(2) + a(1,3)*dc(3))/2 + df(2,m) = (a(2,1)*dc(1) + a(2,2)*dc(2) + a(2,3)*dc(3))/2 + df(3,m) = (a(3,1)*dc(1) + a(3,2)*dc(2) + a(3,3)*dc(3))/2 + + !! # Map (0,1) to (-1/4,1/4) (locations of fine grid points) + shiftx(m) = (ii-0.5d0)/2.d0 + shifty(m) = (jj-0.5d0)/2.d0 + shiftz(m) = (kk-0.5d0)/2.d0 + m = m + 1 + enddo + enddo + enddo + + + mth = 5 + + !! get lower-bottom-left corner of coarse ghost cells that + !! we are interpolating from + call fclaw3d_clawpatch46_fort_get_corner_start_coarse_to_fine( & + icorner_coarse,refratio, & + mx,my,mz,mbc, & + i_start,j_start,k_start) + + mq_loop : do mq = 1,meqn + kc_loop : do kc = k_start,k_start+mbc/2-1 + jc_loop : do jc = j_start,j_start+mbc/2-1 + ic_loop : do ic = i_start,i_start+mbc/2-1 + !! # Interpolate coarse grid corners to fine grid corner ghost cells + call fclaw3d_clawpatch_transform_corner_half(ic,jc,kc,i2,j2,k2, transform_ptr) + + qc = qcoarse(ic,jc,kc,mq) + + !! # Compute limited slopes in both x and y. Note we are not + !! # really computing slopes, but rather just differences. + !! # Scaling is accounted for in 'shiftx' and 'shifty', below. + sl = (qc - qcoarse(ic-1,jc,kc,mq)) + sr = (qcoarse(ic+1,jc,kc,mq) - qc) + gradx = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + sl = (qc - qcoarse(ic,jc-1,kc,mq)) + sr = (qcoarse(ic,jc+1,kc,mq) - qc) + grady = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + sl = (qc - qcoarse(ic,jc,kc-1,mq)) + sr = (qcoarse(ic,jc,kc+1,mq) - qc) + gradz = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + do m = 0,rr3-1 + iff = i2(0) + df(1,m) + jff = j2(0) + df(2,m) + kff = k2(0) + df(3,m) + value = qc + gradx*shiftx(m) + grady*shifty(m) + gradz*shiftz(m) + qfine(iff,jff,kff,mq) = value + end do + end do ic_loop + end do jc_loop + end do kc_loop + end do mq_loop + +end subroutine fclaw3d_clawpatch46_fort_interpolate_corner + + +!! # Conservative intepolation to fine grid patch +subroutine fclaw3d_clawpatch46_fort_interpolate2fine & + (mx,my,mz,mbc,meqn,qcoarse, qfine, volcoarse, & + volfine, igrid, manifold) + implicit none + + integer :: mx,my,mz,mbc,meqn + integer :: igrid, manifold + + double precision :: qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: qfine(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + double precision :: volcoarse(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + double precision :: volfine(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + + integer :: ii, jj, kk, i,j,k, i1, i2, j1, j2, k1, k2, ig, jg, kg, mq, mth + integer :: ic,jc,kc,ic_add, jc_add, kc_add, ifine, jfine, kfine + integer :: i_start_fine, j_start_fine, k_start_fine + double precision :: qc, shiftx, shifty, shiftz, sl, sr, gradx, grady, gradz + double precision :: fclaw2d_clawpatch_compute_slopes + + logical :: lower_x, lower_y, lower_z + + integer :: p8est_refineFactor,refratio + + p8est_refineFactor = 2 + refratio = 2 + + !! # Use limiting done in AMRClaw. + mth = 5 + + !! Get (ig,jg,kg) for grid from linear (igrid) coordinates + !! igrid = ig + refratio*jg + refratio*refratio*kg + ig = mod(igrid,refratio) + jg = mod((igrid-ig)/refratio,refratio) + kg = (igrid-ig-refratio*jg)/(refratio**2) + + i1 = 1-ig + i2 = mx/p8est_refineFactor + (1-ig) + ic_add = ig*mx/p8est_refineFactor + + j1 = 1-jg + j2 = my/p8est_refineFactor + (1-jg) + jc_add = jg*my/p8est_refineFactor + + k1 = 1-kg + k2 = mz/p8est_refineFactor + (1-kg) + kc_add = kg*mz/p8est_refineFactor + + !!iterate of part of coarse patch that we are intepolating from + mq_loop : do mq = 1,meqn + k_loop : do k = k1,k2 + do j = j1,j2 + do i = i1,i2 + ic = i + ic_add + jc = j + jc_add + kc = k + kc_add + qc = qcoarse(ic,jc,kc,mq) + + !! # Compute limited slopes in both x and y. Note we are not + !! # really computing slopes, but rather just differences. + !! # Scaling is accounted for in 'shiftx' and 'shifty', below. + sl = (qc - qcoarse(ic-1,jc,kc,mq)) + sr = (qcoarse(ic+1,jc,kc,mq) - qc) + gradx = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + sl = (qc - qcoarse(ic,jc-1,kc,mq)) + sr = (qcoarse(ic,jc+1,kc,mq) - qc) + grady = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + sl = (qc - qcoarse(ic,jc,kc-1,mq)) + sr = (qcoarse(ic,jc,kc+1,mq) - qc) + gradz = fclaw2d_clawpatch_compute_slopes(sl,sr,mth) + + !! # Fill in refined values on coarse grid cell (ic,jc,kc) + do kk = 1,refratio + do jj = 1,refratio + do ii = 1,refratio + shiftx = (ii - refratio/2.d0 - 0.5d0)/refratio + shifty = (jj - refratio/2.d0 - 0.5d0)/refratio + shiftz = (kk - refratio/2.d0 - 0.5d0)/refratio + ifine = (i-1)*refratio + ii + jfine = (j-1)*refratio + jj + kfine = (k-1)*refratio + kk + qfine(ifine,jfine,kfine,mq) = qc + shiftx*gradx + shifty*grady + shiftz*gradz + end do + end do + end do + end do !! i_loop + end do !! j_loop + end do k_loop + end do mq_loop + + if (manifold .ne. 0) then + !!write(6,*) 'interpolate:fixcapaq2 : Manifold not yet implemented in 3D' + !!stop + call fclaw3d_clawpatch46_fort_fixcapaq2(mx,my,mz,mbc,meqn, & + qcoarse,qfine, volcoarse,volfine,igrid) + endif + + +end subroutine fclaw3d_clawpatch46_fort_interpolate2fine + + + !! # ------------------------------------------------------ + !! # So far, this is only used by the interpolation from + !! # coarse to fine when regridding. But maybe it should + !! # be used by the ghost cell routines as well? + !! # ------------------------------------------------------ +subroutine fclaw3d_clawpatch46_fort_fixcapaq2(mx,my,mz,mbc,meqn, & + qcoarse,qfine, volcoarse,volfine,igrid) + implicit none + + integer :: mx,my,mz,mbc,meqn, refratio, igrid + integer :: p4est_refineFactor + + double precision :: qcoarse(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: qfine(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: volcoarse(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + double precision :: volfine(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc+1) + + integer :: i,j,k,ii, jj, ifine, jfine, m, ig, jg, ic_add, jc_add + double precision :: kf, kc, r2, sum, cons_diff, qf, qc, volf, dz, volc + + p4est_refineFactor = 2 + refratio = 2 + + !! This is a bogus value, since we shouldn't end up here (yet). + dz = 1 + + !! # Get (ig,jg) for grid from linear (igrid) coordinates + ig = mod(igrid,refratio) + jg = (igrid-ig)/refratio + + !! # Get rectangle in coarse grid for fine grid. + ic_add = ig*mx/p4est_refineFactor + jc_add = jg*my/p4est_refineFactor + + !! # ------------------------------------------------------ + !! # This routine ensures that the interpolated solution + !! # has the same mass as the coarse grid solution + !! # ------------------------------------------------------- + + r2 = refratio*refratio + mq_loop : do m = 1,meqn + k_loop : do k = 1,mz + do i = 1,mx/p4est_refineFactor + do j = 1,my/p4est_refineFactor + sum = 0.d0 + do ii = 1,refratio + do jj = 1,refratio + ifine = (i-1)*refratio + ii + jfine = (j-1)*refratio + jj + kf = volfine(ifine,jfine,k) + volf = kf*dz + qf = qfine(ifine,jfine,k,m) + sum = sum + volf*qf + enddo + enddo + + kc = volcoarse(i+ic_add,j+jc_add,k) + volc = kc*dz + qc = qcoarse(i+ic_add, j+jc_add,k,m) + cons_diff = (qc*volc - sum)/r2 + + do ii = 1,refratio + do jj = 1,refratio + ifine = (i-1)*refratio + ii + jfine = (j-1)*refratio + jj + kf = volfine(ifine,jfine,k) + volf = kf*dz + qfine(ifine,jfine,k,m) = qfine(ifine,jfine,k,m) + cons_diff/volf + end do + end do + end do !! j loop + enddo !! i loop + enddo k_loop + enddo mq_loop + +end + + diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_local_ghost_pack.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_local_ghost_pack.f90 new file mode 100644 index 000000000..8ad3d819c --- /dev/null +++ b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_local_ghost_pack.f90 @@ -0,0 +1,222 @@ +subroutine fclaw3d_clawpatch46_fort_local_ghost_pack (mx,my,mz, mbc, & + meqn, mint,qdata,volume,qpack,psize, packmode,ierror) + + implicit none + integer :: mx,my,mz, mbc,meqn,psize, mint + integer :: packmode, ierror + double precision :: qdata(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: volume(-mbc:mx+mbc+1,-mbc:my+mbc+1,-mbc:mz+mbc + 1) + double precision :: qpack(psize) + + integer :: packq, unpackq, packarea, unpackarea + parameter(packq = 0, unpackq = 1, packarea = 2, unpackarea = 3) + + integer :: i,j,k,mq,ibc,jbc,kbc, count, count_final + integer :: nghost + logical :: packdata + + ierror = 0 + if (packmode .ne. packq .and. packmode .ne. unpackq .and. & + packmode .ne. packarea .and. packmode .ne. unpackarea) then + ierror = 1 + return + endif + + packdata = packmode .eq. packq .or. packmode .eq. packarea + + nghost = mbc + count = 1 + meqn_loop : do mq = 1,meqn + !! # Face 0 + do k = 1-nghost,mz+nghost + do j = 1-nghost,my+nghost + do ibc = 1-nghost,mint + if (packdata) then + qpack(count) = qdata(ibc,j,k,mq) + else + qdata(ibc,j,k,mq) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 1 + do k = 1-nghost,mz+nghost + do j = 1-nghost,my+nghost + do ibc = mx-mint+1,mx+nghost + if (packdata) then + qpack(count) = qdata(ibc,j,k,mq) + else + qdata(ibc,j,k,mq) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 2 + do k = 1-nghost,mz+nghost + do jbc = 1-nghost,mint + do i = mint+1,mx-mint + if (packdata) then + qpack(count) = qdata(i,jbc,k,mq) + else + qdata(i,jbc,k,mq) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 3 + do k = 1-nghost,mz+nghost + do jbc = my-mint+1,my+nghost + do i = mint+1,mx-mint + if (packdata) then + qpack(count) = qdata(i,jbc,k,mq) + else + qdata(i,jbc,k,mq) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 4 + do kbc = 1-nghost,mint + do j = mint+1,my-mint + do i = mint+1,mx-mint + if (packdata) then + qpack(count) = qdata(i,j,kbc,mq) + else + qdata(i,j,kbc,mq) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 5 + do kbc = mz-mint+1,mz+nghost + do j = mint+1,my-mint + do i = mint+1,mx-mint + if (packdata) then + qpack(count) = qdata(i,j,kbc,mq) + else + qdata(i,j,kbc,mq) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + end do meqn_loop + + count_final = count - 1 + if (packmode .ne. packarea .and. packmode .ne. unpackarea) then + if (count_final .ne. psize) then + write(6,*) 'Before volume packing/unpacking' + write(6,*) 'count_final = ',count_final + write(6,*) 'psize = ',psize + ierror = 2 + endif + return + endif + + !! # Face 0 + do k = 1-nghost,mz+nghost + do j = 1-nghost,my+nghost + do ibc = 1-nghost,mint + if (packdata) then + qpack(count) = volume(ibc,j,k) + else + volume(ibc,j,k) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 1 + do k = 1-nghost,mz+nghost + do j = 1-nghost,my+nghost + do ibc = mx-mint+1,mx+nghost + if (packdata) then + qpack(count) = volume(ibc,j,k) + else + volume(ibc,j,k) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 2 + do k = 1-nghost,mz+nghost + do jbc = 1-nghost,mint + do i = mint+1,mx-mint + if (packdata) then + qpack(count) = volume(i,jbc,k) + else + volume(i,jbc,k) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 3 + do k = 1-nghost,mz+nghost + do jbc = my-mint+1,my+nghost + do i = mint+1,mx-mint + if (packdata) then + qpack(count) = volume(i,jbc,k) + else + volume(i,jbc,k) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 4 + do kbc = 1-nghost,mint + do j = mint+1,my-mint + do i = mint+1,mx-mint + if (packdata) then + qpack(count) = volume(i,j,kbc) + else + volume(i,j,kbc) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + !! # Face 5 + do kbc = mz-mint+1,mz+nghost + do j = mint+1,my-mint + do i = mint+1,mx-mint + if (packdata) then + qpack(count) = volume(i,j,kbc) + else + volume(i,j,kbc) = qpack(count) + endif + count = count + 1 + end do + end do + end do + + count_final = count-1 + if (count_final .ne. psize) then + write(6,*) 'After volume packing/unpacking' + write(6,*) 'psize = ', psize + write(6,*) 'count_final = ', count_final + ierror = 2 + endif + +end subroutine fclaw3d_clawpatch46_fort_local_ghost_pack + + + diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_output_ascii.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_output_ascii.f90 similarity index 87% rename from src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_output_ascii.f90 rename to src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_output_ascii.f90 index 5c5a3f758..9ed8dc852 100644 --- a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_output_ascii.f90 +++ b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_output_ascii.f90 @@ -1,4 +1,4 @@ -subroutine fclaw3dx_clawpatch46_fort_header_ascii (matname1, & +subroutine fclaw3d_clawpatch46_fort_header_ascii (matname1, & matname2, time,meqn,maux,ngrids) implicit none @@ -25,9 +25,9 @@ subroutine fclaw3dx_clawpatch46_fort_header_ascii (matname1, & open(unit=matunit1,file=matname1,status='replace') close(matunit1) -end subroutine fclaw3dx_clawpatch46_fort_header_ascii +end subroutine fclaw3d_clawpatch46_fort_header_ascii -subroutine fclaw3dx_clawpatch46_fort_output_ascii(matname1, & +subroutine fclaw3d_clawpatch46_fort_output_ascii(matname1, & mx,my,mz,meqn,mbc, xlower,ylower, zlower, dx,dy,dz, & q,patch_num,level,blockno,mpirank) @@ -47,7 +47,7 @@ subroutine fclaw3dx_clawpatch46_fort_output_ascii(matname1, & matunit1 = 10 open(matunit1,file=matname1,position='append'); - call fclaw3dx_clawpatch46_fort_write_grid_header(matunit1, & + call fclaw3d_clawpatch46_fort_write_grid_header(matunit1, & mx,my,mz,xlower,ylower, zlower, dx,dy,dz, patch_num,level, & blockno,mpirank) @@ -79,10 +79,10 @@ subroutine fclaw3dx_clawpatch46_fort_output_ascii(matname1, & close(matunit1) -end subroutine fclaw3dx_clawpatch46_fort_output_ascii +end subroutine fclaw3d_clawpatch46_fort_output_ascii -subroutine fclaw3dx_clawpatch46_fort_write_grid_header (matunit1, & +subroutine fclaw3d_clawpatch46_fort_write_grid_header (matunit1, & mx,my,mz, xlower,ylower, zlower, dx,dy,dz, patch_num,level, & blockno,mpirank) @@ -110,4 +110,4 @@ subroutine fclaw3dx_clawpatch46_fort_write_grid_header (matunit1, & e24.16,' dx', /, & e24.16,' dy',/, & e24.16,' dz',/) -end subroutine fclaw3dx_clawpatch46_fort_write_grid_header +end subroutine fclaw3d_clawpatch46_fort_write_grid_header diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_tag4coarsening.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_tag4coarsening.f90 similarity index 51% rename from src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_tag4coarsening.f90 rename to src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_tag4coarsening.f90 index db2b334f4..964806436 100644 --- a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_tag4coarsening.f90 +++ b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_tag4coarsening.f90 @@ -30,28 +30,106 @@ subroutine fclaw3dx_clawpatch46_fort_tag4coarsening(mx,my,mz, mbc,meqn, & qmax(mq) = q0(1,1,1,mq) end do - call fclaw3dx_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & q0,qmin,qmax, dx,dy,dz,xlower(0), ylower(0),zlower, & coarsen_threshold,initflag, tag_patch) if (tag_patch == 0) return - call fclaw3dx_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & q1,qmin,qmax,dx,dy,dz,xlower(1), ylower(1), zlower, & coarsen_threshold,initflag, tag_patch) if (tag_patch == 0) return - call fclaw3dx_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & q2,qmin,qmax,dx,dy,dz,xlower(2), ylower(2),zlower, & coarsen_threshold,initflag, tag_patch) if (tag_patch == 0) return - call fclaw3dx_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & q3,qmin,qmax,dx,dy,dz,xlower(3), ylower(3),zlower, & coarsen_threshold,initflag, tag_patch) end subroutine fclaw3dx_clawpatch46_fort_tag4coarsening -subroutine fclaw3dx_clawpatch46_test_refine3(blockno,mx,my,mz,mbc, & +subroutine fclaw3d_clawpatch46_fort_tag4coarsening(mx,my,mz, mbc,meqn, & + xlower,ylower,zlower,dx,dy, dz, blockno, & + q0, q1, q2, q3, q4, q5, q6, q7, & + coarsen_threshold, initflag, tag_patch) + implicit none + + integer :: mx,my, mz, mbc, meqn, tag_patch, initflag + integer :: blockno + double precision :: xlower(0:7), ylower(0:7), zlower(0:7), dx, dy, dz + double precision :: coarsen_threshold + double precision :: q0(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: q1(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: q2(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: q3(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: q4(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: q5(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: q6(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + double precision :: q7(1-mbc:mx+mbc,1-mbc:my+mbc,1-mbc:mz+mbc,meqn) + + + integer :: mq + double precision :: qmin(meqn), qmax(meqn) + + !! # Don't coarsen when initializing the mesh + if (initflag .ne. 0) then + tag_patch = 0 + return + endif + + !! # Assume that we will coarsen a family unless we find a grid + !! # that doesn't pass the coarsening test. + tag_patch = 1 + do mq = 1,meqn + qmin(mq) = q0(1,1,1,mq) + qmax(mq) = q0(1,1,1,mq) + end do + + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + q0,qmin,qmax, dx,dy,dz,xlower(0), ylower(0),zlower(0), & + coarsen_threshold,initflag, tag_patch) + if (tag_patch == 0) return + + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + q1,qmin,qmax,dx,dy,dz,xlower(1), ylower(1), zlower(1), & + coarsen_threshold,initflag, tag_patch) + if (tag_patch == 0) return + + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + q2,qmin,qmax,dx,dy,dz,xlower(2), ylower(2),zlower(2), & + coarsen_threshold,initflag, tag_patch) + if (tag_patch == 0) return + + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + q3,qmin,qmax,dx,dy,dz,xlower(3), ylower(3),zlower(3), & + coarsen_threshold,initflag, tag_patch) + if (tag_patch == 0) return + + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + q4,qmin,qmax,dx,dy,dz,xlower(4), ylower(4),zlower(4), & + coarsen_threshold,initflag, tag_patch) + if (tag_patch == 0) return + + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + q5,qmin,qmax,dx,dy,dz,xlower(5), ylower(5),zlower(5), & + coarsen_threshold,initflag, tag_patch) + if (tag_patch == 0) return + + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + q6,qmin,qmax,dx,dy,dz,xlower(6), ylower(6),zlower(6), & + coarsen_threshold,initflag, tag_patch) + if (tag_patch == 0) return + + call fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc,meqn, & + q7,qmin,qmax,dx,dy,dz,xlower(7), ylower(7),zlower(7), & + coarsen_threshold,initflag, tag_patch) + +end subroutine fclaw3d_clawpatch46_fort_tag4coarsening + +subroutine fclaw3d_clawpatch46_test_refine3(blockno,mx,my,mz,mbc, & meqn,q, qmin,qmax,dx,dy,dz,xlower,ylower,zlower, & coarsen_threshold,init_flag,tag_patch) @@ -67,11 +145,11 @@ subroutine fclaw3dx_clawpatch46_test_refine3(blockno,mx,my,mz,mbc, & integer i,j, k, ii, jj,kk, mq - integer :: exceeds_th, fclaw3dx_clawpatch_tag_criteria + integer :: exceeds_th, fclaw3d_clawpatch_tag_criteria logical(kind=4) :: is_ghost, clawpatch3_is_ghost - do k = 1,mz + do k = 1-mbc,mz+mbc do i = 1-mbc,mx+mbc do j = 1-mbc,my+mbc xc = xlower + (i-0.5)*dx @@ -94,7 +172,7 @@ subroutine fclaw3dx_clawpatch46_test_refine3(blockno,mx,my,mz,mbc, & end do end do endif - exceeds_th = fclaw3dx_clawpatch_tag_criteria( & + exceeds_th = fclaw3d_clawpatch_tag_criteria( & blockno, qval,qmin,qmax,quad, dx,dy,dz,xc,yc,zc, & coarsen_threshold, init_flag, is_ghost) @@ -112,4 +190,4 @@ subroutine fclaw3dx_clawpatch46_test_refine3(blockno,mx,my,mz,mbc, & end do end do -end subroutine fclaw3dx_clawpatch46_test_refine3 +end subroutine fclaw3d_clawpatch46_test_refine3 diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_tag4refinement.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_tag4refinement.f90 similarity index 92% rename from src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_tag4refinement.f90 rename to src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_tag4refinement.f90 index b64160957..4ec73fe74 100644 --- a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_tag4refinement.f90 +++ b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_tag4refinement.f90 @@ -1,4 +1,4 @@ -subroutine fclaw3dx_clawpatch46_fort_tag4refinement(mx,my,mz,mbc, & +subroutine fclaw3d_clawpatch46_fort_tag4refinement(mx,my,mz,mbc, & meqn, xlower,ylower,zlower, dx,dy,dz, blockno, & q, tag_threshold, init_flag, tag_patch) implicit none @@ -11,7 +11,7 @@ subroutine fclaw3dx_clawpatch46_fort_tag4refinement(mx,my,mz,mbc, & integer :: i,j,k, mq - integer :: exceeds_th, fclaw3dx_clawpatch_tag_criteria + integer :: exceeds_th, fclaw3d_clawpatch_tag_criteria integer :: ii,jj,kk double precision :: qmin(meqn), qmax(meqn) @@ -54,7 +54,7 @@ subroutine fclaw3dx_clawpatch46_fort_tag4refinement(mx,my,mz,mbc, & end do end do endif - exceeds_th = fclaw3dx_clawpatch_tag_criteria(& + exceeds_th = fclaw3d_clawpatch_tag_criteria(& blockno, qval,qmin,qmax,quad, dx,dy,dz,xc,yc,zc, & tag_threshold,init_flag, is_ghost) !! # -1 : Not conclusive (possibly ghost cell); don't tag for refinement @@ -67,7 +67,7 @@ subroutine fclaw3dx_clawpatch46_fort_tag4refinement(mx,my,mz,mbc, & end do end do end do -end subroutine fclaw3dx_clawpatch46_fort_tag4refinement +end subroutine fclaw3d_clawpatch46_fort_tag4refinement !! # We may want to check ghost cells for tagging. logical(kind=4) function clawpatch3_is_ghost(i,j,k, mx,my,mz) diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_timeinterp.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_timeinterp.f90 similarity index 96% rename from src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_timeinterp.f90 rename to src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_timeinterp.f90 index e4f915444..94f16bc45 100644 --- a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_timeinterp.f90 +++ b/src/patches/clawpatch/fort3_4.6/fclaw3d_clawpatch46_timeinterp.f90 @@ -1,4 +1,4 @@ -subroutine fclaw3dx_clawpatch46_fort_timeinterp(mx,my,mz, mbc,meqn, & +subroutine fclaw3d_clawpatch46_fort_timeinterp(mx,my,mz, mbc,meqn, & psize, qcurr,qlast,qinterp,alpha,ierror) implicit none diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_average.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_average.f90 index 5c7d07d12..7782a4368 100644 --- a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_average.f90 +++ b/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_average.f90 @@ -83,7 +83,7 @@ SUBROUTINE fclaw3dx_clawpatch46_fort_average_face(mx,my,mz,mbc,meqn, & elseif (iface_coarse .eq. 1) then ic = mx+ibc endif - call fclaw3dx_clawpatch_transform_face_half(ic,jc,i2,j2,transform_cptr) + call fclaw2d_clawpatch_transform_face_half(ic,jc,i2,j2,transform_cptr) !! # --------------------------------------------- !! # Two 'half-size' neighbors will be passed into !! # this routine. Only half of the coarse grid ghost @@ -131,7 +131,7 @@ SUBROUTINE fclaw3dx_clawpatch46_fort_average_face(mx,my,mz,mbc,meqn, & jc = my+jbc endif - call fclaw3dx_clawpatch_transform_face_half(ic,jc,i2,j2, transform_cptr) + call fclaw2d_clawpatch_transform_face_half(ic,jc,i2,j2, transform_cptr) skip_this_grid = .false. do m = 0,r2-1 if (.not. fclaw2d_clawpatch_is_valid_average(i2(m),j2(m),mx,my)) then @@ -225,7 +225,7 @@ subroutine fclaw3dx_clawpatch46_fort_average_corner(mx,my,mz,mbc,meqn, & j1 = my+jbc endif - call fclaw3dx_clawpatch_transform_corner_half(i1,j1,i2,j2, transform_cptr) + call fclaw2d_clawpatch_transform_corner_half(i1,j1,i2,j2, transform_cptr) if (is_manifold) then sum = 0 vf_sum = 0 diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_copy.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_copy.f90 index 9137e6c96..aee6441b2 100644 --- a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_copy.f90 +++ b/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_copy.f90 @@ -117,7 +117,7 @@ subroutine fclaw3dx_clawpatch46_fort_copy_corner(mx,my,mz,mbc,meqn, & !! # this routine is not yet complete, but the complete one !! # can now be dropped in. - call fclaw3dx_clawpatch_transform_corner(i1,j1,i2,j2, transform_ptr) + call fclaw2d_clawpatch_transform_corner(i1,j1,i2,j2, transform_ptr) qthis(i1,j1,k,mq) = qneighbor(i2,j2,k,mq) end do end do diff --git a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_interpolate.f90 b/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_interpolate.f90 index ecc5127d4..d86340a95 100644 --- a/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_interpolate.f90 +++ b/src/patches/clawpatch/fort3_4.6/fclaw3dx_clawpatch46_interpolate.f90 @@ -100,7 +100,7 @@ subroutine fclaw3dx_clawpatch46_fort_interpolate_face & do jc = 1,mx i1 = ic j1 = jc - call fclaw3dx_clawpatch_transform_face_half(i1,j1,i2,j2,transform_ptr) + call fclaw2d_clawpatch_transform_face_half(i1,j1,i2,j2,transform_ptr) skip_this_grid = .false. do m = 0,r2-1 if (.not. fclaw2d_clawpatch_is_valid_interp(i2(m),j2(m),mx,my,mbc)) then @@ -145,7 +145,7 @@ subroutine fclaw3dx_clawpatch46_fort_interpolate_face & do ic = 1,mx i1 = ic j1 = jc - call fclaw3dx_clawpatch_transform_face_half(i1,j1,i2,j2, transform_ptr) + call fclaw2d_clawpatch_transform_face_half(i1,j1,i2,j2, transform_ptr) !! # --------------------------------------------- !! # Two 'half-size' neighbors will be passed into !! # this routine. Only half of the coarse grid ghost @@ -265,7 +265,7 @@ subroutine fclaw3dx_clawpatch46_fort_interpolate_corner & !! # Interpolate coarse grid corners to fine grid corner ghost cells i1 = ic j1 = jc - call fclaw3dx_clawpatch_transform_corner_half(i1,j1,i2,j2, transform_ptr) + call fclaw2d_clawpatch_transform_corner_half(i1,j1,i2,j2, transform_ptr) mq_loop : do mq = 1,meqn k_loop : do k = 1,mz diff --git a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_difference_exceeds_th.f90 b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_difference_exceeds_th.f90 similarity index 87% rename from src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_difference_exceeds_th.f90 rename to src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_difference_exceeds_th.f90 index ca9a8d231..421cb9bb6 100644 --- a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_difference_exceeds_th.f90 +++ b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_difference_exceeds_th.f90 @@ -16,7 +16,7 @@ !! @param[in] is_ghost true if cell is a ghost cell !! @return 1 if exceeds threshold, 0 if not, -1 if inconclusive. ! -------------------------------------------------------------- -integer function fclaw3dx_clawpatch_difference_exceeds_th(blockno, meqn, & +integer function fclaw3d_clawpatch_difference_exceeds_th(blockno, meqn, & qval,qmin,qmax,quad, & dx,dy,dz,xc,yc,zc,ivar_threshold, threshold,& init_flag, is_ghost) @@ -35,7 +35,7 @@ integer function fclaw3dx_clawpatch_difference_exceeds_th(blockno, meqn, & if (is_ghost) then !! # quad may have uninitialized values; test inconclusive - fclaw3dx_clawpatch_difference_exceeds_th = -1 + fclaw3d_clawpatch_difference_exceeds_th = -1 return endif @@ -51,6 +51,6 @@ integer function fclaw3dx_clawpatch_difference_exceeds_th(blockno, meqn, & refine = 1 endif - fclaw3dx_clawpatch_difference_exceeds_th = refine + fclaw3d_clawpatch_difference_exceeds_th = refine -end function fclaw3dx_clawpatch_difference_exceeds_th +end function fclaw3d_clawpatch_difference_exceeds_th diff --git a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_gradient_exceeds_th.f90 b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_gradient_exceeds_th.f90 similarity index 91% rename from src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_gradient_exceeds_th.f90 rename to src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_gradient_exceeds_th.f90 index 956ba6c43..996d14c00 100644 --- a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_gradient_exceeds_th.f90 +++ b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_gradient_exceeds_th.f90 @@ -16,7 +16,7 @@ !! @param[in] is_ghost true if cell is a ghost cell !! @return 1 if exceeds threshold, 0 if not, -1 if inconclusive. ! -------------------------------------------------------------- -integer function fclaw3dx_clawpatch_gradient_exceeds_th(blockno, meqn, & +integer function fclaw3d_clawpatch_gradient_exceeds_th(blockno, meqn, & qval,qmin,qmax,quad, & dx,dy,dz, xc,yc,zc, ivar_threshold, threshold, & init_flag, is_ghost) @@ -42,7 +42,7 @@ integer function fclaw3dx_clawpatch_gradient_exceeds_th(blockno, meqn, & if (is_ghost) then !! # quad may have uninitialized values. Test is inconclusive - fclaw3dx_clawpatch_gradient_exceeds_th = -1 + fclaw3d_clawpatch_gradient_exceeds_th = -1 return endif @@ -66,9 +66,9 @@ integer function fclaw3dx_clawpatch_gradient_exceeds_th(blockno, meqn, & refine = 1 endif - fclaw3dx_clawpatch_gradient_exceeds_th = refine + fclaw3d_clawpatch_gradient_exceeds_th = refine -end function fclaw3dx_clawpatch_gradient_exceeds_th +end function fclaw3d_clawpatch_gradient_exceeds_th ! -------------------------------------------------------------- !> @brief Dot product of two vector diff --git a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_minmax_exceeds_th.f90 b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_minmax_exceeds_th.f90 similarity index 89% rename from src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_minmax_exceeds_th.f90 rename to src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_minmax_exceeds_th.f90 index 4290431ff..feea9f557 100644 --- a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_minmax_exceeds_th.f90 +++ b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_minmax_exceeds_th.f90 @@ -17,7 +17,7 @@ !! @param[in] is_ghost true if cell is a ghost cell !! @return 1 if exceeds threshold, 0 if not, -1 if inconclusive. ! -------------------------------------------------------------- -integer function fclaw3dx_clawpatch_minmax_exceeds_th(blockno, meqn, & +integer function fclaw3d_clawpatch_minmax_exceeds_th(blockno, meqn, & qval,qmin,qmax,quad, & dx,dy,dz, xc,yc,zc, ivar_threshold, & threshold, init_flag, is_ghost) @@ -42,6 +42,6 @@ integer function fclaw3dx_clawpatch_minmax_exceeds_th(blockno, meqn, & refine = 1 endif - fclaw3dx_clawpatch_minmax_exceeds_th = refine + fclaw3d_clawpatch_minmax_exceeds_th = refine -end function fclaw3dx_clawpatch_minmax_exceeds_th +end function fclaw3d_clawpatch_minmax_exceeds_th diff --git a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_tag_criteria.c b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_tag_criteria.c similarity index 73% rename from src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_tag_criteria.c rename to src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_tag_criteria.c index baf75c3f2..534a43941 100644 --- a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_tag_criteria.c +++ b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_tag_criteria.c @@ -11,38 +11,38 @@ #if 0 #if REFINE_DIM == 2 && PATCH_DIM == 2 -#include "../fclaw2d_clawpatch.h" +#include "../fclaw_clawpatch.h" -#include "../fclaw2d_clawpatch_options.h" +#include "../fclaw_clawpatch_options.h" #include "../fclaw2d_clawpatch_fort.h" #elif REFINE_DIM == 2 && PATCH_DIM == 3 -#include "../fclaw3dx_clawpatch.h" +#include "../fclaw3d_clawpatch.h" -#include "../fclaw3dx_clawpatch_options.h" +#include "../fclaw_clawpatch_options.h" #include "../fclaw2d_clawpatch_fort.h" -#include "../fclaw3dx_clawpatch_fort.h" +#include "../fclaw3d_clawpatch_fort.h" #include <_fclaw2d_to_fclaw3dx.h> #endif #endif -#include +#include -#include "../fclaw3dx_clawpatch.h" +#include "../fclaw_clawpatch.h" -#include "../fclaw3dx_clawpatch_options.h" +#include "../fclaw_clawpatch_options.h" // #include "../fclaw2d_clawpatch_fort.h" -#include "../fclaw3dx_clawpatch_fort.h" +#include "../fclaw3d_clawpatch_fort.h" /* ------------------------------------------------------------------------------------ */ -int FCLAW3DX_CLAWPATCH_TAG_CRITERIA(const int* blockno, +int FCLAW3D_CLAWPATCH_TAG_CRITERIA(const int* blockno, const double *qval, const double* qmin, const double *qmax, @@ -57,40 +57,40 @@ int FCLAW3DX_CLAWPATCH_TAG_CRITERIA(const int* blockno, const int* init_flag, const int* is_ghost) { - struct fclaw2d_global* glob = fclaw2d_global_get_global(); - fclaw3dx_clawpatch_vtable_t* clawpatch_vt = fclaw3dx_clawpatch_vt(glob); - fclaw3dx_clawpatch_fort_exceeds_threshold_t user_exceeds_threshold = - clawpatch_vt->fort_user_exceeds_threshold; + struct fclaw_global* glob = fclaw_global_get_static_global(); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); + fclaw3d_clawpatch_fort_exceeds_threshold_t user_exceeds_threshold = + clawpatch_vt->d3->fort_user_exceeds_threshold; - fclaw3dx_clawpatch_options_t *clawpatch_opt = fclaw3dx_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int meqn_val = clawpatch_opt->meqn, *meqn = &meqn_val; int ivar_val = clawpatch_opt->threshold_variable, *ivar_variable=&ivar_val; int exceeds_th = 1; - int refinement_criteria = fclaw3dx_clawpatch_get_options(glob)->refinement_criteria; + int refinement_criteria = clawpatch_opt->refinement_criteria; switch(refinement_criteria) { case FCLAW_REFINE_CRITERIA_VALUE: - exceeds_th = FCLAW3DX_CLAWPATCH_VALUE_EXCEEDS_TH(blockno,meqn, + exceeds_th = FCLAW3D_CLAWPATCH_VALUE_EXCEEDS_TH(blockno,meqn, qval,qmin,qmax,quad, dx, dy, dz, xc, yc, zc, ivar_variable, tag_threshold,init_flag,is_ghost); break; case FCLAW_REFINE_CRITERIA_DIFFERENCE: - exceeds_th = FCLAW3DX_CLAWPATCH_DIFFERENCE_EXCEEDS_TH(blockno,meqn, + exceeds_th = FCLAW3D_CLAWPATCH_DIFFERENCE_EXCEEDS_TH(blockno,meqn, qval,qmin,qmax,quad, dx, dy, dz, xc, yc, zc, ivar_variable, tag_threshold,init_flag,is_ghost); break; case FCLAW_REFINE_CRITERIA_MINMAX: - exceeds_th = FCLAW3DX_CLAWPATCH_MINMAX_EXCEEDS_TH(blockno,meqn, + exceeds_th = FCLAW3D_CLAWPATCH_MINMAX_EXCEEDS_TH(blockno,meqn, qval,qmin,qmax,quad, dx, dy, dz, xc, yc, zc, ivar_variable, tag_threshold,init_flag,is_ghost); break; case FCLAW_REFINE_CRITERIA_GRADIENT: - exceeds_th = FCLAW3DX_CLAWPATCH_GRADIENT_EXCEEDS_TH(blockno,meqn, + exceeds_th = FCLAW3D_CLAWPATCH_GRADIENT_EXCEEDS_TH(blockno,meqn, qval,qmin,qmax,quad, dx, dy, dz, xc, yc, zc, ivar_variable, tag_threshold,init_flag,is_ghost); @@ -112,7 +112,7 @@ int FCLAW3DX_CLAWPATCH_TAG_CRITERIA(const int* blockno, tag_threshold,init_flag,is_ghost); break; default: - fclaw_global_essentialf("fclaw3dx_clawpatch_exceeds_threshold.c): " \ + fclaw_global_essentialf("fclaw3d_clawpatch_exceeds_threshold.c): " \ "No valid refinement criteria specified\n"); exit(0); break; diff --git a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_value_exceeds_th.f90 b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_value_exceeds_th.f90 similarity index 89% rename from src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_value_exceeds_th.f90 rename to src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_value_exceeds_th.f90 index 45082e0ee..5b9c36c9a 100644 --- a/src/patches/clawpatch/fort3_user/fclaw3dx_clawpatch_value_exceeds_th.f90 +++ b/src/patches/clawpatch/fort3_user/fclaw3d_clawpatch_value_exceeds_th.f90 @@ -16,7 +16,7 @@ !! @param[in] is_ghost true if cell is a ghost cell !! @return 1 if exceeds threshold, 0 if not, -1 if inconclusive. ! -------------------------------------------------------------- -integer function fclaw3dx_clawpatch_value_exceeds_th(blockno, meqn, & +integer function fclaw3d_clawpatch_value_exceeds_th(blockno, meqn, & qval,qmin,qmax,quad, & dx,dy,dz, xc,yc,zc, ivar_threshold, threshold, & init_flag, is_ghost) @@ -39,6 +39,6 @@ integer function fclaw3dx_clawpatch_value_exceeds_th(blockno, meqn, & refine = 1 endif - fclaw3dx_clawpatch_value_exceeds_th = refine + fclaw3d_clawpatch_value_exceeds_th = refine -end function fclaw3dx_clawpatch_value_exceeds_th +end function fclaw3d_clawpatch_value_exceeds_th diff --git a/src/patches/clawpatch/fort_4.6/fclaw2d_clawpatch46_diagnostics.f b/src/patches/clawpatch/fort_4.6/fclaw2d_clawpatch46_diagnostics.f index b6b373ed0..b894a33cc 100644 --- a/src/patches/clawpatch/fort_4.6/fclaw2d_clawpatch46_diagnostics.f +++ b/src/patches/clawpatch/fort_4.6/fclaw2d_clawpatch46_diagnostics.f @@ -25,7 +25,7 @@ subroutine fclaw2d_clawpatch46_fort_conservation_check integer i,j,m integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used logical use_kahan @@ -37,7 +37,7 @@ subroutine fclaw2d_clawpatch46_fort_conservation_check do m = 1,mfields do j = 1,my do i = 1,mx - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then area_ij = area(i,j) !! Area varies endif if (use_kahan) then @@ -74,12 +74,12 @@ subroutine fclaw2d_clawpatch46_fort_conservation_check integer i,j integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used double precision sum cont = fclaw_map_get_context() - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then sum = 0 do j = 1,my do i = 1,mx @@ -118,14 +118,14 @@ subroutine fclaw2d_clawpatch46_fort_compute_error_norm double precision dxdy, eij integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = fclaw_map_get_context() c # error_norm(:) comes in with values; do not initialize it here! dxdy = dx*dy do m = 1,mfields - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do j = 1,my do i = 1,mx eij = abs(error(i,j,m)) diff --git a/src/patches/clawpatch/fort_5.0/fclaw2d_clawpatch5_diagnostics.f b/src/patches/clawpatch/fort_5.0/fclaw2d_clawpatch5_diagnostics.f index f20001ead..f42d0dda1 100644 --- a/src/patches/clawpatch/fort_5.0/fclaw2d_clawpatch5_diagnostics.f +++ b/src/patches/clawpatch/fort_5.0/fclaw2d_clawpatch5_diagnostics.f @@ -25,13 +25,13 @@ subroutine fclaw2d_clawpatch5_fort_conservation_check(mx,my, integer i,j,m double precision dxdy integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = fclaw_map_get_context() dxdy = dx*dy do m = 1,meqn - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do j = 1,my do i = 1,mx sum(m) = sum(m) + q(m,i,j)*area(i,j) @@ -69,11 +69,11 @@ subroutine fclaw2d_clawpatch5_fort_conservation_check(mx,my, integer i,j double precision sum integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = fclaw_map_get_context() - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then sum = 0 do j = 1,my do i = 1,mx @@ -110,14 +110,14 @@ subroutine fclaw2d_clawpatch5_fort_compute_error_norm( integer i,j,m double precision dxdy, eij integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = fclaw_map_get_context() c # error_norm(:) comes in with values; do not initialize it here! dxdy = dx*dy do m = 1,meqn - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do j = 1,my do i = 1,mx eij = abs(error(m,i,j)) diff --git a/src/patches/clawpatch/fort_user/fclaw2d_clawpatch_gradient_exceeds_th.f90 b/src/patches/clawpatch/fort_user/fclaw2d_clawpatch_gradient_exceeds_th.f90 index cb0226061..4833c581d 100644 --- a/src/patches/clawpatch/fort_user/fclaw2d_clawpatch_gradient_exceeds_th.f90 +++ b/src/patches/clawpatch/fort_user/fclaw2d_clawpatch_gradient_exceeds_th.f90 @@ -37,7 +37,7 @@ integer function fclaw2d_clawpatch_gradient_exceeds_th(blockno, meqn, & integer*8 :: cont, fclaw_map_get_context - integer :: fclaw2d_map_is_used + integer :: fclaw_map_is_used double precision :: clawpatch_gradient_dot integer :: refine @@ -61,16 +61,16 @@ integer function fclaw2d_clawpatch_gradient_exceeds_th(blockno, meqn, & refine = 0 - if (fclaw2d_map_is_used(cont) .ne. 0) THEN - CALL fclaw2d_map_c2m(cont,blockno,xc,yc,xp,yp,zp) - CALL fclaw2d_map_c2m(cont,blockno,xc+dx,yc,xpp,ypp,zpp) - CALL fclaw2d_map_c2m(cont,blockno,xc-dx,yc,xpm,ypm,zpm) + if (fclaw_map_is_used(cont) .ne. 0) THEN + CALL fclaw_map_2d_c2m(cont,blockno,xc,yc,xp,yp,zp) + CALL fclaw_map_2d_c2m(cont,blockno,xc+dx,yc,xpp,ypp,zpp) + CALL fclaw_map_2d_c2m(cont,blockno,xc-dx,yc,xpm,ypm,zpm) t1(1) = (xpp - xpm)/dx2 t1(2) = (ypp - ypm)/dx2 t1(3) = (zpp - zpm)/dx2 - CALL fclaw2d_map_c2m(cont,blockno,xc,yc+dy,xpp,ypp,zpp) - CALL fclaw2d_map_c2m(cont,blockno,xc,yc-dy,xpm,ypm,zpm) + CALL fclaw_map_2d_c2m(cont,blockno,xc,yc+dy,xpp,ypp,zpp) + CALL fclaw_map_2d_c2m(cont,blockno,xc,yc-dy,xpm,ypm,zpm) t2(1) = (xpp - xpm)/dy2 t2(2) = (ypp - ypm)/dy2 t2(3) = (zpp - zpm)/dy2 diff --git a/src/patches/clawpatch/fort_user/fclaw2d_clawpatch_tag_criteria.c b/src/patches/clawpatch/fort_user/fclaw2d_clawpatch_tag_criteria.c index 2a09d6b9e..2db83818f 100644 --- a/src/patches/clawpatch/fort_user/fclaw2d_clawpatch_tag_criteria.c +++ b/src/patches/clawpatch/fort_user/fclaw2d_clawpatch_tag_criteria.c @@ -1,34 +1,11 @@ /* # check to see if value exceeds threshold */ -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif +#include -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif +#include "../fclaw_clawpatch.h" - -#include - -#if REFINE_DIM == 2 && PATCH_DIM == 2 - -#include "../fclaw2d_clawpatch.h" - -#include "../fclaw2d_clawpatch_options.h" -#include "../fclaw2d_clawpatch_fort.h" - -#elif REFINE_DIM == 2 && PATCH_DIM == 3 - -#include "../fclaw3dx_clawpatch.h" - -#include "../fclaw3dx_clawpatch_options.h" +#include "../fclaw_clawpatch_options.h" #include "../fclaw2d_clawpatch_fort.h" -#include "../fclaw3dx_clawpatch_fort.h" - -#include <_fclaw2d_to_fclaw3dx.h> - -#endif /* ------------------------------------------------------------------------------------ */ @@ -51,18 +28,18 @@ int FCLAW2D_CLAWPATCH_TAG_CRITERIA(const int* blockno, const int* init_flag, const int* is_ghost) { - struct fclaw2d_global* glob = fclaw2d_global_get_global(); - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + struct fclaw_global* glob = fclaw_global_get_static_global(); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); clawpatch_fort_exceeds_threshold_t user_exceeds_threshold = - clawpatch_vt->fort_user_exceeds_threshold; + clawpatch_vt->d2->fort_user_exceeds_threshold; - fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int meqn_val = clawpatch_opt->meqn, *meqn = &meqn_val; int ivar_val = clawpatch_opt->threshold_variable, *ivar_threshold=&ivar_val; int exceeds_th = 1; - int refinement_criteria = fclaw2d_clawpatch_get_options(glob)->refinement_criteria; + int refinement_criteria = fclaw_clawpatch_get_options(glob)->refinement_criteria; switch(refinement_criteria) { case FCLAW_REFINE_CRITERIA_VALUE: diff --git a/src/patches/metric/fclaw2d_metric.cpp b/src/patches/metric/fclaw2d_metric.cpp index 1cf460a6d..22274337f 100644 --- a/src/patches/metric/fclaw2d_metric.cpp +++ b/src/patches/metric/fclaw2d_metric.cpp @@ -24,50 +24,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef REFINE_DIM -#define REFINE_DIM 2 -#endif - -#ifndef PATCH_DIM -#define PATCH_DIM 2 -#endif - - #if 0 /* Fix syntax highlighting */ #endif -#if PATCH_DIM == 2 +#include #define METRIC_VTABLE_NAME "fclaw2d_metric" #include "fclaw2d_metric.h" #include "fclaw2d_metric.hpp" -#elif PATCH_DIM == 3 && REFINE_DIM == 2 - -#define METRIC_VTABLE_NAME "fclaw3d_metric" - -#include "fclaw3d_metric.h" -#include "fclaw3d_metric.hpp" - -#include <_fclaw2d_to_fclaw3d.h> - -#else -#error "Octree refinement not yet implemented" -#endif - - #include -#include -#include +#include +#include static -fclaw2d_metric_patch_t* get_metric_patch(fclaw2d_global_t* glob, - fclaw2d_patch_t *patch) +fclaw2d_metric_patch_t* get_metric_patch(fclaw_global_t* glob, + fclaw_patch_t *patch) { - return (fclaw2d_metric_patch_t*) fclaw2d_patch_metric_patch(glob, patch); + return (fclaw2d_metric_patch_t*) fclaw_patch_metric_patch(glob, patch); } @@ -87,26 +64,14 @@ void fclaw2d_metric_patch_delete(fclaw2d_metric_patch_t **mp) } -#if PATCH_DIM == 2 -void fclaw2d_metric_patch_define(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, +void fclaw2d_metric_patch_define(fclaw_global_t* glob, + fclaw_patch_t* patch, int mx, int my, int mbc, double dx, double dy, double xlower, double ylower, double xupper, double yupper, int blockno, int patchno, - fclaw2d_build_mode_t build_mode) -#elif PATCH_DIM == 3 -void fclaw3d_metric_patch_define(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - int mx, int my, int mz, int mbc, - double dx, double dy,double dz, - double xlower, double ylower, double zlower, - double xupper, double yupper, double zupper, - int blockno, int patchno, - fclaw2d_build_mode_t build_mode) -#endif - + fclaw_build_mode_t build_mode) { fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch); @@ -122,81 +87,45 @@ void fclaw3d_metric_patch_define(fclaw2d_global_t* glob, mp->xupper = xupper; mp->yupper = yupper; -#if PATCH_DIM == 3 - mp->mz = mz; - mp->zlower = zlower; - mp->zupper = zupper; - mp->dz = (mp->zupper - mp->zlower)/mp->mz; -#endif - /* Set up area for storage - this is needed for ghost patches, and updated patches */ Box box_p, box_d; { /* Create box for primary grid (cell-centered) */ - int ll_p[PATCH_DIM]; - int ur_p[PATCH_DIM]; - for (int idir = 0; idir < PATCH_DIM; idir++) + int ll_p[FCLAW2D_SPACEDIM]; + int ur_p[FCLAW2D_SPACEDIM]; + for (int idir = 0; idir < FCLAW2D_SPACEDIM; idir++) { ll_p[idir] = -mbc; } ur_p[0] = mp->mx + mbc + 1; ur_p[1] = mp->my + mbc + 1; -#if PATCH_DIM == 3 - ur_p[2] = mp->mz + mbc + 1; -#endif - box_p = Box(ll_p,ur_p,PATCH_DIM); + box_p = Box(ll_p,ur_p,FCLAW2D_SPACEDIM); /* Create box for nodes (cell corners) */ - int ll_d[PATCH_DIM]; - int ur_d[PATCH_DIM]; + int ll_d[FCLAW2D_SPACEDIM]; + int ur_d[FCLAW2D_SPACEDIM]; /* Create node centered box */ - for (int idir = 0; idir < PATCH_DIM; idir++) + for (int idir = 0; idir < FCLAW2D_SPACEDIM; idir++) { ll_d[idir] = -mbc; } ur_d[0] = mp->mx + mbc + 2; ur_d[1] = mp->my + mbc + 2; -#if PATCH_DIM == 3 - ur_d[2] = mp->mz + mbc + 2; -#endif - - box_d = Box(ll_d,ur_d,PATCH_DIM); + box_d = Box(ll_d,ur_d,FCLAW2D_SPACEDIM); -#if PATCH_DIM == 2 mp->area.define(box_p,1); -#elif PATCH_DIM == 3 - /* volume is needed in ghost patches for averaging. The face area is - only needed if we are updating a cell, but since volume and - face area are computed together, we should also allocate memory - for face areas - */ - mp->volume.define(box_p,1); - mp->face_area.define(box_d,3); - - /* Node values are needed by parallel ghost patches when we have an - affine map. In this case, the affine map can use pre-computed xd,yd,zd - values. - - Note: This should be revisited since we are doing extra work for the affine - map. - */ - mp->xd.define(box_d,1); - mp->yd.define(box_d,1); - mp->zd.define(box_d,1); -#endif - } /* Only allocate memory that is needed */ - if (build_mode != FCLAW2D_BUILD_FOR_GHOST_AREA_PACKED - && build_mode == FCLAW2D_BUILD_FOR_UPDATE) + if (build_mode != FCLAW_BUILD_FOR_GHOST_AREA_PACKED + && build_mode == FCLAW_BUILD_FOR_UPDATE) { /* From here on out, we build for patches that get updated @@ -233,8 +162,6 @@ void fclaw3d_metric_patch_define(fclaw2d_global_t* glob, mp->yp.define(box_p,1); mp->zp.define(box_p,1); -#if PATCH_DIM == 2 - mp->xd.define(box_d,1); mp->yd.define(box_d,1); mp->zd.define(box_d,1); @@ -251,16 +178,6 @@ void fclaw3d_metric_patch_define(fclaw2d_global_t* glob, mp->yface_tangents.define(box_d,3); mp->edge_lengths.define(box_d,2); -#elif PATCH_DIM == 3 - /* Store face areas of left, front, bottom edge of box */ - //mp->face_area.define(box_d,3); - - /* Store 3x3 rotation matrix for each of three faces */ - mp->xrot.define(box_d,9); - mp->yrot.define(box_d,9); - mp->zrot.define(box_d,9); -#endif - } } @@ -268,9 +185,9 @@ void fclaw3d_metric_patch_define(fclaw2d_global_t* glob, /* For 3d extruded mesh, this averages cell volumes */ static -void metric_average_area_from_fine(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, - fclaw2d_patch_t *coarse_patch, +void metric_average_area_from_fine(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + fclaw_patch_t *coarse_patch, int blockno, int coarse_patchno, int fine0_patchno) @@ -279,84 +196,41 @@ void metric_average_area_from_fine(fclaw2d_global_t *glob, int mx,my, mbc; double xlower,ylower,dx,dy; -#if PATCH_DIM == 2 fclaw2d_metric_patch_grid_data(glob,coarse_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *areacoarse = fclaw2d_metric_patch_get_area(glob, coarse_patch); -#elif PATCH_DIM == 3 - int mz; - double zlower, dz; - fclaw3d_metric_patch_grid_data(glob,coarse_patch,&mx,&my,&mz,&mbc, - &xlower,&ylower,&zlower,&dx,&dy,&dz); - double *volcoarse, *fa_coarse; - fclaw3d_metric_patch_scalar(glob,coarse_patch,&volcoarse, &fa_coarse); -#endif - for(int igrid = 0; igrid < 4; igrid++) { -#if PATCH_DIM == 2 double* areafine = fclaw2d_metric_patch_get_area(glob, &fine_patches[igrid]); FCLAW2D_METRIC_FORT_AVERAGE_AREA(&mx,&my,&mbc, areacoarse, areafine,&igrid); -#elif PATCH_DIM == 3 -#if REFINE_DIM == 2 - double *volfine, *fa_fine; - fclaw3d_metric_patch_scalar(glob,&fine_patches[igrid],&volfine, &fa_fine); - - /* Average from fine to coarse when creating coarse grid from a fine grid. - This will be exact, since both volume and face areas are computing at - finest level resolution. - */ - FCLAW3DX_METRIC_FORT_AVERAGE_VOLUME(&mx,&my,&mz, &mbc, - volcoarse,volfine, - &igrid); - - FCLAW3DX_METRIC_FORT_AVERAGE_FACEAREA(&mx,&my,&mz, &mbc, - fa_coarse,fa_fine, &igrid); -#else - fclaw_global_essential("Average area/vol from fine not implemented for full octree\n"); - exit(0); -#endif - -#endif /* End PATCH_DIM == 3 */ } /* Compute volume from scratch in second layer of coarse grid ghost cells. These are not averaged from the fine grid (first layer can be averaged from fine grid, however) */ -#if PATCH_DIM == 2 metric_vt->compute_area_ghost(glob,coarse_patch,blockno,coarse_patchno); -#elif PATCH_DIM == 3 - metric_vt->compute_volume_ghost(glob,coarse_patch,blockno,coarse_patchno); -#endif - - } /* --------------------------------- Public interface -------------------------------- */ -void fclaw2d_metric_patch_compute_area (fclaw2d_global_t *glob, - fclaw2d_patch_t* patch, +void fclaw2d_metric_patch_compute_area (fclaw_global_t *glob, + fclaw_patch_t* patch, int blockno, int patchno) { fclaw2d_metric_vtable_t *metric_vt = fclaw2d_metric_vt(glob); -#if PATCH_DIM == 2 FCLAW_ASSERT(metric_vt->compute_area); metric_vt->compute_area(glob,patch,blockno,patchno); -#elif PATCH_DIM == 3 - FCLAW_ASSERT(metric_vt->compute_volume); - metric_vt->compute_volume(glob,patch,blockno,patchno); -#endif } -void fclaw2d_metric_patch_build(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, +void fclaw2d_metric_patch_build(fclaw_global_t* glob, + fclaw_patch_t* patch, int blockno, int patchno) { @@ -370,13 +244,9 @@ void fclaw2d_metric_patch_build(fclaw2d_global_t* glob, Note : These are all computed on finest level mesh and averaged down to coarser meshes. This is required from geometric consistency */ -#if PATCH_DIM == 2 /* Compute 2d patch areas */ metric_vt->compute_area(glob,patch,blockno,patchno); -#elif PATCH_DIM == 3 - /* Compute 3d volumes and 2d face areas */ - metric_vt->compute_volume(glob,patch,blockno,patchno); -#endif + if (metric_vt->compute_basis != NULL) { /* In 2d : Surface normals, tangents, edge lengths, @@ -390,9 +260,9 @@ void fclaw2d_metric_patch_build(fclaw2d_global_t* glob, -void fclaw2d_metric_patch_build_from_fine(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, - fclaw2d_patch_t *coarse_patch, +void fclaw2d_metric_patch_build_from_fine(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + fclaw_patch_t *coarse_patch, int blockno, int coarse_patchno, int fine0_patchno) @@ -438,7 +308,7 @@ void metric_vt_destroy(void* vt) FCLAW_FREE (vt); } -fclaw2d_metric_vtable_t* fclaw2d_metric_vt(fclaw2d_global_t* glob) +fclaw2d_metric_vtable_t* fclaw2d_metric_vt(fclaw_global_t* glob) { fclaw2d_metric_vtable_t* metric_vt = (fclaw2d_metric_vtable_t*) fclaw_pointer_map_get(glob->vtables, METRIC_VTABLE_NAME); @@ -448,13 +318,12 @@ fclaw2d_metric_vtable_t* fclaw2d_metric_vt(fclaw2d_global_t* glob) } -void fclaw2d_metric_vtable_initialize(fclaw2d_global_t* glob) +void fclaw2d_metric_vtable_initialize(fclaw_global_t* glob) { fclaw2d_metric_vtable_t *metric_vt = metric_vt_new(); /* Fortran files */ -#if PATCH_DIM == 2 metric_vt->compute_mesh = fclaw2d_metric_compute_mesh_default; metric_vt->compute_area = fclaw2d_metric_compute_area_default; metric_vt->compute_area_ghost = fclaw2d_metric_compute_area_ghost_default; @@ -464,21 +333,13 @@ void fclaw2d_metric_vtable_initialize(fclaw2d_global_t* glob) metric_vt->fort_compute_normals = &FCLAW2D_METRIC_FORT_COMPUTE_NORMALS; metric_vt->fort_compute_tangents = &FCLAW2D_METRIC_FORT_COMPUTE_TANGENTS; metric_vt->fort_compute_surf_normals = &FCLAW2D_METRIC_FORT_COMPUTE_SURF_NORMALS; -#elif PATCH_DIM == 3 - metric_vt->compute_mesh = fclaw3d_metric_compute_mesh_default; - metric_vt->compute_volume = fclaw3d_metric_compute_volume_default; - metric_vt->compute_volume_ghost = fclaw3d_metric_compute_volume_ghost_default; - metric_vt->compute_basis = fclaw3d_metric_compute_basis_default; - - metric_vt->fort_compute_mesh = &FCLAW3D_METRIC_FORT_COMPUTE_MESH; - metric_vt->fort_compute_volume = &FCLAW3D_METRIC_FORT_COMPUTE_VOLUME; - metric_vt->fort_compute_basis = &FCLAW3D_METRIC_FORT_COMPUTE_BASIS; - -#endif metric_vt->is_set = 1; - FCLAW_ASSERT(fclaw_pointer_map_get(glob->vtables,METRIC_VTABLE_NAME) == NULL); + if(fclaw_pointer_map_get(glob->vtables,METRIC_VTABLE_NAME) != NULL) + { + fclaw_abortf("Metric vtable %s already set\n",METRIC_VTABLE_NAME); + } fclaw_pointer_map_insert(glob->vtables,METRIC_VTABLE_NAME, metric_vt, metric_vt_destroy); } @@ -488,91 +349,55 @@ void fclaw2d_metric_vtable_initialize(fclaw2d_global_t* glob) /* These functions are not virtualized and are not defined by the patch interface */ -fclaw2d_metric_patch_t* fclaw2d_metric_get_metric_patch(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) +fclaw2d_metric_patch_t* fclaw2d_metric_get_metric_patch(fclaw_global_t* glob, + fclaw_patch_t* patch) { return get_metric_patch(glob, patch); } -double* fclaw2d_metric_patch_get_area(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) +double* fclaw2d_metric_patch_get_area(fclaw_global_t* glob, + fclaw_patch_t* patch) { fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch); -#if PATCH_DIM == 2 return mp->area.dataPtr(); -#elif PATCH_DIM == 3 - return mp->volume.dataPtr(); -#endif } /* ----------- See fclaw3d_metric.cpp for 3d versions of functions below -------------- */ -#if PATCH_DIM == 2 -void fclaw2d_metric_patch_scalar(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, +void fclaw2d_metric_patch_scalar(fclaw_global_t* glob, + fclaw_patch_t* patch, double **area, double** edgelengths, double **curvature) -#elif PATCH_DIM == 3 -void fclaw3d_metric_patch_scalar(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **volume, double** faceareas) -#endif { fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch); -#if PATCH_DIM == 2 *area = mp->area.dataPtr(); *edgelengths = mp->edge_lengths.dataPtr(); *curvature = mp->curvature.dataPtr(); -#elif PATCH_DIM == 3 - *volume = mp->volume.dataPtr(); - *faceareas = mp->face_area.dataPtr(); -#endif } -#if PATCH_DIM == 2 -void fclaw2d_metric_patch_vector(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, +void fclaw2d_metric_patch_vector(struct fclaw_global* glob, + struct fclaw_patch* patch, double **xnormals, double **ynormals, double **xtangents, double **ytangents, double **surfnormals) -#elif PATCH_DIM == 3 -void fclaw3d_metric_patch_basis(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **xrot, double **yrot, double **zrot) -#endif { fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch); -#if PATCH_DIM == 2 *xnormals = mp->xface_normals.dataPtr(); *ynormals = mp->yface_normals.dataPtr(); *xtangents = mp->xface_tangents.dataPtr(); *ytangents = mp->yface_tangents.dataPtr(); *surfnormals = mp->surf_normals.dataPtr(); -#elif PATCH_DIM == 3 - *xrot = mp->xrot.dataPtr(); - *yrot = mp->yrot.dataPtr(); - *zrot = mp->zrot.dataPtr(); -#endif } -#if PATCH_DIM == 2 -void fclaw2d_metric_patch_grid_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, +void fclaw2d_metric_patch_grid_data(fclaw_global_t* glob, + fclaw_patch_t* patch, int* mx, int* my, int* mbc, double* xlower, double* ylower, double* dx, double* dy) -#elif PATCH_DIM == 3 -void fclaw3d_metric_patch_grid_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - int* mx, int* my, int* mz, - int* mbc, - double* xlower, double* ylower, double *zlower, - double* dx, double* dy, double* dz) -#endif { fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch); *mx = mp->mx; @@ -582,27 +407,14 @@ void fclaw3d_metric_patch_grid_data(fclaw2d_global_t* glob, *ylower = mp->ylower; *dx = mp->dx; *dy = mp->dy; -#if PATCH_DIM == 3 - *mz = mp->mz; - *zlower = mp->zlower; - *dz = mp->dz; -#endif } -#if PATCH_DIM == 2 -void fclaw2d_metric_patch_mesh_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, +void fclaw2d_metric_patch_mesh_data(fclaw_global_t* glob, + fclaw_patch_t* patch, double **xp, double **yp, double **zp, double **xd, double **yd, double **zd, double **area) -#elif PATCH_DIM == 3 -void fclaw3d_metric_patch_mesh_data(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, - double **xp, double **yp, double **zp, - double **xd, double **yd, double **zd, - double **volume, double** faceareas) -#endif { fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch); *xp = mp->xp.dataPtr(); @@ -611,17 +423,11 @@ void fclaw3d_metric_patch_mesh_data(fclaw2d_global_t* glob, *xd = mp->xd.dataPtr(); *yd = mp->yd.dataPtr(); *zd = mp->zd.dataPtr(); -#if PATCH_DIM == 2 *area = mp->area.dataPtr(); -#elif PATCH_DIM == 3 - *volume = mp->volume.dataPtr(); - *faceareas = mp->face_area.dataPtr(); -#endif } -#if PATCH_DIM == 2 -void fclaw2d_metric_patch_mesh_data2(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, +void fclaw2d_metric_patch_mesh_data2(fclaw_global_t* glob, + fclaw_patch_t* patch, double **xnormals, double **ynormals, double **xtangents, double **ytangents, double **surfnormals, @@ -636,10 +442,9 @@ void fclaw2d_metric_patch_mesh_data2(fclaw2d_global_t* glob, *curvature = mp->curvature.dataPtr(); *edgelengths = mp->edge_lengths.dataPtr(); } -#endif -int fclaw2d_metric_patch_nodes_size(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch) +int fclaw2d_metric_patch_nodes_size(fclaw_global_t* glob, + fclaw_patch_t* patch) { fclaw2d_metric_patch_t* mp = get_metric_patch(glob, patch); return mp->xd.size(); diff --git a/src/patches/metric/fclaw2d_metric.h b/src/patches/metric/fclaw2d_metric.h index 0b6d8ea29..4691f5096 100644 --- a/src/patches/metric/fclaw2d_metric.h +++ b/src/patches/metric/fclaw2d_metric.h @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef FCLAW2D_METRIC_H #define FCLAW2D_METRIC_H -#include /* Needed to get enum for build modes */ +#include /* Needed to get enum for build modes */ #include "fclaw2d_metric_default_fort.h" /* Needed for fort typdefs in vtable */ @@ -44,8 +44,8 @@ extern "C" /** Typedef for ::fclaw2d_metric_vtable */ typedef struct fclaw2d_metric_vtable fclaw2d_metric_vtable_t; -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; /* --------------------------- Metric routines (typedefs) ----------------------------- */ /** @@ -56,8 +56,8 @@ struct fclaw2d_patch; * @param[in] block_no the block number * @param[in] patchno the patch number */ -typedef void (*fclaw2d_metric_compute_mesh_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +typedef void (*fclaw2d_metric_compute_mesh_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int blockno, int patchno); @@ -69,8 +69,8 @@ typedef void (*fclaw2d_metric_compute_mesh_t)(struct fclaw2d_global *glob, * @param[in] block_no the block number * @param[in] patchno the patch number */ -typedef void (*fclaw2d_metric_compute_area_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*fclaw2d_metric_compute_area_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno); @@ -82,8 +82,8 @@ typedef void (*fclaw2d_metric_compute_area_t)(struct fclaw2d_global *glob, * @param[in] block_no the block number * @param[in] patchno the patch number */ -typedef void (*fclaw2d_metric_compute_area_ghost_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*fclaw2d_metric_compute_area_ghost_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno); @@ -95,8 +95,8 @@ typedef void (*fclaw2d_metric_compute_area_ghost_t)(struct fclaw2d_global *glob, * @param[in] block_no the block number * @param[in] patchno the patch number */ -typedef void (*fclaw2d_metric_compute_basis_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +typedef void (*fclaw2d_metric_compute_basis_t)(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int blockno, int patchno); @@ -117,14 +117,14 @@ typedef void (*fclaw2d_metric_compute_basis_t)(struct fclaw2d_global *glob, * @param[in] patchno the patch number * @param[in] build_mode the build mode */ -void fclaw2d_metric_patch_define(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fclaw2d_metric_patch_define(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int mx, int my, int mbc, double dx, double dy, double xlower, double ylower, double xupper, double yupper, int blockno, int patchno, - fclaw2d_build_mode_t build_mode); + fclaw_build_mode_t build_mode); /** @@ -135,8 +135,8 @@ void fclaw2d_metric_patch_define(struct fclaw2d_global* glob, * @param[in] blockno the block number * @param[in] patchno the patch number */ -void fclaw2d_metric_patch_build(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_metric_patch_build(struct fclaw_global* glob, + struct fclaw_patch* this_patch, int blockno, int patchno); @@ -150,9 +150,9 @@ void fclaw2d_metric_patch_build(struct fclaw2d_global* glob, * @param[in] coarse_patchno the block number of the coarse patch * @param[in] fine0_patchno the patch number of the first fine patch */ -void fclaw2d_metric_patch_build_from_fine(struct fclaw2d_global *glob, - struct fclaw2d_patch *fine_patches, - struct fclaw2d_patch *coarse_coarse, +void fclaw2d_metric_patch_build_from_fine(struct fclaw_global *glob, + struct fclaw_patch *fine_patches, + struct fclaw_patch *coarse_coarse, int blockno, int coarse_patchno, int fine0_patchno); @@ -164,8 +164,8 @@ void fclaw2d_metric_patch_build_from_fine(struct fclaw2d_global *glob, * @param[in] blockno the block number * @param[in] patchno the patch number */ -void fclaw2d_metric_patch_compute_area(struct fclaw2d_global *glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_metric_patch_compute_area(struct fclaw_global *glob, + struct fclaw_patch* this_patch, int blockno, int patchno); /* --------------------------------- Access functions --------------------------------- */ @@ -180,8 +180,8 @@ void fclaw2d_metric_patch_compute_area(struct fclaw2d_global *glob, * @param[out] xlower, ylower the coordinate of the lower left corner * @param[out] dx, dy the spacings in the x and y directions */ -void fclaw2d_metric_patch_grid_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_metric_patch_grid_data(struct fclaw_global* glob, + struct fclaw_patch* this_patch, int* mx, int* my, int* mbc, double* xlower, double* ylower, double* dx, double* dy); @@ -198,8 +198,8 @@ void fclaw2d_metric_patch_grid_data(struct fclaw2d_global* glob, * (i,j,2) contains the the left edge length for cell (i,j). * @param[out] curvature the curvature for each cell in the patch */ -void fclaw2d_metric_patch_scalar(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_metric_patch_scalar(struct fclaw_global* glob, + struct fclaw_patch* this_patch, double **area, double** edgelengths, double **curvature); @@ -219,8 +219,8 @@ void fclaw2d_metric_patch_scalar(struct fclaw2d_global* glob, * @param[out] surfnormals the surface normal for each cell center of the patch * An array of dimension(-mbc:mx+mbc+1,-mbc:my+mbc+1,3) */ -void fclaw2d_metric_patch_vector(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_metric_patch_vector(struct fclaw_global* glob, + struct fclaw_patch* this_patch, double **xnormals, double **ynormals, double **xtangents, double **ytangents, double **surfnormals); @@ -234,8 +234,8 @@ void fclaw2d_metric_patch_vector(struct fclaw2d_global* glob, * @param[out] xd, yd, zd the coordinates of the nodes * @param[out] area the area of each cell */ -void fclaw2d_metric_patch_mesh_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_metric_patch_mesh_data(struct fclaw_global* glob, + struct fclaw_patch* this_patch, double **xp, double **yp, double **zp, double **xd, double **yd, double **zd, double **area); @@ -261,8 +261,8 @@ void fclaw2d_metric_patch_mesh_data(struct fclaw2d_global* glob, * (i,j,2) contains the the left edge length for cell (i,j). * @param[out] curvature the curvature for each cell in the patch */ -void fclaw2d_metric_patch_mesh_data2(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_metric_patch_mesh_data2(struct fclaw_global* glob, + struct fclaw_patch* this_patch, double **xnormals, double **ynormals, double **xtangents, double **ytangents, double **surfnormals, @@ -275,8 +275,8 @@ void fclaw2d_metric_patch_mesh_data2(struct fclaw2d_global* glob, * @param this_patch the patch to get the are for * @return double* the area array */ -double* fclaw2d_metric_patch_get_area(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch); +double* fclaw2d_metric_patch_get_area(struct fclaw_global* glob, + struct fclaw_patch* this_patch); /* ---------------------------- Metric default (virtualized) -------------------------- */ @@ -288,8 +288,8 @@ double* fclaw2d_metric_patch_get_area(struct fclaw2d_global* glob, * * @details @copydetails ::fclaw2d_metric_compute_area_t */ -void fclaw2d_metric_compute_area_default(struct fclaw2d_global *glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_metric_compute_area_default(struct fclaw_global *glob, + struct fclaw_patch* this_patch, int blockno, int patchno); @@ -300,8 +300,8 @@ void fclaw2d_metric_compute_area_default(struct fclaw2d_global *glob, * * @details @copydetails ::fclaw2d_metric_compute_area_ghost_t */ -void fclaw2d_metric_compute_area_ghost_default(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +void fclaw2d_metric_compute_area_ghost_default(struct fclaw_global* glob, + struct fclaw_patch* this_patch, int blockno, int patchno); @@ -314,8 +314,8 @@ void fclaw2d_metric_compute_area_ghost_default(struct fclaw2d_global* glob, * * @details @copydetails ::fclaw2d_metric_compute_mesh_t */ -void fclaw2d_metric_compute_mesh_default(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fclaw2d_metric_compute_mesh_default(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int blockno, int patchno); @@ -327,8 +327,8 @@ void fclaw2d_metric_compute_mesh_default(struct fclaw2d_global *glob, * * @details @copydetails ::fclaw2d_metric_compute_basis_t */ -void fclaw2d_metric_compute_basis_default(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fclaw2d_metric_compute_basis_default(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int blockno, int patchno); @@ -369,15 +369,15 @@ struct fclaw2d_metric_vtable * * @return fclaw2d_metric_vtable_t* the vtable */ -fclaw2d_metric_vtable_t* fclaw2d_metric_vt(struct fclaw2d_global* glob); +fclaw2d_metric_vtable_t* fclaw2d_metric_vt(struct fclaw_global* glob); /** * @brief Initializes a global vtable variable */ -void fclaw2d_metric_vtable_initialize(struct fclaw2d_global* glob); +void fclaw2d_metric_vtable_initialize(struct fclaw_global* glob); -int fclaw2d_metric_patch_nodes_size(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +int fclaw2d_metric_patch_nodes_size(struct fclaw_global* glob, + struct fclaw_patch* patch); diff --git a/src/patches/metric/fclaw2d_metric.h.TEST.cpp b/src/patches/metric/fclaw2d_metric.h.TEST.cpp index c0aa0a959..c7d59dcf9 100644 --- a/src/patches/metric/fclaw2d_metric.h.TEST.cpp +++ b/src/patches/metric/fclaw2d_metric.h.TEST.cpp @@ -23,49 +23,49 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include TEST_CASE("fclaw2d_metric_vtable_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fclaw2d_metric_vtable_initialize(glob1); fclaw2d_metric_vtable_initialize(glob2); CHECK_NE(fclaw2d_metric_vt(glob1), fclaw2d_metric_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fclaw2d_metric_vtable_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_global_t* glob = fclaw_global_new(); fclaw2d_metric_vtable_initialize(glob); CHECK_UNARY(fclaw2d_metric_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fclaw2d_metric_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fclaw2d_metric_vtable_initialize(glob1); CHECK_SC_ABORTED(fclaw2d_metric_vtable_initialize(glob1)); fclaw2d_metric_vtable_initialize(glob2); CHECK_SC_ABORTED(fclaw2d_metric_vtable_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/patches/metric/fclaw2d_metric.hpp b/src/patches/metric/fclaw2d_metric.hpp index 2c53d700b..48e229445 100644 --- a/src/patches/metric/fclaw2d_metric.hpp +++ b/src/patches/metric/fclaw2d_metric.hpp @@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef FCLAW2D_METRIC_HPP #define FCLAW2D_METRIC_HPP -#include /* Needed for FArray box used to store metric data */ +#include /* Needed for FArray box used to store metric data */ /** * @brief Struct for patch metric data diff --git a/src/patches/metric/fclaw2d_metric_default.c b/src/patches/metric/fclaw2d_metric_default.c index 52b6abff8..5f9644e4d 100644 --- a/src/patches/metric/fclaw2d_metric_default.c +++ b/src/patches/metric/fclaw2d_metric_default.c @@ -23,16 +23,16 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include "fclaw2d_metric.h" #include "fclaw2d_metric_default_fort.h" -void fclaw2d_metric_compute_mesh_default(fclaw2d_global_t *glob, - fclaw2d_patch_t* patch, +void fclaw2d_metric_compute_mesh_default(fclaw_global_t *glob, + fclaw_patch_t* patch, int blockno, int patchno) { @@ -56,8 +56,8 @@ void fclaw2d_metric_compute_mesh_default(fclaw2d_global_t *glob, } -void fclaw2d_metric_compute_basis_default(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fclaw2d_metric_compute_basis_default(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -107,8 +107,8 @@ void fclaw2d_metric_compute_basis_default(fclaw2d_global_t *glob, } -void fclaw2d_metric_compute_area_default(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fclaw2d_metric_compute_area_default(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -119,7 +119,7 @@ void fclaw2d_metric_compute_area_default(fclaw2d_global_t *glob, double *area = fclaw2d_metric_patch_get_area(glob, patch); - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int level = patch->level; int maxlevel = fclaw_opt->maxlevel; int refratio = fclaw_opt->refratio; @@ -134,8 +134,8 @@ void fclaw2d_metric_compute_area_default(fclaw2d_global_t *glob, FCLAW_FREE(quadstore); } -void fclaw2d_metric_compute_area_ghost_default(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, +void fclaw2d_metric_compute_area_ghost_default(fclaw_global_t* glob, + fclaw_patch_t* patch, int blockno, int patchno) { @@ -148,7 +148,7 @@ void fclaw2d_metric_compute_area_ghost_default(fclaw2d_global_t* glob, double *area = fclaw2d_metric_patch_get_area(glob, patch); /* Set area in ghost cells not set above */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int level = patch->level; int maxlevel = fclaw_opt->maxlevel; int refratio = fclaw_opt->refratio; diff --git a/src/patches/metric/fclaw3d_metric.cpp b/src/patches/metric/fclaw3d_metric.cpp index 3ce8ed0dd..cc9dc6c24 100644 --- a/src/patches/metric/fclaw3d_metric.cpp +++ b/src/patches/metric/fclaw3d_metric.cpp @@ -24,9 +24,437 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define REFINE_DIM 2 -#define PATCH_DIM 3 +#if 0 +/* Fix syntax highlighting */ +#endif -#include +#define METRIC_VTABLE_NAME "fclaw3d_metric" +#include "fclaw3d_metric.h" +#include "fclaw3d_metric.hpp" +#include + +#include +#include +#include + +static +fclaw3d_metric_patch_t* get_metric_patch(fclaw_global_t* glob, + fclaw_patch_t *patch) +{ + return (fclaw3d_metric_patch_t*) fclaw_patch_metric_patch(glob, patch); +} + + +/* ----------------------------- Creating/deleting patches ---------------------------- */ + +fclaw3d_metric_patch_t* fclaw3d_metric_patch_new() +{ + fclaw3d_metric_patch_t *mp = new fclaw3d_metric_patch_t; + return mp; +} + +void fclaw3d_metric_patch_delete(fclaw3d_metric_patch_t **mp) +{ + FCLAW_ASSERT(mp != NULL); + delete *mp; + *mp = NULL; +} + + +void fclaw3d_metric_patch_define(fclaw_global_t* glob, + fclaw_patch_t* patch, + int mx, int my, int mz, int mbc, + double dx, double dy,double dz, + double xlower, double ylower, double zlower, + double xupper, double yupper, double zupper, + int blockno, int patchno, + fclaw_build_mode_t build_mode) +{ + fclaw3d_metric_patch_t* mp = get_metric_patch(glob, patch); + + mp->mx = mx; + mp->my = my; + mp->mz = mz; + mp->mbc = mbc; + mp->blockno = blockno; + + mp->dx = dx; + mp->dy = dy; + mp->dz = dz; + mp->xlower = xlower; + mp->ylower = ylower; + mp->zlower = zlower; + mp->xupper = xupper; + mp->yupper = yupper; + mp->zupper = zupper; + + + /* Set up area for storage - this is needed for ghost patches, + and updated patches */ + Box box_p, box_d; + { + /* Create box for primary grid (cell-centered) */ + int ll_p[FCLAW3D_SPACEDIM]; + int ur_p[FCLAW3D_SPACEDIM]; + for (int idir = 0; idir < FCLAW3D_SPACEDIM; idir++) + { + ll_p[idir] = -mbc; + } + ur_p[0] = mp->mx + mbc + 1; + ur_p[1] = mp->my + mbc + 1; + ur_p[2] = mp->mz + mbc + 1; + + box_p = Box(ll_p,ur_p,FCLAW3D_SPACEDIM); + + + /* Create box for nodes (cell corners) */ + int ll_d[FCLAW3D_SPACEDIM]; + int ur_d[FCLAW3D_SPACEDIM]; + + /* Create node centered box */ + for (int idir = 0; idir < FCLAW3D_SPACEDIM; idir++) + { + ll_d[idir] = -mbc; + } + ur_d[0] = mp->mx + mbc + 2; + ur_d[1] = mp->my + mbc + 2; + ur_d[2] = mp->mz + mbc + 2; + + box_d = Box(ll_d,ur_d,FCLAW3D_SPACEDIM); + + + /* volume is needed in ghost patches for averaging. The face area is + only needed if we are updating a cell, but since volume and + face area are computed together, we should also allocate memory + for face areas + */ + mp->volume.define(box_p,1); + mp->face_area.define(box_d,3); + + /* Node values are needed by parallel ghost patches when we have an + affine map. In this case, the affine map can use pre-computed xd,yd,zd + values. + + Note: This should be revisited since we are doing extra work for the affine + map. + */ + mp->xd.define(box_d,1); + mp->yd.define(box_d,1); + mp->zd.define(box_d,1); + } + + + /* Only allocate memory that is needed */ + if (build_mode != FCLAW_BUILD_FOR_GHOST_AREA_PACKED + && build_mode == FCLAW_BUILD_FOR_UPDATE) + { + /* + From here on out, we build for patches that get updated + + In 2d manifold : + 24 additional field variables needed for all metric terms on a + manifold + xp,yp,zp : 3 + xd,yd,zd : 3 + surf_normals : 3 (3x1 vector) + curvature : 1 + area : 1 + face normals : 6 (2 3x1 vectors) + face tangents : 6 (2 3x1 vectors) + edge lengths : 2 + ----------------------- + Total : 25 + + In 3d : + 36 additional field variables needed for all metric terms + xp,yp,zp : 3 + xd,yd,zd : 3 + face areas : 3 + volume : 1 + rotation matrix : 27 (3 3x3 matrices) + ----------------------- + Total : 37 + + We should come up with a way to store only what is needed + */ + + /* Mesh cell centers of physical mesh */ + mp->xp.define(box_p,1); + mp->yp.define(box_p,1); + mp->zp.define(box_p,1); + + /* Store face areas of left, front, bottom edge of box */ + //mp->face_area.define(box_d,3); + + /* Store 3x3 rotation matrix for each of three faces */ + mp->xrot.define(box_d,9); + mp->yrot.define(box_d,9); + mp->zrot.define(box_d,9); + + } +} + + + +/* For 3d extruded mesh, this averages cell volumes */ +static +void metric_average_area_from_fine(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + fclaw_patch_t *coarse_patch, + int blockno, + int coarse_patchno, + int fine0_patchno) +{ + if(glob->domain->refine_dim == 3) + { + fclaw_abortf("Metric averaging not implemented for oct-trees.\n"); + } + + fclaw3d_metric_vtable_t *metric_vt = fclaw3d_metric_vt(glob); + int mx,my,mz, mbc; + double xlower,ylower,zlower,dx,dy,dz; + + fclaw3d_metric_patch_grid_data(glob,coarse_patch,&mx,&my,&mz,&mbc, + &xlower,&ylower,&zlower,&dx,&dy,&dz); + double *volcoarse, *fa_coarse; + fclaw3d_metric_patch_scalar(glob,coarse_patch,&volcoarse, &fa_coarse); + + + for(int igrid = 0; igrid < 4; igrid++) + { + double *volfine, *fa_fine; + fclaw3d_metric_patch_scalar(glob,&fine_patches[igrid],&volfine, &fa_fine); + + /* Average from fine to coarse when creating coarse grid from a fine grid. + This will be exact, since both volume and face areas are computing at + finest level resolution. + */ + FCLAW3DX_METRIC_FORT_AVERAGE_VOLUME(&mx,&my,&mz, &mbc, + volcoarse,volfine, + &igrid); + + FCLAW3DX_METRIC_FORT_AVERAGE_FACEAREA(&mx,&my,&mz, &mbc, + fa_coarse,fa_fine, &igrid); + } + +/* Compute volume from scratch in second layer of coarse grid ghost cells. These + are not averaged from the fine grid (first layer can be averaged from fine + grid, however) +*/ + metric_vt->compute_volume_ghost(glob,coarse_patch,blockno,coarse_patchno); +} + +/* --------------------------------- Public interface -------------------------------- */ + +void fclaw3d_metric_patch_compute_volume (fclaw_global_t *glob, + fclaw_patch_t* patch, + int blockno, int patchno) +{ + fclaw3d_metric_vtable_t *metric_vt = fclaw3d_metric_vt(glob); + FCLAW_ASSERT(metric_vt->compute_volume); + metric_vt->compute_volume(glob,patch,blockno,patchno); +} + + +void fclaw3d_metric_patch_build(fclaw_global_t* glob, + fclaw_patch_t* patch, + int blockno, + int patchno) +{ + fclaw3d_metric_vtable_t *metric_vt = fclaw3d_metric_vt(glob); + FCLAW_ASSERT(metric_vt != NULL); + + /* Compute (xp,yp,zp) and (xd,yd,zd) */ + metric_vt->compute_mesh(glob,patch,blockno,patchno); + + /* Compute areas/volumes ($$$) from scratch. + Note : These are all computed on finest level + mesh and averaged down to coarser meshes. This is + required from geometric consistency */ + /* Compute 3d volumes and 2d face areas */ + metric_vt->compute_volume(glob,patch,blockno,patchno); + if (metric_vt->compute_basis != NULL) + { + /* In 2d : Surface normals, tangents, edge lengths, + surface normals and curvature. + + In 3d : Rotation matrix at each face. + */ + metric_vt->compute_basis(glob,patch,blockno,patchno); + } +} + + + +void fclaw3d_metric_patch_build_from_fine(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + fclaw_patch_t *coarse_patch, + int blockno, + int coarse_patchno, + int fine0_patchno) +{ + /* This routine does a complete build using fine grid data to average + volumes and in 3d, face areas */ + fclaw3d_metric_vtable_t *metric_vt = fclaw3d_metric_vt(glob); + + /* Compute xd,yd,zd, xp,yp,zp */ + metric_vt->compute_mesh(glob,coarse_patch,blockno,coarse_patchno); + + /* Compute areas/volumes by averaging from finer grids */ + + metric_average_area_from_fine(glob,fine_patches,coarse_patch, + blockno, coarse_patchno, + fine0_patchno); + + if (metric_vt->compute_basis != NULL) + { + /* In 2d : Surface normals and tangents at each face + In 3d : Rotation matrix for each face. + + Note : These are not averaged from finer grids, but are + built from scratch here. + */ + metric_vt->compute_basis(glob,coarse_patch,blockno,coarse_patchno); + } +} + + + +/* ------------------------------------ Virtual table -------------------------------- */ + +static +fclaw3d_metric_vtable_t* metric_vt_new() +{ + return (fclaw3d_metric_vtable_t*) FCLAW_ALLOC_ZERO (fclaw3d_metric_vtable_t, 1); +} + +static +void metric_vt_destroy(void* vt) +{ + FCLAW_FREE (vt); +} + +fclaw3d_metric_vtable_t* fclaw3d_metric_vt(fclaw_global_t* glob) +{ + fclaw3d_metric_vtable_t* metric_vt = (fclaw3d_metric_vtable_t*) + fclaw_pointer_map_get(glob->vtables, METRIC_VTABLE_NAME); + FCLAW_ASSERT(metric_vt != NULL); + FCLAW_ASSERT(metric_vt->is_set != 0); + return metric_vt; +} + + +void fclaw3d_metric_vtable_initialize(fclaw_global_t* glob) +{ + fclaw3d_metric_vtable_t *metric_vt = metric_vt_new(); + + + /* Fortran files */ + metric_vt->compute_mesh = fclaw3d_metric_compute_mesh_default; + metric_vt->compute_volume = fclaw3d_metric_compute_volume_default; + metric_vt->compute_volume_ghost = fclaw3d_metric_compute_volume_ghost_default; + metric_vt->compute_basis = fclaw3d_metric_compute_basis_default; + + metric_vt->fort_compute_mesh = &FCLAW3D_METRIC_FORT_COMPUTE_MESH; + metric_vt->fort_compute_volume = &FCLAW3D_METRIC_FORT_COMPUTE_VOLUME; + metric_vt->fort_compute_basis = &FCLAW3D_METRIC_FORT_COMPUTE_BASIS; + + metric_vt->is_set = 1; + + if(fclaw_pointer_map_get(glob->vtables,METRIC_VTABLE_NAME) != NULL) + { + fclaw_abortf("Metric vtable %s already set\n",METRIC_VTABLE_NAME); + } + fclaw_pointer_map_insert(glob->vtables,METRIC_VTABLE_NAME, metric_vt, metric_vt_destroy); +} + + +/* --------------------------------- Misc access functions ---------------------------- */ + +/* These functions are not virtualized and are not defined by the + patch interface */ + +fclaw3d_metric_patch_t* fclaw3d_metric_get_metric_patch(fclaw_global_t* glob, + fclaw_patch_t* patch) + +{ + return get_metric_patch(glob, patch); +} + +double* fclaw3d_metric_patch_get_volume(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw3d_metric_patch_t* mp = get_metric_patch(glob, patch); + return mp->volume.dataPtr(); +} + + +/* ----------- See fclaw3d_metric.cpp for 3d versions of functions below -------------- */ + +void fclaw3d_metric_patch_scalar(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **volume, double** faceareas) +{ + fclaw3d_metric_patch_t* mp = get_metric_patch(glob, patch); + *volume = mp->volume.dataPtr(); + *faceareas = mp->face_area.dataPtr(); +} + + + +void fclaw3d_metric_patch_basis(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **xrot, double **yrot, double **zrot) +{ + fclaw3d_metric_patch_t* mp = get_metric_patch(glob, patch); + *xrot = mp->xrot.dataPtr(); + *yrot = mp->yrot.dataPtr(); + *zrot = mp->zrot.dataPtr(); +} + +void fclaw3d_metric_patch_grid_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + int* mx, int* my, int* mz, + int* mbc, + double* xlower, double* ylower, double *zlower, + double* dx, double* dy, double* dz) +{ + fclaw3d_metric_patch_t* mp = get_metric_patch(glob, patch); + *mx = mp->mx; + *my = mp->my; + *mz = mp->mz; + *mbc = mp->mbc; + *xlower = mp->xlower; + *ylower = mp->ylower; + *zlower = mp->zlower; + *dx = mp->dx; + *dy = mp->dy; + *dz = mp->dz; +} + + +void fclaw3d_metric_patch_mesh_data(fclaw_global_t* glob, + fclaw_patch_t* patch, + double **xp, double **yp, double **zp, + double **xd, double **yd, double **zd, + double **volume, double** faceareas) +{ + fclaw3d_metric_patch_t* mp = get_metric_patch(glob, patch); + *xp = mp->xp.dataPtr(); + *yp = mp->yp.dataPtr(); + *zp = mp->zp.dataPtr(); + *xd = mp->xd.dataPtr(); + *yd = mp->yd.dataPtr(); + *zd = mp->zd.dataPtr(); + *volume = mp->volume.dataPtr(); + *faceareas = mp->face_area.dataPtr(); +} + +int fclaw3d_metric_patch_nodes_size(fclaw_global_t* glob, + fclaw_patch_t* patch) +{ + fclaw3d_metric_patch_t* mp = get_metric_patch(glob, patch); + return mp->xd.size(); +} \ No newline at end of file diff --git a/src/patches/metric/fclaw3d_metric.h b/src/patches/metric/fclaw3d_metric.h index d73b8b0e3..0c51efb3b 100644 --- a/src/patches/metric/fclaw3d_metric.h +++ b/src/patches/metric/fclaw3d_metric.h @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef FCLAW3D_METRIC_H #define FCLAW3D_METRIC_H -#include /* Needed to get enum for build modes */ +#include /* Needed to get enum for build modes */ #include "fclaw3d_metric_default_fort.h" /* Needed for fort typdefs in vtable */ @@ -49,8 +49,8 @@ extern "C" /** Typedef for ::fclaw3d_metric_vtable */ typedef struct fclaw3d_metric_vtable fclaw3d_metric_vtable_t; -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; /* --------------------------- Metric routines (typedefs) ----------------------------- */ /** @@ -61,8 +61,8 @@ struct fclaw2d_patch; * @param[in] block_no the block number * @param[in] patchno the patch number */ -typedef void (*fclaw3d_metric_compute_mesh_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*fclaw3d_metric_compute_mesh_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno); @@ -74,8 +74,8 @@ typedef void (*fclaw3d_metric_compute_mesh_t)(struct fclaw2d_global *glob, * @param[in] block_no the block number * @param[in] patchno the patch number */ -typedef void (*fclaw3d_metric_compute_volume_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*fclaw3d_metric_compute_volume_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno); @@ -87,8 +87,8 @@ typedef void (*fclaw3d_metric_compute_volume_t)(struct fclaw2d_global *glob, * @param[in] block_no the block number * @param[in] patchno the patch number */ -typedef void (*fclaw3d_metric_compute_volume_ghost_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*fclaw3d_metric_compute_volume_ghost_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno); @@ -101,8 +101,8 @@ typedef void (*fclaw3d_metric_compute_volume_ghost_t)(struct fclaw2d_global *glo * @param[in] patchno the patch number */ -typedef void (*fclaw3d_metric_compute_basis_t)(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +typedef void (*fclaw3d_metric_compute_basis_t)(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno); @@ -124,15 +124,15 @@ typedef void (*fclaw3d_metric_compute_basis_t)(struct fclaw2d_global *glob, * @param[in] build_mode the build mode */ -void fclaw3d_metric_patch_define(struct fclaw2d_global* glob, - struct fclaw2d_patch *patch, +void fclaw3d_metric_patch_define(struct fclaw_global* glob, + struct fclaw_patch *patch, int mx, int my, int mz, int mbc, double dx, double dy, double dz, double xlower, double ylower, double zlower, double xupper, double yupper, double zupper, int blockno, int patchno, - fclaw2d_build_mode_t build_mode); + fclaw_build_mode_t build_mode); /** @@ -143,8 +143,8 @@ void fclaw3d_metric_patch_define(struct fclaw2d_global* glob, * @param[in] blockno the block number * @param[in] patchno the patch number */ -void fclaw3d_metric_patch_build(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, +void fclaw3d_metric_patch_build(struct fclaw_global* glob, + struct fclaw_patch* patch, int blockno, int patchno); @@ -158,9 +158,9 @@ void fclaw3d_metric_patch_build(struct fclaw2d_global* glob, * @param[in] coarse_patchno the block number of the coarse patch * @param[in] fine0_patchno the patch number of the first fine patch */ -void fclaw3d_metric_patch_build_from_fine(struct fclaw2d_global *glob, - struct fclaw2d_patch *fine_patches, - struct fclaw2d_patch *coarse_coarse, +void fclaw3d_metric_patch_build_from_fine(struct fclaw_global *glob, + struct fclaw_patch *fine_patches, + struct fclaw_patch *coarse_coarse, int blockno, int coarse_patchno, int fine0_patchno); @@ -172,8 +172,8 @@ void fclaw3d_metric_patch_build_from_fine(struct fclaw2d_global *glob, * @param[in] blockno the block number * @param[in] patchno the patch number */ -void fclaw3d_metric_patch_compute_volume(struct fclaw2d_global *glob, - struct fclaw2d_patch* patch, +void fclaw3d_metric_patch_compute_volume(struct fclaw_global *glob, + struct fclaw_patch* patch, int blockno, int patchno); /* --------------------------------- Access functions --------------------------------- */ @@ -188,8 +188,8 @@ void fclaw3d_metric_patch_compute_volume(struct fclaw2d_global *glob, * @param[out] xlower, ylower the coordinate of the lower left corner * @param[out] dx, dy the spacings in the x and y directions */ -void fclaw3d_metric_patch_grid_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, +void fclaw3d_metric_patch_grid_data(struct fclaw_global* glob, + struct fclaw_patch* patch, int* mx, int* my, int* mz, int* mbc, double* xlower, double* ylower, double* zlower, @@ -207,8 +207,8 @@ void fclaw3d_metric_patch_grid_data(struct fclaw2d_global* glob, * (i,j,k,2) contains the area of face with normal (0,1,0) (front face) * (i,j,k,3) contains the area of face with normal (0,0,1) (bottom face) */ -void fclaw3d_metric_patch_scalar(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, +void fclaw3d_metric_patch_scalar(struct fclaw_global* glob, + struct fclaw_patch* patch, double **volume, double** faceareas); /** @@ -221,8 +221,8 @@ void fclaw3d_metric_patch_scalar(struct fclaw2d_global* glob, * where 'N' is user-defined value for the number of components * to store (maximum is 3x(3x3) = 27) */ -void fclaw3d_metric_patch_basis(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, +void fclaw3d_metric_patch_basis(struct fclaw_global* glob, + struct fclaw_patch* patch, double **xrot, double **yrot, double **zrot); /** @@ -234,8 +234,8 @@ void fclaw3d_metric_patch_basis(struct fclaw2d_global* glob, * @param[out] xd, yd, zd the coordinates of the nodes * @param[out] area the area of each cell */ -void fclaw3d_metric_patch_mesh_data(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, +void fclaw3d_metric_patch_mesh_data(struct fclaw_global* glob, + struct fclaw_patch* patch, double **xp, double **yp, double **zp, double **xd, double **yd, double **zd, double **volume, double** faceareas); @@ -252,7 +252,7 @@ void fclaw3d_metric_patch_mesh_data(struct fclaw2d_global* glob, * (i,j,k,2) contains the area of face with normal (0,1,0) (front face) * (i,j,k,3) contains the area of face with normal (0,0,1) (bottom face) */ -void fclaw3d_metric_patch_mesh_data2(struct fclaw2d_global* glob, +void fclaw3d_metric_patch_mesh_data2(struct fclaw_global* glob, struct fclaw2d_patch* patch, double **xrot, double **yrot, double **zrot); #endif @@ -264,8 +264,8 @@ void fclaw3d_metric_patch_mesh_data2(struct fclaw2d_global* glob, * @param patch the patch to get the are for * @return double* the area array */ -double* fclaw3d_metric_patch_get_volume(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +double* fclaw3d_metric_patch_get_volume(struct fclaw_global* glob, + struct fclaw_patch* patch); /* ---------------------------- Metric default (virtualized) -------------------------- */ @@ -277,8 +277,8 @@ double* fclaw3d_metric_patch_get_volume(struct fclaw2d_global* glob, * * @details @copydetails ::fclaw3d_metric_compute_area_t */ -void fclaw3d_metric_compute_volume_default(struct fclaw2d_global *glob, - struct fclaw2d_patch* patch, +void fclaw3d_metric_compute_volume_default(struct fclaw_global *glob, + struct fclaw_patch* patch, int blockno, int patchno); @@ -289,8 +289,8 @@ void fclaw3d_metric_compute_volume_default(struct fclaw2d_global *glob, * * @details @copydetails ::fclaw3d_metric_compute_area_ghost_t */ -void fclaw3d_metric_compute_volume_ghost_default(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch, +void fclaw3d_metric_compute_volume_ghost_default(struct fclaw_global* glob, + struct fclaw_patch* patch, int blockno, int patchno); @@ -303,8 +303,8 @@ void fclaw3d_metric_compute_volume_ghost_default(struct fclaw2d_global* glob, * * @details @copydetails ::fclaw3d_metric_compute_mesh_t */ -void fclaw3d_metric_compute_mesh_default(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +void fclaw3d_metric_compute_mesh_default(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno); @@ -317,8 +317,8 @@ void fclaw3d_metric_compute_mesh_default(struct fclaw2d_global *glob, * @details @copydetails ::fclaw3d_metric_compute_tensors_t */ -void fclaw3d_metric_compute_basis_default(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch, +void fclaw3d_metric_compute_basis_default(struct fclaw_global *glob, + struct fclaw_patch *patch, int blockno, int patchno); @@ -365,16 +365,16 @@ struct fclaw3d_metric_vtable * * @return fclaw3d_metric_vtable_t* the vtable */ -fclaw3d_metric_vtable_t* fclaw3d_metric_vt(struct fclaw2d_global* glob); +fclaw3d_metric_vtable_t* fclaw3d_metric_vt(struct fclaw_global* glob); /** * @brief Initializes a global vtable variable */ -void fclaw3d_metric_vtable_initialize(struct fclaw2d_global* glob); +void fclaw3d_metric_vtable_initialize(struct fclaw_global* glob); -int fclaw3d_metric_patch_nodes_size(struct fclaw2d_global* glob, - struct fclaw2d_patch* patch); +int fclaw3d_metric_patch_nodes_size(struct fclaw_global* glob, + struct fclaw_patch* patch); #ifdef __cplusplus diff --git a/src/patches/metric/fclaw3d_metric.hpp b/src/patches/metric/fclaw3d_metric.hpp index f67f84224..24407ac81 100644 --- a/src/patches/metric/fclaw3d_metric.hpp +++ b/src/patches/metric/fclaw3d_metric.hpp @@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef FCLAW3D_METRIC_HPP #define FCLAW3D_METRIC_HPP -#include /* Needed for FArray box used to store metric data */ +#include /* Needed for FArray box used to store metric data */ /** * @brief Struct for patch metric data diff --git a/src/patches/metric/fclaw3d_metric_default.c b/src/patches/metric/fclaw3d_metric_default.c index 2603db226..7dff01b95 100644 --- a/src/patches/metric/fclaw3d_metric_default.c +++ b/src/patches/metric/fclaw3d_metric_default.c @@ -23,16 +23,16 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include "fclaw3d_metric.h" #include "fclaw3d_metric_default_fort.h" -void fclaw3d_metric_compute_mesh_default(fclaw2d_global_t *glob, - fclaw2d_patch_t* patch, +void fclaw3d_metric_compute_mesh_default(fclaw_global_t *glob, + fclaw_patch_t* patch, int blockno, int patchno) { @@ -59,8 +59,8 @@ void fclaw3d_metric_compute_mesh_default(fclaw2d_global_t *glob, } -void fclaw3d_metric_compute_basis_default(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fclaw3d_metric_compute_basis_default(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -93,8 +93,8 @@ void fclaw3d_metric_compute_basis_default(fclaw2d_global_t *glob, } -void fclaw3d_metric_compute_volume_default(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fclaw3d_metric_compute_volume_default(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -103,7 +103,7 @@ void fclaw3d_metric_compute_volume_default(fclaw2d_global_t *glob, fclaw3d_metric_patch_grid_data(glob,patch,&mx,&my,&mz,&mbc, &xlower,&ylower,&zlower,&dx,&dy,&dz); - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int level = patch->level; int maxlevel = fclaw_opt->maxlevel; int refratio = 2; @@ -144,8 +144,8 @@ void fclaw3d_metric_compute_volume_default(fclaw2d_global_t *glob, FCLAW_FREE(hexstore); } -void fclaw3d_metric_compute_volume_ghost_default(fclaw2d_global_t* glob, - fclaw2d_patch_t* patch, +void fclaw3d_metric_compute_volume_ghost_default(fclaw_global_t* glob, + fclaw_patch_t* patch, int blockno, int patchno) { @@ -163,7 +163,7 @@ void fclaw3d_metric_compute_volume_ghost_default(fclaw2d_global_t* glob, /* Set area in ghost cells not set above */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); int level = patch->level; int maxlevel = fclaw_opt->maxlevel; int refratio = fclaw_opt->refratio; diff --git a/src/patches/metric/fortran_source2d/fclaw2d_metric_default_fort.f90 b/src/patches/metric/fortran_source2d/fclaw2d_metric_default_fort.f90 index 2968d07bd..ff492ed6c 100644 --- a/src/patches/metric/fortran_source2d/fclaw2d_metric_default_fort.f90 +++ b/src/patches/metric/fortran_source2d/fclaw2d_metric_default_fort.f90 @@ -43,7 +43,7 @@ subroutine fclaw2d_metric_fort_compute_mesh(mx,my,mbc, & yc = ylower + (j-1)*dyf - call fclaw2d_map_c2m(map_context_ptr, & + call fclaw_map_2d_c2m(map_context_ptr, & blockno,xc,yc,xd1,yd1,zd1) if (abs(mod(i,2)) .eq. 1) then @@ -156,7 +156,7 @@ subroutine fclaw2d_metric_fort_compute_area_general(mx,my,mbc, & xef = xe + ii*dxf yef = ye + jj*dyf - call fclaw2d_map_c2m(cont, & + call fclaw_map_2d_c2m(cont, & blockno,xef,yef,xp1,yp1,zp1) quadstore(ii,jj,1) = xp1 @@ -236,7 +236,7 @@ subroutine fclaw2d_metric_fort_compute_area_affine(mx,my,mbc,dx,dy, & do jcell = 0,1 xcorner = xe + icell*dx ycorner = ye + jcell*dy - call fclaw2d_map_c2m(map_context_ptr, & + call fclaw_map_2d_c2m(map_context_ptr, & blockno,xcorner,ycorner,xp1,yp1,zp1) quad(icell,jcell,1) = xp1 quad(icell,jcell,2) = yp1 diff --git a/src/patches/metric/fortran_source3d/fclaw3d_metric_default_fort.f90 b/src/patches/metric/fortran_source3d/fclaw3d_metric_default_fort.f90 index c748948f2..3ce352ac4 100644 --- a/src/patches/metric/fortran_source3d/fclaw3d_metric_default_fort.f90 +++ b/src/patches/metric/fortran_source3d/fclaw3d_metric_default_fort.f90 @@ -52,7 +52,7 @@ subroutine fclaw3d_metric_fort_compute_mesh(mx,my,mz,mbc, & yc = ylower + (j-1)*dyf zc = zlower + (k-1)*dzf - call fclaw3d_map_c2m(map_context_ptr, & + call fclaw_map_3d_c2m(map_context_ptr, & blockno,xc,yc,zc,xd1,yd1,zd1) !! whole integer indices are cell centers. @@ -187,7 +187,7 @@ subroutine fclaw3d_metric_fort_compute_volume_general(mx,my,mz, mbc, blockno, & yef = ye + jj*dyf zef = ze + kk*dzf - call fclaw3d_map_c2m(cont, & + call fclaw_map_3d_c2m(cont, & blockno,xef,yef,zef, xp1,yp1,zp1) hexfine(ii,jj,kk,1) = xp1 @@ -312,7 +312,7 @@ subroutine fclaw3d_metric_fort_compute_volume_affine(mx,my,mz, mbc, blockno, & ye = ylower + (j-1)*dy ze = zlower + (k-1)*dz - call fclaw3d_map_c2m(cont, & + call fclaw_map_3d_c2m(cont, & blockno,xe,ye,ze, xd1,yd1,zd1) xd(i,j,k) = xd1 diff --git a/src/solvers/fc2d_clawpack4.6/CMakeLists.txt b/src/solvers/fc2d_clawpack4.6/CMakeLists.txt index 9f3bc994f..6f50e12f3 100644 --- a/src/solvers/fc2d_clawpack4.6/CMakeLists.txt +++ b/src/solvers/fc2d_clawpack4.6/CMakeLists.txt @@ -38,14 +38,11 @@ install(FILES fc2d_clawpack46_options.h clawpack46_user_fort.h fc2d_clawpack46_fort.h - DESTINATION include + TYPE INCLUDE ) install(TARGETS clawpack4.6 - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # -- imported target, for use from FetchContent diff --git a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.cpp b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.cpp index 8f38370ef..19bc1084a 100644 --- a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.cpp +++ b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.cpp @@ -27,20 +27,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_clawpack46_options.h" #include "fc2d_clawpack46_fort.h" -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* --------------------- Clawpack solver functions (required) ------------------------- */ static -void clawpack46_setprob(fclaw2d_global_t *glob) +void clawpack46_setprob(fclaw_global_t *glob) { fc2d_clawpack46_vtable_t* claw46_vt = fc2d_clawpack46_vt(glob); if (claw46_vt->fort_setprob != NULL) @@ -60,8 +60,8 @@ void clawpack46_setprob(fclaw2d_global_t *glob) static -void clawpack46_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_qinit(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -70,15 +70,15 @@ void clawpack46_qinit(fclaw2d_global_t *glob, int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); int maxmx = mx; int maxmy = my; @@ -92,8 +92,8 @@ void clawpack46_qinit(fclaw2d_global_t *glob, static -void clawpack46_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_bc2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -106,12 +106,12 @@ void clawpack46_bc2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int maux; double* aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); int maxmx = mx; int maxmy = my; @@ -137,7 +137,7 @@ void clawpack46_bc2(fclaw2d_global_t *glob, */ int meqn; double *q; - fclaw2d_clawpatch_timesync_data(glob,patch,time_interp,&q,&meqn); + fclaw_clawpatch_timesync_data(glob,patch,time_interp,&q,&meqn); CLAWPACK46_SET_BLOCK(&blockno); claw46_vt->fort_bc2(&maxmx,&maxmy,&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -147,8 +147,8 @@ void clawpack46_bc2(fclaw2d_global_t *glob, static -void clawpack46_b4step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_b4step2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, double dt) @@ -160,16 +160,16 @@ void clawpack46_b4step2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); int maxmx = mx; int maxmy = my; @@ -181,8 +181,8 @@ void clawpack46_b4step2(fclaw2d_global_t *glob, } static -void clawpack46_src2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_src2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -198,16 +198,16 @@ void clawpack46_src2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); int maxmx = mx; int maxmy = my; @@ -221,8 +221,8 @@ void clawpack46_src2(fclaw2d_global_t *glob, /* This can be used as a value for patch_vt->patch_setup */ static -void clawpack46_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_setaux(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -231,7 +231,7 @@ void clawpack46_setaux(fclaw2d_global_t *glob, if (claw46_vt->fort_setaux == NULL) return; - if (fclaw2d_patch_is_ghost(patch)) + if (fclaw_patch_is_ghost(patch)) { /* This is going to be removed at some point */ return; @@ -239,12 +239,12 @@ void clawpack46_setaux(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); int maxmx = mx; int maxmy = my; @@ -257,15 +257,15 @@ void clawpack46_setaux(fclaw2d_global_t *glob, /* This is called from the single_step callback. and is of type 'flaw_single_step_t' */ static -double clawpack46_step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +double clawpack46_step2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, double dt) { fc2d_clawpack46_vtable_t* claw46_vt = fc2d_clawpack46_vt(glob); - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); const fc2d_clawpack46_options_t* clawpack_options; clawpack_options = fc2d_clawpack46_get_options(glob); @@ -290,18 +290,18 @@ double clawpack46_step2(fclaw2d_global_t *glob, int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); - fclaw2d_clawpatch_save_current_step(glob, patch); + fclaw_clawpatch_save_current_step(glob, patch); int mx, my, mbc; double xlower, ylower, dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *qold; - fclaw2d_clawpatch_soln_data(glob,patch,&qold,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&qold,&meqn); int mwaves = clawpack_options->mwaves; int maxm = fmax(mx,my); @@ -309,9 +309,9 @@ double clawpack46_step2(fclaw2d_global_t *glob, double cflgrid = 0.0; fclaw2d_clawpatch_registers_t* cr = - fclaw2d_clawpatch_get_registers(glob,patch); + fclaw_clawpatch_get_2d_registers(glob,patch); - int* block_corner_count = fclaw2d_patch_block_corner_count(glob,patch); + int* block_corner_count = fclaw_patch_block_corner_count(glob,patch); /* Evaluate fluxes needed in correction terms */ if (fclaw_opt->time_sync && fclaw_opt->flux_correction) @@ -400,8 +400,8 @@ double clawpack46_step2(fclaw2d_global_t *glob, } static -double clawpack46_update(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +double clawpack46_update(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -415,23 +415,23 @@ double clawpack46_update(fclaw2d_global_t *glob, if (claw46_vt->b4step2 != NULL) { - fclaw2d_timer_start_threadsafe(&glob->timers[FCLAW2D_TIMER_ADVANCE_B4STEP2]); + fclaw_timer_start_threadsafe(&glob->timers[FCLAW_TIMER_ADVANCE_B4STEP2]); claw46_vt->b4step2(glob, patch, blockno, patchno,t,dt); - fclaw2d_timer_stop_threadsafe(&glob->timers[FCLAW2D_TIMER_ADVANCE_B4STEP2]); + fclaw_timer_stop_threadsafe(&glob->timers[FCLAW_TIMER_ADVANCE_B4STEP2]); } - fclaw2d_timer_start_threadsafe(&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_start_threadsafe(&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); double maxcfl = clawpack46_step2(glob, patch, blockno, patchno,t,dt); - fclaw2d_timer_stop_threadsafe(&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_stop_threadsafe(&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); if (clawpack_options->src_term > 0 && claw46_vt->src2 != NULL) { @@ -447,19 +447,19 @@ double clawpack46_update(fclaw2d_global_t *glob, /* ---------------------------------- Output functions -------------------------------- */ static -void clawpack46_output(fclaw2d_global_t *glob, int iframe) +void clawpack46_output(fclaw_global_t *glob, int iframe) { const fc2d_clawpack46_options_t* clawpack_options; clawpack_options = fc2d_clawpack46_get_options(glob); if (clawpack_options->ascii_out != 0) { - fclaw2d_clawpatch_output_ascii(glob,iframe); + fclaw_clawpatch_output_ascii(glob,iframe); } if (clawpack_options->vtk_out != 0) { - fclaw2d_clawpatch_output_vtk(glob,iframe); + fclaw_clawpatch_output_vtk(glob,iframe); } } @@ -480,9 +480,9 @@ void clawpack46_vt_destroy(void* vt) FCLAW_FREE (vt); } -void fc2d_clawpack46_solver_initialize(fclaw2d_global_t* glob) +void fc2d_clawpack46_solver_initialize(fclaw_global_t* glob) { - fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_get_options(glob); fc2d_clawpack46_options_t* clawopt = fc2d_clawpack46_get_options(glob); clawopt->method[6] = clawpatch_opt->maux; @@ -493,17 +493,17 @@ void fc2d_clawpack46_solver_initialize(fclaw2d_global_t* glob) } int claw_version = 4; - fclaw2d_clawpatch_vtable_initialize(glob, claw_version); + fclaw_clawpatch_vtable_initialize(glob, claw_version); - fclaw2d_vtable_t* fclaw_vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_vtable_t* fc_vt = fclaw_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); fc2d_clawpack46_vtable_t* claw46_vt = clawpack46_vt_new(); /* ForestClaw vtable items */ - fclaw_vt->output_frame = clawpack46_output; - fclaw_vt->problem_setup = clawpack46_setprob; + fc_vt->output_frame = clawpack46_output; + fc_vt->problem_setup = clawpack46_setprob; /* These could be over-written by user specific settings */ patch_vt->initialize = clawpack46_qinit; @@ -512,8 +512,8 @@ void fc2d_clawpack46_solver_initialize(fclaw2d_global_t* glob) patch_vt->single_step_update = clawpack46_update; /* Conservation updates (based on Clawpack updates) */ - clawpatch_vt->fort_time_sync_f2c = CLAWPACK46_FORT_TIME_SYNC_F2C; - clawpatch_vt->fort_time_sync_samesize = CLAWPACK46_FORT_TIME_SYNC_SAMESIZE; + clawpatch_vt->d2->fort_time_sync_f2c = CLAWPACK46_FORT_TIME_SYNC_F2C; + clawpatch_vt->d2->fort_time_sync_samesize = CLAWPACK46_FORT_TIME_SYNC_SAMESIZE; /* Wrappers so that user can change argument list */ claw46_vt->b4step2 = clawpack46_b4step2; @@ -543,7 +543,7 @@ void fc2d_clawpack46_solver_initialize(fclaw2d_global_t* glob) /* These are here in case the user wants to call Clawpack routines directly */ -fc2d_clawpack46_vtable_t* fc2d_clawpack46_vt(fclaw2d_global_t* glob) +fc2d_clawpack46_vtable_t* fc2d_clawpack46_vt(fclaw_global_t* glob) { fc2d_clawpack46_vtable_t* claw46_vt = (fc2d_clawpack46_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fc2d_clawpack46"); @@ -553,21 +553,21 @@ fc2d_clawpack46_vtable_t* fc2d_clawpack46_vt(fclaw2d_global_t* glob) } /* This should only be called when a new fclaw2d_clawpatch_t is created. */ -void fc2d_clawpack46_set_capacity(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fc2d_clawpack46_set_capacity(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - double *area = fclaw2d_clawpatch_get_area(glob,patch); + double *area = fclaw_clawpatch_get_2d_area(glob,patch); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); fc2d_clawpack46_options_t *clawopt = fc2d_clawpack46_get_options(glob); int mcapa = clawopt->mcapa; @@ -581,14 +581,14 @@ void fc2d_clawpack46_set_capacity(fclaw2d_global_t *glob, /* -------------------------- Public interface to Clawpack wrappers --------------------*/ -void fc2d_clawpack46_setprob(fclaw2d_global_t *glob) +void fc2d_clawpack46_setprob(fclaw_global_t *glob) { clawpack46_setprob(glob); } /* This can be set to claw46_vt->src2 */ -void fc2d_clawpack46_src2(fclaw2d_global_t* glob, - fclaw2d_patch_t *patch, +void fc2d_clawpack46_src2(fclaw_global_t* glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -598,8 +598,8 @@ void fc2d_clawpack46_src2(fclaw2d_global_t* glob, } -void fc2d_clawpack46_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fc2d_clawpack46_setaux(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -607,16 +607,16 @@ void fc2d_clawpack46_setaux(fclaw2d_global_t *glob, } -void fc2d_clawpack46_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fc2d_clawpack46_qinit(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { clawpack46_qinit(glob,patch,blockno,patchno); } -void fc2d_clawpack46_b4step2(fclaw2d_global_t* glob, - fclaw2d_patch_t *patch, +void fc2d_clawpack46_b4step2(fclaw_global_t* glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -625,8 +625,8 @@ void fc2d_clawpack46_b4step2(fclaw2d_global_t* glob, clawpack46_b4step2(glob,patch,blockno,patchno,t,dt); } -void fc2d_clawpack46_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fc2d_clawpack46_bc2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, diff --git a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.h b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.h index b1ae9aba0..14ffbce5b 100644 --- a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.h +++ b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.h @@ -36,8 +36,8 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; typedef struct fc2d_clawpack46_vtable fc2d_clawpack46_vtable_t; @@ -45,15 +45,15 @@ typedef struct fc2d_clawpack46_vtable fc2d_clawpack46_vtable_t; /* --------------------------- Clawpack solver functions ------------------------------ */ /* Virtualize clawpack-specific wrapper functions */ -typedef void (*clawpack46_src2_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +typedef void (*clawpack46_src2_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -typedef void (*clawpack46_b4step2_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +typedef void (*clawpack46_b4step2_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -197,7 +197,7 @@ struct fc2d_clawpack46_vtable * * @param global the global context */ -void fc2d_clawpack46_solver_initialize(struct fclaw2d_global* global); +void fc2d_clawpack46_solver_initialize(struct fclaw_global* global); /** * @brief Get the clawpack46 vtable @@ -205,38 +205,38 @@ void fc2d_clawpack46_solver_initialize(struct fclaw2d_global* global); * @param global the global context * @return fc2d_clawpack46_vtable_t* the vtable */ -fc2d_clawpack46_vtable_t* fc2d_clawpack46_vt(struct fclaw2d_global* global); +fc2d_clawpack46_vtable_t* fc2d_clawpack46_vt(struct fclaw_global* global); /* ----------------------------- User access to solver functions ---------------------- */ -void fc2d_clawpack46_setprob(struct fclaw2d_global* glob); +void fc2d_clawpack46_setprob(struct fclaw_global* glob); -void fc2d_clawpack46_setaux(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack46_setaux(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_clawpack46_set_capacity(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack46_set_capacity(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_clawpack46_qinit(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack46_qinit(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_clawpack46_b4step2(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack46_b4step2(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -void fc2d_clawpack46_bc2(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack46_bc2(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -244,8 +244,8 @@ void fc2d_clawpack46_bc2(struct fclaw2d_global *glob, int intersects_bc[], int time_interp); -void fc2d_clawpack46_src2(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack46_src2(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.h.TEST.cpp b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.h.TEST.cpp index 6a6b72094..1e8c16617 100644 --- a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.h.TEST.cpp +++ b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46.h.TEST.cpp @@ -23,91 +23,113 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include +#include #include #include -#include +#include #include TEST_CASE("fc2d_clawpack46_solver_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); /* create some empty options structures */ - fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); - fc2d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1)); + fclaw_clawpatch_options_t* clawpatch_opts = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, clawpatch_opts); + fclaw_clawpatch_options_store(glob2, clawpatch_opts); - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fc2d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1)); fc2d_clawpack46_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc2d_clawpack46_solver_initialize(glob1); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_clawpack46_solver_initialize(glob2); CHECK_NE(fc2d_clawpack46_vt(glob1), fc2d_clawpack46_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_clawpack46_solver_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_t* glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); /* create some empty options structures */ - fclaw2d_clawpatch_options_store(glob, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_clawpatch_options_t* clawpatch_opts = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob, clawpatch_opts); fc2d_clawpack46_options_store(glob, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1)); - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_clawpack46_solver_initialize(glob); CHECK_UNARY(fc2d_clawpack46_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_clawpack46_vt fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); CHECK_SC_ABORTED(fc2d_clawpack46_vt(glob1)); CHECK_SC_ABORTED(fc2d_clawpack46_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_clawpack46_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); /* create some empty options structures */ - fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); - fc2d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1)); + fclaw_clawpatch_options_t* clawpatch_opts = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, clawpatch_opts); + fclaw_clawpatch_options_store(glob2, clawpatch_opts); - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fc2d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1)); fc2d_clawpack46_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc2d_clawpack46_solver_initialize(glob1); CHECK_SC_ABORTED(fc2d_clawpack46_solver_initialize(glob1)); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_clawpack46_solver_initialize(glob2); CHECK_SC_ABORTED(fc2d_clawpack46_solver_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_fort.h b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_fort.h index 4348f9057..36f4d8637 100644 --- a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_fort.h +++ b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_fort.h @@ -136,7 +136,7 @@ void CLAWPACK46_FORT_TIME_SYNC_F2C(const int* mx,const int* my, double eff0[], double eff1[], double eff2[], double eff3[], double qfine_dummy[], - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); @@ -160,7 +160,7 @@ void CLAWPACK46_FORT_TIME_SYNC_SAMESIZE(const int* mx,const int* my, double eff0[], double eff1[], double eff2[], double eff3[], double qfine_dummy[], - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); /* ------------------------------- Time stepping functions ---------------------------- */ diff --git a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.c b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.c index debfc17ac..bdd37b0ba 100644 --- a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.c +++ b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.c @@ -25,8 +25,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_clawpack46_options.h" -#include -#include +#include +#include #include #include #include @@ -311,12 +311,12 @@ fc2d_clawpack46_options_t* fc2d_clawpack46_options_register (fclaw_app_t * app, return clawopt; } -fc2d_clawpack46_options_t* fc2d_clawpack46_get_options(fclaw2d_global_t *glob) +fc2d_clawpack46_options_t* fc2d_clawpack46_get_options(fclaw_global_t *glob) { - return (fc2d_clawpack46_options_t*) fclaw2d_global_get_options(glob, "fc2d_clawpack46"); + return (fc2d_clawpack46_options_t*) fclaw_global_get_options(glob, "fc2d_clawpack46"); } -void fc2d_clawpack46_options_store (fclaw2d_global_t* glob, fc2d_clawpack46_options_t* clawopt) +void fc2d_clawpack46_options_store (fclaw_global_t* glob, fc2d_clawpack46_options_t* clawopt) { - fclaw2d_global_options_store(glob, "fc2d_clawpack46", clawopt); + fclaw_global_options_store(glob, "fc2d_clawpack46", clawopt); } diff --git a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.h b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.h index 4e62fc0a4..a5fbe1424 100644 --- a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.h +++ b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.h @@ -36,7 +36,7 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; typedef struct fc2d_clawpack46_options fc2d_clawpack46_options_t; struct fc2d_clawpack46_options @@ -87,11 +87,11 @@ fc2d_clawpack46_options_t* fc2d_clawpack46_options_register (fclaw_app_t * app, void fc2d_clawpack46_package_register(fclaw_app_t* app, fc2d_clawpack46_options_t* clawopt); -fc2d_clawpack46_options_t* fc2d_clawpack46_get_options(struct fclaw2d_global *glob); +fc2d_clawpack46_options_t* fc2d_clawpack46_get_options(struct fclaw_global *glob); -void fc2d_clawpack46_options_store (struct fclaw2d_global* glob, fc2d_clawpack46_options_t* clawopt); +void fc2d_clawpack46_options_store (struct fclaw_global* glob, fc2d_clawpack46_options_t* clawopt); -void fc2d_clawpack46_output(struct fclaw2d_global *glob, int iframe); +void fc2d_clawpack46_output(struct fclaw_global *glob, int iframe); /** * @brief Get the packing vtable for fc2d_clawpack46_options_t diff --git a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.h.TEST.cpp b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.h.TEST.cpp index e5b55c51b..4f7089554 100644 --- a/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.h.TEST.cpp +++ b/src/solvers/fc2d_clawpack4.6/fc2d_clawpack46_options.h.TEST.cpp @@ -23,51 +23,51 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include #include TEST_CASE("fc2d_clawpack46_options can store options in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_clawpack46_options_t* opts1 = FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1); fc2d_clawpack46_options_t* opts2 = FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1); fc2d_clawpack46_options_store(glob1, opts1); /* glob1 has one package glob2 has two */ - fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); + fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_clawpack46_options_store(glob2, opts2); CHECK_EQ(fc2d_clawpack46_get_options(glob1), opts1); CHECK_EQ(fc2d_clawpack46_get_options(glob2), opts2); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_clawpack46_get_options fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); CHECK_SC_ABORTED(fc2d_clawpack46_get_options(glob1)); CHECK_SC_ABORTED(fc2d_clawpack46_get_options(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_clawpack46_options_store fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1)); CHECK_SC_ABORTED(fc2d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1))); @@ -75,8 +75,8 @@ TEST_CASE("fc2d_clawpack46_options_store fails if called twice on a glob") fc2d_clawpack46_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1)); CHECK_SC_ABORTED(fc2d_clawpack46_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_clawpack46_options_t,1))); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_clawpack46_options packing/unpacking") diff --git a/src/solvers/fc2d_clawpack5/CMakeLists.txt b/src/solvers/fc2d_clawpack5/CMakeLists.txt index df8eb5e87..272a3d820 100644 --- a/src/solvers/fc2d_clawpack5/CMakeLists.txt +++ b/src/solvers/fc2d_clawpack5/CMakeLists.txt @@ -38,14 +38,11 @@ install(FILES fc2d_clawpack5_options.h clawpack5_user_fort.h fc2d_clawpack5_fort.h - DESTINATION include + TYPE INCLUDE ) install(TARGETS clawpack5 - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # imported target, for use from FetchContent add_library(FORESTCLAW::CLAWPACK5 INTERFACE IMPORTED GLOBAL) diff --git a/src/solvers/fc2d_clawpack5/fc2d_clawpack5.cpp b/src/solvers/fc2d_clawpack5/fc2d_clawpack5.cpp index d7c2e5d44..9b3d751a3 100644 --- a/src/solvers/fc2d_clawpack5/fc2d_clawpack5.cpp +++ b/src/solvers/fc2d_clawpack5/fc2d_clawpack5.cpp @@ -30,27 +30,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include /* -------------------------- Clawpack solver functions ------------------------------ */ static -void clawpack5_setprob(fclaw2d_global_t *glob) +void clawpack5_setprob(fclaw_global_t *glob) { fc2d_clawpack5_vtable_t* claw5_vt = fc2d_clawpack5_vt(glob); if (claw5_vt->fort_setprob != NULL) @@ -61,8 +61,8 @@ void clawpack5_setprob(fclaw2d_global_t *glob) /* This should only be called when a new fclaw2d_clawpatch_t is created. */ static -void clawpack5_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void clawpack5_setaux(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -72,7 +72,7 @@ void clawpack5_setaux(fclaw2d_global_t *glob, return; } - if (fclaw2d_patch_is_ghost(this_patch)) + if (fclaw_patch_is_ghost(this_patch)) { /* This is going to be removed at some point */ return; @@ -84,9 +84,9 @@ void clawpack5_setaux(fclaw2d_global_t *glob, double *aux; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); CLAWPACK5_SET_BLOCK(&this_block_idx); claw5_vt->fort_setaux(&mbc,&mx,&my,&xlower,&ylower,&dx,&dy, @@ -95,8 +95,8 @@ void clawpack5_setaux(fclaw2d_global_t *glob, } static -void clawpack5_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void clawpack5_qinit(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -107,11 +107,11 @@ void clawpack5_qinit(fclaw2d_global_t *glob, double dx,dy,xlower,ylower; double *q, *aux; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); /* Call to classic Clawpack 'qinit' routine. This must be user defined */ CLAWPACK5_SET_BLOCK(&this_block_idx); @@ -121,8 +121,8 @@ void clawpack5_qinit(fclaw2d_global_t *glob, } static -void clawpack5_b4step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void clawpack5_b4step2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, double dt) @@ -139,11 +139,11 @@ void clawpack5_b4step2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); CLAWPACK5_SET_BLOCK(&this_block_idx); claw5_vt->fort_b4step2(&mbc,&mx,&my,&meqn,q,&xlower,&ylower, @@ -152,8 +152,8 @@ void clawpack5_b4step2(fclaw2d_global_t *glob, } static -void clawpack5_src2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void clawpack5_src2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -170,11 +170,11 @@ void clawpack5_src2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); CLAWPACK5_SET_BLOCK(&this_block_idx); claw5_vt->fort_src2(&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -183,8 +183,8 @@ void clawpack5_src2(fclaw2d_global_t *glob, } static -void clawpack5_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void clawpack5_bc2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -202,10 +202,10 @@ void clawpack5_bc2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); int *block_mthbc = clawopt->mthbc; @@ -229,7 +229,7 @@ void clawpack5_bc2(fclaw2d_global_t *glob, In this case, this boundary condition won't be used to update anything */ - fclaw2d_clawpatch_timesync_data(glob,this_patch,time_interp,&q,&meqn); + fclaw_clawpatch_timesync_data(glob,this_patch,time_interp,&q,&meqn); CLAWPACK5_SET_BLOCK(&this_block_idx); claw5_vt->fort_bc2(&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -241,8 +241,8 @@ void clawpack5_bc2(fclaw2d_global_t *glob, /* This is called from the single_step callback. and is of type 'flaw_single_step_t' */ static -double clawpack5_step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double clawpack5_step2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -263,14 +263,14 @@ double clawpack5_step2(fclaw2d_global_t *glob, level = this_patch->level; - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); - fclaw2d_clawpatch_save_current_step(glob, this_patch); + fclaw_clawpatch_save_current_step(glob, this_patch); - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&qold,&meqn); + fclaw_clawpatch_soln_data(glob,this_patch,&qold,&meqn); int mwaves = clawpack_options->mwaves; @@ -279,10 +279,10 @@ double clawpack5_step2(fclaw2d_global_t *glob, double cflgrid = 0.0; fclaw2d_clawpatch_registers_t* cr = - fclaw2d_clawpatch_get_registers(glob,this_patch); + fclaw_clawpatch_get_2d_registers(glob,this_patch); /* Evaluate fluxes needed in correction terms */ - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); if (fclaw_opt->time_sync && fclaw_opt->flux_correction) { FCLAW_ASSERT(claw5_vt->fort_rpn2_cons != NULL); @@ -325,7 +325,7 @@ double clawpack5_step2(fclaw2d_global_t *glob, // CLAWPACK5_FLUX2FW : CLAWPACK5_FLUX2; clawpack5_fort_flux2_t flux2 = CLAWPACK5_FLUX2; - int* block_corner_count = fclaw2d_patch_block_corner_count(glob,this_patch); + int* block_corner_count = fclaw_patch_block_corner_count(glob,this_patch); CLAWPACK5_SET_BLOCK(&this_block_idx); CLAWPACK5_STEP2_WRAP(&maxm, &meqn, &maux, &mbc, clawpack_options->method, @@ -364,8 +364,8 @@ double clawpack5_step2(fclaw2d_global_t *glob, } static -double clawpack5_update(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double clawpack5_update(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -379,20 +379,20 @@ double clawpack5_update(fclaw2d_global_t *glob, if (claw5_vt->b4step2 != NULL) { - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_ADVANCE_B4STEP2]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_ADVANCE_B4STEP2]); claw5_vt->b4step2(glob, this_patch, this_block_idx, this_patch_idx,t,dt); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_ADVANCE_B4STEP2]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_ADVANCE_B4STEP2]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); double maxcfl = clawpack5_step2(glob, this_patch, this_block_idx, this_patch_idx,t,dt); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); if (clawpack_options->src_term > 0 && claw5_vt->src2 != NULL) { @@ -407,19 +407,19 @@ double clawpack5_update(fclaw2d_global_t *glob, /* ---------------------------------- Output functions -------------------------------- */ static -void clawpack5_output(fclaw2d_global_t *glob, int iframe) +void clawpack5_output(fclaw_global_t *glob, int iframe) { const fc2d_clawpack5_options_t* clawpack_options; clawpack_options = fc2d_clawpack5_get_options(glob); if (clawpack_options->ascii_out != 0) { - fclaw2d_clawpatch_output_ascii(glob,iframe); + fclaw_clawpatch_output_ascii(glob,iframe); } if (clawpack_options->vtk_out != 0) { - fclaw2d_clawpatch_output_vtk(glob,iframe); + fclaw_clawpatch_output_vtk(glob,iframe); } } @@ -439,9 +439,9 @@ void fc2d_clawpack5_vt_destroy(void* vt) } /* This is called from the user application. */ -void fc2d_clawpack5_solver_initialize(fclaw2d_global_t* glob) +void fc2d_clawpack5_solver_initialize(fclaw_global_t* glob) { - fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_get_options(glob); fc2d_clawpack5_options_t* clawopt = fc2d_clawpack5_get_options(glob); clawopt->method[6] = clawpatch_opt->maux; @@ -454,16 +454,16 @@ void fc2d_clawpack5_solver_initialize(fclaw2d_global_t* glob) int claw_version = 5; - fclaw2d_clawpatch_vtable_initialize(glob, claw_version); + fclaw_clawpatch_vtable_initialize(glob, claw_version); - fclaw2d_vtable_t* fclaw_vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_vtable_t* fc_vt = fclaw_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); fc2d_clawpack5_vtable_t* claw5_vt = fc2d_clawpack5_vt_new(); - fclaw_vt->output_frame = clawpack5_output; - fclaw_vt->problem_setup = clawpack5_setprob; + fc_vt->output_frame = clawpack5_output; + fc_vt->problem_setup = clawpack5_setprob; /* Default patch functions */ patch_vt->initialize = clawpack5_qinit; @@ -472,8 +472,8 @@ void fc2d_clawpack5_solver_initialize(fclaw2d_global_t* glob) patch_vt->single_step_update = clawpack5_update; /* Conservation updates (based on Clawpack updates) */ - clawpatch_vt->fort_time_sync_f2c = CLAWPACK5_FORT_TIME_SYNC_F2C; - clawpatch_vt->fort_time_sync_samesize = CLAWPACK5_FORT_TIME_SYNC_SAMESIZE; + clawpatch_vt->d2->fort_time_sync_f2c = CLAWPACK5_FORT_TIME_SYNC_F2C; + clawpatch_vt->d2->fort_time_sync_samesize = CLAWPACK5_FORT_TIME_SYNC_SAMESIZE; claw5_vt->b4step2 = clawpack5_b4step2; @@ -503,7 +503,7 @@ void fc2d_clawpack5_solver_initialize(fclaw2d_global_t* glob) /* These are here in case the user wants to call Clawpack routines directly */ -fc2d_clawpack5_vtable_t* fc2d_clawpack5_vt(fclaw2d_global_t* glob) +fc2d_clawpack5_vtable_t* fc2d_clawpack5_vt(fclaw_global_t* glob) { fc2d_clawpack5_vtable_t* claw5_vt = (fc2d_clawpack5_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fc2d_clawpack5"); @@ -513,13 +513,13 @@ fc2d_clawpack5_vtable_t* fc2d_clawpack5_vt(fclaw2d_global_t* glob) } -void fc2d_clawpack5_setprob(fclaw2d_global_t *glob) +void fc2d_clawpack5_setprob(fclaw_global_t *glob) { clawpack5_setprob(glob); } -void fc2d_clawpack5_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_clawpack5_setaux(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -528,8 +528,8 @@ void fc2d_clawpack5_setaux(fclaw2d_global_t *glob, /* This should only be called when a new fclaw2d_clawpatch_t is created. */ -void fc2d_clawpack5_set_capacity(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_clawpack5_set_capacity(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -541,28 +541,28 @@ void fc2d_clawpack5_set_capacity(fclaw2d_global_t *glob, clawopt = fc2d_clawpack5_get_options(glob); mcapa = clawopt->mcapa; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - area = fclaw2d_clawpatch_get_area(glob,this_patch); + area = fclaw_clawpatch_get_2d_area(glob,this_patch); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); FCLAW_ASSERT(maux >= mcapa && mcapa > 0); CLAWPACK5_SET_CAPACITY(&mx,&my,&mbc,&dx,&dy,area,&mcapa, &maux,aux); } -void fc2d_clawpack5_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_clawpack5_qinit(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { clawpack5_qinit(glob,this_patch,this_block_idx,this_patch_idx); } -void fc2d_clawpack5_b4step2(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, +void fc2d_clawpack5_b4step2(fclaw_global_t* glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -571,8 +571,8 @@ void fc2d_clawpack5_b4step2(fclaw2d_global_t* glob, clawpack5_b4step2(glob,this_patch,this_block_idx,this_patch_idx,t,dt); } -void fc2d_clawpack5_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_clawpack5_bc2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -584,8 +584,8 @@ void fc2d_clawpack5_bc2(fclaw2d_global_t *glob, intersects_bc,time_interp); } -void fc2d_clawpack5_src2(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, +void fc2d_clawpack5_src2(fclaw_global_t* glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/solvers/fc2d_clawpack5/fc2d_clawpack5.h b/src/solvers/fc2d_clawpack5/fc2d_clawpack5.h index e3bf48644..9a8a030b7 100644 --- a/src/solvers/fc2d_clawpack5/fc2d_clawpack5.h +++ b/src/solvers/fc2d_clawpack5/fc2d_clawpack5.h @@ -36,22 +36,22 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; /* --------------------------- Clawpack solver functions ------------------------------ */ /* Virtualize clawpack-specific wrapper functions */ -typedef void (*clawpack5_src2_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +typedef void (*clawpack5_src2_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -typedef void (*clawpack5_b4step2_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +typedef void (*clawpack5_b4step2_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -160,7 +160,7 @@ typedef struct fc2d_clawpack5_vtable * * @param global the global context */ -void fc2d_clawpack5_solver_initialize(struct fclaw2d_global* glob); +void fc2d_clawpack5_solver_initialize(struct fclaw_global* glob); /** * @brief Get the clawpack5 vtable @@ -168,37 +168,37 @@ void fc2d_clawpack5_solver_initialize(struct fclaw2d_global* glob); * @param global the global context * @return fc2d_clawpack5_vtable_t* the vtable */ -fc2d_clawpack5_vtable_t* fc2d_clawpack5_vt(struct fclaw2d_global* glob); +fc2d_clawpack5_vtable_t* fc2d_clawpack5_vt(struct fclaw_global* glob); /* ----------------------------- User access to solver functions --------------------------- */ -void fc2d_clawpack5_setprob(struct fclaw2d_global* glob); +void fc2d_clawpack5_setprob(struct fclaw_global* glob); -void fc2d_clawpack5_setaux(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack5_setaux(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_clawpack5_set_capacity(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack5_set_capacity(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_clawpack5_qinit(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack5_qinit(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_clawpack5_b4step2(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack5_b4step2(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -void fc2d_clawpack5_bc2(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack5_bc2(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -206,8 +206,8 @@ void fc2d_clawpack5_bc2(struct fclaw2d_global *glob, int intersects_bc[], int time_interp); -void fc2d_clawpack5_src2(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_clawpack5_src2(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/solvers/fc2d_clawpack5/fc2d_clawpack5.h.TEST.cpp b/src/solvers/fc2d_clawpack5/fc2d_clawpack5.h.TEST.cpp index a6bc15bcb..5af0d08fe 100644 --- a/src/solvers/fc2d_clawpack5/fc2d_clawpack5.h.TEST.cpp +++ b/src/solvers/fc2d_clawpack5/fc2d_clawpack5.h.TEST.cpp @@ -23,91 +23,115 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include +#include #include #include -#include +#include #include TEST_CASE("fc2d_clawpack5_solver_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* clawpatch_opts = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, clawpatch_opts); + fclaw_clawpatch_options_store(glob2, clawpatch_opts); /* create some empty options structures */ - fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); fc2d_clawpack5_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1)); - - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); fc2d_clawpack5_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc2d_clawpack5_solver_initialize(glob1); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_clawpack5_solver_initialize(glob2); CHECK_NE(fc2d_clawpack5_vt(glob1), fc2d_clawpack5_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_clawpack5_solver_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_global_t* glob = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob, domain); + + fclaw_clawpatch_options_t* clawpatch_opts = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob, clawpatch_opts); /* create some empty options structures */ - fclaw2d_clawpatch_options_store(glob, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); fc2d_clawpack5_options_store(glob, FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1)); - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_clawpack5_solver_initialize(glob); CHECK_UNARY(fc2d_clawpack5_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_clawpack5_vt fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); CHECK_SC_ABORTED(fc2d_clawpack5_vt(glob1)); CHECK_SC_ABORTED(fc2d_clawpack5_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_clawpack5_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* clawpatch_opts = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, clawpatch_opts); + fclaw_clawpatch_options_store(glob2, clawpatch_opts); /* create some empty options structures */ - fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); fc2d_clawpack5_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1)); - - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); fc2d_clawpack5_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc2d_clawpack5_solver_initialize(glob1); CHECK_SC_ABORTED(fc2d_clawpack5_solver_initialize(glob1)); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_clawpack5_solver_initialize(glob2); CHECK_SC_ABORTED(fc2d_clawpack5_solver_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc2d_clawpack5/fc2d_clawpack5_fort.h b/src/solvers/fc2d_clawpack5/fc2d_clawpack5_fort.h index 90b6d945b..25cd17dad 100644 --- a/src/solvers/fc2d_clawpack5/fc2d_clawpack5_fort.h +++ b/src/solvers/fc2d_clawpack5/fc2d_clawpack5_fort.h @@ -139,7 +139,7 @@ void CLAWPACK5_FORT_TIME_SYNC_F2C(const int* mx,const int* my, double eff0[], double eff1[], double eff2[], double eff3[], double qfine_dummy[], - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); @@ -163,7 +163,7 @@ void CLAWPACK5_FORT_TIME_SYNC_SAMESIZE(const int* mx,const int* my, double eff0[], double eff1[], double eff2[], double eff3[], double qfine_dummy[], - struct fclaw2d_patch_transform_data** + struct fclaw_patch_transform_data** transform_cptr); diff --git a/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.c b/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.c index 0d0d3c26f..784ae770b 100644 --- a/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.c +++ b/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.c @@ -26,8 +26,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_clawpack5_options.h" #include "fclaw_base.h" -#include -#include +#include +#include #include #include #include @@ -317,12 +317,12 @@ fc2d_clawpack5_options_t* fc2d_clawpack5_options_register (fclaw_app_t * app, return clawopt; } -fc2d_clawpack5_options_t* fc2d_clawpack5_get_options(fclaw2d_global_t *glob) +fc2d_clawpack5_options_t* fc2d_clawpack5_get_options(fclaw_global_t *glob) { - return (fc2d_clawpack5_options_t*) fclaw2d_global_get_options(glob,"fc2d_clawpack5"); + return (fc2d_clawpack5_options_t*) fclaw_global_get_options(glob,"fc2d_clawpack5"); } -void fc2d_clawpack5_options_store (fclaw2d_global_t* glob, fc2d_clawpack5_options_t* clawopt) +void fc2d_clawpack5_options_store (fclaw_global_t* glob, fc2d_clawpack5_options_t* clawopt) { - fclaw2d_global_options_store(glob,"fc2d_clawpack5",clawopt); + fclaw_global_options_store(glob,"fc2d_clawpack5",clawopt); } diff --git a/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.h b/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.h index eea9b441b..d066c688e 100644 --- a/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.h +++ b/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.h @@ -36,7 +36,7 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; typedef struct fc2d_clawpack5_options fc2d_clawpack5_options_t; @@ -80,12 +80,12 @@ fc2d_clawpack5_options_t *fc2d_clawpack5_options_register (fclaw_app_t *app, const char *section, const char *configfile); -void fc2d_clawpack5_options_store (struct fclaw2d_global* glob, +void fc2d_clawpack5_options_store (struct fclaw_global* glob, fc2d_clawpack5_options_t* clawopt); -fc2d_clawpack5_options_t* fc2d_clawpack5_get_options(struct fclaw2d_global *glob); +fc2d_clawpack5_options_t* fc2d_clawpack5_get_options(struct fclaw_global *glob); -void fc2d_clawpack5_output(struct fclaw2d_global *glob, int iframe); +void fc2d_clawpack5_output(struct fclaw_global *glob, int iframe); #define CLAWPACK5_SET_AMR_MODULE FCLAW_F77_FUNC(clawpack5_set_amr_module, \ diff --git a/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.h.TEST.cpp b/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.h.TEST.cpp index 3a90b82b1..2a644bfd2 100644 --- a/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.h.TEST.cpp +++ b/src/solvers/fc2d_clawpack5/fc2d_clawpack5_options.h.TEST.cpp @@ -23,51 +23,51 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include #include TEST_CASE("fc2d_clawpack5_options can store options in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_clawpack5_options_t* opts1 = FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1); fc2d_clawpack5_options_t* opts2 = FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1); fc2d_clawpack5_options_store(glob1, opts1); /* glob1 has one package glob2 has two */ - fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); + fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_clawpack5_options_store(glob2, opts2); CHECK_EQ(fc2d_clawpack5_get_options(glob1), opts1); CHECK_EQ(fc2d_clawpack5_get_options(glob2), opts2); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_clawpack5_get_options fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); CHECK_SC_ABORTED(fc2d_clawpack5_get_options(glob1)); CHECK_SC_ABORTED(fc2d_clawpack5_get_options(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_clawpack5_options_store fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_clawpack5_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1)); CHECK_SC_ABORTED(fc2d_clawpack5_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1))); @@ -75,8 +75,8 @@ TEST_CASE("fc2d_clawpack5_options_store fails if called twice on a glob") fc2d_clawpack5_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1)); CHECK_SC_ABORTED(fc2d_clawpack5_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_clawpack5_options_t,1))); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_clawpack5_options packing/unpacking") diff --git a/src/solvers/fc2d_cudaclaw/CMakeLists.txt b/src/solvers/fc2d_cudaclaw/CMakeLists.txt index 1420be09f..e6e9abac9 100644 --- a/src/solvers/fc2d_cudaclaw/CMakeLists.txt +++ b/src/solvers/fc2d_cudaclaw/CMakeLists.txt @@ -56,14 +56,11 @@ install(FILES fc2d_cudaclaw_options.h cudaclaw_user_fort.h fc2d_cudaclaw_fort.h - DESTINATION include + TYPE INCLUDE ) install(TARGETS cudaclaw - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # imported target, for use from FetchContent add_library(FORESTCLAW::CUDACLAW INTERFACE IMPORTED GLOBAL) diff --git a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_allocate.cu b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_allocate.cu index dfa34674e..d5903e04e 100644 --- a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_allocate.cu +++ b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_allocate.cu @@ -3,10 +3,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -18,8 +18,8 @@ static double* s_membuffer; static double* s_membuffer_dev; static cudaclaw_fluxes_t* s_array_fluxes_struct_dev; -void cudaclaw_allocate_fluxes(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch) +void cudaclaw_allocate_fluxes(fclaw_global_t *glob, + fclaw_patch_t *patch) { PROFILE_CUDA_GROUP("Allocate patch data in memory device",4); int mx,my,mbc; @@ -28,12 +28,12 @@ void cudaclaw_allocate_fluxes(fclaw2d_global_t *glob, cudaclaw_fluxes_t *fluxes = FCLAW_ALLOC(cudaclaw_fluxes,1); - const fclaw2d_clawpatch_options_t *claw_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *claw_opt = fclaw_clawpatch_get_options(glob); int meqn = claw_opt->meqn; int maux = claw_opt->maux; /* Set values needed in batch node */ - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); fluxes->dx = dx; @@ -78,15 +78,15 @@ void cudaclaw_allocate_fluxes(fclaw2d_global_t *glob, value = 0; CHECK(cudaMemset((void*)fluxes->speeds_dev, value, fluxes->num_bytes_speeds)); - fclaw2d_patch_set_user_data(glob,patch,fluxes); + fclaw_patch_set_user_data(glob,patch,fluxes); } -void cudaclaw_deallocate_fluxes(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch) +void cudaclaw_deallocate_fluxes(fclaw_global_t *glob, + fclaw_patch_t *patch) { PROFILE_CUDA_GROUP("De-allocate patch device memory",4); cudaclaw_fluxes_t *fluxes = (cudaclaw_fluxes_t*) - fclaw2d_patch_get_user_data(glob,patch); + fclaw_patch_get_user_data(glob,patch); FCLAW_ASSERT(fluxes != NULL); @@ -109,9 +109,9 @@ void cudaclaw_deallocate_fluxes(fclaw2d_global_t *glob, -void fc2d_cudaclaw_allocate_buffers(fclaw2d_global_t *glob) +void fc2d_cudaclaw_allocate_buffers(fclaw_global_t *glob) { - fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; int my = clawpatch_opt->my; int mbc = clawpatch_opt->mbc; @@ -131,7 +131,7 @@ void fc2d_cudaclaw_allocate_buffers(fclaw2d_global_t *glob) batch_size*sizeof(cudaclaw_fluxes_t))); } -void fc2d_cudaclaw_deallocate_buffers(fclaw2d_global_t *glob) +void fc2d_cudaclaw_deallocate_buffers(fclaw_global_t *glob) { cudaFreeHost(s_membuffer); cudaFree(s_membuffer_dev); diff --git a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_allocate.h b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_allocate.h index 0f887821e..1f65da6a6 100644 --- a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_allocate.h +++ b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_allocate.h @@ -9,8 +9,8 @@ extern "C" #include /* defines size_t */ -struct fclaw2d_patch; -struct fclaw2d_global; +struct fclaw_patch; +struct fclaw_global; /* This can breaks cuda if memory is not aligne dproperly; use -malign-double flag in gcc */ diff --git a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_initialize.cu b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_initialize.cu index b095a81ae..bf19b2c4f 100644 --- a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_initialize.cu +++ b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_initialize.cu @@ -28,13 +28,13 @@ #include "../fc2d_cudaclaw_cuda.h" #include "../fc2d_cudaclaw_check.h" -#include +#include #if defined(FCLAW_ENABLE_MPI) #endif #include -void fc2d_cudaclaw_initialize_GPUs(fclaw2d_global_t *glob) +void fc2d_cudaclaw_initialize_GPUs(fclaw_global_t *glob) { cudaDeviceProp prop; diff --git a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_step2.cu b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_step2.cu index 3f2507aa8..ab76a456e 100644 --- a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_step2.cu +++ b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_step2.cu @@ -5,12 +5,12 @@ #include "cudaclaw_allocate.h" /* Needed for def of cudaclaw_fluxes_t */ -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include #include #include "../fc2d_cudaclaw_check.h" /* CHECK defined here */ @@ -46,7 +46,7 @@ void cudaclaw_compute_speeds_batch (const int mx, const int my, cudaclaw_cuda_b4step2_t b4step2); -double cudaclaw_step2_batch(fclaw2d_global_t *glob, +double cudaclaw_step2_batch(fclaw_global_t *glob, cudaclaw_fluxes_t* array_fluxes_struct, int batch_size, double t, double dt) { @@ -69,7 +69,7 @@ double cudaclaw_step2_batch(fclaw2d_global_t *glob, /* To get patch-independent parameters */ fc2d_cudaclaw_options_t *clawopt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; /* ---------------------------------- start code ---------------------------------- */ FCLAW_ASSERT(batch_size > 0); @@ -84,7 +84,7 @@ double cudaclaw_step2_batch(fclaw2d_global_t *glob, FCLAW_ASSERT(cuclaw_vt->cuda_rpt2 != NULL); } - clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + clawpatch_opt = fclaw_clawpatch_get_options(glob); mx = clawpatch_opt->mx; my = clawpatch_opt->my; mbc = clawpatch_opt->mbc; @@ -98,7 +98,7 @@ double cudaclaw_step2_batch(fclaw2d_global_t *glob, /* ---------------------------------- Merge Memory ---------------------------------*/ membuffer_cpu = cudaclaw_get_cpu_membuffer(); membuffer_dev = cudaclaw_get_gpu_membuffer(); - fclaw2d_timer_start_threadsafe (&glob->timers[FCLAW2D_TIMER_CUDA_MEMCOPY_H2H]); + fclaw_timer_start_threadsafe (&glob->timers[FCLAW_TIMER_CUDA_MEMCOPY_H2H]); { PROFILE_CUDA_GROUP("Copy data on patches to CPU memory buffer",5); for(i = 0; i < batch_size; i++) @@ -117,16 +117,16 @@ double cudaclaw_step2_batch(fclaw2d_global_t *glob, } } } - fclaw2d_timer_stop_threadsafe(&glob->timers[FCLAW2D_TIMER_CUDA_MEMCOPY_H2H]); + fclaw_timer_stop_threadsafe(&glob->timers[FCLAW_TIMER_CUDA_MEMCOPY_H2H]); - fclaw2d_timer_start_threadsafe(&glob->timers[FCLAW2D_TIMER_CUDA_MEMCOPY_H2D]); + fclaw_timer_start_threadsafe(&glob->timers[FCLAW_TIMER_CUDA_MEMCOPY_H2D]); { PROFILE_CUDA_GROUP("Copy CPU buffer to device memory",3); CHECK(cudaMemcpy(membuffer_dev, membuffer_cpu, bytes, cudaMemcpyHostToDevice)); } - fclaw2d_timer_stop_threadsafe(&glob->timers[FCLAW2D_TIMER_CUDA_MEMCOPY_H2D]); + fclaw_timer_stop_threadsafe(&glob->timers[FCLAW_TIMER_CUDA_MEMCOPY_H2D]); /* -------------------------------- Work with array --------------------------------*/ @@ -242,7 +242,7 @@ double cudaclaw_step2_batch(fclaw2d_global_t *glob, /* -------------------------- Copy q back to host ----------------------------------*/ - fclaw2d_timer_start_threadsafe (&glob->timers[FCLAW2D_TIMER_CUDA_MEMCOPY_D2H]); + fclaw_timer_start_threadsafe (&glob->timers[FCLAW_TIMER_CUDA_MEMCOPY_D2H]); { PROFILE_CUDA_GROUP("Copy device memory buffer back to CPU",3); @@ -250,9 +250,9 @@ double cudaclaw_step2_batch(fclaw2d_global_t *glob, CHECK(cudaMemcpy(membuffer_cpu, membuffer_dev, batch_size*fluxes->num_bytes, cudaMemcpyDeviceToHost)); } - fclaw2d_timer_stop_threadsafe (&glob->timers[FCLAW2D_TIMER_CUDA_MEMCOPY_D2H]); + fclaw_timer_stop_threadsafe (&glob->timers[FCLAW_TIMER_CUDA_MEMCOPY_D2H]); - fclaw2d_timer_start_threadsafe (&glob->timers[FCLAW2D_TIMER_CUDA_MEMCOPY_H2H]); + fclaw_timer_start_threadsafe (&glob->timers[FCLAW_TIMER_CUDA_MEMCOPY_H2H]); { PROFILE_CUDA_GROUP("Copy CPU buffer back to patches",5); for (i = 0; i < batch_size; ++i) @@ -263,7 +263,7 @@ double cudaclaw_step2_batch(fclaw2d_global_t *glob, memcpy(fluxes->qold,&membuffer_cpu[I_q],fluxes->num_bytes); } } - fclaw2d_timer_stop_threadsafe (&glob->timers[FCLAW2D_TIMER_CUDA_MEMCOPY_H2H]); + fclaw_timer_stop_threadsafe (&glob->timers[FCLAW_TIMER_CUDA_MEMCOPY_H2H]); return maxcfl; } diff --git a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_store_patches.cu b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_store_patches.cu index 440c29250..f22c5dc30 100644 --- a/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_store_patches.cu +++ b/src/solvers/fc2d_cudaclaw/cuda_source/cudaclaw_store_patches.cu @@ -1,15 +1,15 @@ #include "../fc2d_cudaclaw.h" -#include -#include +#include +#include -#include +#include #include #include "cudaclaw_allocate.h" #include -void cudaclaw_store_buffer(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, +void cudaclaw_store_buffer(fclaw_global_t* glob, + fclaw_patch_t *this_patch, int this_patch_idx, int count, int iter, cudaclaw_fluxes_t* flux_array) @@ -22,12 +22,12 @@ void cudaclaw_store_buffer(fclaw2d_global_t* glob, cudaclaw_fluxes_t *fluxes = (cudaclaw_fluxes_t*) - fclaw2d_patch_get_user_data(glob,this_patch); + fclaw_patch_get_user_data(glob,this_patch); FCLAW_ASSERT(fluxes != NULL); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); - fclaw2d_clawpatch_soln_data(glob,this_patch,&qold,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&qold,&meqn); fluxes->qold = qold; fluxes->aux = aux; diff --git a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.cpp b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.cpp index 134d36d3e..4593ea817 100644 --- a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.cpp +++ b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.cpp @@ -33,18 +33,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include #include #include "fc2d_cudaclaw_cuda.h" @@ -55,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* --------------------- Clawpack solver functions (required) ------------------------- */ static -void cudaclaw_setprob(fclaw2d_global_t *glob) +void cudaclaw_setprob(fclaw_global_t *glob) { fc2d_cudaclaw_vtable_t* cudaclaw_vt = fc2d_cudaclaw_vt(glob); if (cudaclaw_vt->fort_setprob != NULL) @@ -67,8 +67,8 @@ void cudaclaw_setprob(fclaw2d_global_t *glob) static -void cudaclaw_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw_qinit(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -80,11 +80,11 @@ void cudaclaw_qinit(fclaw2d_global_t *glob, double dx,dy,xlower,ylower; double *q, *aux; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); maxmx = mx; maxmy = my; @@ -98,8 +98,8 @@ void cudaclaw_qinit(fclaw2d_global_t *glob, static -void cudaclaw_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw_bc2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -118,10 +118,10 @@ void cudaclaw_bc2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); maxmx = mx; maxmy = my; @@ -148,7 +148,7 @@ void cudaclaw_bc2(fclaw2d_global_t *glob, In this case, this boundary condition won't be used to update anything */ - fclaw2d_clawpatch_timesync_data(glob,this_patch,time_interp,&q,&meqn); + fclaw_clawpatch_timesync_data(glob,this_patch,time_interp,&q,&meqn); CUDACLAW_SET_BLOCK(&this_block_idx); cudaclaw_vt->fort_bc2(&maxmx,&maxmy,&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -158,8 +158,8 @@ void cudaclaw_bc2(fclaw2d_global_t *glob, static -void cudaclaw_b4step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw_b4step2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, double dt) @@ -177,11 +177,11 @@ void cudaclaw_b4step2(fclaw2d_global_t *glob, return; } - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); maxmx = mx; maxmy = my; @@ -193,8 +193,8 @@ void cudaclaw_b4step2(fclaw2d_global_t *glob, } static -void cudaclaw_src2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw_src2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -213,11 +213,11 @@ void cudaclaw_src2(fclaw2d_global_t *glob, return; } - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); maxmx = mx; maxmy = my; @@ -231,8 +231,8 @@ void cudaclaw_src2(fclaw2d_global_t *glob, /* This can be used as a value for patch_vt->patch_setup */ static -void cudaclaw_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw_setaux(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -245,7 +245,7 @@ void cudaclaw_setaux(fclaw2d_global_t *glob, return; } - if (fclaw2d_patch_is_ghost(this_patch)) + if (fclaw_patch_is_ghost(this_patch)) { /* This is going to be removed at some point */ return; @@ -255,10 +255,10 @@ void cudaclaw_setaux(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); maxmx = mx; maxmy = my; @@ -270,8 +270,8 @@ void cudaclaw_setaux(fclaw2d_global_t *glob, } static -double cudaclaw_update(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double cudaclaw_update(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -300,21 +300,21 @@ double cudaclaw_update(fclaw2d_global_t *glob, #endif /* -------------------------------- Main update ----------------------------------- */ - fclaw2d_timer_start_threadsafe (&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_start_threadsafe (&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); cuclaw_opt = fc2d_cudaclaw_get_options(glob); maxcfl = 0.0; - fclaw2d_single_step_buffer_data_t *buffer_data = - (fclaw2d_single_step_buffer_data_t*) user; + fclaw_single_step_buffer_data_t *buffer_data = + (fclaw_single_step_buffer_data_t*) user; patch_buffer_len = cuclaw_opt->buffer_len; iter = buffer_data->iter; total = buffer_data->total_count; /* Be sure to save current step! */ - fclaw2d_clawpatch_save_current_step(glob, this_patch); + fclaw_clawpatch_save_current_step(glob, this_patch); maxcfl = 0; @@ -353,7 +353,7 @@ double cudaclaw_update(fclaw2d_global_t *glob, FCLAW_FREE(buffer_data->user); } - fclaw2d_timer_stop_threadsafe (&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_stop_threadsafe (&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); /* -------------------------------- Source term ----------------------------------- */ if (cuclaw_opt->src_term > 0) @@ -371,19 +371,19 @@ double cudaclaw_update(fclaw2d_global_t *glob, /* ---------------------------------- Output functions -------------------------------- */ static -void cudaclaw_output(fclaw2d_global_t *glob, int iframe) +void cudaclaw_output(fclaw_global_t *glob, int iframe) { const fc2d_cudaclaw_options_t* clawpack_options; clawpack_options = fc2d_cudaclaw_get_options(glob); if (clawpack_options->ascii_out != 0) { - fclaw2d_clawpatch_output_ascii(glob,iframe); + fclaw_clawpatch_output_ascii(glob,iframe); } if (clawpack_options->vtk_out != 0) { - fclaw2d_clawpatch_output_vtk(glob,iframe); + fclaw_clawpatch_output_vtk(glob,iframe); } } @@ -402,9 +402,9 @@ void cudaclaw_vt_destroy(void* vt) FCLAW_FREE (vt); } -void fc2d_cudaclaw_solver_initialize(fclaw2d_global_t* glob) +void fc2d_cudaclaw_solver_initialize(fclaw_global_t* glob) { - fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_get_options(glob); fc2d_cudaclaw_options_t* clawopt = fc2d_cudaclaw_get_options(glob); clawopt->method[6] = clawpatch_opt->maux; @@ -416,10 +416,10 @@ void fc2d_cudaclaw_solver_initialize(fclaw2d_global_t* glob) } int claw_version = 4; - fclaw2d_clawpatch_vtable_initialize(glob, claw_version); + fclaw_clawpatch_vtable_initialize(glob, claw_version); - fclaw2d_vtable_t* fclaw_vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_vtable_t* fc_vt = fclaw_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); fc2d_cudaclaw_vtable_t* cudaclaw_vt = cudaclaw_vt_new(); @@ -429,8 +429,8 @@ void fc2d_cudaclaw_solver_initialize(fclaw2d_global_t* glob) #endif /* ForestClaw vtable items */ - fclaw_vt->output_frame = cudaclaw_output; - fclaw_vt->problem_setup = cudaclaw_setprob; + fc_vt->output_frame = cudaclaw_output; + fc_vt->problem_setup = cudaclaw_setprob; /* These could be over-written by user specific settings */ patch_vt->initialize = cudaclaw_qinit; @@ -470,7 +470,7 @@ void fc2d_cudaclaw_solver_initialize(fclaw2d_global_t* glob) /* These are here in case the user wants to call Clawpack routines directly */ -fc2d_cudaclaw_vtable_t* fc2d_cudaclaw_vt(fclaw2d_global_t *glob) +fc2d_cudaclaw_vtable_t* fc2d_cudaclaw_vt(fclaw_global_t *glob) { fc2d_cudaclaw_vtable_t* cudaclaw_vt = (fc2d_cudaclaw_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fc2d_cudaclaw"); @@ -480,8 +480,8 @@ fc2d_cudaclaw_vtable_t* fc2d_cudaclaw_vt(fclaw2d_global_t *glob) } /* This should only be called when a new fclaw2d_clawpatch_t is created. */ -void fc2d_cudaclaw_set_capacity(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw_set_capacity(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -493,12 +493,12 @@ void fc2d_cudaclaw_set_capacity(fclaw2d_global_t *glob, clawopt = fc2d_cudaclaw_get_options(glob); mcapa = clawopt->mcapa; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - area = fclaw2d_clawpatch_get_area(glob,this_patch); + area = fclaw_clawpatch_get_2d_area(glob,this_patch); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); FCLAW_ASSERT(maux >= mcapa && mcapa > 0); CUDACLAW_SET_CAPACITY(&mx,&my,&mbc,&dx,&dy,area,&mcapa, @@ -510,14 +510,14 @@ void fc2d_cudaclaw_set_capacity(fclaw2d_global_t *glob, /* -------------------------- Public interface to Clawpack wrappers --------------------*/ /* These are overkill; it isn't obvious why the user would want these */ -void fc2d_cudaclaw_setprob(fclaw2d_global_t *glob) +void fc2d_cudaclaw_setprob(fclaw_global_t *glob) { cudaclaw_setprob(glob); } /* This can be set to cudaclaw_vt->src2 */ -void fc2d_cudaclaw_src2(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw_src2(fclaw_global_t* glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -527,8 +527,8 @@ void fc2d_cudaclaw_src2(fclaw2d_global_t* glob, } -void fc2d_cudaclaw_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw_setaux(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -536,16 +536,16 @@ void fc2d_cudaclaw_setaux(fclaw2d_global_t *glob, } -void fc2d_cudaclaw_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw_qinit(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { cudaclaw_qinit(glob,this_patch,this_block_idx,this_patch_idx); } -void fc2d_cudaclaw_b4step2(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw_b4step2(fclaw_global_t* glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -554,8 +554,8 @@ void fc2d_cudaclaw_b4step2(fclaw2d_global_t* glob, cudaclaw_b4step2(glob,this_patch,this_block_idx,this_patch_idx,t,dt); } -void fc2d_cudaclaw_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw_bc2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.h b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.h index 85870129a..f248c33f4 100644 --- a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.h +++ b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.h @@ -36,8 +36,8 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; struct cudaclaw_fluxes; typedef struct fc2d_cudaclaw_vtable fc2d_cudaclaw_vtable_t; @@ -45,15 +45,15 @@ typedef struct fc2d_cudaclaw_vtable fc2d_cudaclaw_vtable_t; /* --------------------------- Clawpack solver functions ------------------------------ */ /* Virtualize clawpack-specific wrapper functions */ -typedef void (*cudaclaw_src2_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +typedef void (*cudaclaw_src2_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -typedef void (*cudaclaw_b4step2_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +typedef void (*cudaclaw_b4step2_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -174,7 +174,7 @@ struct fc2d_cudaclaw_vtable * * @param global the global context */ -void fc2d_cudaclaw_solver_initialize(struct fclaw2d_global* glob); +void fc2d_cudaclaw_solver_initialize(struct fclaw_global* glob); /** * @brief Get the cudaclaw vtable @@ -182,38 +182,38 @@ void fc2d_cudaclaw_solver_initialize(struct fclaw2d_global* glob); * @param global the global context * @return fc2d_cudaclaw_vtable_t* the vtable */ -fc2d_cudaclaw_vtable_t* fc2d_cudaclaw_vt(struct fclaw2d_global* glob); +fc2d_cudaclaw_vtable_t* fc2d_cudaclaw_vt(struct fclaw_global* glob); /* ----------------------------- User access to solver functions ---------------------- */ -void fc2d_cudaclaw_setprob(struct fclaw2d_global* glob); +void fc2d_cudaclaw_setprob(struct fclaw_global* glob); -void fc2d_cudaclaw_setaux(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw_setaux(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_cudaclaw_set_capacity(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw_set_capacity(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_cudaclaw_qinit(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw_qinit(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_cudaclaw_b4step2(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw_b4step2(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -void fc2d_cudaclaw_bc2(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw_bc2(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -221,8 +221,8 @@ void fc2d_cudaclaw_bc2(struct fclaw2d_global *glob, int intersects_bc[], int time_interp); -void fc2d_cudaclaw_src2(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw_src2(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.h.TEST.cpp b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.h.TEST.cpp index a5702ff7f..906ab9a22 100644 --- a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.h.TEST.cpp +++ b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw.h.TEST.cpp @@ -23,91 +23,91 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include -#include +#include #include TEST_CASE("fc2d_cudaclaw_solver_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); /* create some empty options structures */ - fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_clawpatch_options_t,1)); fc2d_cudaclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1)); - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_clawpatch_options_t,1)); fc2d_cudaclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc2d_cudaclaw_solver_initialize(glob1); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_cudaclaw_solver_initialize(glob2); CHECK_NE(fc2d_cudaclaw_vt(glob1), fc2d_cudaclaw_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_cudaclaw_solver_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_global_t* glob = fclaw_global_new(); /* create some empty options structures */ - fclaw2d_clawpatch_options_store(glob, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob, FCLAW_ALLOC_ZERO(fclaw_clawpatch_options_t,1)); fc2d_cudaclaw_options_store(glob, FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1)); - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_cudaclaw_solver_initialize(glob); CHECK_UNARY(fc2d_cudaclaw_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_cudaclaw_vt fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); CHECK_SC_ABORTED(fc2d_cudaclaw_vt(glob1)); CHECK_SC_ABORTED(fc2d_cudaclaw_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_cudaclaw_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); /* create some empty options structures */ - fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_clawpatch_options_t,1)); fc2d_cudaclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1)); - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_clawpatch_options_t,1)); fc2d_cudaclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc2d_cudaclaw_solver_initialize(glob1); CHECK_SC_ABORTED(fc2d_cudaclaw_solver_initialize(glob1)); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_cudaclaw_solver_initialize(glob2); CHECK_SC_ABORTED(fc2d_cudaclaw_solver_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_cuda.h b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_cuda.h index f96debdb0..4d96c0404 100644 --- a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_cuda.h +++ b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_cuda.h @@ -42,8 +42,8 @@ extern "C" #define FC2D_CUDACLAW_MWAVES 10 /* Used to set shared memory (checked) */ -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; struct cudaclaw_fluxes; @@ -75,19 +75,19 @@ typedef void (*cudaclaw_cuda_speeds_t)(int idir, int meqn, int mwaves, int maux, /* ------------------------------------- Function headers ------------------------------*/ -void cudaclaw_allocate_fluxes(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch); +void cudaclaw_allocate_fluxes(struct fclaw_global *glob, + struct fclaw_patch *patch); -void cudaclaw_deallocate_fluxes(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch); +void cudaclaw_deallocate_fluxes(struct fclaw_global *glob, + struct fclaw_patch *patch); -double cudaclaw_step2_batch(struct fclaw2d_global* glob, +double cudaclaw_step2_batch(struct fclaw_global* glob, struct cudaclaw_fluxes* fluxes_array, int patch_buffer_len, double t, double dt); -void cudaclaw_store_buffer(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void cudaclaw_store_buffer(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_atch_idx, int count, int iter, struct cudaclaw_fluxes* flux_array); @@ -100,11 +100,11 @@ struct cudaclaw_fluxes* cudaclaw_get_flux_buffer(); /* --------------------------- Function headers (used outside) -------------------------*/ -void fc2d_cudaclaw_allocate_buffers(struct fclaw2d_global *glob); /* Done once */ +void fc2d_cudaclaw_allocate_buffers(struct fclaw_global *glob); /* Done once */ -void fc2d_cudaclaw_deallocate_buffers(struct fclaw2d_global *glob); +void fc2d_cudaclaw_deallocate_buffers(struct fclaw_global *glob); -void fc2d_cudaclaw_initialize_GPUs(struct fclaw2d_global *glob); +void fc2d_cudaclaw_initialize_GPUs(struct fclaw_global *glob); void cudaclaw_get_method_parameters(int** order, int** mthlim); diff --git a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.c b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.c index 77d8fd912..afd1b40eb 100644 --- a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.c +++ b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.c @@ -25,8 +25,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_cudaclaw_options.h" -#include -#include +#include +#include #include #include @@ -219,7 +219,7 @@ fc2d_cudaclaw_options_t* fc2d_cudaclaw_options_register (fclaw_app_t * app, return clawopt; } -fc2d_cudaclaw_options_t* fc2d_cudaclaw_get_options(fclaw2d_global_t *glob) +fc2d_cudaclaw_options_t* fc2d_cudaclaw_get_options(fclaw_global_t *glob) { fc2d_cudaclaw_options_t* clawopt = (fc2d_cudaclaw_options_t*) fclaw_pointer_map_get(glob->options, "fc2d_cudaclaw"); @@ -227,7 +227,7 @@ fc2d_cudaclaw_options_t* fc2d_cudaclaw_get_options(fclaw2d_global_t *glob) return clawopt; } -void fc2d_cudaclaw_options_store (fclaw2d_global_t* glob, fc2d_cudaclaw_options_t* clawopt) +void fc2d_cudaclaw_options_store (fclaw_global_t* glob, fc2d_cudaclaw_options_t* clawopt) { FCLAW_ASSERT(fclaw_pointer_map_get(glob->options,"fc2d_cudaclaw") == NULL); fclaw_pointer_map_insert(glob->options, "fc2d_cudaclaw", clawopt, NULL); diff --git a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.h b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.h index 54b7fdf87..33548dc9b 100644 --- a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.h +++ b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.h @@ -36,7 +36,7 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; typedef struct fc2d_cudaclaw_options fc2d_cudaclaw_options_t; struct fc2d_cudaclaw_options @@ -88,11 +88,11 @@ fc2d_cudaclaw_options_t* fc2d_cudaclaw_options_register (fclaw_app_t * app, void fc2d_cudaclaw_package_register(fclaw_app_t* app, fc2d_cudaclaw_options_t* clawopt); -fc2d_cudaclaw_options_t* fc2d_cudaclaw_get_options(struct fclaw2d_global *glob); +fc2d_cudaclaw_options_t* fc2d_cudaclaw_get_options(struct fclaw_global *glob); -void fc2d_cudaclaw_options_store (struct fclaw2d_global* glob, fc2d_cudaclaw_options_t* clawopt); +void fc2d_cudaclaw_options_store (struct fclaw_global* glob, fc2d_cudaclaw_options_t* clawopt); -void fc2d_cudaclaw_output(struct fclaw2d_global *glob, int iframe); +void fc2d_cudaclaw_output(struct fclaw_global *glob, int iframe); int cudaclaw_check_parameters(int mwaves); void cudaclaw_set_method_parameters(int order[], int mthlim[], int mwaves, int use_fwaves); diff --git a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.h.TEST.cpp b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.h.TEST.cpp index 1b5f806e4..2c52d9962 100644 --- a/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.h.TEST.cpp +++ b/src/solvers/fc2d_cudaclaw/fc2d_cudaclaw_options.h.TEST.cpp @@ -23,50 +23,50 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include TEST_CASE("fc2d_cudaclaw_options can store options in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_cudaclaw_options_t* opts1 = FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1); fc2d_cudaclaw_options_t* opts2 = FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1); fc2d_cudaclaw_options_store(glob1, opts1); /* glob1 has one package glob2 has two */ - fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); + fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_cudaclaw_options_store(glob2, opts2); CHECK_EQ(fc2d_cudaclaw_get_options(glob1), opts1); CHECK_EQ(fc2d_cudaclaw_get_options(glob2), opts2); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_cudaclaw_get_options fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); CHECK_SC_ABORTED(fc2d_cudaclaw_get_options(glob1)); CHECK_SC_ABORTED(fc2d_cudaclaw_get_options(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_cudaclaw_options_store fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_cudaclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1)); CHECK_SC_ABORTED(fc2d_cudaclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1))); @@ -74,8 +74,8 @@ TEST_CASE("fc2d_cudaclaw_options_store fails if called twice on a glob") fc2d_cudaclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1)); CHECK_SC_ABORTED(fc2d_cudaclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_cudaclaw_options_t,1))); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc2d_cudaclaw5/CMakeLists.txt b/src/solvers/fc2d_cudaclaw5/CMakeLists.txt index 3a198bc35..b04d3c446 100644 --- a/src/solvers/fc2d_cudaclaw5/CMakeLists.txt +++ b/src/solvers/fc2d_cudaclaw5/CMakeLists.txt @@ -51,14 +51,11 @@ install(FILES fc2d_cudaclaw5_fort.h cuda_source/cudaclaw5_update_q.h cuda_source/cudaclaw5_allocate.h - DESTINATION include + TYPE INCLUDE ) install(TARGETS cudaclaw5 - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # imported target, for use from FetchContent add_library(FORESTCLAW::CUDACLAW5 INTERFACE IMPORTED GLOBAL) diff --git a/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_allocate.cu b/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_allocate.cu index d53d4e7e0..051b36f66 100644 --- a/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_allocate.cu +++ b/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_allocate.cu @@ -2,18 +2,18 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include -void cudaclaw5_allocate_fluxes(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch) +void cudaclaw5_allocate_fluxes(struct fclaw_global *glob, + struct fclaw_patch *patch) { - const fclaw2d_clawpatch_options_t *claw_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *claw_opt = fclaw_clawpatch_get_options(glob); int mx = claw_opt->mx; int my = claw_opt->my; int mbc = claw_opt->mbc; @@ -32,7 +32,7 @@ void cudaclaw5_allocate_fluxes(struct fclaw2d_global *glob, fluxes->num_bytes_speeds = mwaves*size; /* Assumption here is that cudaMalloc is a synchronous call */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_CUDA_ALLOCATE]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_CUDA_ALLOCATE]); cudaMalloc((void**)&fluxes->qold_dev, fluxes->num_bytes); cudaMalloc((void**)&fluxes->fm_dev, fluxes->num_bytes); @@ -43,21 +43,21 @@ void cudaclaw5_allocate_fluxes(struct fclaw2d_global *glob, cudaMalloc((void**)&fluxes->waves_dev, fluxes->num_bytes_waves); cudaMalloc((void**)&fluxes->speeds_dev, fluxes->num_bytes_speeds); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_CUDA_ALLOCATE]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_CUDA_ALLOCATE]); - fclaw2d_patch_set_user_data(glob,patch,fluxes); + fclaw_patch_set_user_data(glob,patch,fluxes); } -void cudaclaw5_deallocate_fluxes(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch) +void cudaclaw5_deallocate_fluxes(fclaw_global_t *glob, + fclaw_patch_t *patch) { cudaclaw5_fluxes_t *fluxes = (cudaclaw5_fluxes_t*) - fclaw2d_patch_get_user_data(glob,patch); + fclaw_patch_get_user_data(glob,patch); FCLAW_ASSERT(fluxes != NULL); /* Assumption here is that cudaFree is a synchronous call */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_CUDA_ALLOCATE]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_CUDA_ALLOCATE]); cudaFree(fluxes->qold_dev); cudaFree(fluxes->fm_dev); cudaFree(fluxes->fp_dev); @@ -66,7 +66,7 @@ void cudaclaw5_deallocate_fluxes(fclaw2d_global_t *glob, cudaFree(fluxes->aux_dev); cudaFree(fluxes->waves_dev); cudaFree(fluxes->speeds_dev); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_CUDA_ALLOCATE]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_CUDA_ALLOCATE]); FCLAW_FREE((void*) fluxes); } diff --git a/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_allocate.h b/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_allocate.h index 1937b8375..f821d55c3 100644 --- a/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_allocate.h +++ b/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_allocate.h @@ -12,8 +12,8 @@ extern "C" { #endif -struct fclaw2d_patch; -struct fclaw2d_global; +struct fclaw_patch; +struct fclaw_global; typedef struct cudaclaw5_fluxes { @@ -35,11 +35,11 @@ typedef struct cudaclaw5_fluxes } cudaclaw5_fluxes_t; -void cudaclaw5_allocate_fluxes(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch); +void cudaclaw5_allocate_fluxes(struct fclaw_global *glob, + struct fclaw_patch *patch); -void cudaclaw5_deallocate_fluxes(struct fclaw2d_global *glob, - struct fclaw2d_patch *patch); +void cudaclaw5_deallocate_fluxes(struct fclaw_global *glob, + struct fclaw_patch *patch); #ifdef __cplusplus diff --git a/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_step2.cu b/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_step2.cu index 220a333c4..0ac9eafd1 100644 --- a/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_step2.cu +++ b/src/solvers/fc2d_cudaclaw5/cuda_source/cudaclaw5_step2.cu @@ -1,9 +1,9 @@ #include "../fc2d_cudaclaw5.h" #include "cudaclaw5_allocate.h" -#include -#include -#include +#include +#include +#include #include "../fc2d_cudaclaw5_options.h" @@ -74,8 +74,8 @@ double cudaclaw5_compute_cfl(int idir, int mx, int my, int mbc, int mwaves, return cflgrid; } -double cudaclaw5_step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double cudaclaw5_step2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -97,7 +97,7 @@ double cudaclaw5_step2(fclaw2d_global_t *glob, fc2d_cudaclaw5_options_t* cuda_opt = fc2d_cudaclaw5_get_options(glob); cudaclaw5_fluxes_t *fluxes = (cudaclaw5_fluxes_t*) - fclaw2d_patch_get_user_data(glob,this_patch); + fclaw_patch_get_user_data(glob,this_patch); FCLAW_ASSERT(fluxes != NULL); @@ -106,11 +106,11 @@ double cudaclaw5_step2(fclaw2d_global_t *glob, FCLAW_ASSERT(cuclaw5_vt->cuda_rpn2 != NULL); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); - fclaw2d_clawpatch_save_current_step(glob, this_patch); - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_save_current_step(glob, this_patch); + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&qold,&meqn); + fclaw_clawpatch_soln_data(glob,this_patch,&qold,&meqn); #if 0 int mwork = (maxm+2*mbc)*(12*meqn + (meqn+1)*mwaves + 3*maux + 2); @@ -121,9 +121,9 @@ double cudaclaw5_step2(fclaw2d_global_t *glob, int ierror = 0; // cudaclaw5_fort_flux2_t flux2 = CUDACLAW5_FLUX2; - int* block_corner_count = fclaw2d_patch_block_corner_count(glob,this_patch); + int* block_corner_count = fclaw_patch_block_corner_count(glob,this_patch); - size_t size = fclaw2d_clawpatch_size(glob); + size_t size = fclaw_clawpatch_size(glob); /* -------------------------- Construct fluctuations -------------------------------*/ cudaEventRecord(start); diff --git a/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5.cpp b/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5.cpp index 0a65785d0..c12266c54 100644 --- a/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5.cpp +++ b/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5.cpp @@ -31,16 +31,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "cuda_source/cudaclaw5_allocate.h" -#include -#include +#include +#include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #include @@ -49,7 +49,7 @@ static fc2d_cudaclaw5_vtable_t s_cudaclaw5_vt; /* -------------------------- Clawpack solver functions ------------------------------ */ static -void cudaclaw5_setprob(fclaw2d_global_t *glob) +void cudaclaw5_setprob(fclaw_global_t *glob) { fc2d_cudaclaw5_vtable_t* cuclaw5_vt = fc2d_cudaclaw5_vt(); if (cuclaw5_vt->fort_setprob != NULL) @@ -60,8 +60,8 @@ void cudaclaw5_setprob(fclaw2d_global_t *glob) /* This should only be called when a new fclaw2d_clawpatch_t is created. */ static -void cudaclaw5_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw5_setaux(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -71,7 +71,7 @@ void cudaclaw5_setaux(fclaw2d_global_t *glob, return; } - if (fclaw2d_patch_is_ghost(this_patch)) + if (fclaw_patch_is_ghost(this_patch)) { /* This is going to be removed at some point */ return; @@ -83,9 +83,9 @@ void cudaclaw5_setaux(fclaw2d_global_t *glob, double *aux; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); CUDACLAW5_SET_BLOCK(&this_block_idx); cuclaw5_vt->fort_setaux(&mbc,&mx,&my,&xlower,&ylower,&dx,&dy, @@ -94,8 +94,8 @@ void cudaclaw5_setaux(fclaw2d_global_t *glob, } static -void cudaclaw5_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw5_qinit(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -106,11 +106,11 @@ void cudaclaw5_qinit(fclaw2d_global_t *glob, double dx,dy,xlower,ylower; double *q, *aux; - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); /* Call to classic Clawpack 'qinit' routine. This must be user defined */ CUDACLAW5_SET_BLOCK(&this_block_idx); @@ -120,8 +120,8 @@ void cudaclaw5_qinit(fclaw2d_global_t *glob, } static -void cudaclaw5_b4step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw5_b4step2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, double dt) @@ -138,11 +138,11 @@ void cudaclaw5_b4step2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); CUDACLAW5_SET_BLOCK(&this_block_idx); cuclaw5_vt->fort_b4step2(&mbc,&mx,&my,&meqn,q,&xlower,&ylower, @@ -151,8 +151,8 @@ void cudaclaw5_b4step2(fclaw2d_global_t *glob, } static -void cudaclaw5_src2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw5_src2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -169,11 +169,11 @@ void cudaclaw5_src2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); CUDACLAW5_SET_BLOCK(&this_block_idx); cuclaw5_vt->fort_src2(&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -182,8 +182,8 @@ void cudaclaw5_src2(fclaw2d_global_t *glob, } static -void cudaclaw5_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void cudaclaw5_bc2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -201,10 +201,10 @@ void cudaclaw5_bc2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); int *block_mthbc = clawopt->mthbc; @@ -228,7 +228,7 @@ void cudaclaw5_bc2(fclaw2d_global_t *glob, In this case, this boundary condition won't be used to update anything */ - fclaw2d_clawpatch_timesync_data(glob,this_patch,time_interp,&q,&meqn); + fclaw_clawpatch_timesync_data(glob,this_patch,time_interp,&q,&meqn); CUDACLAW5_SET_BLOCK(&this_block_idx); cuclaw5_vt->fort_bc2(&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -238,8 +238,8 @@ void cudaclaw5_bc2(fclaw2d_global_t *glob, } static -double cudaclaw5_update(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double cudaclaw5_update(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -253,20 +253,20 @@ double cudaclaw5_update(fclaw2d_global_t *glob, if (cuclaw5_vt->b4step2 != NULL) { - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_ADVANCE_B4STEP2]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_ADVANCE_B4STEP2]); cuclaw5_vt->b4step2(glob, this_patch, this_block_idx, this_patch_idx,t,dt); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_ADVANCE_B4STEP2]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_ADVANCE_B4STEP2]); } - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); double maxcfl = cudaclaw5_step2(glob, this_patch, this_block_idx, this_patch_idx,t,dt); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); if (cudaclaw_options->src_term > 0 && cuclaw5_vt->src2 != NULL) { @@ -281,19 +281,19 @@ double cudaclaw5_update(fclaw2d_global_t *glob, /* ---------------------------------- Output functions -------------------------------- */ static -void cudaclaw5_output(fclaw2d_global_t *glob, int iframe) +void cudaclaw5_output(fclaw_global_t *glob, int iframe) { const fc2d_cudaclaw5_options_t* cudaclaw_options; cudaclaw_options = fc2d_cudaclaw5_get_options(glob); if (cudaclaw_options->ascii_out != 0) { - fclaw2d_clawpatch_output_ascii(glob,iframe); + fclaw_clawpatch_output_ascii(glob,iframe); } if (cudaclaw_options->vtk_out != 0) { - fclaw2d_clawpatch_output_vtk(glob,iframe); + fclaw_clawpatch_output_vtk(glob,iframe); } } @@ -316,10 +316,10 @@ void fc2d_cudaclaw5_solver_initialize() //fc2d_clawpack46_solver_initialize(glob); int claw_version = 5; - fclaw2d_clawpatch_vtable_initialize(claw_version); + fclaw_clawpatch_vtable_initialize(claw_version); - fclaw2d_vtable_t* fclaw_vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_vtable_t* fclaw_vt = fclaw_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); fc2d_cudaclaw5_vtable_t* cuclaw5_vt = fc2d_cudaclaw5_vt_init(); @@ -367,13 +367,13 @@ fc2d_cudaclaw5_vtable_t* fc2d_cudaclaw5_vt() } -void fc2d_cudaclaw5_setprob(fclaw2d_global_t *glob) +void fc2d_cudaclaw5_setprob(fclaw_global_t *glob) { cudaclaw5_setprob(glob); } -void fc2d_cudaclaw5_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw5_setaux(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -382,8 +382,8 @@ void fc2d_cudaclaw5_setaux(fclaw2d_global_t *glob, /* This should only be called when a new fclaw2d_clawpatch_t is created. */ -void fc2d_cudaclaw5_set_capacity(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw5_set_capacity(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -395,28 +395,28 @@ void fc2d_cudaclaw5_set_capacity(fclaw2d_global_t *glob, clawopt = fc2d_cudaclaw5_get_options(glob); mcapa = clawopt->mcapa; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - area = fclaw2d_clawpatch_get_area(glob,this_patch); + area = fclaw_clawpatch_get_2d_area(glob,this_patch); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); FCLAW_ASSERT(maux >= mcapa && mcapa > 0); CUDACLAW5_SET_CAPACITY(&mx,&my,&mbc,&dx,&dy,area,&mcapa, &maux,aux); } -void fc2d_cudaclaw5_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw5_qinit(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { cudaclaw5_qinit(glob,this_patch,this_block_idx,this_patch_idx); } -void fc2d_cudaclaw5_b4step2(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw5_b4step2(fclaw_global_t* glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -425,8 +425,8 @@ void fc2d_cudaclaw5_b4step2(fclaw2d_global_t* glob, cudaclaw5_b4step2(glob,this_patch,this_block_idx,this_patch_idx,t,dt); } -void fc2d_cudaclaw5_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw5_bc2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -438,8 +438,8 @@ void fc2d_cudaclaw5_bc2(fclaw2d_global_t *glob, intersects_bc,time_interp); } -void fc2d_cudaclaw5_src2(fclaw2d_global_t* glob, - fclaw2d_patch_t *this_patch, +void fc2d_cudaclaw5_src2(fclaw_global_t* glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5.h b/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5.h index cc9ca76ee..e5ebe3d2b 100644 --- a/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5.h +++ b/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5.h @@ -36,8 +36,8 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; #if 0 /* to get syntax highlighting */ @@ -46,15 +46,15 @@ struct fclaw2d_patch; /* --------------------------- Clawpack solver functions ------------------------------ */ /* Virtualize clawpack-specific wrapper functions */ -typedef void (*cudaclaw5_src2_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +typedef void (*cudaclaw5_src2_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -typedef void (*cudaclaw5_b4step2_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +typedef void (*cudaclaw5_b4step2_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -142,8 +142,8 @@ typedef void (*cudaclaw5_fort_fluxfun_t)(const int* meqn, double q[], double aux /* ------------------------------ CUDA functions ------------------------------------ */ -double cudaclaw5_step2(struct fclaw2d_global* glob, - struct fclaw2d_patch* this_patch, +double cudaclaw5_step2(struct fclaw_global* glob, + struct fclaw_patch* this_patch, int this_block_idx, int this_patch_idx, double t, @@ -179,32 +179,32 @@ fc2d_cudaclaw5_vtable_t* fc2d_cudaclaw5_vt(); /* ----------------------------- User access to solver functions ---------------------- */ -void fc2d_cudaclaw5_setprob(struct fclaw2d_global* glob); +void fc2d_cudaclaw5_setprob(struct fclaw_global* glob); -void fc2d_cudaclaw5_setaux(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw5_setaux(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_cudaclaw5_set_capacity(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw5_set_capacity(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_cudaclaw5_qinit(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw5_qinit(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_cudaclaw5_b4step2(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw5_b4step2(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -void fc2d_cudaclaw5_bc2(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw5_bc2(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -212,8 +212,8 @@ void fc2d_cudaclaw5_bc2(struct fclaw2d_global *glob, int intersects_bc[], int time_interp); -void fc2d_cudaclaw5_src2(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc2d_cudaclaw5_src2(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5_options.c b/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5_options.c index 3ac7891c2..f6c6220c3 100644 --- a/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5_options.c +++ b/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5_options.c @@ -25,8 +25,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_cudaclaw5_options.h" -#include -#include +#include +#include #include static void* @@ -83,7 +83,7 @@ cudaclaw5_postprocess (fc2d_cudaclaw5_options_t * clawopt) fclaw_exit_type_t cudaclaw5_check (fc2d_cudaclaw5_options_t * clawopt, - fclaw2d_clawpatch_options_t *clawpatch_opt) + fclaw_clawpatch_options_t *clawpatch_opt) { clawopt->method[0] = 0; /* Time stepping is controlled outside of cudaclaw */ @@ -174,7 +174,7 @@ static fclaw_exit_type_t options_check (fclaw_app_t * app, void *package, void *registered) { fc2d_cudaclaw5_options_t *clawopt; - fclaw2d_clawpatch_options_t *clawpatch_opt; + fclaw_clawpatch_options_t *clawpatch_opt; FCLAW_ASSERT (app != NULL); FCLAW_ASSERT (package != NULL); @@ -183,7 +183,7 @@ options_check (fclaw_app_t * app, void *package, void *registered) clawopt = (fc2d_cudaclaw5_options_t*) package; FCLAW_ASSERT (clawopt->is_registered); - clawpatch_opt = (fclaw2d_clawpatch_options_t *) + clawpatch_opt = (fclaw_clawpatch_options_t *) fclaw_app_get_attribute(app,"clawpatch",NULL); FCLAW_ASSERT(clawpatch_opt->is_registered); @@ -231,12 +231,12 @@ fc2d_cudaclaw5_options_t* fc2d_cudaclaw5_options_register (fclaw_app_t * app, return clawopt; } -fc2d_cudaclaw5_options_t* fc2d_cudaclaw5_get_options(fclaw2d_global_t *glob) +fc2d_cudaclaw5_options_t* fc2d_cudaclaw5_get_options(fclaw_global_t *glob) { - return (fc2d_cudaclaw5_options_t*) fclaw2d_global_get_options(glob, "cudaclaw5"); + return (fc2d_cudaclaw5_options_t*) fclaw_global_get_options(glob, "cudaclaw5"); } -void fc2d_cudaclaw5_options_store (fclaw2d_global_t* glob, fc2d_cudaclaw5_options_t* clawopt) +void fc2d_cudaclaw5_options_store (fclaw_global_t* glob, fc2d_cudaclaw5_options_t* clawopt) { - fclaw2d_global_options_store(glob, "cudaclaw5", clawopt); + fclaw_global_options_store(glob, "cudaclaw5", clawopt); } diff --git a/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5_options.h b/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5_options.h index 4ead6b826..dc3fbf05b 100644 --- a/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5_options.h +++ b/src/solvers/fc2d_cudaclaw5/fc2d_cudaclaw5_options.h @@ -36,7 +36,7 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; typedef struct fc2d_cudaclaw5_options fc2d_cudaclaw5_options_t; @@ -72,12 +72,12 @@ fc2d_cudaclaw5_options_t *fc2d_cudaclaw5_options_register (fclaw_app_t * const char *configfile); -void fc2d_cudaclaw5_options_store (struct fclaw2d_global* glob, +void fc2d_cudaclaw5_options_store (struct fclaw_global* glob, fc2d_cudaclaw5_options_t* clawopt); -fc2d_cudaclaw5_options_t* fc2d_cudaclaw5_get_options(struct fclaw2d_global *glob); +fc2d_cudaclaw5_options_t* fc2d_cudaclaw5_get_options(struct fclaw_global *glob); -void fc2d_cudaclaw5_output(struct fclaw2d_global *glob, int iframe); +void fc2d_cudaclaw5_output(struct fclaw_global *glob, int iframe); /* Check in cudaclaw5_flux2.cu */ int cudaclaw5_check_dims(int meqn, int maux, int mwaves); diff --git a/src/solvers/fc2d_dummy/CMakeLists.txt b/src/solvers/fc2d_dummy/CMakeLists.txt index 2c781a93a..2fa035b6a 100644 --- a/src/solvers/fc2d_dummy/CMakeLists.txt +++ b/src/solvers/fc2d_dummy/CMakeLists.txt @@ -15,13 +15,11 @@ target_include_directories(dummy # -- install install(FILES fc2d_dummy.h + TYPE INCLUDE ) install(TARGETS dummy - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # imported target, for use from FetchContent add_library(FORESTCLAW::DUMMY INTERFACE IMPORTED GLOBAL) diff --git a/src/solvers/fc2d_dummy/fc2d_dummy.cpp b/src/solvers/fc2d_dummy/fc2d_dummy.cpp index 7bc4f7604..45b4bef9e 100644 --- a/src/solvers/fc2d_dummy/fc2d_dummy.cpp +++ b/src/solvers/fc2d_dummy/fc2d_dummy.cpp @@ -24,8 +24,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "fc2d_dummy.h" -#include -#include +#include +#include #include static int s_dummy_package_id = -1; @@ -93,8 +93,8 @@ int fc2d_dummy_package_id() return s_dummy_package_id; } -void fc2d_dummy_setup_patch(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void fc2d_dummy_setup_patch(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -102,7 +102,7 @@ void fc2d_dummy_setup_patch(fclaw2d_domain_t *domain, } -void fc2d_dummy_define_data(fclaw2d_domain_t* domain, fclaw2d_patch_t* this_patch) +void fc2d_dummy_define_data(fclaw_domain_t* domain, fclaw_patch_t* this_patch) { const fclaw_options_t *gparms = get_domain_parms(domain); ClawPatch *cp = fclaw2d_clawpatch_get_cp(this_patch); diff --git a/src/solvers/fc2d_dummy/fc2d_dummy.h b/src/solvers/fc2d_dummy/fc2d_dummy.h index c846b3338..e152508b2 100644 --- a/src/solvers/fc2d_dummy/fc2d_dummy.h +++ b/src/solvers/fc2d_dummy/fc2d_dummy.h @@ -27,7 +27,7 @@ #define FC2D_DUMMY_H #include -#include +#include #ifdef __cplusplus extern "C" @@ -41,12 +41,12 @@ void fc2d_dummy_register(fclaw_app_t *app); int fc2d_dummy_package_id(); -void fc2d_dummy_setup_patch(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void fc2d_dummy_setup_patch(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx); -void fc2d_dummy_define_data(fclaw2d_domain_t* domain,fclaw2d_patch_t* this_patch); +void fc2d_dummy_define_data(fclaw_domain_t* domain,fclaw_patch_t* this_patch); #ifdef __cplusplus #if 0 diff --git a/src/solvers/fc2d_geoclaw/CMakeLists.txt b/src/solvers/fc2d_geoclaw/CMakeLists.txt index fbcb50966..418638491 100644 --- a/src/solvers/fc2d_geoclaw/CMakeLists.txt +++ b/src/solvers/fc2d_geoclaw/CMakeLists.txt @@ -84,7 +84,7 @@ install(FILES fc2d_geoclaw_options.h fc2d_geoclaw_fort.h fc2d_geoclaw_gauges_default.h - DESTINATION include + TYPE INCLUDE ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/amr_module.mod @@ -99,14 +99,11 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/storm_module.mod ${CMAKE_CURRENT_BINARY_DIR}/include/topo_module.mod ${CMAKE_CURRENT_BINARY_DIR}/include/utility_module.mod - DESTINATION include + TYPE INCLUDE ) install(TARGETS geoclaw - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # imported target, for use from FetchContent diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw.cpp b/src/solvers/fc2d_geoclaw/fc2d_geoclaw.cpp index 725c75628..1ec010fe4 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw.cpp +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw.cpp @@ -33,23 +33,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "fc2d_geoclaw_gauges_default.h" -#include -#include -#include +#include +#include +#include /* Basic forestclaw functions */ -#include -#include /* Needed to get search function for gauges */ -#include "fclaw2d_options.h" -#include -#include -#include +#include +#include /* Needed to get search function for gauges */ +#include +#include +#include +#include #include /* Some mapping functions */ -#include -#include -#include +#include +#include +#include /* Needed for debugging */ @@ -59,8 +59,8 @@ struct region_type region_type_for_debug; /* ----------------------------- static function defs ------------------------------- */ static -void geoclaw_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void geoclaw_setaux(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno); @@ -69,8 +69,8 @@ void geoclaw_setaux(fclaw2d_global_t *glob, /* --------------------------- Creating/deleting patches ---------------------------- */ static -void geoclaw_patch_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void geoclaw_patch_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -82,7 +82,7 @@ void geoclaw_patch_setup(fclaw2d_global_t *glob, static -void geoclaw_setprob(fclaw2d_global_t *glob) +void geoclaw_setprob(fclaw_global_t *glob) { fc2d_geoclaw_vtable_t *geoclaw_vt = fc2d_geoclaw_vt(glob); if (geoclaw_vt->setprob != NULL) @@ -90,8 +90,8 @@ void geoclaw_setprob(fclaw2d_global_t *glob) } static -void geoclaw_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void geoclaw_qinit(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -100,16 +100,16 @@ void geoclaw_qinit(fclaw2d_global_t *glob, int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double* q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); /* Call to classic Clawpack 'qinit' routine. This must be user defined */ FC2D_GEOCLAW_SET_BLOCK(&blockno); @@ -119,8 +119,8 @@ void geoclaw_qinit(fclaw2d_global_t *glob, } static -void geoclaw_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void geoclaw_bc2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -135,12 +135,12 @@ void geoclaw_bc2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); int *block_mthbc = geo_opt->mthbc; @@ -166,7 +166,7 @@ void geoclaw_bc2(fclaw2d_global_t *glob, */ int meqn; double *q; - fclaw2d_clawpatch_timesync_data(glob,patch,time_interp,&q,&meqn); + fclaw_clawpatch_timesync_data(glob,patch,time_interp,&q,&meqn); FC2D_GEOCLAW_SET_BLOCK(&blockno); geoclaw_vt->bc2(&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -176,8 +176,8 @@ void geoclaw_bc2(fclaw2d_global_t *glob, } static -void geoclaw_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void geoclaw_setaux(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -186,15 +186,15 @@ void geoclaw_setaux(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); /* If this is a ghost patch, we only set aux values in ghost cells */ - int is_ghost = fclaw2d_patch_is_ghost(patch); + int is_ghost = fclaw_patch_is_ghost(patch); int mint = 2*mbc; int nghost = mbc; @@ -207,8 +207,8 @@ void geoclaw_setaux(fclaw2d_global_t *glob, static -void geoclaw_b4step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void geoclaw_b4step2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, double dt) @@ -220,16 +220,16 @@ void geoclaw_b4step2(fclaw2d_global_t *glob, { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); FC2D_GEOCLAW_SET_BLOCK(&blockno); geoclaw_vt->b4step2(&mbc,&mx,&my,&meqn,q,&xlower,&ylower, @@ -239,8 +239,8 @@ void geoclaw_b4step2(fclaw2d_global_t *glob, } static -void geoclaw_src2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void geoclaw_src2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -251,16 +251,16 @@ void geoclaw_src2(fclaw2d_global_t *glob, int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); FC2D_GEOCLAW_SET_BLOCK(&blockno); geoclaw_vt->src2(&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -271,8 +271,8 @@ void geoclaw_src2(fclaw2d_global_t *glob, /* This is called from the single_step callback. and is of type 'flaw_single_step_t' */ static -double geoclaw_step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +double geoclaw_step2(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -288,19 +288,19 @@ double geoclaw_step2(fclaw2d_global_t *glob, int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); /* In case we need to re-take this step */ - fclaw2d_clawpatch_save_current_step(glob, patch); + fclaw_clawpatch_save_current_step(glob, patch); int mx, my, mbc; double xlower, ylower, dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *qold; - fclaw2d_clawpatch_soln_data(glob,patch,&qold,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&qold,&meqn); /* Allocate work arrays */ int mwaves = geoclaw_options->mwaves; @@ -314,7 +314,7 @@ double geoclaw_step2(fclaw2d_global_t *glob, double* gp = new double[size]; double* gm = new double[size]; - int* block_corner_count = fclaw2d_patch_block_corner_count(glob,patch); + int* block_corner_count = fclaw_patch_block_corner_count(glob,patch); /* Still need conservation fix */ @@ -348,8 +348,8 @@ void fc2d_geoclaw_dt(fclaw2d_global_t *glob,double t, double* dt) static -double geoclaw_update(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +double geoclaw_update(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -384,7 +384,7 @@ double geoclaw_update(fclaw2d_global_t *glob, /* --------------------------------- Output functions ---------------------------- */ static -void geoclaw_output(fclaw2d_global_t *glob, int iframe) +void geoclaw_output(fclaw_global_t *glob, int iframe) { const fc2d_geoclaw_options_t*geo_opt = fc2d_geoclaw_get_options(glob); if (geo_opt->ascii_out != 0) @@ -396,24 +396,24 @@ void geoclaw_output(fclaw2d_global_t *glob, int iframe) static -int geoclaw_patch_tag4refinement(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +int geoclaw_patch_tag4refinement(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, int initflag) { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *q; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); int level = patch->level; double t = glob->curr_time; @@ -440,7 +440,7 @@ int geoclaw_patch_tag4refinement(fclaw2d_global_t *glob, if (tag_patch < 0) { /* Need maxlevel to get length speed_tolerance - hackish? */ - const fclaw_options_t * fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t * fclaw_opt = fclaw_get_options(glob); int maxlevel = fclaw_opt->maxlevel; FC2D_GEOCLAW_FORT_TAG4REFINEMENT(&mx,&my,&mbc,&meqn,&maux,&xlower,&ylower, &dx,&dy,&t,&blockno,q,aux,&level,&maxlevel, @@ -452,8 +452,8 @@ int geoclaw_patch_tag4refinement(fclaw2d_global_t *glob, static -int geoclaw_patch_tag4coarsening(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, +int geoclaw_patch_tag4coarsening(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, int blockno, int patchno, int initflag) @@ -464,10 +464,10 @@ int geoclaw_patch_tag4coarsening(fclaw2d_global_t *glob, double *q[4], *aux[4]; for (int igrid = 0; igrid < 4; igrid++) { - fclaw2d_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); - fclaw2d_clawpatch_aux_data(glob,&fine_patches[igrid],&aux[igrid],&maux); + fclaw_clawpatch_soln_data(glob,&fine_patches[igrid],&q[igrid],&meqn); + fclaw_clawpatch_aux_data(glob,&fine_patches[igrid],&aux[igrid],&maux); - fclaw2d_clawpatch_grid_data(glob,&fine_patches[igrid],&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,&fine_patches[igrid],&mx,&my,&mbc, &xlower[igrid],&ylower[igrid],&dx,&dy); } @@ -487,7 +487,7 @@ int geoclaw_patch_tag4coarsening(fclaw2d_global_t *glob, if (tag_patch < 0) { /* Region tagging is inconclusive */ - const fclaw_options_t * fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t * fclaw_opt = fclaw_get_options(glob); int maxlevel = fclaw_opt->maxlevel; FC2D_GEOCLAW_FORT_TAG4COARSENING(&blockno,&mx,&my,&mbc,&meqn,&maux,xlower,ylower, @@ -500,9 +500,9 @@ int geoclaw_patch_tag4coarsening(fclaw2d_global_t *glob, } static -void geoclaw_interpolate2fine(fclaw2d_global_t *glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patches, +void geoclaw_interpolate2fine(fclaw_global_t *glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patches, int blockno, int coarse_patchno, int fine0_patchno) @@ -510,27 +510,27 @@ void geoclaw_interpolate2fine(fclaw2d_global_t *glob, { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,coarse_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *qcoarse; - fclaw2d_clawpatch_soln_data(glob,coarse_patch,&qcoarse,&meqn); + fclaw_clawpatch_soln_data(glob,coarse_patch,&qcoarse,&meqn); int maux; double *auxcoarse; - fclaw2d_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); + fclaw_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); /* Loop over four siblings (z-ordering) */ for (int igrid = 0; igrid < 4; igrid++) { - fclaw2d_patch_t* fine_patch = &fine_patches[igrid]; + fclaw_patch_t* fine_patch = &fine_patches[igrid]; double *qfine; - fclaw2d_clawpatch_soln_data(glob,fine_patch,&qfine,&meqn); + fclaw_clawpatch_soln_data(glob,fine_patch,&qfine,&meqn); double *auxfine; - fclaw2d_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); + fclaw_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); FC2D_GEOCLAW_FORT_INTERPOLATE2FINE(&mx,&my,&mbc,&meqn,qcoarse,qfine, &maux,auxcoarse,auxfine, &igrid); @@ -538,9 +538,9 @@ void geoclaw_interpolate2fine(fclaw2d_global_t *glob, } static -void geoclaw_average2coarse(fclaw2d_global_t *glob, - fclaw2d_patch_t *fine_patches, - fclaw2d_patch_t *coarse_patch, +void geoclaw_average2coarse(fclaw_global_t *glob, + fclaw_patch_t *fine_patches, + fclaw_patch_t *coarse_patch, int blockno, int fine0_patchno, int coarse_patchno) @@ -549,27 +549,27 @@ void geoclaw_average2coarse(fclaw2d_global_t *glob, /* Only mx, my are needed here */ int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,coarse_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *qcoarse; - fclaw2d_clawpatch_soln_data(glob,coarse_patch,&qcoarse,&meqn); + fclaw_clawpatch_soln_data(glob,coarse_patch,&qcoarse,&meqn); int maux; double *auxcoarse; - fclaw2d_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); + fclaw_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); /* Loop over four siblings (z-ordering) */ for (int igrid = 0; igrid < 4; igrid++) { - fclaw2d_patch_t *fine_patch = &fine_patches[igrid]; + fclaw_patch_t *fine_patch = &fine_patches[igrid]; double *qfine; - fclaw2d_clawpatch_soln_data(glob,fine_patch,&qfine,&meqn); + fclaw_clawpatch_soln_data(glob,fine_patch,&qfine,&meqn); double *auxfine; - fclaw2d_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); + fclaw_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); const fc2d_geoclaw_options_t* geo_opt = fc2d_geoclaw_get_options(glob); int mcapa = geo_opt->mcapa; @@ -581,40 +581,40 @@ void geoclaw_average2coarse(fclaw2d_global_t *glob, /* ------------------------- Ghost filling - patch specific ------------------------ */ -void geoclaw_average_face(fclaw2d_global_t *glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, +void geoclaw_average_face(fclaw_global_t *glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, int idir, int iface_coarse, int p4est_refineFactor, int refratio, int time_interp, int igrid, - fclaw2d_patch_transform_data_t* transform_data) + fclaw_patch_transform_data_t* transform_data) { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,coarse_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); - double* qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); + double* qfine = fclaw_clawpatch_get_q(glob,fine_patch); /* These will be empty for non-manifolds cases */ int maux; double *auxcoarse; - fclaw2d_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); + fclaw_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); double *auxfine; - fclaw2d_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); + fclaw_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); const fc2d_geoclaw_options_t *geo_opt = fc2d_geoclaw_get_options(glob); int mcapa = geo_opt->mcapa; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int manifold = fclaw_opt->manifold; if (manifold != 0) { @@ -629,69 +629,69 @@ void geoclaw_average_face(fclaw2d_global_t *glob, &igrid,&transform_data); } -void geoclaw_interpolate_face(fclaw2d_global_t *glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, +void geoclaw_interpolate_face(fclaw_global_t *glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, int idir, int iside, int p4est_refineFactor, int refratio, int time_interp, int igrid, - fclaw2d_patch_transform_data_t* transform_data) + fclaw_patch_transform_data_t* transform_data) { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,coarse_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); - double *qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); int maux; double *auxcoarse; - fclaw2d_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); + fclaw_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); double *auxfine; - fclaw2d_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); + fclaw_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); FC2D_GEOCLAW_FORT_INTERPOLATE_FACE(&mx,&my,&mbc,&meqn,qcoarse,qfine,&maux, auxcoarse,auxfine, &idir, &iside, &igrid, &transform_data); } -void geoclaw_average_corner(fclaw2d_global_t *glob, - fclaw2d_patch_t *coarse_patch, - fclaw2d_patch_t *fine_patch, +void geoclaw_average_corner(fclaw_global_t *glob, + fclaw_patch_t *coarse_patch, + fclaw_patch_t *fine_patch, int coarse_blockno, int fine_blockno, int coarse_corner, int time_interp, - fclaw2d_patch_transform_data_t* transform_data) + fclaw_patch_transform_data_t* transform_data) { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,coarse_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); - double *qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); + double *qfine = fclaw_clawpatch_get_q(glob,fine_patch); int maux; double *auxcoarse; - fclaw2d_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); + fclaw_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); double *auxfine; - fclaw2d_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); + fclaw_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); const fc2d_geoclaw_options_t *geo_opt = fc2d_geoclaw_get_options(glob); int mcapa = geo_opt->mcapa; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); int manifold = fclaw_opt->manifold; if (manifold != 0) { @@ -707,33 +707,33 @@ void geoclaw_average_corner(fclaw2d_global_t *glob, } -void geoclaw_interpolate_corner(fclaw2d_global_t* glob, - fclaw2d_patch_t* coarse_patch, - fclaw2d_patch_t* fine_patch, +void geoclaw_interpolate_corner(fclaw_global_t* glob, + fclaw_patch_t* coarse_patch, + fclaw_patch_t* fine_patch, int coarse_blockno, int fine_blockno, int coarse_corner, int time_interp, - fclaw2d_patch_transform_data_t* transform_data) + fclaw_patch_transform_data_t* transform_data) { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,coarse_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int meqn; double *qcoarse; - fclaw2d_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); + fclaw_clawpatch_timesync_data(glob,coarse_patch,time_interp,&qcoarse,&meqn); - double* qfine = fclaw2d_clawpatch_get_q(glob,fine_patch); + double* qfine = fclaw_clawpatch_get_q(glob,fine_patch); int maux; double *auxcoarse; - fclaw2d_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); + fclaw_clawpatch_aux_data(glob,coarse_patch,&auxcoarse,&maux); double *auxfine; - fclaw2d_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); + fclaw_clawpatch_aux_data(glob,fine_patch,&auxfine,&maux); FC2D_GEOCLAW_FORT_INTERPOLATE_CORNER(&mx,&my,&mbc,&meqn, qcoarse,qfine,&maux, @@ -744,13 +744,13 @@ void geoclaw_interpolate_corner(fclaw2d_global_t* glob, /* --------------------------- Parallel ghost patches -------------------------------- */ -void geoclaw_remote_ghost_setup(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void geoclaw_remote_ghost_setup(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { - fclaw2d_clawpatch_options_t* clawpatch_options; - clawpatch_options = fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t* clawpatch_options; + clawpatch_options = fclaw_clawpatch_get_options(glob); if (!clawpatch_options->ghost_patch_pack_aux) { @@ -763,8 +763,8 @@ void geoclaw_remote_ghost_setup(fclaw2d_global_t *glob, } static -void geoclaw_local_ghost_pack_aux(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void geoclaw_local_ghost_pack_aux(fclaw_global_t *glob, + fclaw_patch_t *patch, int mint, double *auxpack, int auxsize, int packmode, @@ -772,12 +772,12 @@ void geoclaw_local_ghost_pack_aux(fclaw2d_global_t *glob, { int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int maux; double *aux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); FC2D_GEOCLAW_LOCAL_GHOST_PACK_AUX(&mx,&my,&mbc,&maux, &mint,aux,auxpack,&auxsize, &packmode,ierror); @@ -786,10 +786,10 @@ void geoclaw_local_ghost_pack_aux(fclaw2d_global_t *glob, /* ------------------------------ Misc access functions ----------------------------- */ /* Called from application routines */ -void fc2d_geoclaw_module_setup(fclaw2d_global_t *glob) +void fc2d_geoclaw_module_setup(fclaw_global_t *glob) { - const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); const fc2d_geoclaw_options_t *geo_opt = fc2d_geoclaw_get_options(glob); FC2D_GEOCLAW_SET_MODULES(&geo_opt->mwaves, @@ -818,7 +818,7 @@ void fc2d_geoclaw_vt_destroy(void* vt) FCLAW_FREE (vt); } -fc2d_geoclaw_vtable_t* fc2d_geoclaw_vt(fclaw2d_global_t* glob) +fc2d_geoclaw_vtable_t* fc2d_geoclaw_vt(fclaw_global_t* glob) { fc2d_geoclaw_vtable_t* geoclaw_vt = (fc2d_geoclaw_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fc2d_geoclaw"); @@ -827,10 +827,10 @@ fc2d_geoclaw_vtable_t* fc2d_geoclaw_vt(fclaw2d_global_t* glob) return geoclaw_vt; } -void fc2d_geoclaw_solver_initialize(fclaw2d_global_t* glob) +void fc2d_geoclaw_solver_initialize(fclaw_global_t* glob) { - fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); - fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + fclaw_options_t* fclaw_opt = fclaw_get_options(glob); + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_get_options(glob); fc2d_geoclaw_options_t* geo_opt = fc2d_geoclaw_get_options(glob); geo_opt->method[6] = clawpatch_opt->maux; @@ -843,18 +843,18 @@ void fc2d_geoclaw_solver_initialize(fclaw2d_global_t* glob) } int claw_version = 5; - fclaw2d_clawpatch_vtable_initialize(glob, claw_version); + fclaw_clawpatch_vtable_initialize(glob, claw_version); fclaw_gauges_vtable_t* gauges_vt = fclaw_gauges_vt(glob); - fclaw2d_vtable_t* fclaw_vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); - fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); + fclaw_vtable_t* fc_vt = fclaw_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); + fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(glob); fc2d_geoclaw_vtable_t* geoclaw_vt = fc2d_geoclaw_vt_new(); /* ForestClaw virtual tables */ - fclaw_vt->problem_setup = geoclaw_setprob; + fc_vt->problem_setup = geoclaw_setprob; // fclaw_vt->after_regrid = geoclaw_after_regrid; /* Handle gauges */ /* Set basic patch operations */ @@ -863,7 +863,7 @@ void fc2d_geoclaw_solver_initialize(fclaw2d_global_t* glob) patch_vt->physical_bc = geoclaw_bc2; patch_vt->single_step_update = geoclaw_update; /* Includes b4step2 and src2 */ - fclaw_vt->output_frame = geoclaw_output; + fc_vt->output_frame = geoclaw_output; /* Regridding */ patch_vt->tag4refinement = geoclaw_patch_tag4refinement; @@ -872,8 +872,8 @@ void fc2d_geoclaw_solver_initialize(fclaw2d_global_t* glob) patch_vt->average2coarse = geoclaw_average2coarse; /* Ghost filling */ - clawpatch_vt->fort_copy_face = FC2D_GEOCLAW_FORT_COPY_FACE; - clawpatch_vt->fort_copy_corner = FC2D_GEOCLAW_FORT_COPY_CORNER; + clawpatch_vt->d2->fort_copy_face = FC2D_GEOCLAW_FORT_COPY_FACE; + clawpatch_vt->d2->fort_copy_corner = FC2D_GEOCLAW_FORT_COPY_CORNER; /* Geoclaw needs specialized averaging and interpolation routines */ patch_vt->average_face = geoclaw_average_face; @@ -881,15 +881,15 @@ void fc2d_geoclaw_solver_initialize(fclaw2d_global_t* glob) patch_vt->average_corner = geoclaw_average_corner; patch_vt->interpolate_corner = geoclaw_interpolate_corner; - patch_vt->remote_ghost_setup = geoclaw_remote_ghost_setup; - clawpatch_vt->fort_local_ghost_pack = FC2D_GEOCLAW_LOCAL_GHOST_PACK; - clawpatch_vt->local_ghost_pack_aux = geoclaw_local_ghost_pack_aux; + patch_vt->remote_ghost_setup = geoclaw_remote_ghost_setup; + clawpatch_vt->d2->fort_local_ghost_pack = FC2D_GEOCLAW_LOCAL_GHOST_PACK; + clawpatch_vt->local_ghost_pack_aux = geoclaw_local_ghost_pack_aux; /* Diagnostic functions partially implemented in clawpatch */ - clawpatch_vt->fort_compute_error_norm = FC2D_GEOCLAW_FORT_COMPUTE_ERROR_NORM; - clawpatch_vt->fort_compute_patch_area = FC2D_GEOCLAW_FORT_COMPUTE_PATCH_AREA; - clawpatch_vt->fort_conservation_check = FC2D_GEOCLAW_FORT_CONSERVATION_CHECK; - clawpatch_vt->fort_timeinterp = FC2D_GEOCLAW_FORT_TIMEINTERP; + clawpatch_vt->d2->fort_compute_error_norm = FC2D_GEOCLAW_FORT_COMPUTE_ERROR_NORM; + clawpatch_vt->d2->fort_compute_patch_area = FC2D_GEOCLAW_FORT_COMPUTE_PATCH_AREA; + clawpatch_vt->d2->fort_conservation_check = FC2D_GEOCLAW_FORT_CONSERVATION_CHECK; + clawpatch_vt->d2->fort_timeinterp = FC2D_GEOCLAW_FORT_TIMEINTERP; geoclaw_vt->setprob = NULL; geoclaw_vt->setaux = FC2D_GEOCLAW_SETAUX; diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw.h b/src/solvers/fc2d_geoclaw/fc2d_geoclaw.h index b85ecfd0a..f329e363b 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw.h +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw.h @@ -40,19 +40,19 @@ extern "C" typedef struct fc2d_geoclaw_vtable fc2d_geoclaw_vtable_t; /* Forward declarations */ -struct fclaw2d_patch_transform_data; -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_patch_transform_data; +struct fclaw_global; +struct fclaw_patch; struct geoclaw_gauge; -void fc2d_geoclaw_run(struct fclaw2d_global *glob); +void fc2d_geoclaw_run(struct fclaw_global *glob); /* ------------------------------------- Access functions ---------------------------------- */ -void fc2d_geoclaw_module_setup(struct fclaw2d_global *glob); +void fc2d_geoclaw_module_setup(struct fclaw_global *glob); -void fc2d_geoclaw_output(struct fclaw2d_global *glob, int iframe); +void fc2d_geoclaw_output(struct fclaw_global *glob, int iframe); /* ------------------------------------- Virtual table ----------------------------------- */ @@ -66,7 +66,7 @@ void fc2d_geoclaw_output(struct fclaw2d_global *glob, int iframe); * * @param global the global context */ -void fc2d_geoclaw_solver_initialize(struct fclaw2d_global *glob); +void fc2d_geoclaw_solver_initialize(struct fclaw_global *glob); /** * @brief Get the geoclaw vtable @@ -74,7 +74,7 @@ void fc2d_geoclaw_solver_initialize(struct fclaw2d_global *glob); * @param global the global context * @return fc2d_geoclaw_vtable_t* the vtable */ -fc2d_geoclaw_vtable_t* fc2d_geoclaw_vt(struct fclaw2d_global *glob); +fc2d_geoclaw_vtable_t* fc2d_geoclaw_vt(struct fclaw_global *glob); struct fc2d_geoclaw_vtable diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw.h.TEST.cpp b/src/solvers/fc2d_geoclaw/fc2d_geoclaw.h.TEST.cpp index cc93f4de0..528158efa 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw.h.TEST.cpp +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw.h.TEST.cpp @@ -23,97 +23,122 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include +#include +#include +#include #include #include -#include +#include +#include #include TEST_CASE("fc2d_geoclaw_solver_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, clawpatch_opt); + fclaw_clawpatch_options_store(glob2, clawpatch_opt); /* create some empty options structures */ - fclaw2d_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); - fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_geoclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1)); - fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_geoclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc2d_geoclaw_solver_initialize(glob1); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_geoclaw_solver_initialize(glob2); CHECK_NE(fc2d_geoclaw_vt(glob1), fc2d_geoclaw_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_geoclaw_solver_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_t* glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); + + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob, clawpatch_opt); /* create some empty options structures */ - fclaw2d_options_store(glob, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); - fclaw2d_clawpatch_options_store(glob, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_options_store(glob, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_geoclaw_options_store(glob, FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1)); - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc2d_geoclaw_solver_initialize(glob); CHECK_UNARY(fc2d_geoclaw_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_geoclaw_vt fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); CHECK_SC_ABORTED(fc2d_geoclaw_vt(glob1)); CHECK_SC_ABORTED(fc2d_geoclaw_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_geoclaw_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, clawpatch_opt); + fclaw_clawpatch_options_store(glob2, clawpatch_opt); /* create some empty options structures */ - fclaw2d_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); - fclaw2d_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_geoclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1)); - fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); - fclaw2d_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw2d_clawpatch_options_t,1)); + fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_geoclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc2d_geoclaw_solver_initialize(glob1); CHECK_SC_ABORTED(fc2d_geoclaw_solver_initialize(glob1)); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_geoclaw_solver_initialize(glob2); CHECK_SC_ABORTED(fc2d_geoclaw_solver_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_fort.h b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_fort.h index b22041dbf..6e8951f52 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_fort.h +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_fort.h @@ -37,7 +37,7 @@ extern "C" /* Needed to get syntax highlighting to work */ #endif -struct fclaw2d_patch_transform_data; /* Should be replaced by long int? */ +struct fclaw_patch_transform_data; /* Should be replaced by long int? */ /* --------------------------------------- Typedefs ----------------------------------- */ @@ -357,7 +357,7 @@ void FC2D_GEOCLAW_FORT_COPY_FACE(const int* mx, const int* my, const int* mbc, const int* meqn, double qthis[], double qneighbor[], const int* a_idir, - struct fclaw2d_patch_transform_data** transform_cptr); + struct fclaw_patch_transform_data** transform_cptr); #define FC2D_GEOCLAW_FORT_AVERAGE_FACE \ @@ -377,7 +377,7 @@ void FC2D_GEOCLAW_FORT_AVERAGE_FACE(const int* mx, const int* idir, const int* iface_coarse, const int* igrid, - struct fclaw2d_patch_transform_data** transform_data); + struct fclaw_patch_transform_data** transform_data); #define FC2D_GEOCLAW_FORT_INTERPOLATE_FACE \ FCLAW_F77_FUNC(fc2d_geoclaw_fort_interpolate_face, \ @@ -393,7 +393,7 @@ void FC2D_GEOCLAW_FORT_INTERPOLATE_FACE(const int* mx, const int* idir, const int* iside, const int* igrid, - struct fclaw2d_patch_transform_data** transform_cptr); + struct fclaw_patch_transform_data** transform_cptr); #define FC2D_GEOCLAW_FORT_COPY_CORNER \ @@ -405,7 +405,7 @@ void FC2D_GEOCLAW_FORT_COPY_CORNER(const int* mx, const int* meqn, double this_q[], double neighbor_q[], const int* a_corner, - struct fclaw2d_patch_transform_data** transform_cptr); + struct fclaw_patch_transform_data** transform_cptr); #define FC2D_GEOCLAW_FORT_AVERAGE_CORNER \ FCLAW_F77_FUNC(fc2d_geoclaw_fort_average_corner, \ @@ -419,7 +419,7 @@ void FC2D_GEOCLAW_FORT_AVERAGE_CORNER(const int* mx, double auxcoarse[], double auxfine[], const int* mcapa, const int* corner, - struct fclaw2d_patch_transform_data** transform_cptr); + struct fclaw_patch_transform_data** transform_cptr); #define FC2D_GEOCLAW_FORT_INTERPOLATE_CORNER \ FCLAW_F77_FUNC(fc2d_geoclaw_fort_interpolate_corner, \ @@ -433,7 +433,7 @@ void FC2D_GEOCLAW_FORT_INTERPOLATE_CORNER(const int* mx, const int* maux, double aux_coarse[], double aux_fine[], const int* corner, - struct fclaw2d_patch_transform_data** transform_cptr); + struct fclaw_patch_transform_data** transform_cptr); diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_gauges_default.c b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_gauges_default.c index f8f5a42b6..c871c626b 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_gauges_default.c +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_gauges_default.c @@ -30,11 +30,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_geoclaw_options.h" -#include -#include +#include +#include -#include -#include +#include +#include #ifdef __cplusplus extern "C" @@ -53,7 +53,7 @@ typedef struct geoclaw_user } geoclaw_user_t; -void geoclaw_read_gauges_data_default(fclaw2d_global_t *glob, +void geoclaw_read_gauges_data_default(fclaw_global_t *glob, fclaw_gauge_t **gauges, int *num_gauges) { @@ -169,7 +169,7 @@ void geoclaw_read_gauges_data_default(fclaw2d_global_t *glob, /* This function can be virtualized so the user can specify their gauge output */ -void geoclaw_create_gauge_files_default(fclaw2d_global_t *glob, +void geoclaw_create_gauge_files_default(fclaw_global_t *glob, fclaw_gauge_t *gauges, int num_gauges) { @@ -199,8 +199,8 @@ void geoclaw_create_gauge_files_default(fclaw2d_global_t *glob, } } -void geoclaw_gauge_normalize_coordinates(fclaw2d_global_t *glob, - fclaw2d_block_t *block, +void geoclaw_gauge_normalize_coordinates(fclaw_global_t *glob, + fclaw_block_t *block, int blockno, fclaw_gauge_t *g, double *xc, double *yc) @@ -213,7 +213,7 @@ void geoclaw_gauge_normalize_coordinates(fclaw2d_global_t *glob, Return normalized (xc,yc) coordinates for gauge. */ - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double ax,bx,ay,by; ax = fclaw_opt->ax; @@ -227,9 +227,9 @@ void geoclaw_gauge_normalize_coordinates(fclaw2d_global_t *glob, } -void geoclaw_gauge_update_default(fclaw2d_global_t* - glob, fclaw2d_block_t* block, - fclaw2d_patch_t* patch, +void geoclaw_gauge_update_default(fclaw_global_t* + glob, fclaw_block_t* block, + fclaw_patch_t* patch, int blockno, int patchno, double tcurr, fclaw_gauge_t *g) { @@ -242,7 +242,7 @@ void geoclaw_gauge_update_default(fclaw2d_global_t* int m; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); fclaw_gauge_get_data(glob,g,&num, &xc, &yc, &t1, &t2); @@ -250,8 +250,8 @@ void geoclaw_gauge_update_default(fclaw2d_global_t* FCLAW_ASSERT(xc >= xlower && xc <= xlower + mx*dx); FCLAW_ASSERT(yc >= ylower && yc <= ylower + my*dy); - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); /* Interpolate q variables and aux variables (bathy only for now) to gauge location */ @@ -272,7 +272,7 @@ void geoclaw_gauge_update_default(fclaw2d_global_t* fclaw_gauge_set_buffer_entry(glob,g,guser); } -void geoclaw_print_gauges_default(fclaw2d_global_t *glob, +void geoclaw_print_gauges_default(fclaw_global_t *glob, fclaw_gauge_t *gauge) { int k, kmax, id; diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_gauges_default.h b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_gauges_default.h index df4fdb08f..dd95c6a83 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_gauges_default.h +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_gauges_default.h @@ -34,33 +34,33 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; struct fclaw_gauge; -struct fclaw2d_patch; -struct fclaw2d_block; +struct fclaw_patch; +struct fclaw_block; -void geoclaw_read_gauges_data_default(struct fclaw2d_global *glob, +void geoclaw_read_gauges_data_default(struct fclaw_global *glob, struct fclaw_gauge **gauges, int *num); -void geoclaw_create_gauge_files_default(struct fclaw2d_global *glob, +void geoclaw_create_gauge_files_default(struct fclaw_global *glob, struct fclaw_gauge *gauges, int num_gauges); -void geoclaw_gauge_normalize_coordinates(struct fclaw2d_global *glob, - struct fclaw2d_block *block, +void geoclaw_gauge_normalize_coordinates(struct fclaw_global *glob, + struct fclaw_block *block, int blockno, struct fclaw_gauge *g, double *xc, double *yc); -void geoclaw_gauge_update_default(struct fclaw2d_global* glob, - struct fclaw2d_block* block, - struct fclaw2d_patch* patch, +void geoclaw_gauge_update_default(struct fclaw_global* glob, + struct fclaw_block* block, + struct fclaw_patch* patch, int blockno, int patchno, double tcurr, struct fclaw_gauge *g); -void geoclaw_print_gauges_default(struct fclaw2d_global *glob, +void geoclaw_print_gauges_default(struct fclaw_global *glob, struct fclaw_gauge *gauge); #ifdef __cplusplus diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.c b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.c index 2c36e88a9..cf526417a 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.c +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.c @@ -26,8 +26,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_geoclaw_options.h" #include -#include -#include +#include +#include #ifdef __cplusplus extern "C" @@ -229,15 +229,15 @@ fc2d_geoclaw_options_register (fclaw_app_t * app, return geo_opt; } -fc2d_geoclaw_options_t* fc2d_geoclaw_get_options(fclaw2d_global_t *glob) +fc2d_geoclaw_options_t* fc2d_geoclaw_get_options(fclaw_global_t *glob) { - return (fc2d_geoclaw_options_t*) fclaw2d_global_get_options(glob, "fc2d_geoclaw"); + return (fc2d_geoclaw_options_t*) fclaw_global_get_options(glob, "fc2d_geoclaw"); } -void fc2d_geoclaw_options_store (fclaw2d_global_t* glob, +void fc2d_geoclaw_options_store (fclaw_global_t* glob, fc2d_geoclaw_options_t* geo_opt) { - fclaw2d_global_options_store(glob, "fc2d_geoclaw", geo_opt); + fclaw_global_options_store(glob, "fc2d_geoclaw", geo_opt); } diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.h b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.h index 803f27efa..8d459fa71 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.h +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.h @@ -36,7 +36,7 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; typedef struct fc2d_geoclaw_options { @@ -82,10 +82,10 @@ fc2d_geoclaw_options_t *fc2d_geoclaw_options_register (fclaw_app_t * app, const char *section, const char *configfile); -void fc2d_geoclaw_options_store (struct fclaw2d_global* glob, +void fc2d_geoclaw_options_store (struct fclaw_global* glob, fc2d_geoclaw_options_t* geo_opt); -fc2d_geoclaw_options_t* fc2d_geoclaw_get_options(struct fclaw2d_global *glob); +fc2d_geoclaw_options_t* fc2d_geoclaw_get_options(struct fclaw_global *glob); diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.h.TEST.cpp b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.h.TEST.cpp index 961beb6fc..b3bf37fb3 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.h.TEST.cpp +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_options.h.TEST.cpp @@ -23,50 +23,50 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include TEST_CASE("fc2d_geoclaw_options can store options in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_geoclaw_options_t* opts1 = FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1); fc2d_geoclaw_options_t* opts2 = FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1); fc2d_geoclaw_options_store(glob1, opts1); /* glob1 has one package glob2 has two */ - fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); + fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_geoclaw_options_store(glob2, opts2); CHECK_EQ(fc2d_geoclaw_get_options(glob1), opts1); CHECK_EQ(fc2d_geoclaw_get_options(glob2), opts2); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_geoclaw_get_options fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); CHECK_SC_ABORTED(fc2d_geoclaw_get_options(glob1)); CHECK_SC_ABORTED(fc2d_geoclaw_get_options(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_geoclaw_options_store fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_geoclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1)); CHECK_SC_ABORTED(fc2d_geoclaw_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1))); @@ -74,8 +74,8 @@ TEST_CASE("fc2d_geoclaw_options_store fails if called twice on a glob") fc2d_geoclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1)); CHECK_SC_ABORTED(fc2d_geoclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_geoclaw_options_t,1))); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_output_ascii.c b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_output_ascii.c index 7665f2eb4..1d3525a80 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_output_ascii.c +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_output_ascii.c @@ -29,42 +29,42 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_geoclaw_fort.h" #include "fc2d_geoclaw_options.h" -#include /* Include patch, domain declarations */ -#include /* Include patch, domain declarations */ +#include /* Include patch, domain declarations */ +#include /* Include patch, domain declarations */ -#include -#include +#include +#include static -void cb_geoclaw_output_ascii(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void cb_geoclaw_output_ascii(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_global_t *glob = (fclaw2d_global_t*) s->glob; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_global_t *glob = (fclaw_global_t*) s->glob; int iframe = *((int *) s->user); /* Get info not readily available to user */ int local_num, global_num, level; - fclaw2d_patch_get_info(glob->domain,patch, + fclaw_patch_get_info(glob->domain,patch, blockno,patchno, &global_num, &local_num,&level); int mx,my,mbc; double xlower,ylower,dx,dy; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); double *q; int meqn; - fclaw2d_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); double *aux; int maux; - fclaw2d_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); FC2D_GEOCLAW_FORT_WRITE_FILE(&mx,&my,&meqn, &maux,&mbc,&xlower,&ylower, &dx,&dy,q,aux,&iframe,&global_num,&level, @@ -72,12 +72,12 @@ void cb_geoclaw_output_ascii(fclaw2d_domain_t *domain, } static -void geoclaw_header_ascii(fclaw2d_global_t* glob,int iframe) +void geoclaw_header_ascii(fclaw_global_t* glob,int iframe) { double time = glob->curr_time; int ngrids = glob->domain->global_num_patches; - const fclaw2d_clawpatch_options_t *clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + const fclaw_clawpatch_options_t *clawpatch_opt = fclaw_clawpatch_get_options(glob); int meqn = clawpatch_opt->meqn; int maux = clawpatch_opt->maux; @@ -88,22 +88,22 @@ void geoclaw_header_ascii(fclaw2d_global_t* glob,int iframe) Public interface ------------------------------------------------------------ */ -void fc2d_geoclaw_output_ascii(fclaw2d_global_t* glob,int iframe) +void fc2d_geoclaw_output_ascii(fclaw_global_t* glob,int iframe) { - fclaw2d_domain_t *domain = glob->domain; + fclaw_domain_t *domain = glob->domain; /* BEGIN NON-SCALABLE CODE */ /* Write the file contents in serial. Use only for small numbers of processors. */ - fclaw2d_domain_serialization_enter (domain); + fclaw_domain_serialization_enter (domain); if (domain->mpirank == 0) geoclaw_header_ascii(glob,iframe); /* Write out each patch to fort.qXXXX */ - fclaw2d_global_iterate_patches (glob, cb_geoclaw_output_ascii, &iframe); + fclaw_global_iterate_patches (glob, cb_geoclaw_output_ascii, &iframe); - fclaw2d_domain_serialization_leave (domain); + fclaw_domain_serialization_leave (domain); /* END OF NON-SCALABLE CODE */ } diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_output_ascii.h b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_output_ascii.h index e847ce61b..6217dd133 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_output_ascii.h +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_output_ascii.h @@ -35,9 +35,9 @@ extern "C" #endif -struct fclaw2d_global; +struct fclaw_global; -void fc2d_geoclaw_output_ascii(struct fclaw2d_global* glob,int iframe); +void fc2d_geoclaw_output_ascii(struct fclaw_global* glob,int iframe); #ifdef __cplusplus diff --git a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_run.c b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_run.c index 7f1f33a83..515b43ef8 100644 --- a/src/solvers/fc2d_geoclaw/fc2d_geoclaw_run.c +++ b/src/solvers/fc2d_geoclaw/fc2d_geoclaw_run.c @@ -25,16 +25,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "fclaw_math.h" @@ -50,40 +50,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------- */ static -void cb_restore_time_step(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_restore_time_step(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_patch_restore_step(s->glob,this_patch); + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_patch_restore_step(s->glob,this_patch); } static -void restore_time_step(fclaw2d_global_t *glob) +void restore_time_step(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob,cb_restore_time_step,(void *) NULL); + fclaw_global_iterate_patches(glob,cb_restore_time_step,(void *) NULL); //fclaw_options_t *fopt = fclaw2d_get_options(glob); //fclaw2d_time_sync_reset(glob,fopt->minlevel,fopt->maxlevel,0); } static -void cb_save_time_step(fclaw2d_domain_t *domain, - fclaw2d_patch_t *this_patch, +void cb_save_time_step(fclaw_domain_t *domain, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; - fclaw2d_patch_save_step(s->glob,this_patch); + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; + fclaw_patch_save_step(s->glob,this_patch); } static -void save_time_step(fclaw2d_global_t *glob) +void save_time_step(fclaw_global_t *glob) { - fclaw2d_global_iterate_patches(glob,cb_save_time_step,(void *) NULL); + fclaw_global_iterate_patches(glob,cb_save_time_step,(void *) NULL); } @@ -91,7 +91,7 @@ void save_time_step(fclaw2d_global_t *glob) Output style dtopo (Time step over any moving topography) -------------------------------------------------------------------------------- */ static -double step_dtopo(fclaw2d_global_t *glob, double tstart_outer, double tend_outer, +double step_dtopo(fclaw_global_t *glob, double tstart_outer, double tend_outer, double dtopo_interval[2], double dt_max_dtopo, int *took_step) { if (dtopo_interval[1] <= tstart_outer || tend_outer <= dtopo_interval[0]) @@ -120,7 +120,7 @@ double step_dtopo(fclaw2d_global_t *glob, double tstart_outer, double tend_outer glob->curr_dt = dt0; glob->curr_time = tstart_local; - double maxcfl_step = fclaw2d_advance_all_levels(glob, tstart_local, dt0); + double maxcfl_step = fclaw_advance_all_levels(glob, tstart_local, dt0); maxcfl = maxcfl_step; glob->curr_time += dt0; tstart_local += dt0; @@ -155,7 +155,7 @@ double step_dtopo(fclaw2d_global_t *glob, double tstart_outer, double tend_outer for(int n = 0; n < M; n++) { double tstart = glob->curr_time; - double maxcfl_step = fclaw2d_advance_all_levels(glob, tstart, dt1); + double maxcfl_step = fclaw_advance_all_levels(glob, tstart, dt1); /* We only keep track of maxcfl; don't try to retake a time step */ maxcfl = (maxcfl_step > maxcfl) ? maxcfl_step : maxcfl; @@ -172,7 +172,7 @@ double step_dtopo(fclaw2d_global_t *glob, double tstart_outer, double tend_outer { tstart_local = tend_local; double dt2 = tend_outer - tstart_local; - double maxcfl_step = fclaw2d_advance_all_levels(glob, tstart_local, dt2); + double maxcfl_step = fclaw_advance_all_levels(glob, tstart_local, dt2); maxcfl = (maxcfl_step > maxcfl) ? maxcfl_step : maxcfl; glob->curr_time += dt2; } @@ -188,15 +188,15 @@ double step_dtopo(fclaw2d_global_t *glob, double tstart_outer, double tend_outer Output times are at times [0,dT, 2*dT, 3*dT,...,Tfinal], where dT = tfinal/nout -------------------------------------------------------------------------------- */ static -void outstyle_1(fclaw2d_global_t *glob) +void outstyle_1(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double final_time = fclaw_opt->tfinal; int nout = fclaw_opt->nout; @@ -206,7 +206,7 @@ void outstyle_1(fclaw2d_global_t *glob) int init_flag = 1; /* Store anything that needs to be stored */ - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; double t0 = 0; @@ -297,7 +297,7 @@ void outstyle_1(fclaw2d_global_t *glob) { /* Just to a regular step */ glob->curr_dt = dt_step; - maxcfl_step = fclaw2d_advance_all_levels(glob, t_curr,dt_step); + maxcfl_step = fclaw_advance_all_levels(glob, t_curr,dt_step); tc = t_curr + dt_step; } @@ -306,9 +306,9 @@ void outstyle_1(fclaw2d_global_t *glob) { /* If we are taking a variable time step, we have to reduce the maxcfl so that every processor takes the same size dt */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); - maxcfl_step = fclaw2d_domain_global_maximum (*domain, maxcfl_step); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_CFL_COMM]); + maxcfl_step = fclaw_domain_global_maximum (*domain, maxcfl_step); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_CFL_COMM]); } @@ -381,7 +381,7 @@ void outstyle_1(fclaw2d_global_t *glob) if (fclaw_opt->advance_one_step) { - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); } if (fclaw_opt->regrid_interval > 0) @@ -389,16 +389,16 @@ void outstyle_1(fclaw2d_global_t *glob) if (n_inner % fclaw_opt->regrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } } /* Output file at every outer loop iteration */ - fclaw2d_diagnostics_gather(glob, init_flag); + fclaw_diagnostics_gather(glob, init_flag); glob->curr_time = t_curr; iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } @@ -415,19 +415,19 @@ static void outstyle_2(fclaw2d_global_t *glob) static -void outstyle_3(fclaw2d_global_t *glob) +void outstyle_3(fclaw_global_t *glob) { - fclaw2d_domain_t** domain = &glob->domain; + fclaw_domain_t** domain = &glob->domain; int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; @@ -502,7 +502,7 @@ void outstyle_3(fclaw2d_global_t *glob) { /* Just to a regular step */ glob->curr_dt = dt_step; - maxcfl_step = fclaw2d_advance_all_levels(glob, t_curr,dt_step); + maxcfl_step = fclaw_advance_all_levels(glob, t_curr,dt_step); tc = t_curr + dt_step; } @@ -511,9 +511,9 @@ void outstyle_3(fclaw2d_global_t *glob) { /* If we are taking a variable time step, we have to reduce the maxcfl so that every processor takes the same size dt */ - fclaw2d_timer_start (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); - maxcfl_step = fclaw2d_domain_global_maximum (*domain, maxcfl_step); - fclaw2d_timer_stop (&glob->timers[FCLAW2D_TIMER_CFL_COMM]); + fclaw_timer_start (&glob->timers[FCLAW_TIMER_CFL_COMM]); + maxcfl_step = fclaw_domain_global_maximum (*domain, maxcfl_step); + fclaw_timer_stop (&glob->timers[FCLAW_TIMER_CFL_COMM]); } int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ? @@ -571,38 +571,38 @@ void outstyle_3(fclaw2d_global_t *glob) if (n % nregrid_interval == 0) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } if (fclaw_opt->advance_one_step) { - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); } if (n % nstep_inner == 0) { iframe++; //fclaw2d_diagnostics_gather(glob,init_flag); - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } static -void outstyle_4(fclaw2d_global_t *glob) +void outstyle_4(fclaw_global_t *glob) { /* Write out an initial time file */ int iframe = 0; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); int init_flag = 1; - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); init_flag = 0; - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); double initial_dt = fclaw_opt->initial_dt; int nstep_outer = fclaw_opt->nout; int nstep_inner = fclaw_opt->nstep; @@ -615,7 +615,7 @@ void outstyle_4(fclaw2d_global_t *glob) while (n < nstep_outer) { /* Get current domain data since it may change during regrid */ - fclaw2d_advance_all_levels(glob, t_curr, dt_minlevel); + fclaw_advance_all_levels(glob, t_curr, dt_minlevel); int level2print = (fclaw_opt->advance_one_step && fclaw_opt->outstyle_uses_maxlevel) ? fclaw_opt->maxlevel : fclaw_opt->minlevel; @@ -635,7 +635,7 @@ void outstyle_4(fclaw2d_global_t *glob) { fclaw_global_infof("regridding at step %d\n",n); - fclaw2d_regrid(glob); + fclaw_regrid(glob); } } else @@ -645,9 +645,9 @@ void outstyle_4(fclaw2d_global_t *glob) if (n % nstep_inner == 0) { - fclaw2d_diagnostics_gather(glob,init_flag); + fclaw_diagnostics_gather(glob,init_flag); iframe++; - fclaw2d_output_frame(glob,iframe); + fclaw_output_frame(glob,iframe); } } } @@ -657,10 +657,10 @@ void outstyle_4(fclaw2d_global_t *glob) Public interface ---------------------------------------------------------------- */ -void fc2d_geoclaw_run(fclaw2d_global_t *glob) +void fc2d_geoclaw_run(fclaw_global_t *glob) { - const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + const fclaw_options_t *fclaw_opt = fclaw_get_options(glob); switch (fclaw_opt->outstyle) { diff --git a/src/solvers/fc2d_geoclaw/fclaw2d_source/fc2d_geoclaw_diagnostics_fort.f b/src/solvers/fc2d_geoclaw/fclaw2d_source/fc2d_geoclaw_diagnostics_fort.f index 873fd9798..49169f662 100644 --- a/src/solvers/fc2d_geoclaw/fclaw2d_source/fc2d_geoclaw_diagnostics_fort.f +++ b/src/solvers/fc2d_geoclaw/fclaw2d_source/fc2d_geoclaw_diagnostics_fort.f @@ -15,13 +15,13 @@ subroutine fc2d_geoclaw_fort_conservation_check(mx,my,mbc,meqn, integer i,j,m integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = fclaw_map_get_context() dxdy = dx*dy do m = 1,meqn - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do j = 1,my do i = 1,mx y = q(i,j,m)*area(i,j) - c_kahan @@ -57,11 +57,11 @@ subroutine fc2d_geoclaw_fort_conservation_check(mx,my,mbc,meqn, integer i,j,m integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = fclaw_map_get_context() - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then sum = 0 do j = 1,my do i = 1,mx @@ -90,14 +90,14 @@ subroutine fc2d_geoclaw_fort_compute_error_norm(blockno, integer i,j,m integer*8 cont, fclaw_map_get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = fclaw_map_get_context() c # error_norm(:) comes in with values; do not initialize it here! dxdy = dx*dy do m = 1,meqn - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do j = 1,my do i = 1,mx eij = abs(error(m,i,j)) diff --git a/src/solvers/fc2d_thunderegg/CMakeLists.txt b/src/solvers/fc2d_thunderegg/CMakeLists.txt index 7d7b95255..34c12c057 100644 --- a/src/solvers/fc2d_thunderegg/CMakeLists.txt +++ b/src/solvers/fc2d_thunderegg/CMakeLists.txt @@ -45,14 +45,11 @@ install(FILES operators/fc2d_thunderegg_fivepoint.h operators/fc2d_thunderegg_varpoisson.h operators/fc2d_thunderegg_heat.h - DESTINATION include + TYPE INCLUDE ) install(TARGETS fc2d_thunderegg - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # imported target, for use from FetchContent diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg.cpp b/src/solvers/fc2d_thunderegg/fc2d_thunderegg.cpp index 09799077a..7353a76d0 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg.cpp +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg.cpp @@ -30,18 +30,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include #include "operators/fc2d_thunderegg_fivepoint.h" #include "operators/fc2d_thunderegg_heat.h" @@ -53,15 +53,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* --------------------- ThunderEgg solver (required) ------------------------- */ static -void thunderegg_setup_solver(fclaw2d_global_t *glob) +void thunderegg_setup_solver(fclaw_global_t *glob) { //fc2d_thunderegg_vtable_t* mg_vt = fc2d_thunderegg_vt(glob); } static -void thunderegg_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void thunderegg_rhs(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -71,12 +71,12 @@ void thunderegg_rhs(fclaw2d_global_t *glob, int mx,my,mbc; double dx,dy,xlower,ylower; - fclaw2d_clawpatch_grid_data(glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); int mfields; double *rhs; - fclaw2d_clawpatch_rhs_data(glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(glob,patch,&rhs,&mfields); FCLAW_ASSERT(mfields == 1); /* Compute right hand side */ @@ -85,7 +85,7 @@ void thunderegg_rhs(fclaw2d_global_t *glob, } static -void thunderegg_solve(fclaw2d_global_t* glob) +void thunderegg_solve(fclaw_global_t* glob) { // Apply non-homogeneous boundary conditions fc2d_thunderegg_physical_bc(glob); @@ -129,19 +129,19 @@ void thunderegg_solve(fclaw2d_global_t* glob) /* ---------------------------------- Output functions -------------------------------- */ static -void thunderegg_output(fclaw2d_global_t *glob, int iframe) +void thunderegg_output(fclaw_global_t *glob, int iframe) { const fc2d_thunderegg_options_t* mg_options; mg_options = fc2d_thunderegg_get_options(glob); if (mg_options->ascii_out != 0) { - fclaw2d_clawpatch_output_ascii(glob,iframe); + fclaw_clawpatch_output_ascii(glob,iframe); } if (mg_options->vtk_out != 0) { - fclaw2d_clawpatch_output_vtk(glob,iframe); + fclaw_clawpatch_output_vtk(glob,iframe); } } @@ -161,24 +161,24 @@ void thunderegg_vt_destroy(void* vt) FCLAW_FREE (vt); } -void fc2d_thunderegg_solver_initialize(fclaw2d_global_t* glob) +void fc2d_thunderegg_solver_initialize(fclaw_global_t* glob) { int claw_version = 4; /* solution data is organized as (i,j,m) */ - fclaw2d_clawpatch_vtable_initialize(glob, claw_version); + fclaw_clawpatch_vtable_initialize(glob, claw_version); //fclaw2d_clawpatch_vtable_t* clawpatch_vt = fclaw2d_clawpatch_vt(glob); /* ForestClaw vtable items */ - fclaw2d_vtable_t* fclaw_vt = fclaw2d_vt(glob); - fclaw_vt->output_frame = thunderegg_output; + fclaw_vtable_t* fc_vt = fclaw_vt(glob); + fc_vt->output_frame = thunderegg_output; /* These could be over-written by user specific settings */ - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); patch_vt->rhs = thunderegg_rhs; /* Calls FORTRAN routine */ patch_vt->setup = NULL; - fclaw2d_elliptic_vtable_t *elliptic_vt = fclaw2d_elliptic_vt(glob); + fclaw_elliptic_vtable_t *elliptic_vt = fclaw_elliptic_vt(glob); elliptic_vt->setup = thunderegg_setup_solver; elliptic_vt->solve = thunderegg_solve; elliptic_vt->apply_bc = fc2d_thunderegg_physical_bc; @@ -201,7 +201,7 @@ void fc2d_thunderegg_solver_initialize(fclaw2d_global_t* glob) /* ----------------------------- User access to solver functions --------------------------- */ -fc2d_thunderegg_vtable_t* fc2d_thunderegg_vt(fclaw2d_global_t* glob) +fc2d_thunderegg_vtable_t* fc2d_thunderegg_vt(fclaw_global_t* glob) { fc2d_thunderegg_vtable_t* thunderegg_vt = (fc2d_thunderegg_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fc2d_thunderegg"); diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg.h b/src/solvers/fc2d_thunderegg/fc2d_thunderegg.h index aa82b45f2..c10eef041 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg.h +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg.h @@ -34,8 +34,8 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; typedef struct fc2d_thunderegg_vtable fc2d_thunderegg_vtable_t; @@ -68,7 +68,7 @@ typedef void (*fc2d_thunderegg_fort_apply_bc_t)(const int* blockno, const int* double rhs[], fc2d_thunderegg_fort_eval_bc_t g_bc, int* cons_check, double flux_sum[]); -typedef void (*fc2d_thunderegg_operator_t)(struct fclaw2d_global *glob); +typedef void (*fc2d_thunderegg_operator_t)(struct fclaw_global *glob); /* -------------------------- Solver and utilities ------------------------------------ */ @@ -97,7 +97,7 @@ struct fc2d_thunderegg_vtable * * @param global the global context */ -void fc2d_thunderegg_solver_initialize(struct fclaw2d_global* glob); +void fc2d_thunderegg_solver_initialize(struct fclaw_global* glob); /** * @brief Get the thunderegg vtable @@ -105,16 +105,16 @@ void fc2d_thunderegg_solver_initialize(struct fclaw2d_global* glob); * @param global the global context * @return fc2d_thunderegg_vtable_t* the vtable */ -fc2d_thunderegg_vtable_t* fc2d_thunderegg_vt(struct fclaw2d_global* glob); +fc2d_thunderegg_vtable_t* fc2d_thunderegg_vt(struct fclaw_global* glob); /* ----------------------------- User access to solver functions ---------------------- */ -void fc2d_thunderegg_setprob(struct fclaw2d_global* glob); +void fc2d_thunderegg_setprob(struct fclaw_global* glob); -void fc2d_thunderegg_rhs(struct fclaw2d_global* glob, - struct fclaw2d_patch *patch, +void fc2d_thunderegg_rhs(struct fclaw_global* glob, + struct fclaw_patch *patch, int blockno, int patchno); diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg.h.TEST.cpp b/src/solvers/fc2d_thunderegg/fc2d_thunderegg.h.TEST.cpp index a128c0671..68f5a199b 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg.h.TEST.cpp +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg.h.TEST.cpp @@ -23,58 +23,85 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include +#include +#include #include -#include +#include #include TEST_CASE("fc2d_thunderegg_solver_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); - fclaw2d_vtables_initialize(glob1); + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, clawpatch_opt); + fclaw_clawpatch_options_store(glob2, clawpatch_opt); + + fclaw_vtables_initialize(glob1); fc2d_thunderegg_solver_initialize(glob1); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_thunderegg_solver_initialize(glob2); CHECK_NE(fc2d_thunderegg_vt(glob1), fc2d_thunderegg_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_thunderegg_solver_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_global_t* glob = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_store_domain(glob, domain); - fclaw2d_vtables_initialize(glob); + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob, clawpatch_opt); + + fclaw_vtables_initialize(glob); fc2d_thunderegg_solver_initialize(glob); CHECK_UNARY(fc2d_thunderegg_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_thunderegg_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); - - fclaw2d_vtables_initialize(glob1); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_options_new(2); + fclaw_clawpatch_options_store(glob1, clawpatch_opt); + fclaw_clawpatch_options_store(glob2, clawpatch_opt); + + fclaw_vtables_initialize(glob1); fc2d_thunderegg_solver_initialize(glob1); CHECK_SC_ABORTED(fc2d_thunderegg_solver_initialize(glob1)); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc2d_thunderegg_solver_initialize(glob2); CHECK_SC_ABORTED(fc2d_thunderegg_solver_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.c b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.c index d0fec453a..f80a5cce3 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.c +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.c @@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_thunderegg_options.h" -#include +#include #include static void* @@ -228,12 +228,12 @@ fc2d_thunderegg_options_t* fc2d_thunderegg_options_register (fclaw_app_t * app, return mg_opt; } -fc2d_thunderegg_options_t* fc2d_thunderegg_get_options(fclaw2d_global_t *glob) +fc2d_thunderegg_options_t* fc2d_thunderegg_get_options(fclaw_global_t *glob) { - return (fc2d_thunderegg_options_t*) fclaw2d_global_get_options(glob,"fc2d_thunderegg"); + return (fc2d_thunderegg_options_t*) fclaw_global_get_options(glob,"fc2d_thunderegg"); } -void fc2d_thunderegg_options_store (fclaw2d_global_t* glob, fc2d_thunderegg_options_t* mg_opt) +void fc2d_thunderegg_options_store (fclaw_global_t* glob, fc2d_thunderegg_options_t* mg_opt) { - fclaw2d_global_options_store(glob, "fc2d_thunderegg", mg_opt); + fclaw_global_options_store(glob, "fc2d_thunderegg", mg_opt); } diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.h b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.h index 7771b701d..f1915d768 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.h +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.h @@ -36,7 +36,7 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; typedef struct fc2d_thunderegg_options fc2d_thunderegg_options_t; @@ -117,12 +117,12 @@ fc2d_thunderegg_options_t* fc2d_thunderegg_options_register (fclaw_app_t * app, void fc2d_thunderegg_package_register(fclaw_app_t* app, fc2d_thunderegg_options_t* mg_opt); -fc2d_thunderegg_options_t* fc2d_thunderegg_get_options(struct fclaw2d_global *glob); +fc2d_thunderegg_options_t* fc2d_thunderegg_get_options(struct fclaw_global *glob); -void fc2d_thunderegg_options_store (struct fclaw2d_global* glob, +void fc2d_thunderegg_options_store (struct fclaw_global* glob, fc2d_thunderegg_options_t* mg_opt); -void fc2d_thunderegg_output(struct fclaw2d_global *glob, int iframe); +void fc2d_thunderegg_output(struct fclaw_global *glob, int iframe); #ifdef __cplusplus diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.h.TEST.cpp b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.h.TEST.cpp index ea395902e..b4b83de88 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.h.TEST.cpp +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_options.h.TEST.cpp @@ -23,50 +23,50 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include TEST_CASE("fc2d_thunderegg_options can store options in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_thunderegg_options_t* opts1 = FCLAW_ALLOC_ZERO(fc2d_thunderegg_options_t,1); fc2d_thunderegg_options_t* opts2 = FCLAW_ALLOC_ZERO(fc2d_thunderegg_options_t,1); fc2d_thunderegg_options_store(glob1, opts1); /* glob1 has one package glob2 has two */ - fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); + fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc2d_thunderegg_options_store(glob2, opts2); CHECK_EQ(fc2d_thunderegg_get_options(glob1), opts1); CHECK_EQ(fc2d_thunderegg_get_options(glob2), opts2); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc2d_thunderegg_get_options fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); CHECK_SC_ABORTED(fc2d_thunderegg_get_options(glob1)); CHECK_SC_ABORTED(fc2d_thunderegg_get_options(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc2d_thunderegg_options_store fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc2d_thunderegg_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_thunderegg_options_t,1)); CHECK_SC_ABORTED(fc2d_thunderegg_options_store(glob1, FCLAW_ALLOC_ZERO(fc2d_thunderegg_options_t,1))); @@ -74,8 +74,8 @@ TEST_CASE("fc2d_thunderegg_options_store fails if called twice on a glob") fc2d_thunderegg_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_thunderegg_options_t,1)); CHECK_SC_ABORTED(fc2d_thunderegg_options_store(glob2, FCLAW_ALLOC_ZERO(fc2d_thunderegg_options_t,1))); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_physical_bc.c b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_physical_bc.c index 34a35e9be..0696e9c4e 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_physical_bc.c +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_physical_bc.c @@ -29,22 +29,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_thunderegg.h" #include "fc2d_thunderegg_options.h" -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -void cb_fc2d_thunderegg_physical_bc(fclaw2d_domain_t *domain, - fclaw2d_patch_t *patch, +void cb_fc2d_thunderegg_physical_bc(fclaw_domain_t *domain, + fclaw_patch_t *patch, int blockno, int patchno, void *user) { - fclaw2d_global_iterate_t* s = (fclaw2d_global_iterate_t*) user; + fclaw_global_iterate_t* s = (fclaw_global_iterate_t*) user; fc2d_thunderegg_time_info_t *tinfo = (fc2d_thunderegg_time_info_t*) s->user; double t = tinfo->t; @@ -52,17 +52,17 @@ void cb_fc2d_thunderegg_physical_bc(fclaw2d_domain_t *domain, /* Determine which faces are at the physical boundary */ int intersects_bc[4]; - fclaw2d_physical_get_bc(s->glob,blockno,patchno,intersects_bc); + fclaw_physical_get_bc(s->glob,blockno,patchno,intersects_bc); int mx, my, mbc; double xlower, ylower, dx, dy; - fclaw2d_clawpatch_grid_data(s->glob,patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(s->glob,patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); const fc2d_thunderegg_options_t* mg_opt = fc2d_thunderegg_get_options(s->glob); int mfields; double *rhs; - fclaw2d_clawpatch_rhs_data(s->glob,patch,&rhs,&mfields); + fclaw_clawpatch_rhs_data(s->glob,patch,&rhs,&mfields); fc2d_thunderegg_vtable_t* mg_vt = fc2d_thunderegg_vt(s->glob); @@ -84,14 +84,14 @@ void cb_fc2d_thunderegg_physical_bc(fclaw2d_domain_t *domain, } /* This is needed by other routines, so we don't set it to static. */ -void fc2d_thunderegg_physical_get_bc(fclaw2d_global_t *glob, +void fc2d_thunderegg_physical_get_bc(fclaw_global_t *glob, int blockno, int patchno, int *intersects_bdry) { // const int numfaces = get_faces_per_patch(domain); int bdry[4]; - fclaw2d_patch_boundary_type(glob->domain,blockno,patchno,bdry); + fclaw_patch_boundary_type(glob->domain,blockno,patchno,bdry); int i; for(i = 0; i < 4; i++) { @@ -106,12 +106,12 @@ void fc2d_thunderegg_physical_get_bc(fclaw2d_global_t *glob, Public interface : Set physical boundary conditions on a patch ----------------------------------------------------------------------------- */ -void fc2d_thunderegg_physical_bc(fclaw2d_global_t *glob) +void fc2d_thunderegg_physical_bc(fclaw_global_t *glob) { fc2d_thunderegg_time_info_t tinfo; tinfo.t = glob->curr_time; - fclaw2d_global_iterate_patches(glob, + fclaw_global_iterate_patches(glob, cb_fc2d_thunderegg_physical_bc, (void *) &tinfo); } diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_physical_bc.h b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_physical_bc.h index 2d2bfd740..e70c7f9d6 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_physical_bc.h +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_physical_bc.h @@ -34,9 +34,9 @@ extern "C" #endif #endif -struct fclaw2d_global; -struct fclaw2d_domain; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_domain; +struct fclaw_patch; typedef struct fc2d_thunderegg_time_info @@ -45,7 +45,7 @@ typedef struct fc2d_thunderegg_time_info } fc2d_thunderegg_time_info_t; -void fc2d_thunderegg_physical_bc(struct fclaw2d_global *glob); +void fc2d_thunderegg_physical_bc(struct fclaw_global *glob); #ifdef __cplusplus diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector.cpp b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector.cpp index 9b0a363d6..a10b182ec 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector.cpp +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector.cpp @@ -24,35 +24,35 @@ */ #include "fc2d_thunderegg_vector.hpp" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "fc2d_thunderegg.h" #include "fc2d_thunderegg_options.h" using namespace ThunderEgg; -static void get_data(struct fclaw2d_global* glob, fclaw2d_patch_t* patch, fc2d_thunderegg_data_choice_t data_choice, double** q, int* meqn) +static void get_data(struct fclaw_global* glob, fclaw_patch_t* patch, fc2d_thunderegg_data_choice_t data_choice, double** q, int* meqn) { switch(data_choice){ case RHS: - fclaw2d_clawpatch_rhs_data(glob, patch, q, meqn); + fclaw_clawpatch_rhs_data(glob, patch, q, meqn); break; case SOLN: - fclaw2d_clawpatch_soln_data(glob, patch, q, meqn); + fclaw_clawpatch_soln_data(glob, patch, q, meqn); break; case STORE_STATE: - fclaw2d_clawpatch_soln_data(glob, patch, q, meqn); + fclaw_clawpatch_soln_data(glob, patch, q, meqn); break; } } -ThunderEgg::Vector<2> fc2d_thunderegg_get_vector(struct fclaw2d_global *glob, fc2d_thunderegg_data_choice_t data_choice) +ThunderEgg::Vector<2> fc2d_thunderegg_get_vector(struct fclaw_global *glob, fc2d_thunderegg_data_choice_t data_choice) { - fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); std::array ns; ns[0] = clawpatch_opt->mx; @@ -75,7 +75,7 @@ ThunderEgg::Vector<2> fc2d_thunderegg_get_vector(struct fclaw2d_global *glob, fc strides[2] = strides[1]*(ns[1] + 2 * mbc); std::vector starts(glob->domain->local_num_patches); for(int blockno = 0; blockno < glob->domain->num_blocks; blockno++){ - fclaw2d_block_t* block = &glob->domain->blocks[blockno]; + fclaw_block_t* block = &glob->domain->blocks[blockno]; for(int patchno = 0; patchno < block->num_patches; patchno++){ int meqn; get_data(glob, &block->patches[patchno], data_choice, &starts[block->num_patches_before+patchno], &meqn); @@ -84,16 +84,16 @@ ThunderEgg::Vector<2> fc2d_thunderegg_get_vector(struct fclaw2d_global *glob, fc Communicator comm(glob->mpicomm); return ThunderEgg::Vector<2>(comm,starts,strides,ns,mbc); } -void fc2d_thunderegg_store_vector(struct fclaw2d_global *glob, fc2d_thunderegg_data_choice_t data_choice, const ThunderEgg::Vector<2>& vec) +void fc2d_thunderegg_store_vector(struct fclaw_global *glob, fc2d_thunderegg_data_choice_t data_choice, const ThunderEgg::Vector<2>& vec) { - fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; int my = clawpatch_opt->my; int mbc = clawpatch_opt->mbc; for(int blockno = 0; blockno < glob->domain->num_blocks; blockno++){ - fclaw2d_block_t* block = &glob->domain->blocks[blockno]; + fclaw_block_t* block = &glob->domain->blocks[blockno]; for(int patchno = 0; patchno < block->num_patches; patchno++){ PatchView view = vec.getPatchView(block->num_patches_before+patchno); int meqn; diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector.hpp b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector.hpp index a7285b2c3..de263dc0a 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector.hpp +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector.hpp @@ -32,9 +32,9 @@ /* Avoid circular dependencies */ -struct fclaw2d_patch; -struct fclaw2d_domain; -struct fclaw2d_global; +struct fclaw_patch; +struct fclaw_domain; +struct fclaw_global; /** * @brief Choice for patch data @@ -56,7 +56,7 @@ typedef enum fc2d_thunderegg_data_choice * @param data_choice the data choice * @return ThunderEgg::Vector<2> the vector */ -ThunderEgg::Vector<2> fc2d_thunderegg_get_vector(struct fclaw2d_global *glob, fc2d_thunderegg_data_choice_t data_choice); +ThunderEgg::Vector<2> fc2d_thunderegg_get_vector(struct fclaw_global *glob, fc2d_thunderegg_data_choice_t data_choice); /** * @brief Get a thunderegg vector that is a view to forestclaw data @@ -65,5 +65,5 @@ ThunderEgg::Vector<2> fc2d_thunderegg_get_vector(struct fclaw2d_global *glob, fc * @param data_choice the data choice * @return ThunderEgg::Vector<2> the vector */ -void fc2d_thunderegg_store_vector(struct fclaw2d_global *glob, fc2d_thunderegg_data_choice_t data_choice, const ThunderEgg::Vector<2>& vec); +void fc2d_thunderegg_store_vector(struct fclaw_global *glob, fc2d_thunderegg_data_choice_t data_choice, const ThunderEgg::Vector<2>& vec); diff --git a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector_TEST.cpp b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector_TEST.cpp index efa32b18f..98d8ed1f3 100644 --- a/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector_TEST.cpp +++ b/src/solvers/fc2d_thunderegg/fc2d_thunderegg_vector_TEST.cpp @@ -24,42 +24,40 @@ */ #include "fc2d_thunderegg_vector.hpp" -#include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include +#include #include #include using namespace ThunderEgg; namespace{ struct QuadDomain { - fclaw2d_global_t* glob; + fclaw_global_t* glob; fclaw_options_t fopts; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *map; - fclaw2d_clawpatch_options_t opts; + fclaw_map_context_t *map; + fclaw_domain_t *domain; + fclaw_clawpatch_options_t* opts; QuadDomain(){ - int rank; - int size; - sc_MPI_Comm_rank(sc_MPI_COMM_WORLD, &rank); + int size, rank; sc_MPI_Comm_size(sc_MPI_COMM_WORLD, &size); - glob = fclaw2d_global_new_comm(sc_MPI_COMM_WORLD, rank, size); - - fclaw2d_vtables_initialize(glob); - fclaw2d_clawpatch_vtable_initialize(glob, 4); + sc_MPI_Comm_rank(sc_MPI_COMM_WORLD, &rank); + glob = fclaw_global_new_comm(sc_MPI_COMM_WORLD, size, rank); + opts = fclaw_clawpatch_options_new(2); memset(&fopts, 0, sizeof(fopts)); fopts.mi=1; @@ -72,57 +70,59 @@ struct QuadDomain { fopts.bz = 3; fopts.compute_error = true; fopts.subcycle = true; + fclaw_options_store(glob, &fopts); + + opts->mx = 5; + opts->my = 6; + opts->mbc = 2; + opts->meqn = 1; + opts->maux = 1; + opts->rhs_fields = 1; + fclaw_clawpatch_options_store(glob, opts); - domain = fclaw2d_domain_new_unitsquare(glob->mpicomm,fopts.minlevel); - map = fclaw2d_map_new_nomap(); - fclaw2d_options_store(glob, &fopts); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, map); + domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 1); + fclaw_global_store_domain(glob, domain); - memset(&opts, 0, sizeof(opts)); - opts.mx = 5; - opts.my = 6; - opts.mbc = 2; - opts.meqn = 1; - opts.maux = 1; - opts.rhs_fields = 1; - fclaw2d_clawpatch_options_store(glob, &opts); + map = fclaw_map_new_nomap(); + fclaw_map_store(glob,map); - fclaw2d_domain_data_new(glob->domain); + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + } void setup(){ - fclaw2d_build_mode_t build_mode = FCLAW2D_BUILD_FOR_UPDATE; - fclaw2d_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); - fclaw2d_patch_build(glob, &domain->blocks[0].patches[1], 0, 1, &build_mode); - fclaw2d_patch_build(glob, &domain->blocks[0].patches[2], 0, 2, &build_mode); - fclaw2d_patch_build(glob, &domain->blocks[0].patches[3], 0, 3, &build_mode); + fclaw_build_mode_t build_mode = FCLAW_BUILD_FOR_UPDATE; + fclaw_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); + fclaw_patch_build(glob, &domain->blocks[0].patches[1], 0, 1, &build_mode); + fclaw_patch_build(glob, &domain->blocks[0].patches[2], 0, 2, &build_mode); + fclaw_patch_build(glob, &domain->blocks[0].patches[3], 0, 3, &build_mode); } ~QuadDomain(){ - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[0]); - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[1]); - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[2]); - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[3]); - fclaw2d_global_destroy(glob); + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[0]); + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[1]); + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[2]); + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[3]); + fclaw_clawpatch_options_destroy(opts); + fclaw_map_destroy(map); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); } }; struct QuadDomainBrick { - fclaw2d_global_t* glob; + fclaw_global_t* glob; fclaw_options_t fopts; - fclaw2d_domain_t *domain; - fclaw2d_map_context_t *map; - fclaw2d_clawpatch_options_t opts; + fclaw_map_context_t* map; + fclaw_domain_t *domain; + fclaw_clawpatch_options_t* opts; QuadDomainBrick(){ - int rank; - int size; - sc_MPI_Comm_rank(sc_MPI_COMM_WORLD, &rank); + int size, rank; sc_MPI_Comm_size(sc_MPI_COMM_WORLD, &size); - glob = fclaw2d_global_new_comm(sc_MPI_COMM_WORLD, rank, size); + sc_MPI_Comm_rank(sc_MPI_COMM_WORLD, &rank); + glob = fclaw_global_new_comm(sc_MPI_COMM_WORLD, size, rank); + opts = fclaw_clawpatch_options_new(2); - fclaw2d_vtables_initialize(glob); - fclaw2d_clawpatch_vtable_initialize(glob, 4); - memset(&fopts, 0, sizeof(fopts)); fopts.mi=2; fopts.mj=2; @@ -134,39 +134,43 @@ struct QuadDomainBrick { fopts.bz = 3; fopts.compute_error = true; fopts.subcycle = true; + fclaw_options_store(glob, &fopts); - domain = fclaw2d_domain_new_brick(glob->mpicomm,fopts.mi,fopts.mj,0,0,fopts.minlevel); - fclaw2d_map_context_t *brick = - fclaw2d_map_new_brick(domain, fopts.mi, fopts.mj, 0, 0); - map = fclaw2d_map_new_nomap_brick(brick); - fclaw2d_global_store_domain(glob, domain); - fclaw2d_global_store_map(glob, map); - fclaw2d_options_store(glob, &fopts); - - memset(&opts, 0, sizeof(opts)); - opts.mx = 5; - opts.my = 6; - opts.mbc = 2; - opts.meqn = 1; - opts.maux = 1; - opts.rhs_fields = 1; - fclaw2d_clawpatch_options_store(glob, &opts); - - fclaw2d_domain_data_new(glob->domain); - } + + opts->mx = 5; + opts->my = 6; + opts->mbc = 2; + opts->meqn = 1; + opts->maux = 1; + opts->rhs_fields = 1; + fclaw_clawpatch_options_store(glob, opts); + + domain = fclaw_domain_new_2d_brick(sc_MPI_COMM_WORLD, fopts.mi, fopts.mj, 0,0,0); + fclaw_global_store_domain(glob, domain); + + map = fclaw_map_new_nomap(); + fclaw_map_store(glob, map); + + fclaw_vtables_initialize(glob); + fclaw_clawpatch_vtable_initialize(glob, 4); + + } void setup(){ - fclaw2d_build_mode_t build_mode = FCLAW2D_BUILD_FOR_UPDATE; - fclaw2d_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); - fclaw2d_patch_build(glob, &domain->blocks[1].patches[0], 1, 0, &build_mode); - fclaw2d_patch_build(glob, &domain->blocks[2].patches[0], 2, 0, &build_mode); - fclaw2d_patch_build(glob, &domain->blocks[3].patches[0], 3, 0, &build_mode); + fclaw_build_mode_t build_mode = FCLAW_BUILD_FOR_UPDATE; + fclaw_patch_build(glob, &domain->blocks[0].patches[0], 0, 0, &build_mode); + fclaw_patch_build(glob, &domain->blocks[1].patches[0], 1, 0, &build_mode); + fclaw_patch_build(glob, &domain->blocks[2].patches[0], 2, 0, &build_mode); + fclaw_patch_build(glob, &domain->blocks[3].patches[0], 3, 0, &build_mode); } ~QuadDomainBrick(){ - fclaw2d_patch_data_delete(glob, &domain->blocks[0].patches[0]); - fclaw2d_patch_data_delete(glob, &domain->blocks[1].patches[0]); - fclaw2d_patch_data_delete(glob, &domain->blocks[2].patches[0]); - fclaw2d_patch_data_delete(glob, &domain->blocks[3].patches[0]); - fclaw2d_global_destroy(glob); + fclaw_patch_data_delete(glob, &domain->blocks[0].patches[0]); + fclaw_patch_data_delete(glob, &domain->blocks[1].patches[0]); + fclaw_patch_data_delete(glob, &domain->blocks[2].patches[0]); + fclaw_patch_data_delete(glob, &domain->blocks[3].patches[0]); + fclaw_clawpatch_options_destroy(opts); + fclaw_map_destroy(map); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); } }; } @@ -179,13 +183,13 @@ TEST_CASE("fclaw2d_thunderegg_get_vector") for(int meqn : {1,2}) { QuadDomain test_data; - test_data.opts.mx = mx; - test_data.opts.my = my; - test_data.opts.mbc = mbc; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mbc = mbc; if(data_choice == RHS){ - test_data.opts.rhs_fields = meqn; + test_data.opts->rhs_fields = meqn; }else{ - test_data.opts.meqn = meqn; + test_data.opts->meqn = meqn; } test_data.setup(); @@ -194,13 +198,13 @@ TEST_CASE("fclaw2d_thunderegg_get_vector") double * data = nullptr; switch(data_choice){ case RHS: - fclaw2d_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); + fclaw_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); break; case SOLN: - fclaw2d_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); break; case STORE_STATE: - fclaw2d_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); break; } for(int j=0; j<(mx+2*mbc)*(my+2*mbc)*meqn; j++){ @@ -251,13 +255,13 @@ TEST_CASE("fclaw2d_thunderegg_store_vector") for(int meqn : {1,2}) { QuadDomain test_data; - test_data.opts.mx = mx; - test_data.opts.my = my; - test_data.opts.mbc = mbc; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mbc = mbc; if(data_choice == RHS){ - test_data.opts.rhs_fields = meqn; + test_data.opts->rhs_fields = meqn; }else{ - test_data.opts.meqn = meqn; + test_data.opts->meqn = meqn; } test_data.setup(); @@ -284,13 +288,13 @@ TEST_CASE("fclaw2d_thunderegg_store_vector") double * data = nullptr; switch(data_choice){ case RHS: - fclaw2d_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); + fclaw_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); break; case SOLN: - fclaw2d_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); break; case STORE_STATE: - fclaw2d_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[0].patches[i], &data, &meqn); break; } for(int j=0; j<(mx+2*mbc)*(my+2*mbc)*meqn; j++){ @@ -309,32 +313,32 @@ TEST_CASE("fclaw2d_thunderegg_get_vector multiblock") for(int meqn : {1,2}) { QuadDomainBrick test_data; - test_data.opts.mx = mx; - test_data.opts.my = my; - test_data.opts.mbc = mbc; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mbc = mbc; if(data_choice == RHS){ - test_data.opts.rhs_fields = meqn; + test_data.opts->rhs_fields = meqn; }else{ - test_data.opts.meqn = meqn; + test_data.opts->meqn = meqn; } test_data.setup(); - int mx = test_data.opts.mx; - int my = test_data.opts.my; - int mbc = test_data.opts.mbc; + int mx = test_data.opts->mx; + int my = test_data.opts->my; + int mbc = test_data.opts->mbc; //set data for(int i=0; i < 4; i++){ double * data = nullptr; switch(data_choice){ case RHS: - fclaw2d_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); + fclaw_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); break; case SOLN: - fclaw2d_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); break; case STORE_STATE: - fclaw2d_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); break; } for(int j=0; j<(mx+2*mbc)*(my+2*mbc)*meqn; j++){ @@ -385,13 +389,13 @@ TEST_CASE("fclaw2d_thunderegg_store_vector multiblock") for(int meqn : {1,2}) { QuadDomainBrick test_data; - test_data.opts.mx = mx; - test_data.opts.my = my; - test_data.opts.mbc = mbc; + test_data.opts->mx = mx; + test_data.opts->my = my; + test_data.opts->mbc = mbc; if(data_choice == RHS){ - test_data.opts.rhs_fields = meqn; + test_data.opts->rhs_fields = meqn; }else{ - test_data.opts.meqn = meqn; + test_data.opts->meqn = meqn; } test_data.setup(); @@ -418,13 +422,13 @@ TEST_CASE("fclaw2d_thunderegg_store_vector multiblock") double * data = nullptr; switch(data_choice){ case RHS: - fclaw2d_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); + fclaw_clawpatch_rhs_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); break; case SOLN: - fclaw2d_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); break; case STORE_STATE: - fclaw2d_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); + fclaw_clawpatch_soln_data(test_data.glob, &test_data.domain->blocks[i].patches[0], &data, &meqn); break; } for(int j=0; j<(mx+2*mbc)*(my+2*mbc)*meqn; j++){ diff --git a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_fivepoint.cpp b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_fivepoint.cpp index 8f743a893..44a5d2d8d 100644 --- a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_fivepoint.cpp +++ b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_fivepoint.cpp @@ -29,23 +29,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_thunderegg_options.h" #include "fc2d_thunderegg_vector.hpp" -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include +#include + #include using namespace std; @@ -262,12 +264,12 @@ void fivePoint::modifyRHSForInternalBoundaryConditions(const PatchInfo<2>& pinfo } -void fc2d_thunderegg_fivepoint_solve(fclaw2d_global_t *glob) +void fc2d_thunderegg_fivepoint_solve(fclaw_global_t *glob) { // get needed options - fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); fc2d_thunderegg_options_t *mg_opt = fc2d_thunderegg_get_options(glob); GhostFillingType fill_type = GhostFillingType::Faces; @@ -283,15 +285,15 @@ void fc2d_thunderegg_fivepoint_solve(fclaw2d_global_t *glob) int mbc = clawpatch_opt->mbc; // get p4est structure - fclaw2d_domain_t *domain = glob->domain; - p4est_wrap_t *wrap = (p4est_wrap_t *)domain->pp; + fclaw_domain_t *domain = glob->domain; + p4est_wrap_t *wrap = (p4est_wrap_t *)domain->d2->pp; // create map function P4estDomainGenerator::BlockMapFunc bmf = [&](int block_no, double unit_x, double unit_y, double &x, double &y) { double x1,y1,z1; - FCLAW2D_MAP_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); + FCLAW_MAP_2D_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); x = fclaw_opt->ax + (fclaw_opt->bx - fclaw_opt->ax) * x1; y = fclaw_opt->ay + (fclaw_opt->by - fclaw_opt->ay) * y1; }; diff --git a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_fivepoint.h b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_fivepoint.h index f4a0a668f..1e47c51b3 100644 --- a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_fivepoint.h +++ b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_fivepoint.h @@ -38,10 +38,10 @@ extern "C" /* fix syntax highlighting */ #endif -struct fclaw2d_global; +struct fclaw_global; -void fc2d_thunderegg_fivepoint_solve(struct fclaw2d_global *glob); +void fc2d_thunderegg_fivepoint_solve(struct fclaw_global *glob); /* Everything is defined in the .cpp function */ diff --git a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_heat.cpp b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_heat.cpp index 6a267fb9c..84024f5d5 100644 --- a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_heat.cpp +++ b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_heat.cpp @@ -29,23 +29,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_thunderegg_options.h" #include "fc2d_thunderegg_vector.hpp" -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include +#include + #include using namespace std; @@ -56,7 +58,7 @@ class heat : public PatchOperator<2> public: static double lambda; - heat(fclaw2d_global_t *glob, + heat(fclaw_global_t *glob, const Domain<2>& domain, const GhostFiller<2>& ghost_filler); @@ -95,7 +97,7 @@ double fc2d_thunderegg_heat_get_lambda() return heat::lambda; } -heat::heat(fclaw2d_global_t *glob, +heat::heat(fclaw_global_t *glob, const Domain<2>& domain, const GhostFiller<2>& ghost_filler) : PatchOperator<2>(domain,ghost_filler) @@ -327,12 +329,12 @@ void heat::modifyRHSForInternalBoundaryConditions(const PatchInfo<2>& pinfo, } -void fc2d_thunderegg_heat_solve(fclaw2d_global_t *glob) +void fc2d_thunderegg_heat_solve(fclaw_global_t *glob) { // get needed options - fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); fc2d_thunderegg_options_t *mg_opt = fc2d_thunderegg_get_options(glob); GhostFillingType fill_type = GhostFillingType::Faces; @@ -348,15 +350,15 @@ void fc2d_thunderegg_heat_solve(fclaw2d_global_t *glob) int mbc = clawpatch_opt->mbc; // get p4est structure - fclaw2d_domain_t *domain = glob->domain; - p4est_wrap_t *wrap = (p4est_wrap_t *)domain->pp; + fclaw_domain_t *domain = glob->domain; + p4est_wrap_t *wrap = (p4est_wrap_t *)domain->d2->pp; // create map function P4estDomainGenerator::BlockMapFunc bmf = [&](int block_no, double unit_x, double unit_y, double &x, double &y) { double x1,y1,z1; - FCLAW2D_MAP_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); + FCLAW_MAP_2D_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); x = fclaw_opt->ax + (fclaw_opt->bx - fclaw_opt->ax) * x1; y = fclaw_opt->ay + (fclaw_opt->by - fclaw_opt->ay) * y1; }; diff --git a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_heat.h b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_heat.h index ecf310aba..f3506740d 100644 --- a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_heat.h +++ b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_heat.h @@ -38,10 +38,10 @@ extern "C" /* fix syntax highlighting */ #endif -struct fclaw2d_global; +struct fclaw_global; -void fc2d_thunderegg_heat_solve(struct fclaw2d_global *glob); +void fc2d_thunderegg_heat_solve(struct fclaw_global *glob); void fc2d_thunderegg_heat_set_lambda(double lambda); diff --git a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_starpatch.cpp b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_starpatch.cpp index 7203691f0..58a23a13b 100644 --- a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_starpatch.cpp +++ b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_starpatch.cpp @@ -29,23 +29,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_thunderegg_options.h" #include "fc2d_thunderegg_vector.hpp" -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include +#include + #include using namespace std; @@ -68,12 +70,12 @@ Vector<2> restrict_beta_vec(const Vector<2>& prev_beta_vec, return restrictor.restrict(prev_beta_vec); } -void fc2d_thunderegg_starpatch_solve(fclaw2d_global_t *glob) +void fc2d_thunderegg_starpatch_solve(fclaw_global_t *glob) { // get needed options - fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); fc2d_thunderegg_options_t *mg_opt = fc2d_thunderegg_get_options(glob); // ghost filling type @@ -91,15 +93,15 @@ void fc2d_thunderegg_starpatch_solve(fclaw2d_global_t *glob) int mbc = clawpatch_opt->mbc; // get p4est structure - fclaw2d_domain_t *domain = glob->domain; - p4est_wrap_t *wrap = (p4est_wrap_t *)domain->pp; + fclaw_domain_t *domain = glob->domain; + p4est_wrap_t *wrap = (p4est_wrap_t *)domain->d2->pp; // create map function P4estDomainGenerator::BlockMapFunc bmf = [&](int block_no, double unit_x, double unit_y, double &x, double &y) { double x1,y1,z1; - FCLAW2D_MAP_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); + FCLAW_MAP_2D_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); x = fclaw_opt->ax + (fclaw_opt->bx - fclaw_opt->ax) * x1; y = fclaw_opt->ay + (fclaw_opt->by - fclaw_opt->ay) * y1; }; diff --git a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_starpatch.h b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_starpatch.h index 39e686de7..35f87c132 100644 --- a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_starpatch.h +++ b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_starpatch.h @@ -38,10 +38,10 @@ extern "C" /* fix syntax highlighting */ #endif -struct fclaw2d_global; +struct fclaw_global; -void fc2d_thunderegg_starpatch_solve(struct fclaw2d_global *glob); +void fc2d_thunderegg_starpatch_solve(struct fclaw_global *glob); /* Everything is defined in the .cpp function */ diff --git a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_varpoisson.cpp b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_varpoisson.cpp index 8016baaa6..254ed768a 100644 --- a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_varpoisson.cpp +++ b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_varpoisson.cpp @@ -29,23 +29,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc2d_thunderegg_options.h" #include "fc2d_thunderegg_vector.hpp" -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include +#include + #include using namespace std; @@ -327,12 +329,12 @@ Vector<2> varpoisson_restrict_beta_vec(const Vector<2>& prev_beta_vec, /* Public interface - this function is virtualized */ -void fc2d_thunderegg_varpoisson_solve(fclaw2d_global_t *glob) +void fc2d_thunderegg_varpoisson_solve(fclaw_global_t *glob) { // get needed options - fclaw2d_clawpatch_options_t *clawpatch_opt = - fclaw2d_clawpatch_get_options(glob); - fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); + fclaw_clawpatch_options_t *clawpatch_opt = + fclaw_clawpatch_get_options(glob); + fclaw_options_t *fclaw_opt = fclaw_get_options(glob); fc2d_thunderegg_options_t *mg_opt = fc2d_thunderegg_get_options(glob); GhostFillingType fill_type = GhostFillingType::Faces; @@ -345,15 +347,15 @@ void fc2d_thunderegg_varpoisson_solve(fclaw2d_global_t *glob) int mbc = clawpatch_opt->mbc; // get p4est structure - fclaw2d_domain_t *domain = glob->domain; - p4est_wrap_t *wrap = (p4est_wrap_t *)domain->pp; + fclaw_domain_t *domain = glob->domain; + p4est_wrap_t *wrap = (p4est_wrap_t *)domain->d2->pp; // create map function P4estDomainGenerator::BlockMapFunc bmf = [&](int block_no, double unit_x, double unit_y, double &x, double &y) { double x1,y1,z1; - FCLAW2D_MAP_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); + FCLAW_MAP_2D_BRICK2C(&glob->cont,&block_no,&unit_x, &unit_y, &x1, &y1, &z1); x = fclaw_opt->ax + (fclaw_opt->bx - fclaw_opt->ax) * x1; y = fclaw_opt->ay + (fclaw_opt->by - fclaw_opt->ay) * y1; }; diff --git a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_varpoisson.h b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_varpoisson.h index 900026e4f..534beea27 100644 --- a/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_varpoisson.h +++ b/src/solvers/fc2d_thunderegg/operators/fc2d_thunderegg_varpoisson.h @@ -38,10 +38,10 @@ extern "C" /* Needed to fix syntax highlighting */ #endif -struct fclaw2d_global; +struct fclaw_global; -void fc2d_thunderegg_varpoisson_solve(struct fclaw2d_global *glob); +void fc2d_thunderegg_varpoisson_solve(struct fclaw_global *glob); #ifdef __cplusplus diff --git a/src/solvers/fc3d_clawpack46/CMakeLists.txt b/src/solvers/fc3d_clawpack46/CMakeLists.txt index e3b8311b3..42d4555a6 100644 --- a/src/solvers/fc3d_clawpack46/CMakeLists.txt +++ b/src/solvers/fc3d_clawpack46/CMakeLists.txt @@ -38,14 +38,11 @@ install(FILES fc3d_clawpack46_fort.h fc3d_clawpack46_options.h fc3d_clawpack46_user_fort.h -DESTINATION include +TYPE INCLUDE ) install(TARGETS clawpack3_46 - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # -- imported target, for use from FetchContent diff --git a/src/solvers/fc3d_clawpack46/fc3d_clawpack46.cpp b/src/solvers/fc3d_clawpack46/fc3d_clawpack46.cpp index 0bfa95ebd..29e731550 100644 --- a/src/solvers/fc3d_clawpack46/fc3d_clawpack46.cpp +++ b/src/solvers/fc3d_clawpack46/fc3d_clawpack46.cpp @@ -29,30 +29,29 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include /* --------------------- Clawpack solver functions (required) ------------------------- */ static -void clawpack46_setprob(fclaw2d_global_t *glob) +void clawpack46_setprob(fclaw_global_t *glob) { fc3d_clawpack46_vtable_t* claw46_vt = fc3d_clawpack46_vt(glob); if (claw46_vt->fort_setprob != NULL) @@ -63,24 +62,24 @@ void clawpack46_setprob(fclaw2d_global_t *glob) static -void clawpack46_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_qinit(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { int mx,my,mz,mbc; double dx,dy,dz, xlower,ylower, zlower; - fclaw3dx_clawpatch_grid_data(glob,patch,&mx,&my,&mz,&mbc, + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz,&mbc, &xlower,&ylower,&zlower, &dx,&dy,&dz); int meqn; double *q; - fclaw3dx_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int maux; double *aux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); fc3d_clawpack46_vtable_t* claw46_vt = fc3d_clawpack46_vt(glob); @@ -95,8 +94,8 @@ void clawpack46_qinit(fclaw2d_global_t *glob, static -void clawpack46_bc3(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_bc3(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -112,26 +111,39 @@ void clawpack46_bc3(fclaw2d_global_t *glob, int mx,my,mz, mbc; double dx,dy,dz, xlower,ylower, zlower; - fclaw3dx_clawpatch_grid_data(glob,patch, &mx,&my,&mz,&mbc, + fclaw_clawpatch_3d_grid_data(glob,patch, &mx,&my,&mz,&mbc, &xlower,&ylower,&zlower, &dx,&dy,&dz); double *aux; int maux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); int *block_mthbc = clawpack_options->mthbc; /* Set a local copy of mthbc that can be used for a patch. */ int mthbc[6]; - for(int i = 0; i < 6; i++) + if(glob->domain->refine_dim == 2) { - if (i < 4) + for(int i = 0; i < 6; i++) + { + if (i < 4) + if (intersects_phys_bdry[i]) + mthbc[i] = block_mthbc[i]; + else + mthbc[i] = -1; + else + mthbc[i] = block_mthbc[i]; + } + } + else + { + for(int i = 0; i < 6; i++) + { if (intersects_phys_bdry[i]) mthbc[i] = block_mthbc[i]; else mthbc[i] = -1; - else - mthbc[i] = block_mthbc[i]; + } } /* @@ -142,7 +154,7 @@ void clawpack46_bc3(fclaw2d_global_t *glob, */ double *q; int meqn; - fclaw3dx_clawpatch_timesync_data(glob,patch,time_interp,&q,&meqn); + fclaw_clawpatch_timesync_data(glob,patch,time_interp,&q,&meqn); FC3D_CLAWPACK46_SET_BLOCK(&blockno); claw46_vt->fort_bc3(&meqn,&mbc,&mx,&my,&mz,&xlower,&ylower,&zlower, @@ -152,8 +164,8 @@ void clawpack46_bc3(fclaw2d_global_t *glob, static -void clawpack46_b4step3(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_b4step3(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, double dt) @@ -165,16 +177,16 @@ void clawpack46_b4step3(fclaw2d_global_t *glob, int mx,my,mz,mbc; double xlower,ylower,zlower,dx,dy,dz; - fclaw3dx_clawpatch_grid_data(glob,patch, &mx,&my,&mz, &mbc, + fclaw_clawpatch_3d_grid_data(glob,patch, &mx,&my,&mz, &mbc, &xlower,&ylower,&zlower,&dx,&dy,&dz); int meqn; double *q; - fclaw3dx_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); int maux; double *aux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); FC3D_CLAWPACK46_SET_BLOCK(&blockno); claw46_vt->fort_b4step3(&mbc,&mx,&my,&mz, &meqn,q, @@ -184,8 +196,8 @@ void clawpack46_b4step3(fclaw2d_global_t *glob, } static -void clawpack46_src3(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_src3(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -199,16 +211,16 @@ void clawpack46_src3(fclaw2d_global_t *glob, int mx,my,mz, mbc; double xlower,ylower,zlower,dx,dy,dz; - fclaw3dx_clawpatch_grid_data(glob,patch, &mx,&my,&mz, &mbc, + fclaw_clawpatch_3d_grid_data(glob,patch, &mx,&my,&mz, &mbc, &xlower,&ylower,&zlower, &dx,&dy, &dz); double *q; int meqn; - fclaw3dx_clawpatch_soln_data(glob,patch,&q,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&q,&meqn); double *aux; int maux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); FC3D_CLAWPACK46_SET_BLOCK(&blockno); claw46_vt->fort_src3(&meqn,&mbc,&mx,&my,&mz, &xlower,&ylower,&zlower, @@ -219,8 +231,8 @@ void clawpack46_src3(fclaw2d_global_t *glob, /* This can be used as a value for patch_vt->patch_setup */ static -void clawpack46_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void clawpack46_setaux(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -232,7 +244,7 @@ void clawpack46_setaux(fclaw2d_global_t *glob, return; } - if (fclaw2d_patch_is_ghost(patch)) + if (fclaw_patch_is_ghost(patch)) { /* This is going to be removed at some point */ return; @@ -240,11 +252,11 @@ void clawpack46_setaux(fclaw2d_global_t *glob, int mx,my,mz,mbc; double xlower,ylower,zlower, dx,dy, dz; - fclaw3dx_clawpatch_grid_data(glob,patch, &mx,&my,&mz,&mbc, + fclaw_clawpatch_3d_grid_data(glob,patch, &mx,&my,&mz,&mbc, &xlower,&ylower,&zlower, &dx,&dy, &dz); int maux; double *aux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); FC3D_CLAWPACK46_SET_BLOCK(&blockno); claw46_vt->fort_setaux(&mbc,&mx,&my,&mz, &xlower,&ylower,&zlower, @@ -254,14 +266,14 @@ void clawpack46_setaux(fclaw2d_global_t *glob, /* This is called from the single_step callback. and is of type 'flaw_single_step_t' */ static -double clawpack46_step3(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +double clawpack46_step3(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, double dt) { - // const fclaw_options_t* fclaw_opt = fclaw2d_get_options(glob); + // const fclaw_options_t* fclaw_opt = fclaw_get_options(glob); fc3d_clawpack46_vtable_t* claw46_vt = fc3d_clawpack46_vt(glob); FCLAW_ASSERT(claw46_vt->fort_rpn3 != NULL); @@ -279,18 +291,18 @@ double clawpack46_step3(fclaw2d_global_t *glob, int maux; double *aux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); - fclaw3dx_clawpatch_save_current_step(glob, patch); + fclaw_clawpatch_save_current_step(glob, patch); int mx, my, mz, mbc; double xlower, ylower, zlower, dx,dy, dz; - fclaw3dx_clawpatch_grid_data(glob,patch,&mx,&my,&mz,&mbc, + fclaw_clawpatch_3d_grid_data(glob,patch,&mx,&my,&mz,&mbc, &xlower,&ylower,&zlower, &dx,&dy,&dz); int meqn; double *qold; - fclaw3dx_clawpatch_soln_data(glob,patch,&qold,&meqn); + fclaw_clawpatch_soln_data(glob,patch,&qold,&meqn); int mwaves = clawpack_options->mwaves; @@ -352,7 +364,7 @@ double clawpack46_step3(fclaw2d_global_t *glob, double* hm = FCLAW_ALLOC(double,size); int ierror = 0; - int* block_corner_count = fclaw2d_patch_block_corner_count(glob,patch); + int* block_corner_count = fclaw_patch_block_corner_count(glob,patch); #if 0 if (claw46_vt->flux2 == NULL) @@ -408,8 +420,8 @@ double clawpack46_step3(fclaw2d_global_t *glob, } static -double clawpack46_update(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +double clawpack46_update(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -420,23 +432,23 @@ double clawpack46_update(fclaw2d_global_t *glob, fc3d_clawpack46_vtable_t* claw46_vt = fc3d_clawpack46_vt(glob); if (claw46_vt->b4step3 != NULL) { - fclaw2d_timer_start_threadsafe(&glob->timers[FCLAW2D_TIMER_ADVANCE_B4STEP2]); + fclaw_timer_start_threadsafe(&glob->timers[FCLAW_TIMER_ADVANCE_B4STEP2]); claw46_vt->b4step3(glob, patch, blockno, patchno,t,dt); - fclaw2d_timer_stop_threadsafe(&glob->timers[FCLAW2D_TIMER_ADVANCE_B4STEP2]); + fclaw_timer_stop_threadsafe(&glob->timers[FCLAW_TIMER_ADVANCE_B4STEP2]); } - fclaw2d_timer_start_threadsafe(&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_start_threadsafe(&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); double maxcfl = clawpack46_step3(glob, patch, blockno, patchno,t,dt); - fclaw2d_timer_stop_threadsafe(&glob->timers[FCLAW2D_TIMER_ADVANCE_STEP2]); + fclaw_timer_stop_threadsafe(&glob->timers[FCLAW_TIMER_ADVANCE_STEP2]); const fc3d_clawpack46_options_t* clawpack_options = fc3d_clawpack46_get_options(glob); if (clawpack_options->src_term > 0 && claw46_vt->src3 != NULL) @@ -453,15 +465,15 @@ double clawpack46_update(fclaw2d_global_t *glob, /* ---------------------------------- Output functions -------------------------------- */ static -void clawpack46_output(fclaw2d_global_t *glob, int iframe) +void clawpack46_output(fclaw_global_t *glob, int iframe) { const fc3d_clawpack46_options_t* clawpack_options = fc3d_clawpack46_get_options(glob); if (clawpack_options->ascii_out != 0) - fclaw3dx_clawpatch_output_ascii(glob,iframe); + fclaw_clawpatch_output_ascii(glob,iframe); if (clawpack_options->vtk_out != 0) - fclaw3dx_clawpatch_output_vtk(glob,iframe); + fclaw_clawpatch_output_vtk(glob,iframe); } @@ -480,11 +492,16 @@ void clawpack46_vt_destroy(void* vt) FCLAW_FREE (vt); } -void fc3d_clawpack46_solver_initialize(fclaw2d_global_t* glob) +void fc3d_clawpack46_solver_initialize(fclaw_global_t* glob) { - fclaw3dx_clawpatch_options_t* clawpatch_opt = fclaw3dx_clawpatch_get_options(glob); + fclaw_clawpatch_options_t* clawpatch_opt = fclaw_clawpatch_get_options(glob); fc3d_clawpack46_options_t* clawopt = fc3d_clawpack46_get_options(glob); + if(clawpatch_opt->patch_dim != 3) + { + fclaw_abortf("Clawpatch dimension set to 2d. fc3d_clawpack46 is only for 3d."); + } + clawopt->method[6] = clawpatch_opt->maux; if (clawpatch_opt->maux == 0 && clawopt->mcapa > 0) @@ -494,17 +511,17 @@ void fc3d_clawpack46_solver_initialize(fclaw2d_global_t* glob) } int claw_version = 4; - fclaw3dx_clawpatch_vtable_initialize(glob, claw_version); - //fclaw3dx_clawpatch_vtable_t* clawpatch_vt = fclaw3dx_clawpatch_vt(); + fclaw_clawpatch_vtable_initialize(glob, claw_version); + //fclaw_clawpatch_vtable_t* clawpatch_vt = fclaw_clawpatch_vt(); - fclaw2d_vtable_t* fclaw_vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_vtable_t* fc_vt = fclaw_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); fc3d_clawpack46_vtable_t* claw46_vt = clawpack46_vt_new(); /* ForestClaw vtable items */ - fclaw_vt->output_frame = clawpack46_output; - fclaw_vt->problem_setup = clawpack46_setprob; + fc_vt->output_frame = clawpack46_output; + fc_vt->problem_setup = clawpack46_setprob; /* These could be over-written by user specific settings */ patch_vt->initialize = clawpack46_qinit; @@ -547,7 +564,7 @@ void fc3d_clawpack46_solver_initialize(fclaw2d_global_t* glob) /* These are here in case the user wants to call Clawpack routines directly */ -fc3d_clawpack46_vtable_t* fc3d_clawpack46_vt(fclaw2d_global_t* glob) +fc3d_clawpack46_vtable_t* fc3d_clawpack46_vt(fclaw_global_t* glob) { fc3d_clawpack46_vtable_t* claw46_vt = (fc3d_clawpack46_vtable_t*) fclaw_pointer_map_get(glob->vtables, "fc3d_clawpack46"); @@ -557,8 +574,8 @@ fc3d_clawpack46_vtable_t* fc3d_clawpack46_vt(fclaw2d_global_t* glob) } /* This should only be called when a new fclaw3dx_clawpatch_t is created. */ -void fc3d_clawpack46_set_capacity(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fc3d_clawpack46_set_capacity(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -567,14 +584,14 @@ void fc3d_clawpack46_set_capacity(fclaw2d_global_t *glob, int mx,my,mz, mbc; double dx,dy,dz, xlower,ylower,zlower; - fclaw3dx_clawpatch_grid_data(glob,patch, &mx,&my,&mz,&mbc, + fclaw_clawpatch_3d_grid_data(glob,patch, &mx,&my,&mz,&mbc, &xlower,&ylower,&zlower,&dx,&dy,&dz); - double *volume = fclaw3d_clawpatch_get_volume(glob,patch); + double *volume = fclaw_clawpatch_get_3d_volume(glob,patch); int maux; double *aux; - fclaw3dx_clawpatch_aux_data(glob,patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,patch,&aux,&maux); FCLAW_ASSERT(maux >= mcapa && mcapa > 0); FC3D_CLAWPACK46_SET_CAPACITY(&mx,&my,&mz,&mbc,&dx,&dy,&dz,volume,&mcapa, @@ -587,14 +604,14 @@ void fc3d_clawpack46_set_capacity(fclaw2d_global_t *glob, /* These are overkill; it isn't obvious why the user would want these */ -void fc3d_clawpack46_setprob(fclaw2d_global_t *glob) +void fc3d_clawpack46_setprob(fclaw_global_t *glob) { clawpack46_setprob(glob); } /* This can be set to claw46_vt->src3 */ -void fc3d_clawpack46_src3(fclaw2d_global_t* glob, - fclaw2d_patch_t *patch, +void fc3d_clawpack46_src3(fclaw_global_t* glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -604,8 +621,8 @@ void fc3d_clawpack46_src3(fclaw2d_global_t* glob, } -void fc3d_clawpack46_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fc3d_clawpack46_setaux(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { @@ -613,16 +630,16 @@ void fc3d_clawpack46_setaux(fclaw2d_global_t *glob, } -void fc3d_clawpack46_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fc3d_clawpack46_qinit(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno) { clawpack46_qinit(glob,patch,blockno,patchno); } -void fc3d_clawpack46_b4step3(fclaw2d_global_t* glob, - fclaw2d_patch_t *patch, +void fc3d_clawpack46_b4step3(fclaw_global_t* glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, @@ -631,8 +648,8 @@ void fc3d_clawpack46_b4step3(fclaw2d_global_t* glob, clawpack46_b4step3(glob,patch,blockno,patchno,t,dt); } -void fc3d_clawpack46_bc3(fclaw2d_global_t *glob, - fclaw2d_patch_t *patch, +void fc3d_clawpack46_bc3(fclaw_global_t *glob, + fclaw_patch_t *patch, int blockno, int patchno, double t, diff --git a/src/solvers/fc3d_clawpack46/fc3d_clawpack46.h b/src/solvers/fc3d_clawpack46/fc3d_clawpack46.h index 10d627273..95503be01 100644 --- a/src/solvers/fc3d_clawpack46/fc3d_clawpack46.h +++ b/src/solvers/fc3d_clawpack46/fc3d_clawpack46.h @@ -33,8 +33,8 @@ extern "C" { #endif -struct fclaw2d_global; -struct fclaw2d_patch; +struct fclaw_global; +struct fclaw_patch; typedef struct fc3d_clawpack46_vtable fc3d_clawpack46_vtable_t; @@ -42,99 +42,99 @@ typedef struct fc3d_clawpack46_vtable fc3d_clawpack46_vtable_t; /* --------------------------- Clawpack solver functions ------------------------------ */ /* Virtualize clawpack-specific wrapper functions */ -typedef void (*clawpack46_src3_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, - int blockno, - int patchno, - double t, - double dt); +typedef void (*fc3d_clawpack46_src3_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, + int blockno, + int patchno, + double t, + double dt); -typedef void (*clawpack46_b4step3_t)(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, - int this_block_idx, - int this_patch_idx, - double t, - double dt); +typedef void (*fc3d_clawpack46_b4step3_t)(struct fclaw_global* glob, + struct fclaw_patch *this_patch, + int this_block_idx, + int this_patch_idx, + double t, + double dt); /* ---------------------- Clawpack solver functions (Fortran) ------------------------- */ -typedef void (*clawpack46_fort_setprob_t)(void); - -typedef void (*clawpack46_fort_bc3_t)(const int* meqn, const int* mbc, - const int* mx, const int* my, const int* mz, - const double* xlower, const double* ylower, - const double* zlower, - const double* dx, const double* dy, - const double* dz, - const double q[], const int* maux, - const double aux[], const double* t, - const double* dt, const int mthbc[]); - -typedef void (*clawpack46_fort_qinit_t)(const int* meqn,const int* mbc, - const int* mx, const int* my, const int* mz, - const double* xlower, const double* ylower, - const double* zlower, - const double* dx, const double* dy, - const double *dz, - double q[], const int* maux, double aux[]); - -typedef void (*clawpack46_fort_setaux_t)(const int* mbc, - const int* mx, const int* my, const int *mz, - const double* xlower, const double* ylower, - const double *zlower, - const double* dx, const double* dy, - const double* dz, - const int* maux, double aux[]); - -typedef void (*clawpack46_fort_b4step3_t)(const int* mbc, - const int* mx, const int* my, const int* mz, - const int* meqn, - double q[], const double* xlower, - const double* ylower, const double *zlower, - const double* dx, const double* dy, - const double* dz, - const double* t, const double* dt, - const int* maux, double aux[]); - -typedef void (*clawpack46_fort_src3_t)(const int* meqn, - const int* mbc, const int* mx,const int* my, - const int* mz, - const double* xlower, const double* ylower, - const double* zlower, - const double* dx, const double* dy, const - double *dz, double q[], - const int* maux, double aux[], const double* t, - const double* dt); - -typedef void (*clawpack46_fort_rpn3_t)(const int* ixyz,const int* maxm, - const int* meqn, const int* mwaves, - const int* maux, const int* mbc,const int* mx, - double ql[], double qr[], - double auxl[], double auxr[], double wave[], - double s[], double amdq[], double apdq[]); - - -typedef void (*clawpack46_fort_rpt3_t)(const int* ixyz, const int* icoor, - const int* imp, - const int *maxm, const int* meqn, - const int* mwaves, const int *maux, - const int* mbc, const int* mx, - double ql[], double qr[], - double aux1[], double aux2[], double aux3[], - double dsdq[], double bmasdq[], double bpasdq[]); - -typedef void (*clawpack46_fort_rptt3_t)(const int* ixyz, const int* icoor, - const int* imp, const int* impt, - const int* maxm, const int* meqn, - const int* mwaves, const int* maux, - const int* mbc,const int* mx, - double ql[], double qr[], - double aux1[], double aux2[], double aux3[], - double bsasdq[], - double cmbsasdq[], double cpbsasdq[]); - - -typedef void (*clawpack46_fort_flux3_t)(const int* ixyz,const int* maxm, const int* meqn, +typedef void (*fc3d_clawpack46_fort_setprob_t)(void); + +typedef void (*fc3d_clawpack46_fort_bc3_t)(const int* meqn, const int* mbc, + const int* mx, const int* my, const int* mz, + const double* xlower, const double* ylower, + const double* zlower, + const double* dx, const double* dy, + const double* dz, + const double q[], const int* maux, + const double aux[], const double* t, + const double* dt, const int mthbc[]); + +typedef void (*fc3d_clawpack46_fort_qinit_t)(const int* meqn,const int* mbc, + const int* mx, const int* my, const int* mz, + const double* xlower, const double* ylower, + const double* zlower, + const double* dx, const double* dy, + const double *dz, + double q[], const int* maux, double aux[]); + +typedef void (*fc3d_clawpack46_fort_setaux_t)(const int* mbc, + const int* mx, const int* my, const int *mz, + const double* xlower, const double* ylower, + const double *zlower, + const double* dx, const double* dy, + const double* dz, + const int* maux, double aux[]); + +typedef void (*fc3d_clawpack46_fort_b4step3_t)(const int* mbc, + const int* mx, const int* my, const int* mz, + const int* meqn, + double q[], const double* xlower, + const double* ylower, const double *zlower, + const double* dx, const double* dy, + const double* dz, + const double* t, const double* dt, + const int* maux, double aux[]); + +typedef void (*fc3d_clawpack46_fort_src3_t)(const int* meqn, + const int* mbc, const int* mx,const int* my, + const int* mz, + const double* xlower, const double* ylower, + const double* zlower, + const double* dx, const double* dy, const + double *dz, double q[], + const int* maux, double aux[], const double* t, + const double* dt); + +typedef void (*fc3d_clawpack46_fort_rpn3_t)(const int* ixyz,const int* maxm, + const int* meqn, const int* mwaves, + const int* maux, const int* mbc,const int* mx, + double ql[], double qr[], + double auxl[], double auxr[], double wave[], + double s[], double amdq[], double apdq[]); + + +typedef void (*fc3d_clawpack46_fort_rpt3_t)(const int* ixyz, const int* icoor, + const int* imp, + const int *maxm, const int* meqn, + const int* mwaves, const int *maux, + const int* mbc, const int* mx, + double ql[], double qr[], + double aux1[], double aux2[], double aux3[], + double dsdq[], double bmasdq[], double bpasdq[]); + +typedef void (*fc3d_clawpack46_fort_rptt3_t)(const int* ixyz, const int* icoor, + const int* imp, const int* impt, + const int* maxm, const int* meqn, + const int* mwaves, const int* maux, + const int* mbc,const int* mx, + double ql[], double qr[], + double aux1[], double aux2[], double aux3[], + double bsasdq[], + double cmbsasdq[], double cpbsasdq[]); + + +typedef void (*fc3d_clawpack46_fort_flux3_t)(const int* ixyz,const int* maxm, const int* meqn, const int* maux, const int* mbc,const int* mx, double q1d[], double dtdx1d[], double dtdy[], double dtdz[], double aux1[], double aux2[], double aux3[], @@ -149,13 +149,13 @@ typedef void (*clawpack46_fort_flux3_t)(const int* ixyz,const int* maxm, const i double cmcqxxm[], double cmcqxxp[], double cpcqxxm[], double cpcqxxp[], double bmcmamdq[], double bmcmapdq[], double bpcmamdq[], double bpcmapdq[], double bmcpamdq[], double bmcpapdq[], double bpcpamdq[], double bpcpapdq[], - clawpack46_fort_rpn3_t rpn3, - clawpack46_fort_rpt3_t rpt3, - clawpack46_fort_rptt3_t rptt3, + fc3d_clawpack46_fort_rpn3_t rpn3, + fc3d_clawpack46_fort_rpt3_t rpt3, + fc3d_clawpack46_fort_rptt3_t rptt3, const int* mwaves, const int* mcapa, int method[], int mthlim[]); -typedef void (*clawpack46_fort_rpn3_cons_t)(const int* meqn, const int* maux, +typedef void (*fc3d_clawpack46_fort_rpn3_cons_t)(const int* meqn, const int* maux, const int *idir, const int* iface, double q[], double auxvec_center[], double auxvec_edge[], double fq[]); @@ -167,23 +167,23 @@ struct fc3d_clawpack46_vtable { /* C wrappers */ - clawpack46_b4step3_t b4step3; - clawpack46_src3_t src3; + fc3d_clawpack46_b4step3_t b4step3; + fc3d_clawpack46_src3_t src3; /* Fortran routines */ - clawpack46_fort_setprob_t fort_setprob; - clawpack46_fort_bc3_t fort_bc3; - clawpack46_fort_qinit_t fort_qinit; - clawpack46_fort_setaux_t fort_setaux; - clawpack46_fort_b4step3_t fort_b4step3; - clawpack46_fort_src3_t fort_src3; + fc3d_clawpack46_fort_setprob_t fort_setprob; + fc3d_clawpack46_fort_bc3_t fort_bc3; + fc3d_clawpack46_fort_qinit_t fort_qinit; + fc3d_clawpack46_fort_setaux_t fort_setaux; + fc3d_clawpack46_fort_b4step3_t fort_b4step3; + fc3d_clawpack46_fort_src3_t fort_src3; - clawpack46_fort_rpn3_t fort_rpn3; - clawpack46_fort_rpt3_t fort_rpt3; - clawpack46_fort_rptt3_t fort_rptt3; - clawpack46_fort_rpn3_cons_t fort_rpn2_cons; + fc3d_clawpack46_fort_rpn3_t fort_rpn3; + fc3d_clawpack46_fort_rpt3_t fort_rpt3; + fc3d_clawpack46_fort_rptt3_t fort_rptt3; + fc3d_clawpack46_fort_rpn3_cons_t fort_rpn2_cons; - clawpack46_fort_flux3_t flux3; + fc3d_clawpack46_fort_flux3_t flux3; int is_set; @@ -199,7 +199,7 @@ struct fc3d_clawpack46_vtable * * @param glob the global context */ -void fc3d_clawpack46_solver_initialize(struct fclaw2d_global* glob); +void fc3d_clawpack46_solver_initialize(struct fclaw_global* glob); /** * @brief Get the clawpack46 vtable @@ -207,38 +207,38 @@ void fc3d_clawpack46_solver_initialize(struct fclaw2d_global* glob); * @param glob the global context * @return fc3d_clawpack46_vtable_t* the vtable */ -fc3d_clawpack46_vtable_t* fc3d_clawpack46_vt(struct fclaw2d_global* glob); +fc3d_clawpack46_vtable_t* fc3d_clawpack46_vt(struct fclaw_global* glob); /* ----------------------------- User access to solver functions ---------------------- */ -void fc3d_clawpack46_setprob(struct fclaw2d_global* glob); +void fc3d_clawpack46_setprob(struct fclaw_global* glob); -void fc3d_clawpack46_setaux(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc3d_clawpack46_setaux(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc3d_clawpack46_set_capacity(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc3d_clawpack46_set_capacity(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc3d_clawpack46_qinit(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc3d_clawpack46_qinit(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx); -void fc3d_clawpack46_b4step3(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc3d_clawpack46_b4step3(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); -void fc3d_clawpack46_bc3(struct fclaw2d_global *glob, - struct fclaw2d_patch *this_patch, +void fc3d_clawpack46_bc3(struct fclaw_global *glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -246,8 +246,8 @@ void fc3d_clawpack46_bc3(struct fclaw2d_global *glob, int intersects_bc[], int time_interp); -void fc3d_clawpack46_src2(struct fclaw2d_global* glob, - struct fclaw2d_patch *this_patch, +void fc3d_clawpack46_src2(struct fclaw_global* glob, + struct fclaw_patch *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/solvers/fc3d_clawpack46/fc3d_clawpack46.h.TEST.cpp b/src/solvers/fc3d_clawpack46/fc3d_clawpack46.h.TEST.cpp index 62ca98566..afd2e2741 100644 --- a/src/solvers/fc3d_clawpack46/fc3d_clawpack46.h.TEST.cpp +++ b/src/solvers/fc3d_clawpack46/fc3d_clawpack46.h.TEST.cpp @@ -23,91 +23,123 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include -#include -#include +#include +#include +#include #include TEST_CASE("fc3d_clawpack46_solver_initialize stores two seperate vtables in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* opts1 = fclaw_clawpatch_options_new(3); + fclaw_clawpatch_options_t* opts2 = fclaw_clawpatch_options_new(3); /* create some empty options structures */ - fclaw3dx_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob1, opts1); fc3d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1)); - fclaw3dx_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob2, opts2); fc3d_clawpack46_options_store(glob2, FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc3d_clawpack46_solver_initialize(glob1); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc3d_clawpack46_solver_initialize(glob2); CHECK_NE(fc3d_clawpack46_vt(glob1), fc3d_clawpack46_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_clawpatch_options_destroy(opts1); + fclaw_clawpatch_options_destroy(opts2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc3d_clawpack46_solver_initialize sets is_set flag") { - fclaw2d_global_t* glob = fclaw2d_global_new(); + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_t* glob = fclaw_global_new(); + fclaw_global_store_domain(glob, domain); + + fclaw_clawpatch_options_t* opts = fclaw_clawpatch_options_new(3); /* create some empty options structures */ - fclaw3dx_clawpatch_options_store(glob, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob, opts); fc3d_clawpack46_options_store(glob, FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1)); - fclaw2d_vtables_initialize(glob); + fclaw_vtables_initialize(glob); fc3d_clawpack46_solver_initialize(glob); CHECK_UNARY(fc3d_clawpack46_vt(glob)->is_set); - fclaw2d_global_destroy(glob); + fclaw_clawpatch_options_destroy(opts); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc3d_clawpack46_vt fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); CHECK_SC_ABORTED(fc3d_clawpack46_vt(glob1)); CHECK_SC_ABORTED(fc3d_clawpack46_vt(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc3d_clawpack46_vtable_initialize fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); + + fclaw_domain_t* domain = fclaw_domain_new_unitsquare(sc_MPI_COMM_WORLD, 0); + fclaw_global_store_domain(glob1, domain); + fclaw_global_store_domain(glob2, domain); + + fclaw_clawpatch_options_t* opts1 = fclaw_clawpatch_options_new(3); + fclaw_clawpatch_options_t* opts2 = fclaw_clawpatch_options_new(3); /* create some empty options structures */ - fclaw3dx_clawpatch_options_store(glob1, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob1, opts1); fc3d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1)); - fclaw3dx_clawpatch_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw3dx_clawpatch_options_t,1)); + fclaw_clawpatch_options_store(glob2, opts2); fc3d_clawpack46_options_store(glob2, FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1)); - fclaw2d_vtables_initialize(glob1); + fclaw_vtables_initialize(glob1); fc3d_clawpack46_solver_initialize(glob1); CHECK_SC_ABORTED(fc3d_clawpack46_solver_initialize(glob1)); - fclaw2d_vtables_initialize(glob2); + fclaw_vtables_initialize(glob2); fc3d_clawpack46_solver_initialize(glob2); CHECK_SC_ABORTED(fc3d_clawpack46_solver_initialize(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_clawpatch_options_destroy(opts1); + fclaw_clawpatch_options_destroy(opts2); + fclaw_domain_destroy(domain); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc3d_clawpack46/fc3d_clawpack46_fort.h b/src/solvers/fc3d_clawpack46/fc3d_clawpack46_fort.h index d6b0e3a27..d452623a1 100644 --- a/src/solvers/fc3d_clawpack46/fc3d_clawpack46_fort.h +++ b/src/solvers/fc3d_clawpack46/fc3d_clawpack46_fort.h @@ -201,9 +201,9 @@ void CLAWPACK46_STEP3_WRAP(const int* maxm, const int* meqn, const int* maux, double fp[], double fm[], double gp[], double gm[], double hp[], double hm[], - clawpack46_fort_rpn3_t rpn3, - clawpack46_fort_rpt3_t rpt3, - clawpack46_fort_rptt3_t rptt3, + fc3d_clawpack46_fort_rpn3_t rpn3, + fc3d_clawpack46_fort_rpt3_t rpt3, + fc3d_clawpack46_fort_rptt3_t rptt3, const int* use_fwaves, int block_corner_count[], int* ierror); diff --git a/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.c b/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.c index 6d81b19a3..98f1f24fd 100644 --- a/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.c +++ b/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.c @@ -25,8 +25,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "fc3d_clawpack46_options.h" -#include -#include +#include +#include #include static void* @@ -199,12 +199,12 @@ fc3d_clawpack46_options_t* fc3d_clawpack46_options_register (fclaw_app_t * app, return clawopt; } -fc3d_clawpack46_options_t* fc3d_clawpack46_get_options(fclaw2d_global_t *glob) +fc3d_clawpack46_options_t* fc3d_clawpack46_get_options(fclaw_global_t *glob) { - return (fc3d_clawpack46_options_t*) fclaw2d_global_get_options(glob,"fc3d_clawpack46"); + return (fc3d_clawpack46_options_t*) fclaw_global_get_options(glob,"fc3d_clawpack46"); } -void fc3d_clawpack46_options_store (fclaw2d_global_t* glob, fc3d_clawpack46_options_t* clawopt) +void fc3d_clawpack46_options_store (fclaw_global_t* glob, fc3d_clawpack46_options_t* clawopt) { - fclaw2d_global_options_store(glob, "fc3d_clawpack46", clawopt); + fclaw_global_options_store(glob, "fc3d_clawpack46", clawopt); } diff --git a/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.h b/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.h index eafd07d0d..8151315e2 100644 --- a/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.h +++ b/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.h @@ -36,7 +36,7 @@ extern "C" #endif #endif -struct fclaw2d_global; +struct fclaw_global; typedef struct fc3d_clawpack46_options fc3d_clawpack46_options_t; struct fc3d_clawpack46_options @@ -86,12 +86,12 @@ fc3d_clawpack46_options_t* fc3d_clawpack46_options_register (fclaw_app_t * app, void fc3d_clawpack46_package_register(fclaw_app_t* app, fc3d_clawpack46_options_t* clawopt); -fc3d_clawpack46_options_t* fc3d_clawpack46_get_options(struct fclaw2d_global *glob); +fc3d_clawpack46_options_t* fc3d_clawpack46_get_options(struct fclaw_global *glob); -void fc3d_clawpack46_options_store (struct fclaw2d_global* glob, +void fc3d_clawpack46_options_store (struct fclaw_global* glob, fc3d_clawpack46_options_t* clawopt); -void fc3d_clawpack46_output(struct fclaw2d_global *glob, int iframe); +void fc3d_clawpack46_output(struct fclaw_global *glob, int iframe); #ifdef __cplusplus diff --git a/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.h.TEST.cpp b/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.h.TEST.cpp index 05fbffb66..2490f3f7f 100644 --- a/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.h.TEST.cpp +++ b/src/solvers/fc3d_clawpack46/fc3d_clawpack46_options.h.TEST.cpp @@ -23,50 +23,50 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include TEST_CASE("fc3d_clawpack46_options can store options in two seperate globs") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc3d_clawpack46_options_t* opts1 = FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1); fc3d_clawpack46_options_t* opts2 = FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1); fc3d_clawpack46_options_store(glob1, opts1); /* glob1 has one package glob2 has two */ - fclaw2d_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); + fclaw_options_store(glob2, FCLAW_ALLOC_ZERO(fclaw_options_t,1)); fc3d_clawpack46_options_store(glob2, opts2); CHECK_EQ(fc3d_clawpack46_get_options(glob1), opts1); CHECK_EQ(fc3d_clawpack46_get_options(glob2), opts2); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #ifdef FCLAW_ENABLE_DEBUG TEST_CASE("fc3d_clawpack46_get_options fails if not intialized") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); CHECK_SC_ABORTED(fc3d_clawpack46_get_options(glob1)); CHECK_SC_ABORTED(fc3d_clawpack46_get_options(glob2)); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } TEST_CASE("fc3d_clawpack46_options_store fails if called twice on a glob") { - fclaw2d_global_t* glob1 = fclaw2d_global_new(); - fclaw2d_global_t* glob2 = fclaw2d_global_new(); + fclaw_global_t* glob1 = fclaw_global_new(); + fclaw_global_t* glob2 = fclaw_global_new(); fc3d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1)); CHECK_SC_ABORTED(fc3d_clawpack46_options_store(glob1, FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1))); @@ -74,8 +74,8 @@ TEST_CASE("fc3d_clawpack46_options_store fails if called twice on a glob") fc3d_clawpack46_options_store(glob2, FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1)); CHECK_SC_ABORTED(fc3d_clawpack46_options_store(glob2, FCLAW_ALLOC_ZERO(fc3d_clawpack46_options_t,1))); - fclaw2d_global_destroy(glob1); - fclaw2d_global_destroy(glob2); + fclaw_global_destroy(glob1); + fclaw_global_destroy(glob2); } #endif \ No newline at end of file diff --git a/src/solvers/fc3d_clawpack5/CMakeLists.txt b/src/solvers/fc3d_clawpack5/CMakeLists.txt index 7f9c6561a..5d2ebea1d 100644 --- a/src/solvers/fc3d_clawpack5/CMakeLists.txt +++ b/src/solvers/fc3d_clawpack5/CMakeLists.txt @@ -34,14 +34,11 @@ install(FILES fc3d_clawpack5.h clawpack5_user_fort.h fc3d_clawpack5_options.h - DESTINATION include + TYPE INCLUDE ) install(TARGETS clawpack5_3d - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) + EXPORT ${PROJECT_NAME}-targets) # imported target, for use from FetchContent add_library(FORESTCLAW::CLAWPACK5_3D INTERFACE IMPORTED GLOBAL) diff --git a/src/solvers/fc3d_clawpack5/clawpack5_user_fort.h b/src/solvers/fc3d_clawpack5/clawpack5_user_fort.h index 3f31afdbb..e2dd618fb 100644 --- a/src/solvers/fc3d_clawpack5/clawpack5_user_fort.h +++ b/src/solvers/fc3d_clawpack5/clawpack5_user_fort.h @@ -26,7 +26,7 @@ #ifndef CLAWPACK5_USER_FORT_H #define CLAWPACK5_USER_FORT_H -#include +#include #include #include "fc3d_clawpack5_options.h" diff --git a/src/solvers/fc3d_clawpack5/fc3d_clawpack5.cpp b/src/solvers/fc3d_clawpack5/fc3d_clawpack5.cpp index 0e1bd1a12..e4df24c97 100644 --- a/src/solvers/fc3d_clawpack5/fc3d_clawpack5.cpp +++ b/src/solvers/fc3d_clawpack5/fc3d_clawpack5.cpp @@ -23,11 +23,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include -#include +#include #include -#include +#include #include "fc3d_clawpack5.h" #include "fc3d_clawpack5_options.h" @@ -56,8 +56,8 @@ void fc3d_clawpack5_set_vtable(const fc3d_clawpack5_vtable_t user_vt) /* This is called from the user application. */ void fc3d_clawpack5_set_vtable_defaults() { - fclaw2d_vtable_t* fclaw_vt = fclaw2d_vt(glob); - fclaw2d_patch_vtable_t* patch_vt = fclaw2d_patch_vt(glob); + fclaw_vtable_t* fclaw_vt = fclaw_vt(glob); + fclaw_patch_vtable_t* patch_vt = fclaw_patch_vt(glob); fclaw_clawpatch3_vtable_t* clawpatch_vt = fclaw_clawpatch3_vt(); fc3d_clawpack5_vtable_t* claw5_vt = fc3d_clawpack5_vt(); @@ -123,9 +123,9 @@ void fc3d_clawpack5_set_vtable_defaults() #endif } -fc3d_clawpack5_options_t* fc3d_clawpack5_get_options(fclaw2d_global_t *glob) +fc3d_clawpack5_options_t* fc3d_clawpack5_get_options(fclaw_global_t *glob) { - return (fc3d_clawpack5_options_t*) fclaw2d_global_get_options(glob, + return (fc3d_clawpack5_options_t*) fclaw_global_get_options(glob, "fc3d_clawpack5"); } @@ -152,19 +152,19 @@ void fc3d_clawpack5_register (fclaw_app_t* app, const char *configfile, fclaw2d_ } #endif -void fc3d_clawpack5_set_options (fclaw2d_global_t* glob, fc3d_clawpack5_options_t* clawopt) +void fc3d_clawpack5_set_options (fclaw_global_t* glob, fc3d_clawpack5_options_t* clawopt) { - fclaw2d_global_options_store(glob, "fc3d_clawpack5", clawopt); + fclaw_global_options_store(glob, "fc3d_clawpack5", clawopt); } -void fc3d_clawpack5_aux_data(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc3d_clawpack5_aux_data(fclaw_global_t *glob, + fclaw_patch_t *this_patch, double **aux, int* maux) { - fclaw2d_clawpatch_aux_data(glob, this_patch, aux, maux); + fclaw_clawpatch_aux_data(glob, this_patch, aux, maux); } -void fc3d_clawpack5_setprob(fclaw2d_global_t *glob) +void fc3d_clawpack5_setprob(fclaw_global_t *glob) { if (classic_vt.setprob != NULL) { @@ -173,8 +173,8 @@ void fc3d_clawpack5_setprob(fclaw2d_global_t *glob) } /* This should only be called when a new fclaw2d_clawpatch_t is created. */ -void fc3d_clawpack5_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc3d_clawpack5_setaux(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -188,7 +188,7 @@ void fc3d_clawpack5_setaux(fclaw2d_global_t *glob, return; } - if (fclaw2d_patch_is_ghost(this_patch)) + if (fclaw_patch_is_ghost(this_patch)) { /* This is going to be removed at some point */ return; @@ -211,8 +211,8 @@ void fc3d_clawpack5_setaux(fclaw2d_global_t *glob, } /* This should only be called when a new fclaw2d_clawpatch_t is created. */ -void fc3d_clawpack5_set_capacity(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc3d_clawpack5_set_capacity(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -224,12 +224,12 @@ void fc3d_clawpack5_set_capacity(fclaw2d_global_t *glob, clawopt = fc3d_clawpack5_get_options(glob); mcapa = clawopt->mcapa; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - area = fclaw2d_clawpatch_get_area(glob,this_patch); + area = fclaw_clawpatch_get_2d_area(glob,this_patch); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); FCLAW_ASSERT(maux >= mcapa && mcapa > 0); CLAWPACK5_SET_CAPACITY(&mx,&my,&mbc,&dx,&dy,area,&mcapa, @@ -237,8 +237,8 @@ void fc3d_clawpack5_set_capacity(fclaw2d_global_t *glob, } -void fc3d_clawpack5_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc3d_clawpack5_qinit(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx) { @@ -260,8 +260,8 @@ void fc3d_clawpack5_qinit(fclaw2d_global_t *glob, CLAWPACK5_UNSET_BLOCK(); } -void fc3d_clawpack5_b4step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc3d_clawpack5_b4step2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, double dt) @@ -273,11 +273,11 @@ void fc3d_clawpack5_b4step2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); CLAWPACK5_SET_BLOCK(&this_block_idx); classic_vt.b4step2(&mbc,&mx,&my,&meqn,q,&xlower,&ylower, @@ -285,8 +285,8 @@ void fc3d_clawpack5_b4step2(fclaw2d_global_t *glob, CLAWPACK5_UNSET_BLOCK(); } -void fc3d_clawpack5_src2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc3d_clawpack5_src2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -298,11 +298,11 @@ void fc3d_clawpack5_src2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&q,&meqn); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_soln_data(glob,this_patch,&q,&meqn); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); CLAWPACK5_SET_BLOCK(&this_block_idx); classic_vt.src2(&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -313,8 +313,8 @@ void fc3d_clawpack5_src2(fclaw2d_global_t *glob, /* Use this to return only the right hand side of the clawpack algorithm */ -double fc3d_clawpack5_step2_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double fc3d_clawpack5_step2_rhs(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -328,8 +328,8 @@ double fc3d_clawpack5_step2_rhs(fclaw2d_global_t *glob, } -void fc3d_clawpack5_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc3d_clawpack5_bc2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -345,10 +345,10 @@ void fc3d_clawpack5_bc2(fclaw2d_global_t *glob, double xlower,ylower,dx,dy; double *aux,*q; - fclaw2d_clawpatch_grid_data(glob,this_patch, &mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch, &mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); int *block_mthbc = clawopt->mthbc; @@ -372,7 +372,7 @@ void fc3d_clawpack5_bc2(fclaw2d_global_t *glob, In this case, this boundary condition won't be used to update anything */ - fclaw2d_clawpatch_timesync_data(glob,this_patch,time_interp,&q,&meqn); + fclaw_clawpatch_timesync_data(glob,this_patch,time_interp,&q,&meqn); CLAWPACK5_SET_BLOCK(&this_block_idx); classic_vt.bc2(&meqn,&mbc,&mx,&my,&xlower,&ylower, @@ -382,8 +382,8 @@ void fc3d_clawpack5_bc2(fclaw2d_global_t *glob, /* This is called from the single_step callback. and is of type 'flaw_single_step_t' */ -double fc3d_clawpack5_step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double fc3d_clawpack5_step2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -404,14 +404,14 @@ double fc3d_clawpack5_step2(fclaw2d_global_t *glob, level = this_patch->level; - fclaw2d_clawpatch_aux_data(glob,this_patch,&aux,&maux); + fclaw_clawpatch_aux_data(glob,this_patch,&aux,&maux); - fclaw2d_clawpatch_save_current_step(glob, this_patch); + fclaw_clawpatch_save_current_step(glob, this_patch); - fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, + fclaw_clawpatch_2d_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); - fclaw2d_clawpatch_soln_data(glob,this_patch,&qold,&meqn); + fclaw_clawpatch_soln_data(glob,this_patch,&qold,&meqn); int mwaves = clawpack_options->mwaves; @@ -433,7 +433,7 @@ double fc3d_clawpack5_step2(fclaw2d_global_t *glob, //fc3d_clawpack5_flux2_t flux2 = clawpack_options->use_fwaves ? // CLAWPACK5_FLUX2FW : CLAWPACK5_FLUX2; fc3d_clawpack5_flux2_t flux2 = CLAWPACK5_FLUX2; - int* block_corner_count = fclaw2d_patch_block_corner_count(glob,this_patch); + int* block_corner_count = fclaw_patch_block_corner_count(glob,this_patch); CLAWPACK5_STEP2_WRAP(&maxm, &meqn, &maux, &mbc, clawpack_options->method, clawpack_options->mthlim, &clawpack_options->mcapa, &mwaves,&mx, &my, qold, aux, &dx, &dy, &dt, &cflgrid, @@ -462,8 +462,8 @@ double fc3d_clawpack5_step2(fclaw2d_global_t *glob, return cflgrid; } -double fc3d_clawpack5_update(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double fc3d_clawpack5_update(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -492,15 +492,15 @@ double fc3d_clawpack5_update(fclaw2d_global_t *glob, return maxcfl; } -void fc3d_clawpack5_output_header_ascii(fclaw2d_global_t* glob, +void fc3d_clawpack5_output_header_ascii(fclaw_global_t* glob, int iframe) { - const fclaw2d_clawpatch_options_t *clawpatch_opt; + const fclaw_clawpatch_options_t *clawpatch_opt; int meqn,maux,ngrids; double time; - clawpatch_opt = fclaw2d_clawpatch_get_options(glob); + clawpatch_opt = fclaw_clawpatch_get_options(glob); time = glob->curr_time; ngrids = fclaw2d_domain_get_num_patches(glob->domain); diff --git a/src/solvers/fc3d_clawpack5/fc3d_clawpack5.h b/src/solvers/fc3d_clawpack5/fc3d_clawpack5.h index 9289e8811..3faa22f36 100644 --- a/src/solvers/fc3d_clawpack5/fc3d_clawpack5.h +++ b/src/solvers/fc3d_clawpack5/fc3d_clawpack5.h @@ -27,9 +27,9 @@ #define FC3D_CLAWPACK5_H #include -#include +#include #include -#include +#include #include "fc3d_clawpack5_options.h" @@ -387,56 +387,56 @@ void fc3d_clawpack5_register_vtable (fclaw_package_container_t * /* ------------------------------------------------------------------------- New routines ------------------------------------------------------------------------- */ -void fc3d_clawpack5_aux_data(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +void fc3d_clawpack5_aux_data(fclaw_global_t *glob, + fclaw_patch_t *this_patch, double **aux, int* maux); // void fc3d_clawpack5_register (fclaw_app_t* app, const char *configfile, fclaw2d_global_t* glob); -void fc3d_clawpack5_set_options (fclaw2d_global_t* glob, fc3d_clawpack5_options_t* clawopt); +void fc3d_clawpack5_set_options (fclaw_global_t* glob, fc3d_clawpack5_options_t* clawopt); void fc3d_clawpack5_package_register(fclaw_app_t* app, fc3d_clawpack5_options_t* clawopt); -void fc3d_clawpack5_output_header_ascii(fclaw2d_global_t* glob, +void fc3d_clawpack5_output_header_ascii(fclaw_global_t* glob, int iframe); -fc3d_clawpack5_options_t* fc3d_clawpack5_get_options(fclaw2d_global_t *glob); +fc3d_clawpack5_options_t* fc3d_clawpack5_get_options(fclaw_global_t *glob); /* ------------------------------------------------------------------------- Routines that won't change ------------------------------------------------------------------------- */ void - fc3d_clawpack5_setprob(fclaw2d_global_t* glob); + fc3d_clawpack5_setprob(fclaw_global_t* glob); void - fc3d_clawpack5_setaux(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, + fc3d_clawpack5_setaux(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx); void - fc3d_clawpack5_set_capacity(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, + fc3d_clawpack5_set_capacity(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx); void - fc3d_clawpack5_qinit(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, + fc3d_clawpack5_qinit(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx); void - fc3d_clawpack5_b4step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, + fc3d_clawpack5_b4step2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, double dt); void - fc3d_clawpack5_bc2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, + fc3d_clawpack5_bc2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -445,8 +445,8 @@ void fclaw_bool time_interp); void - fc3d_clawpack5_src2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, + fc3d_clawpack5_src2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -455,8 +455,8 @@ void /* A single step method that advances the solution a single step on a single grid using a time step dt determined by the subcycle manager */ -double fc3d_clawpack5_step2(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double fc3d_clawpack5_step2(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, @@ -464,15 +464,15 @@ double fc3d_clawpack5_step2(fclaw2d_global_t *glob, /* Use this ro return only the right hand side of the clawpack algorithm */ double - fc3d_clawpack5_step2_rhs(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, + fc3d_clawpack5_step2_rhs(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, double *rhs); -double fc3d_clawpack5_update(fclaw2d_global_t *glob, - fclaw2d_patch_t *this_patch, +double fc3d_clawpack5_update(fclaw_global_t *glob, + fclaw_patch_t *this_patch, int this_block_idx, int this_patch_idx, double t, diff --git a/src/solvers/fc3d_clawpack5/fclaw2d_source/fc3d_clawpack5_diagnostics.f b/src/solvers/fc3d_clawpack5/fclaw2d_source/fc3d_clawpack5_diagnostics.f index 83ab4a3d9..219a72fb5 100644 --- a/src/solvers/fc3d_clawpack5/fclaw2d_source/fc3d_clawpack5_diagnostics.f +++ b/src/solvers/fc3d_clawpack5/fclaw2d_source/fc3d_clawpack5_diagnostics.f @@ -14,13 +14,13 @@ subroutine fc3d_clawpack5_fort_conservation_check(mx,my,mbc,meqn, integer i,j,m integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = get_context() dxdy = dx*dy do m = 1,meqn - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do j = 1,my do i = 1,mx sum(m) = sum(m) + q(1,i,j)*area(i,j) @@ -52,11 +52,11 @@ subroutine fc3d_clawpack5_fort_conservation_check(mx,my,mbc,meqn, integer i,j,m integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = get_context() - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then sum = 0 do j = 1,my do i = 1,mx @@ -85,14 +85,14 @@ subroutine fc3d_clawpack5_fort_compute_error_norm(mx,my,mbc,meqn, integer i,j,m integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = get_context() c # error_norm(:) comes in with values; do not initialize it here! dxdy = dx*dy do m = 1,meqn - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do j = 1,my do i = 1,mx eij = abs(error(m,i,j)) diff --git a/src/user_fortran_source2d/diagnostics.f b/src/user_fortran_source2d/diagnostics.f index 2b25e671d..0dcf9e280 100644 --- a/src/user_fortran_source2d/diagnostics.f +++ b/src/user_fortran_source2d/diagnostics.f @@ -14,13 +14,13 @@ subroutine user_fort_conservation_check(mx,my,mbc,meqn, integer i,j,m integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = get_context() dxdy = dx*dy do m = 1,meqn - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do j = 1,my do i = 1,mx sum(m) = sum(m) + q(i,j,m)*area(i,j) @@ -51,11 +51,11 @@ subroutine user_fort_conservation_check(mx,my,mbc,meqn, integer i,j,m integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = get_context() - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then sum = 0 do j = 1,my do i = 1,mx @@ -84,14 +84,14 @@ subroutine user_fort_compute_error_norm(mx,my,mbc, integer i,j,m integer*8 cont, get_context - logical fclaw2d_map_is_used + logical fclaw_map_is_used cont = get_context() c # error_norm(:) comes in with values; do not initialize it here! dxdy = dx*dy do m = 1,meqn - if (fclaw2d_map_is_used(cont)) then + if (fclaw_map_is_used(cont)) then do j = 1,my do i = 1,mx eij = abs(error(i,j,m)) diff --git a/test/test.cpp b/test/test.cpp index 0c2674839..fe85e6018 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -6,12 +6,21 @@ #include #include +static bool output_vtk=false; + +bool test_output_vtk() +{ + return output_vtk; +} + +static bool has_aborted=true; static bool expect_abort=false; std::jmp_buf jump_buffer; void throw_exception() { + has_aborted = true; if(expect_abort) { expect_abort=false; @@ -37,6 +46,15 @@ std::jmp_buf& fclaw_test_get_jump_buffer() int main(int argc, char *argv[]) { bool listing = false; + //add vtk option to output vtk files + for (int i = 0; i < argc; i++) { + output_vtk = strcmp(argv[i], "--vtk") == 0; + if (output_vtk) + { + std::cout << "outputting vtk files" << std::endl; + break; + } + } for (int i = 0; i < argc; i++) { listing = strcmp(argv[i], "--list-test-cases") == 0; if (listing) diff --git a/test/test.hpp b/test/test.hpp index 7523d9a50..08160f70b 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -3,6 +3,8 @@ #include #include +bool test_output_vtk(); + void fclaw_test_expect_abort(); void fclaw_test_clear_expect_abort();