pybFoam.sampling

Pydantic config models plus the sampledSurface / sampledSet factories and interpolationScalar / interpolationVector.

pybFoam.sampling package exports for convenience.

Keep the public API small: import configs in the package namespace so from pybFoam.sampling import SampledPlaneConfig, UniformSetConfig works in examples/tests.

class pybFoam.sampling.ArraySetConfig(*, type: Literal['array'] = 'array', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, pointsDensity: List[int], spanBox: List[float], origin: List[float] | None = None, **extra_data: Any)[source]

Configuration for array (3D grid) sampledSet.

classmethod density_len(v: List[int]) List[int][source]
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

origin: List[float] | None
classmethod origin_len(v: List[float] | None) List[float] | None[source]
pointsDensity: List[int]
spanBox: List[float]
classmethod span_len(v: List[float]) List[float][source]
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

type: Literal['array']
class pybFoam.sampling.CellCentreSetConfig(*, type: Literal['cellCentre'] = 'cellCentre', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, start: List[float], end: List[float], **extra_data: Any)[source]

Configuration for cellCentre sampledSet.

end: List[float]
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod point_len(v: List[float]) List[float][source]
start: List[float]
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

type: Literal['cellCentre']
class pybFoam.sampling.CircleSetConfig(*, type: Literal['circle'] = 'circle', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, origin: List[float], circleAxis: List[float], startPoint: List[float], dTheta: Annotated[float, Gt(gt=0)], **extra_data: Any)[source]

Configuration for circle sampledSet.

circleAxis: List[float]
dTheta: float
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

origin: List[float]
classmethod point_len(v: List[float]) List[float][source]
startPoint: List[float]
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

type: Literal['circle']
class pybFoam.sampling.CloudSetConfig(*, type: Literal['cloud'] = 'cloud', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, points: List[List[float]], **extra_data: Any)[source]

Configuration for cloud (arbitrary points) sampledSet.

model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

points: List[List[float]]
to_foam_dict() dictionary[source]

Return OpenFOAM dictionary object.

type: Literal['cloud']
classmethod validate_points(v: List[List[float]]) List[List[float]][source]
class pybFoam.sampling.FaceOnlySetConfig(*, type: Literal['face', 'faceOnly'] = 'face', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, start: List[float], end: List[float], **extra_data: Any)[source]

Configuration for faceOnly sampledSet.

end: List[float]
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod point_len(v: List[float]) List[float][source]
start: List[float]
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

type: Literal['face', 'faceOnly']
class pybFoam.sampling.MidPointAndFaceSetConfig(*, type: Literal['midPointAndFace'] = 'midPointAndFace', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, start: List[float], end: List[float], **extra_data: Any)[source]

Configuration for midPointAndFace sampledSet.

end: List[float]
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod point_len(v: List[float]) List[float][source]
start: List[float]
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

type: Literal['midPointAndFace']
class pybFoam.sampling.MidPointSetConfig(*, type: Literal['midPoint'] = 'midPoint', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, start: List[float], end: List[float], **extra_data: Any)[source]

Configuration for midPoint sampledSet.

end: List[float]
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod point_len(v: List[float]) List[float][source]
start: List[float]
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

type: Literal['midPoint']
pybFoam.sampling.OUT_OF_MESH: float = 1.7976931348623157e+308

Sentinel value returned by sampleSetScalar / sampleSetVector for sample points that did not land in any cell of the mesh. This mirrors OpenFOAM’s pTraits<scalar>::max (i.e. std::numeric_limits<double>::max()). Any value at least an order of magnitude smaller than this is a real interpolated result.

class pybFoam.sampling.PatchCloudSetConfig(*, type: Literal['patchCloud'] = 'patchCloud', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, patches: str | List[str], points: List[List[float]], maxDistance: Annotated[float | None, Gt(gt=0)] = None, **extra_data: Any)[source]

Configuration for patchCloud sampledSet.

maxDistance: float | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

patches: str | List[str]
classmethod patches_list(v: str | List[str]) str | List[str][source]
points: List[List[float]]
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

type: Literal['patchCloud']
classmethod validate_points(v: List[List[float]]) List[List[float]][source]
class pybFoam.sampling.PatchSeedSetConfig(*, type: Literal['patchSeed'] = 'patchSeed', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, patches: str | List[str], searchDir: List[float], maxDistance: Annotated[float | None, Gt(gt=0)] = None, **extra_data: Any)[source]

Configuration for patchSeed sampledSet.

classmethod dir_len(v: List[float]) List[float][source]
maxDistance: float | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

