Skip to content

Hotfix for the boundary_spec_translator #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 24, 2024
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
7 changes: 7 additions & 0 deletions flow360/component/simulation/translator/solver_translator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Flow360 solver setting parameter translator."""

# pylint: disable=too-many-lines
from typing import Type, Union

from flow360.component.simulation.framework.entity_base import EntityList
Expand Down Expand Up @@ -656,6 +657,9 @@ def boundary_spec_translator(model: SurfaceModelTypes, op_acousitc_to_static_pre
elif isinstance(model.spec, MassFlowRate):
boundary["type"] = "MassInflow"
boundary["massFlowRate"] = model_dict["spec"]["value"]
if model.turbulence_quantities is not None:
boundary["turbulenceQuantities"] = model_dict["turbulenceQuantities"]
replace_dict_key(boundary["turbulenceQuantities"], "typeName", "modelType")
elif isinstance(model, Outflow):
if isinstance(model.spec, Pressure):
boundary["type"] = "SubsonicOutflowPressure"
Expand All @@ -678,6 +682,9 @@ def boundary_spec_translator(model: SurfaceModelTypes, op_acousitc_to_static_pre
boundary["type"] = "Freestream"
if model.velocity is not None:
boundary["velocity"] = list(model_dict["velocity"])
if model.turbulence_quantities is not None:
boundary["turbulenceQuantities"] = model_dict["turbulenceQuantities"]
replace_dict_key(boundary["turbulenceQuantities"], "typeName", "modelType")
elif isinstance(model, SymmetryPlane):
boundary["type"] = "SymmetryPlane"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"boundaries": {
"1": {
"type": "NoSlipWall"
},
"2": {
"type": "SlipWall"
},
"3": {
"turbulenceQuantities": {
"modelType": "ModifiedTurbulentViscosityRatio",
"modifiedTurbulentViscosityRatio": 10.0
},
"type": "Freestream"
}
},
"freestream": {
"Mach": 0.8399999999999999,
"Temperature": 288.15,
"alphaAngle": 3.06,
"betaAngle": 0.0,
"muRef": 5.326121165140212e-08
},
"geometry": {
"momentCenter": [
0.0,
0.0,
0.0
],
"momentLength": [
0.801672958512342,
0.801672958512342,
0.801672958512342
],
"refArea": 1.1529999999999987
},
"navierStokesSolver": {
"CFLMultiplier": 1.0,
"absoluteTolerance": 1e-10,
"equationEvalFrequency": 1,
"kappaMUSCL": -1.0,
"limitPressureDensity": false,
"limitVelocity": false,
"linearSolver": {
"maxIterations": 25
},
"lowMachPreconditioner": false,
"maxForceJacUpdatePhysicalSteps": 0,
"modelType": "Compressible",
"numericalDissipationFactor": 1.0,
"orderOfAccuracy": 2,
"relativeTolerance": 0.0,
"updateJacobianFrequency": 4
},
"sliceOutput": {
"animationFrequency": -1,
"animationFrequencyOffset": 0,
"animationFrequencyTimeAverage": -1,
"animationFrequencyTimeAverageOffset": 0,
"computeTimeAverages": false,
"outputFields": [],
"outputFormat": "tecplot",
"slices": {
"sliceName_1": {
"outputFields": [
"primitiveVars",
"vorticity",
"T",
"s",
"Cp",
"mut",
"mutRatio",
"Mach"
],
"sliceNormal": [
0.0,
1.0,
0.0
],
"sliceOrigin": [
0.0,
0.7000000000000001,
0.0
]
}
},
"startAverageIntegrationStep": -1
},
"surfaceOutput": {
"animationFrequency": -1,
"animationFrequencyOffset": 0,
"animationFrequencyTimeAverage": -1,
"animationFrequencyTimeAverageOffset": 0,
"computeTimeAverages": false,
"outputFields": [],
"outputFormat": "paraview",
"startAverageIntegrationStep": -1,
"surfaces": {
"1": {
"outputFields": [
"nuHat"
]
},
"2": {
"outputFields": [
"nuHat"
]
},
"3": {
"outputFields": [
"nuHat"
]
}
},
"writeSingleFile": false
},
"timeStepping": {
"CFL": {
"final": 200.0,
"initial": 5.0,
"rampSteps": 40,
"type": "ramp"
},
"maxPseudoSteps": 2000,
"orderOfAccuracy": 2,
"physicalSteps": 1,
"timeStepSize": "inf"
},
"turbulenceModelSolver": {
"CFLMultiplier": 2.0,
"DDES": false,
"absoluteTolerance": 1e-08,
"equationEvalFrequency": 4,
"gridSizeForLES": "maxEdgeLength",
"linearSolver": {
"maxIterations": 15
},
"maxForceJacUpdatePhysicalSteps": 0,
"modelConstants": {
"C_DES": 0.72,
"C_cb1": 0.1355,
"C_cb2": 0.622,
"C_d": 8.0,
"C_min_rd": 10.0,
"C_sigma": 0.6666666666666666,
"C_t3": 1.2,
"C_t4": 0.5,
"C_v1": 7.1,
"C_vonKarman": 0.41,
"C_w2": 0.3
},
"modelType": "SpalartAllmaras",
"orderOfAccuracy": 2,
"quadraticConstitutiveRelation": false,
"reconstructionGradientLimiter": 0.5,
"relativeTolerance": 0.0,
"rotationCorrection": false,
"updateJacobianFrequency": 4
},
"volumeOutput": {
"animationFrequency": -1,
"animationFrequencyOffset": 0,
"animationFrequencyTimeAverage": -1,
"animationFrequencyTimeAverageOffset": 0,
"computeTimeAverages": false,
"outputFields": [
"primitiveVars",
"residualNavierStokes",
"residualTurbulence",
"Mach"
],
"outputFormat": "paraview",
"startAverageIntegrationStep": -1
}
}
10 changes: 10 additions & 0 deletions tests/simulation/translator/test_solver_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
SlipWall,
Wall,
)
from flow360.component.simulation.models.turbulence_quantities import (
TurbulenceQuantities,
)
from flow360.component.simulation.models.volume_models import Fluid
from flow360.component.simulation.operating_condition.operating_condition import (
AerospaceCondition,
Expand Down Expand Up @@ -171,6 +174,13 @@ def test_om6wing_tutorial(get_om6Wing_tutorial_param):

def test_om6wing_with_specified_freestream_BC(get_om6Wing_tutorial_param):
params = get_om6Wing_tutorial_param
params.models[3].turbulence_quantities = TurbulenceQuantities(modified_viscosity_ratio=10)
translate_and_compare(
get_om6Wing_tutorial_param,
mesh_unit=0.8059 * u.m,
ref_json_file="Flow360_om6wing_FS_with_turbulence_quantities.json",
)
params.models[3].turbulence_quantities = None
params.models[3].velocity = (01.0, 10.0, 0.0) * u.m / u.s
translate_and_compare(
get_om6Wing_tutorial_param,
Expand Down
Loading