Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
89a0ac5
Added ellipse marker patch
danieljvickers Dec 12, 2025
ef446f5
Added ellipse IB patch
danieljvickers Dec 12, 2025
2f9b1be
Added an ellipse immersed boundary patch
danieljvickers Dec 12, 2025
e3495d9
Pre processing builds and all IB marker and levelset values have been…
danieljvickers Jan 28, 2026
f23eaff
Merged with master
danieljvickers Jan 29, 2026
59c8dc2
intermediate commit
Jan 29, 2026
b7b8d2d
Merge branch 'airfoil-4d-fixes' into levelset-refactor
Jan 29, 2026
128562b
Missed one merge message
danieljvickers Jan 29, 2026
3e097d7
Merge branch 'levelset-refactor' of github.com:danieljvickers/MFC int…
danieljvickers Jan 29, 2026
285999f
This code fully works, except the IB markers are not getting written
danieljvickers Jan 29, 2026
455d16b
fixed MPI IO error, except for first time step
danieljvickers Jan 29, 2026
d5aa186
We now also write at time step 0
danieljvickers Jan 29, 2026
ed9edac
Removed some of the ib marker data from tests
danieljvickers Jan 30, 2026
4fa238a
More case file changes
danieljvickers Jan 30, 2026
97c54f3
Removed unneeded variable
danieljvickers Jan 30, 2026
0662d47
STLs run
danieljvickers Feb 2, 2026
75ddc11
Merge branch 'levelset-refactor' of github.com:danieljvickers/MFC int…
danieljvickers Feb 2, 2026
b2a821c
Update casedicts to pass in STL file location to simulation
danieljvickers Feb 2, 2026
6c45fc6
Intermitent commit swapping machines
danieljvickers Feb 2, 2026
2b84f06
Transferring state
danieljvickers Feb 3, 2026
e8fd89f
Resolved 2D STL files
danieljvickers Feb 3, 2026
fb9dbaf
Remove additional airfoil data from golden files
danieljvickers Feb 3, 2026
a9c6c5c
Make sure we have reasonable default values in simulation as well
danieljvickers Feb 3, 2026
31799e1
Removed Ib markers from golden
danieljvickers Feb 3, 2026
070e062
I only need that change for circles
danieljvickers Feb 3, 2026
8c4fa75
generated new golden files with master
danieljvickers Feb 3, 2026
12256ec
Merged in new golden files generated via the correct dimensions off o…
danieljvickers Feb 3, 2026
0497b85
intermittent commit'
danieljvickers Feb 4, 2026
2a0fb21
finished first pass of levelset module
danieljvickers Feb 4, 2026
d7bef7f
First pass of refactor finished. Time to try building
danieljvickers Feb 4, 2026
8427e56
STL model refactor
danieljvickers Feb 4, 2026
7980cb5
Compiles
danieljvickers Feb 4, 2026
1781f45
Tests pass, except for STLs, which give seg faults.
danieljvickers Feb 4, 2026
30dd642
STL models work
danieljvickers Feb 4, 2026
4d69e5a
GPU STLs
danieljvickers Feb 4, 2026
13cfbbd
Formatting and spelling
danieljvickers Feb 4, 2026
aafff97
Merge branch 'master' into levelset-refactor
danieljvickers Feb 4, 2026
cc67478
Added 3D models to pregeneration step
danieljvickers Feb 5, 2026
b56678e
For some reason model scale was commented out
danieljvickers Feb 5, 2026
dbef122
Merge branch 'master' into levelset-refactor
danieljvickers Feb 5, 2026
b7978a3
Made changes to pointer read for GPU routine and formatting
danieljvickers Feb 5, 2026
d8432f6
Merge branch 'levelset-refactor' of github.com:danieljvickers/MFC int…
danieljvickers Feb 5, 2026
e7e7d33
Resovled conflicts from master
danieljvickers Feb 5, 2026
b7b6284
Missed some cleanup variables for IB patches
danieljvickers Feb 5, 2026
05915fb
fixed build issues with phoenix. Had to disable IB marker STL GPU sup…
Feb 5, 2026
51bc07f
spelling
Feb 5, 2026
c304b37
We no longer need if guards to protect against redundant compute, bec…
Feb 5, 2026
6d7f39c
Fixed airfoil comparison
Feb 5, 2026
05c069e
For some reason NVHPC did not like the way I was writing normal vecto…
Feb 5, 2026
d363ed6
Stupid OpenMP making do good software practices
Feb 5, 2026
4e0553b
Formatting
Feb 5, 2026
0002855
Cleanup
Feb 5, 2026
dc65fc7
some comments on future STL implementation and added local coordinate…
Feb 5, 2026
668604e
Format and loca coordiantes for STLs
Feb 5, 2026
3eb260d
More stability changes over model import and rotation
Feb 5, 2026
5c9ff7e
We no longer need to check if we are inside an ellipse to compute a l…
Feb 5, 2026
1701344
Fixed STL test with rotation
danieljvickers Feb 5, 2026
7a9a435
Format
danieljvickers Feb 5, 2026
47c9ced
Need to make some values private
danieljvickers Feb 5, 2026
baca16e
Added a limiter to maximum number of ghost points generated to ensure…
danieljvickers Feb 5, 2026
20774c6
typo
danieljvickers Feb 5, 2026
3769f12
format
danieljvickers Feb 5, 2026
5b5f170
Fixing macros
danieljvickers Feb 5, 2026
0975fd3
Need to GPU allocate triangles for models as well
danieljvickers Feb 6, 2026
76ab0db
Finally got circle working on GPU
Feb 6, 2026
ccca21f
Reverted to match rest of ghost point reads
Feb 6, 2026
89412b6
clean up
Feb 6, 2026
c0c9ea3
All tests pass with openACC
Feb 6, 2026
99de417
format
danieljvickers Feb 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
625 changes: 0 additions & 625 deletions src/common/m_compute_levelset.fpp

