Skip to content

Commit

Permalink
keep pyattrs on compute_from_hier
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Oct 25, 2024
1 parent 52e733e commit 2558d44
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
9 changes: 5 additions & 4 deletions pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,16 @@ def new_patchdatas_from(compute, patchdatas, layout, id, **kwargs):
def new_patches_from(compute, hierarchies, ilvl, t, **kwargs):
reference_hier = hierarchies[0]
new_patches = []
patch_nbr = len(reference_hier.level(ilvl, time=t).patches)
for ip in range(patch_nbr):
current_patch = reference_hier.level(ilvl, time=t).patches[ip]
ref_patches = reference_hier.level(ilvl, time=t).patches
for ip, current_patch in enumerate(ref_patches):
layout = current_patch.layout
patch_datas = extract_patchdatas(hierarchies, ilvl, t, ip)
new_patch_datas = new_patchdatas_from(
compute, patch_datas, layout, id=current_patch.id, **kwargs
)
new_patches.append(Patch(new_patch_datas, current_patch.id))
new_patches.append(
Patch(new_patch_datas, current_patch.id, attrs=current_patch.attrs)
)
return new_patches


Expand Down
28 changes: 17 additions & 11 deletions tests/simulator/test_run.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
#!/usr/bin/env python3

import numpy as np
from pathlib import Path
import matplotlib as mpl

import pyphare.pharein as ph
from pyphare.cpp import cpp_lib
from pyphare.simulator.simulator import Simulator, startMPI
from pyphare.pharesee.run import Run

import numpy as np

import matplotlib as mpl

mpl.use("Agg")

from pyphare.cpp import cpp_lib
from tests.simulator import SimulatorTest

mpl.use("Agg")

cpp = cpp_lib()
startMPI()

time_step = 0.005
final_time = 0.1
final_time = 0.05
time_step_nbr = int(final_time / time_step)
timestamps = np.arange(0, final_time + 0.01, 0.05)
diag_dir = "phare_outputs/test_run"
Expand Down Expand Up @@ -224,15 +220,25 @@ def test_run(self):
sim = config()
self.register_diag_dir_for_cleanup(diag_dir)
Simulator(sim).run().reset()

run = Run(diag_dir)
B = run.GetB(timestamps[-1], all_primal=False)
self.assertTrue(B.levels()[0].patches[0].attrs)

B = run.GetB(timestamps[-1])
self.assertTrue(B.levels()[0].patches[0].attrs)

if cpp.mpi_rank() == 0:
plot(diag_dir)

for time in timestamps:
for q in ["divb", "Ranks", "N", "jz"]:
assert_file_exists_with_size_at_least(plot_file_for_qty(q, time))

for c in ["x", "y", "z"]:
assert_file_exists_with_size_at_least(plot_file_for_qty(f"b{c}", time))
assert_file_exists_with_size_at_least(
plot_file_for_qty(f"b{c}", time)
)

cpp.mpi_barrier()

Expand Down

0 comments on commit 2558d44

Please sign in to comment.