Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added interface for selecting inhouse Mesher #648

Merged
merged 1 commit into from
Jan 8, 2025
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
2 changes: 1 addition & 1 deletion examples/tutorials/quick_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
)

# Step 5: Run the simulation case with the specified parameters
project.run_case(params=params, name="Case of Simple Airplane from Python")
project.run_case(params=params, name="Case of Simple Airplane from Python", use_beta_mesher=False)
18 changes: 13 additions & 5 deletions flow360/component/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,14 @@ def _get_root_simulation_json(self):
# pylint: disable=too-many-arguments, too-many-locals
def _run(
self,
*,
params: SimulationParams,
target: AssetOrResource,
draft_name: str = None,
fork_from: Case = None,
run_async: bool = True,
solver_version: str = None,
draft_name: str,
fork_from: Case,
run_async: bool,
solver_version: str,
use_beta_mesher: bool,
):
"""
Runs a simulation for the project.
Expand Down Expand Up @@ -629,7 +631,7 @@ def _run(

draft.update_simulation_params(params)

destination_id = draft.run_up_to_target_asset(target)
destination_id = draft.run_up_to_target_asset(target, use_beta_mesher=use_beta_mesher)

self._project_webapi.patch(
# pylint: disable=protected-access
Expand Down Expand Up @@ -660,6 +662,7 @@ def generate_surface_mesh(
name: str = "SurfaceMesh",
run_async: bool = True,
solver_version: str = None,
use_beta_mesher: bool = False,
):
"""
Runs the surface mesher for the project.
Expand Down Expand Up @@ -693,6 +696,7 @@ def generate_surface_mesh(
run_async=run_async,
fork_from=None,
solver_version=solver_version,
use_beta_mesher=use_beta_mesher,
)
)

Expand All @@ -703,6 +707,7 @@ def generate_volume_mesh(
name: str = "VolumeMesh",
run_async: bool = True,
solver_version: str = None,
use_beta_mesher: bool = False,
):
"""
Runs the volume mesher for the project.
Expand Down Expand Up @@ -736,6 +741,7 @@ def generate_volume_mesh(
run_async=run_async,
fork_from=None,
solver_version=solver_version,
use_beta_mesher=use_beta_mesher,
)
)

Expand All @@ -747,6 +753,7 @@ def run_case(
run_async: bool = True,
fork_from: Case = None,
solver_version: str = None,
use_beta_mesher: bool = False,
):
"""
Runs a case for the project.
Expand All @@ -773,5 +780,6 @@ def run_case(
run_async=run_async,
fork_from=fork_from,
solver_version=solver_version,
use_beta_mesher=use_beta_mesher,
)
)
9 changes: 7 additions & 2 deletions flow360/component/simulation/web/draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,18 @@ def get_simulation_dict(self) -> dict:
response = self.get(method="simulation/file", params={"type": "simulation"})
return json.loads(response["simulationJson"])

def run_up_to_target_asset(self, target_asset: type) -> str:
def run_up_to_target_asset(self, target_asset: type, use_beta_mesher: bool) -> str:
"""run the draft up to the target asset"""

try:
# pylint: disable=protected-access
if use_beta_mesher is True:
log.info("Selecting beta/inhouse mesher for possible meshing tasks.")
run_response = self.post(
json={"upTo": target_asset._cloud_resource_type_name, "useInHouse": False},
json={
"upTo": target_asset._cloud_resource_type_name,
"useInHouse": use_beta_mesher,
},
method="run",
)
except Flow360WebError as err:
Expand Down
Loading