Skip to content
Draft
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c710a3e
start to add a test for predcorr
PaulineVidal Aug 6, 2025
99c5a95
Google test to modify
PaulineVidal Aug 6, 2025
de830a2
add files for test
PaulineVidal Aug 6, 2025
aec4974
Merge remote-tracking branch 'origin/devel' into pvidal_google_test_f…
PaulineVidal Aug 6, 2025
4e901fe
remove comment
PaulineVidal Aug 6, 2025
30c0886
line
PaulineVidal Aug 6, 2025
130839f
on local it doesnt work. Try on Persee.
PaulineVidal Aug 7, 2025
6413737
remove useless file
PaulineVidal Aug 7, 2025
2936963
change the parameter in the .yaml
PaulineVidal Aug 7, 2025
1c82ca7
Merge remote-tracking branch 'origin/devel' into pvidal_google_test_f…
PaulineVidal Aug 7, 2025
ef78a1f
try fix the path to tets
PaulineVidal Aug 7, 2025
75d73a5
fix ci tes t?
PaulineVidal Aug 7, 2025
445118f
f string
PaulineVidal Aug 7, 2025
8e3a65a
print(folder)
PaulineVidal Aug 7, 2025
8f78251
remove tests
PaulineVidal Aug 7, 2025
fcf0e9a
try other path?
PaulineVidal Aug 7, 2025
207d8ad
print
PaulineVidal Aug 7, 2025
97855e6
path wrong
PaulineVidal Aug 7, 2025
fdb4a25
try to get keys
PaulineVidal Aug 7, 2025
c59a81d
print path
PaulineVidal Aug 8, 2025
2c2cc1b
test different path
PaulineVidal Aug 8, 2025
1c9837c
try path
PaulineVidal Aug 8, 2025
9e2e493
space
PaulineVidal Aug 8, 2025
561d734
change path
PaulineVidal Aug 8, 2025
7c2446f
clean files
PaulineVidal Aug 8, 2025
1116ac0
Merge remote-tracking branch 'origin/devel' into pvidal_google_test_f…
PaulineVidal Aug 8, 2025
db59cec
remove line in the CHANGELOG which shouldnt be here.
PaulineVidal Aug 8, 2025
f7e2bad
add if with BUILD_END_TO_END_TESTS
PaulineVidal Aug 8, 2025
1fb0d08
add release only
PaulineVidal Aug 8, 2025
61376c7
TIMEOUT is in s.
PaulineVidal Aug 8, 2025
da9a05a
PROPERY is not the new PROPERTY
PaulineVidal Aug 8, 2025
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
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allow a `DerivField` to be stored in a `MultipatchField`.
- Add `DerivFieldOnPatch` and `IdxRangeSliceOnPatch` aliases for the `MultipatchField` in `types.hpp`.
- Allow `min` and `max` from `math_tools.hpp` to be called from GPU.
- Add a `periodic_strips_non_uniform_2d_9patches` geometry.

### Fixed

Expand Down
8 changes: 5 additions & 3 deletions tests/geometryRTheta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# Allow the possibility of deactivating slow polar poisson tests
option(POISSON_2D_BUILD_TESTING "Build polar poisson tests" ON)


add_subdirectory(advection_field_rtheta)
add_subdirectory(advection_rtheta)
if("${POISSON_2D_BUILD_TESTING}")
add_subdirectory(polar_poisson)
endif()
add_subdirectory(spline_interpolator_rtheta)
add_subdirectory(quadrature)
add_subdirectory(advection_rtheta)
add_subdirectory(advection_field_rtheta)
add_subdirectory(spline_interpolator_rtheta)
add_subdirectory(time_solver)
22 changes: 22 additions & 0 deletions tests/geometryRTheta/time_solver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-License-Identifier: MIT

find_package(Python3 REQUIRED COMPONENTS Interpreter)

function (diocotron_test_executable PREDCORR_METHOD TIME_METHOD )
set(test_name "TestSimulationDiocotron_${PREDCORR_METHOD}_${TIME_METHOD}")

