Skip to content

Commit 18a4bbd

Browse files
committed
Handle cases when eta is a list or np.ndarray
1 parent eab6cc5 commit 18a4bbd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

psydac/fem/tensor.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,16 @@ def eval_field( self, field, *eta, weights=None):
208208
if not field.coeffs.ghost_regions_in_sync:
209209
field.coeffs.update_ghost_regions()
210210

211+
# Check if `x` is iterable and loop over elements
212+
if isinstance(eta[0], (list, np.ndarray)):
213+
for dim in range(1, self.ldim):
214+
assert len(eta[0]) == len(eta[dim])
215+
res_list = []
216+
for i in range(len(eta[0])):
217+
x = [eta[j][i] for j in range(self.ldim)]
218+
res_list.append(self.eval_field(field, *x, weights=weights))
219+
return np.array(res_list)
220+
211221
for (x, xlim, space) in zip( eta, self.eta_lims, self.spaces ):
212222

213223
knots = space.knots
@@ -433,7 +443,6 @@ def eval_fields(self, grid, *fields, weights=None, npts_per_cell=None, overlap=0
433443
List of ndarray of floats
434444
List of the evaluated fields.
435445
"""
436-
437446
assert all(f.space is self for f in fields)
438447
for f in fields:
439448
# Necessary if vector coeffs is distributed across processes

0 commit comments

Comments
 (0)