Skip to content

feat: gen mwf api #4063

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
8 changes: 5 additions & 3 deletions codegen/allapigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from ansys.fluent.core import CODEGEN_OUTDIR, FluentMode, FluentVersion, launch_fluent
from ansys.fluent.core.codegen import StaticInfoType, allapigen
from ansys.fluent.core.codegen.print_fluent_version import print_fluent_version
from ansys.fluent.core.search import _generate_api_data
from ansys.fluent.core.utils.fluent_version import get_version_for_file_name

Expand All @@ -16,6 +15,7 @@
gt_222 = FluentVersion(version) > FluentVersion.v222
ge_231 = FluentVersion(version) >= FluentVersion.v231
ge_242 = FluentVersion(version) >= FluentVersion.v242
ge_261 = FluentVersion(version) >= FluentVersion.v261

static_infos = {
StaticInfoType.DATAMODEL_WORKFLOW: meshing._datamodel_service_se.get_static_info(
Expand All @@ -39,8 +39,11 @@
static_infos[StaticInfoType.DATAMODEL_MESHING_UTILITIES] = (
meshing._datamodel_service_se.get_static_info("MeshingUtilities")
)
if ge_261:
static_infos[StaticInfoType.DATAMODEL_MESHING_WORKFLOW] = (
meshing._datamodel_service_se.get_static_info("meshing_workflow")
)
meshing.exit()

solver = launch_fluent(
mode=FluentMode.SOLVER_ICING if ge_231 else FluentMode.SOLVER
)
Expand All @@ -62,7 +65,6 @@
t1 = time()
print(f"\nTime to fetch static info: {t1 - t0:.2f} seconds")
CODEGEN_OUTDIR.mkdir(parents=True, exist_ok=True)
print_fluent_version(solver._app_utilities)
solver.exit()
parser = argparse.ArgumentParser(
description="A script to write Fluent API files with an optional verbose output."
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/4063.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gen mwf api
2 changes: 2 additions & 0 deletions src/ansys/fluent/core/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class StaticInfoType(Enum):
DATAMODEL_MESHING = auto()
DATAMODEL_PART_MANAGEMENT = auto()
DATAMODEL_PM_FILE_MANAGEMENT = auto()
DATAMODEL_MESHING_WORKFLOW = auto()
# DATAMODEL_MESHING_WORKFLOW_X = auto()
DATAMODEL_FLICING = auto()
DATAMODEL_PREFERENCES = auto()
DATAMODEL_SOLVER_WORKFLOW = auto()
Expand Down
26 changes: 26 additions & 0 deletions src/ansys/fluent/core/codegen/datamodelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def _build_command_query_docstring(
"MeshingUtilities": "meshing_utilities",
"flicing": "flicing",
"solverworkflow": "solver_workflow",
"meshing_workflow": "meshing_workflow",
}


Expand All @@ -204,6 +205,7 @@ def __init__(
version: str,
rules_save_name: str = "",
):
print(f"DataModelStaticInfo for {rules}: enter")
self.static_info_type = static_info_type
self.rules = rules
self.modes = modes
Expand All @@ -220,6 +222,7 @@ def __init__(
if len(modes) > 1:
for mode in modes[1:]:
DataModelStaticInfo._noindices.append(f"{mode}.datamodel.{rules}")
print(f"DataModelStaticInfo for {rules}: return")


class DataModelGenerator:
Expand Down Expand Up @@ -258,6 +261,23 @@ def __init__(self, version, static_infos: dict, verbose: bool = False):
("meshing",),
self.version,
)
print("check if mw in static_infos")
if StaticInfoType.DATAMODEL_MESHING_WORKFLOW in static_infos:
print("Instantiate DataModelStaticInfo and insert")
self._static_info["meshing_workflow"] = DataModelStaticInfo(
StaticInfoType.DATAMODEL_MESHING_WORKFLOW,
"meshing_workflow",
("meshing",),
self.version,
)
# if StaticInfoType.DATAMODEL_MESHING_WORKFLOW_X in static_infos:
# print("Instantiate DataModelStaticInfo and insert")
# self._static_info["meshing_workflow_x"] = DataModelStaticInfo(
# StaticInfoType.DATAMODEL_MESHING_WORKFLOW_X,
# "meshing_workflow_x",
# ("meshing",),
# self.version,
# )
if StaticInfoType.DATAMODEL_FLICING in static_infos:
self._static_info["flicing"] = DataModelStaticInfo(
StaticInfoType.DATAMODEL_FLICING,
Expand Down Expand Up @@ -605,6 +625,12 @@ def generate(version, static_infos: dict, verbose: bool = False):
StaticInfoType.DATAMODEL_PM_FILE_MANAGEMENT: meshing._datamodel_service_se.get_static_info(
"PMFileManagement"
),
StaticInfoType.DATAMODEL_MESHING_WORKFLOW: meshing._datamodel_service_se.get_static_info(
"meshing_workflow"
),
# StaticInfoType.DATAMODEL_MESHING_WORKFLOW_X: meshing._datamodel_service_se.get_static_info(
# "meshing_workflow_x"
# ),
StaticInfoType.DATAMODEL_PREFERENCES: solver._datamodel_service_se.get_static_info(
"preferences"
),
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/services/datamodel_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -2225,7 +2225,7 @@ def __init__(
["String", "ListString", "String List"], PyTextualCommandArgumentsSubItem
),
**dict.fromkeys(
["Real", "Int", "ListReal", "Real List", "Integer", "ListInt"],
["Real", "Int", "ListReal", "Real List", "Integer", "ListInt", "Integer List"],
PyNumericalCommandArgumentsSubItem,
),
"Dict": PyDictionaryCommandArgumentsSubItem,
Expand Down
18 changes: 18 additions & 0 deletions src/ansys/fluent/core/session_base_meshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def __init__(
self._old_workflow = None
self._part_management = None
self._pm_file_management = None
self._meshing_workflow = None
# self._meshing_workflow_x = None
self._preferences = None
self._session_execute_tui = session_execute_tui
self._product_version = None
Expand Down Expand Up @@ -264,6 +266,22 @@ def PMFileManagement(self):
self._pm_file_management = _make_datamodel_module(self, "PMFileManagement")
return self._pm_file_management

@property
def meshing_workflow(self):
"""Full API to meshing and meshing_workflow."""
if self._meshing_workflow is None:
self._meshing_workflow = _make_datamodel_module(self, "meshing_workflow")
return self._meshing_workflow

# @property
# def meshing_workflow_x(self):
# """Full API to meshing and meshing_workflow."""
# if self._meshing_workflow_x is None:
# self._meshing_workflow_x = _make_datamodel_module(
# self, "meshing_workflow_x"
# )
# return self._meshing_workflow_x

@property
def preferences(self):
"""Datamodel root of preferences."""
Expand Down
10 changes: 10 additions & 0 deletions src/ansys/fluent/core/session_meshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ def PMFileManagement(self):
"""Part management file management datamodel root."""
return super(Meshing, self).PMFileManagement

@property
def meshing_workflow(self):
"""Full API to meshing and meshing_workflow."""
return super(Meshing, self).meshing_workflow

# @property
# def meshing_workflow_x(self):
# """Full API to dummy meshing and meshing_workflow."""
# return super(Meshing, self).meshing_workflow_x

@property
def preferences(self):
"""Preferences datamodel root."""
Expand Down
10 changes: 10 additions & 0 deletions src/ansys/fluent/core/session_pure_meshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ def PMFileManagement(self):
"""Datamodel root of PMFileManagement."""
return self._base_meshing.PMFileManagement

@property
def meshing_workflow(self):
"""Full API to meshing and meshing_workflow."""
return self._base_meshing.meshing_workflow

# @property
# def meshing_workflow_x(self):
# """Full API to dummy meshing and meshing_workflow."""
# return self._base_meshing.meshing_workflow_x

@property
def preferences(self):
"""Datamodel root of preferences."""
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/fluent/core/session_pure_meshing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class PureMeshing:
@property
def PMFileManagement(self) -> pmfilemanagement_root: ...
@property
def meshing_workflow(self) -> meshing_workflow_root: ...
@property
def meshing_x_workflow(self) -> meshing_workflow_x_root: ...
@property
def preferences(self) -> preferences_root: ...
def transfer_mesh_to_solvers(
self,
Expand Down