add_test(NAME "${test_name}"
COMMAND bash "${CMAKE_CURRENT_SOURCE_DIR}/test_diocotron.sh"
"${PROJECT_SOURCE_DIR}"
"$<TARGET_FILE:diocotron_${PREDCORR_METHOD}_${TIME_METHOD}>"
"$<TARGET_FILE:Python3::Interpreter>")

# The test should take less than 15 min.
set_property(TEST "${test_name}" PROPERTY TIMEOUT 900000)

@EmilyBourne EmilyBourne Aug 8, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On the CI the timings are:

Serial Debug GNU

  • TestSimulationDiocotron_PREDCORR_EULER_METHOD (582.507s)
  • TestSimulationDiocotron_EXPLICIT_PREDCORR_EULER_METHOD (409.768s)
  • TestSimulationDiocotron_IMPLICIT_PREDCORR_EULER_METHOD (314.197s)

Serial Debug Clang

  • TestSimulationDiocotron_PREDCORR_EULER_METHOD (267.755s)
  • TestSimulationDiocotron_EXPLICIT_PREDCORR_EULER_METHOD (199.956s)
  • TestSimulationDiocotron_IMPLICIT_PREDCORR_EULER_METHOD (162.804s)

Serial Release GNU

  • TestSimulationDiocotron_PREDCORR_EULER_METHOD (179.175s)
  • TestSimulationDiocotron_EXPLICIT_PREDCORR_EULER_METHOD (141.35s)
  • TestSimulationDiocotron_IMPLICIT_PREDCORR_EULER_METHOD (93.0959s)

Serial Release Clang

  • TestSimulationDiocotron_PREDCORR_EULER_METHOD (216.769s)
  • TestSimulationDiocotron_EXPLICIT_PREDCORR_EULER_METHOD (163.87s)
  • TestSimulationDiocotron_IMPLICIT_PREDCORR_EULER_METHOD (130.083s)

OpenMP Release GNU

  • TestSimulationDiocotron_PREDCORR_EULER_METHOD (245.865s)
  • TestSimulationDiocotron_EXPLICIT_PREDCORR_EULER_METHOD (202.417s)
  • TestSimulationDiocotron_IMPLICIT_PREDCORR_EULER_METHOD (149.567s)

Coverage Flags GNU

  • TestSimulationDiocotron_PREDCORR_EULER_METHOD (5687.16s)
  • TestSimulationDiocotron_EXPLICIT_PREDCORR_EULER_METHOD (3960.98s)
  • TestSimulationDiocotron_IMPLICIT_PREDCORR_EULER_METHOD (2883.25s)

Unacceptably slow

GPU

  • TestSimulationDiocotron_PREDCORR_EULER_METHOD (68.71s)
  • TestSimulationDiocotron_EXPLICIT_PREDCORR_EULER_METHOD (73.10s)
  • TestSimulationDiocotron_IMPLICIT_PREDCORR_EULER_METHOD (519.86s)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we can choose the parameters based on the CI. Run with 1 step for the coverage just to show there is a test 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is also probably sufficient to run in Release only if we can work out a clean way to do it

Comment thread
PaulineVidal marked this conversation as resolved.
Outdated
set_property(TEST "${test_name}" PROPERTY COST 100)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
set_property(TEST "${test_name}" PROPERTY COST 100)
set_property(TEST "${test_name}" PROPERTY COST 100)
set_property(TEST "${test_name}" PROPERY LABEL Release_only)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This would require -L Release_only to be passed to ctest though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe they could just be activated with an environment variable?

@PaulineVidal PaulineVidal Aug 8, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I dont know what is the best solution. The release only is better because indeed we dont need to test in debug.

endfunction()

# Select the parameters of the simulation:
diocotron_test_executable(PREDCORR EULER_METHOD)
diocotron_test_executable(EXPLICIT_PREDCORR EULER_METHOD)
diocotron_test_executable(IMPLICIT_PREDCORR EULER_METHOD)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
diocotron_test_executable(PREDCORR EULER_METHOD)
diocotron_test_executable(EXPLICIT_PREDCORR EULER_METHOD)
diocotron_test_executable(IMPLICIT_PREDCORR EULER_METHOD)
if(defined ENV{BUILD_END_TO_END_TESTS})
diocotron_test_executable(PREDCORR EULER_METHOD)
diocotron_test_executable(EXPLICIT_PREDCORR EULER_METHOD)
diocotron_test_executable(IMPLICIT_PREDCORR EULER_METHOD)
endif()