patches: str | List[str]
classmethod patches_list(v: str | List[str]) str | List[str][source]
searchDir: List[float]
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

type: Literal['patchSeed']
class pybFoam.sampling.PolyLineSetConfig(*, type: Literal['polyLine'] = 'polyLine', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, points: List[List[float]], nPoints: Annotated[int | None, Gt(gt=0)] = None, **extra_data: Any)[source]

Configuration for polyLine (multi-segment) sampledSet.

model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

nPoints: int | None
points: List[List[float]]
to_foam_dict() dictionary[source]

Return OpenFOAM dictionary object.

type: Literal['polyLine']
classmethod validate_points(v: List[List[float]]) List[List[float]][source]
class pybFoam.sampling.SampledCuttingPlaneConfig(*, type: Literal['cuttingPlane'] = 'cuttingPlane', name: str | None = None, planeType: str | None = None, point: List[float] | None = None, origin: List[float] | None = None, normal: List[float] | None = None, offsets: List[float] | None = None, isoMethod: Literal['cell', 'topo', 'point'] | None = None, bounds: List[List[float]] | None = None, zone: str | None = None, zones: List[str] | None = None, regularise: bool | None = None, mergeTol: float | None = None, **extra_data: Any)[source]
bounds: List[List[float]] | None
isoMethod: Literal['cell', 'topo', 'point'] | None
mergeTol: float | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

normal: List[float] | None
classmethod normal_len(v: List[float] | None) List[float] | None[source]
offsets: List[float] | None
origin: List[float] | None
planeType: str | None
point: List[float] | None
classmethod point_len(v: List[float] | None) List[float] | None[source]
regularise: bool | None
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

type: Literal['cuttingPlane']
zone: str | None
zones: List[str] | None
class pybFoam.sampling.SampledCuttingSurfaceConfig(*, type: Literal['cuttingSurface'] = 'cuttingSurface', name: str | None = None, surfaceType: str, surfaceName: str | None = None, triangulate: bool | None = None, bounds: List[List[float]] | None = None, zone: str | None = None, zones: List[str] | None = None, **extra_data: Any)[source]
bounds: List[List[float]] | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

surfaceName: str | None
surfaceType: str
triangulate: bool | None
type: Literal['cuttingSurface']
zone: str | None
zones: List[str] | None
class pybFoam.sampling.SampledDistanceSurfaceConfig(*, type: Literal['distanceSurface'] = 'distanceSurface', name: str | None = None, surfaceType: str, surfaceName: str | None = None, distance: float | None = None, signed: bool | None = None, isoMethod: Literal['cell', 'topo', 'point'] | None = None, regularise: bool | None = None, average: bool | None = None, bounds: List[List[float]] | None = None, topology: str | None = None, **extra_data: Any)[source]
average: bool | None
bounds: List[List[float]] | None
distance: float | None
isoMethod: Literal['cell', 'topo', 'point'] | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

regularise: bool | None
signed: bool | None
surfaceName: str | None
surfaceType: str
topology: str | None
type: Literal['distanceSurface']
class pybFoam.sampling.SampledFaceZoneConfig(*, type: Literal['faceZone', 'faceZones'] = 'faceZone', name: str | None = None, zones: List[str], triangulate: bool | None = None, **extra_data: Any)[source]
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

triangulate: bool | None
type: Literal['faceZone', 'faceZones']
zones: List[str]
class pybFoam.sampling.SampledIsoSurfaceConfig(*, type: Literal['isoSurface'] = 'isoSurface', name: str | None = None, isoField: str, isoValue: float | None = None, isoValues: List[float] | None = None, isoMethod: Literal['cell', 'topo', 'point'] | None = None, average: bool | None = None, bounds: List[List[float]] | None = None, zone: str | None = None, zones: List[str] | None = None, regularise: bool | None = None, triangulate: bool | None = None, mergeTol: float | None = None, **extra_data: Any)[source]
average: bool | None
bounds: List[List[float]] | None
isoField: str
isoMethod: Literal['cell', 'topo', 'point'] | None
isoValue: float | None
isoValues: List[float] | None
mergeTol: float | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

regularise: bool | None
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

triangulate: bool | None
type: Literal['isoSurface']
zone: str | None
zones: List[str] | None
class pybFoam.sampling.SampledMeshedSurfaceConfig(*, type: Literal['meshedSurface'] = 'meshedSurface', name: str | None = None, surface: str | None = None, source: Literal['cells', 'insideCells', 'boundaryFaces'] | None = None, patches: List[str] | None = None, maxDistance: float | None = None, interpolate: bool | None = None, **extra_data: Any)[source]
interpolate: bool | None
maxDistance: float | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

