Skip to content

Commit cffe740

Browse files
[POC] entire workflow passed
1 parent 67442ae commit cffe740

File tree

10 files changed

+396
-161
lines changed

10 files changed

+396
-161
lines changed

flow360/__init__.py

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -134,51 +134,52 @@
134134
Transformation,
135135
)
136136
from flow360.component.simulation.simulation_params import SimulationParams
137-
from flow360.component.simulation.solver_builtins import (
138-
CD,
139-
CL,
140-
alphaAngle,
141-
bet_omega,
142-
bet_thrust,
143-
bet_torque,
144-
betaAngle,
145-
coordinate,
146-
forceX,
147-
forceY,
148-
forceZ,
149-
kOmega,
150-
momentCenterX,
151-
momentCenterY,
152-
momentCenterZ,
153-
momentLengthX,
154-
momentLengthY,
155-
momentLengthZ,
156-
momentX,
157-
momentY,
158-
momentZ,
159-
mu,
160-
mut,
161-
nodeNormals,
162-
nuHat,
163-
omega,
164-
omegaDot,
165-
physicalStep,
166-
pressureFreestream,
167-
pseudoStep,
168-
residualHeatSolver,
169-
residualNavierStokes,
170-
residualTransition,
171-
residualTurbulence,
172-
solutionHeatSolver,
173-
solutionNavierStokes,
174-
solutionTransition,
175-
solutionTurbulence,
176-
theta,
177-
timeStepSize,
178-
wallFunctionMetric,
179-
wallShearStress,
180-
yPlus,
181-
)
137+
138+
# from flow360.component.simulation.solver_builtins import (
139+
# CD,
140+
# CL,
141+
# alphaAngle,
142+
# bet_omega,
143+
# bet_thrust,
144+
# bet_torque,
145+
# betaAngle,
146+
# coordinate,
147+
# forceX,
148+
# forceY,
149+
# forceZ,
150+
# kOmega,
151+
# momentCenterX,
152+
# momentCenterY,
153+
# momentCenterZ,
154+
# momentLengthX,
155+
# momentLengthY,
156+
# momentLengthZ,
157+
# momentX,
158+
# momentY,
159+
# momentZ,
160+
# mu,
161+
# mut,
162+
# nodeNormals,
163+
# nuHat,
164+
# omega,
165+
# omegaDot,
166+
# physicalStep,
167+
# pressureFreestream,
168+
# pseudoStep,
169+
# residualHeatSolver,
170+
# residualNavierStokes,
171+
# residualTransition,
172+
# residualTurbulence,
173+
# solutionHeatSolver,
174+
# solutionNavierStokes,
175+
# solutionTransition,
176+
# solutionTurbulence,
177+
# theta,
178+
# timeStepSize,
179+
# wallFunctionMetric,
180+
# wallShearStress,
181+
# yPlus,
182+
# )
182183
from flow360.component.simulation.time_stepping.time_stepping import (
183184
AdaptiveCFL,
184185
RampCFL,

flow360/component/simulation/conversion.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,21 @@ def get_base_thermal_conductivity():
342342
base_density * base_length**3 / base_time
343343
)
344344

345+
elif dimension == u.dimensions.mass_flux:
346+
base_density = get_base_density()
347+
base_length = get_base_length()
348+
base_time = get_base_time()
349+
# TODO: Unit test for non-dimensionalize this new unit
350+
flow360_conversion_unit_system.base_mass_flux = base_density * base_length / base_time
351+
352+
elif dimension == u.dimensions.energy_density:
353+
base_density = get_base_density()
354+
base_velocity = get_base_velocity()
355+
# TODO: Unit test for non-dimensionalize this new unit
356+
flow360_conversion_unit_system.base_energy_density = (
357+
base_density * base_velocity * base_velocity
358+
)
359+
345360
elif dimension == u.dimensions.specific_energy:
346361
base_velocity = get_base_velocity()
347362

flow360/component/simulation/outputs/outputs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
Surface,
3838
)
3939
from flow360.component.simulation.unit_system import LengthType
40+
from flow360.component.simulation.user_code import SolverVariable
4041
from flow360.component.simulation.validation.validation_context import (
4142
ALL,
4243
CASE,
@@ -260,7 +261,7 @@ class VolumeOutput(_AnimationAndFileFormatSettings):
260261
"""
261262

262263
name: Optional[str] = pd.Field("Volume output", description="Name of the `VolumeOutput`.")
263-
output_fields: UniqueItemList[Union[VolumeFieldNames, str]] = pd.Field(
264+
output_fields: UniqueItemList[Union[VolumeFieldNames, str, SolverVariable]] = pd.Field(
264265
description="List of output variables. Including :ref:`universal output variables<UniversalVariablesV2>`,"
265266
" :ref:`variables specific to VolumeOutput<VolumeAndSliceSpecificVariablesV2>`"
266267
" and :class:`UserDefinedField`."

flow360/component/simulation/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def _translate_simulation_json(
524524
translated_dict = translation_func(input_params, mesh_unit)
525525
except Flow360TranslationError as err:
526526
raise ValueError(str(err)) from err
527-
except Exception as err: # tranlsation itself is not supposed to raise any other exception
527+
except Exception as err: # translation itself is not supposed to raise any other exception
528528
raise ValueError(
529529
f"Unexpected error translating to {target_name} json: " + str(err)
530530
) from err
Lines changed: 111 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,116 @@
1-
from flow360.component.simulation.user_code import SolverVariable
1+
from flow360.component.simulation.unit_system import *
2+
from flow360.component.simulation.user_code import SolverVariable, VariableComponents
23

3-
mut = SolverVariable(name="fl.mut", value=float("NaN")) # Turbulent viscosity
4-
mu = SolverVariable(name="fl.mu", value=float("NaN")) # Laminar viscosity
4+
# mut = SolverVariable(
5+
# name="fl.mut",
6+
# source_type="Volume",
7+
# components=VariableComponents(sizes=[1], dimensions=[ViscosityType.dim]),
8+
# description="Turbulent viscosity",
9+
# )
10+
# mu = SolverVariable(
11+
# name="fl.mu",
12+
# source_type="Volume",
13+
# components=VariableComponents(sizes=[1], dimensions=[ViscosityType.dim]),
14+
# description="Laminar viscosity",
15+
# )
516
solutionNavierStokes = SolverVariable(
6-
name="fl.solutionNavierStokes", value=float("NaN")
7-
) # Solution for N-S equation in conservative form
17+
name="fl.solutionNavierStokes",
18+
source_type="Volume",
19+
solver_side_name="NavierStokes_solution",
20+
source=None,
21+
components=VariableComponents(
22+
sizes=[1, 3, 1],
23+
dimensions=[DensityType.dim_name, MassFluxType.dim_name, EnergyDensityType.dim_name],
24+
),
25+
description="Solution for N-S equation in conservative form...",
26+
)
27+
828
residualNavierStokes = SolverVariable(
9-
name="fl.residualNavierStokes", value=float("NaN")
10-
) # Residual for N-S equation in conservative form
11-
solutionTurbulence = SolverVariable(
12-
name="fl.solutionTurbulence", value=float("NaN")
13-
) # Solution for turbulence model
14-
residualTurbulence = SolverVariable(
15-
name="fl.residualTurbulence", value=float("NaN")
16-
) # Residual for turbulence model
17-
kOmega = SolverVariable(
18-
name="fl.kOmega", value=float("NaN")
19-
) # Effectively solutionTurbulence when using SST model
20-
nuHat = SolverVariable(
21-
name="fl.nuHat", value=float("NaN")
22-
) # Effectively solutionTurbulence when using SA model
23-
solutionTransition = SolverVariable(
24-
name="fl.solutionTransition", value=float("NaN")
25-
) # Solution for transition model
26-
residualTransition = SolverVariable(
27-
name="fl.residualTransition", value=float("NaN")
28-
) # Residual for transition model
29-
solutionHeatSolver = SolverVariable(
30-
name="fl.solutionHeatSolver", value=float("NaN")
31-
) # Solution for heat equation
32-
residualHeatSolver = SolverVariable(
33-
name="fl.residualHeatSolver", value=float("NaN")
34-
) # Residual for heat equation
35-
coordinate = SolverVariable(name="fl.coordinate", value=float("NaN")) # Grid coordinates
29+
name="fl.residualNavierStokes",
30+
source_type="Volume",
31+
solver_side_name="NavierStokes_residual",
32+
source=None,
33+
components=VariableComponents(sizes=[1, 3, 1], dimensions=["1", "1", "1"]),
34+
description="Residual for N-S equation in conservative form.",
35+
)
36+
37+
# TODO: Revert the comment below and finish conversion
38+
# kOmega = SolverVariable(
39+
# name="fl.kOmega", value=float("NaN")
40+
# ) # Effectively solutionTurbulence when using SST model
41+
# nuHat = SolverVariable(
42+
# name="fl.nuHat", value=float("NaN")
43+
# ) # Effectively solutionTurbulence when using SA model
44+
# solutionTransition = SolverVariable(
45+
# name="fl.solutionTransition", value=float("NaN")
46+
# ) # Solution for transition model
47+
# residualTransition = SolverVariable(
48+
# name="fl.residualTransition", value=float("NaN")
49+
# ) # Residual for transition model
50+
# solutionHeatSolver = SolverVariable(
51+
# name="fl.solutionHeatSolver", value=float("NaN")
52+
# ) # Solution for heat equation
53+
# residualHeatSolver = SolverVariable(
54+
# name="fl.residualHeatSolver", value=float("NaN")
55+
# ) # Residual for heat equation
56+
# coordinate = SolverVariable(name="fl.coordinate", value=float("NaN")) # Grid coordinates
3657

37-
physicalStep = SolverVariable(
38-
name="fl.physicalStep", value=float("NaN")
39-
) # Physical time step, starting from 0
40-
pseudoStep = SolverVariable(
41-
name="fl.pseudoStep", value=float("NaN")
42-
) # Pseudo time step within physical time step
43-
timeStepSize = SolverVariable(name="fl.timeStepSize", value=float("NaN")) # Physical time step size
44-
alphaAngle = SolverVariable(
45-
name="fl.alphaAngle", value=float("NaN")
46-
) # Alpha angle specified in freestream
47-
betaAngle = SolverVariable(
48-
name="fl.betaAngle", value=float("NaN")
49-
) # Beta angle specified in freestream
50-
pressureFreestream = SolverVariable(
51-
name="fl.pressureFreestream", value=float("NaN")
52-
) # Freestream reference pressure (1.0/1.4)
53-
momentLengthX = SolverVariable(
54-
name="fl.momentLengthX", value=float("NaN")
55-
) # X component of momentLength
56-
momentLengthY = SolverVariable(
57-
name="fl.momentLengthY", value=float("NaN")
58-
) # Y component of momentLength
59-
momentLengthZ = SolverVariable(
60-
name="fl.momentLengthZ", value=float("NaN")
61-
) # Z component of momentLength
62-
momentCenterX = SolverVariable(
63-
name="fl.momentCenterX", value=float("NaN")
64-
) # X component of momentCenter
65-
momentCenterY = SolverVariable(
66-
name="fl.momentCenterY", value=float("NaN")
67-
) # Y component of momentCenter
68-
momentCenterZ = SolverVariable(
69-
name="fl.momentCenterZ", value=float("NaN")
70-
) # Z component of momentCenter
58+
# physicalStep = SolverVariable(
59+
# name="fl.physicalStep", value=float("NaN")
60+
# ) # Physical time step, starting from 0
61+
# pseudoStep = SolverVariable(
62+
# name="fl.pseudoStep", value=float("NaN")
63+
# ) # Pseudo time step within physical time step
64+
# timeStepSize = SolverVariable(name="fl.timeStepSize", value=float("NaN")) # Physical time step size
65+
# alphaAngle = SolverVariable(
66+
# name="fl.alphaAngle", value=float("NaN")
67+
# ) # Alpha angle specified in freestream
68+
# betaAngle = SolverVariable(
69+
# name="fl.betaAngle", value=float("NaN")
70+
# ) # Beta angle specified in freestream
71+
# pressureFreestream = SolverVariable(
72+
# name="fl.pressureFreestream", value=float("NaN")
73+
# ) # Freestream reference pressure (1.0/1.4)
74+
# momentLengthX = SolverVariable(
75+
# name="fl.momentLengthX", value=float("NaN")
76+
# ) # X component of momentLength
77+
# momentLengthY = SolverVariable(
78+
# name="fl.momentLengthY", value=float("NaN")
79+
# ) # Y component of momentLength
80+
# momentLengthZ = SolverVariable(
81+
# name="fl.momentLengthZ", value=float("NaN")
82+
# ) # Z component of momentLength
83+
# momentCenterX = SolverVariable(
84+
# name="fl.momentCenterX", value=float("NaN")
85+
# ) # X component of momentCenter
86+
# momentCenterY = SolverVariable(
87+
# name="fl.momentCenterY", value=float("NaN")
88+
# ) # Y component of momentCenter
89+
# momentCenterZ = SolverVariable(
90+
# name="fl.momentCenterZ", value=float("NaN")
91+
# ) # Z component of momentCenter
7192

72-
bet_thrust = SolverVariable(name="fl.bet_thrust", value=float("NaN")) # Thrust force for BET disk
73-
bet_torque = SolverVariable(name="fl.bet_torque", value=float("NaN")) # Torque for BET disk
74-
bet_omega = SolverVariable(name="fl.bet_omega", value=float("NaN")) # Rotation speed for BET disk
75-
CD = SolverVariable(name="fl.CD", value=float("NaN")) # Drag coefficient on patch
76-
CL = SolverVariable(name="fl.CL", value=float("NaN")) # Lift coefficient on patch
77-
forceX = SolverVariable(name="fl.forceX", value=float("NaN")) # Total force in X direction
78-
forceY = SolverVariable(name="fl.forceY", value=float("NaN")) # Total force in Y direction
79-
forceZ = SolverVariable(name="fl.forceZ", value=float("NaN")) # Total force in Z direction
80-
momentX = SolverVariable(name="fl.momentX", value=float("NaN")) # Total moment in X direction
81-
momentY = SolverVariable(name="fl.momentY", value=float("NaN")) # Total moment in Y direction
82-
momentZ = SolverVariable(name="fl.momentZ", value=float("NaN")) # Total moment in Z direction
83-
nodeNormals = SolverVariable(name="fl.nodeNormals", value=float("NaN")) # Normal vector of patch
84-
theta = SolverVariable(name="fl.theta", value=float("NaN")) # Rotation angle of volume zone
85-
omega = SolverVariable(name="fl.omega", value=float("NaN")) # Rotation speed of volume zone
86-
omegaDot = SolverVariable(
87-
name="fl.omegaDot", value=float("NaN")
88-
) # Rotation acceleration of volume zone
89-
wallFunctionMetric = SolverVariable(
90-
name="fl.wallFunctionMetric", value=float("NaN")
91-
) # Wall model quality indicator
92-
wallShearStress = SolverVariable(
93-
name="fl.wallShearStress", value=float("NaN")
94-
) # Wall viscous shear stress
95-
yPlus = SolverVariable(name="fl.yPlus", value=float("NaN")) # Non-dimensional wall distance
93+
# bet_thrust = SolverVariable(name="fl.bet_thrust", value=float("NaN")) # Thrust force for BET disk
94+
# bet_torque = SolverVariable(name="fl.bet_torque", value=float("NaN")) # Torque for BET disk
95+
# bet_omega = SolverVariable(name="fl.bet_omega", value=float("NaN")) # Rotation speed for BET disk
96+
# CD = SolverVariable(name="fl.CD", value=float("NaN")) # Drag coefficient on patch
97+
# CL = SolverVariable(name="fl.CL", value=float("NaN")) # Lift coefficient on patch
98+
# forceX = SolverVariable(name="fl.forceX", value=float("NaN")) # Total force in X direction
99+
# forceY = SolverVariable(name="fl.forceY", value=float("NaN")) # Total force in Y direction
100+
# forceZ = SolverVariable(name="fl.forceZ", value=float("NaN")) # Total force in Z direction
101+
# momentX = SolverVariable(name="fl.momentX", value=float("NaN")) # Total moment in X direction
102+
# momentY = SolverVariable(name="fl.momentY", value=float("NaN")) # Total moment in Y direction
103+
# momentZ = SolverVariable(name="fl.momentZ", value=float("NaN")) # Total moment in Z direction
104+
# nodeNormals = SolverVariable(name="fl.nodeNormals", value=float("NaN")) # Normal vector of patch
105+
# theta = SolverVariable(name="fl.theta", value=float("NaN")) # Rotation angle of volume zone
106+
# omega = SolverVariable(name="fl.omega", value=float("NaN")) # Rotation speed of volume zone
107+
# omegaDot = SolverVariable(
108+
# name="fl.omegaDot", value=float("NaN")
109+
# ) # Rotation acceleration of volume zone
110+
# wallFunctionMetric = SolverVariable(
111+
# name="fl.wallFunctionMetric", value=float("NaN")
112+
# ) # Wall model quality indicator
113+
# wallShearStress = SolverVariable(
114+
# name="fl.wallShearStress", value=float("NaN")
115+
# ) # Wall viscous shear stress
116+
# yPlus = SolverVariable(name="fl.yPlus", value=float("NaN")) # Non-dimensional wall distance

0 commit comments

Comments
 (0)