Skip to content

Commit d08ca66

Browse files
committed
Updated eval_field_gradient to handle cases where x is an array
1 parent 58a7b7a commit d08ca66

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

psydac/fem/tensor.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,16 @@ def eval_field_gradient(self, field, *eta, weights=None):
618618
bases_1 = []
619619
index = []
620620

621+
# Check if `x` is iterable and loop over elements
622+
if isinstance(eta[0], (list, np.ndarray)) and np.ndim(eta[0]) > 0:
623+
for dim in range(1, self.ldim):
624+
assert len(eta[0]) == len(eta[dim])
625+
res_list = []
626+
for i in range(len(eta[0])):
627+
x = [eta[j][i] for j in range(self.ldim)]
628+
res_list.append(self.eval_field_gradient(field, *x, weights=weights))
629+
return np.array(res_list)
630+
621631
for (x, xlim, space) in zip( eta, self.eta_lims, self.spaces ):
622632

623633
knots = space.knots

0 commit comments

Comments
 (0)