DNDSR 0.2.1
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
test_restart_redistribute Namespace Reference

Functions

 _strip_json_comments (text)
 
 _load_json (path)
 
 _write_json (path, obj)
 
 _run_solver (np_count, config_path, work_dir, overrides=None, timeout=300)
 
 _read_h5_u_data (h5_path)
 
 _gather_by_orig_index (orig_idx, data)
 
 work_dir ()
 
 _make_step1_config (work_dir, mesh_file=MESH_SMALL)
 
 _make_step2_config (work_dir, restart_h5_path, tag, np_count, reorder_cells=False, mesh_bisect=0, mesh_file=MESH_SMALL)
 
 _find_restart_h5 (search_dir, label="")
 
 _compare_restart_h5 (restart_a, restart_b, tol=1e-10)
 
 _run_step1 (work_dir, np_write, mesh_file=MESH_SMALL)
 
 _run_step2 (work_dir, restart_h5, tag, np_count, overrides=None, mesh_file=MESH_SMALL)
 
 work_dir_large ()
 
 test_restart_redistribute_same_np (work_dir)
 
 test_restart_redistribute_different_np (work_dir)
 
 test_restart_redistribute_large_mesh_multi_np (work_dir_large)
 

Variables

 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
 
 PROJECT_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, "..", ".."))
 
 BUILD_DIR = os.path.join(PROJECT_ROOT, "build")
 
 EULER_EXE = os.path.join(BUILD_DIR, "app", "euler.exe")
 
 BASE_CONFIG
 
 MESH_SMALL
 
 MESH_LARGE
 
 prefix
 

Detailed Description

Functional test for ArrayPair redistribution via Euler solver restart.

The test verifies that DOF data written in a restart file by one MPI partition
can be correctly read by a different partition (different np), producing
identical solver behaviour.

Steps:
  1. Run the Euler IV solver for 20 time steps with np=2, writing an H5 restart.
  2. Load that restart and immediately write it back at np=2 (reference).
  3. Load that restart and immediately write it back at np=3 (redistributed read).
  4. Compare the two restart H5 files: the DOF data must match to machine precision.

The file contains three test variants: same-np reseed, cross-np redistribution,
and a large-mesh multi-np (np=4 → np=4..8) case.

Usage:
    pytest test/Euler/test_restart_redistribute.py -s
    # or directly:
    python test/Euler/test_restart_redistribute.py

Function Documentation

◆ _compare_restart_h5()

test_restart_redistribute._compare_restart_h5 (   restart_a,
  restart_b,
  tol = 1e-10 
)
protected
Compare two restart H5 files by origIndex. Returns max_diff, rel_norm.

Definition at line 261 of file test_restart_redistribute.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _find_restart_h5()

test_restart_redistribute._find_restart_h5 (   search_dir,
  label = "" 
)
protected
Find restart H5 files in directory tree.

Definition at line 248 of file test_restart_redistribute.py.

Here is the caller graph for this function:

◆ _gather_by_orig_index()

test_restart_redistribute._gather_by_orig_index (   orig_idx,
  data 
)
protected
Reorder data rows by original index so that global ordering is canonical.

Definition at line 120 of file test_restart_redistribute.py.

Here is the caller graph for this function:

◆ _load_json()

test_restart_redistribute._load_json (   path)
protected

Definition at line 55 of file test_restart_redistribute.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _make_step1_config()

test_restart_redistribute._make_step1_config (   work_dir,
  mesh_file = MESH_SMALL 
)
protected
Config for the initial 20-step run (produces the restart).

Definition at line 138 of file test_restart_redistribute.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _make_step2_config()

test_restart_redistribute._make_step2_config (   work_dir,
  restart_h5_path,
  tag,
  np_count,
  reorder_cells = False,
  mesh_bisect = 0,
  mesh_file = MESH_SMALL 
)
protected
Config for the 1-step restart run.

Definition at line 189 of file test_restart_redistribute.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _read_h5_u_data()

test_restart_redistribute._read_h5_u_data (   h5_path)
protected
Read the DOF 'u' data from a restart H5 file.

Returns (origIndex, data) where:
  - origIndex: 1-D array of original cell indices (global key)
  - data: 2-D array of DOF values, shape (nGlobal, nVars)

