Server-side subsample: extract at most N points from field_data and solution_variable_data (SVARs)

Open
#5,547 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
data

Research direction

Start by tracing SurfaceFieldDataRequest and fields.field_data, then inspect fields.solution_variable_data.get_data and their tests to understand how data is extracted and streamed. The issue proposes optional sampling for both paths, with a configurable size and possibly seed and method; define behavior that returns at most N points while preserving the current full-data default, then verify both extraction paths.

Written by the indexing model from the issue text.

Description

enhancement new feature
❓ Problem statement

For large cases, clients often need only a random (or stratified) sample of N points for downstream work (e.g. ML inference), but today both APIs force a full-zone transfer, then the user must subsample in NumPy.

1. fields.field_data / SurfaceFieldDataRequest (e.g. SurfaceDataType.Vertices)
  • Every requested surface zone returns all vertices.
  • On cases with many wall zones (or very large walls), full extract can be slow, memory-heavy, or destabilize Fluent (e.g. cortex faults) even when only N points are needed afterward.
2. fields.solution_variable_data.get_data (SVARs, e.g. SV_CENTROID)
  • For huge fluid zones (O(1e8) cells), the payload is multi‑GB.
  • In practice the gRPC stream can fail or return incomplete/None-like data, so clients cannot even reach a post-hoc np.random.choice subsample.
Why current behavior is insufficient
  • Over-fetch: API always materializes the full array client-side.
  • No server-side N: there is no first-class n_max / sample_size / stride on these requests.
  • Fragile at scale: full SV_CENTROID for main fluid zones is often the blocker for production workflows that only need a representative sample.

We need the sample to be taken in Fluent (or on the nodes) before/during streaming, not after a successful full download.

To reproduce :

vol = solver.fields.solution_variable_data.get_data(
    variable_name="SV_CENTROID",
    zone_names=[z],
    domain_name=domain,
)[z]
pts = np.asarray(vol).reshape(-1, 3)  # fails or OOMs on huge zones
💡 Proposed solution

Add optional server-side sampling to both extract paths so the client can request at most N points (default: current behavior = all).

A. Field data (surfaces)

Extend SurfaceFieldDataRequest (and/or get_field_data) with something like:

SurfaceFieldDataRequest(
    surfaces=[...],
    data_types=[SurfaceDataType.Vertices],  # and ideally FaceCentroids later
    sample_size=1_000_000,   # or n_max=
    sample_seed=42,          # optional, for reproducibility
    sample_method="random",  # or "stride" / "uniform"
)
Dominant language
Python
Stars
550
Forks
86
Avg merge
2d 1h
Merged PRs (30d)
58

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ansys/pyfluent

All issues in ansys/pyfluent

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.