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
3 changes: 2 additions & 1 deletion flow360/component/simulation/translator/solver_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,8 @@ def get_solver_json(
udd_dict = dump_dict(udd)
udd_dict_translated = {}
udd_dict_translated["dynamicsName"] = udd_dict.pop("name")
udd_dict_translated["inputVars"] = udd_dict.pop("inputVars", []).sort()
udd_dict_translated["inputVars"] = udd_dict.pop("inputVars", [])
udd_dict_translated["inputVars"].sort()
udd_dict_translated["outputVars"] = udd_dict.pop("outputVars", [])
udd_dict_translated["stateVarsInitialValue"] = udd_dict.pop("stateVarsInitialValue", [])
udd_dict_translated["updateLaw"] = udd_dict.pop("updateLaw", [])
Expand Down
98 changes: 80 additions & 18 deletions tests/simulation/translator/ref/Flow360_boundaries.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
"type": "SubsonicInflow",
"totalTemperatureRatio": 1.0411244143675171,
"totalPressureRatio": 0.9,
"velocityDirection": [1.0,0.0,0.0]
"velocityDirection": [
1.0,
0.0,
0.0
]
},
"boundary_name_B": {
"type": "MassInflow",
"totalTemperatureRatio": 1.0411244143675171,
"massFlowRate": 0.2,
"rampSteps": 10,
"velocityDirection": [0.0,0.0,1.0]
"velocityDirection": [
0.0,
0.0,
1.0
]
},
"boundary_name_E": {
"type": "SubsonicOutflowPressure",
Expand All @@ -26,25 +34,25 @@
"type": "SubsonicOutflowMach",
"MachNumber": 0.3
},
"boundary_name_G" : {
"type" : "NoSlipWall",
"wallVelocityModel" : {
"type" : "SlaterPorousBleed",
"staticPressureRatio" : 0.8165514936615943,
"porosity" : 0.49,
"activationStep" : 20
"boundary_name_G": {
"type": "NoSlipWall",
"wallVelocityModel": {
"type": "SlaterPorousBleed",
"staticPressureRatio": 0.8165514936615943,
"porosity": 0.49,
"activationStep": 20
},
"heatFlux" : 0.0,
"roughnessHeight" : 0.0
"heatFlux": 0.0,
"roughnessHeight": 0.0
},
"boundary_name_I" : {
"type" : "NoSlipWall",
"boundary_name_I": {
"type": "NoSlipWall",
"velocity": [
"0.0 * (z - 3.0) - 0.030773317581937965 * (y - 2.0)",
"0.030773317581937965 * (x - 1.0) - 0.0 * (z - 3.0)",
"0.0 * (z - 3.0) - 0.030773317581937965 * (y - 2.0)",
"0.030773317581937965 * (x - 1.0) - 0.0 * (z - 3.0)",
"0.0 * (y - 2.0) - 0.0 * (x - 1.0)"
],
"heatFlux": 0.0,
"heatFlux": 0.0,
"roughnessHeight": 0.0
}
},
Expand Down Expand Up @@ -97,7 +105,7 @@
"turbulenceModelSolver": {
"CFLMultiplier": 2.0,
"DDES": false,
"ZDES": false,
"ZDES": false,
"absoluteTolerance": 1e-08,
"equationEvalFrequency": 4,
"gridSizeForLES": "maxEdgeLength",
Expand Down Expand Up @@ -127,8 +135,62 @@
"updateJacobianFrequency": 4
},
"userDefinedFields": [],
"userDefinedDynamics": [
{
"constants": {
"Kp": 0.01,
"initialTotalPressureRatio": 1.0,
"massFlowRateTarget": 0.2
},
"dynamicsName": "massInflowController_boundary_name_B",
"inputBoundaryPatches": [
"boundary_name_B"
],
"inputVars": [
"area",
"hasSupersonicFlow",
"massFlowRate"
],
"outputTargetName": "boundary_name_B",
"outputVars": {
"totalPressureRatio": "(pseudoStep > 0) ? (state[0]) : (initialTotalPressureRatio);"
},
"stateVarsInitialValue": [
"initialTotalPressureRatio"
],
"updateLaw": [
"(hasSupersonicFlow and massFlowRate > 0) ? ((1.0 - Kp) * state[0]) : (state[0] - Kp * (massFlowRate/area - massFlowRateTarget/area));"
]
},
{
"constants": {
"Kp": 0.01,
"initialStaticPressureRatio": 1.0,
"massFlowRateTarget": 0.2
},
"dynamicsName": "massOutflowController_boundary_name_H",
"inputBoundaryPatches": [
"boundary_name_H"
],
"inputVars": [
"area",
"hasSupersonicFlow",
"massFlowRate"
],
"outputTargetName": "boundary_name_H",
"outputVars": {
"staticPressureRatio": "(pseudoStep > 0) ? (state[0]) : (initialStaticPressureRatio);"
},
"stateVarsInitialValue": [
"initialStaticPressureRatio"
],
"updateLaw": [
"(hasSupersonicFlow and massFlowRate > 0) ? ((1.0 + Kp) * state[0]) : (state[0] + Kp * (massFlowRate/area - massFlowRateTarget/area));"
]
}
],
"usingLiquidAsMaterial": false,
"outputRescale": {
"velocityScale": 1.0
}
}
}
4 changes: 1 addition & 3 deletions tests/simulation/translator/test_solver_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ def translate_and_compare(
if debug:
print("=== translated ===\n", json.dumps(translated, indent=4, sort_keys=True))
print("=== ref_dict ===\n", json.dumps(ref_dict, indent=4, sort_keys=True))
assert compare_values(
ref_dict, translated, atol=atol, rtol=rtol, ignore_keys="userDefinedDynamics"
)
assert compare_values(ref_dict, translated, atol=atol, rtol=rtol)


def test_om6wing_tutorial(get_om6Wing_tutorial_param):
Expand Down
Loading