-
Notifications
You must be signed in to change notification settings - Fork 7
Project class interface #511
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
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
29024e4
Added initial version of the Project class interface
andrzej-krupka 4f82beb
Added examples, remove usages of cloud static functions
andrzej-krupka 8ca3122
Entity info injection during _run()
andrzej-krupka 266df20
Style fixes
andrzej-krupka b6ea7cc
Fix webapi test
andrzej-krupka b9ca4a7
Fix examples, fix from_cloud
andrzej-krupka 6372e0e
Add case fork option
andrzej-krupka 6f6648f
Switched docstrings to numpy style
andrzej-krupka 9ba5587
Fix PR feedback
andrzej-krupka 3b7aa70
Fix PR feedback #2
andrzej-krupka 99f2143
Fix PR feedback #3
andrzej-krupka 8e1ad0b
Merge branch 'develop' into andrzej/project-class
benflexcompute d07cfe8
Fix PR feedback #4
andrzej-krupka 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 was deleted.
Oops, something went wrong.
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,49 @@ | ||
from flow360.component.project import Project | ||
from flow360.component.simulation.meshing_param.params import ( | ||
MeshingDefaults, | ||
MeshingParams, | ||
) | ||
from flow360.component.simulation.meshing_param.volume_params import AutomatedFarfield | ||
from flow360.component.simulation.models.surface_models import Freestream, Wall | ||
from flow360.component.simulation.operating_condition.operating_condition import ( | ||
AerospaceCondition, | ||
) | ||
from flow360.component.simulation.outputs.outputs import SurfaceOutput | ||
from flow360.component.simulation.primitives import ReferenceGeometry | ||
from flow360.component.simulation.simulation_params import SimulationParams | ||
from flow360.component.simulation.time_stepping.time_stepping import Steady | ||
from flow360.component.simulation.unit_system import SI_unit_system, u | ||
from flow360.environment import dev | ||
|
||
dev.active() | ||
|
||
project = Project.from_cloud("prj-f3569ba5-16a3-4e41-bfd2-b8840df79835") | ||
|
||
geometry = project.geometry | ||
geometry.show_available_groupings(verbose_mode=True) | ||
geometry.group_faces_by_tag("faceId") | ||
|
||
with SI_unit_system: | ||
params = SimulationParams( | ||
meshing=MeshingParams( | ||
defaults=MeshingDefaults( | ||
boundary_layer_first_layer_thickness=0.001, surface_max_edge_length=1 | ||
), | ||
volume_zones=[AutomatedFarfield()], | ||
), | ||
reference_geometry=ReferenceGeometry(), | ||
operating_condition=AerospaceCondition(velocity_magnitude=100, alpha=5 * u.deg), | ||
time_stepping=Steady(max_steps=1000), | ||
models=[ | ||
Wall( | ||
surfaces=[geometry["*"]], | ||
name="Wall", | ||
), | ||
Freestream(surfaces=[AutomatedFarfield().farfield], name="Freestream"), | ||
], | ||
outputs=[ | ||
SurfaceOutput(surfaces=geometry["*"], output_fields=["Cp", "Cf", "yPlus", "CfVec"]) | ||
], | ||
) | ||
|
||
project.run_case(params=params, name="Case of Simple Airplane from Python") |
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,27 @@ | ||
import flow360.component.simulation.units as u | ||
from flow360.component.project import Project | ||
from flow360.component.simulation.models.surface_models import Freestream, Wall | ||
from flow360.component.simulation.models.volume_models import Fluid | ||
from flow360.component.simulation.operating_condition.operating_condition import ( | ||
AerospaceCondition, | ||
) | ||
from flow360.component.simulation.simulation_params import SimulationParams | ||
from flow360.component.simulation.unit_system import SI_unit_system | ||
from flow360.environment import dev | ||
|
||
dev.active() | ||
|
||
project = Project.from_cloud("prj-e8c6c7eb-c18b-4c15-bac8-edf5aaf9b155") | ||
|
||
volume_mesh = project.volume_mesh | ||
|
||
with SI_unit_system: | ||
params = SimulationParams( | ||
operating_condition=AerospaceCondition(velocity_magnitude=100 * u.m / u.s), | ||
models=[ | ||
Wall(entities=[volume_mesh["fluid/wall"]]), | ||
Freestream(entities=[volume_mesh["fluid/farfield"]]), | ||
], | ||
) | ||
|
||
project.run_case(params=params) | ||
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,50 @@ | ||
import flow360 as fl | ||
from flow360.component.project import Project | ||
from flow360.component.simulation.meshing_param.params import ( | ||
MeshingDefaults, | ||
MeshingParams, | ||
) | ||
from flow360.component.simulation.meshing_param.volume_params import AutomatedFarfield | ||
from flow360.component.simulation.models.surface_models import Freestream, Wall | ||
from flow360.component.simulation.operating_condition.operating_condition import ( | ||
AerospaceCondition, | ||
) | ||
from flow360.component.simulation.outputs.outputs import SurfaceOutput | ||
from flow360.component.simulation.primitives import ReferenceGeometry | ||
from flow360.component.simulation.simulation_params import SimulationParams | ||
from flow360.component.simulation.time_stepping.time_stepping import Steady | ||
from flow360.component.simulation.unit_system import SI_unit_system, u | ||
from flow360.examples import Airplane | ||
|
||
fl.Env.dev.active() | ||
|
||
project = Project.from_file(Airplane.geometry, name="Python Project (Geometry, from file)") | ||
|
||
geometry = project.geometry | ||
geometry.show_available_groupings(verbose_mode=True) | ||
geometry.group_faces_by_tag("groupName") | ||
|
||
with SI_unit_system: | ||
params = SimulationParams( | ||
meshing=MeshingParams( | ||
defaults=MeshingDefaults( | ||
boundary_layer_first_layer_thickness=0.001, surface_max_edge_length=1 | ||
), | ||
volume_zones=[AutomatedFarfield()], | ||
), | ||
reference_geometry=ReferenceGeometry(), | ||
operating_condition=AerospaceCondition(velocity_magnitude=100, alpha=5 * u.deg), | ||
time_stepping=Steady(max_steps=1000), | ||
models=[ | ||
Wall( | ||
surfaces=[geometry["*"]], | ||
name="Wall", | ||
), | ||
Freestream(surfaces=[AutomatedFarfield().farfield], name="Freestream"), | ||
], | ||
outputs=[ | ||
SurfaceOutput(surfaces=geometry["*"], output_fields=["Cp", "Cf", "yPlus", "CfVec"]) | ||
], | ||
) | ||
|
||
project.run_case(params=params, name="Case of Simple Airplane from Python") |
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,67 @@ | ||
import flow360 as fl | ||
from flow360.component.project import Project | ||
from flow360.component.simulation.meshing_param.params import ( | ||
MeshingDefaults, | ||
MeshingParams, | ||
) | ||
from flow360.component.simulation.meshing_param.volume_params import AutomatedFarfield | ||
from flow360.component.simulation.models.surface_models import Freestream, Wall | ||
from flow360.component.simulation.operating_condition.operating_condition import ( | ||
AerospaceCondition, | ||
) | ||
from flow360.component.simulation.outputs.outputs import SurfaceOutput | ||
from flow360.component.simulation.primitives import ReferenceGeometry | ||
from flow360.component.simulation.simulation_params import SimulationParams | ||
from flow360.component.simulation.time_stepping.time_stepping import Steady | ||
from flow360.component.simulation.unit_system import SI_unit_system, u | ||
from flow360.examples import Airplane | ||
|
||
fl.Env.dev.active() | ||
|
||
project = Project.from_file( | ||
Airplane.geometry, name="Python Project (Geometry, from file, multiple runs)" | ||
) | ||
|
||
geometry = project.geometry | ||
geometry.show_available_groupings(verbose_mode=True) | ||
geometry.group_faces_by_tag("groupName") | ||
|
||
with SI_unit_system: | ||
params = SimulationParams( | ||
meshing=MeshingParams( | ||
defaults=MeshingDefaults( | ||
boundary_layer_first_layer_thickness=0.001, surface_max_edge_length=1 | ||
), | ||
volume_zones=[AutomatedFarfield()], | ||
), | ||
reference_geometry=ReferenceGeometry(), | ||
operating_condition=AerospaceCondition(velocity_magnitude=100, alpha=5 * u.deg), | ||
time_stepping=Steady(max_steps=1000), | ||
models=[ | ||
Wall( | ||
surfaces=[geometry["*"]], | ||
name="Wall", | ||
), | ||
Freestream(surfaces=[AutomatedFarfield().farfield], name="Freestream"), | ||
], | ||
outputs=[ | ||
SurfaceOutput(surfaces=geometry["*"], output_fields=["Cp", "Cf", "yPlus", "CfVec"]) | ||
], | ||
) | ||
|
||
# Run the mesher once | ||
project.generate_surface_mesh(params=params, name="Surface mesh 1") | ||
surface_mesh_1 = project.surface_mesh | ||
|
||
# Tweak some parameter in the params | ||
params.meshing.defaults.surface_max_edge_length = 2 * u.m | ||
|
||
# Run the mesher again | ||
project.generate_surface_mesh(params=params, name="Surface mesh 2") | ||
surface_mesh_2 = project.surface_mesh | ||
|
||
assert surface_mesh_1.id != surface_mesh_2.id | ||
|
||
# Check available surface mesh IDs in the project | ||
ids = project.available_surface_meshes() | ||
print(ids) |
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,38 @@ | ||
import flow360 as fl | ||
import flow360.component.simulation.units as u | ||
from flow360.component.project import Project | ||
from flow360.component.simulation.models.surface_models import ( | ||
Freestream, | ||
SymmetryPlane, | ||
Wall, | ||
) | ||
from flow360.component.simulation.models.volume_models import Fluid | ||
from flow360.component.simulation.operating_condition.operating_condition import ( | ||
AerospaceCondition, | ||
) | ||
from flow360.component.simulation.simulation_params import SimulationParams | ||
from flow360.component.simulation.unit_system import SI_unit_system | ||
from flow360.examples import OM6wing | ||
|
||
fl.Env.dev.active() | ||
|
||
OM6wing.get_files() | ||
# Creating and uploading a volume mesh from file | ||
project = Project.from_file( | ||
OM6wing.mesh_filename, name="wing-volume-mesh-python-upload", tags=["python"] | ||
) | ||
|
||
volume_mesh = project.volume_mesh | ||
|
||
with SI_unit_system: | ||
params = SimulationParams( | ||
operating_condition=AerospaceCondition(velocity_magnitude=100 * u.m / u.s), | ||
models=[ | ||
Fluid(), | ||
Wall(entities=[volume_mesh["1"]]), | ||
Freestream(entities=[volume_mesh["3"]]), | ||
SymmetryPlane(entities=[volume_mesh["2"]]), | ||
], | ||
) | ||
|
||
project.run_case(params=params) |
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
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.