Skip to content

Comments

Octree base spacing for volume mesh#1807

Open
shreyas-flex wants to merge 5 commits intomainfrom
shreyas/octree-base-spacing-for-volume-mesh
Open

Octree base spacing for volume mesh#1807
shreyas-flex wants to merge 5 commits intomainfrom
shreyas/octree-base-spacing-for-volume-mesh

Conversation

@shreyas-flex
Copy link
Contributor

@shreyas-flex shreyas-flex commented Feb 12, 2026

  • Extends the octree base spacing functionality to non-snappy meshing workflow.
  • Now, validation will emit warnings if their spacings are not aligned with available octree spacings. (available spacings = 2**n * base_spacing for some integer n).
  • When base_spacing is not defined, it is defaulted to project unit after flow360.MeshingDefaults is constructed.

WIP:

  • unit testing
  • how to handle missing project unit

Note

Medium Risk
Touches meshing parameter validation and translation output (including emitted JSON), which can change runtime mesher behavior and produce new warnings, but is largely additive and backward-compatible via aliasing.

Overview
Adds first-class octree_spacing support to the non-snappy (volume) meshing workflow by introducing an OctreeSpacing config on MeshingDefaults/VolumeMeshingDefaults, defaulting it from project_length_unit when available and warning when missing.

Renames snappy’s base_spacing input to octree_spacing (keeps backward-compatible alias + deprecation warning), updates translators to consume the new field, and propagates octreeBaseSpacing into the volume mesher farfield JSON when using the in-house mesher.

Adds beta-mesher validation that warns when UniformRefinement.spacing is not aligned to the octree power-of-2 spacing series, and expands unit tests/fixtures and golden JSON accordingly (including ensuring AssetCache carries project_length_unit).

Written by Cursor Bugbot for commit d071510. This will update automatically on new commits. Configure here.

@benflexcompute benflexcompute marked this pull request as ready for review February 19, 2026 16:57
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9e405ba79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

if isinstance(refinement, UniformRefinement):
check_spacing(refinement.spacing, type(refinement).__name__)

return self
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated validator logic across two class pairs

Low Severity

The _check_sizing_against_octree_series method (including the inner check_spacing closure) is copy-pasted between MeshingParams and VolumeMeshingParams — only the warning message string differs. Similarly, _set_default_octree_spacing is identically duplicated between MeshingDefaults and VolumeMeshingDefaults. The check_spacing logic also closely mirrors the one in snappy's _check_sizing_against_octree_series. A shared utility (or a method on OctreeSpacing itself) would eliminate these three copies, reducing the risk of inconsistent bug fixes.

Additional Locations (2)

Fix in Cursor Fix in Web

Comment on lines +50 to +52
octree_spacing: Optional[OctreeSpacing] = pd.Field(
None, validation_alias=AliasChoices("octree_spacing", "base_spacing")
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not
octree_spacing: Optional[OctreeSpacing] = pd.Field( None, alias="base_spacing") )

refinements: Optional[List[SnappySurfaceRefinementTypes]] = pd.Field(None)
base_spacing: Optional[OctreeSpacing] = pd.Field(None)
octree_spacing: Optional[OctreeSpacing] = pd.Field(
None, validation_alias=AliasChoices("octree_spacing", "base_spacing")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validation_alias = "base_spacing" 

Is good enough?


@pd.model_validator(mode="before")
@classmethod
def _project_spacing_to_object(cls, input_data):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC I had a comment when Snappy introduces this function. I understand this provides convenience but at the same time introduces inhomogeneity on interface.

Personally it is more of a burden/annoyance to me remembering here I have a shortcut OctreeSpacing(1*u.mm) than just typing "base_spacing = " like everywhere else.

I wish we can get rid of this before it goes public. CC:@piotrkluba

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it provide inhomogeneity? The goal was for the user to be able to specify the spacing with The OctreeSpacing object as well as a simple length value. For me its an extension of the interface for convenience

Copy link
Collaborator

@benflexcompute benflexcompute Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is an extension but it is an extension that does provide an interface different than other places (albeit we did introduce something similar like this elsewhere early stage which I regret now).

The inhomogeneity is because now we support OctreeSpacing(1*u.mm) which is not the same with any other Pydantic model (Class(field_name1=value1, field_name2=value2, ...)).

Supporting one-off interface like this may bring us trouble in the future when there is change for this model. For example let's say we add a min_spacing field. Then in this spirit do we ask customer to write OctreeSpacing(1*u.mm, 0.1*u.mm)?

For anyone that uses IDE, the IDE will not prompt you this shortcut usage so we need to spend effort educate user that for this particular class and for only this class you can actually skip base_spacing. Otherwise this seems more like an internal knowledge providing convenience just for us developers not customers. BTW for most people using IDE they just type "b" and tab and the base_spacing should be completed by IDE anyway.

I am fine if there is customer push back saying they just hate typing/seeing "base_spacing" but until then let's just support one single interface like everywhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants