Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rochSmets committed Jan 15, 2024
1 parent a955eb2 commit 2a94080
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 57 deletions.
68 changes: 12 additions & 56 deletions pyphare/pyphare/core/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
from pyphare.pharesee.hierarchy import ScalarField, VectorField#, TensorField


# TODO commencer par calculer z=hier*hier puis racine caree du dataset
def _compute_dot_product(patchdatas, **kwargs):

pd_attrs = []

return tuple(pd_attrs)


def dot(hier_a, hier_b):

# doit utiliser un compute_hier_from

return hier_a


def sqrt(hier):
Expand Down Expand Up @@ -48,59 +59,4 @@ def modulus(hier):



def sqrt_old(hierarchy):

"""
returns a Hierarchy of the same type of the input (which can be
ScalarField, VectorField or Tensor2Field) containing the square root
of each dataset
"""

patch_levels = hierarchy.patch_levels
domain_box = hierarchy.domain_box

num_of_components = len(hierarchy.levels()[0].patches[0].patch_datas.keys())

if num_of_components == 1:
names = ['value']
elif num_of_components == 3:
names = ['x', 'y', 'z']
elif num_of_components == 6:
names = ['xx', 'xy', 'xz', 'yy', 'yz', 'zz']
elif num_of_components == 9:
names = ['xx', 'xy', 'xz', 'yx', 'yy', 'yz', 'zx', 'zy', 'zz']


for time in list(hierarchy.time_hier.keys()):
new_patch_level = {}

for ilvl, lvl in hierarchy.levels(time).items():
new_patches = {}

for patch in lvl.patches:
new_pd = {}
layout = patch.layout

num_of_components = len(patch.patch_datas.keys())

for (name, pd_name) in zip(names, patch.patch_datas.keys()):
dset = np.sqrt(np.asarray(patch.patch_datas[pd_name].dataset))

pd = FieldData(layout, name, dset, centering=patch.patch_datas[pd_name].centerings)
new_pd[name] = pd

if ilvl not in new_patches:
new_patches[ilvl] = []

new_patches[ilvl].append(Patch(new_pd, patch.id))

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

if num_of_components == 1:
return ScalarField(new_patch_level, domain_box, time=time)
if num_of_components == 3:
return VectorField(new_patch_level, domain_box, time=time)
if num_of_components == 6 or num_of_components == 9:
return Tensor2Field(new_patch_level, domain_box, time=time)

2 changes: 1 addition & 1 deletion pyphare/pyphare/pharesee/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def __init__(self, patch_levels, domain_box, **kwargs):
time = kwargs.get("time", .0)
data_files = kwargs.get("data_files", None)

self.name = ['scalar'] # TODO should we use the static name ?
# self.name = ['scalar'] # TODO should we use the static name ?

super().__init__(patch_levels, domain_box, refinement_ratio, time, data_files)

Expand Down

0 comments on commit 2a94080

Please sign in to comment.