DNDSR 0.1.0.dev1+gcd065ad
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 = os.path.join(PROJECT_ROOT, "cases", "euler", "euler_config_IV.json")
 
 DEFAULT_CONFIG = os.path.join(PROJECT_ROOT, "cases", "euler", "euler_default_config.json")
 
 MESH_SMALL = os.path.join(PROJECT_ROOT, "data", "mesh", "IV10_10.cgns")
 
 MESH_LARGE = os.path.join(PROJECT_ROOT, "data", "mesh", "IV10_20.cgns")
 
 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 258 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 245 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 117 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 53 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 135 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 186 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 86 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 63 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 284 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 295 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 48 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 58 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 349 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 367 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 324 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 127 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 317 of file test_restart_redistribute.py.

Variable Documentation

◆ BASE_CONFIG

test_restart_redistribute.BASE_CONFIG = os.path.join(PROJECT_ROOT, "cases", "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.

◆ DEFAULT_CONFIG

test_restart_redistribute.DEFAULT_CONFIG = os.path.join(PROJECT_ROOT, "cases", "euler", "euler_default_config.json")

Definition at line 43 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 = os.path.join(PROJECT_ROOT, "data", "mesh", "IV10_20.cgns")

Definition at line 45 of file test_restart_redistribute.py.

◆ MESH_SMALL

test_restart_redistribute.MESH_SMALL = os.path.join(PROJECT_ROOT, "data", "mesh", "IV10_10.cgns")

Definition at line 44 of file test_restart_redistribute.py.

◆ prefix

test_restart_redistribute.prefix

Definition at line 402 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.