diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml deleted file mode 100644 index f8179989..00000000 --- a/.github/workflows/ci_cd.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: GitHub CI -on: - pull_request: - workflow_dispatch: - push: - tags: - - "*" - branches: - - main - -env: - MAIN_PYTHON_VERSION: '3.12' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - code-style: - name: "Code style checks" - runs-on: ubuntu-latest - steps: - - name: "Run PyAnsys code style checks" - uses: ansys/actions/code-style@v9 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 55551e0f..00000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: Documentation build - -on: - workflow_dispatch: - schedule: - - cron: "0 1 * * *" - -env: - MAIN_PYTHON_VERSION: '3.12' - DOCUMENTATION_CNAME: 'workflows.docs.pyansys.com' - -jobs: - geometry-mesh: - uses: ./.github/workflows/geometry-mesh.yml - secrets: inherit - with: - doc-build: true - - geometry-mesh-fluent: - uses: ./.github/workflows/geometry-mesh-fluent.yml - secrets: inherit - with: - doc-build: true - - geometry-mechanical-dpf: - uses: ./.github/workflows/geometry-mechanical-dpf.yml - secrets: inherit - with: - doc-build: true - - fluent-mechanical: - uses: ./.github/workflows/fluent-mechanical.yml - secrets: inherit - with: - doc-build: true - - compile-docs: - runs-on: ubuntu-latest - needs: [geometry-mesh, geometry-mesh-fluent, geometry-mechanical-dpf, fluent-mechanical] - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ref: main - fetch-depth: 0 - - - name: Set up Python ${{ env.MAIN_PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r doc/requirements.txt - - - name: Download artifacts for geometry-mesh - uses: actions/download-artifact@v4 - with: - name: geometry-mesh-docs - path: doc/ - - - name: Download artifacts for geometry-mesh-fluent - uses: actions/download-artifact@v4 - with: - name: geometry-mesh-fluent-docs - path: doc/ - - - name: Download artifacts for geometry-mechanical-dpf - uses: actions/download-artifact@v4 - with: - name: geometry-mechanical-dpf-docs - path: doc/ - - - name: Download artifacts for fluent-mechanical - uses: actions/download-artifact@v4 - with: - name: fluent-mechanical-docs - path: doc/ - - - name: Build the documentation - run: | - cd doc - make html - - - name: Upload the documentation - uses: actions/upload-artifact@v4 - with: - name: documentation-html - path: doc/_build/html/ - - publish-docs: - runs-on: ubuntu-latest - needs: compile-docs - steps: - - name: "Download the documentation artifact" - uses: actions/download-artifact@v4 - with: - name: documentation-html - path: doc - - - name: List all files - run: ls -R . - - - name: "Deploy documentation to gh-pages" - uses: peaceiris/actions-gh-pages@v4 - with: - publish_dir: ./doc - commit_message: "DOC: update documentation" - github_token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - cname: ${{ env.DOCUMENTATION_CNAME }} - force_orphan: true diff --git a/.github/workflows/fluent-mechanical.yml b/.github/workflows/fluent-mechanical.yml deleted file mode 100644 index 0cb93e00..00000000 --- a/.github/workflows/fluent-mechanical.yml +++ /dev/null @@ -1,232 +0,0 @@ -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/pyfluent' - 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.1 - RUN_DOC_BUILD: false - PYMECHANICAL_START_INSTANCE: false - -jobs: - fluent: - name: Fluent - runs-on: public-ubuntu-latest-8-cores - strategy: - fail-fast: false - matrix: - ansys-release: [24.1, 24.2, 25.1] - steps: - - - name: Checkout code - uses: actions/checkout@v4 - with: - sparse-checkout: | - fluent-mechanical - doc - - - name: Set up Python ${{ env.MAIN_PYTHON_VERSION }} - uses: actions/setup-python@v5 - 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: Download Fluent service container - run: docker pull ${{ env.FLUENT_DOCKER_IMAGE }}:v${{ matrix.ansys-release }}.0 - - - name: Run the Fluent script - env: - FLUENT_IMAGE_TAG: v${{ matrix.ansys-release }}.0 - run: | - python fluent-mechanical/wf_fm_01_fluent.py - - - name: Store the outputs - uses: actions/upload-artifact@v4 - 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) Check if docs should be built - if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && inputs.doc-build - run: | - echo "Requested to build docs..." - if [ "${{ matrix.ansys-release }}" == "${{ env.ANSYS_RELEASE_FOR_DOCS }}" ]; then - echo "Building docs" - echo "RUN_DOC_BUILD=true" >> $GITHUB_ENV - else - echo "Not building docs - since not primary release" - echo "RUN_DOC_BUILD=false" >> $GITHUB_ENV - fi - - - name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS}}) - if: ${{ env.RUN_DOC_BUILD == 'true' }} - 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 - make html - - - name: (DOCS) Upload docs artifacts - if: ${{ env.RUN_DOC_BUILD == 'true' }} - uses: actions/upload-artifact@v4 - 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 - strategy: - fail-fast: false - matrix: - ansys-release: [24.1, 24.2, 25.1] - steps: - - - name: Checkout code - uses: actions/checkout@v4 - with: - sparse-checkout: | - fluent-mechanical - doc - - - name: Set up Python ${{ env.MAIN_PYTHON_VERSION }} - uses: actions/setup-python@v5 - 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 & - grep -q 'WB Initialize Done' <(timeout 60 tail -f log.txt) - - - name: Check out the fluent outputs - uses: actions/download-artifact@v4 - 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@v4 - with: - name: fluent-mechanical-workflow-mechanical-outputs-${{ matrix.ansys-release }} - path: fluent-mechanical/outputs - - - name: (DOCS) Check if docs should be built - if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && inputs.doc-build - run: | - echo "Requested to build docs..." - if [ "${{ matrix.ansys-release }}" = "${{ env.ANSYS_RELEASE_FOR_DOCS }}" ]; then - echo "Building docs" - echo "RUN_DOC_BUILD=true" >> $GITHUB_ENV - else - echo "Not building docs - since not primary release" - echo "RUN_DOC_BUILD=false" >> $GITHUB_ENV - fi - - - name: (DOCS) Download the docs artifacts - uses: actions/download-artifact@v4 - if: ${{ env.RUN_DOC_BUILD == 'true' }} - with: - name: fluent-mechanical-docs-stage-fluent - path: doc - - - name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS }}) - if: ${{ env.RUN_DOC_BUILD == 'true' }} - 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: ${{ env.RUN_DOC_BUILD == 'true' }} - uses: actions/upload-artifact@v4 - with: - name: fluent-mechanical-docs - path: | - doc/_build/ - doc/source/examples/fluent-mechanical/ - overwrite: true \ No newline at end of file diff --git a/.github/workflows/geometry-mechanical-dpf.yml b/.github/workflows/geometry-mechanical-dpf.yml index 84d74941..de701ad7 100644 --- a/.github/workflows/geometry-mechanical-dpf.yml +++ b/.github/workflows/geometry-mechanical-dpf.yml @@ -31,7 +31,13 @@ env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER )}} PYANSYS_WORKFLOWS_CI: true ANSYS_RELEASE_FOR_DOCS: 25.1 - RUN_DOC_BUILD: false + RUN_DOC_BUILD: true + DOCKER_IMAGE_PRIME_NAME: ghcr.io/ansys/prime + DOCKER_IMAGE_PRIME_TAG: '25.2.0' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: geometry: @@ -40,7 +46,7 @@ jobs: strategy: fail-fast: false matrix: - ansys-release: [24.1, 24.2, 25.1] + ansys-release: [25.1] steps: - name: Checkout code @@ -86,6 +92,11 @@ jobs: # Define the ANSYS_GEOMETRY_RELEASE environment variable to be used in the next stages echo "ANSYS_GEOMETRY_RELEASE=$env:ANSYS_GEOMETRY_RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Append + + - name: Pull prime service + run: | + docker pull ${{ env.DOCKER_IMAGE_PRIME_NAME }}:${{ env.DOCKER_IMAGE_PRIME_TAG }} + - name: Run the PyAnsys Geometry script run: | .venv/Scripts/activate diff --git a/.github/workflows/geometry-mesh-fluent.yml b/.github/workflows/geometry-mesh-fluent.yml deleted file mode 100644 index a85f3fa7..00000000 --- a/.github/workflows/geometry-mesh-fluent.yml +++ /dev/null @@ -1,345 +0,0 @@ -name: Geometry Mesh Fluent 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: - - 'geometry-mesh-fluent/**' - -env: - MAIN_PYTHON_VERSION: '3.12' - GEOMETRY_DOCKER_IMAGE: 'ghcr.io/ansys/geometry' - FLUENT_DOCKER_IMAGE: 'ghcr.io/ansys/pyfluent' - ANSRV_GEO_PORT: 700 - ANSRV_GEO_LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} - ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER )}} - PYANSYS_WORKFLOWS_CI: true - ANSYS_RELEASE_FOR_DOCS: 25.1 - RUN_DOC_BUILD: false - -jobs: - geometry: - name: Geometry - runs-on: [self-hosted, Windows, pyansys-workflows] - strategy: - fail-fast: false - matrix: - ansys-release: [24.1, 24.2, 25.1] - steps: - - - name: Checkout code - uses: actions/checkout@v4 - with: - sparse-checkout: | - geometry-mesh-fluent - doc - - - name: Set up Python ${{ env.MAIN_PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: Setup headless display - uses: pyvista/setup-headless-display-action@v4 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m venv .venv - .venv/Scripts/activate - pip install -r geometry-mesh-fluent/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) and run Geometry service container - run: | - # If we are on 25.1 or above - the tag name is different - remember we are on powershell - if (${{ matrix.ansys-release }} -ge 25.2) { - $env:ANSYS_GEOMETRY_RELEASE = "${{ env.GEOMETRY_DOCKER_IMAGE }}:core-windows-${{ matrix.ansys-release }}" - } else { - $env:ANSYS_GEOMETRY_RELEASE = "${{ env.GEOMETRY_DOCKER_IMAGE }}:windows-${{ matrix.ansys-release }}" - } - Write-Host "Running Geometry service container: $env:ANSYS_GEOMETRY_RELEASE" - # Pull the container image - docker pull $env:ANSYS_GEOMETRY_RELEASE - # Define the ANSYS_GEOMETRY_RELEASE environment variable to be used in the next stages - echo "ANSYS_GEOMETRY_RELEASE=$env:ANSYS_GEOMETRY_RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Append - - - name: Run the PyAnsys Geometry script - run: | - .venv/Scripts/activate - python geometry-mesh-fluent/wf_gmf_01_geometry.py - - - name: Store the outputs - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-fluent-workflow-geometry-outputs-${{ matrix.ansys-release }} - path: geometry-mesh-fluent/outputs - - - name: (DOCS) Check if docs should be built - if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && inputs.doc-build - run: | - Write-Host "Requested to build docs..." - if ("${{ matrix.ansys-release }}" -eq $env:ANSYS_RELEASE_FOR_DOCS) { - Write-Host "Building docs" - echo "RUN_DOC_BUILD=true" >> $env:GITHUB_ENV - } else { - Write-Host "Not building docs - since not primary release" - echo "RUN_DOC_BUILD=false" >> $env:GITHUB_ENV - } - - - name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS}}) - if: ${{ env.RUN_DOC_BUILD == 'true' }} - env: - BUILD_DOCS_SCRIPT: 'geometry-mesh-fluent/wf_gmf_01_geometry.py' - run: | - .venv/Scripts/activate - cd doc - pip install -r requirements.txt - ./make.bat html - - - name: (DOCS) Upload docs artifacts - if: ${{ env.RUN_DOC_BUILD == 'true' }} - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-fluent-docs-stage-geometry - path: | - doc/_build/ - doc/source/examples/geometry-mesh-fluent/ - - - name: Stop any remaining containers - if: always() - run: | - $dockerContainers = docker ps -a -q - if (-not [string]::IsNullOrEmpty($dockerContainers)) { - docker stop $dockerContainers - docker rm $dockerContainers - } - - fluent-mesh: - name: Fluent Meshing - runs-on: public-ubuntu-latest-8-cores - needs: geometry - strategy: - fail-fast: false - matrix: - ansys-release: [24.1, 24.2, 25.1] - steps: - - - name: Checkout code - uses: actions/checkout@v4 - with: - sparse-checkout: | - geometry-mesh-fluent - doc - - - name: Set up Python ${{ env.MAIN_PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r geometry-mesh-fluent/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 Fluent service container - run: docker pull ${{ env.FLUENT_DOCKER_IMAGE }}:v${{ matrix.ansys-release }}.0 - - - name: Check out the geometry outputs - uses: actions/download-artifact@v4 - with: - name: geometry-mesh-fluent-workflow-geometry-outputs-${{ matrix.ansys-release }} - path: geometry-mesh-fluent/outputs - - - name: Run the Fluent meshing script - env: - FLUENT_IMAGE_TAG: v${{ matrix.ansys-release }}.0 - run: | - python geometry-mesh-fluent/wf_gmf_02_fluent_meshing.py - - - name: Store the outputs - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-fluent-workflow-fluent-mesh-outputs-${{ matrix.ansys-release }} - path: | - geometry-mesh-fluent/outputs/NACA_Airfoil_*.pmdb - geometry-mesh-fluent/outputs/NACA_Airfoil_*.msh.h5 - - - name: Stop all containers (if any) - run: | - if [ -n "$(docker ps -a -q)" ]; then - docker rm -f $(docker ps -a -q) - fi - - - name: (DOCS) Check if docs should be built - if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && inputs.doc-build - run: | - echo "Requested to build docs..." - if [ "${{ matrix.ansys-release }}" == "${{ env.ANSYS_RELEASE_FOR_DOCS }}" ]; then - echo "Building docs" - echo "RUN_DOC_BUILD=true" >> $GITHUB_ENV - else - echo "Not building docs - since not primary release" - echo "RUN_DOC_BUILD=false" >> $GITHUB_ENV - fi - - - name: (DOCS) Download the docs artifacts - uses: actions/download-artifact@v4 - if: ${{ env.RUN_DOC_BUILD == 'true' }} - with: - name: geometry-mesh-fluent-docs-stage-geometry - path: doc - - - name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS}}) - if: ${{ env.RUN_DOC_BUILD == 'true' }} - env: - FLUENT_IMAGE_TAG: v${{ matrix.ansys-release }}.0 - BUILD_DOCS_SCRIPT: 'geometry-mesh-fluent/wf_gmf_02_fluent_meshing.py' - run: | - cd doc - find . -type f -exec sed -i 's|C:\\Users\\ansys\\actions-runner\\_work\\pyansys-workflows\\pyansys-workflows\\doc\\source\\examples\\geometry-mesh-fluent\\images\\|./images/|g' {} + - pip install -r requirements.txt - make html - - - name: (DOCS) Upload docs artifacts - if: ${{ env.RUN_DOC_BUILD == 'true' }} - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-fluent-docs-stage-mesh - path: | - doc/_build/ - doc/source/examples/geometry-mesh-fluent/ - overwrite: true - - fluent-solve: - name: Fluent Solver - runs-on: public-ubuntu-latest-8-cores # Potential memory issues with 24.1 otherwise - needs: fluent-mesh - strategy: - fail-fast: false - matrix: - ansys-release: [24.1, 24.2, 25.1] - steps: - - - name: Checkout code - uses: actions/checkout@v4 - with: - sparse-checkout: | - geometry-mesh-fluent - doc - - - name: Set up Python ${{ env.MAIN_PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r geometry-mesh-fluent/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 Fluent service container - run: docker pull ${{ env.FLUENT_DOCKER_IMAGE }}:v${{ matrix.ansys-release }}.0 - - - name: Check out the meshing outputs - uses: actions/download-artifact@v4 - with: - name: geometry-mesh-fluent-workflow-fluent-mesh-outputs-${{ matrix.ansys-release }} - path: geometry-mesh-fluent/outputs - - - name: Run the Fluent solver script - env: - FLUENT_IMAGE_TAG: v${{ matrix.ansys-release }}.0 - run: | - python geometry-mesh-fluent/wf_gmf_03_fluent_solver.py - - - name: Store the outputs - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-fluent-workflow-fluent-solve-outputs-${{ matrix.ansys-release }} - path: | - geometry-mesh-fluent/outputs/NACA_Airfoil_*.pmdb - geometry-mesh-fluent/outputs/NACA_Airfoil_*.msh.h5 - geometry-mesh-fluent/outputs/NACA_Airfoil_*.cas.h5 - geometry-mesh-fluent/outputs/NACA_Airfoil_*.dat.h5 - - - name: Stop all containers (if any) - run: | - if [ -n "$(docker ps -a -q)" ]; then - docker rm -f $(docker ps -a -q) - fi - - - name: (DOCS) Check if docs should be built - if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && inputs.doc-build - run: | - echo "Requested to build docs..." - if [ "${{ matrix.ansys-release }}" == "${{ env.ANSYS_RELEASE_FOR_DOCS }}" ]; then - echo "Building docs" - echo "RUN_DOC_BUILD=true" >> $GITHUB_ENV - else - echo "Not building docs - since not primary release" - echo "RUN_DOC_BUILD=false" >> $GITHUB_ENV - fi - - - name: (DOCS) Download the docs artifacts - uses: actions/download-artifact@v4 - if: ${{ env.RUN_DOC_BUILD == 'true' }} - with: - name: geometry-mesh-fluent-docs-stage-mesh - path: doc - - - name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS}}) - if: ${{ env.RUN_DOC_BUILD == 'true' }} - env: - FLUENT_IMAGE_TAG: v${{ matrix.ansys-release }}.0 - BUILD_DOCS_SCRIPT: 'geometry-mesh-fluent/wf_gmf_03_fluent_solver.py' - run: | - cd doc - pip install -r requirements.txt - make html - - - name: (DOCS) Upload docs artifacts - if: ${{ env.RUN_DOC_BUILD == 'true' }} - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-fluent-docs - path: | - doc/_build/ - doc/source/examples/geometry-mesh-fluent/ - overwrite: true diff --git a/.github/workflows/geometry-mesh.yml b/.github/workflows/geometry-mesh.yml deleted file mode 100644 index bdcc8c4f..00000000 --- a/.github/workflows/geometry-mesh.yml +++ /dev/null @@ -1,236 +0,0 @@ -name: Geometry Mesh 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: - - 'geometry-mesh/**' - -env: - MAIN_PYTHON_VERSION: '3.12' - GEOMETRY_DOCKER_IMAGE: 'ghcr.io/ansys/geometry' - PRIME_DOCKER_IMAGE: 'ghcr.io/ansys/prime' - ANSRV_GEO_PORT: 700 - ANSRV_GEO_LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} - PYPRIMEMESH_LAUNCH_CONTAINER: 1 - ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER )}} - ANSYS_RELEASE_FOR_DOCS: 25.1 - RUN_DOC_BUILD: false - -jobs: - geometry: - name: Geometry - runs-on: [self-hosted, Windows, pyansys-workflows] - strategy: - fail-fast: false - matrix: - ansys-release: [24.1, 24.2, 25.1] - steps: - - - name: Checkout code - uses: actions/checkout@v4 - with: - sparse-checkout: | - geometry-mesh - doc - - - name: Set up Python ${{ env.MAIN_PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: Setup headless display - uses: pyvista/setup-headless-display-action@v4 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m venv .venv - .venv/Scripts/activate - pip install -r geometry-mesh/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) and run Geometry service container - run: | - # If we are on 25.1 or above - the tag name is different - remember we are on powershell - if (${{ matrix.ansys-release }} -ge 25.2) { - $env:ANSYS_GEOMETRY_RELEASE = "${{ env.GEOMETRY_DOCKER_IMAGE }}:core-windows-${{ matrix.ansys-release }}" - } else { - $env:ANSYS_GEOMETRY_RELEASE = "${{ env.GEOMETRY_DOCKER_IMAGE }}:windows-${{ matrix.ansys-release }}" - } - Write-Host "Running Geometry service container: $env:ANSYS_GEOMETRY_RELEASE" - # Pull the container image - docker pull $env:ANSYS_GEOMETRY_RELEASE - # Define the ANSYS_GEOMETRY_RELEASE environment variable to be used in the next stages - echo "ANSYS_GEOMETRY_RELEASE=$env:ANSYS_GEOMETRY_RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Append - - - name: Run the PyAnsys Geometry script - run: | - .venv/Scripts/activate - python geometry-mesh/wf_gm_01_geometry.py - - - name: Store the outputs - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-workflow-geometry-outputs-${{ matrix.ansys-release }} - path: geometry-mesh/outputs - - - name: (DOCS) Check if docs should be built - if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && inputs.doc-build - run: | - Write-Host "Requested to build docs..." - if ("${{ matrix.ansys-release }}" -eq $env:ANSYS_RELEASE_FOR_DOCS) { - Write-Host "Building docs" - echo "RUN_DOC_BUILD=true" >> $env:GITHUB_ENV - } else { - Write-Host "Not building docs - since not primary release" - echo "RUN_DOC_BUILD=false" >> $env:GITHUB_ENV - } - - - name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS}}) - if: ${{ env.RUN_DOC_BUILD == 'true' }} - env: - BUILD_DOCS_SCRIPT: 'geometry-mesh/wf_gm_01_geometry.py' - run: | - .venv/Scripts/activate - cd doc - pip install -r requirements.txt - ./make.bat html - - - name: (DOCS) Upload docs artifacts - if: ${{ env.RUN_DOC_BUILD == 'true' }} - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-docs-stage-geometry - path: | - doc/_build/ - doc/source/examples/geometry-mesh/ - - - name: Stop any remaining containers - if: always() - run: | - $dockerContainers = docker ps -a -q - if (-not [string]::IsNullOrEmpty($dockerContainers)) { - docker stop $dockerContainers - docker rm $dockerContainers - } - - prime: - name: Meshing - runs-on: ubuntu-latest - needs: geometry - strategy: - fail-fast: false - matrix: - ansys-release: [24.1, 24.2, 25.1] - steps: - - - name: Checkout code - uses: actions/checkout@v4 - with: - sparse-checkout: | - geometry-mesh - doc - - - name: Set up Python ${{ env.MAIN_PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: Setup headless display - uses: pyvista/setup-headless-display-action@v4 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r geometry-mesh/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 PRIME service container - run: docker pull ${{ env.PRIME_DOCKER_IMAGE }}:${{ matrix.ansys-release }} - - - name: Check out the geometry outputs - uses: actions/download-artifact@v4 - with: - name: geometry-mesh-workflow-geometry-outputs-${{ matrix.ansys-release }} - path: geometry-mesh/outputs - - - name: Run the PyPrimeMesh script - env: - PYPRIMEMESH_IMAGE_TAG: ${{ matrix.ansys-release }} - run: | - python geometry-mesh/wf_gm_02_mesh.py - - - name: Store the outputs - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-workflow-prime-outputs-${{ matrix.ansys-release }} - path: geometry-mesh/outputs - - - name: (DOCS) Check if docs should be built - if: (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && inputs.doc-build - run: | - echo "Requested to build docs..." - if [ "${{ matrix.ansys-release }}" == "${{ env.ANSYS_RELEASE_FOR_DOCS }}" ]; then - echo "Building docs" - echo "RUN_DOC_BUILD=true" >> $GITHUB_ENV - else - echo "Not building docs - since not primary release" - echo "RUN_DOC_BUILD=false" >> $GITHUB_ENV - fi - - - name: (DOCS) Download the docs artifacts - uses: actions/download-artifact@v4 - if: ${{ env.RUN_DOC_BUILD == 'true' }} - with: - name: geometry-mesh-docs-stage-geometry - path: doc - - - name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS}}) - if: ${{ env.RUN_DOC_BUILD == 'true' }} - env: - PYPRIMEMESH_IMAGE_TAG: ${{ matrix.ansys-release }} - BUILD_DOCS_SCRIPT: 'geometry-mesh/wf_gm_02_mesh.py' - run: | - cd doc - find . -type f -exec sed -i 's|C:\\Users\\ansys\\actions-runner\\_work\\pyansys-workflows\\pyansys-workflows\\doc\\source\\examples\\geometry-mesh\\images\\|./images/|g' {} + - pip install -r requirements.txt - make html - - - name: (DOCS) Upload docs artifacts - if: ${{ env.RUN_DOC_BUILD == 'true' }} - uses: actions/upload-artifact@v4 - with: - name: geometry-mesh-docs - path: | - doc/_build/ - doc/source/examples/geometry-mesh/ - overwrite: true diff --git a/doc/make.bat b/doc/make.bat index caaa0c6b..e8082244 100644 --- a/doc/make.bat +++ b/doc/make.bat @@ -14,17 +14,17 @@ if "%1" == "" goto help if "%1" == "clean" goto clean REM Check if vtk is installed - if so, uninstall and install vtk-osmesa -set IS_VTK_INSTALLED=0 -pip show vtk >NUL 2>NUL -if %ERRORLEVEL% EQU 0 ( - set IS_VTK_INSTALLED=1 - echo Uninstalling vtk... - pip uninstall -y vtk -) -if %IS_VTK_INSTALLED% EQU 1 ( - echo Installing vtk-osmesa... - pip install --extra-index-url https://wheels.vtk.org vtk-osmesa==9.3.0 -) +REM set IS_VTK_INSTALLED=0 +REM pip show vtk >NUL 2>NUL +REM if %ERRORLEVEL% EQU 0 ( +REM set IS_VTK_INSTALLED=1 +REM echo Uninstalling vtk... +REM pip uninstall -y vtk +REM ) +REM if %IS_VTK_INSTALLED% EQU 1 ( +REM echo Installing vtk-osmesa... +REM pip install --extra-index-url https://wheels.vtk.org vtk-osmesa==9.3.0 +REM ) %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( diff --git a/geometry-mechanical-dpf/outputs/pcb.pmdb b/geometry-mechanical-dpf/outputs/pcb.pmdb new file mode 100644 index 00000000..3154f79d Binary files /dev/null and b/geometry-mechanical-dpf/outputs/pcb.pmdb differ diff --git a/geometry-mechanical-dpf/requirements_24.1.txt b/geometry-mechanical-dpf/requirements_24.1.txt index 26ec07f9..58adb870 100644 --- a/geometry-mechanical-dpf/requirements_24.1.txt +++ b/geometry-mechanical-dpf/requirements_24.1.txt @@ -1,3 +1,3 @@ -ansys-geometry-core[all]==0.7.6 +ansys-geometry-core[all]==0.4.14 ansys-mechanical-core==0.11.7 ansys-dpf-core[plotting]==0.12.2 diff --git a/geometry-mechanical-dpf/requirements_25.1.txt b/geometry-mechanical-dpf/requirements_25.1.txt index cc5e30d0..d94a6289 100644 --- a/geometry-mechanical-dpf/requirements_25.1.txt +++ b/geometry-mechanical-dpf/requirements_25.1.txt @@ -1,3 +1,4 @@ ansys-geometry-core[all]==0.9.2 ansys-mechanical-core==0.11.13 ansys-dpf-core[plotting]==0.13.4 +ansys-meshing-prime[all]==0.8.1 diff --git a/geometry-mechanical-dpf/wf_gmd_01_geometry.py b/geometry-mechanical-dpf/wf_gmd_01_geometry.py index 2da8f765..f5d30deb 100644 --- a/geometry-mechanical-dpf/wf_gmd_01_geometry.py +++ b/geometry-mechanical-dpf/wf_gmd_01_geometry.py @@ -1,216 +1,240 @@ -# Copyright (C) 2024 - 2025 ANSYS, Inc. and/or its affiliates. -# SPDX-License-Identifier: MIT -# -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -""" -.. _ref_geometry_mech_dpf_01-geometry: - -Geometry generation -################### - -This example shows how to generate a simple PCB using PyAnsys Geometry via -the Ansys Geometry Service. The example demonstrates how to create a sketch, -perform modeling operations, and export the file in different formats (in this -specific case, PMDB). - -""" # noqa: D400, D415 - -import os -from pathlib import Path - -from ansys.geometry.core import launch_modeler -from ansys.geometry.core.connection import GEOMETRY_SERVICE_DOCKER_IMAGE, GeometryContainers -from ansys.geometry.core.designer import DesignFileFormat -from ansys.geometry.core.math import Plane, Point2D, Point3D, UnitVector3D -from ansys.geometry.core.misc import DEFAULT_UNITS, UNITS -from ansys.geometry.core.sketch import Sketch - -############################################################################### -# Preparing the environment -# ------------------------- -# This section is only necessary for workflow runs and docs generation. It checks -# the environment variables to determine which image to use for the geometry service. -# If you are running this script outside of a workflow, you can ignore this section. -# -image = None -if "ANSYS_GEOMETRY_RELEASE" in os.environ: - image_tag = os.environ["ANSYS_GEOMETRY_RELEASE"] - for geom_services in GeometryContainers: - if image_tag == f"{GEOMETRY_SERVICE_DOCKER_IMAGE}:{geom_services.value[2]}": - print(f"Using {image_tag} image") - image = geom_services - break - -# sphinx_gallery_start_ignore -# Check if the __file__ variable is defined. If not, set it. -# This is a workaround to run the script in Sphinx-Gallery. -if "__file__" not in locals(): - __file__ = Path(os.getcwd(), "wf_gmd_01_geometry.py") -# sphinx_gallery_end_ignore - -############################################################################### -# Parameters for the script -# ------------------------- -# The following parameters are used to control the script execution. You can -# modify these parameters to suit your needs. -# - -GRAPHICS_BOOL = False # Set to True to display the graphics -OUTPUT_DIR = Path(Path(__file__).parent, "outputs") # Output directory - -# sphinx_gallery_start_ignore -if "DOC_BUILD" in os.environ: - GRAPHICS_BOOL = True -# sphinx_gallery_end_ignore - -############################################################################### -# Start a modeler session -# ----------------------- -# Start a modeler session to interact with the Ansys Geometry Service. The -# modeler object is used to create designs, sketches, and perform modeling -# operations. -# - -modeler = launch_modeler(image=image) -print(modeler) - -############################################################################### -# Create PCB geometry -# ----------------------- -# - -# Define default length units -DEFAULT_UNITS.LENGTH = UNITS.cm - -# Define the radius of holes in pcb -pcb_hole_radius = 1 - -# Create PCB Substrate -sketch_substrate = Sketch() -( - sketch_substrate.segment(Point2D([5, 0]), Point2D([122, 0])) - .arc_to_point(Point2D([127, 5]), Point2D([122, 5])) - .segment_to_point(Point2D([127, 135])) - .arc_to_point(Point2D([122, 140]), Point2D([122, 135])) - .segment_to_point(Point2D([5, 140])) - .arc_to_point(Point2D([0, 135]), Point2D([5, 135])) - .segment_to_point(Point2D([0, 5])) - .arc_to_point(Point2D([5, 0]), Point2D([5, 5])) - .circle(Point2D([6.35, 6.35]), radius=3.94 / 2) - .circle(Point2D([127 - 6.35, 6.35]), radius=3.94 / 2) - .circle(Point2D([127 - 6.35, 140 - 6.35]), radius=3.94 / 2) - .circle(Point2D([6.35, 140 - 6.35]), radius=3.94 / 2) -) -substrate_height = 1.575 -plane = Plane( - origin=Point3D([0, 0, substrate_height]), - direction_x=[1, 0, 0], - direction_y=[0, 1, 0], -) - -# create IC -sketch_IC = Sketch(plane) -sketch_IC.box(Point2D([62 / 2 + 7.5, 51 / 2 + 5]), 15, 10) - -# create capacitor sketch -sketch_capacitor = Sketch(plane=plane) -sketch_capacitor.circle(center=Point2D([95, 104]), radius=4.4) - -# create ic -sketch_ic_7 = Sketch(plane=plane) -sketch_ic_7.box(Point2D([25, 108]), 18, 24) - -# create ic -sketch_ic_8 = Sketch(plane=plane) -sketch_ic_8.box(Point2D([21, 59]), 10, 18) - -############################################################################### -# Modeling operations -# ------------------------- -# Now that the sketch is ready to be extruded, perform some modeling operations, -# including creating the design, creating the body directly on the design, and -# plotting the body. -# - -# Start by creating the Design -design = modeler.create_design("pcb_design") - -# Create all necessary components for pcb -component = design.add_component("PCB") -component.extrude_sketch("substrate", sketch_substrate, distance=substrate_height) -ic_1 = component.extrude_sketch("ic-1", sketch_IC, distance=4.5) - -ic_2 = ic_1.copy(parent=component, name="ic-2") -ic_2.translate(direction=UnitVector3D([1, 0, 0]), distance=17) - -ic_3 = ic_1.copy(parent=component, name="ic-3") -ic_3.translate(direction=UnitVector3D([0, 1, 0]), distance=17) - -ic_4 = ic_2.copy(parent=component, name="ic-4") -ic_4.translate(direction=UnitVector3D([1, 0, 0]), distance=17) - -ic_5 = ic_2.copy(parent=component, name="ic-5") -ic_5.translate(direction=UnitVector3D([0, 1, 0]), distance=17) - -ic_6 = ic_5.copy(parent=component, name="ic-6") -ic_6.translate(direction=UnitVector3D([1, 0, 0]), distance=17) - -ic_7 = component.extrude_sketch("ic-7", sketch=sketch_ic_7, distance=2) -ic_8 = component.extrude_sketch("ic-8", sketch=sketch_ic_8, distance=2) - -capacitor_1 = component.extrude_sketch("capacitor_1", sketch_capacitor, distance=20) -capacitor_2 = capacitor_1.copy(parent=component, name="capacitor_2") -capacitor_2.translate(direction=UnitVector3D([0, 1, 0]), distance=-20) -capacitor_3 = capacitor_1.copy(parent=component, name="capacitor_3") -capacitor_3.translate(direction=UnitVector3D([0, 1, 0]), distance=-40) -capacitor_4 = capacitor_1.copy(parent=component, name="capacitor_4") -capacitor_4.translate(direction=UnitVector3D([0, 1, 0]), distance=-60) - -# Create named selections -for body in component.bodies: - design.create_named_selection(name=body.name, bodies=[body]) - -# Plot the the entire geometry -if GRAPHICS_BOOL: - design.plot() - -############################################################################### -# Export the design -# ----------------- -# Once modeling operations are finalized, you can export files -# in different formats. For the formats supported by DMS, see the -# ``DesignFileFormat`` class in the ``Design`` module documentation. -# - -# Export files in PMDB format for Mechanical. -OUTPUT_DIR.mkdir(exist_ok=True) -download_file = Path(OUTPUT_DIR, "pcb.pmdb") -design.download(file_location=download_file, format=DesignFileFormat.PMDB) - -############################################################################### -# Close session -# ------------- -# -# When you finish interacting with your modeling service, you should close the active -# server session. This frees resources wherever the service is running. -# - -# Close the server session. -modeler.close() +# # Copyright (C) 2024 - 2025 ANSYS, Inc. and/or its affiliates. +# # SPDX-License-Identifier: MIT +# # +# # +# # Permission is hereby granted, free of charge, to any person obtaining a copy +# # of this software and associated documentation files (the "Software"), to deal +# # in the Software without restriction, including without limitation the rights +# # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# # copies of the Software, and to permit persons to whom the Software is +# # furnished to do so, subject to the following conditions: +# # +# # The above copyright notice and this permission notice shall be included in all +# # copies or substantial portions of the Software. +# # +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# # SOFTWARE. +# """ +# .. _ref_geometry_mech_dpf_01-geometry: +# +# Geometry generation +# ################### +# +# This example shows how to generate a simple PCB using PyAnsys Geometry via +# the Ansys Geometry Service. The example demonstrates how to create a sketch, +# perform modeling operations, and export the file in different formats (in this +# specific case, PMDB). +# +# """ # noqa: D400, D415 +# +# import os +# from pathlib import Path +# +# from ansys.geometry.core import launch_modeler +# from ansys.geometry.core.connection import GEOMETRY_SERVICE_DOCKER_IMAGE, GeometryContainers +# from ansys.geometry.core.designer import DesignFileFormat +# from ansys.geometry.core.math import Plane, Point2D, Point3D, UnitVector3D +# from ansys.geometry.core.misc import DEFAULT_UNITS, UNITS +# from ansys.geometry.core.sketch import Sketch +# +# ############################################################################### +# # Preparing the environment +# # ------------------------- +# # This section is only necessary for workflow runs and docs generation. It checks +# # the environment variables to determine which image to use for the geometry service. +# # If you are running this script outside of a workflow, you can ignore this section. +# # +# image = None +# if "ANSYS_GEOMETRY_RELEASE" in os.environ: +# image_tag = os.environ["ANSYS_GEOMETRY_RELEASE"] +# for geom_services in GeometryContainers: +# if image_tag == f"{GEOMETRY_SERVICE_DOCKER_IMAGE}:{geom_services.value[2]}": +# print(f"Using {image_tag} image") +# image = geom_services +# break +# +# # sphinx_gallery_start_ignore +# # Check if the __file__ variable is defined. If not, set it. +# # This is a workaround to run the script in Sphinx-Gallery. +# if "__file__" not in locals(): +# __file__ = Path(os.getcwd(), "wf_gmd_01_geometry.py") +# # sphinx_gallery_end_ignore +# +# ############################################################################### +# # Parameters for the script +# # ------------------------- +# # The following parameters are used to control the script execution. You can +# # modify these parameters to suit your needs. +# # +# +# GRAPHICS_BOOL = False # Set to True to display the graphics +# OUTPUT_DIR = Path(Path(__file__).parent, "outputs") # Output directory +# +# # sphinx_gallery_start_ignore +# if "DOC_BUILD" in os.environ: +# GRAPHICS_BOOL = True +# # sphinx_gallery_end_ignore +# +# ############################################################################### +# # Start a modeler session +# # ----------------------- +# # Start a modeler session to interact with the Ansys Geometry Service. The +# # modeler object is used to create designs, sketches, and perform modeling +# # operations. +# # +# +# modeler = launch_modeler(mode="spaceclaim") +# print(modeler) +# +# ############################################################################### +# # Create PCB geometry +# # ----------------------- +# # +# +# # Define default length units +# DEFAULT_UNITS.LENGTH = UNITS.cm +# +# # Define the radius of holes in pcb +# pcb_hole_radius = 1 +# +# # Create PCB Substrate +# sketch_substrate = Sketch() +# ( +# sketch_substrate.segment(Point2D([5, 0]), Point2D([122, 0])) +# .arc_to_point(Point2D([127, 5]), Point2D([122, 5])) +# .segment_to_point(Point2D([127, 135])) +# .arc_to_point(Point2D([122, 140]), Point2D([122, 135])) +# .segment_to_point(Point2D([5, 140])) +# .arc_to_point(Point2D([0, 135]), Point2D([5, 135])) +# .segment_to_point(Point2D([0, 5])) +# .arc_to_point(Point2D([5, 0]), Point2D([5, 5])) +# .circle(Point2D([6.35, 6.35]), radius=3.94 / 2) +# .circle(Point2D([127 - 6.35, 6.35]), radius=3.94 / 2) +# .circle(Point2D([127 - 6.35, 140 - 6.35]), radius=3.94 / 2) +# .circle(Point2D([6.35, 140 - 6.35]), radius=3.94 / 2) +# ) +# substrate_height = 1.575 +# plane = Plane( +# origin=Point3D([0, 0, substrate_height]), +# direction_x=[1, 0, 0], +# direction_y=[0, 1, 0], +# ) +# +# # create IC +# sketch_IC = Sketch(plane) +# sketch_IC.box(Point2D([62 / 2 + 7.5, 51 / 2 + 5]), 15, 10) +# +# # create capacitor sketch +# sketch_capacitor = Sketch(plane=plane) +# sketch_capacitor.circle(center=Point2D([95, 104]), radius=4.4) +# +# # create ic +# sketch_ic_7 = Sketch(plane=plane) +# sketch_ic_7.box(Point2D([25, 108]), 18, 24) +# +# # create ic +# sketch_ic_8 = Sketch(plane=plane) +# sketch_ic_8.box(Point2D([21, 59]), 10, 18) +# +# ############################################################################### +# # Modeling operations +# # ------------------------- +# # Now that the sketch is ready to be extruded, perform some modeling operations, +# # including creating the design, creating the body directly on the design, and +# # plotting the body. +# # +# +# # Start by creating the Design +# design = modeler.create_design("pcb_design") +# +# # Create all necessary components for pcb +# component = design.add_component("PCB") +# component.extrude_sketch("substrate", sketch_substrate, distance=substrate_height) +# ic_1 = component.extrude_sketch("ic-1", sketch_IC, distance=4.5) +# +# ic_2 = ic_1.copy(parent=component, name="ic-2") +# ic_2.translate(direction=UnitVector3D([1, 0, 0]), distance=17) +# +# ic_3 = ic_1.copy(parent=component, name="ic-3") +# ic_3.translate(direction=UnitVector3D([0, 1, 0]), distance=17) +# +# ic_4 = ic_2.copy(parent=component, name="ic-4") +# ic_4.translate(direction=UnitVector3D([1, 0, 0]), distance=17) +# +# ic_5 = ic_2.copy(parent=component, name="ic-5") +# ic_5.translate(direction=UnitVector3D([0, 1, 0]), distance=17) +# +# ic_6 = ic_5.copy(parent=component, name="ic-6") +# ic_6.translate(direction=UnitVector3D([1, 0, 0]), distance=17) +# +# ic_7 = component.extrude_sketch("ic-7", sketch=sketch_ic_7, distance=2) +# ic_8 = component.extrude_sketch("ic-8", sketch=sketch_ic_8, distance=2) +# +# capacitor_1 = component.extrude_sketch("capacitor_1", sketch_capacitor, distance=20) +# capacitor_2 = capacitor_1.copy(parent=component, name="capacitor_2") +# capacitor_2.translate(direction=UnitVector3D([0, 1, 0]), distance=-20) +# capacitor_3 = capacitor_1.copy(parent=component, name="capacitor_3") +# capacitor_3.translate(direction=UnitVector3D([0, 1, 0]), distance=-40) +# capacitor_4 = capacitor_1.copy(parent=component, name="capacitor_4") +# capacitor_4.translate(direction=UnitVector3D([0, 1, 0]), distance=-60) +# +# # Create named selections +# for body in component.bodies: +# design.create_named_selection(name=body.name, bodies=[body]) +# +# # Plot the the entire geometry +# if GRAPHICS_BOOL: +# +# from ansys.geometry.core.plotting import GeometryPlotter +# plotter = GeometryPlotter(show_plane=False) +# plotter.plot(design) +# plotter.show() +# +# ############################################################################### +# # Export the design +# # ----------------- +# # Once modeling operations are finalized, you can export files +# # in different formats. For the formats supported by DMS, see the +# # ``DesignFileFormat`` class in the ``Design`` module documentation. +# # +# +# # Export files in PMDB format for Mechanical. +# OUTPUT_DIR.mkdir(exist_ok=True) +# download_file = Path(OUTPUT_DIR, "pcb.pmdb") +# design.download(file_location=download_file, format=DesignFileFormat.PMDB) +# +# ############################################################################### +# # Close session +# # ------------- +# # +# # When you finish interacting with your modeling service, you should close the active +# # server session. This frees resources wherever the service is running. +# # +# +# # Close the server session. +# modeler.close() + +# Mesh the file + +import ansys.meshing.prime as prime +import pathlib + +file = pathlib.Path(__file__).parent / "outputs" / "pcb.pmdb" + +prime_client = prime.launch_prime() +model = prime_client.model +mesh_util = prime.lucid.Mesh(model=model) + +mesh_util.read(str(file.resolve().absolute())) +mesh_util.surface_mesh(min_size=2.0) + +from ansys.meshing.prime.graphics.plotter import PrimePlotter + +plotter = PrimePlotter() +plotter.plot(model) +plotter.show()