Skip to content

Commit bf43fd2

Browse files
committed
Make STL model setup stage-independent
1 parent 913573c commit bf43fd2

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/common/m_model.fpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ module m_model
2424
public :: s_check_boundary, s_register_edge, f_model_is_inside, s_distance_normals_3D, s_distance_normals_2D, &
2525
& s_pack_model_for_gpu
2626

27-
#ifndef MFC_POST_PROCESS
2827
public :: s_instantiate_STL_models
29-
#endif
3028

3129
type(t_model_array), allocatable, target :: models(:) !< STL/OBJ models for IB markers and levelset
3230
integer, allocatable :: gpu_ntrs(:) !< GPU-friendly flat arrays for STL model data
@@ -851,7 +849,6 @@ contains
851849

852850
end subroutine s_distance_normals_2D
853851

854-
#ifndef MFC_POST_PROCESS
855852
!> Load, transform, and register STL/OBJ immersed-boundary models onto the simulation grid.
856853
subroutine s_instantiate_STL_models()
857854

@@ -1002,7 +999,6 @@ contains
1002999
end block
10031000

10041001
end subroutine s_instantiate_STL_models
1005-
#endif
10061002

10071003
!> Pack triangle vertices and normals from a model into flat arrays for GPU transfer.
10081004
subroutine s_pack_model_for_gpu(ma)

toolchain/mfc/params/definitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ def _decl(targets: set, *names: str) -> None:
12231223
_PRE = {"pre"}
12241224
_POST = {"post"}
12251225

1226-
_decl(_ALL, "avg_state", "alt_soundspeed", "mixture_err", "sigR", "viscous", "riemann_solver")
1226+
_decl(_ALL, "avg_state", "alt_soundspeed", "mixture_err", "sigR", "viscous", "riemann_solver", "stl_models", "num_stl_models")
12271227

12281228
_nv(
12291229
_ALL,

toolchain/mfc/params/generators/fortran_gen.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ def generate_decls_fpp(target: str) -> str:
234234
lines.append(f"{fortran_type_decl(param).ljust(_DECL_COL)}:: {name}")
235235
declared_names.add(name)
236236
for name, (ftype, dim, gpu, desc) in TYPED_DECLS.items():
237-
if name not in NAMELIST_VARS or target not in NAMELIST_VARS[name]:
237+
declaration_targets = NAMELIST_VARS.get(name, set()) | DECLARATION_TARGETS.get(name, set())
238+
if target not in declaration_targets:
238239
continue
239240
decl = f"{ftype}, dimension({dim})" if dim else ftype
240241
padded = decl.ljust(_ARRAY_DECL_COL)

toolchain/mfc/params_tests/test_fortran_gen.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ def test_common_module_decls_do_not_expand_namelists():
142142
assert NAMELIST_VARS["riemann_solver"] == {"sim"}
143143

144144

145+
def test_stl_model_declarations_do_not_expand_post_namelist():
146+
from mfc.params.generators.fortran_gen import generate_decls_fpp, generate_namelist_fpp
147+
148+
post_declarations = generate_decls_fpp("post")
149+
post_namelist = generate_namelist_fpp("post")
150+
151+
assert ":: num_stl_models" in post_declarations
152+
assert ":: stl_models" in post_declarations
153+
assert "num_stl_models" not in post_namelist
154+
assert "stl_models" not in post_namelist
155+
156+
145157
def test_decls_no_percent_vars():
146158
from mfc.params.generators.fortran_gen import generate_decls_fpp
147159

0 commit comments

Comments
 (0)