Skip to content

Commit 76eccea

Browse files
authored
Merge branch 'MFlowCode:master' into io
2 parents b0002b3 + 82af415 commit 76eccea

File tree

21 files changed

+307
-225
lines changed

21 files changed

+307
-225
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ __pycache__
2828

2929
docs/*/initial*
3030
docs/*/result*
31+
docs/documentation/*-example.png
3132
docs/documentation/examples.md
3233

3334
examples/*batch/*/

CMakeLists.txt

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
6565
endif()
6666
elseif ((CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") OR (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI"))
6767
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 21.7)
68-
message(FATAL_ERROR "${__err_msg}ERROR: NVHPC v21.7 or newer is required to build MFC.")
68+
message(FATAL_ERROR "${__err_msg}ERROR: When using NVHPC, v21.7 or newer is required to build MFC.")
69+
endif()
70+
if (MAKE_BUILD_TYPE STREQUAL "Debug")
71+
if (MFC_OpenACC)
72+
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 23.0)
73+
message(FATAL_ERROR "${__err_msg}ERROR: When using NVHPC, v23.0 or newer is required to build MFC with Debug and GPU options.")
74+
endif()
75+
else()
76+
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 23.8)
77+
message(FATAL_ERROR "${__err_msg}ERROR: Debug is not working with NVHPC 23.X and older and CPU options at present.")
78+
endif()
79+
endif()
6980
endif()
7081
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
7182
message(FATAL_ERROR "${__err_msg}ERROR: MFC does not support the Apple Clang compilers. Please consult the documentation.")
@@ -145,7 +156,7 @@ elseif ((CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") OR (CMAKE_Fortran_COMPILER_
145156
endif()
146157

147158
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
148-
add_compile_options(-C -g -traceback -Mchkptr -Mchkstk -Minform=inform -Mbounds)
159+
add_compile_options(-C -g -O0 -traceback -Mchkptr -Mchkstk -Minform=inform -Mbounds)
149160
endif()
150161
endif()
151162

@@ -229,6 +240,8 @@ macro(HANDLE_SOURCES target useCommon)
229240
set(${target}_DIR "${CMAKE_SOURCE_DIR}/src/${target}")
230241
set(common_DIR "${CMAKE_SOURCE_DIR}/src/common")
231242

243+
string(TOUPPER ${target} ${target}_UPPER)
244+
232245
# Gather src/[<target>,common]/*.f90
233246
file(GLOB ${target}_F90s CONFIGURE_DEPENDS "${${target}_DIR}/*.f90")
234247
set(${target}_SRCs ${${target}_F90s})
@@ -245,9 +258,9 @@ macro(HANDLE_SOURCES target useCommon)
245258
endif()
246259

247260
# Locate src/[<target>,common]/include/*.fpp
248-
if (EXISTS "${${target}_DIR}/include")
249-
file(GLOB ${target}_incs CONFIGURE_DEPENDS "${${target}_DIR}/include/*.fpp")
250-
endif()
261+
file(GLOB ${target}_incs CONFIGURE_DEPENDS "${${target}_DIR}/include/*.fpp"
262+
"${CMAKE_CURRENT_BINARY_DIR}/include/*.fpp")
263+
251264
if (${useCommon})
252265
file(GLOB common_incs CONFIGURE_DEPENDS "${common_DIR}/include/*.fpp")
253266
list(APPEND ${target}_incs ${common_incs})
@@ -261,11 +274,14 @@ macro(HANDLE_SOURCES target useCommon)
261274
add_custom_command(
262275
OUTPUT ${f90}
263276
COMMAND ${FYPP_EXE} -m re
264-
-I "${common_DIR}"
265-
-I "${common_DIR}/include"
277+
-I "${CMAKE_CURRENT_BINARY_DIR}/include"
266278
-I "${${target}_DIR}/include"
279+
-I "${common_DIR}/include"
280+
-I "${common_DIR}"
267281
-D MFC_${CMAKE_Fortran_COMPILER_ID}
282+
-D MFC_${${target}_UPPER}
268283
-D MFC_COMPILER="${CMAKE_Fortran_COMPILER_ID}"
284+
-D MFC_CASE_OPTIMIZATION=False
269285
--line-numbering
270286
--no-folding
271287
"${fpp}" "${f90}"
@@ -317,10 +333,10 @@ function(MFC_SETUP_TARGET)
317333
"${CMAKE_SOURCE_DIR}/src/${ARGS_TARGET}/include")
318334
endif()
319335

320-
string(TOUPPER "${ARGS_TARGET}" ARGS_TARGET_UPPER)
336+
string(TOUPPER "${ARGS_TARGET}" ${ARGS_TARGET}_UPPER)
321337
target_compile_definitions(
322338
${ARGS_TARGET} PRIVATE MFC_${CMAKE_Fortran_COMPILER_ID}
323-
MFC_${ARGS_TARGET_UPPER}
339+
MFC_${${ARGS_TARGET}_UPPER}
324340
)
325341

326342
if (MFC_MPI AND ARGS_MPI)
@@ -430,6 +446,19 @@ if (MFC_SYSCHECK)
430446
endif()
431447

432448
if (MFC_DOCUMENTATION)
449+
# Files in docs/examples are used to generate docs/documentation/examples.md
450+
file(GLOB_RECURSE examples_DOCs CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/docs/examples/*")
451+
452+
add_custom_command(
453+
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/docs/documentation/examples.md"
454+
DEPENDS "${examples_DOCs}"
455+
COMMAND "bash" "${CMAKE_CURRENT_SOURCE_DIR}/docs/examples.sh"
456+
"${CMAKE_CURRENT_SOURCE_DIR}"
457+
COMMENT "Generating examples.md"
458+
)
459+
460+
file(GLOB common_DOCs CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/docs/*")
461+
433462
# GEN_DOCS: Given a target name (herein <target>), this macro sets up a
434463
# target, <target>_docs, that generates documentation for <target> using
435464
# Doxygen. It is then added as a dependency of the documentation target.
@@ -456,13 +485,20 @@ if (MFC_DOCUMENTATION)
456485
"${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in"
457486
"${CMAKE_CURRENT_BINARY_DIR}/${target}-Doxyfile" @ONLY)
458487

488+
set(opt_example_dependency "")
489+
if (target STREQUAL "documentation")
490+
set(opt_example_dependency "${CMAKE_CURRENT_SOURCE_DIR}/docs/documentation/examples.md")
491+
endif()
492+
493+
file(GLOB_RECURSE ${target}_DOCs CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/docs/${target}/*")
494+
list(APPEND ${target}_DOCs "${common_DOCs}")
495+
459496
add_custom_command(
460497
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}/html/index.html"
461498
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}-Doxyfile"
462-
"${${target}_SRCs}"
463-
COMMAND "bash" "${CMAKE_CURRENT_SOURCE_DIR}/docs/examples.sh"
464-
"${CMAKE_CURRENT_SOURCE_DIR}" &&
465-
"${DOXYGEN_EXECUTABLE}" "${target}-Doxyfile"
499+
"${opt_example_dependency}"
500+
"${${target}_SRCs}" "${${target}_DOCs}"
501+
COMMAND "${DOXYGEN_EXECUTABLE}" "${target}-Doxyfile"
466502
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
467503
COMMENT "${target}: Generating documentation"
468504
)
@@ -487,7 +523,7 @@ if (MFC_DOCUMENTATION)
487523
ExternalProject_Add(doxygen-awesome-css
488524
PREFIX doxygen-awesome-css
489525
GIT_REPOSITORY "https://github.com/jothepro/doxygen-awesome-css"
490-
GIT_TAG "df83fbf22cfff76b875c13d324baf584c74e96d0"
526+
GIT_TAG "df88fe4fdd97714fadfd3ef17de0b4401f804052"
491527
CONFIGURE_COMMAND ""
492528
BUILD_COMMAND ""
493529
INSTALL_COMMAND ""

docs/documentation/case.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,18 +509,24 @@ Implementation of the parameterse into the model follow [Ando (2010)](references
509509
| Parameter | Type | Description |
510510
| ---: | :----: | :--- |
511511
| `perturb_flow` | Logical | Perturb the initlal velocity field by random noise |
512+
| `perturb_flow_fluid` | Integer | Fluid density whose flow is to be perturbed |
513+
| `perturb_flow_mag` | Real | Set the magnitude of flow perturbations |
512514
| `perturb_sph` | Logical | Perturb the initial partial density by random noise |
513-
| `perturb_sph_fluid` | Integer | Fluid component whose partial density to be perturbed |
515+
| `perturb_sph_fluid` | Integer | Fluid component whose partial density is to be perturbed |
514516
| `vel_profile` | Logical | Set the mean streamwise velocity to hyperbolic tangent profile |
515517
| `instability_wave` | Logical | Perturb the initial velocity field by instability waves |
516518

517519
The table lists velocity field parameters. The parameters are optionally used to define initial velocity profiles and perturbations.
518520

519521
- `perturb_flow` activates the perturbation of initial velocity by random noise.
520522

521-
- `perturb_sph` activates the perturbation of intial partial density by random noise.
523+
- `perturb_flow_fluid` specifies the fluid component whose flow is to be perturbed.
522524

523-
- `perturb_sph_fluid` specifies the fluid component whose the partial density to be perturbed.
525+
- `perturb_flow` activates the perturbation of initial velocity by random noise.
526+
527+
- `perturb_sph` activates the perturbation of initial partial density by random noise.
528+
529+
- `perturb_sph_fluid` specifies the fluid component whose partial density is to be perturbed.
524530

525531
- `vel_profile` activates setting the mean streamwise velocity to hyperbolic tangent profile. This option works only for 2D and 3D cases.
526532

docs/examples.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@ rm "$examples_md" || true
77

88
echo -e "# Example Cases\n" > "$examples_md"
99

10-
for casedir in $(find "$1/examples/" -maxdepth 1 -type d); do
11-
casename="$(basename $casedir)"
12-
13-
if [ "$casename" == "examples" ]; then
14-
continue
15-
fi
10+
for casedir in $(find "$1/examples/" -mindepth 1 -maxdepth 1 -type d); do
11+
casename="$(basename "$casedir")"
1612

1713
if [ -f "$casedir/README.md" ]; then
18-
sed -e "s/\.png/-$casename\.png/g" "$casedir/README.md" | sed 's/^#/##/g' >> "$examples_md"
19-
echo "" >> "$examples_md"
14+
sed -e "s/\.png/-$casename-example\.png/g" "$casedir/README.md" | sed 's/^#/##/g' >> "$examples_md"
15+
echo '' >> "$examples_md"
2016

21-
for png in $(find "$casedir" -maxdepth 1 -name "*.png"); do
22-
cp "$png" "$1/docs/documentation/$(basename $png | sed s/\.png//g)-$casename.png"
17+
for png in $(find "$casedir" -maxdepth 1 -name '*.png'); do
18+
cp "$png" "$1/docs/documentation/$(basename "$png" | sed s/\.png//g)-$casename-example.png"
2319
done
2420
fi
2521
done

src/pre_process/include/case.fpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
! This file was generated by MFC. It is only used when analytical patches are
2-
! present in the input file. It is used to define the analytical patches with
3-
! expressions that are evaluated at runtime from the input file.
1+
! By default, no analytical patches are defined.
42

53
#:def analytical()
6-
74
#:enddef

src/pre_process/m_check_patches.fpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ contains
302302

303303
end subroutine s_check_2D_TaylorGreen_vortex_patch_geometry! --------------
304304

305+
305306
!> This subroutine verifies that the geometric parameters of
306307
!! the analytical patch have consistently been inputted by
307308
!! the user.

src/pre_process/m_checker.f90

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,15 @@ subroutine s_check_inputs()
543543
call s_mpi_abort('Unsupported choice for the value of '// &
544544
'num_patches. Exiting ...')
545545
! Constraints on perturbing the initial condition
546-
elseif ((perturb_flow .and. perturb_flow_fluid == dflt_int) &
546+
elseif ((perturb_flow &
547+
.and. &
548+
(perturb_flow_fluid == dflt_int .or. perturb_flow_mag == dflt_real)) &
547549
.or. &
548-
((perturb_flow .neqv. .true.) .and. (perturb_flow_fluid /= dflt_int))) then
550+
((perturb_flow .neqv. .true.) &
551+
.and. &
552+
(perturb_flow_fluid /= dflt_int .or. perturb_flow_mag /= dflt_real))) then
549553
call s_mpi_abort('Unsupported choice of the combination of '// &
550-
'values for perturb_flow and perturb_flow_fluid. '// &
554+
'values for perturb_flow, perturb_flow_fluid, and perturb_flow_mag. '// &
551555
'Exiting ...')
552556
elseif ((perturb_flow_fluid > num_fluids) &
553557
.or. &

src/pre_process/m_global_parameters.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ module m_global_parameters
104104
! Perturb density of surrounding air so as to break symmetry of grid
105105
logical :: perturb_flow
106106
integer :: perturb_flow_fluid !< Fluid to be perturbed with perturb_flow flag
107+
real(kind(0d0)) :: perturb_flow_mag !< Magnitude of perturbation with perturb_flow flag
107108
logical :: perturb_sph
108109
integer :: perturb_sph_fluid !< Fluid to be perturbed with perturb_sph flag
109110
real(kind(0d0)), dimension(num_fluids_max) :: fluid_rho
@@ -256,6 +257,7 @@ contains
256257
instability_wave = .false.
257258
perturb_flow = .false.
258259
perturb_flow_fluid = dflt_int
260+
perturb_flow_mag = dflt_real
259261
perturb_sph = .false.
260262
perturb_sph_fluid = dflt_int
261263
fluid_rho = dflt_real

src/pre_process/m_initial_condition.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ contains
324324
! q_prim_vf(perturb_flow_fluid)%sf(i,j,k) = q_prim_vf(perturb_flow_fluid)%sf(i,j,k) + rand_real
325325
! Perturb velocity
326326
call random_number(rand_real)
327-
rand_real = rand_real*1.d-2
327+
rand_real = rand_real*perturb_flow_mag
328328
q_prim_vf(mom_idx%beg)%sf(i, j, k) = (1.d0 + rand_real)*q_prim_vf(mom_idx%beg)%sf(i, j, k)
329329
q_prim_vf(mom_idx%end)%sf(i, j, k) = rand_real*q_prim_vf(mom_idx%beg)%sf(i, j, k)
330330
if (bubbles) then

src/pre_process/m_mpi_proxy.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ contains
6565
& 'y_domain%end', 'z_domain%beg', 'z_domain%end', 'a_x', 'a_y', &
6666
& 'a_z', 'x_a', 'x_b', 'y_a', 'y_b', 'z_a', 'z_b', 'bc_x%beg', &
6767
& 'bc_x%end', 'bc_y%beg', 'bc_y%end', 'bc_z%beg', 'bc_z%end', &
68-
& 'pref', 'rhoref', 'poly_sigma', 'R0ref', 'Web', 'Ca', 'Re_inv', &
69-
& 'sigR', 'sigV', 'rhoRV' ]
68+
& 'perturb_flow_mag', 'pref', 'rhoref', 'poly_sigma', 'R0ref', &
69+
& 'Web', 'Ca', 'Re_inv', 'sigR', 'sigV', 'rhoRV' ]
7070
call MPI_BCAST(${VAR}$, 1, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
7171
#:endfor
7272

0 commit comments

Comments
 (0)