Definition at line 88 of file test_restart_redistribute.py.

Here is the caller graph for this function:

◆ _run_solver()

test_restart_redistribute._run_solver (   np_count,
  config_path,
  work_dir,
  overrides = None,
  timeout = 300 
)
protected
Run the Euler solver via mpirun and return the process result.

Definition at line 65 of file test_restart_redistribute.py.

Here is the caller graph for this function:

◆ _run_step1()

test_restart_redistribute._run_step1 (   work_dir,
  np_write,
  mesh_file = MESH_SMALL 
)
protected
Run step 1: initial 20-step run producing a restart.

Definition at line 288 of file test_restart_redistribute.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _run_step2()

test_restart_redistribute._run_step2 (   work_dir,
  restart_h5,
  tag,
  np_count,
  overrides = None,
  mesh_file = MESH_SMALL 
)
protected
Run step 2: load restart and immediately write it back.

Definition at line 298 of file test_restart_redistribute.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _strip_json_comments()

test_restart_redistribute._strip_json_comments (   text)
protected
Remove // comments from JSON-with-comments (DNDS convention).

Definition at line 50 of file test_restart_redistribute.py.

Here is the caller graph for this function:

◆ _write_json()

test_restart_redistribute._write_json (   path,
  obj 
)
protected

Definition at line 60 of file test_restart_redistribute.py.

Here is the caller graph for this function:

◆ test_restart_redistribute_different_np()

test_restart_redistribute.test_restart_redistribute_different_np (   work_dir)
Write restart at np=2, read at np=3 (cross-np redistribution).

Definition at line 357 of file test_restart_redistribute.py.

Here is the call graph for this function:

◆ test_restart_redistribute_large_mesh_multi_np()

test_restart_redistribute.test_restart_redistribute_large_mesh_multi_np (   work_dir_large)
Write restart at np=4 with 20x20 mesh, read at np=4..8.

Definition at line 379 of file test_restart_redistribute.py.

Here is the call graph for this function:

◆ test_restart_redistribute_same_np()

test_restart_redistribute.test_restart_redistribute_same_np (   work_dir)
Write restart at np=2, read at np=2 with different Metis seed.

Definition at line 329 of file test_restart_redistribute.py.

Here is the call graph for this function:

◆ work_dir()

test_restart_redistribute.work_dir ( )
Create a temporary working directory for the test.

Definition at line 130 of file test_restart_redistribute.py.

◆ work_dir_large()

test_restart_redistribute.work_dir_large ( )
Create a temporary working directory for the large-mesh test.

Definition at line 322 of file test_restart_redistribute.py.

Variable Documentation

◆ BASE_CONFIG

test_restart_redistribute.BASE_CONFIG
Initial value:
1= os.path.join(PROJECT_ROOT, "cases",
2 "euler", "euler_config_IV.json")

Definition at line 42 of file test_restart_redistribute.py.

◆ BUILD_DIR

test_restart_redistribute.BUILD_DIR = os.path.join(PROJECT_ROOT, "build")

Definition at line 40 of file test_restart_redistribute.py.

◆ EULER_EXE

test_restart_redistribute.EULER_EXE = os.path.join(BUILD_DIR, "app", "euler.exe")

Definition at line 41 of file test_restart_redistribute.py.

◆ MESH_LARGE

test_restart_redistribute.MESH_LARGE
Initial value:
1= os.path.join(PROJECT_ROOT, "data", "mesh",
2 "IV10_20.cgns")

Definition at line 46 of file test_restart_redistribute.py.

◆ MESH_SMALL

test_restart_redistribute.MESH_SMALL
Initial value:
1= os.path.join(PROJECT_ROOT, "data", "mesh",
2 "IV10_10.cgns")

Definition at line 44 of file test_restart_redistribute.py.

◆ prefix

test_restart_redistribute.prefix

Definition at line 419 of file test_restart_redistribute.py.

◆ PROJECT_ROOT

test_restart_redistribute.PROJECT_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, "..", ".."))

Definition at line 39 of file test_restart_redistribute.py.

◆ SCRIPT_DIR

test_restart_redistribute.SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))

Definition at line 38 of file test_restart_redistribute.py.