Skip to content

Commit

Permalink
fix(): Removing order of accuracy for steady time stepping (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
benflexcompute authored Dec 4, 2024
1 parent ba16a55 commit 600fe4c
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 20 deletions.
14 changes: 3 additions & 11 deletions flow360/component/simulation/time_stepping/time_stepping.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Time stepping setting for simulation"""

from abc import ABCMeta
from typing import Literal, Optional, Union

import pydantic as pd
Expand Down Expand Up @@ -87,15 +86,7 @@ def default_steady(cls):
return cls(max=1e4, convergence_limiting_factor=0.25, max_relative_change=1)


class BaseTimeStepping(Flow360BaseModel, metaclass=ABCMeta):
"""
Base class for time stepping component
"""

order_of_accuracy: Literal[1, 2] = pd.Field(2)


class Steady(BaseTimeStepping):
class Steady(Flow360BaseModel):
"""
:class:`Steady` class for specifying steady simulation.
"""
Expand Down Expand Up @@ -123,7 +114,7 @@ def set_default_cfl(cls, values):
return values


class Unsteady(BaseTimeStepping):
class Unsteady(Flow360BaseModel):
"""
:class:`Unsteady` class for specifying unsteady simulation.
"""
Expand All @@ -140,6 +131,7 @@ class Unsteady(BaseTimeStepping):
default=AdaptiveCFL.default_unsteady(),
description="CFL settings within each physical step.",
)
order_of_accuracy: Literal[1, 2] = pd.Field(2, description="Temporal order of accuracy.")

@pd.model_validator(mode="before")
@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ def get_solver_json(
translated["timeStepping"] = {
"CFL": dump_dict(ts.CFL),
"physicalSteps": 1,
"orderOfAccuracy": ts.order_of_accuracy,
"orderOfAccuracy": 2, # Solver always want to read this even if it is steady... Setting dummy value here.
"maxPseudoSteps": ts.max_steps,
"timeStepSize": "inf",
}
Expand Down
1 change: 0 additions & 1 deletion tests/ref/simulation/service_init_geometry.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@
}
],
"time_stepping": {
"order_of_accuracy": 2,
"type_name": "Steady",
"max_steps": 2000,
"CFL": {
Expand Down
1 change: 0 additions & 1 deletion tests/ref/simulation/service_init_volume_mesh.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@
}
],
"time_stepping": {
"order_of_accuracy": 2,
"type_name": "Steady",
"max_steps": 2000,
"CFL": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@
"type": "adaptive"
},
"max_steps": 2000,
"order_of_accuracy": 2,
"type_name": "Steady"
},
"unit_system": {
Expand Down
1 change: 0 additions & 1 deletion tests/simulation/service/simulation_param.json
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@
"type": "adaptive"
},
"max_steps": 2000,
"order_of_accuracy": 2,
"type_name": "Steady"
},
"unit_system": {
Expand Down
3 changes: 0 additions & 3 deletions tests/simulation/service/test_services_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def test_validate_service():
"area": {"value": 1.0, "units": "m**2"},
},
"time_stepping": {
"order_of_accuracy": 2,
"type_name": "Steady",
"max_steps": 10,
"CFL": {"type": "ramp", "initial": 1.5, "final": 1.5, "ramp_steps": 5},
Expand Down Expand Up @@ -136,7 +135,6 @@ def test_validate_error():
"area": {"value": 1.0, "units": "m**2"},
},
"time_stepping": {
"order_of_accuracy": 2,
"type_name": "Steady",
"max_steps": 10,
"CFL": {"type": "ramp", "initial": 1.5, "final": 1.5, "ramp_steps": 5},
Expand Down Expand Up @@ -202,7 +200,6 @@ def test_validate_multiple_errors():
"area": {"value": -10.0, "units": "m**2"},
},
"time_stepping": {
"order_of_accuracy": 2,
"type_name": "Steady",
"max_steps": 10,
"CFL": {"type": "ramp", "initial": 1.5, "final": 1.5, "ramp_steps": 5},
Expand Down
1 change: 0 additions & 1 deletion tests/simulation/service/test_translator_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ def test_simulation_to_case_json():
"CFL": {"final": 200.0, "initial": 5.0, "ramp_steps": 40, "type": "ramp"},
"max_steps": 2000,
"type_name": "Steady",
"order_of_accuracy": 2,
},
"user_defined_fields": [
{
Expand Down

0 comments on commit 600fe4c

Please sign in to comment.