52 changes: 52 additions & 0 deletions tests/geometryRTheta/time_solver/growth_rate_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/python3

# SPDX-License-Identifier: MIT

"""
File which tests whether the growth rate of the perturbation of a diocotron instabilities test case
follows the predicted slope.
"""

from argparse import ArgumentParser
from pathlib import Path
import numpy as np

from gysdata import DiskStore


if __name__ == '__main__':
parser = ArgumentParser(description="Check growth rate.")
parser.add_argument('data_dir',
action='store',
nargs='?',
default=Path.cwd(),
type=Path,
help='Location of the results (output folder).')
args = parser.parse_args()

path_data_structure = Path('data_structure_RTheta.yaml')
ds = DiskStore(args.data_dir, data_structure=path_data_structure)

# Get initial data
rho_eq = np.array(ds['density_eq'])
phi_eq = np.array(ds['electrical_potential_eq'])

jacobian = np.array(ds["jacobian"])

T = float(ds["final_T"])
omega_Im = float(ds["slope"])

# Get the data at each time step
Time = np.array(ds["density"].coords["time"])
rho = np.array(ds['density'])
phi = np.array(ds['electrical_potential'])

# Compute norms
L2norms_rho = np.linalg.norm((rho - rho_eq[None,:,:])*abs(jacobian[None,:,:]), 2, axis=(1,2))
L2norms_phi = np.linalg.norm((phi - phi_eq[None,:,:])*abs(jacobian[None,:,:]), 2, axis=(1,2))

slope_rho = np.polyfit(Time, L2norms_rho, 1)[0]
slope_phi = np.polyfit(Time, L2norms_phi, 1)[0]

assert abs(slope_rho - omega_Im) / abs(omega_Im) < 1
assert abs(slope_phi - omega_Im) / abs(omega_Im) < 1
48 changes: 48 additions & 0 deletions tests/geometryRTheta/time_solver/test_diocotron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -xe

if [ $# -ne 3 ]; then
echo "Usage: $0 <GYSELALIBXX_SRCDIR> <GYSELALIBXX_EXEC> <PYTHON3_EXE>"
exit 1
fi
GYSELALIBXX_SRCDIR="$1"
GYSELALIBXX_EXEC="$2"
PYTHON3_EXE="$3"

OUTDIR="${PWD}"

TMPDIR="$(mktemp -p "${PWD}" -d run-XXXXXXXXXX)"
function finish {
rm -rf "${TMPDIR}"
}
trap finish EXIT QUIT ABRT KILL SEGV TERM STOP

cd "${TMPDIR}"

# Create a parameter file with the default values.
"${GYSELALIBXX_EXEC}" "--dump-config" "${PWD}/diocotron_params.yaml"

# Modify the default parameter files for a faster test.
MODIFY_PARAMETERS=$(cat <<EOF
import yaml

with open('diocotron_params.yaml') as f:
data = yaml.safe_load(f)

data['SplineMesh']['r_ncells'] = 32
data['SplineMesh']['theta_ncells'] = 64
data['Time']['final_T'] = 40.
data['Output']['time_step_diag'] = 40

with open('diocotron_params.yaml', 'w') as f:
yaml.dump(data, f)
EOF
)

"${PYTHON3_EXE}" -c "$MODIFY_PARAMETERS"

# Launch the test with the modified parameter file.
"${GYSELALIBXX_EXEC}" "${PWD}/diocotron_params.yaml"

export PYTHONPATH="${GYSELALIBXX_SRCDIR}/post-process/PythonScripts:${PYTHONPATH}"
"${PYTHON3_EXE}" -B "${GYSELALIBXX_SRCDIR}/tests/geometryRTheta/time_solver/growth_rate_test.py" "${TMPDIR}/output"
Loading