Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions flow360/component/simulation/meshing_param/volume_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,14 @@ class MeshSliceOutput(Flow360BaseModel):
alias="slices",
description="List of output :class:`~flow360.Slice` entities.",
)
include_crinkled_slices: bool = pd.Field(
default=False, description="Generate crinkled slices in addition to flat slices."
)
cutoff_radius: Optional[pd.PositiveFloat] = pd.Field(
default=None,
description="Cutoff radius of the slice output. If not specified, "
"the slice extends to the boundaries of the volume mesh.",
)
output_type: Literal["MeshSliceOutput"] = pd.Field("MeshSliceOutput", frozen=True)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,17 @@ def _get_custom_volumes(volume_zones: list):
return custom_volumes


def translate_mesh_slice_fields(
model: MeshSliceOutput,
):
"""Translate mesh slice type and radius fields."""
mesh_slice_fields = {}
mesh_slice_fields["crinkled"] = model.include_crinkled_slices
if model.cutoff_radius is not None:
mesh_slice_fields["cutoffRadius"] = model.cutoff_radius
return mesh_slice_fields


# def _get_seedpoint_zones(volume_zones: list):
# """
# Get translated seedpoint volumes from volume zones.
Expand All @@ -274,15 +285,15 @@ def _get_custom_volumes(volume_zones: list):

def translate_mesh_slice_output(
output_params: list,
output_class: Union[MeshSliceOutput],
output_class: MeshSliceOutput,
injection_function,
):
"""Translate slice or isosurface output settings."""
"""Translate mesh slice output settings."""
translated_output = {}
translated_output["slices"] = translate_setting_and_apply_to_all_entities(
output_params,
output_class,
translation_func=lambda x: {},
translation_func=translate_mesh_slice_fields,
to_list=False,
entity_injection_func=injection_function,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@
"slices": {
"test_slice_y_normal": {
"sliceOrigin": [0.1, 0.2, 0.3],
"sliceNormal": [0.0, 1.0, 0.0]
"sliceNormal": [0.0, 1.0, 0.0],
"crinkled": false
},
"test_slice_z_normal": {
"sliceOrigin": [0.6, 0.1, 0.4],
"sliceNormal": [0.0, 0.0, 1.0]
"sliceNormal": [0.0, 0.0, 1.0],
"crinkled": false
},
"crinkled_slice_with_cutoff": {
"sliceOrigin": [0.1, 0.2, 0.3],
"sliceNormal": [0.0, 0.7071067811865475, 0.7071067811865475],
"crinkled": true,
"cutoffRadius": 10.0
},
"crinkled_slice_without_cutoff": {
"sliceOrigin": [0.5, 0.6, 0.7],
"sliceNormal": [-1.0, 0.0, 0.0],
"crinkled": true
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@
"slices": {
"test_slice_y_normal": {
"sliceOrigin": [0.1, 0.2, 0.3],
"sliceNormal": [0.0, 1.0, 0.0]
"sliceNormal": [0.0, 1.0, 0.0],
"crinkled": false
},
"test_slice_z_normal": {
"sliceOrigin": [0.6, 0.1, 0.4],
"sliceNormal": [0.0, 0.0, 1.0]
"sliceNormal": [0.0, 0.0, 1.0],
"crinkled": false
},
"crinkled_slice_with_cutoff": {
"sliceOrigin": [0.1, 0.2, 0.3],
"sliceNormal": [0.0, 0.7071067811865475, 0.7071067811865475],
"crinkled": true,
"cutoffRadius": 10.0
},
"crinkled_slice_without_cutoff": {
"sliceOrigin": [0.5, 0.6, 0.7],
"sliceNormal": [-1.0, 0.0, 0.0],
"crinkled": true
}
}
},
Expand Down
67 changes: 50 additions & 17 deletions tests/simulation/translator/test_volume_meshing_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,55 @@ def _make(beta_mesher: bool = True):
)
)

# Build mesh slice outputs
meshSliceOutputs = []
meshSliceOutputs.append(
MeshSliceOutput(
name="slice_output",
entities=[
Slice(
name=f"test_slice_y_normal",
origin=(0.1, 0.2, 0.3),
normal=(0, 1, 0),
),
Slice(
name=f"test_slice_z_normal",
origin=(0.6, 0.1, 0.4),
normal=(0, 0, 1),
),
],
)
)

meshSliceOutputs.append(
MeshSliceOutput(
name="slice_output_2",
entities=[
Slice(
name=f"crinkled_slice_with_cutoff",
origin=(0.1, 0.2, 0.3),
normal=(0, 1, 1),
),
],
include_crinkled_slices=True,
cutoff_radius=10.0,
)
)

meshSliceOutputs.append(
MeshSliceOutput(
name="slice_output_3",
entities=[
Slice(
name=f"crinkled_slice_without_cutoff",
origin=(0.5, 0.6, 0.7),
normal=(-1, 0, 0),
),
],
include_crinkled_slices=True,
)
)

param = SimulationParams(
meshing=MeshingParams(
refinement_factor=1.45,
Expand All @@ -297,23 +346,7 @@ def _make(beta_mesher: bool = True):
),
refinements=refinements,
volume_zones=volume_zones,
outputs=[
MeshSliceOutput(
name="slice_output",
entities=[
Slice(
name=f"test_slice_y_normal",
origin=(0.1, 0.2, 0.3),
normal=(0, 1, 0),
),
Slice(
name=f"test_slice_z_normal",
origin=(0.6, 0.1, 0.4),
normal=(0, 0, 1),
),
],
),
],
outputs=meshSliceOutputs,
),
private_attribute_asset_cache=AssetCache(use_inhouse_mesher=beta_mesher),
)
Expand Down
Loading