Skip to content

Commit

Permalink
Merge branch 'main' into ci/fluent-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prmukherj authored Dec 10, 2024
2 parents 3b98672 + 2e41f58 commit 2613cbd
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 1,041 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,6 @@ jobs:
restore-keys: |
Python-${{ runner.os }}-${{ matrix.python-version }}
- name: Install Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
tinytex: true

- name: Check Quarto Version
shell: bash
run: |
quarto --version
- name: "Install Poppler for PDF to PNG conversion"
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y poppler-utils
- name: Install pyfluent
run: make install

Expand Down Expand Up @@ -197,6 +181,7 @@ jobs:
make build-doc-source
env:
FLUENT_IMAGE_TAG: ${{ env.DOC_DEPLOYMENT_IMAGE_TAG }}
PYFLUENT_DOC_SKIP_CHEATSHEET: 1

- name: Zip HTML Documentation before upload
run: |
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/doc-build-dev-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ jobs:
sudo apt update
sudo apt-get install pandoc libegl1 make xvfb libfontconfig1 libxrender1 libxkbcommon-x11-0 -y
- name: Install Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
tinytex: true

- name: Check Quarto Version
shell: bash
run: |
quarto --version
- name: "Install Poppler for PDF to PNG conversion"
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y poppler-utils
- name: Install pyfluent
run: make install

Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/doc-build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ jobs:
sudo apt update
sudo apt-get install pandoc libegl1 make xvfb libfontconfig1 libxrender1 libxkbcommon-x11-0 -y
- name: Install Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
tinytex: true

