Skip to content
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

add examples for submitting assemblies and parts #381

Closed
wants to merge 114 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
4f102e9
added strucuture and interface for Simulation object (#239)
maciej-flexcompute May 1, 2024
1b64d6c
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 8, 2024
a3cacea
API for geometry (#257)
feilin-flexcompute May 14, 2024
43c8f26
Populate (almost) all model fields (#254)
benflexcompute May 15, 2024
57610b7
Fix PorousMedium example error noticed by YiFan
benflexcompute May 15, 2024
c930b2d
isort
benflexcompute May 15, 2024
7d05cda
add version to surface meshing params (#259)
feilin-flexcompute May 15, 2024
28dbe96
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 17, 2024
79865b6
Fix windows unit test failure because of accessing temp file before c…
benflexcompute May 17, 2024
90b7795
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 20, 2024
a88eaac
Merged volumes and surfaces into models to reflect latest design
benflexcompute May 21, 2024
cfb5ef2
Implement the framework for entities. (#258)
benflexcompute May 22, 2024
efefa03
[ModelRef] Added Field Definitions for **UserDefinedDynamics** (#271)
benflexcompute May 23, 2024
8e944f1
Fix the wrong way of checking exceptions (#276)
benflexcompute May 23, 2024
c56f91d
Allowing entityList to accept None so the using class can set None de…
benflexcompute May 24, 2024
616ae7e
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 24, 2024
9928fa3
[ModelRef] Added Field Definitions for **Outputs** (#270)
benflexcompute May 28, 2024
e0736f9
support for pydantic v2 in unit system (#265)
maciej-flexcompute May 29, 2024
0204165
Disable Simulation Pylint for now as it is not even finished. (#283)
benflexcompute May 29, 2024
8d59a32
[ModelRef] Added Field Definitions for **TimeStepping** (#272)
benflexcompute May 29, 2024
d3d7a09
Fix bug where time average outputs are not listed (#284)
benflexcompute May 29, 2024
28b5df2
Added output format option (#285)
benflexcompute May 29, 2024
500443d
[ModelRef] Added Field Definitions for **ReferenceGeometry** (#280)
benflexcompute May 30, 2024
ec306bc
[ready for review] create surface mesh from geometry id (#262)
feilin-flexcompute May 30, 2024
183b436
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute May 30, 2024
83426f9
Add preprocess for base model (#281)
yifan-flex May 30, 2024
8e5bfe3
[ModelRef] Add Field Definitions for **OperatingCondition** (#275)
yifan-flex May 31, 2024
af9d86f
[ModelRef] Add Field Definitions for **SurfaceModels** (#274)
yifan-flex May 31, 2024
dce763f
[ModelRef] Added Field Definitions for **VolumeModels** (#273)
benflexcompute May 31, 2024
e6c379c
[ModelRef] Add Field Definitions for **MeshingParameters** (#279)
benflexcompute May 31, 2024
42fbf2d
Rename volume models: FluidDynamics->Fluid, HeatTransfer->Solid (#288)
yifan-flex May 31, 2024
2d8c1fa
Rename and separate FluidMaterialTypes and SolidMaterialTypes (#289)
yifan-flex May 31, 2024
e86fbd4
Add reference_mach to AerospaceCondition.from_mach (#286)
yifan-flex May 31, 2024
ffd8425
Deleted unused file (#291)
benflexcompute May 31, 2024
16a663a
remove box from enclosed_objects (#292)
benflexcompute May 31, 2024
8b275d6
Remove turbulent quantities from outflow (#293)
yifan-flex Jun 3, 2024
ffb3191
Fix some field definitions (#287)
benflexcompute Jun 3, 2024
422af43
Unify TranslationallyPeriodic and RotationallyPeriodic (#290)
yifan-flex Jun 3, 2024
c0b8701
Correct units for material default (#297)
yifan-flex Jun 3, 2024
f96fda1
Added seralizer for SimulationParam (#300)
benflexcompute Jun 6, 2024
a65a439
Add cache model serialization (#301)
yifan-flex Jun 6, 2024
a8ac05b
Added pylint back (#302)
benflexcompute Jun 6, 2024
adefa8e
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jun 6, 2024
afd8e26
Created pydantic V2 version of the validation service, created tests.…
andrzej-krupka Jun 7, 2024
1df75cb
Unit conversion for simulationParam (#305)
benflexcompute Jun 7, 2024
31a6484
Renames and new meshing part (#306)
benflexcompute Jun 7, 2024
c723463
Added _type so translator knows the class (#307)
benflexcompute Jun 8, 2024
723bc36
Translator Utils (#310)
benflexcompute Jun 10, 2024
e7f927c
surface mesh translator (#309)
benflexcompute Jun 10, 2024
3fbc2b5
Revert " Added _type so translator knows the class (#307)"
yifan-flex Jun 10, 2024
843f512
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jun 10, 2024
a95b0d4
Ben y/volume meshing translator (#311)
benflexcompute Jun 11, 2024
efe80de
Add solver translator (#312)
yifan-flex Jun 11, 2024
15ecc90
Fixed all the unit test warnings (#315)
benflexcompute Jun 11, 2024
380832d
Enforce 0 warning (#316)
benflexcompute Jun 11, 2024
f1871bf
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jun 11, 2024
9630ced
Changed turbulent_viscosity_ratio to be positive only (#317)
benflexcompute Jun 11, 2024
60cf99c
Add service functions for translations. (#313)
benflexcompute Jun 12, 2024
6b3307e
Update cached model to store all constructor function arguments (#318)
yifan-flex Jun 12, 2024
7138f3d
construct from geometry to case (#321)
feilin-flexcompute Jun 12, 2024
9fe2bb5
Add BET solver JSON translator (#319)
benflexcompute Jun 17, 2024
2fec29e
fix volume params (#326)
feilin-flexcompute Jun 18, 2024
3fe8d8d
Entity Registry in SimulationParams (#328)
benflexcompute Jun 20, 2024
d8825a4
Remove _type attribute (#329)
yifan-flex Jun 20, 2024
4362cc7
Fix linting on python 3.9 (#331)
benflexcompute Jun 21, 2024
2feb4ca
Fix pylint for ALL simulation files. (#330)
benflexcompute Jun 21, 2024
18982eb
Add translator for rotation (#327)
yifan-flex Jun 21, 2024
80a5950
[ServiceIntegration] Add operating condition unit test for the implem…
benflexcompute Jun 24, 2024
a67e365
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jun 25, 2024
0a05038
Fix merge
benflexcompute Jun 25, 2024
14172f5
Fix model constants (#334)
yifan-flex Jun 25, 2024
49c1e01
Add from_axes for Box entities (#337)
yifan-flex Jun 26, 2024
f35d4aa
Maciej/workbench service (#335)
maciej-flexcompute Jun 28, 2024
7483b6a
minor fix on volume mesh JSON translator
maciej-flexcompute Jun 29, 2024
c24e328
translator: fixed farfield type format
maciej-flexcompute Jun 29, 2024
f98e89c
fixed translator tests
maciej-flexcompute Jun 29, 2024
0278781
added name to uniform refinement
maciej-flexcompute Jun 30, 2024
c41cbca
updated schemas
maciej-flexcompute Jun 30, 2024
a21dff7
fixed styling
maciej-flexcompute Jun 30, 2024
cc13213
added default axis and angle for box
maciej-flexcompute Jul 1, 2024
85c4a51
Prepend zone name to the surface name (#345)
benflexcompute Jul 1, 2024
4f8084c
Merge branch 'develop' into UnderConstruction/SimulationInterface
yifan-flex Jul 1, 2024
c73d24b
output translator (#343)
benflexcompute Jul 1, 2024
eb64d1f
Removed hash from JSON when deserializing (#346)
benflexcompute Jul 2, 2024
1d0fd2e
Add tranlator for porous media (#339)
yifan-flex Jul 2, 2024
a148e4c
updated JSON examples for UI
maciej-flexcompute Jul 9, 2024
e8371b0
fixed black
maciej-flexcompute Jul 9, 2024
7e1ebf5
Fixed 500 Reponses (#353)
benflexcompute Jul 9, 2024
3ff1242
Merge remote-tracking branch 'origin/develop' into UnderConstruction/…
benflexcompute Jul 10, 2024
05a0f49
Add AutomatedFarfield (#347)
benflexcompute Jul 10, 2024
d9397c9
improved check on unit parser (#351)
maciej-flexcompute Jul 11, 2024
ae8a43b
added type discriminator to meshing->volume zones (#356)
maciej-flexcompute Jul 11, 2024
57575bf
Rebased (#352)
benflexcompute Jul 11, 2024
6f504a6
added default meshing to init service (#354)
maciej-flexcompute Jul 11, 2024
f633d8a
Added GhostSurface to full name detection and fixed the type name (#358)
benflexcompute Jul 12, 2024
a2301ef
added units to actuator disk (#357)
maciej-flexcompute Jul 12, 2024
6aadb50
Work around for inconsistent zone name from meshers (#360)
benflexcompute Jul 12, 2024
f87f418
fixed comparing to not None in if statements (#362)
maciej-flexcompute Jul 15, 2024
f8b125d
Remove reference geometry default from translator (#359)
yifan-flex Jul 15, 2024
2e06b21
Add actuator disk translator (#361)
yifan-flex Jul 15, 2024
f622440
Removed skipping defaults when getting a setting (#365)
benflexcompute Jul 16, 2024
119a789
Added validation of reusing cylinders in meshing (#363)
benflexcompute Jul 16, 2024
60b0813
Merge branch 'develop' into UnderConstruction/SimulationInterface
yifan-flex Jul 16, 2024
81cf0bd
Fix unit tests
yifan-flex Jul 16, 2024
d6fe44a
Add CHT and periodic boundary translator (#348)
yifan-flex Jul 16, 2024
20ae144
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jul 17, 2024
90635d7
Fix front end JSON validation issues. (#368)
benflexcompute Jul 17, 2024
49acd72
Removed str from EntityList
benflexcompute Jul 17, 2024
1421474
added om6WingWallModel case
Jul 17, 2024
0dfcc81
isorted
Jul 17, 2024
f716b93
Merge branch 'develop' into UnderConstruction/SimulationInterface
benflexcompute Jul 18, 2024
53d6d72
Minor changes to AD validation (#367)
yifan-flex Jul 18, 2024
e417d3b
test error handling in geometry pipelines
feilin-flexcompute Jul 18, 2024
36f5798
add example to test geometry : geometry_from_assembly_part_files.py
feilin-flexcompute Jul 22, 2024
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
4 changes: 3 additions & 1 deletion .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
cache: 'poetry'
- name: Install isort
run: poetry install --only=dev
- name: Check isort version
run: poetry run isort --version
- name: Run isort
run: poetry run isort . --check-only

Expand All @@ -56,4 +58,4 @@ jobs:
- name: Install dependencies
run: poetry install
- name: Run pylint
run: poetry run pylint flow360 --rcfile .pylintrc
run: poetry run pylint $(git ls-files "flow360/*.py") --rcfile .pylintrc
13 changes: 8 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: unit testing
on:
workflow_dispatch:
push:
branches: [ develop, main, release-candidate/* ]
branches: [ develop, main, release-candidate/*, UnderConstruction/SimulationInterface ]
pull_request:
branches: [ develop, main, release-candidate/* ]
branches: [ develop, main, release-candidate/*, UnderConstruction/SimulationInterface ]
workflow_call:

jobs:
Expand Down Expand Up @@ -41,6 +41,9 @@ jobs:
poetry cache clear --all pypi
Remove-Item -Recurse -Force $env:USERPROFILE\AppData\Local\pypoetry\Cache\virtualenvs
- name: Install dependencies
run: poetry install
- name: Run tests
run: poetry run pytest -rA
run: |
poetry install
- name: Run simulation_params tests
run: poetry run pytest -rA tests/simulation
- name: Run flow360_params tests
run: poetry run pytest -rA --ignore tests/simulation
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,7 @@ $RECYCLE.BIN/

tmp/

/.vscode
/.vscode

# test residual
flow360/examples/cylinder2D/flow360mesh.json
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ignore=tests, flow360/examples

# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths and can be in Posix or Windows format.
ignore-paths=tests
ignore-paths=tests, flow360/examples, flow360/component/simulation/user_story_examples, flow360/component/results

# Files or directories matching the regex patterns are skipped. The regex
# matches against base names, not paths. The default value ignores Emacs file
Expand Down Expand Up @@ -82,7 +82,7 @@ persistent=yes

# Minimum Python version to use for version dependent checks. Will default to
# the version used to run pylint.
py-version=3.7
py-version=3.9

# Discover python modules and packages in the file system subtree.
recursive=no
Expand Down
6 changes: 3 additions & 3 deletions examples/case_params_with_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import flow360 as fl
from flow360 import log
from flow360 import units as u
from flow360.services import validate_flow360_params_model
from flow360.component.flow360_params.services import validate_model

log.set_logging_level("DEBUG")

Expand Down Expand Up @@ -53,7 +53,7 @@

del params_as_dict["fluid_properties"]

errors, warnings = validate_flow360_params_model(params_as_dict, "SI")
errors, warnings = validate_model(params_as_dict, "SI")
pprint(errors)

params_as_json = params.json(indent=4)
Expand All @@ -72,5 +72,5 @@

# Class name removal from loc
params_as_dict["freestream"]["foo"] = "bar"
errors, warnings = validate_flow360_params_model(params_as_dict, "SI")
errors, warnings = validate_model(params_as_dict, "SI")
pprint(errors)
7,363 changes: 7,363 additions & 0 deletions examples/data/airplane_geometry.egads

Large diffs are not rendered by default.

Binary file added examples/data/two_cubes/cube_1.SLDPRT
Binary file not shown.
Binary file added examples/data/two_cubes/cube_2.SLDPRT
Binary file not shown.
Binary file added examples/data/two_cubes/two_cubes.SLDASM
Binary file not shown.
125 changes: 125 additions & 0 deletions examples/dev/dev_serializing_unyt.py
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)
2 changes: 1 addition & 1 deletion examples/dev/dev_webservice_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import re

from flow360.services import get_default_fork
from flow360.component.flow360_params.services import get_default_fork

# Webservice examples

Expand Down
13 changes: 13 additions & 0 deletions examples/geometry_from_3rd_party_geometry_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import flow360 as fl
from flow360.component.geometry import Geometry
from flow360.examples import Cylinder3D

fl.Env.preprod.active()

geometry_draft = Geometry.from_file(
Cylinder3D.geometry,
name="testing-cylinder3d-geometry",
)
geometry = geometry_draft.submit()

print(geometry)
32 changes: 32 additions & 0 deletions examples/geometry_from_assembly_part_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os

os.environ["FLOW360_BETA_FEATURES"] = "1"
import flow360 as fl

fl.Env.dev.active()

from flow360.component.geometry import Geometry

# 1. full assembly + parts files
full_assembly_parts = []
for filename in ["two_cubes.SLDASM", "cube_1.SLDPRT", "cube_2.SLDPRT"]:
full_assembly_parts.append(os.path.join("./data/two_cubes", filename))
geometry_draft = Geometry.from_file(full_assembly_parts, name="testing-full-assembly-part", solver_version="geoHoops-24.7.0")
geometry = geometry_draft.submit()
print(geometry)

# 2. some part files are missing
full_assembly_parts = []
for filename in ["two_cubes.SLDASM", "cube_1.SLDPRT"]:
full_assembly_parts.append(os.path.join("./data/two_cubes", filename))
geometry_draft = Geometry.from_file(full_assembly_parts, name="testing-missing-part", solver_version="geoHoops-24.7.0")
geometry = geometry_draft.submit()
print(geometry)

# 3. multiple root level files
full_assembly_parts = []
for filename in ["cube_1.SLDPRT", "cube_2.SLDPRT"]:
full_assembly_parts.append(os.path.join("./data/two_cubes", filename))
geometry_draft = Geometry.from_file(full_assembly_parts, name="testing-root-level-files", solver_version="geoHoops-24.7.0")
geometry = geometry_draft.submit()
print(geometry)
13 changes: 13 additions & 0 deletions examples/geometry_from_csm_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import flow360 as fl
from flow360.component.geometry import Geometry
from flow360.examples import Airplane

fl.Env.preprod.active()

geometry_draft = Geometry.from_file(
Airplane.geometry,
name="testing-airplane-csm-geometry",
)
geometry = geometry_draft.submit()

print(geometry)
56 changes: 56 additions & 0 deletions examples/geometry_id_surface_volume_case_airplane_v1_from_csm.py
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 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.1",
)
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.1",
)
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()
Loading
Loading