ForestClaw / forestclaw

Quadtree/octree adaptive PDE solver based based on p4est.
http://www.forestclaw.org
BSD 2-Clause "Simplified" License
58 stars 22 forks source link

Translation to 3D in source files #268

Open tim-griesbach opened 1 year ago

tim-griesbach commented 1 year ago

If I include fclaw2d_convenience.h in fclaw2d_global.h this results in errors of the form

 In file included from /home/runner/work/forestclaw/forestclaw/applications/build/ForestClaw-prefix/src/ForestClaw/src/fclaw2d_convenience.h:31,
                 from /home/runner/work/forestclaw/forestclaw/applications/build/ForestClaw-prefix/src/ForestClaw/src/fclaw2d_global.h:31,
                 from /home/runner/work/forestclaw/forestclaw/applications/build/ForestClaw-prefix/src/ForestClaw/src/fclaw2d_map.c:37,
                 from /home/runner/work/forestclaw/forestclaw/applications/build/ForestClaw-prefix/src/ForestClaw/src/fclaw3d_map.c:27:
/home/runner/work/forestclaw/forestclaw/applications/build/local/include/p4est_connectivity.h:36:2: error: #error "Including a p4est header with P4_TO_P8 defined"
   36 | #error "Including a p4est header with P4_TO_P8 defined"
      |  ^~~~~

because fclaw2d_convenience.h includes p4est headers and these check if a p4est 2D header and p4est_to_p8est.h are both included and throw an error if this is the case.

Up to my understanding, we encounter the error described above because the 3D code in fclaw3d_map.c is generated from the 2D code in fclaw2d_map.c by including it. However, fclaw2d_map.c differentiates including dimension-dependent headers only based on PATCH_DIM and REFINE_DIM, which are not necessarily defined. Therefore, 2D headers are included in the 3D code.

In fclaw2d_map.c we must consider three cases (2d, 3d, 3dx). Because of the possible 3dx case the macros REFINE_DIM and PATCH_DIM are used but these macros are only defined in Clawpatch. Since in fclaw2d_map.c PATCH_DIM is also used to detect the 2d case, an undefined PATCH_DIM leads to always entering the 2d case. This is the case because in fclaw2d_map.c PATCH_DIM (and also REFINE_DIM) is set to 2 if it is undefined.

tim-griesbach commented 1 year ago

I edited the issue to elaborate more on the role of 3dx in this issue.

tim-griesbach commented 1 year ago

I edited the issue again and now it only focusses on the 3D translation issue in fclaw3d_map.c that is related to differentiating between the three cases 2d, 3dx and 3d. The 3D translation issue related to fclaw3d_exchange is now fixed in the PR https://github.com/ForestClaw/forestclaw/pull/270.