Skip to content

Commit

Permalink
Adding MacOS runners to GitHub unit test workflow (#346)
Browse files Browse the repository at this point in the history
* Adding macos runner to CI

* adding missing xpt interpolation to TACSInertialForce2D
  • Loading branch information
timryanb authored Jan 16, 2025
1 parent ce5a61a commit a3ab45a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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
Expand All @@ -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 .;
Expand Down
10 changes: 6 additions & 4 deletions src/elements/TACSInertialForce2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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];
Expand Down Expand Up @@ -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
Expand All @@ -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];
Expand Down

0 comments on commit a3ab45a

Please sign in to comment.