- name: Check Quarto Version
shell: bash
run: |
quarto --version
- name: "Install Poppler for PDF to PNG conversion"
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y poppler-utils
- name: Install pyfluent
run: make install

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* [Harshal Pohekar](https://github.com/hpohekar)
* [Mainak Kundu](https://github.com/mkundu1)
* [Prithwish Mukherjee](https://github.com/prmukherj)
* [Raphael Luciano](https://github.com/raph-luc)
* [Raphael Luciano](https://github.com/raph-luc)
13 changes: 6 additions & 7 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@

toggleprompt_offset_right = 35

skip_examples = int(os.getenv("PYFLUENT_SKIP_EXAMPLES_DOC", 0))
if skip_examples:
pass
else:
if os.getenv("PYFLUENT_DOC_SKIP_EXAMPLES") != "1":
extensions.append("sphinx_gallery.gen_gallery")

typehints_document_rtype = False
Expand Down Expand Up @@ -197,13 +194,15 @@ def _stop_fluent_container(gallery_conf, fname):
"navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"],
"navigation_depth": -1,
"collapse_navigation": True,
"cheatsheet": {
}

if os.getenv("PYFLUENT_DOC_SKIP_CHEATSHEET") != "1":
html_theme_options["cheatsheet"] = {
"file": "cheatsheet/cheat_sheet.qmd",
"pages": ["index", "getting_started/index", "user_guide/index"],
"title": "PyFluent cheat sheet",
"version": __version__,
},
}
}

# -- Options for HTMLHelp output ---------------------------------------------

Expand Down
8 changes: 6 additions & 2 deletions doc/source/contributing/environment_variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Following is a list of environment variables that can be set to control various
- Specifies the Docker image name while starting a Fluent container in :func:`launch_fluent() <ansys.fluent.core.launcher.launcher.launch_fluent>`.
* - FLUENT_IMAGE_TAG
- Specifies the Docker image tag while starting a Fluent container in :func:`launch_fluent() <ansys.fluent.core.launcher.launcher.launch_fluent>`.
* - PYFLUENT_CODEGEN_OUTDIR
- Specifies the directory where API files are written out during codegen.
* - PYFLUENT_CODEGEN_SKIP_BUILTIN_SETTINGS
- Skips the generation of built-in settings during codegen.
* - PYFLUENT_CONTAINER_MOUNT_SOURCE
Expand All @@ -29,6 +31,10 @@ Following is a list of environment variables that can be set to control various
- Specifies the path inside the container where the host path is mounted while starting a Fluent container in :func:`launch_fluent() <ansys.fluent.core.launcher.launcher.launch_fluent>`.
* - PYFLUENT_FLUENT_DEBUG
- Starts Fluent in debug mode while launching Fluent in :func:`launch_fluent() <ansys.fluent.core.launcher.launcher.launch_fluent>`.
* - PYFLUENT_DOC_SKIP_CHEATSHEET:
- Skips the generation of cheatsheet.
* - PYFLUENT_DOC_SKIP_EXAMPLES
- Skips the generation of examples documentation.
* - PYFLUENT_FLUENT_IP
- Specifies the IP address of the Fluent server in :func:`connect_to_fluent() <ansys.fluent.core.launcher.launcher.connect_to_fluent>`.
* - PYFLUENT_FLUENT_PORT
Expand All @@ -47,8 +53,6 @@ Following is a list of environment variables that can be set to control various
- Shows the Fluent GUI while launching Fluent in :func:`launch_fluent() <ansys.fluent.core.launcher.launcher.launch_fluent>`.
* - PYFLUENT_SKIP_API_UPGRADE_ADVICE
- Disables printing of TUI to settings API upgrade advice.
* - PYFLUENT_SKIP_EXAMPLES_DOC
- Skips the generation of examples documentation.
* - PYFLUENT_TIMEOUT_FORCE_EXIT
- Enables force exit while exiting a Fluent session and specifies the timeout in seconds.
* - PYFLUENT_WATCHDOG_DEBUG
Expand Down
21 changes: 14 additions & 7 deletions doc/source/user_guide/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,27 @@ The following code triggers a callback at the end of every iteration.

.. code-block:: python
>>> from ansys.fluent.core import SolverEvent
>>> from ansys.fluent.core import SolverEvent, IterationEndedEventInfo
>>>
>>> def on_iteration_ended(session, event_info):
>>> def on_iteration_ended(session, event_info: IterationEndedEventInfo):
>>> print("Iteration ended. Index = ", event_info.index)
>>>
>>> callback_id = solver.events.register_callback(SolverEvent.ITERATION_ENDED, on_iteration_ended)
>>>
The general signature of the callback function is ``cb(session, event_info, <additional arguments>)``, where ``session`` is the session instance
and ``event_info`` instance holds information about the event. The event information classes for each event are documented in the
API reference of the :obj:`~ansys.fluent.core.streaming_services.events_streaming` module. See the callback function
``on_case_loaded_with_args()`` in the below examples for an example of how to pass additional arguments to the callback
function.


Examples
--------

.. code-block:: python
>>> from ansys.fluent.core import MeshingEvent, SolverEvent
>>> from ansys.fluent.core import CaseLoadedEventInfo, DataLoadedEventInfo, SolutionInitializedEventInfo, IterationEndedEventInfo
>>> from ansys.fluent.core.utils.event_loop import execute_in_event_loop_threadsafe
>>> from ansys.fluent.visualization.matplotlib import matplot_windows_manager
>>> from ansys.fluent.visualization.pyvista import pyvista_windows_manager
Expand All @@ -48,26 +55,26 @@ Examples
>>> contour2.surfaces_list = ["symmetry"]
>>>
>>> @execute_in_event_loop_threadsafe
>>> def auto_refersh_call_back_iteration(session, event_info):
>>> def auto_refersh_call_back_iteration(session, event_info: IterationEndedEventInfo):
>>> if event_info.index % 5 == 0:
>>> pyvista_windows_manager.refresh_windows(session.id, ["contour-1", "contour-2"])
>>> matplot_windows_manager.refresh_windows("", ["residual"])
>>>
>>> callback_itr_id = solver.events.register_callback(SolverEvent.ITERATION_ENDED, auto_refersh_call_back_iteration)
>>>
>>> @execute_in_event_loop_threadsafe
>>> def initialize_call_back(session, event_info):
>>> def initialize_call_back(session, event_info: SolutionInitializedEventInfo | DataLoadedEventInfo):
>>> pyvista_windows_manager.refresh_windows(session.id, ["contour-1", "contour-2"])
>>> matplot_windows_manager.refresh_windows("", ["residual"])
>>>
>>> callback_init_id = solver.events.register_callback(SolverEvent.SOLUTION_INITIALIZED, initialize_call_back)
>>>
>>> callback_data_read_id = solver.events.register_callback(SolverEvent.DATA_LOADED, initialize_call_back)
>>>
>>> def on_case_loaded(session, event_info):
>>> def on_case_loaded(session, event_info: CaseLoadedEventInfo):
>>> print("Case loaded. Index = ", event_info.index)
>>>
>>> def on_case_loaded_with_args(x, y, session, event_info):
>>> def on_case_loaded_with_args(session, event_info: CaseLoadedEventInfo, x, y):
>>> print(f"Case loaded with {x}, {y}. Index = ", event_info.index)
>>>
>>> callback = meshing.events.register_callback(MeshingEvent.CASE_LOADED, on_case_loaded)
Expand Down
9 changes: 4 additions & 5 deletions src/ansys/fluent/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ def version_info() -> str:
# Whether to use remote gRPC file transfer service
USE_FILE_TRANSFER_SERVICE = False

# Directory where API files are writes out during codegen
CODEGEN_OUTDIR = (Path(__file__) / ".." / "generated").resolve()

# Whether to zip settings API files during codegen
CODEGEN_ZIP_SETTINGS = os.getenv("PYFLUENT_CODEGEN_ZIP_SETTINGS", False)
# Directory where API files are written out during codegen
CODEGEN_OUTDIR = os.getenv(
"PYFLUENT_CODEGEN_OUTDIR", (Path(__file__) / ".." / "generated").resolve()
)

# Whether to show mesh in Fluent after case read
FLUENT_SHOW_MESH_AFTER_CASE_READ = False
Expand Down
3 changes: 0 additions & 3 deletions src/ansys/fluent/core/codegen/allapigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ def generate(version: str, static_infos: dict):
api_tree = {"<meshing_session>": {}, "<solver_session>": {}}
_update_first_level(api_tree, tuigen.generate(version, static_infos))
_update_first_level(api_tree, datamodelgen.generate(version, static_infos))
if os.getenv("PYFLUENT_USE_OLD_SETTINGSGEN") == "1":
global settingsgen
from ansys.fluent.core.codegen import settingsgen_old as settingsgen
_update_first_level(api_tree, settingsgen.generate(version, static_infos))
api_tree_file = get_api_tree_file_name(version)
Path(api_tree_file).parent.mkdir(parents=True, exist_ok=True)
Expand Down
25 changes: 5 additions & 20 deletions src/ansys/fluent/core/codegen/builtin_settingsgen.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""Generate builtin setting classes."""

import os
from zipimport import zipimporter

from ansys.fluent.core import CODEGEN_OUTDIR, FluentVersion
from ansys.fluent.core.solver.flobject import CreatableNamedObjectMixin, NamedObject
from ansys.fluent.core.solver.settings_builtin_data import DATA
Expand All @@ -12,24 +9,12 @@


def _get_settings_root(version: str):
from ansys.fluent.core import CODEGEN_OUTDIR, CODEGEN_ZIP_SETTINGS, utils
from ansys.fluent.core import CODEGEN_OUTDIR, utils

if os.getenv("PYFLUENT_USE_OLD_SETTINGSGEN") != "1":
settings = utils.load_module(
f"settings_{version}",
CODEGEN_OUTDIR / "solver" / f"settings_{version}.py",
)
else:
if CODEGEN_ZIP_SETTINGS:
importer = zipimporter(
str(CODEGEN_OUTDIR / "solver" / f"settings_{version}.zip")
)
settings = importer.load_module("settings")
else:
settings = utils.load_module(
f"settings_{version}",
CODEGEN_OUTDIR / "solver" / f"settings_{version}" / "__init__.py",
)
settings = utils.load_module(
f"settings_{version}",
CODEGEN_OUTDIR / "solver" / f"settings_{version}.py",
)
return settings.root


Expand Down
Loading

0 comments on commit 2613cbd

Please sign in to comment.