From a3ab45a66703eee5b7e8dce8f91d4cdd22b8f287 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Thu, 16 Jan 2025 13:47:56 -0500 Subject: [PATCH] Adding MacOS runners to GitHub unit test workflow (#346) * Adding macos runner to CI * adding missing xpt interpolation to TACSInertialForce2D --- .github/workflows/unit_tests.yml | 36 +++++++++++++++++++++------- src/elements/TACSInertialForce2D.cpp | 10 ++++---- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 7307bcf3b..2d21de2bb 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -20,7 +20,7 @@ jobs: # This job is called test_docs. unit_test_and_docs: # Run on Ubuntu - runs-on: ubuntu-latest + runs-on: ${{ matrix.OS }} timeout-minutes: 40 # Necessary to prevent mpi tests failing due to lack of slots env: @@ -36,13 +36,27 @@ jobs: matrix: include: # real versions - - NAME: Real + - NAME: Real-Ubuntu + OS: ubuntu-latest OPTIONAL: 'debug' INTERFACE: 'interface' PUBLISH_DOCS: true + - NAME: Real-MacOS + OS: macos-latest + OPTIONAL: 'debug' + INTERFACE: 'interface' + PUBLISH_DOCS: false + # complex versions - - NAME: Complex + - NAME: Complex-Ubuntu + OS: ubuntu-latest + OPTIONAL: 'complex_debug' + INTERFACE: 'complex_interface' + PUBLISH_DOCS: false + + - NAME: Complex-MacOS + OS: macos-latest OPTIONAL: 'complex_debug' INTERFACE: 'complex_interface' PUBLISH_DOCS: false @@ -74,14 +88,17 @@ jobs: with: auto-update-conda: true python-version: 3.9 + conda-remove-defaults: true - name: Install TACS run: | export TACS_DIR=${GITHUB_WORKSPACE}; echo "TACS_DIR=${GITHUB_WORKSPACE}" >> $GITHUB_ENV - conda install -c conda-forge sysroot_linux-64=2.17 -q -y; + if [[ ${{ matrix.OS }} == 'ubuntu-latest' ]]; then + conda install -c conda-forge sysroot_linux-64=2.17 -q -y; + conda install -c conda-forge openblas -q -y; + fi conda install -c conda-forge openmpi openmpi-mpicxx -q -y; - conda install -c anaconda openblas -q -y; conda install -c conda-forge lapack -q -y; conda install -c conda-forge metis=5.1.0 -q -y; cd $TACS_DIR; @@ -93,8 +110,9 @@ jobs: make ${{ matrix.OPTIONAL }} TACS_DIR=$TACS_DIR METIS_INCLUDE=-I${CONDA_PREFIX}/include/ METIS_LIB="-L${CONDA_PREFIX}/lib/ -lmetis"; - name: Install f5totec/f5tovtk run: | + # Sometimes needed for macos runner to prevent it from pulling numpy 2 when installing tecio later + conda install -c smdogroup -c conda-forge tecio "numpy<2" -q -y; # Compile f5totec/f5tovtk - conda install -c smdogroup tecio -q -y; cd $TACS_DIR/extern/f5totec; make TACS_DIR=$TACS_DIR TECIO_INCLUDE=-I${CONDA_PREFIX}/include/ TECIO_LIB=${CONDA_PREFIX}/lib/libtecio.a\ METIS_INCLUDE=-I${CONDA_PREFIX}/include/ METIS_LIB="-L${CONDA_PREFIX}/lib/ -lmetis"; @@ -104,9 +122,9 @@ jobs: - name: Install optional dependencies run: | # Install petsc for openmdao tests - conda install -c conda-forge petsc=3.19 petsc4py -q -y; + conda install -c conda-forge petsc>=3.19 petsc4py -q -y; # Install ESP/CAPS prebuilt for shape derivatives, only in Real mode - if [[ ${{ matrix.NAME }} == 'Real' ]]; then + if [[ ${{ matrix.NAME }} == 'Real-Ubuntu' ]]; then cd $TACS_DIR/extern/ wget https://acdl.mit.edu/ESP/archive/ESP122Lin.tgz tar -xvf ESP122Lin.tgz @@ -128,7 +146,7 @@ jobs: - name: Run unit tests run: | # Reload ESP/CAPS environment variables if in real mode - if [[ ${{ matrix.NAME }} == 'Real' ]]; then + if [[ ${{ matrix.NAME }} == 'Real-Ubuntu' ]]; then source ${TACS_DIR}/extern/ESP122/ESPenv.sh fi testflo --timeout 240 .; diff --git a/src/elements/TACSInertialForce2D.cpp b/src/elements/TACSInertialForce2D.cpp index 3567589ed..82b6c760f 100644 --- a/src/elements/TACSInertialForce2D.cpp +++ b/src/elements/TACSInertialForce2D.cpp @@ -109,7 +109,8 @@ void TACSInertialForce2D::addResidual( double weight = basis->getQuadraturePoint(n, pt); // Get the face normal - TacsScalar Xd[4], J[4]; + TacsScalar X[3], Xd[4], J[4]; + basis->interpFields(n, pt, 3, Xpts, 1, X); TacsScalar detXd = basis->getJacobianTransform(n, pt, Xpts, Xd, J); // Multiply the quadrature weight by the quadrature point @@ -122,7 +123,7 @@ void TACSInertialForce2D::addResidual( memset(DUx, 0, 2 * varsPerNode * sizeof(TacsScalar)); // Get the element density - TacsScalar density = con->evalDensity(elemIndex, pt, Xpts); + TacsScalar density = con->evalDensity(elemIndex, pt, X); for (int k = 0; k < 2; k++) { DUt[3 * k] = -density * inertiaVec[k]; @@ -153,7 +154,8 @@ void TACSInertialForce2D::addJacobian(int elemIndex, double time, double weight = basis->getQuadraturePoint(n, pt); // Get the face normal - TacsScalar Xd[4], J[4]; + TacsScalar X[3], Xd[4], J[4]; + basis->interpFields(n, pt, 3, Xpts, 1, X); TacsScalar detXd = basis->getJacobianTransform(n, pt, Xpts, Xd, J); // Multiply the quadrature weight by the quadrature point @@ -166,7 +168,7 @@ void TACSInertialForce2D::addJacobian(int elemIndex, double time, memset(DUx, 0, 2 * varsPerNode * sizeof(TacsScalar)); // Get the element density - TacsScalar density = con->evalDensity(elemIndex, pt, Xpts); + TacsScalar density = con->evalDensity(elemIndex, pt, X); for (int k = 0; k < 2; k++) { DUt[3 * k] = -density * inertiaVec[k];