-
Notifications
You must be signed in to change notification settings - Fork 7
[Tracking] Simulation Interface #253
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
benflexcompute
merged 135 commits into
develop
from
UnderConstruction/SimulationInterface
Aug 2, 2024
Merged
Changes from 133 commits
Commits
Show all changes
135 commits
Select commit
Hold shift + click to select a range
4f102e9
added strucuture and interface for Simulation object (#239)
maciej-flexcompute 1b64d6c
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute a3cacea
API for geometry (#257)
feilin-flexcompute 43c8f26
Populate (almost) all model fields (#254)
benflexcompute 57610b7
Fix PorousMedium example error noticed by YiFan
benflexcompute c930b2d
isort
benflexcompute 7d05cda
add version to surface meshing params (#259)
feilin-flexcompute 28dbe96
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute 79865b6
Fix windows unit test failure because of accessing temp file before c…
benflexcompute 90b7795
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute a88eaac
Merged volumes and surfaces into models to reflect latest design
benflexcompute cfb5ef2
Implement the framework for entities. (#258)
benflexcompute efefa03
[ModelRef] Added Field Definitions for **UserDefinedDynamics** (#271)
benflexcompute 8e944f1
Fix the wrong way of checking exceptions (#276)
benflexcompute c56f91d
Allowing entityList to accept None so the using class can set None de…
benflexcompute 616ae7e
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute 9928fa3
[ModelRef] Added Field Definitions for **Outputs** (#270)
benflexcompute e0736f9
support for pydantic v2 in unit system (#265)
maciej-flexcompute 0204165
Disable Simulation Pylint for now as it is not even finished. (#283)
benflexcompute 8d59a32
[ModelRef] Added Field Definitions for **TimeStepping** (#272)
benflexcompute d3d7a09
Fix bug where time average outputs are not listed (#284)
benflexcompute 28b5df2
Added output format option (#285)
benflexcompute 500443d
[ModelRef] Added Field Definitions for **ReferenceGeometry** (#280)
benflexcompute ec306bc
[ready for review] create surface mesh from geometry id (#262)
feilin-flexcompute 183b436
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute 83426f9
Add preprocess for base model (#281)
yifan-flex 8e5bfe3
[ModelRef] Add Field Definitions for **OperatingCondition** (#275)
yifan-flex af9d86f
[ModelRef] Add Field Definitions for **SurfaceModels** (#274)
yifan-flex dce763f
[ModelRef] Added Field Definitions for **VolumeModels** (#273)
benflexcompute e6c379c
[ModelRef] Add Field Definitions for **MeshingParameters** (#279)
benflexcompute 42fbf2d
Rename volume models: FluidDynamics->Fluid, HeatTransfer->Solid (#288)
yifan-flex 2d8c1fa
Rename and separate FluidMaterialTypes and SolidMaterialTypes (#289)
yifan-flex e86fbd4
Add reference_mach to AerospaceCondition.from_mach (#286)
yifan-flex ffd8425
Deleted unused file (#291)
benflexcompute 16a663a
remove box from enclosed_objects (#292)
benflexcompute 8b275d6
Remove turbulent quantities from outflow (#293)
yifan-flex ffb3191
Fix some field definitions (#287)
benflexcompute 422af43
Unify TranslationallyPeriodic and RotationallyPeriodic (#290)
yifan-flex c0b8701
Correct units for material default (#297)
yifan-flex f96fda1
Added seralizer for SimulationParam (#300)
benflexcompute a65a439
Add cache model serialization (#301)
yifan-flex a8ac05b
Added pylint back (#302)
benflexcompute adefa8e
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute afd8e26
Created pydantic V2 version of the validation service, created tests.…
andrzej-krupka 1df75cb
Unit conversion for simulationParam (#305)
benflexcompute 31a6484
Renames and new meshing part (#306)
benflexcompute c723463
Added _type so translator knows the class (#307)
benflexcompute 723bc36
Translator Utils (#310)
benflexcompute e7f927c
surface mesh translator (#309)
benflexcompute 3fbc2b5
Revert " Added _type so translator knows the class (#307)"
yifan-flex 843f512
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute a95b0d4
Ben y/volume meshing translator (#311)
benflexcompute efe80de
Add solver translator (#312)
yifan-flex 15ecc90
Fixed all the unit test warnings (#315)
benflexcompute 380832d
Enforce 0 warning (#316)
benflexcompute f1871bf
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute 9630ced
Changed turbulent_viscosity_ratio to be positive only (#317)
benflexcompute 60cf99c
Add service functions for translations. (#313)
benflexcompute 6b3307e
Update cached model to store all constructor function arguments (#318)
yifan-flex 7138f3d
construct from geometry to case (#321)
feilin-flexcompute 9fe2bb5
Add BET solver JSON translator (#319)
benflexcompute 2fec29e
fix volume params (#326)
feilin-flexcompute 3fe8d8d
Entity Registry in SimulationParams (#328)
benflexcompute d8825a4
Remove _type attribute (#329)
yifan-flex 4362cc7
Fix linting on python 3.9 (#331)
benflexcompute 2feb4ca
Fix pylint for ALL simulation files. (#330)
benflexcompute 18982eb
Add translator for rotation (#327)
yifan-flex 80a5950
[ServiceIntegration] Add operating condition unit test for the implem…
benflexcompute a67e365
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute 0a05038
Fix merge
benflexcompute 14172f5
Fix model constants (#334)
yifan-flex 49c1e01
Add from_axes for Box entities (#337)
yifan-flex f35d4aa
Maciej/workbench service (#335)
maciej-flexcompute 7483b6a
minor fix on volume mesh JSON translator
maciej-flexcompute c24e328
translator: fixed farfield type format
maciej-flexcompute f98e89c
fixed translator tests
maciej-flexcompute 0278781
added name to uniform refinement
maciej-flexcompute c41cbca
updated schemas
maciej-flexcompute a21dff7
fixed styling
maciej-flexcompute cc13213
added default axis and angle for box
maciej-flexcompute 85c4a51
Prepend zone name to the surface name (#345)
benflexcompute 4f8084c
Merge branch 'develop' into UnderConstruction/SimulationInterface
yifan-flex c73d24b
output translator (#343)
benflexcompute eb64d1f
Removed hash from JSON when deserializing (#346)
benflexcompute 1d0fd2e
Add tranlator for porous media (#339)
yifan-flex a148e4c
updated JSON examples for UI
maciej-flexcompute e8371b0
fixed black
maciej-flexcompute 7e1ebf5
Fixed 500 Reponses (#353)
benflexcompute 3ff1242
Merge remote-tracking branch 'origin/develop' into UnderConstruction/…
benflexcompute 05a0f49
Add AutomatedFarfield (#347)
benflexcompute d9397c9
improved check on unit parser (#351)
maciej-flexcompute ae8a43b
added type discriminator to meshing->volume zones (#356)
maciej-flexcompute 57575bf
Rebased (#352)
benflexcompute 6f504a6
added default meshing to init service (#354)
maciej-flexcompute f633d8a
Added GhostSurface to full name detection and fixed the type name (#358)
benflexcompute a2301ef
added units to actuator disk (#357)
maciej-flexcompute 6aadb50
Work around for inconsistent zone name from meshers (#360)
benflexcompute f87f418
fixed comparing to not None in if statements (#362)
maciej-flexcompute f8b125d
Remove reference geometry default from translator (#359)
yifan-flex 2e06b21
Add actuator disk translator (#361)
yifan-flex f622440
Removed skipping defaults when getting a setting (#365)
benflexcompute 119a789
Added validation of reusing cylinders in meshing (#363)
benflexcompute 60b0813
Merge branch 'develop' into UnderConstruction/SimulationInterface
yifan-flex 81cf0bd
Fix unit tests
yifan-flex d6fe44a
Add CHT and periodic boundary translator (#348)
yifan-flex 20ae144
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute 90635d7
Fix front end JSON validation issues. (#368)
benflexcompute 49acd72
Removed str from EntityList
benflexcompute 1421474
added om6WingWallModel case
0dfcc81
isorted
f716b93
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute 53d6d72
Minor changes to AD validation (#367)
yifan-flex 8b36ef9
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute 7b588c3
Updated Schema (#385)
benflexcompute 6706e9f
Feilin/construction/surface mesh formats (#323)
feilin-flexcompute 0136fa9
Make Slice and Probe entities (#390)
yifan-flex ab9864c
fix surface_mesh.py and upload examples for surface meshing (#389)
feilin-flexcompute 6563b6f
Nasser/move cases (#387)
NasserFlexCompute 63cdbd5
Merge branch 'develop' into UnderConstruction/SimulationInterface
yifan-flex 54489ed
Update unit test ref file hash
yifan-flex c11cb79
Added discriminator for timestepping (#394)
benflexcompute ae362f7
Add discriminator for some single attribute models (#393)
yifan-flex 5e0f768
Rename Probe to ProbeGroup to avoid confusion (#396)
benflexcompute c193fc7
Just Update schema
benflexcompute 8b24218
Fix missing value error in __init__ signature (#398)
benflexcompute 58c1447
New geometry class (#397)
benflexcompute 65ae8bb
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute aeebe7d
Removed unused/unnecessary/outdated examples (#403)
benflexcompute c5b5133
Remove v2 examples as they are not simulation related
benflexcompute d334630
Mistakenly delete too many examples
benflexcompute b3a02b5
Update linting readme instruction and remove footpint of underconstru…
benflexcompute e2bee1e
Comments adddressed
benflexcompute b1c6d0c
Fix all sorts of small JIRA tickets (#401)
benflexcompute 8068bfb
Added StandardAtmosphereModel implementation
benflexcompute 6e0afbc
Fix Lint
benflexcompute File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,4 +325,7 @@ $RECYCLE.BIN/ | |
|
||
tmp/ | ||
|
||
/.vscode | ||
/.vscode | ||
|
||
# test residual | ||
flow360/examples/cylinder2D/flow360mesh.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
3 | ||
1 4000 leftWing | ||
2 4000 fuselage | ||
3 4000 rightWing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Annotated, List, Literal | ||
|
||
import pydantic as pd | ||
import unyt as u | ||
from pydantic import PlainSerializer, PlainValidator | ||
from pydantic_core import core_schema | ||
|
||
|
||
def _has_dimensions(quant, dim): | ||
try: | ||
arg_dim = quant.units.dimensions | ||
except AttributeError: | ||
arg_dim = u.dimensionless | ||
return arg_dim == dim | ||
|
||
|
||
def _unit_object_parser(value, unyt_types: List[type]): | ||
if isinstance(value, dict) and "units" in value: | ||
if "value" in value: | ||
for unyt_type in unyt_types: | ||
try: | ||
return unyt_type(value["value"], value["units"]) | ||
except u.exceptions.UnitParseError: | ||
pass | ||
else: | ||
raise TypeError( | ||
f"Dimensioned type instance {value} expects a 'value' field which was not given" | ||
) | ||
return value | ||
|
||
|
||
def _is_unit_validator(value): | ||
if isinstance(value, str): | ||
try: | ||
value = u.Unit(value) | ||
except u.exceptions.UnitParseError as err: | ||
raise TypeError(str(err)) from err | ||
return value | ||
|
||
|
||
def _unit_array_validator(value, dim): | ||
if not _has_dimensions(value, dim): | ||
if any(_has_dimensions(item, dim) for item in value): | ||
raise TypeError( | ||
f"arg '{value}' has unit provided per component, " | ||
"instead provide dimension for entire array." | ||
) | ||
return value | ||
|
||
|
||
def validate(value): | ||
""" | ||
Validator for unyt value | ||
""" | ||
|
||
value = _unit_object_parser(value, [u.unyt_quantity]) | ||
value = _is_unit_validator(value) | ||
|
||
if isinstance(value, u.Unit): | ||
return 1.0 * value | ||
|
||
return value | ||
|
||
|
||
def serialize(value): | ||
""" | ||
Serializer for unyt value | ||
""" | ||
|
||
return {"value": str(value["data"].value), "units": str(value["data"].units)} | ||
|
||
|
||
class _DimensionedField(pd.BaseModel): | ||
data: u.unyt_quantity = pd.Field() | ||
dim_type: Literal["length"] = pd.Field() | ||
|
||
@classmethod | ||
def validate(cls, value): | ||
""" | ||
Validator for value | ||
""" | ||
|
||
try: | ||
value = _unit_object_parser(value, [u.unyt_quantity]) | ||
except TypeError as err: | ||
raise pd.ValidationError.from_exception_data("validation error", []) | ||
|
||
if isinstance(value, u.Unit): | ||
return {"data": 1.0 * value} | ||
|
||
return {"data": value} | ||
|
||
@classmethod | ||
def __get_pydantic_core_schema__(cls, *args, **kwargs) -> pd.CoreSchema: | ||
return core_schema.no_info_plain_validator_function(cls.validate) | ||
|
||
|
||
DimensionedField = Annotated[ | ||
_DimensionedField, | ||
PlainSerializer(serialize), | ||
] | ||
|
||
|
||
class _OtherField(_DimensionedField): | ||
dim_type: Literal["time"] = pd.Field() | ||
|
||
|
||
OtherField = Annotated[ | ||
_OtherField, | ||
PlainSerializer(serialize), | ||
] | ||
|
||
|
||
class DataModel(pd.BaseModel): | ||
dimensioned_field: OtherField = pd.Field() | ||
|
||
|
||
data = DataModel(dimensioned_field=1 * u.m) | ||
|
||
|
||
data_json = data.model_dump_json(indent=2) | ||
|
||
print(data_json) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
56 changes: 56 additions & 0 deletions
56
examples/geometry_id_surface_volume_case_airplane_v1_from_csm.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
|
||
import flow360 as fl | ||
|
||
fl.Env.preprod.active() | ||
|
||
from flow360.component.geometry_v1 import Geometry | ||
from flow360.component.meshing.params import Farfield, Volume, VolumeMeshingParams | ||
from flow360.examples import Airplane | ||
|
||
# geometry | ||
geometry_draft = Geometry.from_file(Airplane.geometry, name="testing-airplane-csm-geometry") | ||
geometry = geometry_draft.submit() | ||
print(geometry) | ||
|
||
# surface mesh | ||
params = fl.SurfaceMeshingParams(max_edge_length=0.16) | ||
|
||
surface_mesh_draft = fl.SurfaceMesh.create( | ||
geometry_id=geometry.id, | ||
params=params, | ||
name="airplane-surface-mesh-from-geometry-id-v1", | ||
solver_version="mesher-24.2.2", | ||
) | ||
surface_mesh = surface_mesh_draft.submit() | ||
|
||
print(surface_mesh) | ||
|
||
# volume mesh | ||
params = fl.VolumeMeshingParams( | ||
volume=Volume( | ||
first_layer_thickness=1e-5, | ||
growth_rate=1.2, | ||
), | ||
farfield=Farfield(type="auto"), | ||
) | ||
|
||
volume_mesh_draft = fl.VolumeMesh.create( | ||
surface_mesh_id=surface_mesh.id, | ||
name="airplane-volume-mesh-from-geometry-id-v1", | ||
params=params, | ||
solver_version="mesher-24.2.2", | ||
) | ||
volume_mesh = volume_mesh_draft.submit() | ||
print(volume_mesh) | ||
|
||
# case | ||
params = fl.Flow360Params(Airplane.case_json) | ||
params.boundaries = { | ||
"fluid/farfield": fl.FreestreamBoundary(), | ||
"fluid/fuselage": fl.NoSlipWall(), | ||
"fluid/leftWing": fl.NoSlipWall(), | ||
"fluid/rightWing": fl.NoSlipWall(), | ||
} | ||
case_draft = volume_mesh.create_case("airplane-case-from-csm-geometry-id-v1", params) | ||
case = case_draft.submit() |
56 changes: 56 additions & 0 deletions
56
examples/geometry_id_surface_volume_case_airplane_v1_from_egads.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
|
||
import flow360 as fl | ||
|
||
fl.Env.preprod.active() | ||
|
||
from flow360.component.geometry_v1 import Geometry | ||
from flow360.component.meshing.params import Farfield, Volume, VolumeMeshingParams | ||
from flow360.examples import Airplane | ||
|
||
# geometry | ||
geometry_draft = Geometry.from_file( | ||
"data/airplane_geometry.egads", name="testing-airplane-egads-geometry" | ||
) | ||
geometry = geometry_draft.submit() | ||
print(geometry) | ||
|
||
# surface mesh | ||
params = fl.SurfaceMeshingParams(max_edge_length=0.16) | ||
|
||
surface_mesh_draft = fl.SurfaceMesh.create( | ||
geometry_id=geometry.id, | ||
params=params, | ||
name="airplane-surface-mesh-from-geometry-id-v1", | ||
) | ||
surface_mesh = surface_mesh_draft.submit() | ||
|
||
print(surface_mesh) | ||
|
||
# volume mesh | ||
params = fl.VolumeMeshingParams( | ||
volume=Volume( | ||
first_layer_thickness=1e-5, | ||
growth_rate=1.2, | ||
), | ||
farfield=Farfield(type="auto"), | ||
) | ||
|
||
volume_mesh_draft = fl.VolumeMesh.create( | ||
surface_mesh_id=surface_mesh.id, | ||
name="airplane-volume-mesh-from-geometry-id-v1", | ||
params=params, | ||
) | ||
volume_mesh = volume_mesh_draft.submit() | ||
print(volume_mesh) | ||
|
||
# case | ||
params = fl.Flow360Params(Airplane.case_json) | ||
params.boundaries = { | ||
"fluid/farfield": fl.FreestreamBoundary(), | ||
"fluid/fuselage": fl.NoSlipWall(), | ||
"fluid/leftWing": fl.NoSlipWall(), | ||
"fluid/rightWing": fl.NoSlipWall(), | ||
} | ||
case_draft = volume_mesh.create_case("airplane-case-from-egads-geometry-id-v1", params) | ||
case = case_draft.submit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import flow360 as fl | ||
from flow360.component.geometry import Geometry | ||
from flow360.component.simulation import cloud | ||
from flow360.component.simulation.meshing_param.face_params import ( | ||
BoundaryLayer, | ||
SurfaceRefinement, | ||
) | ||
from flow360.component.simulation.meshing_param.params import MeshingParams | ||
from flow360.component.simulation.meshing_param.volume_params import AutomatedFarfield | ||
from flow360.component.simulation.simulation_params import SimulationParams | ||
from flow360.component.simulation.unit_system import SI_unit_system | ||
from flow360.examples import Airplane | ||
|
||
fl.Env.dev.active() | ||
|
||
geometry_draft = Geometry.from_file( | ||
Airplane.geometry, name="testing-airplane-csm-geometry", solver_version="workbench-24.7" | ||
) | ||
geometry = geometry_draft.submit() | ||
with SI_unit_system: | ||
params = SimulationParams( | ||
meshing=MeshingParams( | ||
refinements=[ | ||
SurfaceRefinement(max_edge_length=0.8), | ||
BoundaryLayer(first_layer_thickness=0.8), | ||
], | ||
volume_zones=[AutomatedFarfield()], | ||
), | ||
) | ||
cloud.generate_surface_mesh(geometry, params=params, async_mode=True) | ||
# geometry.generate_volume_mesh(params=params, async_mode=False) | ||
print(geometry._meta_class) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.