kipe.fenicsx.points module

Spatial sampler at points: fenicsx.points.

PointSampler evaluates a field of the solver at given points. Its entries are in the order of the points; for a vector field, the components of each point one after another. This order is fixed by the study file, so the data do not depend on the number of ranks (see kipe.sampling).

A small, complete sampler: the how-to “Write a spatial sampler” in the documentation walks through it.

class kipe.fenicsx.points.PointSampler(field: str, source: dolfinx.fem.FunctionSpace, points: list[list[float]], comm: mpi4py.MPI.Comm = mpi4py.MPI.COMM_WORLD)[source]

Bases: SpatialSampler

Evaluates a field at given points.

Each point is evaluated by one rank: the lowest rank that owns a cell containing it. A point on the boundary between the cells of two ranks lies in cells of both.

Parameters:
  • field – name of the observed field

  • source – the field’s function space, on the solver’s mesh

  • points – coordinates of the points, one row per point

  • comm – communicator of the run

Raises:

StudyFileError – if the points do not have the coordinates of the mesh’s dimension, or a point lies outside the mesh

sample(fields: Mapping[str, NDArray_f64]) → NDArray_f64[source]

Evaluate the field at this rank’s points.

Parameters:

fields – the observed state field, this rank’s owned degrees of freedom

Returns:

the values at this rank’s points (a new array), at the positions global_indices

kipe.fenicsx.points.build_point_sampler(options: PointSamplingOptions, fields: list[str], solver: ForwardSolver, comm: mpi4py.MPI.Comm = mpi4py.MPI.COMM_WORLD) → PointSampler[source]

Construct a PointSampler from the spatial_sampling options of a measurement.

Parameters:
  • options – spatial_sampling options of the measurement

  • fields – names of the fields the measurement observes; exactly one

  • solver – the forward solver, which provides the field’s function space

  • comm – communicator of the run

Returns:

the sampler