patches: List[str] | None
source: Literal['cells', 'insideCells', 'boundaryFaces'] | None
surface: str | None
type: Literal['meshedSurface']
class pybFoam.sampling.SampledPatchConfig(*, type: Literal['patch'] = 'patch', name: str | None = None, patches: str | List[str], triangulate: bool | None = None, **extra_data: Any)[source]
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

patches: str | List[str]
classmethod patches_list(v: str | List[str]) str | List[str][source]
to_foam_dict() dictionary[source]

Return OpenFOAM dictionary object.

triangulate: bool | None
type: Literal['patch']
class pybFoam.sampling.SampledPatchInternalFieldConfig(*, type: Literal['patchInternalField'] = 'patchInternalField', name: str | None = None, patches: str | List[str], offsetMode: Literal['normal', 'uniform', 'nonuniform'] | None = None, distance: float | None = None, offset: List[float] | None = None, offsets: List[List[float]] | None = None, **extra_data: Any)[source]
distance: float | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

offset: List[float] | None
offsetMode: Literal['normal', 'uniform', 'nonuniform'] | None
offsets: List[List[float]] | None
patches: str | List[str]
type: Literal['patchInternalField']
class pybFoam.sampling.SampledPlaneConfig(*, type: Literal['plane'] = 'plane', name: str | None = None, planeType: str | None = None, point: List[float] | None = None, origin: List[float] | None = None, normal: List[float] | None = None, triangulate: bool | None = None, bounds: List[List[float]] | None = None, zone: str | None = None, zones: List[str] | None = None, **extra_data: Any)[source]
bounds: List[List[float]] | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

normal: List[float] | None
classmethod normal_len(v: List[float] | None) List[float] | None[source]
origin: List[float] | None
planeType: str | None
point: List[float] | None
classmethod point_len(v: List[float] | None) List[float] | None[source]
to_foam_dict() dictionary[source]

Return OpenFOAM dictionary object.

triangulate: bool | None
type: Literal['plane']
zone: str | None
zones: List[str] | None
class pybFoam.sampling.SampledSetBaseConfig(*, type: str, axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, **extra_data: Any)[source]

Base configuration for all sampledSet types.

axis: Literal['x', 'y', 'z', 'xyz', 'distance']
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str | None
type: str
class pybFoam.sampling.SampledSurfaceBaseConfig(*, type: str, name: str | None = None, **extra_data: Any)[source]
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str | None
type: str
class pybFoam.sampling.SampledThresholdCellFacesConfig(*, type: Literal['thresholdCellFaces'] = 'thresholdCellFaces', name: str | None = None, field: str, lowerLimit: float | None = None, upperLimit: float | None = None, triangulate: bool | None = None, **extra_data: Any)[source]
field: str
lowerLimit: float | None
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

triangulate: bool | None
type: Literal['thresholdCellFaces']
upperLimit: float | None
class pybFoam.sampling.UniformSetConfig(*, type: Literal['uniform'] = 'uniform', axis: Literal['x', 'y', 'z', 'xyz', 'distance'], name: str | None = None, start: List[float], end: List[float], nPoints: Annotated[int, Gt(gt=0)], tol: Annotated[float | None, Gt(gt=0)] = None, **extra_data: Any)[source]

Configuration for uniform (straight line) sampledSet.

end: List[float]
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

nPoints: int
classmethod point_len(v: List[float]) List[float][source]
start: List[float]
to_foam_dict() Any[source]

Return OpenFOAM dictionary object.

tol: float | None
type: Literal['uniform']
pybFoam.sampling.dict_to_foam(py_dict: Dict[str, Any]) dictionary[source]

Convert a Python dictionary to an OpenFOAM dictionary object.

This helper converts nested Python dicts and lists into OpenFOAM dictionary objects that can be passed to C++ bindings.

Args:

py_dict: Python dictionary with string keys and various value types

Returns:

OpenFOAM dictionary object

pybFoam.sampling.sampled_set_from(obj: Dict[str, Any] | SampledSetBaseConfig) Dict[str, Any][source]

Normalize input to a plain dict for bindings.

Accepts either a plain dict (returned unchanged) or a Pydantic model (converted).

pybFoam.sampling.sampled_surface_from(obj: Dict[str, Any] | SampledSurfaceBaseConfig) Dict[str, Any][source]

Normalize input to a plain dict for bindings.

Accepts either a plain dict (returned unchanged) or a Pydantic model (converted).