Skip to content

Commit

Permalink
Remove merging props in interpolator.
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavmuta authored and prabhuramachandran committed May 22, 2020
1 parent 5882e20 commit 7402819
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 5 additions & 16 deletions pysph/tools/interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ def interpolate(self, prop, comp=0):
"""
assert isinstance(comp, int), 'Error: only interger value is allowed'
for array in self.particle_arrays:
data = array.get(prop, only_real_particles=False)
if prop not in array.properties:
data = 0.0
else:
data = array.get(prop, only_real_particles=False)

array.get('temp_prop', only_real_particles=False)[:] = data

self.func_eval.compute(0.0, 0.1) # These are junk arguments.
Expand Down Expand Up @@ -463,25 +467,10 @@ def _get_max_h_in_arrays(self):

def _set_particle_arrays(self, particle_arrays):
self.particle_arrays = particle_arrays
self._make_all_arrays_have_same_props(particle_arrays)
for array in self.particle_arrays:
if 'temp_prop' not in array.properties:
array.add_property('temp_prop')

def _make_all_arrays_have_same_props(self, particle_arrays):
"""Make sure all arrays have the same props.
"""
all_props = reduce(
set.union, [set(x.properties.keys()) for x in particle_arrays]
)
for array in particle_arrays:
all_props.update(array.properties.keys())

for array in particle_arrays:
array_props = set(array.properties.keys())
for prop in (all_props - array_props):
array.add_property(prop)


def main(fname, prop, npoint):
from pysph.solver.utils import load
Expand Down
2 changes: 1 addition & 1 deletion pysph/tools/tests/test_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def test_should_correctly_update_domain(self):
def test_should_work_when_arrays_have_different_props(self):
# Given
pa1 = self._make_2d_grid()
pa1.add_property('junk', default=2.0)
pa1.add_property('junk', default=2.0, type='int')
pa2 = self._make_2d_grid('solid')

# When.
Expand Down

0 comments on commit 7402819

Please sign in to comment.