Skip to content

Commit 3700d42

Browse files
committed
Connect with docker session in examples
1 parent 2af58a5 commit 3700d42

File tree

4 files changed

+82
-14
lines changed

4 files changed

+82
-14
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
branches:
1111
- main
1212

13+
concurrency:
14+
group: ${{ github.ref }}
15+
cancel-in-progress: true
16+
1317
jobs:
1418
stylecheck:
1519
name: Style Check
@@ -119,12 +123,25 @@ jobs:
119123
- name: Install pyfluent with post module
120124
run: make install-post
121125

126+
- name: Login to GitHub Container Registry
127+
uses: docker/login-action@v1
128+
with:
129+
registry: ghcr.io
130+
username: ${{ secrets.GH_USERNAME }}
131+
password: ${{ secrets.REPO_DOWNLOAD_PAT }}
132+
133+
- name: Pull Fluent docker image
134+
run: make docker-pull
135+
122136
- name: Build Documentation
123137
run: |
124138
pip install -r requirements_docs.txt
125139
make -C doc html
126140
touch doc/_build/html/.nojekyll
127141
echo "fluentdocs.pyansys.com" >> doc/_build/html/CNAME
142+
env:
143+
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
144+
PYFLUENT_RUN_EXAMPLES_WITH_DOCKER: "1"
128145

129146
- name: Upload HTML Documentation
130147
uses: actions/upload-artifact@v2

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ install-pyvistaqt-requirements:
1818
@sudo apt-get update
1919
@sudo apt-get install libegl1 -y
2020

21+
docker-pull:
22+
@docker pull ghcr.io/pyansys/pyfluent:latest
23+
2124
test-import:
2225
@python -c "import ansys.fluent.core as pyfluent"
2326

examples/00-fluent/mixing_elbow_settings_api.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,34 @@
4141

4242
# First, start Fluent as a service with Meshing Mode, Double Precision, Number
4343
# of Processors 4
44+
import os
45+
import subprocess
46+
from time import sleep
47+
4448
import ansys.fluent.core as pyfluent
49+
from ansys.fluent.core import examples
4550

46-
s = pyfluent.launch_fluent(
47-
meshing_mode=True, precision="double", processor_count="4"
48-
)
51+
if "PYFLUENT_RUN_EXAMPLES_WITH_DOCKER" in os.environ:
52+
examples.download_file("mixing_elbow.pmdb", "pyfluent/mixing_elbow")
53+
examples.download_file("mixing_elbow.scdoc", "pyfluent/mixing_elbow")
54+
55+
license_server = os.getenv("LICENSE_SERVER", "leblnxlic64.ansys.com")
56+
subprocess.run(["docker", "run", "-d", "--rm", "-p", "63084:63084",
57+
"-v", f"{pyfluent.EXAMPLES_PATH}:/examples",
58+
"-e", f"ANSYSLMD_LICENSE_FILE=1055@{license_server}",
59+
"-e", "REMOTING_PORTS=63084/portspan=2",
60+
"-e", "FLUENT_LAUNCHED_FROM_PYFLUENT=1",
61+
"ghcr.io/pyansys/pyfluent",
62+
"3ddp", "-t4", "-meshing", "-g", "-sifile=server.txt"])
63+
sleep(60)
64+
65+
s = pyfluent.launch_fluent(
66+
start_instance=False, ip="localhost", port=63084
67+
)
68+
else:
69+
s = pyfluent.launch_fluent(
70+
meshing_mode=True, precision="double", processor_count="4"
71+
)
4972

5073
###############################################################################
5174

@@ -58,9 +81,12 @@
5881
# Import the CAD geometry. For Length Units, select "in".
5982
# Execute the Import Geometry task.
6083

61-
84+
if "PYFLUENT_RUN_EXAMPLES_WITH_DOCKER" in os.environ:
85+
filename = "/examples/mixing_elbow.pmdb"
86+
else:
87+
filename = "mixing_elbow.pmdb"
6288
s.workflow.TaskObject["Import Geometry"].Arguments = dict(
63-
FileName="mixing_elbow.pmdb", LengthUnit="in"
89+
FileName=filename, LengthUnit="in"
6490
)
6591

6692
s.workflow.TaskObject["Import Geometry"].Execute()
@@ -525,4 +551,3 @@
525551
# s.tui.solver.file.write_case_data('mixing_elbow2_set.cas.h5').result()
526552

527553
###############################################################################
528-
s.exit()

examples/00-fluent/mixing_elbow_tui_api.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,34 @@
4040

4141
# First, start Fluent as a service with Meshing Mode, Double Precision, Number
4242
# of Processors 4
43+
import os
44+
import subprocess
45+
from time import sleep
46+
4347
import ansys.fluent.core as pyfluent
48+
from ansys.fluent.core import examples
4449

45-
s = pyfluent.launch_fluent(
46-
meshing_mode=True, precision="double", processor_count="4"
47-
)
50+
if "PYFLUENT_RUN_EXAMPLES_WITH_DOCKER" in os.environ:
51+
examples.download_file("mixing_elbow.pmdb", "pyfluent/mixing_elbow")
52+
examples.download_file("mixing_elbow.scdoc", "pyfluent/mixing_elbow")
53+
54+
license_server = os.getenv("LICENSE_SERVER", "leblnxlic64.ansys.com")
55+
subprocess.run(["docker", "run", "-d", "--rm", "-p", "63084:63084",
56+
"-v", f"{pyfluent.EXAMPLES_PATH}:/examples",
57+
"-e", f"ANSYSLMD_LICENSE_FILE=1055@{license_server}",
58+
"-e", "REMOTING_PORTS=63084/portspan=2",
59+
"-e", "FLUENT_LAUNCHED_FROM_PYFLUENT=1",
60+
"ghcr.io/pyansys/pyfluent",
61+
"3ddp", "-t4", "-meshing", "-g", "-sifile=server.txt"])
62+
sleep(60)
63+
64+
s = pyfluent.launch_fluent(
65+
start_instance=False, ip="localhost", port=63084
66+
)
67+
else:
68+
s = pyfluent.launch_fluent(
69+
meshing_mode=True, precision="double", processor_count="4"
70+
)
4871

4972
###############################################################################
5073

@@ -57,9 +80,12 @@
5780
# Import the CAD geometry. For Length Units, select "in".
5881
# Execute the Import Geometry task.
5982

60-
83+
if "PYFLUENT_RUN_EXAMPLES_WITH_DOCKER" in os.environ:
84+
filename = "/examples/mixing_elbow.pmdb"
85+
else:
86+
filename = "mixing_elbow.pmdb"
6187
s.workflow.TaskObject["Import Geometry"].Arguments = dict(
62-
FileName="mixing_elbow.pmdb", LengthUnit="in"
88+
FileName=filename, LengthUnit="in"
6389
)
6490

6591
s.workflow.TaskObject["Import Geometry"].Execute()
@@ -530,6 +556,3 @@
530556
# s.tui.solver.file.write_case_data("mixing_elbow2_tui.cas.h5").result()
531557

532558
###############################################################################
533-
534-
# Exit from Ansys Fluent
535-
s.exit()

0 commit comments

Comments
 (0)