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".

Comment on lines +282 to +286
if param_info.project_length_unit is None:
add_validation_warning(
"No project length unit found; `octree_spacing` will not be set automatically. "
"Octree spacing validation will be skipped."
)

Choose a reason for hiding this comment

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

P2 Badge Skip octree missing-unit warning outside beta mesher

This validator emits a warning whenever project_length_unit is absent, even when param_info.is_beta_mesher is False and octree spacing is irrelevant for the legacy mesher. In non-beta validation flows, this introduces a new spurious warning ("octree_spacing ... will not be set automatically") that can pollute validate_params_with_context warning output and force callers/tests to provide a fake project length unit just to keep warning-free runs. The warning/defaulting branch should be gated by beta-mesher context so legacy workflows are unaffected.

Useful? React with 👍 / 👎.

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

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