Skip to content

Commit 8a3d867

Browse files
tested the import_surface_field_and_integral
added example for imported surface trim the path prefix of file_name of imported surface lint update solver version use release-25.7.5 to run workflow using imported surfaces remove solver version from submission
1 parent ba93b74 commit 8a3d867

File tree

6 files changed

+118
-1
lines changed

6 files changed

+118
-1
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import flow360 as fl
2+
from flow360.examples import ObliqueChannel
3+
4+
ObliqueChannel.get_files()
5+
6+
project = fl.Project.from_volume_mesh(
7+
ObliqueChannel.mesh_filename, name="Cartesian channel mesh",
8+
)
9+
10+
volume_mesh = project.volume_mesh
11+
12+
with fl.SI_unit_system:
13+
op = fl.GenericReferenceCondition.from_mach(
14+
mach=0.3,
15+
)
16+
massFlowRate = fl.UserVariable(
17+
name="MassFluxProjected",
18+
value=-1
19+
* fl.solution.density
20+
* fl.math.dot(fl.solution.velocity, fl.solution.node_unit_normal),
21+
)
22+
massFlowRateIntegral = fl.SurfaceIntegralOutput(
23+
name="MassFluxIntegral",
24+
output_fields=[massFlowRate],
25+
surfaces=volume_mesh["VOLUME/LEFT"],
26+
)
27+
params = fl.SimulationParams(
28+
operating_condition=op,
29+
models=[
30+
fl.Fluid(
31+
navier_stokes_solver=fl.NavierStokesSolver(absolute_tolerance=1e-10),
32+
turbulence_model_solver=fl.NoneSolver(),
33+
),
34+
fl.Inflow(
35+
entities=[volume_mesh["VOLUME/LEFT"]],
36+
total_temperature=op.thermal_state.temperature * 1.018,
37+
velocity_direction=(1.0, 0.0, 0.0),
38+
spec=fl.MassFlowRate(
39+
value=op.velocity_magnitude * op.thermal_state.density * (0.2 * fl.u.m**2)
40+
),
41+
),
42+
fl.Outflow(
43+
entities=[volume_mesh["VOLUME/RIGHT"]],
44+
spec=fl.Pressure(op.thermal_state.pressure),
45+
),
46+
fl.SlipWall(
47+
entities=[
48+
volume_mesh["VOLUME/FRONT"],
49+
volume_mesh["VOLUME/BACK"],
50+
volume_mesh["VOLUME/TOP"],
51+
volume_mesh["VOLUME/BOTTOM"],
52+
]
53+
),
54+
],
55+
time_stepping=fl.Steady(),
56+
outputs=[
57+
fl.VolumeOutput(
58+
output_format="paraview",
59+
output_fields=["primitiveVars"],
60+
),
61+
fl.SurfaceOutput(
62+
output_fields=[
63+
fl.solution.velocity,
64+
fl.solution.Cp,
65+
],
66+
surfaces=[
67+
fl.ImportedSurface(
68+
name="normal", file_name=ObliqueChannel.extra["rectangle_normal"]
69+
),
70+
fl.ImportedSurface(
71+
name="oblique", file_name=ObliqueChannel.extra["rectangle_oblique"]
72+
),
73+
],
74+
),
75+
fl.SurfaceIntegralOutput(
76+
name="MassFlowRateImportedSurface",
77+
output_fields=[massFlowRate],
78+
surfaces=[
79+
fl.ImportedSurface(
80+
name="normal", file_name=ObliqueChannel.extra["rectangle_normal"]
81+
),
82+
fl.ImportedSurface(
83+
name="oblique", file_name=ObliqueChannel.extra["rectangle_oblique"]
84+
),
85+
],
86+
),
87+
],
88+
)
89+
project.run_case(params, "test_imported_surfaces_field_and_integral")

flow360/component/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,8 +1446,8 @@ def _run(
14461446

14471447
params.pre_submit_summary()
14481448

1449-
draft.update_simulation_params(params)
14501449
upload_imported_surfaces_to_draft(params, draft, fork_from)
1450+
draft.update_simulation_params(params)
14511451

14521452
if draft_only:
14531453
# pylint: disable=import-outside-toplevel

flow360/component/project_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,3 +480,10 @@ def upload_imported_surfaces_to_draft(params, draft, parent_case):
480480
if file_basename not in parent_existing_imported_file_basenames:
481481
deduplicated_surface_file_paths_to_import.append(file_path_to_import)
482482
draft.upload_imported_surfaces(deduplicated_surface_file_paths_to_import)
483+
484+
if params is not None and params.outputs is not None:
485+
for output in params.outputs:
486+
if isinstance(output, (SurfaceOutput, SurfaceIntegralOutput)):
487+
for surface in output.entities.stored_entities:
488+
if isinstance(surface, ImportedSurface):
489+
surface.file_name = os.path.basename(surface.file_name)

flow360/examples/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .evtol import EVTOL
1111
from .isolated_propeller import IsolatedPropeller
1212
from .monitors import MonitorsAndSlices
13+
from .oblique_channel import ObliqueChannel
1314
from .om6wing import OM6wing
1415
from .quadcopter import Quadcopter
1516
from .rotating_spheres import RotatingSpheres
@@ -50,4 +51,5 @@
5051
"TutorialRANSXv15",
5152
"TutorialUDDForcesMoments",
5253
"Quadcopter",
54+
"ObliqueChannel",
5355
]

flow360/examples/base_test_case.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,6 @@ def get_files(cls):
223223
cls._get_file(cls.url.geometry, cls._geometry_filename)
224224
if hasattr(cls.url, "surface_json"):
225225
cls._get_file(cls.url.surface_json, cls._surface_json)
226+
if hasattr(cls.url, "extra"):
227+
for key, value in cls.url.extra.items():
228+
cls._get_file(value, cls._extra[key])
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Cartesian mesh with oblique boundaries example
3+
"""
4+
5+
from .base_test_case import BaseTestCase
6+
7+
8+
class ObliqueChannel(BaseTestCase):
9+
name = "obliqueChannel"
10+
11+
class url:
12+
mesh = "https://simcloud-public-1.s3.amazonaws.com/examples/obliqueChannel/cartesian_2d_mesh.oblique.cgns"
13+
extra = {
14+
"rectangle_normal": "https://simcloud-public-1.s3.amazonaws.com/examples/obliqueChannel/rectangle_normal.cgns",
15+
"rectangle_oblique": "https://simcloud-public-1.s3.amazonaws.com/examples/obliqueChannel/rectangle_oblique.cgns",
16+
}

0 commit comments

Comments
 (0)