Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep pyattrs on compute_from_hier #919

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading