-
Notifications
You must be signed in to change notification settings - Fork 2
256 lines (224 loc) · 8.9 KB
/
fluent-mechanical.yml
File metadata and controls
256 lines (224 loc) · 8.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: Fluent - Mechanical Exhaust Manifold Workflow
on:
workflow_dispatch:
inputs:
doc-build:
required: false
default: false
type: boolean
description: 'Whether to build the documentation'
workflow_call:
inputs:
doc-build:
required: false
default: false
type: boolean
description: 'Whether to build the documentation'
push:
branches:
- main
pull_request:
paths:
- 'fluent-mechanical/**'
env:
MAIN_PYTHON_VERSION: '3.12'
FLUENT_DOCKER_IMAGE: 'ghcr.io/ansys/fluent'
FLUENT_DOCKER_EXEC_COMMAND: ${{ secrets.FLUENT_DOCKER_EXEC_COMMAND }}
MECHANICAL_DOCKER_IMAGE: 'ghcr.io/ansys/mechanical'
DOCKER_MECH_CONTAINER_NAME: mechanical
PYMECHANICAL_PORT: 10000
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER )}}
PYANSYS_WORKFLOWS_CI: true
ANSYS_RELEASE_FOR_DOCS: 25.2
PYMECHANICAL_START_INSTANCE: false
jobs:
is-only-docs-required:
uses: ./.github/workflows/check-docs-required.yml
with:
doc-build: ${{ inputs.doc-build || false }}
fluent:
name: Fluent
runs-on: public-ubuntu-latest-8-cores
needs: is-only-docs-required
strategy:
fail-fast: false
matrix:
ansys-release: ${{ needs.is-only-docs-required.outputs.only-docs == 'true' && fromJSON('[25.2]') || fromJSON('[24.2, 25.1, 25.2]') }}
steps:
- name: Checkout code
uses: actions/checkout@v6.0.1
with:
sparse-checkout: |
fluent-mechanical
doc
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r fluent-mechanical/requirements_${{ matrix.ansys-release }}.txt
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Full Fluent image (name+tag)
run: |
if [[ "${{ matrix.ansys-release }}" == "24.1" || "${{ matrix.ansys-release }}" == "24.2" ]]; then
IMAGE_TAG=v24.2.5
elif [[ "${{ matrix.ansys-release }}" == "25.1" ]]; then
IMAGE_TAG=v25.1.4
else
echo "Unsupported release: ${{ matrix.ansys-release }}"
exit 1
fi
echo "FLUENT_DOCKER_IMAGE=${{ env.FLUENT_DOCKER_IMAGE }}:${IMAGE_TAG}" >> $GITHUB_ENV
- name: Download Fluent service container
run: |
echo "Pulling Fluent image: ${{ env.FLUENT_DOCKER_IMAGE }}"
docker pull ${{ env.FLUENT_DOCKER_IMAGE }}
- name: Update graphics dependencies
run: |
sudo apt-get update
sudo apt-get install -y libegl1-mesa-dev libosmesa6-dev xvfb
- name: Run the Fluent script
env:
FLUENT_IMAGE_TAG: v${{ matrix.ansys-release }}.0
run: |
xvfb-run python fluent-mechanical/wf_fm_01_fluent.py
- name: Store the outputs
uses: actions/upload-artifact@v6
with:
name: fluent-mechanical-workflow-fluent-outputs-${{ matrix.ansys-release }}
path: |
fluent-mechanical/outputs/htc_temp_mapping_LOW_TEMP.csv
fluent-mechanical/outputs/htc_temp_mapping_MEDIUM_TEMP.csv
fluent-mechanical/outputs/htc_temp_mapping_HIGH_TEMP.csv
- name: Stop all containers (if any)
run: |
if [ -n "$(docker ps -a -q)" ]; then
docker rm -f $(docker ps -a -q)
fi
- name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS}})
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
env:
FLUENT_IMAGE_TAG: v${{ matrix.ansys-release }}.0
BUILD_DOCS_SCRIPT: 'fluent-mechanical/wf_fm_01_fluent.py'
run: |
cd doc
pip install -r requirements.txt
xvfb-run make html
- name: (DOCS) Upload docs artifacts
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
uses: actions/upload-artifact@v6
with:
name: fluent-mechanical-docs-stage-fluent
path: |
doc/_build/
doc/source/examples/fluent-mechanical/
overwrite: true
mechanical:
name: Mechanical
runs-on: [public-ubuntu-latest-8-cores]
needs: [fluent, is-only-docs-required]
strategy:
fail-fast: false
matrix:
ansys-release: ${{ needs.is-only-docs-required.outputs.only-docs == 'true' && fromJSON('[25.2]') || fromJSON('[24.2, 25.1, 25.2]') }}
steps:
- name: Checkout code
uses: actions/checkout@v6.0.1
with:
sparse-checkout: |
fluent-mechanical
doc
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y nodejs npm graphviz xvfb
npm install -g @mermaid-js/mermaid-cli
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m venv .venv
. .venv/bin/activate
pip install -r fluent-mechanical/requirements_${{ matrix.ansys-release }}.txt
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download (if needed) launch, and validate Mechanical service
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
MECHANICAL_IMAGE: ${{ env.MECHANICAL_DOCKER_IMAGE }}:${{ matrix.ansys-release }}.0
run: |
docker pull ${{ env.MECHANICAL_IMAGE }}
docker run --restart always --name ${{ env.DOCKER_MECH_CONTAINER_NAME }} -e ANSYSLMD_LICENSE_FILE=1055@${{ env.LICENSE_SERVER }} -p ${{ env.PYMECHANICAL_PORT }}:10000 ${{ env.MECHANICAL_IMAGE }} > log.txt &
# Wait for Mechanical to initialize with intelligent polling
max_wait=300 # Maximum wait time in seconds
check_interval=10 # Check every 10 seconds
elapsed=0
echo "Waiting for Mechanical to initialize..."
while [ $elapsed -lt $max_wait ]; do
if grep -q 'WB Initialize Done' log.txt 2>/dev/null; then
echo "Mechanical initialized successfully after ${elapsed} seconds"
break
fi
echo "Waiting for initialization... (${elapsed}/${max_wait}s)"
sleep $check_interval
elapsed=$((elapsed + check_interval))
done
# Final check
if ! grep -q 'WB Initialize Done' log.txt 2>/dev/null; then
echo "ERROR: Mechanical failed to initialize within ${max_wait} seconds"
echo "=== Last 50 lines of log.txt ==="
tail -n 50 log.txt || echo "No log file found"
exit 1
fi
- name: Check out the fluent outputs
uses: actions/download-artifact@v7
with:
name: fluent-mechanical-workflow-fluent-outputs-${{ matrix.ansys-release }}
path: fluent-mechanical/outputs
- name: Run the PyMechanical script
run: |
. .venv/bin/activate
xvfb-run python fluent-mechanical/wf_fm_02_mechanical.py
- name: Store the outputs
uses: actions/upload-artifact@v6
with:
name: fluent-mechanical-workflow-mechanical-outputs-${{ matrix.ansys-release }}
path: fluent-mechanical/outputs
- name: (DOCS) Download the docs artifacts
uses: actions/download-artifact@v7
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
with:
name: fluent-mechanical-docs-stage-fluent
path: doc
- name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS }})
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
env:
BUILD_DOCS_SCRIPT: 'fluent-mechanical/wf_fm_02_mechanical.py'
run: |
. .venv/bin/activate
cd doc
pip install -r requirements.txt
xvfb-run make html
- name: (DOCS) Upload docs artifacts
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
uses: actions/upload-artifact@v6
with:
name: fluent-mechanical-docs
path: |
doc/_build/
doc/source/examples/fluent-mechanical/
overwrite: true