Evaluate Function at points x. Args: x: Points with shape (num_points, 3) cells: Array with cell indices, with shape (num_points,), where cell[i] is the index of the cell containing point x[i]. If the cell index is negative the point is ig
(
self,
x: npt.ArrayLike,
cells: npt.NDArray[np.int32],
u: None | npt.NDArray[Scalar] = None,
tol: float = 1.0e-6,
maxit: int = 15,
)
| 419 | return self._V |
| 420 | |
| 421 | def eval( |
| 422 | self, |
| 423 | x: npt.ArrayLike, |
| 424 | cells: npt.NDArray[np.int32], |
| 425 | u: None | npt.NDArray[Scalar] = None, |
| 426 | tol: float = 1.0e-6, |
| 427 | maxit: int = 15, |
| 428 | ) -> npt.NDArray[Scalar]: |
| 429 | """Evaluate Function at points x. |
| 430 | |
| 431 | Args: |
| 432 | x: Points with shape (num_points, 3) |
| 433 | cells: Array with cell indices, with shape (num_points,), where |
| 434 | cell[i] is the index of the cell containing point x[i]. |
| 435 | If the cell index is negative the point is ignored. |
| 436 | u: Array to put evaluated data in. |
| 437 | tol: Tolerance for convergence in Newton method for |
| 438 | nonaffine pullbacks. |
| 439 | maxit: Maximum number of Newton iterations for |
| 440 | nonaffine pullbacks. |
| 441 | """ |
| 442 | # Make sure input coordinates are a NumPy array |
| 443 | _x = np.asarray(x, dtype=self._V.mesh.geometry.x.dtype) |
| 444 | assert _x.ndim < 3 |
| 445 | if len(_x) == 0: |
| 446 | _x = np.zeros((0, 3), dtype=self._V.mesh.geometry.x.dtype) |
| 447 | else: |
| 448 | shape0 = _x.shape[0] if _x.ndim == 2 else 1 |
| 449 | _x = np.reshape(_x, (shape0, -1)) |
| 450 | num_points = _x.shape[0] |
| 451 | if _x.shape[1] != 3: |
| 452 | raise ValueError("Coordinate(s) for Function evaluation must have length 3.") |
| 453 | |
| 454 | # Make sure cells are a NumPy array |
| 455 | _cells = np.asarray(cells, dtype=np.int32) |
| 456 | assert _cells.ndim < 2 |
| 457 | num_points_c = _cells.shape[0] if _cells.ndim == 1 else 1 |
| 458 | _cells = np.reshape(_cells, num_points_c) |
| 459 | |
| 460 | # Allocate memory for return value if not provided |
| 461 | if u is None: |
| 462 | value_size = self._V.value_size |
| 463 | u = np.empty((num_points, value_size), self.dtype) |
| 464 | |
| 465 | self._cpp_object.eval(_x, _cells, u, tol, maxit) # type: ignore |
| 466 | if num_points == 1: |
| 467 | u = np.reshape(u, (-1,)) |
| 468 | return u |
| 469 | |
| 470 | def interpolate_nonmatching( |
| 471 | self, |
no outgoing calls