Skip to content

Commit

Permalink
add pressure tensor to quantities proposed by Run
Browse files Browse the repository at this point in the history
also add momentum_tensor to cpp diag tests
  • Loading branch information
nicolasaunai committed Nov 29, 2023
1 parent 87d7425 commit c1939c4
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 122 deletions.
19 changes: 11 additions & 8 deletions pyphare/pyphare/pharesee/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(self, layout, field_name, data, **kwargs):
self.centerings = [kwargs["centering"]]
else:
raise ValueError(
"centering not specified and cannot be inferred from field name"
f"centering not specified and cannot be inferred from field name : {field_name}"
)

if self.field_name != "tags":
Expand Down Expand Up @@ -1262,29 +1262,32 @@ def are_compatible_hierarchies(hierarchies):
def compute_hier_from_(compute, hierarchies):
# check that hierarchies are compatible
# and take the first one as a reference
h = hierarchies[0]
ref_hier = hierarchies[0]

patch_levels = {}
for ilvl in range(h.levelNbr()):
for ilvl in range(ref_hier.levelNbr()):
new_patches = {}
for ip in range(len(h.patch_levels[ilvl].patches)):
for ip in range(len(ref_hier.patch_levels[ilvl].patches)):
patches = [h.patch_levels[ilvl].patches[ip] for h in hierarchies]
patch_datas = {
k: v for p in patches for k, v in list(p.patch_datas.items())
}
new_patch_datas = {}
layout = patches[0].layout # asssume all layouts are the same
datas = compute(patches)
datas = compute(patch_datas)
for data in datas:
pd = FieldData(
layout, data["name"], data["data"], centering=data["centering"]
)
new_patch_datas[data["name"]] = pd
if ilvl not in new_patches:
new_patches[ilvl] = []
patches[ilvl].append(Patch(new_patch_datas, patches[0].id))
new_patches[ilvl].append(Patch(new_patch_datas, patches[0].id))

patch_levels[ilvl] = PatchLevel(ilvl, new_patches[ilvl])

t = list(h.time_hier.keys())[0]
return PatchHierarchy(patch_levels, h.domain_box, refinement_ratio, time=t)
t = list(ref_hier.time_hier.keys())[0]
return PatchHierarchy(patch_levels, ref_hier.domain_box, refinement_ratio, time=t)


def pop_name(basename):
Expand Down
Loading

0 comments on commit c1939c4

Please sign in to comment.