This file was deleted.

12 changes: 12 additions & 0 deletions src/common/m_derived_types.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,18 @@ module m_derived_types
type :: t_model
integer :: ntrs ! Number of triangles
type(t_triangle), allocatable :: trs(:) ! Triangles

end type t_model

type :: t_model_array
type(t_model), allocatable :: model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The component model in t_model_array is declared as a scalar allocatable rather than an allocatable array, which prevents this type from correctly representing multiple models; any calling code that expects to store or iterate over several models in this container will either silently only store one model or malfunction when trying to index it. [logic error]

Severity Level: Major ⚠️
- ❌ STL model loading routines rely on arrays.
- ⚠️ Preprocessing multiple-model workflows misbehave.
- ⚠️ ic_patch_parameters model handling impacted during setup.
Suggested change
type(t_model), allocatable :: model
type(t_model), allocatable, dimension(:) :: model
Steps of Reproduction ✅
1. Open the type definition at src/common/m_derived_types.fpp lines 186-193 (type
t_model_array definition).

2. Create a small test or locate a caller that intends to hold multiple models. Example
test (new file src/tests/allocate_model_test.f90):

   - use m_derived_types

   - type(t_model_array) :: t

   - integer :: n

   - n = 2

   - allocate(t%model(n)) ! attempt to allocate an array of models

3. Compile the test with the project's Fortran compiler (e.g., gfortran or nvfortran). The
compiler will reject the allocation or indexing:

   - Expected failure: "Error: Cannot allocate an object with bounds; 'model' is a scalar
   allocatable" or "subscripted object 'model' is not an array".

4. Alternatively, try to reference t%model(1) in code that iterates models; this will
produce a compile-time error "subscripted object is not an array" (observable in build
logs). This reproduces the malfunction concretely from the type definition at the cited
lines.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/common/m_derived_types.fpp
**Line:** 187:187
**Comment:**
	*Logic Error: The component `model` in `t_model_array` is declared as a scalar allocatable rather than an allocatable array, which prevents this type from correctly representing multiple models; any calling code that expects to store or iterate over several models in this container will either silently only store one model or malfunction when trying to index it.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.

real(wp), allocatable, dimension(:, :, :) :: boundary_v
real(wp), allocatable, dimension(:, :) :: interpolated_boundary_v
integer :: boundary_edge_count
integer :: total_vertices
logical :: interpolate
end type t_model_array
Comment on lines +186 to +193
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the exact code at lines 186-193 in m_derived_types.fpp
sed -n '186,193p' src/common/m_derived_types.fpp

Repository: MFlowCode/MFC

Length of output: 395


🏁 Script executed:

# Find and examine m_compute_levelset to see how it uses these components
fd -e fpp -e f90 | xargs grep -l "m_compute_levelset" | head -5

Repository: MFlowCode/MFC

Length of output: 119


🏁 Script executed:

# Search for pointer association patterns with boundary_v or interpolated_boundary_v
rg "boundary_v\s*=>" src/

Repository: MFlowCode/MFC

Length of output: 258


🏁 Script executed:

# Check if TARGET is already on allocatable components in the actual file
rg -A 10 "type :: t_model_array" src/common/m_derived_types.fpp

Repository: MFlowCode/MFC

Length of output: 553


🏁 Script executed:

# Examine the context around pointer associations in m_compute_levelset
rg -B 5 -A 5 "boundary_v => models" src/simulation/m_compute_levelset.fpp

Repository: MFlowCode/MFC

Length of output: 577


🏁 Script executed:

# Look for pointer declarations in m_compute_levelset
rg "pointer.*::.*boundary_v" src/simulation/m_compute_levelset.fpp

Repository: MFlowCode/MFC

Length of output: 186


🏁 Script executed:

# Get broader context - find the subroutine containing these assignments
rg -B 20 "boundary_v => models" src/simulation/m_compute_levelset.fpp | head -60

Repository: MFlowCode/MFC

Length of output: 926


🏁 Script executed:

# Check if other allocatable components in derived types use TARGET
rg "allocatable.*target|target.*allocatable" src/common/m_derived_types.fpp

Repository: MFlowCode/MFC

Length of output: 39


🏁 Script executed:

# Search for other derived type definitions with allocatable components
rg -A 8 "type ::" src/common/m_derived_types.fpp | grep -A 8 "allocatable" | head -40

Repository: MFlowCode/MFC

Length of output: 479


🏁 Script executed:

# Check the coding guidelines file to see if TARGET is required for allocatable in derived types
cat .cursor/rules/mfc-agent-rules.mdc | head -100

Repository: MFlowCode/MFC

Length of output: 3968


🏁 Script executed:

# Check if models (the array of t_model_array) is declared with TARGET
rg -B 5 -A 5 "models.*t_model_array|allocatable.*models" src/simulation/m_compute_levelset.fpp | head -40

Repository: MFlowCode/MFC

Length of output: 39


🏁 Script executed:

# Search for how models is declared - find the variable declaration
rg "type.*t_model_array.*::|:.*models" src/simulation/m_compute_levelset.fpp

Repository: MFlowCode/MFC

Length of output: 39


🏁 Script executed:

# Look for the full context of where models is declared/allocated
rg -B 10 "models(patch_id)" src/simulation/m_compute_levelset.fpp | head -60

Repository: MFlowCode/MFC

Length of output: 39


🏁 Script executed:

# Find where models is passed as a parameter or declared in m_compute_levelset
rg "subroutine.*models|function.*models" src/simulation/m_compute_levelset.fpp

Repository: MFlowCode/MFC

Length of output: 39


🏁 Script executed:

# Look for all subroutine/function signatures that use models
ast-grep --pattern 'subroutine $FUNC($$$models$$$)
  $$$
end subroutine'

Repository: MFlowCode/MFC

Length of output: 39


🏁 Script executed:

# Find the subroutine containing the pointer associations
rg -B 50 "boundary_v => models" src/simulation/m_compute_levelset.fpp | grep "subroutine\|function" | tail -1

Repository: MFlowCode/MFC

Length of output: 92


🏁 Script executed:

# Get the full subroutine signature to see if models is a parameter
sed -n '/subroutine.*compute_levelset/,/end subroutine/p' src/simulation/m_compute_levelset.fpp | head -80

Repository: MFlowCode/MFC

Length of output: 39


🏁 Script executed:

# Find the full subroutine s_model_levelset with its signature and initial context
rg -A 60 "subroutine s_model_levelset" src/simulation/m_compute_levelset.fpp | head -80

Repository: MFlowCode/MFC

Length of output: 2385


🏁 Script executed:

# Check what type gp is and how models is accessed (likely via module-level variable)
rg "type.*::|intent.*models" src/simulation/m_compute_levelset.fpp | head -20

Repository: MFlowCode/MFC

Length of output: 572


🏁 Script executed:

# Search for module-level declarations in m_compute_levelset
rg "^[[:space:]]*(type|real|integer|logical|character).*models|^[[:space:]]*allocatable.*models" src/simulation/m_compute_levelset.fpp

Repository: MFlowCode/MFC

Length of output: 39


🏁 Script executed:

# Look at the top of m_compute_levelset module for variable declarations
head -100 src/simulation/m_compute_levelset.fpp

Repository: MFlowCode/MFC

Length of output: 3212


🏁 Script executed:

# Search for where models is declared or imported - it's used but not a parameter
rg "models|allocate.*models|type.*models" src/simulation/m_compute_levelset.fpp | grep -v "patch_models\|s_model_\|f_model_\|t_model"

Repository: MFlowCode/MFC

Length of output: 440


🏁 Script executed:

# Search in m_ib_patches which is used in m_compute_levelset
rg "models" src/common/m_ib_patches.fpp | head -20

Repository: MFlowCode/MFC

Length of output: 124


🏁 Script executed:

# Look at m_global_parameters to see if models is declared there
rg "models" src/common/m_global_parameters.fpp | head -20

Repository: MFlowCode/MFC

Length of output: 131


🏁 Script executed:

# Search broadly for where models array is declared as module variable
rg "^[[:space:]]*(allocatable|target).*models|type.*t_model_array.*models" src/

Repository: MFlowCode/MFC

Length of output: 146


🏁 Script executed:

# Verify the coding guideline reference about pointer encapsulation
grep -A 5 "pointer.*encapsulation\|encapsulation.*pointer" .cursor/rules/mfc-agent-rules.mdc

Repository: MFlowCode/MFC

Length of output: 39


Add target attribute to allocatable components in t_model_array.

The boundary_v and interpolated_boundary_v allocatable components are pointer targets in m_compute_levelset. Since the parent models variable itself is declared with target, these components should also be explicitly marked as target for consistency, portability, and safety—especially for device code where some compilers enforce strict pointer-association rules.

🛠️ Suggested fix
 type :: t_model_array
-    type(t_model), allocatable :: model
-    real(wp), allocatable, dimension(:, :, :) :: boundary_v
-    real(wp), allocatable, dimension(:, :) :: interpolated_boundary_v
+    type(t_model), allocatable, target :: model
+    real(wp), allocatable, target, dimension(:, :, :) :: boundary_v
+    real(wp), allocatable, target, dimension(:, :) :: interpolated_boundary_v
     integer :: boundary_edge_count
     integer :: total_vertices
     logical :: interpolate
 end type t_model_array
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
type :: t_model_array
type(t_model), allocatable :: model
real(wp), allocatable, dimension(:, :, :) :: boundary_v
real(wp), allocatable, dimension(:, :) :: interpolated_boundary_v
integer :: boundary_edge_count
integer :: total_vertices
logical :: interpolate
end type t_model_array
type :: t_model_array
type(t_model), allocatable, target :: model
real(wp), allocatable, target, dimension(:, :, :) :: boundary_v
real(wp), allocatable, target, dimension(:, :) :: interpolated_boundary_v
integer :: boundary_edge_count
integer :: total_vertices
logical :: interpolate
end type t_model_array
🤖 Prompt for AI Agents
In `@src/common/m_derived_types.fpp` around lines 186 - 193, The allocatable array
components in type t_model_array (boundary_v and interpolated_boundary_v) must
be declared with the target attribute so they can be safely associated by
pointers in m_compute_levelset; update the type t_model_array to add the target
attribute to the allocatable declarations for boundary_v and
interpolated_boundary_v (keeping their existing kinds/dimensions) so pointer
association from models (which is declared target) works correctly and is
portable to device compilers.


