diff --git a/.ci/azure-publish-dist.yml b/.ci/azure-publish-dist.yml deleted file mode 100644 index 645ffbda..00000000 --- a/.ci/azure-publish-dist.yml +++ /dev/null @@ -1,16 +0,0 @@ -steps: -- task: PublishPipelineArtifact@0 - inputs: - artifactName: 'artifact_$(Agent.OS)_$(Agent.JobName)' - targetPath: 'dist' - -- script: | - python setup.py sdist - condition: and(startsWith(variables['Build.SourceBranch'], 'refs/tags/'), eq(variables['Agent.OS'], 'Windows_NT')) - -- script: | - python -m pip install -r requirements_build.txt - python -m pip install twine - python -m twine upload dist/* --skip-existing -p $(PYPI_TOKEN) -u __token__ - displayName: 'Upload Artifacts' - condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/') diff --git a/.ci/build_wheel.yml b/.ci/build_wheel.yml deleted file mode 100644 index ead533be..00000000 --- a/.ci/build_wheel.yml +++ /dev/null @@ -1,5 +0,0 @@ -steps: -- script: | - python -m pip install -r requirements_build.txt - python setup.py bdist_wheel - displayName: 'Build wheel' \ No newline at end of file diff --git a/.ci/build_wheels.sh b/.ci/build_wheels.sh index 9a142c3e..2d8849de 100755 --- a/.ci/build_wheels.sh +++ b/.ci/build_wheels.sh @@ -32,4 +32,4 @@ cd io "${PYBIN}/python" setup.py bdist_wheel auditwheel repair dist/ansys_mapdl_reader*.whl rm -f dist/* -mv wheelhouse/*manylinux1* dist/ +mv wheelhouse/*manylinux* dist/ diff --git a/.ci/display_test.py b/.ci/display_test.py deleted file mode 100644 index 65714bc9..00000000 --- a/.ci/display_test.py +++ /dev/null @@ -1,7 +0,0 @@ -"""Quickly check if VTK off screen plotting works.""" -import pyvista -from pyvista.plotting import system_supports_plotting - -print('system_supports_plotting', system_supports_plotting()) -pyvista.OFF_SCREEN = True -pyvista.plot(pyvista.Sphere()) diff --git a/.ci/install_opengl.ps1 b/.ci/install_opengl.ps1 deleted file mode 100644 index 59f08513..00000000 --- a/.ci/install_opengl.ps1 +++ /dev/null @@ -1,51 +0,0 @@ -# Sample script to install Python and pip under Windows -# Authors: Olivier Grisel, Jonathan Helmus and Kyle Kastner -# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ - -# Adapted from VisPy - -$MESA_GL_URL = "https://github.com/vispy/demo-data/raw/master/mesa/" - -# Mesa DLLs found linked from: -# http://qt-project.org/wiki/Cross-compiling-Mesa-for-Windows -# to: -# http://sourceforge.net/projects/msys2/files/REPOS/MINGW/x86_64/mingw-w64-x86_64-mesa-10.2.4-1-any.pkg.tar.xz/download - -function DownloadMesaOpenGL ($architecture) { - [Net.ServicePointManager]::SecurityProtocol = 'Ssl3, Tls, Tls11, Tls12' - $webclient = New-Object System.Net.WebClient - # Download and retry up to 3 times in case of network transient errors. - $url = $MESA_GL_URL + "opengl32_mingw_" + $architecture + ".dll" - if ($architecture -eq "32") { - $filepath = "C:\Windows\SysWOW64\opengl32.dll" - } else { - $filepath = "C:\Windows\system32\opengl32.dll" - } - takeown /F $filepath /A - icacls $filepath /grant "${env:ComputerName}\${env:UserName}:F" - Remove-item -LiteralPath $filepath - Write-Host "Downloading" $url - $retry_attempts = 2 - for($i=0; $i -lt $retry_attempts; $i++){ - try { - $webclient.DownloadFile($url, $filepath) - break - } - Catch [Exception]{ - Start-Sleep 1 - } - } - if (Test-Path $filepath) { - Write-Host "File saved at" $filepath - } else { - # Retry once to get the error message if any at the last try - $webclient.DownloadFile($url, $filepath) - } -} - - -function main () { - DownloadMesaOpenGL "64" -} - -main \ No newline at end of file diff --git a/.ci/install_package.yml b/.ci/install_package.yml deleted file mode 100644 index 90152360..00000000 --- a/.ci/install_package.yml +++ /dev/null @@ -1,5 +0,0 @@ -steps: -- script: | - python -m pip install -r requirements.txt - python -m pip install $(package_name) -f dist/ --no-index - displayName: 'Install ansys-mapdl-reader' \ No newline at end of file diff --git a/.ci/pyvista_test.py b/.ci/pyvista_test.py deleted file mode 100644 index 3ae32a4f..00000000 --- a/.ci/pyvista_test.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Quickly quickly check if VTK off screen plotting works.""" -import pyvista -import sys -from pyvista.plotting import system_supports_plotting - -print('system_supports_plotting', system_supports_plotting()) -pyvista.OFF_SCREEN = True -sphere = pyvista.Sphere() -pyvista.plot(sphere) diff --git a/.ci/requirements_test_xvfb.txt b/.ci/requirements_test_xvfb.txt deleted file mode 100644 index f8796db0..00000000 --- a/.ci/requirements_test_xvfb.txt +++ /dev/null @@ -1 +0,0 @@ -pyvista>=0.27.2 diff --git a/.ci/setup_headless_display.sh b/.ci/setup_headless_display.sh deleted file mode 100755 index 50079b07..00000000 --- a/.ci/setup_headless_display.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -set -x - -# sudo apt-get update && sudo apt-get install python-qt4 libgl1-mesa-glx -sudo apt-get install python-qt4 libgl1-mesa-glx -sudo apt-get install -y xvfb -export DISPLAY=:99.0 -export PYVISTA_OFF_SCREEN=True -which Xvfb -Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & -# Debugging commands: -# ls -l /etc/init.d/ -# sh -e /etc/init.d/xvfb start -# give xvfb some time to start -sleep 3 -set +x diff --git a/.ci/unit_testing.yml b/.ci/unit_testing.yml deleted file mode 100644 index e5a7cb0c..00000000 --- a/.ci/unit_testing.yml +++ /dev/null @@ -1,7 +0,0 @@ -steps: -- script: | - python -m pip install -r requirements_test.txt - cd tests - python -m pytest -v --cov pyvista --cov-report xml - cd .. - displayName: 'Unit Testing' \ No newline at end of file diff --git a/.ci/unit_testing_allow_error.yml b/.ci/unit_testing_allow_error.yml deleted file mode 100644 index a11a660b..00000000 --- a/.ci/unit_testing_allow_error.yml +++ /dev/null @@ -1,8 +0,0 @@ -steps: -- script: | - python -m pip install -r requirements_test.txt - cd tests - python -m pytest -v --cov pyvista --cov-report xml - cd .. - displayName: 'Unit Testing' - continueOnError: True diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml deleted file mode 100644 index dffc9e80..00000000 --- a/.github/workflows/doc-build.yml +++ /dev/null @@ -1,57 +0,0 @@ -# Build documentation -name: Documentation Build - -on: [push, pull_request, workflow_dispatch] - -jobs: - docs_build: - runs-on: ubuntu-20.04 - - env: - DISPLAY: ':99.0' - PYANSYS_OFF_SCREEN: True - - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - - name: Setup Python - uses: actions/setup-python@v2.1.4 - with: - python-version: 3.8 - - - name: Install, start, and test the virtual framebuffer - run: | - .ci/setup_headless_display.sh - pip install -r .ci/requirements_test_xvfb.txt --disable-pip-version-check - python .ci/display_test.py - - - name: Install ansys-mapdl-reader - run: | - pip install -r requirements_build.txt --disable-pip-version-check - python setup.py bdist_wheel - pip install dist/ansys*.whl --disable-pip-version-check - cd tests/ - python -c "from ansys.mapdl import reader as pymapdl_reader; print(pymapdl_reader.Report())" - - - name: Build Documentation - run: | - sudo apt install pandoc -qy - pip install -r requirements_docs.txt --disable-pip-version-check - make -C doc html - - - name: Upload Documentation - uses: actions/upload-artifact@v2.2.1 - with: - name: Documentation - path: doc/build/html - retention-days: 7 - - - name: Deploy - uses: JamesIves/github-pages-deploy-action@3.7.1 - if: startsWith(github.ref, 'refs/tags/') - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages - FOLDER: doc/build/html - CLEAN: true \ No newline at end of file diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml deleted file mode 100644 index 3a65f388..00000000 --- a/.github/workflows/mac-build.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Mac Unit Testing and Deployment - -on: - push: - branches: "*" - tags: "*" - pull_request: - branches: "**" - -jobs: - macOS: - runs-on: macos-latest - name: Mac OS Unit Testing - strategy: - matrix: - python-version: ['3.8'] - - env: - SHELLOPTS: 'errexit:pipefail' - - steps: - - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - - name: Build wheels - uses: joerick/cibuildwheel@v2.0.1 - env: - CIBW_BEFORE_BUILD: pip install -r requirements_build.txt - CIBW_BUILD: cp38-macosx_x86_64 - - - name: Build wheels - if: startsWith(github.event.ref, 'refs/tags') - uses: joerick/cibuildwheel@v2.0.1 - env: - CIBW_BEFORE_BUILD: pip install -r requirements_build.txt - CIBW_SKIP: pp* cp38-macosx_x86_64 - - - name: Show files - run: ls -lh wheelhouse - shell: bash - - - name: Upload wheels - uses: actions/upload-artifact@v2 - with: - path: wheelhouse/*.whl - - - name: Install wheel - run: | - pip install wheelhouse/*38* - - - name: Test - run: | - pip install -r requirements_test.txt - cd tests - pytest -v - - - name: Upload to PyPi - if: startsWith(github.event.ref, 'refs/tags') - run: | - twine upload -u __token__ --skip-existing wheelhouse/* - env: - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml deleted file mode 100644 index 9e93e33f..00000000 --- a/.github/workflows/style.yml +++ /dev/null @@ -1,22 +0,0 @@ -# check spelling, codestyle -name: Style Check - -on: [push, pull_request, workflow_dispatch] - -jobs: - check_style: - runs-on: ubuntu-20.04 - - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - - name: Setup Python - uses: actions/setup-python@v2.1.4 - with: - python-version: 3.8 - - - name: Style - run: | - pip install -r requirements_style.txt --disable-pip-version-check - make diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml new file mode 100644 index 00000000..67d4cf7a --- /dev/null +++ b/.github/workflows/testing-and-deployment.yml @@ -0,0 +1,269 @@ +name: GH Actions + +# repo specific gh actions +env: + SHELLOPTS: 'errexit:pipefail' + PACKAGE_NAME: ansys-mapdl-reader + PYVISTA_OFF_SCREEN: true + +on: + pull_request: + push: + tags: + - "*" + branches: + - main + +jobs: + check_style: + name: Style Check + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Style + run: | + pip install -r requirements_style.txt --disable-pip-version-check + make + + doc_build: + name: Build Documentation + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install XVFB + run: | + sudo apt-get install libgl1-mesa-glx xvfb + pip install pyvista + xvfb-run python -c "import pyvista; print(pyvista.Report())" + + - name: Install ansys-mapdl-reader + run: | + pip install -r requirements_build.txt --disable-pip-version-check + python setup.py bdist_wheel + pip install dist/ansys*.whl --disable-pip-version-check + cd tests/ + xvfb-run python -c "from ansys.mapdl import reader as pymapdl_reader; print(pymapdl_reader.Report())" + + - name: Build Documentation + run: | + sudo apt install pandoc -qy + pip install -r requirements_docs.txt --disable-pip-version-check + xvfb-run make -C doc html + sudo apt install zip + cd doc/build/html/ + zip ../../../${{ env.PACKAGE_NAME }}-HTML.zip ./* + + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PACKAGE_NAME }}-Documentation + path: | + ${{ env.PACKAGE_NAME }}-HTML.zip + doc/build/latex/*.pdf + retention-days: 7 + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@3.7.1 + if: startsWith(github.ref, 'refs/tags/') + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: doc/build/html + CLEAN: true + + build: + name: Build and Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ['3.6', '3.7', '3.8', '3.9'] + os: [ubuntu-latest, windows-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Linux pip cache + uses: actions/cache@v2 + if: ${{ runner.os == 'Linux' }} + with: + path: ~/.cache/pip + key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_*.txt') }} + restore-keys: | + Python-${{ runner.os }}-${{ matrix.python-version }} + + - name: Window pip cache + uses: actions/cache@v2 + if: ${{ runner.os == 'Windows' }} + with: + path: ~\AppData\Local\pip\Cache + key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_*.txt') }} + restore-keys: | + Python-${{ runner.os }}-${{ matrix.python-version }} + + # Docker layer caching. + - uses: satackey/action-docker-layer-caching@v0.0.11 + if: runner.os == 'Linux' + # Ignore the failure of a step and avoid terminating the job. + continue-on-error: true + + - name: Build ManyLinux wheel + if: ${{ runner.os == 'Linux' }} + run: | + docker run \ + --rm -v `pwd`:/io \ + quay.io/pypa/manylinux2014_x86_64 \ + /io/.ci/build_wheels.sh ${{ matrix.python-version }} + + - name: Build wheel on Windows + if: ${{ runner.os == 'Windows' }} + run: | + pip install -r requirements_build.txt + python setup.py bdist_wheel + + - name: Validate wheel + run: | + pip install twine + twine check dist/* + + - name: Install + run: | + pip install wheel + pip install --find-links=dist ${{ env.PACKAGE_NAME }} + pip list + + - name: Get PyVista tools + if: ${{ runner.os == 'Windows' }} + uses: actions/checkout@v2 + with: + repository: pyvista/gl-ci-helpers + path: pyvista-tools + + - name: Install OpenGL on Windows + if: ${{ runner.os == 'Windows' }} + shell: pwsh + run: | + Set-StrictMode -Version Latest + $ErrorActionPreference = "Stop" + pyvista-tools/appveyor/install_opengl.ps1 + python -c "import pyvista; print(pyvista.Report())" + + - name: Install XVFB on Linux + if: ${{ runner.os == 'Linux' }} + run: | + sudo apt-get install libgl1-mesa-glx xvfb + xvfb-run python -c "import pyvista; print(pyvista.Report())" + + - name: Test with XVFB + if: ${{ runner.os == 'Linux' }} + run: | + pip install -r requirements_test.txt + xvfb-run pytest -v tests/ --durations=0 + + - name: Test without XVFB + if: ${{ runner.os == 'Windows' }} + run: | + pip install -r requirements_test.txt + pytest -v tests/ --durations=0 + + - name: Upload wheel + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PACKAGE_NAME }}-${{ runner.os }}-${{ matrix.python-version }} + path: dist/ + retention-days: 7 + + mac_build: + runs-on: macos-latest + name: Mac OS Unit Testing + strategy: + matrix: + python-version: ['3.8'] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Build wheels + uses: joerick/cibuildwheel@v2.0.1 + env: + CIBW_BEFORE_BUILD: pip install -r requirements_build.txt + CIBW_BUILD: cp38-macosx_x86_64 + + - name: Build wheels + if: startsWith(github.event.ref, 'refs/tags') + uses: joerick/cibuildwheel@v2.0.1 + env: + CIBW_BEFORE_BUILD: pip install -r requirements_build.txt + CIBW_SKIP: pp* cp38-macosx_x86_64 + + - name: Show files + run: ls -lh wheelhouse + shell: bash + + - name: Upload wheels + uses: actions/upload-artifact@v2 + with: + path: wheelhouse/*.whl + + - name: Install wheel + run: | + pip install wheelhouse/*38* + + - name: Test + run: | + pip install -r requirements_test.txt + cd tests + pytest -v + + Release: + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') + needs: [check_style, doc_build, build, mac_build] + runs-on: ubuntu-latest + steps: + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + # this downloads all artifacts + - uses: actions/download-artifact@v2 + + - name: Display structure of downloaded files + run: ls -R + + - name: Upload to Public PyPi + run: | + pip install twine + twine upload --skip-existing ./**/*.whl + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + ./**/*.whl + ./**/*.zip + ./**/*.pdf diff --git a/ansys/mapdl/reader/archive.py b/ansys/mapdl/reader/archive.py index 247931f5..8dd457f7 100644 --- a/ansys/mapdl/reader/archive.py +++ b/ansys/mapdl/reader/archive.py @@ -358,8 +358,8 @@ def save_as_archive(filename, grid, mtype_start=1, etype_start=1, header = '/PREP7\n' # node numbers - if 'ansys_node_num' in grid.point_arrays: - nodenum = grid.point_arrays['ansys_node_num'] + if 'ansys_node_num' in grid.point_data: + nodenum = grid.point_data['ansys_node_num'] else: log.info('No ANSYS node numbers set in input. Adding default range') nodenum = np.arange(1, grid.number_of_points + 1, dtype=np.int32) @@ -378,8 +378,8 @@ def save_as_archive(filename, grid, mtype_start=1, etype_start=1, # element block ncells = grid.number_of_cells - if 'ansys_elem_num' in grid.cell_arrays: - enum = grid.cell_arrays['ansys_elem_num'] + if 'ansys_elem_num' in grid.cell_data: + enum = grid.cell_data['ansys_elem_num'] else: if not allow_missing: raise Exception('Missing node numbers. Exiting due "allow_missing=False"') @@ -402,8 +402,8 @@ def save_as_archive(filename, grid, mtype_start=1, etype_start=1, enum[enum == -1] = np.arange(start_num, end_num, dtype=np.int32) # material type - if 'ansys_material_type' in grid.cell_arrays: - mtype = grid.cell_arrays['ansys_material_type'] + if 'ansys_material_type' in grid.cell_data: + mtype = grid.cell_data['ansys_material_type'] else: log.info('No ANSYS element numbers set in input. ' + 'Adding default range starting from %d', mtype_start) @@ -414,8 +414,8 @@ def save_as_archive(filename, grid, mtype_start=1, etype_start=1, mtype[mtype == -1] = mtype_start # real constant - if 'ansys_real_constant' in grid.cell_arrays: - rcon = grid.cell_arrays['ansys_real_constant'] + if 'ansys_real_constant' in grid.cell_data: + rcon = grid.cell_data['ansys_real_constant'] else: log.info('No ANSYS element numbers set in input. ' + 'Adding default range starting from %d', real_constant_start) @@ -427,10 +427,10 @@ def save_as_archive(filename, grid, mtype_start=1, etype_start=1, # element type invalid = False - if 'ansys_etype' in grid.cell_arrays and not reset_etype: + if 'ansys_etype' in grid.cell_data and not reset_etype: missing = False - typenum = grid.cell_arrays['ansys_elem_type_num'] - etype = grid.cell_arrays['ansys_etype'] + typenum = grid.cell_data['ansys_elem_type_num'] + etype = grid.cell_data['ansys_etype'] if np.any(etype == -1): log.warning('Some elements are missing element type numbers.') invalid = True @@ -445,7 +445,7 @@ def save_as_archive(filename, grid, mtype_start=1, etype_start=1, # check if valid if not missing: mask = grid.celltypes < 20 - if np.any(grid.cell_arrays['ansys_elem_type_num'][mask] == 186): + if np.any(grid.cell_data['ansys_elem_type_num'][mask] == 186): invalid = True log.warning('Invalid ANSYS element types.') @@ -513,15 +513,15 @@ def save_as_archive(filename, grid, mtype_start=1, etype_start=1, with open(filename, 'a') as fid: # write node components - for node_key in grid.point_arrays: - arr = grid.point_arrays[node_key] + for node_key in grid.point_data: + arr = grid.point_data[node_key] if arr.dtype in [np.uint8, np.bool]: items = nodenum[arr.view(np.bool)] write_cmblock(fid, items, node_key, 'NODE') # write element components - for node_key in grid.cell_arrays: - arr = grid.cell_arrays[node_key] + for node_key in grid.cell_data: + arr = grid.cell_data[node_key] if arr.dtype in [np.uint8, np.bool]: items = enum[arr.view(np.bool)] write_cmblock(fid, items, node_key, 'ELEMENT') diff --git a/ansys/mapdl/reader/cyclic_reader.py b/ansys/mapdl/reader/cyclic_reader.py index 72d307af..fbbcb440 100644 --- a/ansys/mapdl/reader/cyclic_reader.py +++ b/ansys/mapdl/reader/cyclic_reader.py @@ -90,7 +90,7 @@ def _add_cyclic_properties(self): # idenfity the sector based on number of elements in master sector cs_els = self._resultheader['csEls'] - mask = self.quadgrid.cell_arrays['ansys_elem_num'] <= cs_els + mask = self.quadgrid.cell_data['ansys_elem_num'] <= cs_els self.master_cell_mask = mask self._mas_grid = self.grid.extract_cells(mask) @@ -1532,7 +1532,7 @@ def plot_nodal_temperature(self, rnum, def animate_nodal_solution(self, rnum, comp='norm', displacement_factor=0.1, - nangles=180, + n_frames=180, add_text=True, loop=True, movie_filename=None, **kwargs): @@ -1551,7 +1551,7 @@ def animate_nodal_solution(self, rnum, comp='norm', displacement_factor : float, optional Increases or decreases displacement by a factor. - nangles : int, optional + n_frames : int, optional Number of "frames" between each full cycle. show_phase : bool, optional @@ -1573,6 +1573,12 @@ def animate_nodal_solution(self, rnum, comp='norm', See help(pyvista.plot) for additional keyword arguments. """ + if 'nangles' in kwargs: # pragma: no cover + n_frames = kwargs.pop('nangles') + warnings.warn('The ``nangles`` kwarg is depreciated and ``n_frames`` ' + 'should be used instead.') + + rnum = self.parse_step_substep(rnum) # need cumulative if 'full_rotor' in kwargs: raise NotImplementedError('``full_rotor`` keyword argument not supported') @@ -1601,7 +1607,7 @@ def animate_nodal_solution(self, rnum, comp='norm', orig_pt = plot_mesh.points.copy() # reduce the complex displacement to just the surface points - ind = plot_mesh.point_arrays['vtkOriginalPointIds'] + ind = plot_mesh.point_data['vtkOriginalPointIds'] complex_disp = np.take(complex_disp, ind, axis=0) if axis is not None: @@ -1657,7 +1663,7 @@ def q_callback(): first_loop = True while self._animating: - for angle in np.linspace(0, np.pi*2, nangles): + for angle in np.linspace(0, np.pi*2, n_frames): padj = 1*np.cos(angle) - 1j*np.sin(angle) complex_disp_adj = np.real(complex_disp*padj) @@ -1703,7 +1709,7 @@ def _gen_full_rotor(self): grid.transform(matrix) # consider forcing low and high to be exact - # self._mas_grid.point_arrays['CYCLIC_M01H'] --> rotate and match + # self._mas_grid.point_data['CYCLIC_M01H'] --> rotate and match vtkappend = vtkAppendFilter() # vtkappend.MergePointsOn() @@ -1714,7 +1720,7 @@ def _gen_full_rotor(self): sector = grid.copy() sector_id = np.empty(grid.n_points) sector_id[:] = i - sector.point_arrays['sector_id'] = sector_id + sector.point_data['sector_id'] = sector_id sector.rotate_z(rang * i) vtkappend.AddInputData(sector) @@ -1872,7 +1878,7 @@ def _plot_cyclic_point_scalars(self, scalars, rnum, else: surf_sector = grid.extract_surface() - ind = surf_sector.point_arrays['vtkOriginalPointIds'] + ind = surf_sector.point_data['vtkOriginalPointIds'] rang = 360.0 / self.n_sector for i in range(self.n_sector): if scalars is not None: diff --git a/ansys/mapdl/reader/cython/_archive.pyx b/ansys/mapdl/reader/cython/_archive.pyx index dd979209..70c0729e 100644 --- a/ansys/mapdl/reader/cython/_archive.pyx +++ b/ansys/mapdl/reader/cython/_archive.pyx @@ -59,6 +59,8 @@ def py_write_nblock(filename, const int [::1] node_id, int max_node_id, cdef int has_angles = 0 if angles.size == pos.size: has_angles = 1 + else: + angles = np.zeros((1, 1), np.double) write_nblock(cfile, n_nodes, max_node_id, &node_id[0], &pos[0, 0], &angles[0, 0], has_angles); fclose(cfile) @@ -90,6 +92,8 @@ def py_write_nblock_float(filename, const int [::1] node_id, int max_node_id, cdef int has_angles = 0 if angles.size == pos.size: has_angles = 1 + else: + angles = np.zeros((1, 1), np.float32) write_nblock_float(cfile, n_nodes, max_node_id, &node_id[0], &pos[0, 0], &angles[0, 0], has_angles); fclose(cfile) diff --git a/ansys/mapdl/reader/dis_result.py b/ansys/mapdl/reader/dis_result.py index 4750bf9b..98f78a5a 100644 --- a/ansys/mapdl/reader/dis_result.py +++ b/ansys/mapdl/reader/dis_result.py @@ -101,7 +101,7 @@ def __init__(self, main_file): result.grid['_dist_idx'] = np.arange(st, st + result.grid.n_points) _result_idx = np.empty(result.grid.n_cells, np.int32) _result_idx[:] = i - result.grid.cell_arrays['_result_idx'] = _result_idx + result.grid.cell_data['_result_idx'] = _result_idx st += result.grid.n_points vtkappend.AddInputData(result.grid) @@ -118,7 +118,7 @@ def __init__(self, main_file): # elem_split_ind = np.diff(self.grid['_result_idx']).nonzero()[0] # self._elem_split = np.hstack(([0], elem_split_ind)) - elem = np.hstack(result.mesh._elem for result in self._results) + elem = np.hstack(list(result.mesh._elem for result in self._results)) glb_elem_off = [] for result in self._results: elem_off = result.mesh._elem_off @@ -143,7 +143,7 @@ def __init__(self, main_file): self.grid = self.quadgrid.linear_copy() # self._neqv = self._resultheader['neqv'] # may not need this - self._eeqv = self.grid.cell_arrays['ansys_elem_num'] + self._eeqv = self.grid.cell_data['ansys_elem_num'] @property def _main_result(self): @@ -276,7 +276,7 @@ def _nodal_result(self, rnum, result_type, **kwargs): # average across nodes data /= ncount.reshape(-1, 1) - return self.grid.point_arrays['ansys_node_num'], data + return self.grid.point_data['ansys_node_num'], data @wraps(Result.element_solution_data) def element_solution_data(self, *args, **kwargs): diff --git a/ansys/mapdl/reader/mesh.py b/ansys/mapdl/reader/mesh.py index 1745f9a1..ea240d4d 100644 --- a/ansys/mapdl/reader/mesh.py +++ b/ansys/mapdl/reader/mesh.py @@ -157,28 +157,28 @@ def _parse_vtk(self, allowable_types=None, force_linear=False, deep=True) # Store original ANSYS element and node information - grid.point_arrays['ansys_node_num'] = nnum - grid.cell_arrays['ansys_elem_num'] = self.enum - grid.cell_arrays['ansys_real_constant'] = self.elem_real_constant - grid.cell_arrays['ansys_material_type'] = self.material_type - grid.cell_arrays['ansys_etype'] = self._ans_etype - grid.cell_arrays['ansys_elem_type_num'] = self.etype + grid.point_data['ansys_node_num'] = nnum + grid.cell_data['ansys_elem_num'] = self.enum + grid.cell_data['ansys_real_constant'] = self.elem_real_constant + grid.cell_data['ansys_material_type'] = self.material_type + grid.cell_data['ansys_etype'] = self._ans_etype + grid.cell_data['ansys_elem_type_num'] = self.etype # add components # Add element components to unstructured grid for key, item in self.element_components.items(): mask = np.in1d(self.enum, item, assume_unique=True) - grid.cell_arrays[key] = mask + grid.cell_data[key] = mask # Add node components to unstructured grid for key, item in self.node_components.items(): mask = np.in1d(nnum, item, assume_unique=True) - grid.point_arrays[key] = mask + grid.point_data[key] = mask # store node angles if angles is not None: if angles.shape[1] == 3: - grid.point_arrays['angles'] = angles + grid.point_data['angles'] = angles if not null_unallowed: grid = grid.extract_cells(grid.celltypes != 0) @@ -189,8 +189,8 @@ def _parse_vtk(self, allowable_types=None, force_linear=False, # map over element types # Add tracker for original node numbering ind = np.arange(grid.number_of_points) - grid.point_arrays['origid'] = ind - grid.point_arrays['VTKorigID'] = ind + grid.point_data['origid'] = ind + grid.point_data['VTKorigID'] = ind return grid @property diff --git a/ansys/mapdl/reader/misc.py b/ansys/mapdl/reader/misc.py index 1f56ef5e..175a67c0 100644 --- a/ansys/mapdl/reader/misc.py +++ b/ansys/mapdl/reader/misc.py @@ -168,10 +168,10 @@ def random_string(stringLength=10): def _configure_pyvista(): """Configure PyVista's ``rcParams`` for pyansys""" import pyvista as pv - pv.rcParams['interactive'] = True - pv.rcParams["cmap"] = "jet" - pv.rcParams["font"]["family"] = "courier" - pv.rcParams["title"] = "pyansys" + # pv.global_theme.interactive = True + pv.global_theme.cmap = "jet" + pv.global_theme.font.family = "courier" + pv.global_theme.title = "PyMAPDL-Reader" def break_apart_surface(surf, force_linear=True): @@ -192,7 +192,7 @@ def break_apart_surface(surf, force_linear=True): ------- bsurf : pyvista.PolyData Surface with unique points for each face. Contains the - original indices in point_arrays "orig_ind". + original indices in point_data "orig_ind". """ faces = surf.faces @@ -205,7 +205,7 @@ def break_apart_surface(surf, force_linear=True): surf.n_faces, force_linear) bsurf = pyvista.PolyData(b_points, b_faces) - bsurf.point_arrays['orig_ind'] = idx + bsurf.point_data['orig_ind'] = idx return bsurf diff --git a/ansys/mapdl/reader/rst.py b/ansys/mapdl/reader/rst.py index a23fbc39..542e7bff 100644 --- a/ansys/mapdl/reader/rst.py +++ b/ansys/mapdl/reader/rst.py @@ -42,7 +42,7 @@ def access_bit(data, num): """Access a single bit from a bitmask""" base = int(num // 8) shift = int(num % 8) - return (data[base] & (1 <> shift + return (data & (1 <> shift EMAIL_ME = """Please raise an issue at: @@ -629,7 +629,7 @@ def plot_nodal_solution(self, rnum, comp=None, npoints = self.grid.number_of_points if nnum.size != npoints: new_scalars = np.zeros(npoints) - nnum_grid = self.grid.point_arrays['ansys_node_num'] + nnum_grid = self.grid.point_data['ansys_node_num'] new_scalars[np.in1d(nnum_grid, nnum, assume_unique=True)] = scalars scalars = new_scalars @@ -714,11 +714,11 @@ def _extract_node_components(self, node_components, mask = np.zeros(grid.n_points, np.bool) for component in node_components: component = component.upper() - if component not in grid.point_arrays: + if component not in grid.point_data: raise KeyError('Result file does not contain node ' + 'component "%s"' % component) - mask += grid.point_arrays[component].view(np.bool) + mask += grid.point_data[component].view(np.bool) # need to extract the mesh cells, offset = vtk_cell_info(grid) @@ -737,7 +737,7 @@ def _extract_node_components(self, node_components, raise RuntimeError('Empty mesh due to component selection\n' + 'Try "sel_type_all=False"') - ind = reduced_grid.point_arrays['vtkOriginalPointIds'] + ind = reduced_grid.point_data['vtkOriginalPointIds'] if not ind.any(): raise RuntimeError('Invalid selection.\n' + 'Try ``sel_type_all=False``') @@ -760,16 +760,16 @@ def _extract_element_components(self, element_components, grid=None): cell_mask = np.zeros(grid.n_cells, np.bool) for component in element_components: component = component.upper() - if component not in grid.cell_arrays: + if component not in grid.cell_data: raise KeyError('Result file does not contain element ' + 'component "%s"' % component) - cell_mask += grid.cell_arrays[component].view(np.bool) + cell_mask += grid.cell_data[component].view(np.bool) if not cell_mask.any(): raise RuntimeError('Empty component') reduced_grid = grid.extract_cells(cell_mask) - ind = reduced_grid.point_arrays['vtkOriginalPointIds'] + ind = reduced_grid.point_data['vtkOriginalPointIds'] if not ind.any(): raise RuntimeError('Invalid component') @@ -859,7 +859,7 @@ def animate_nodal_solution(self, rnum, comp='norm', >>> rst.animate_nodal_solution(0, movie_filename='disp.mp4', off_screen=True) """ - if 'nangles' in kwargs: + if 'nangles' in kwargs: # pragma: no cover n_frames = kwargs.pop('nangles') warnings.warn('The ``nangles`` kwarg is depreciated and ``n_frames`` ' 'should be used instead.') @@ -1344,18 +1344,18 @@ def _nodal_solution_result(self, rnum, solution_type, # TODO: inefficient and should be able to only read from this subselection. if nodes is not None: if isinstance(nodes, str): - if nodes not in self.grid.point_arrays: + if nodes not in self.grid.point_data: raise ValueError(f'Invalid node component {nodes}') - mask = self.grid.point_arrays[nodes].view(bool) + mask = self.grid.point_data[nodes].view(bool) elif isinstance(nodes, Sequence): if isinstance(nodes[0], int): mask = np.in1d(self.mesh.nnum, nodes) elif isinstance(nodes[0], str): mask = np.zeros(self.grid.n_points, bool) for node_component in nodes: - if node_component not in self.grid.point_arrays: + if node_component not in self.grid.point_data: raise ValueError(f'Invalid node component {nodes}') - mask = np.logical_or(mask, self.grid.point_arrays[node_component].view(bool)) + mask = np.logical_or(mask, self.grid.point_data[node_component].view(bool)) else: raise TypeError(f'Invalid type for {nodes}. Expected Sequence of ' 'str or int') @@ -1364,7 +1364,7 @@ def _nodal_solution_result(self, rnum, solution_type, 'str or int') # mask is for global nodes, need for potentially subselectd nodes - submask = np.in1d(nnum, self.grid.point_arrays['ansys_node_num'][mask]) + submask = np.in1d(nnum, self.grid.point_data['ansys_node_num'][mask]) nnum, result = nnum[submask], result[submask] return nnum, result @@ -2659,14 +2659,14 @@ def _plot_point_scalars(self, scalars, rnum=None, grid=None, # extract mesh surface mapped_indices = None - if 'vtkOriginalPointIds' in grid.point_arrays: - mapped_indices = grid.point_arrays['vtkOriginalPointIds'] + if 'vtkOriginalPointIds' in grid.point_data: + mapped_indices = grid.point_data['vtkOriginalPointIds'] # weird bug in some edge cases, have to roll our own indices here - if '_temp_id' not in grid.point_arrays: - grid.point_arrays['_temp_id'] = np.arange(grid.n_points) + if '_temp_id' not in grid.point_data: + grid.point_data['_temp_id'] = np.arange(grid.n_points) mesh = grid.extract_surface() - ind = mesh.point_arrays['_temp_id'] + ind = mesh.point_data['_temp_id'] if disp is not None: if mapped_indices is not None: @@ -2690,16 +2690,16 @@ def _plot_point_scalars(self, scalars, rnum=None, grid=None, return_cpos = kwargs.pop('return_cpos', False) cmap = kwargs.pop('cmap', 'jet') - window_size = kwargs.pop('window_size', pv.rcParams['window_size']) - full_screen = kwargs.pop('full_screen', pv.rcParams.get('full_screen', None)) - notebook = kwargs.pop('notebook', pv.rcParams.get('notebook', None)) + window_size = kwargs.get('window_size') + full_screen = kwargs.get('full_screen') + notebook = kwargs.get('notebook') off_screen = kwargs.pop('off_screen', pv.OFF_SCREEN) cpos = kwargs.pop('cpos', None) screenshot = kwargs.pop('screenshot', None) interactive = kwargs.pop('interactive', True) text_color = kwargs.pop('text_color', None) - kwargs.setdefault('smooth_shading', pv.rcParams.get('smooth_shading', True)) + kwargs.setdefault('smooth_shading', None) kwargs.setdefault('color', 'w') kwargs.setdefault('interpolate_before_map', True) @@ -2793,9 +2793,9 @@ def q_callback(): if cached_normals[j] is None: copied_mesh.compute_normals(cell_normals=False, inplace=True) - cached_normals[j] = copied_mesh.point_arrays['Normals'] + cached_normals[j] = copied_mesh.point_data['Normals'] else: - copied_mesh.point_arrays['Normals'][:] = cached_normals[j] + copied_mesh.point_data['Normals'][:] = cached_normals[j] if add_text: # 2 maps to vtk.vtkCornerAnnotation.UpperLeft @@ -2890,14 +2890,14 @@ def _animate_point_scalars(self, scalars, grid=None, # extract mesh surface # mapped_indices = None - # if 'vtkOriginalPointIds' in grid.point_arrays: - # mapped_indices = grid.point_arrays['vtkOriginalPointIds'] + # if 'vtkOriginalPointIds' in grid.point_data: + # mapped_indices = grid.point_data['vtkOriginalPointIds'] # weird bug in some edge cases, have to roll our own indices here - if '_temp_id' not in grid.point_arrays: + if '_temp_id' not in grid.point_data: grid['_temp_id'] = np.arange(grid.n_points) mesh = grid.extract_surface() - ind = mesh.point_arrays['_temp_id'] + ind = mesh.point_data['_temp_id'] # if disp is not None: # if mapped_indices is not None: @@ -3210,14 +3210,14 @@ def save_as_vtk(self, filename, rsets=None, result_types=['ENS'], for i in rsets: # Nodal results _, val = self.nodal_solution(i) - grid.point_arrays['Nodal Solution {:d}'.format(i)] = val + grid.point_data['Nodal Solution {:d}'.format(i)] = val # Nodal results for rtype in self.available_results: if rtype in result_types: _, values = self._nodal_result(i, rtype) desc = element_index_table_info[rtype] - grid.point_arrays['{:s} {:d}'.format(desc, i)] = values + grid.point_data['{:s} {:d}'.format(desc, i)] = values if pbar is not None: pbar.update(1) @@ -3443,9 +3443,9 @@ def _nodal_result(self, rnum, result_type, nnum_of_interest=None): ncount = ncount[mask] data = data[mask] else: - nnum = self.grid.point_arrays['ansys_node_num'] + nnum = self.grid.point_data['ansys_node_num'] else: - nnum = self.grid.point_arrays['ansys_node_num'] + nnum = self.grid.point_data['ansys_node_num'] # average across nodes ncount = ncount.reshape(-1, 1) @@ -3663,12 +3663,12 @@ def _extract_surface_element_result(self, rnum, result_type, item_index, # TODO: add element/node components surf = self.grid.extract_surface() bsurf = break_apart_surface(surf, force_linear=True) - nnum_surf = surf.point_arrays['ansys_node_num'][bsurf['orig_ind']] + nnum_surf = surf.point_data['ansys_node_num'][bsurf['orig_ind']] faces = bsurf.faces if faces.dtype != np.int64: faces = faces.astype(np.int64) - elem_ind = surf.cell_arrays['vtkOriginalCellIds'] + elem_ind = surf.cell_data['vtkOriginalCellIds'] # index within the element table pointing to the data of interest result_index = ELEMENT_INDEX_TABLE_KEYS.index(result_type) diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index ce1fc0b2..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,77 +0,0 @@ -# azure pipelines build and test PyMAPDL Reader - -variables: - ALLOW_PLOTTING: true - package_name: ansys-mapdl-reader - SHELLOPTS: 'errexit:pipefail' - - -trigger: - branches: - include: - - '*' - exclude: - - gh-pages - tags: - include: - - '*' - -jobs: -- job: Linux - strategy: - matrix: - Python36: - python.version: '3.6' - Python37: - python.version: '3.7' - Python38: - python.version: '3.8' - Python39: - python.version: '3.9' - pool: - vmImage: 'ubuntu-20.04' - variables: - DISPLAY: ':99.0' - PYVISTA_OFF_SCREEN: 'True' - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - displayName: 'Use Python $(python.version)' - - script: | - set -ex - docker pull quay.io/pypa/manylinux2010_x86_64 - docker run -e package_name=$(package_name) --rm -v `pwd`:/io quay.io/pypa/manylinux2010_x86_64 /io/.ci/build_wheels.sh $(python.version) - displayName: Build wheels using manylinux2010 - - script: | - .ci/setup_headless_display.sh - - template: .ci/install_package.yml - - template: .ci/unit_testing.yml - - template: .ci/azure-publish-dist.yml - - -- job: Windows - strategy: - matrix: - Python36: - python.version: '3.6' - Python37: - python.version: '3.7' - Python38: - python.version: '3.8' - Python39: - python.version: '3.9' - pool: - vmImage: 'windows-2019' - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: $(python.version) - addToPath: true - - powershell: | - powershell .ci/install_opengl.ps1 - displayName: 'Install OpenGL' - - template: .ci/build_wheel.yml - - template: .ci/install_package.yml - - template: .ci/unit_testing.yml - - template: .ci/azure-publish-dist.yml diff --git a/doc/source/conf.py b/doc/source/conf.py index 7947928f..54f86c76 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import warnings import os @@ -14,7 +13,7 @@ pyvista.OFF_SCREEN = True # Preferred plotting style for documentation # pyvista.set_plot_theme('document') -pyvista.rcParams['window_size'] = np.array([1024, 768]) * 2 +pyvista.global_theme.window_size = (1024, 768) # Save figures in specified directory pyvista.FIGURE_PATH = os.path.join(os.path.abspath('./images/'), 'auto-generated/') if not os.path.exists(pyvista.FIGURE_PATH): diff --git a/examples/00-read_binary/load_shaft_result.py b/examples/00-read_binary/load_shaft_result.py index 2dee4730..76a2c756 100644 --- a/examples/00-read_binary/load_shaft_result.py +++ b/examples/00-read_binary/load_shaft_result.py @@ -74,9 +74,9 @@ # Animate a mode of a component the shaft # # Set ``loop==True`` to plot continuously. -# Disable ``movie_filename`` and increase ``nangles`` for a smoother plot +# Disable ``movie_filename`` and increase ``n_frames`` for a smoother plot shaft.animate_nodal_solution(5, element_components='SHAFT_MESH', comp='norm', displacement_factor=1, show_edges=True, cpos=cpos, loop=False, movie_filename='demo.gif', - nangles=30) + n_frames=30) diff --git a/examples/01-cyclic_results/academic_sector_nd.py b/examples/01-cyclic_results/academic_sector_nd.py index fd057c5c..f97d9691 100644 --- a/examples/01-cyclic_results/academic_sector_nd.py +++ b/examples/01-cyclic_results/academic_sector_nd.py @@ -231,11 +231,11 @@ # on the settings within the modal analysis. # # Set ``loop=True`` to allow for a continuous plot, and modify -# ``nangles`` to allow for a smoother or faster plot. See +# ``n_frames`` to allow for a smoother or faster plot. See # ``help(pyvista.plot)`` for additional keyword arguments. # _ = rotor.animate_nodal_displacement((3, 1), displacement_factor=0.03, - nangles=30, show_axes=False, background='w', + n_frames=30, show_axes=False, background='w', loop=False, add_text=False, movie_filename='EO3_Mode1.gif') @@ -245,6 +245,6 @@ # second mode in the mode pair ``(3, 2)`` instead of ``(3, 1)``. # _ = rotor.animate_nodal_displacement((3, 2), displacement_factor=0.03, - nangles=30, show_axes=False, background='w', + n_frames=30, show_axes=False, background='w', loop=False, add_text=False, movie_filename='EO3_Mode1.gif') diff --git a/examples/01-cyclic_results/sector_model.py b/examples/01-cyclic_results/sector_model.py index e51ae222..4d871143 100644 --- a/examples/01-cyclic_results/sector_model.py +++ b/examples/01-cyclic_results/sector_model.py @@ -38,8 +38,8 @@ ############################################################################### # Animate Mode 21 # ~~~~~~~~~~~~~~~ -# Disable movie_filename and increase nangles for a smoother plot +# Disable movie_filename and increase n_frames for a smoother plot rotor.animate_nodal_solution(20, loop=False, movie_filename='rotor_mode.gif', background='w', displacement_factor=0.001, add_text=False, - nangles=30) + n_frames=30) diff --git a/setup.py b/setup.py index a7ce392c..3aca574f 100644 --- a/setup.py +++ b/setup.py @@ -118,8 +118,8 @@ def compilerName(): # execute file from raw string exec(fd.read()) -install_requires = ['numpy>=1.14.0', - 'pyvista>=0.30.1', +install_requires = ['numpy>=1.16.0', + 'pyvista>=0.32.0', 'appdirs>=1.4.0', 'matplotlib>=3.0.0', 'tqdm>=4.45.0'] diff --git a/tests/archive/test_archive.py b/tests/archive/test_archive.py index 7be60490..119c1dd9 100644 --- a/tests/archive/test_archive.py +++ b/tests/archive/test_archive.py @@ -2,13 +2,12 @@ import pytest import numpy as np -from vtk import (VTK_TETRA, VTK_QUADRATIC_TETRA, VTK_PYRAMID, - VTK_QUADRATIC_PYRAMID, VTK_WEDGE, - VTK_QUADRATIC_WEDGE, VTK_HEXAHEDRON, - VTK_QUADRATIC_HEXAHEDRON) +from pyvista._vtk import (VTK_TETRA, VTK_QUADRATIC_TETRA, VTK_PYRAMID, + VTK_QUADRATIC_PYRAMID, VTK_WEDGE, + VTK_QUADRATIC_WEDGE, VTK_HEXAHEDRON, + VTK_QUADRATIC_HEXAHEDRON, VTK9) from pyvista import examples as pyvista_examples import pyvista as pv -import vtk from ansys.mapdl import reader as pymapdl_reader from ansys.mapdl.reader import examples, _archive, archive @@ -105,7 +104,7 @@ def test_parse_vtk(hex_archive): grid = hex_archive.grid assert grid.points.size assert grid.cells.size - assert 'ansys_node_num' in grid.point_arrays + assert 'ansys_node_num' in grid.point_data assert np.all(hex_archive.quality > 0) with pytest.raises(TypeError): @@ -170,9 +169,9 @@ def test_writesector(tmpdir): def test_writehex_missing_elem_num(tmpdir, hex_archive): grid = hex_archive.grid - grid.cell_arrays['ansys_elem_num'][:10] = -1 - grid.cell_arrays['ansys_etype'] = np.ones(grid.number_of_cells)*-1 - grid.cell_arrays['ansys_elem_type_num'] = np.ones(grid.number_of_cells)*-1 + grid.cell_data['ansys_elem_num'][:10] = -1 + grid.cell_data['ansys_etype'] = np.ones(grid.number_of_cells)*-1 + grid.cell_data['ansys_elem_type_num'] = np.ones(grid.number_of_cells)*-1 filename = str(tmpdir.mkdir("tmpdir").join('tmp.cdb')) pymapdl_reader.save_as_archive(filename, grid) @@ -183,7 +182,7 @@ def test_writehex_missing_elem_num(tmpdir, hex_archive): def test_writehex_missing_node_num(tmpdir, hex_archive): - hex_archive.grid.point_arrays['ansys_node_num'][:-1] = -1 + hex_archive.grid.point_data['ansys_node_num'][:-1] = -1 filename = str(tmpdir.mkdir("tmpdir").join('tmp.cdb')) pymapdl_reader.save_as_archive(filename, hex_archive.grid) @@ -194,8 +193,8 @@ def test_writehex_missing_node_num(tmpdir, hex_archive): def test_write_non_ansys_grid(tmpdir): grid = pv.UnstructuredGrid(pyvista_examples.hexbeamfile) - del grid.point_arrays['sample_point_scalars'] - del grid.cell_arrays['sample_cell_scalars'] + del grid.point_data['sample_point_scalars'] + del grid.cell_data['sample_cell_scalars'] archive_file = str(tmpdir.mkdir("tmpdir").join('tmp.cdb')) pymapdl_reader.save_as_archive(archive_file, grid) @@ -397,9 +396,8 @@ def test_write_nblock(hex_archive, tmpdir, dtype, has_angles): assert np.allclose(hex_archive.node_angles, tmp_archive.node_angles) -def test_cython_write_eblock(hex_archive): - vtk9 = vtk.vtkVersion().GetVTKMajorVersion() >= 9 - filename = '/tmp/eblock.inp' +def test_cython_write_eblock(hex_archive, tmpdir): + filename = str(tmpdir.mkdir("tmpdir").join('eblock.inp')) etype = np.ones(hex_archive.n_elem, np.int32) typenum = hex_archive.etype @@ -423,7 +421,7 @@ def test_cython_write_eblock(hex_archive): hex_archive.grid.celltypes, typenum, nodenum, - vtk9) + VTK9) def test_rlblock_prior_to_nblock(): diff --git a/tests/test_binary_reader.py b/tests/test_binary_reader.py index df03ba0b..75d2c925 100644 --- a/tests/test_binary_reader.py +++ b/tests/test_binary_reader.py @@ -288,7 +288,7 @@ def test_loadresult(result): grid = result.grid assert grid.points.size assert grid.cells.size - assert 'ansys_node_num' in grid.point_arrays + assert 'ansys_node_num' in grid.point_data # check results can be loaded nnum, disp = result.nodal_solution(0) @@ -345,13 +345,13 @@ def test_save_as_vtk(tmpdir, result, result_type): grid = pv.UnstructuredGrid(filename) for i in range(result.nsets): key = 'Nodal Solution %d' % i - assert key in grid.point_arrays - arr = grid.point_arrays[key] + assert key in grid.point_data + arr = grid.point_data[key] assert np.allclose(arr, result.nodal_solution(i)[1], atol=1E-5) key = '%s %d' % (element_index_table_info[result_type], i) - assert key in grid.point_arrays - arr = grid.point_arrays[key] + assert key in grid.point_data + arr = grid.point_data[key] _, rst_arr = result._nodal_result(i, result_type) if rst_arr.shape[1] == 1: rst_arr = rst_arr.ravel() @@ -416,7 +416,7 @@ def test_file_close(tmpdir): @pytest.mark.skipif(not HAS_FFMPEG, reason="requires imageio_ffmpeg") def test_animate_nodal_solution(tmpdir, result): temp_movie = str(tmpdir.mkdir("tmpdir").join('tmp.mp4')) - result.animate_nodal_solution(0, nangles=20, movie_filename=temp_movie, + result.animate_nodal_solution(0, n_frames=20, movie_filename=temp_movie, loop=False, off_screen=True) assert np.any(result.grid.points) assert os.path.isfile(temp_movie) diff --git a/tests/test_cyclic.py b/tests/test_cyclic.py index 1e0c0b9f..0146aecb 100644 --- a/tests/test_cyclic.py +++ b/tests/test_cyclic.py @@ -350,7 +350,7 @@ def test_full_x_principal_nodal_stress(result_x): @pytest.mark.skipif(result_z is None, reason="Requires result file") def test_animate_nodal_solution(tmpdir): temp_movie = str(tmpdir.mkdir("tmpdir").join('tmp.mp4')) - result_z.animate_nodal_solution(0, nangles=20, movie_filename=temp_movie, + result_z.animate_nodal_solution(0, n_frames=20, movie_filename=temp_movie, loop=False) assert os.path.isfile(temp_movie) diff --git a/tests/test_dist_rst.py b/tests/test_dist_rst.py index d4e3b14e..e5596ca7 100644 --- a/tests/test_dist_rst.py +++ b/tests/test_dist_rst.py @@ -221,13 +221,13 @@ def test_save_as_vtk(tmpdir, static_dis, static_rst, rtype): grid = pv.read(filename) key = 'Nodal Solution %d' % 0 - assert key in grid.point_arrays - arr = grid.point_arrays[key] + assert key in grid.point_data + arr = grid.point_data[key] assert np.allclose(arr, static_dis.nodal_solution(0)[1], atol=1E-5) key = '%s %d' % (element_index_table_info[rtype], 0) - assert key in grid.point_arrays - arr = grid.point_arrays[key] + assert key in grid.point_data + arr = grid.point_data[key] _, rst_arr = static_dis._nodal_result(0, rtype) if rst_arr.shape[1] == 1: rst_arr = rst_arr.ravel() diff --git a/tests/test_rst.py b/tests/test_rst.py index eba10bed..dc129084 100644 --- a/tests/test_rst.py +++ b/tests/test_rst.py @@ -179,7 +179,7 @@ def test_read_volume(volume_rst): edata = np.asarray(edata) volume = edata[:, 0] - enum_vtk = np.sort(volume_rst.grid.cell_arrays['ansys_elem_num']) + enum_vtk = np.sort(volume_rst.grid.cell_data['ansys_elem_num']) assert np.allclose(enum, enum_vtk) assert np.allclose(volume, 291895460.0) @@ -389,12 +389,12 @@ def test_nodes_subselection(hex_rst, nodes): nnum_sel, data_sel = hex_rst.nodal_solution(0, nodes=nodes) nnum, data = hex_rst.nodal_solution(0, nodes=nodes) - grid_nnum = hex_rst.grid.point_arrays['ansys_node_num'] + grid_nnum = hex_rst.grid.point_data['ansys_node_num'] if isinstance(nodes, str): - nnum_of_interest = grid_nnum[hex_rst.grid.point_arrays[nodes].view(bool)] + nnum_of_interest = grid_nnum[hex_rst.grid.point_data[nodes].view(bool)] elif isinstance(nodes, tuple): - mask = np.logical_or(hex_rst.grid.point_arrays[nodes[0]].view(bool), - hex_rst.grid.point_arrays[nodes[1]].view(bool)) + mask = np.logical_or(hex_rst.grid.point_data[nodes[0]].view(bool), + hex_rst.grid.point_data[nodes[1]].view(bool)) nnum_of_interest = grid_nnum[mask] else: nnum_of_interest = nodes diff --git a/tests/text_examples.py b/tests/text_examples.py index e8213db5..3e308fbc 100644 --- a/tests/text_examples.py +++ b/tests/text_examples.py @@ -68,7 +68,7 @@ def test_shaft_animate(tmpdir): filename = str(tmpdir.mkdir("tmpdir").join('tmp.mp4')) shaft.animate_nodal_solution(5, element_components='SHAFT_MESH', comp='norm', loop=False, - nangles=10, show_edges=True, + n_frames=10, show_edges=True, off_screen=True, movie_filename=filename)