Skip to content
Open
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
5 changes: 3 additions & 2 deletions src/ansys/fluent/core/examples/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import zipfile

import ansys.fluent.core as pyfluent
from ansys.fluent.core.types import PathType
from ansys.fluent.core.utils.networking import check_url_exists, get_url_content

logger = logging.getLogger("pyfluent.networking")
Expand Down Expand Up @@ -74,7 +75,7 @@ def _get_file_url(file_name: str, directory: str | None = None) -> str:
def _retrieve_file(
url: str,
file_name: str,
save_path: str | None = None,
save_path: "PathType | None" = None,
return_without_path: bool | None = False,
) -> str:
"""Download specified file from specified URL."""
Expand Down Expand Up @@ -121,7 +122,7 @@ def _retrieve_file(
def download_file(
file_name: str,
directory: str | None = None,
save_path: str | None = None,
save_path: "PathType | None" = None,
return_without_path: bool | None = None,
) -> str:
"""Download specified example file from the Ansys example data repository.
Expand Down
9 changes: 5 additions & 4 deletions src/ansys/fluent/core/filereader/case_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import numpy as np

from ansys.fluent.core.solver.error_message import allowed_name_error_message
from ansys.fluent.core.types import PathType

from . import lispy
from .pre_processor import remove_unsupported_xml_chars
Expand Down Expand Up @@ -616,17 +617,17 @@ class CaseFile(RPVarProcessor):

def __init__(
self,
case_file_name: str | None = None,
project_file_name: str | None = None,
case_file_name: "PathType | None" = None,
project_file_name: "PathType | None" = None,
) -> None:
"""Initialize a CaseFile object. Exactly one file path argument must be
specified.

Parameters
----------
case_file_name : str
case_file_name : :class:`os.PathLike` | str | None
The path of a case file.
project_file_name : str
project_file_name : :class:`os.PathLike` | str | None
The path of a project file from which the case file is selected.
"""
self._is_case_file = False
Expand Down
17 changes: 9 additions & 8 deletions src/ansys/fluent/core/launcher/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
from ansys.fluent.core.session_pure_meshing import PureMeshing
from ansys.fluent.core.session_solver import Solver
from ansys.fluent.core.session_solver_icing import SolverIcing
from ansys.fluent.core.types import PathType
from ansys.fluent.core.utils.deprecate import all_deprecators
from ansys.fluent.core.utils.fluent_version import FluentVersion

Expand Down Expand Up @@ -162,14 +163,14 @@ def launch_fluent(
graphics_driver: (
FluentWindowsGraphicsDriver | FluentLinuxGraphicsDriver | str | None
) = None,
case_file_name: str | None = None,
case_data_file_name: str | None = None,
case_file_name: "PathType | None" = None,
case_data_file_name: "PathType | None" = None,
lightweight_mode: bool | None = None,
mode: FluentMode | str | None = None,
py: bool | None = None,
gpu: bool | list[int] | None = None,
cwd: str | None = None,
fluent_path: str | None = None,
cwd: "PathType | None" = None,
fluent_path: "PathType | None" = None,
topy: str | list | None = None,
start_watchdog: bool | None = None,
scheduler_options: dict | None = None,
Expand Down Expand Up @@ -254,9 +255,9 @@ def launch_fluent(
``"null"``, ``"x11"``, ``"opengl2"``, ``"opengl"`` or ``"auto"``. The default is
``FluentWindowsGraphicsDriver.AUTO`` in Windows and
``FluentLinuxGraphicsDriver.AUTO`` in Linux.
case_file_name : str, optional
case_file_name : :class:`os.PathLike` or str, optional
If provided, the case file at ``case_file_name`` is read into the Fluent session.
case_data_file_name : str, optional
case_data_file_name : :class:`os.PathLike` or str, optional
If provided, the case and data files at ``case_data_file_name`` are read into the Fluent session.
lightweight_mode : bool, optional
Whether to run in lightweight mode. In lightweight mode, the lightweight settings are read into the
Expand All @@ -278,9 +279,9 @@ def launch_fluent(
clamped to the value of ``processor_count``. Please refer to
*Starting the Fluent GPU Solver* section in *Fluent's User Guide* for more
information like how to determine the GPU IDs.
cwd : str, Optional
cwd : :class:`os.PathLike` or str, optional
Working directory for the Fluent client.
fluent_path: str, Optional
fluent_path: :class:`os.PathLike` or str, optional
User provided Fluent installation path.
topy : bool or str, optional
A boolean flag to write the equivalent Python journal(s) from the journal(s) passed.
Expand Down
17 changes: 9 additions & 8 deletions src/ansys/fluent/core/launcher/slurm_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
from ansys.fluent.core.session_pure_meshing import PureMeshing
from ansys.fluent.core.session_solver import Solver
from ansys.fluent.core.session_solver_icing import SolverIcing
from ansys.fluent.core.types import PathType
from ansys.fluent.core.utils.fluent_version import FluentVersion

logger = logging.getLogger("pyfluent.launcher")
Expand Down Expand Up @@ -298,13 +299,13 @@ def __init__(
env: Dict[str, Any] | None = None,
cleanup_on_exit: bool = True,
start_transcript: bool = True,
case_file_name: str | None = None,
case_data_file_name: str | None = None,
case_file_name: "PathType | None" = None,
case_data_file_name: "PathType | None" = None,
lightweight_mode: bool | None = None,
py: bool | None = None,
gpu: bool | None = None,
cwd: str | None = None,
fluent_path: str | None = None,
cwd: "PathType | None" = None,
fluent_path: "PathType | None" = None,
topy: str | list | None = None,
start_watchdog: bool | None = None,
scheduler_options: dict | None = None,
Expand Down Expand Up @@ -359,10 +360,10 @@ def __init__(
default is ``True``. You can stop and start the streaming of the
Fluent transcript subsequently via the method calls, ``transcript.start()``
and ``transcript.stop()`` on the session object.
case_file_name : str, optional
case_file_name : :class:`os.PathLike` or str, optional
Name of the case file to read into the
Fluent session. The default is ``None``.
case_data_file_name : str, optional
case_data_file_name : :class:`os.PathLike` or str, optional
Name of the case data file. If names of both a case file and case data file are provided, they are read into the Fluent session.
lightweight_mode : bool, optional
Whether to run in lightweight mode. In lightweight mode, the lightweight settings are read into the
Expand All @@ -375,9 +376,9 @@ def __init__(
If True, Fluent will run in Python mode. Default is None.
gpu : bool, optional
If True, Fluent will start with GPU Solver.
cwd : str, Optional
cwd : :class:`os.PathLike` or str, optional
Working directory for the Fluent client.
fluent_path: str, Optional
fluent_path: :class:`os.PathLike` or str, optional
User provided Fluent installation path.
topy : bool or str, optional
A boolean flag to write the equivalent Python journal(s) from the journal(s) passed.
Expand Down
17 changes: 9 additions & 8 deletions src/ansys/fluent/core/launcher/standalone_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
_get_server_info_file_names,
)
import ansys.fluent.core.launcher.watchdog as watchdog
from ansys.fluent.core.types import PathType
from ansys.fluent.core.utils.fluent_version import FluentVersion

logger = logging.getLogger("pyfluent.launcher")
Expand All @@ -95,13 +96,13 @@ def __init__(
cleanup_on_exit: bool = True,
dry_run: bool = False,
start_transcript: bool = True,
case_file_name: str | None = None,
case_data_file_name: str | None = None,
case_file_name: "PathType | None" = None,
case_data_file_name: "PathType | None" = None,
lightweight_mode: bool | None = None,
py: bool | None = None,
gpu: bool | None = None,
cwd: str | None = None,
fluent_path: str | None = None,
cwd: "PathType | None" = None,
fluent_path: "PathType | None" = None,
topy: str | list | None = None,
start_watchdog: bool | None = None,
file_transfer_service: Any | None = None,
Expand Down Expand Up @@ -150,9 +151,9 @@ def __init__(
start_transcript : bool, optional
Indicates whether to start streaming the Fluent transcript in the client. Defaults to True;
streaming can be controlled via `transcript.start()` and `transcript.stop()` methods on the session object.
case_file_name : str, optional
case_file_name : :class:`os.PathLike` or str, optional
Name of the case file to read into the Fluent session. Defaults to None.
case_data_file_name : str, optional
case_data_file_name : :class:`os.PathLike` or str, optional
Name of the case data file. If both case and data files are provided, they are read into the session.
lightweight_mode : bool, optional
If True, runs in lightweight mode where mesh settings are read into a background solver session,
Expand All @@ -161,9 +162,9 @@ def __init__(
If True, runs Fluent in Python mode. Defaults to None.
gpu : bool, optional
If True, starts Fluent with GPU Solver enabled.
cwd : str, optional
cwd : :class:`os.PathLike` or str, optional
Working directory for the Fluent client.
fluent_path: str, optional
fluent_path: :class:`os.PathLike` or str, optional
User-specified path for Fluent installation.
topy : bool or str, optional
A flag indicating whether to write equivalent Python journals from provided journal files; can also specify
Expand Down
10 changes: 6 additions & 4 deletions src/ansys/fluent/core/meshing/meshing_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
from __future__ import annotations

from enum import Enum
import os

from ansys.fluent.core.services.datamodel_se import PyMenuGeneric
from ansys.fluent.core.types import PathType
from ansys.fluent.core.utils.fluent_version import FluentVersion
from ansys.fluent.core.workflow import Workflow

Expand Down Expand Up @@ -272,7 +274,7 @@ def __init__(
self,
workflow: PyMenuGeneric,
meshing: PyMenuGeneric,
file_path: str,
file_path: PathType,
fluent_version: FluentVersion,
) -> None:
"""Initialize a ``LoadWorkflow`` instance.
Expand All @@ -283,8 +285,8 @@ def __init__(
Underlying workflow object.
meshing : PyMenuGeneric
Meshing object.
file_path: str
Path to the saved workflow.
file_path: os.PathLike[str | bytes] | str | bytes
Path to the saved workflow file.
fluent_version: FluentVersion
Version of Fluent in this session.
"""
Expand All @@ -293,7 +295,7 @@ def __init__(
)
self._meshing = meshing
self._unsubscribe_root_affected_callback()
self._load_workflow(file_path=file_path)
self._load_workflow(file_path=os.fspath(file_path))


class CreateWorkflow(Workflow):
Expand Down
8 changes: 6 additions & 2 deletions src/ansys/fluent/core/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@
"""

from math import ceil
import os
from typing import Any, Dict

from ansys.fluent.core.launcher.launcher import launch_fluent
from ansys.fluent.core.types import PathType
from ansys.fluent.core.utils.execution import asynchronous

BASE_DP_NAME = "Base DP"
Expand Down Expand Up @@ -293,11 +295,13 @@ class LocalParametricStudy:
If the design point is not found.
"""

def __init__(self, case_filepath: str, base_design_point_name: str = "Base DP"):
def __init__(
self, case_filepath: PathType, base_design_point_name: str = "Base DP"
):
"""Initialize LocalParametricStudy."""
from ansys.fluent.core.filereader.casereader import CaseReader

self.case_filepath = case_filepath
self.case_filepath = os.fspath(case_filepath)
base_design_point = LocalDesignPoint(base_design_point_name)
case_reader = CaseReader(case_file_name=case_filepath)

Expand Down
10 changes: 6 additions & 4 deletions src/ansys/fluent/core/services/app_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from dataclasses import dataclass
from enum import Enum
import os
from typing import List, Tuple

import grpc
Expand All @@ -37,6 +38,7 @@
TracingInterceptor,
)
from ansys.fluent.core.streaming_services.events_streaming import SolverEvent
from ansys.fluent.core.types import PathType


class AppUtilitiesService:
Expand Down Expand Up @@ -328,9 +330,9 @@ def exit(self) -> None:
"""Exit."""
self.scheme.exec(("(exit-server)",))

def set_working_directory(self, path: str) -> None:
def set_working_directory(self, path: PathType) -> None:
"""Change client cortex dir."""
self.scheme.eval(f'(syncdir "{path}")')
self.scheme.eval(f'(syncdir "{os.fspath(path)}")')


class AppUtilities:
Expand Down Expand Up @@ -474,10 +476,10 @@ def exit(self) -> None:
request = AppUtilitiesProtoModule.ExitRequest()
self.service.exit(request)

def set_working_directory(self, path: str) -> None:
def set_working_directory(self, path: PathType) -> None:
"""Change client cortex dir."""
request = AppUtilitiesProtoModule.SetWorkingDirectoryRequest()
request.path = path
request.path = os.fspath(path)
self.service.set_working_directory(request)


Expand Down
8 changes: 5 additions & 3 deletions src/ansys/fluent/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from enum import Enum
import json
import logging
import os
from typing import Any, Callable, Dict
import warnings
import weakref
Expand All @@ -46,6 +47,7 @@
)
from ansys.fluent.core.streaming_services.events_streaming import EventsManager
from ansys.fluent.core.streaming_services.transcript_streaming import Transcript
from ansys.fluent.core.types import PathType
from ansys.fluent.core.utils.fluent_version import FluentVersion

from .rpvars import RPVars
Expand Down Expand Up @@ -452,15 +454,15 @@ def download(self, file_name: str, local_directory: str | None = None):
if self._file_transfer_service:
return self._file_transfer_service.download(file_name, local_directory)

def chdir(self, path: str) -> None:
def chdir(self, path: PathType) -> None:
"""Change Fluent working directory.

Parameters
----------
path : str
path : os.PathLike[str | bytes] | str | bytes
Path of the directory to change.
"""
self._app_utilities.set_working_directory(path)
self._app_utilities.set_working_directory(os.fspath(path))

def __enter__(self):
return self
Expand Down
6 changes: 4 additions & 2 deletions src/ansys/fluent/core/session_base_meshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"""Provides a module to get base Meshing session."""

import logging
import os

from ansys.fluent.core.fluent_connection import FluentConnection
from ansys.fluent.core.meshing.meshing_workflow import (
Expand All @@ -35,6 +36,7 @@
_make_datamodel_module,
_make_tui_module,
)
from ansys.fluent.core.types import PathType
from ansys.fluent.core.utils.fluent_version import (
FluentVersion,
get_version_for_file_name,
Expand Down Expand Up @@ -169,12 +171,12 @@ def topology_based_meshing_workflow(self, initialize: bool = True):
)
return self._current_workflow

def load_workflow(self, file_path: str):
def load_workflow(self, file_path: PathType):
"""Datamodel root of workflow."""
self._current_workflow = LoadWorkflow(
_make_datamodel_module(self, "workflow"),
self.meshing,
file_path,
os.fspath(file_path),
self.get_fluent_version(),
)
return self._current_workflow
Expand Down
Loading
Loading