!> Derived type adding initial condition (ic) patch parameters as attributes
!! NOTE: The requirements for the specification of the above parameters
!! are strongly dependent on both the choice of the multicomponent flow
Expand Down Expand Up @@ -437,6 +447,8 @@ module m_derived_types
integer, dimension(3) :: ip_grid !< Top left grid point of IP
real(wp), dimension(2, 2, 2) :: interp_coeffs !< Interpolation Coefficients of image point
integer :: ib_patch_id !< ID of the IB Patch the ghost point is part of
real(wp) :: levelset
real(wp), dimension(1:3) :: levelset_norm
Comment on lines +450 to +451
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The newly added levelset and levelset_norm fields in ghost_point are not initialized, so any code that reads these values before they are explicitly set (e.g., for classification or interpolation) will operate on garbage data and may misclassify ghost points. [possible bug]

Severity Level: Critical 🚨
- ❌ Ghost-point classification may be incorrect.
- ❌ Levelset-based IB forces/markers miscomputed.
- ⚠️ Simulation results nondeterministic across runs.
Suggested change
real(wp) :: levelset
real(wp), dimension(1:3) :: levelset_norm
real(wp) :: levelset = 0.0_wp
real(wp), dimension(1:3) :: levelset_norm = 0.0_wp
Steps of Reproduction ✅
1. Inspect the ghost_point type in src/common/m_derived_types.fpp lines 448-455; lines
451-452 add levelset and levelset_norm fields.

2. Create a minimal reproducer (or find IB code that allocates ghost points) that declares
a ghost_point variable and reads the fields before any assignment:

   - use m_derived_types

   - type(ghost_point) :: g

   - print *, g%levelset, g%levelset_norm

3. Compile and run the reproducer. The printed values will be indeterminate
(uninitialized), demonstrating that reading these fields without prior initialization
yields garbage or non-deterministic values.

4. In a real simulation run, any IB/ghost-point routine that reads g%levelset or
g%levelset_norm for classification or interpolation before explicitly writing them (for
example, ghost-point setup or levelset-based boundary condition code paths) will make
wrong decisions; verify by locating IB routines that use ghost_point fields after
allocation and before explicit assignment.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/common/m_derived_types.fpp
**Line:** 451:452
**Comment:**
	*Possible Bug: The newly added `levelset` and `levelset_norm` fields in `ghost_point` are not initialized, so any code that reads these values before they are explicitly set (e.g., for classification or interpolation) will operate on garbage data and may misclassify ghost points.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.

logical :: slip
integer, dimension(3) :: DB
end type ghost_point
Expand Down
27 changes: 23 additions & 4 deletions src/common/m_model.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ contains
!! @return True if the point is inside the octree, false otherwise.
impure function f_model_is_inside(model, point, spacing, spc) result(fraction)

! $:GPU_ROUTINE(parallelism='[seq]')

type(t_model), intent(in) :: model
real(wp), dimension(1:3), intent(in) :: point
real(wp), dimension(1:3), intent(in) :: spacing
Expand All @@ -499,6 +501,15 @@ contains

real(wp), dimension(1:spc, 1:3) :: ray_origins, ray_dirs

