|
4 | 4 | import subprocess
|
5 | 5 | import numpy as np
|
6 | 6 | import pyphare.pharein as ph
|
7 |
| - |
| 7 | +from pathlib import Path |
8 | 8 |
|
9 | 9 | from pyphare.simulator.simulator import Simulator
|
10 | 10 | from pyphare.pharesee.hierarchy.patchdata import FieldData, ParticleData
|
|
19 | 19 | time_step = 0.001
|
20 | 20 | time_step_nbr = 5
|
21 | 21 | final_time = time_step_nbr * time_step
|
22 |
| -first_mpi_size = 4 |
| 22 | +first_mpi_size = 5 |
23 | 23 | ppc = 100
|
24 | 24 | cells = 200
|
25 |
| -first_out = "phare_outputs/reinit/first" |
| 25 | +first_out = "test_init_from_restart" |
26 | 26 | secnd_out = "phare_outputs/reinit/secnd"
|
27 | 27 | timestamps = np.arange(0, final_time + time_step, time_step)
|
28 | 28 | restart_idx = Z = 2
|
@@ -77,30 +77,8 @@ def test_reinit(self):
|
77 | 77 | self.assertTrue(hierarchy_compare(*ds, atol=1e-12))
|
78 | 78 |
|
79 | 79 |
|
80 |
| -def run_first_sim(): |
81 |
| - """uses params from tests_restarts.py""" |
82 |
| - simput = copy.deepcopy(test_restarts.simArgs) |
83 |
| - simput["restart_options"]["dir"] = first_out |
84 |
| - simput["restart_options"]["timestamps"] = timestamps |
85 |
| - simput["diag_options"]["options"]["dir"] = first_out |
86 |
| - sim = ph.Simulation(**simput) |
87 |
| - dump_all_diags(test_restarts.setup_model().populations, timestamps=timestamps) |
88 |
| - Simulator(sim).run() |
89 |
| - |
90 |
| - |
91 |
| -def launch(): |
92 |
| - """Launch secondary process to run first simulation to avoid initalizing MPI now""" |
93 |
| - |
94 |
| - cmd = f"mpirun -n {first_mpi_size} python3 -O {__file__} lol" |
95 |
| - try: |
96 |
| - p = subprocess.run(cmd.split(" "), check=True, capture_output=True) |
97 |
| - except subprocess.CalledProcessError as e: |
98 |
| - print("CalledProcessError", e) |
99 |
| - |
100 |
| - |
101 | 80 | if __name__ == "__main__":
|
102 |
| - if len(sys.argv) == 1: |
103 |
| - launch() |
| 81 | + if Path("test_init_from_restart").exists(): |
104 | 82 | unittest.main()
|
105 | 83 | else:
|
106 |
| - run_first_sim() |
| 84 | + print("No source data found - see tools/test_data_gen.py ") |
0 commit comments