! TODO :: The random number generation prohibits GPU compute due to the subroutine not being able to be called in kernels
! This should be swapped out with something that allows GPU compute. I recommend the fibonacci sphere:
! do i = 1, spc
! phi = acos(1.0 - 2.0*(i-1.0)/(spc-1.0))
! theta = pi * (1.0 + sqrt(5.0)) * (i-1.0)
! ray_dirs(i,:) = [cos(theta)*sin(phi), sin(theta)*sin(phi), cos(phi)]
! ray_origins(i,:) = point
! end do

do i = 1, spc
call random_number(ray_origins(i, :))
ray_origins(i, :) = point + (ray_origins(i, :) - 0.5_wp)*spacing(:)
Expand Down Expand Up @@ -739,7 +750,6 @@ contains
interpolate = .false.

do j = 1, boundary_edge_count

l1 = sqrt((boundary_v(j, 2, 1) - boundary_v(j, 1, 1))**2 + &
(boundary_v(j, 2, 2) - boundary_v(j, 1, 2))**2)

Expand Down Expand Up @@ -1049,6 +1059,8 @@ contains
!! @param distance The output levelset distance
subroutine f_distance_normals_3D(model, point, normals, distance)

$:GPU_ROUTINE(parallelism='[seq]')

type(t_model), intent(IN) :: model
real(wp), dimension(1:3), intent(in) :: point
real(wp), dimension(1:3), intent(out) :: normals
Expand Down Expand Up @@ -1112,8 +1124,11 @@ contains
!! @return Distance which the levelset distance without interpolation
function f_distance(boundary_v, boundary_edge_count, point) result(distance)

$:GPU_ROUTINE(parallelism='[seq]')

integer, intent(in) :: boundary_edge_count
real(wp), intent(in), dimension(1:boundary_edge_count, 1:3, 1:2) :: boundary_v
real(wp), intent(in), dimension(:, :, :) :: boundary_v
! real(wp), intent(in), dimension(1:boundary_edge_count, 1:3, 1:2) :: boundary_v
real(wp), dimension(1:3), intent(in) :: point

integer :: i
Expand Down Expand Up @@ -1143,8 +1158,10 @@ contains
!! @param normals Output levelset normals without interpolation
subroutine f_normals(boundary_v, boundary_edge_count, point, normals)

$:GPU_ROUTINE(parallelism='[seq]')

integer, intent(in) :: boundary_edge_count
real(wp), intent(in), dimension(1:boundary_edge_count, 1:3, 1:2) :: boundary_v
real(wp), intent(in), dimension(:, :, :) :: boundary_v
real(wp), dimension(1:3), intent(in) :: point
real(wp), dimension(1:3), intent(out) :: normals

Expand Down Expand Up @@ -1203,8 +1220,10 @@ contains
!! @return Distance which the levelset distance without interpolation
function f_interpolated_distance(interpolated_boundary_v, total_vertices, point) result(distance)

$:GPU_ROUTINE(parallelism='[seq]')

integer, intent(in) :: total_vertices
real(wp), intent(in), dimension(1:total_vertices, 1:3) :: interpolated_boundary_v
real(wp), intent(in), dimension(:, :) :: interpolated_boundary_v
real(wp), dimension(1:3), intent(in) :: point

integer :: i !< Loop iterator
Expand Down
68 changes: 2 additions & 66 deletions src/common/m_mpi_common.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,11 @@ contains

!! @param q_cons_vf Conservative variables
!! @param ib_markers track if a cell is within the immersed boundary
!! @param levelset closest distance from every cell to the IB
!! @param levelset_norm normalized vector from every cell to the closest point to the IB
!! @param beta Eulerian void fraction from lagrangian bubbles
impure subroutine s_initialize_mpi_data(q_cons_vf, ib_markers, levelset, levelset_norm, beta)
impure subroutine s_initialize_mpi_data(q_cons_vf, ib_markers, beta)

type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf
type(integer_field), optional, intent(in) :: ib_markers
type(levelset_field), optional, intent(IN) :: levelset
type(levelset_norm_field), optional, intent(IN) :: levelset_norm
type(scalar_field), intent(in), optional :: beta

integer, dimension(num_dims) :: sizes_glb, sizes_loc
Expand Down Expand Up @@ -203,73 +199,13 @@ contains
end if
#endif

#ifndef MFC_PRE_PROCESS
if (present(ib_markers)) then

#ifdef MFC_PRE_PROCESS
MPI_IO_IB_DATA%var%sf => ib_markers%sf
MPI_IO_levelset_DATA%var%sf => levelset%sf
MPI_IO_levelsetnorm_DATA%var%sf => levelset_norm%sf
#else
MPI_IO_IB_DATA%var%sf => ib_markers%sf(0:m, 0:n, 0:p)

#ifndef MFC_POST_PROCESS
MPI_IO_levelset_DATA%var%sf => levelset%sf(0:m, 0:n, 0:p, 1:num_ibs)
MPI_IO_levelsetnorm_DATA%var%sf => levelset_norm%sf(0:m, 0:n, 0:p, 1:num_ibs, 1:3)
#endif

#endif
call MPI_TYPE_CREATE_SUBARRAY(num_dims, sizes_glb, sizes_loc, start_idx, &
MPI_ORDER_FORTRAN, MPI_INTEGER, MPI_IO_IB_DATA%view, ierr)
call MPI_TYPE_COMMIT(MPI_IO_IB_DATA%view, ierr)

#ifndef MFC_POST_PROCESS
call MPI_TYPE_CREATE_SUBARRAY(num_dims, sizes_glb, sizes_loc, start_idx, &
MPI_ORDER_FORTRAN, mpi_p, MPI_IO_levelset_DATA%view, ierr)
call MPI_TYPE_CREATE_SUBARRAY(num_dims, sizes_glb, sizes_loc, start_idx, &
MPI_ORDER_FORTRAN, mpi_p, MPI_IO_levelsetnorm_DATA%view, ierr)

call MPI_TYPE_COMMIT(MPI_IO_levelset_DATA%view, ierr)
call MPI_TYPE_COMMIT(MPI_IO_levelsetnorm_DATA%view, ierr)
#endif
end if

#ifndef MFC_POST_PROCESS
if (present(ib_markers)) then
do j = 1, num_ibs
if (patch_ib(j)%c > 0) then

#ifdef MFC_PRE_PROCESS
allocate (MPI_IO_airfoil_IB_DATA%var(1:2*Np))
#endif

airfoil_glb(1) = 3*Np*num_procs
airfoil_loc(1) = 3*Np
airfoil_start(1) = 3*proc_rank*Np

#ifdef MFC_PRE_PROCESS
do i = 1, Np
MPI_IO_airfoil_IB_DATA%var(i)%x = airfoil_grid_l(i)%x
MPI_IO_airfoil_IB_DATA%var(i)%y = airfoil_grid_l(i)%y
end do
#endif

call MPI_TYPE_CREATE_SUBARRAY(1, airfoil_glb, airfoil_loc, airfoil_start, &
MPI_ORDER_FORTRAN, mpi_p, MPI_IO_airfoil_IB_DATA%view(1), ierr)
call MPI_TYPE_COMMIT(MPI_IO_airfoil_IB_DATA%view(1), ierr)

#ifdef MFC_PRE_PROCESS
do i = 1, Np
MPI_IO_airfoil_IB_DATA%var(Np + i)%x = airfoil_grid_u(i)%x
MPI_IO_airfoil_IB_DATA%var(Np + i)%y = airfoil_grid_u(i)%y
end do
#endif
call MPI_TYPE_CREATE_SUBARRAY(1, airfoil_glb, airfoil_loc, airfoil_start, &
MPI_ORDER_FORTRAN, mpi_p, MPI_IO_airfoil_IB_DATA%view(2), ierr)
call MPI_TYPE_COMMIT(MPI_IO_airfoil_IB_DATA%view(2), ierr)

end if
end do

end if
#endif

Expand Down
Loading
Loading