diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..4c9b9224 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +[*.sh] +indent_style = space +indent_size = 4 +space_redirects = true +keep_padding = true +never_split = true + +[unit/run_tests] +indent_style = space +indent_size = 4 +space_redirects = true +keep_padding = true +never_split = true diff --git a/.github/linters/.clang-format b/.github/linters/.clang-format new file mode 120000 index 00000000..2d112372 --- /dev/null +++ b/.github/linters/.clang-format @@ -0,0 +1 @@ +../../.clang-format \ No newline at end of file diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 120000 index 00000000..7e62b3d9 --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1 @@ +../../.markdownlint.yml \ No newline at end of file diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml new file mode 120000 index 00000000..54a3654b --- /dev/null +++ b/.github/linters/.yaml-lint.yml @@ -0,0 +1 @@ +../../.yamllint.yml \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..ce30aa9f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,46 @@ +--- +name: Lint + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: { } + +jobs: + build: + name: Lint + runs-on: ubuntu-latest + + permissions: + contents: read + packages: read + # To report GitHub Actions status checks + statuses: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # super-linter needs the full git history to get the + # list of files that changed across commits + fetch-depth: 0 + + - name: Super-linter + uses: super-linter/super-linter/slim@v6.6.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_ANSIBLE: false + VALIDATE_CHECKOV: false + VALIDATE_CPP: false + VALIDATE_JSCPD: false + VALIDATE_PYTHON_BLACK: false + VALIDATE_PYTHON_FLAKE8: false + VALIDATE_PYTHON_ISORT: false + VALIDATE_PYTHON_MYPY: false + VALIDATE_PYTHON_PYLINT: false + VALIDATE_PYTHON_RUFF: false diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2792d3b3..65fa04a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,30 +1,40 @@ +--- name: BuildTest on: push: branches: - - main + - main pull_request: branches: - - main + - main jobs: docker-build-test-ubuntu: runs-on: ubuntu-latest name: BuildTestUbuntu env: - PRCOMMITSHA : ${{ github.event.pull_request.head.sha }} + PRCOMMITSHA: ${{ github.event.pull_request.head.sha }} PRREPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} steps: # First check out the repository to get the docker file - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Print the context for this GitHub workflow - name: PrintGithubContext - run: echo ${PRCOMMITSHA:-$GITHUB_SHA} ${PRREPOSITORY:-$GITHUB_REPOSITORY} + run: echo "${PRCOMMITSHA:-$GITHUB_SHA}" "${PRREPOSITORY:-$GITHUB_REPOSITORY}" # Now build in a container with all deps - name: DockerBuildTest run: | docker build -t ci-platypus-ubuntu \ - --build-arg build_git_sha=${PRCOMMITSHA:-$GITHUB_SHA} \ - --build-arg build_git_repo=${PRREPOSITORY:-$GITHUB_REPOSITORY} \ + --build-arg build_git_sha="${PRCOMMITSHA:-$GITHUB_SHA}" \ + --build-arg build_git_repo="${PRREPOSITORY:-$GITHUB_REPOSITORY}" \ + --build-arg coverage=true \ docker/platypus + - name: UploadCoverage + run: | + ci_env=$(bash <(curl -s https://codecov.io/env)) + # shellcheck disable=SC2086 + docker run $ci_env -e CI=true ci-platypus-ubuntu:latest \ + bash /opt/platypus/scripts/upload-coverage.sh + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/weekly_build.yml b/.github/workflows/weekly_build.yml index cf78d9f7..1c8dbc98 100644 --- a/.github/workflows/weekly_build.yml +++ b/.github/workflows/weekly_build.yml @@ -1,9 +1,10 @@ +--- name: Publish Docker Images on: workflow_dispatch: schedule: # Schedule to update image every Monday morning at 04:00. - - cron: '00 4 * * 1' + - cron: '00 4 * * 1' jobs: push-platypus-deps-image-to-docker-hub: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 333b21d8..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,140 +0,0 @@ -image: ubuntu:latest - -variables: - GIT_SUBMODULE_STRATEGY: recursive - -stages: - - build - - test - - quality - - security - - deploy - -# Build the software, along with all tests -build: - stage: build - script: - - mkdir build - - cd build - - cmake .. - - make -j - - cd .. - artifacts: - paths: - - build/ - - bin/ - - lib/ - expire_in: 1 day - -# Run tests - -.template: &coverage_template - stage: test - before_script: - - apt install gcovr - - cd build - - cmake .. -DBUILD_TYPE=TEST - - make -j -# after_script: -# - make gcovr - coverage: '/^lines: (\d+.\d+)%/' - - -unit_tests: - <<: *coverage_template - script: - - ../bin/unit_tests - - make gcovr - - mv gcovr unit_test_coverage - artifacts: - paths: - - build/unit_test_coverage - expire_in: 1 week - -integration_tests: - <<: *coverage_template - script: - - ../bin/integration_tests - - make gcovr - - mv gcovr integration_test_coverage - artifacts: - paths: - - build/integration_test_coverage - expire_in: 1 week - -regression_tests: - <<: *coverage_template - script: - - ../bin/regression_tests - - make gcovr - - mv gcovr regression_test_coverage - artifacts: - paths: - - build/regression_test_coverage - expire_in: 1 week - -format_tests: - stage: test - script: - - find ./{test,src}/ -iname *.h -o -iname *.cpp -o -iname *.hpp | xargs clang-format-8 -style=file | clang-format-diff-8 > out.txt - - if [[ -s out.txt ]]; then false; fi - allow_failure: true - -# Code quality -cyclomatic_complexity: - stage: quality - script: - - python /home/lizard/lizard.py --CCN=15 --length=100 --arguments=10 src - -static_analysis: - stage: quality - script: - - script -c "cppcheck src --enable=all" cppcheck.out - artifacts: - paths: - - cppcheck.out - expire_in: 1 week - -similarity: - stage: quality - script: - - script -c "sim_c++ -aRn src/*" similarity.out - artifacts: - paths: - - similarity.out - expire_in: 1 week - - -flaws: - stage: security - script: - - script -c "flawfinder src" flawfinder.out - artifacts: - paths: - - flawfinder.out - expire_in: 1 week - -pages: - stage: deploy - script: - # assuming build folder in the build stage is kept - - mkdir builddoc && cd builddoc - - cmake .. - - make doc - # doxygen output folder name is controlled in defined Doxygen.in - # gitlab pages request document must put into `public` folder of the repo directory - - mv public/html ../public - - cd .. - - mv build/unit_test_coverage public/unit_coverage - - mv build/integration_test_coverage public/integration_coverage - - mv build/regression_test_coverage public/regression_coverage - dependencies: - - unit_tests - - integration_tests - - regression_tests - only: - - master - artifacts: - paths: - - public - allow_failure: true # TODO change to false diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 00000000..a694d1b7 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,35 @@ +--- +########################### +########################### +## Markdown Linter rules ## +########################### +########################### + +# Linter rules doc: +# - https://github.com/DavidAnson/markdownlint +# +# Note: +# To comment out a single error: +# +# any violations you want +# +# + +############### +# Rules by id # +############### +MD004: false # Unordered list style +MD007: + indent: 2 # Unordered list indentation +MD013: + line_length: 100 # Line length 80 is far too short +MD026: + punctuation: ".,;:!。,;:" # List of not allowed +MD029: false # Ordered list item prefix +MD033: false # Allow inline HTML +MD041: false # Allow MOOSE configuration data before first heading + +################# +# Rules by tags # +################# +blank_lines: false # Error on blank lines diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b8aee6cb..e0d6aa26 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,64 @@ +--- repos: -- repo: https://github.com/pre-commit/mirrors-clang-format - rev: v14.0.6 - hooks: - - id: clang-format - -- repo: https://github.com/pocc/pre-commit-hooks - rev: v1.3.5 - hooks: - - id: clang-tidy - args: [-p=./build, -config-file=./.clang-tidy, --warnings-as-errors=*, -extra-arg=-std=c++17, -extra-arg=-stdlib=libstdc++] \ No newline at end of file + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v14.0.6 + hooks: + - id: clang-format + + # Not yet figured out how to configure this properly + # - repo: https://github.com/pocc/pre-commit-hooks + # rev: v1.3.5 + # hooks: + # - id: clang-tidy + # args: + # - "-p=./build" + # - "-config-file=./.clang-tidy" + # - "--warnings-as-errors=*" + # - "-extra-arg=-std=c++17" + # - "-extra-arg=-stdlib=libstdc++" + + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: 2.7.3 + hooks: + - id: editorconfig-checker + alias: ec + + - repo: https://github.com/scop/pre-commit-shfmt + rev: v3.8.0-1 + hooks: + - id: shfmt + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + + # Hadolint isn't trivial to install + # - repo: https://github.com/hadolint/hadolint + # rev: v2.12.0 + # hooks: + # - id: hadolint + + # Note: needs node.js >= 18, which is more recent than version + # distributed with Ubuntu 22.4. The latest versions of node.js can + # be installed using the instructions at + # https://github.com/nodesource/distributions?tab=readme-ov-file#debian-and-ubuntu-based-distributions + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.41.0 + hooks: + - id: markdownlint-fix + + - repo: https://github.com/rhysd/actionlint + rev: v1.7.1 + hooks: + - id: actionlint + + - repo: https://github.com/adrienverge/yamllint + rev: v1.35.1 + hooks: + - id: yamllint + + - repo: https://github.com/gitleaks/gitleaks + rev: v8.16.1 + hooks: + - id: gitleaks diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 00000000..4c44381e --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,62 @@ +--- +########################################### +# These are the rules used for # +# linting all the yaml files in the stack # +# NOTE: # +# You can disable line with: # +# # yamllint disable-line # +########################################### +rules: + braces: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + brackets: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + colons: + level: warning + max-spaces-before: 0 + max-spaces-after: 1 + commas: + level: warning + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: disable + comments-indentation: disable + document-end: disable + document-start: + level: warning + present: true + empty-lines: + level: warning + max: 2 + max-start: 0 + max-end: 0 + hyphens: + level: warning + max-spaces-after: 1 + indentation: + level: warning + spaces: consistent + indent-sequences: true + check-multi-line-strings: false + key-duplicates: enable + line-length: + level: warning + max: 100 + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable + +ignore: + - syntax.yaml diff --git a/README.md b/README.md index 76ce82bc..d2f13404 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,17 @@ Platypus ===== -Platypus is a MOOSE-based application created to enable custom MOOSE problems to be set up and solved using the [MFEM](https://github.com/mfem/mfem) finite element library as an alternative backend to libMesh. It is based off of the MOOSE electromagnetics app [Apollo](https://github.com/aurora-multiphysics/apollo) that uses MFEM for solving electromagnetics problems in a variety of formulations. +![lint](https://github.com/aurora-multiphysics/platypus/actions/workflows/lint.yml/badge.svg?branch=main) +![build](https://github.com/aurora-multiphysics/platypus/actions/workflows/main.yml/badge.svg?branch=main) +[![codecov](https://codecov.io/gh/aurora-multiphysics/platypus/graph/badge.svg?token=WV2DE9DT53)](https://codecov.io/gh/aurora-multiphysics/platypus) +[![GitHub License](https://img.shields.io/github/license/aurora-multiphysics/platypus)](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) + +Platypus is a MOOSE-based application created to enable custom MOOSE +problems to be set up and solved using the +[MFEM](https://github.com/mfem/mfem) finite element library as an +alternative backend to libMesh. It is based off of the MOOSE +electromagnetics app +[Apollo](https://github.com/aurora-multiphysics/apollo) that uses MFEM +for solving electromagnetics problems in a variety of formulations. Platypus is under active development and is being updated frequently. diff --git a/doc/config.yml b/doc/config.yml index 0cfa7005..95128cfc 100644 --- a/doc/config.yml +++ b/doc/config.yml @@ -1,3 +1,4 @@ +--- Content: Platypus: root_dir: ${ROOT_DIR}/doc/content diff --git a/docker/platypus-deps/Dockerfile b/docker/platypus-deps/Dockerfile index 2b2bf6a3..7188db5c 100644 --- a/docker/platypus-deps/Dockerfile +++ b/docker/platypus-deps/Dockerfile @@ -9,8 +9,9 @@ ARG compile_cores=4 ARG WORKDIR=opt # Configure MOOSE +WORKDIR /$WORKDIR +# hadolint ignore=DL3003 RUN export MOOSE_JOBS=$compile_cores && \ - cd /$WORKDIR && \ git clone https://github.com/idaholab/moose && \ cd moose && \ git checkout master && \ @@ -25,23 +26,23 @@ RUN export MOOSE_JOBS=$compile_cores && \ ./configure --with-derivative-size=200 # Build WASP -RUN cd /$WORKDIR/moose/scripts && \ - METHODS=opt ./update_and_rebuild_wasp.sh +WORKDIR /$WORKDIR/moose/scripts +RUN METHODS=opt ./update_and_rebuild_wasp.sh # Build MOOSE -RUN cd /$WORKDIR/moose/framework && \ - METHOD=opt make -j$compile_cores +WORKDIR /$WORKDIR/moose/framework +RUN METHOD=opt make -j$compile_cores -RUN cd /$WORKDIR/moose/test && \ - METHOD=opt make -j$compile_cores +WORKDIR /$WORKDIR/moose/test +RUN METHOD=opt make -j$compile_cores # This is needed or it mpiexec complains because docker runs as root # Discussion on this issue https://github.com/open-mpi/ompi/issues/4451 ENV OMPI_ALLOW_RUN_AS_ROOT=1 ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 -# RUN cd /$WORKDIR/moose/test && \ -# ./run_tests -j"$compile_cores" --re='(?!initial_condition.newton_with_exact_initialization)' +# WORKDIR /$WORKDIR/moose/test +# RUN ./run_tests -j"$compile_cores" --re='(?!initial_condition.newton_with_exact_initialization)' # ENV OMPI_ALLOW_RUN_AS_ROOT= # ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM= diff --git a/docker/platypus/Dockerfile b/docker/platypus/Dockerfile index 86ebd142..5e0832cd 100644 --- a/docker/platypus/Dockerfile +++ b/docker/platypus/Dockerfile @@ -12,28 +12,33 @@ ARG build_git_repo=aurora-multiphysics/platypus # By default we install everything under /opt ARG WORKDIR=opt +# By default, build without code coverage flags +ARG coverage=false + # Get Platypus with Hephaestus -RUN cd /$WORKDIR && \ - git clone https://github.com/$build_git_repo && \ +WORKDIR /$WORKDIR +# hadolint ignore=DL3003 +RUN git clone https://github.com/$build_git_repo && \ cd platypus && \ git checkout $build_git_sha && \ git submodule update --init --recursive # Build Hephaestus -RUN cd /$WORKDIR/platypus/contrib/hephaestus/ && \ - mkdir build && \ +WORKDIR /$WORKDIR/platypus/contrib/hephaestus/ +# hadolint ignore=DL3003 +RUN mkdir build && \ cd build && \ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DMFEM_DIR=/$WORKDIR/mfem/build .. && \ ninja # Test Hephaestus -RUN cd /$WORKDIR/platypus/contrib/hephaestus/build && \ - ninja test +WORKDIR /$WORKDIR/platypus/contrib/hephaestus/build +RUN ninja test # Build Platypus -RUN cd /$WORKDIR/platypus && \ - make -j$compile_cores +WORKDIR /$WORKDIR/platypus +RUN make -j$compile_cores coverage=$coverage # Test Platypus -RUN cd /$WORKDIR/platypus && \ - make test +WORKDIR /$WORKDIR/platypus +RUN make test linkcoverage=$coverage diff --git a/include/base/PlatypusApp.h b/include/base/PlatypusApp.h index 15b1e2e4..bfa1962b 100644 --- a/include/base/PlatypusApp.h +++ b/include/base/PlatypusApp.h @@ -14,4 +14,3 @@ class PlatypusApp : public MooseApp static void registerAll(Factory & f, ActionFactory & af, Syntax & s); static void associateSyntax(Syntax & syntax, ActionFactory & action_factory); }; - diff --git a/include/problem/MFEMProblem.h b/include/problem/MFEMProblem.h index dee49f69..1be63adc 100644 --- a/include/problem/MFEMProblem.h +++ b/include/problem/MFEMProblem.h @@ -147,7 +147,8 @@ class MFEMProblem : public ExternalProblem void setMOOSEElementalVarData(MooseVariableFieldBase & moose_variable); /** - * Template method for adding kernels. We can only add kernels using equation system problem builders. + * Template method for adding kernels. We can only add kernels using equation system problem + * builders. */ template void addKernel(std::string var_name, std::shared_ptr> kernel) @@ -156,13 +157,15 @@ class MFEMProblem : public ExternalProblem EquationSystemProblemBuilderInterface * eqn_system_problem_builder{nullptr}; - if ((eqn_system_problem_builder = dynamic_cast(mfem_problem_builder.get()))) + if ((eqn_system_problem_builder = + dynamic_cast(mfem_problem_builder.get()))) { eqn_system_problem_builder->AddKernel(std::move(var_name), std::move(kernel)); } - else + else { - mooseError("Cannot add kernel with name '" + var_name + "' because there is no equation system."); + mooseError("Cannot add kernel with name '" + var_name + + "' because there is no equation system."); } } diff --git a/platypus.yaml b/platypus.yaml index ff87e7db..99471ace 100644 --- a/platypus.yaml +++ b/platypus.yaml @@ -1,9 +1,10 @@ +--- DMETHOD: opt Werror: reorder compiler_type: gcc documentation: true installation_type: in_tree registered_apps: -- WASPAPP -- PLATYPUSAPP -- PLATYPUSTESTAPP + - WASPAPP + - PLATYPUSAPP + - PLATYPUSTESTAPP diff --git a/scripts/build-platypus-csd3-cclake.sh b/scripts/build-platypus-csd3-cclake.sh old mode 100644 new mode 100755 index 8dd20206..226bfeba --- a/scripts/build-platypus-csd3-cclake.sh +++ b/scripts/build-platypus-csd3-cclake.sh @@ -1,8 +1,10 @@ #!/bin/bash #set -ue -export STACK_SRC=`mktemp -d /tmp/moose_stack_src.XXXXXX` -export WORKDIR=`pwd` +STACK_SRC=$(mktemp -d /tmp/moose_stack_src.XXXXXX) +export STACK_SRC +WORKDIR=$(pwd) +export WORKDIR export compile_cores=32 export OMPI_MCA_mca_base_component_show_load_errors=0 @@ -14,42 +16,42 @@ function load_modules() { } function build_petsc() { - cd $WORKDIR + cd "$WORKDIR" || exit 1 curl -LJO https://github.com/xiaoyeli/superlu_dist/archive/refs/tags/v8.1.0.tar.gz - if [ -d "$WORKDIR/petsc" ] ; then - return + if [ -d "$WORKDIR/petsc" ]; then + return fi mkdir petsc - cd petsc + cd petsc || exit 1 curl -L -O http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.19.3.tar.gz tar -xf petsc-3.19.3.tar.gz -C . - cd petsc-3.19.3 + cd petsc-3.19.3 || exit 1 ./configure \ - --prefix=$WORKDIR/petsc \ + --prefix="$WORKDIR"/petsc \ CXXOPTFLAGS='-O3 -march=cascadelake -funroll-loops' COPTFLAGS='-O3 -march=cascadelake -funroll-loops' FOPTFLAGS='-O3 -march=cascadelake' \ - --with-debugging=0 \ - --with-ssl=0 \ - --with-pic=1 \ - --with-openmp=1 \ - --with-mpi=1 \ - --with-shared-libraries=1 \ - --with-fortran-bindings=0 \ - --with-sowing=0 \ - --download-hypre=1 \ - --download-fblaslapack=1 \ - --download-metis=1 \ - --download-ptscotch=1 \ - --download-parmetis=1 \ - --download-superlu_dist=$WORKDIR/superlu_dist-8.1.0.tar.gz \ - --download-scalapack=1 \ - --download-mumps=1 \ - --download-slepc=1 \ - --with-64-bit-indices=1 \ - --with-mpi-dir=/usr/local/Cluster-Apps/openmpi/gcc/9.3/4.0.4 \ - PETSC_DIR=`pwd` PETSC_ARCH=arch-linux-c-opt + --with-debugging=0 \ + --with-ssl=0 \ + --with-pic=1 \ + --with-openmp=1 \ + --with-mpi=1 \ + --with-shared-libraries=1 \ + --with-fortran-bindings=0 \ + --with-sowing=0 \ + --download-hypre=1 \ + --download-fblaslapack=1 \ + --download-metis=1 \ + --download-ptscotch=1 \ + --download-parmetis=1 \ + --download-superlu_dist="$WORKDIR"/superlu_dist-8.1.0.tar.gz \ + --download-scalapack=1 \ + --download-mumps=1 \ + --download-slepc=1 \ + --with-64-bit-indices=1 \ + --with-mpi-dir=/usr/local/Cluster-Apps/openmpi/gcc/9.3/4.0.4 \ + PETSC_DIR="$(pwd)" PETSC_ARCH=arch-linux-c-opt make - make PETSC_DIR=$WORKDIR/petsc/petsc-3.19.3 PETSC_ARCH=arch-linux-c-opt install - make PETSC_DIR=$WORKDIR/petsc PETSC_ARCH="" check + make PETSC_DIR="$WORKDIR"/petsc/petsc-3.19.3 PETSC_ARCH=arch-linux-c-opt install + make PETSC_DIR="$WORKDIR"/petsc PETSC_ARCH="" check cd .. cd .. export PETSC_DIR=$WORKDIR/petsc @@ -57,20 +59,20 @@ function build_petsc() { function build_moose() { export MOOSE_JOBS=32 - cd $WORKDIR - if [ -d "$WORKDIR/moose" ] ; then - return + cd "$WORKDIR" || exit 1 + if [ -d "$WORKDIR/moose" ]; then + return fi -# _build_mpich33 + # _build_mpich33 load_modules - #build_vtk_git - cd $WORKDIR + # build_vtk_git + cd "$WORKDIR" || exit 1 git clone https://github.com/idaholab/moose - cd moose + cd moose || exit 1 git checkout master - if [ ! -f "$WORKDIR/petsc/lib/libpetsc.so" ] ; then - echo "PETSc Install Unsuccessful" - return + if [ ! -f "$WORKDIR/petsc/lib/libpetsc.so" ]; then + echo "PETSc Install Unsuccessful" + return fi export PETSC_DIR=$WORKDIR/petsc @@ -80,22 +82,22 @@ function build_moose() { export F90=mpif90 export F77=mpif77 export FC=mpif90 - if [ -d "$WORKDIR/vtk" ] ; then - echo "building libmesh with VTK" - METHODS='opt' ./scripts/update_and_rebuild_libmesh.sh --with-mpi --with-cxx-std=2017 --with-vtk-include=$WORKDIR/vtk/include/vtk-9.1 --with-vtk-lib=$WORKDIR/vtk/lib64 + if [ -d "$WORKDIR/vtk" ]; then + echo "building libmesh with VTK" + METHODS='opt' ./scripts/update_and_rebuild_libmesh.sh --with-mpi --with-cxx-std=2017 --with-vtk-include="$WORKDIR"/vtk/include/vtk-9.1 --with-vtk-lib="$WORKDIR"/vtk/lib64 else - echo "Building libmesh withOUT VTK" - METHODS='opt' ./scripts/update_and_rebuild_libmesh.sh --with-mpi + echo "Building libmesh withOUT VTK" + METHODS='opt' ./scripts/update_and_rebuild_libmesh.sh --with-mpi fi ./configure --with-derivative-size=200 --with-ad-indexing-type=global METHODS='opt' ./scripts/update_and_rebuild_wasp.sh - cd framework + cd framework || exit 1 METHOD=opt make -j32 cd .. - cd modules + cd modules || exit 1 METHOD=opt make -j32 cd .. - cd test + cd test || exit 1 METHOD=opt make -j32 ./run_tests -j32 cd .. @@ -103,16 +105,16 @@ function build_moose() { } function build_mfem() { - cd $WORKDIR - if [ -d "$WORKDIR/mfem" ] ; then - return + cd "$WORKDIR" || exit 1 + if [ -d "$WORKDIR/mfem" ]; then + return fi git clone https://github.com/Heinrich-BR/mfem.git - cd mfem + cd mfem || exit 1 git checkout SubmeshBoundary - sed -i "s|list|# list|g" $WORKDIR/mfem/config/cmake/modules/FindNetCDF.cmake + sed -i "s|list|# list|g" "$WORKDIR"/mfem/config/cmake/modules/FindNetCDF.cmake mkdir build - cd build + cd build || exit 1 echo "Building MFEM" cmake .. \ -DCMAKE_BUILD_TYPE=Release \ @@ -120,41 +122,41 @@ function build_mfem() { -DMFEM_SHARED=YES \ -DMFEM_USE_OPENMP=YES \ -DMFEM_THREAD_SAFE=NO \ - -DHYPRE_DIR=/$WORKDIR/petsc/ \ - -DBLAS_LIBRARIES=/$WORKDIR/petsc/lib/libfblas.a \ - -DLAPACK_LIBRARIES=/$WORKDIR/petsc/lib/libflapack.a \ + -DHYPRE_DIR=/"$WORKDIR"/petsc/ \ + -DBLAS_LIBRARIES=/"$WORKDIR"/petsc/lib/libfblas.a \ + -DLAPACK_LIBRARIES=/"$WORKDIR"/petsc/lib/libflapack.a \ -DMFEM_USE_MPI=YES \ -DMFEM_USE_METIS_5=YES \ - -DMETIS_DIR=/$WORKDIR/petsc/ \ - -DParMETIS_DIR=/$WORKDIR/petsc/ \ + -DMETIS_DIR=/"$WORKDIR"/petsc/ \ + -DParMETIS_DIR=/"$WORKDIR"/petsc/ \ -DMFEM_USE_SUPERLU=YES \ - -DSuperLUDist_DIR=/$WORKDIR/petsc/ \ + -DSuperLUDist_DIR=/"$WORKDIR"/petsc/ \ -DMFEM_USE_NETCDF=YES \ - -DNETCDF_LIBRARIES=$WORKDIR/moose/libmesh/installed/lib/libnetcdf.so \ - -DNETCDF_INCLUDE_DIRS=$WORKDIR/moose/libmesh/contrib/netcdf/netcdf-c-4.6.2/include \ + -DNETCDF_LIBRARIES="$WORKDIR"/moose/libmesh/installed/lib/libnetcdf.so \ + -DNETCDF_INCLUDE_DIRS="$WORKDIR"/moose/libmesh/contrib/netcdf/netcdf-c-4.6.2/include \ -DHDF5_DIR=/usr/local/Cluster-Apps/hdf5/openmpi/gcc/9.3/1.12.0 \ -DCMAKE_POLICY_DEFAULT_CMP0057=NEW make -j"$compile_cores" - cd miniapps/common + cd miniapps/common || exit 1 make -j"$compile_cores" } function build_platypus() { - cd $WORKDIR - if [ -d "$WORKDIR/platypus" ] ; then - return + cd "$WORKDIR" || exit 1 + if [ -d "$WORKDIR/platypus" ]; then + return fi git clone https://github.com/aurora-multiphysics/platypus.git - cd platypus + cd platypus || exit 1 git checkout master git submodule update --init --recursive - cd contrib/hephaestus/ + cd contrib/hephaestus/ || exit 1 mkdir build - cd build - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DMFEM_DIR=/$WORKDIR/mfem/build -DMFEM_COMMON_INCLUDES=/$WORKDIR/mfem/miniapps/common .. + cd build || exit 1 + cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DMFEM_DIR=/"$WORKDIR"/mfem/build -DMFEM_COMMON_INCLUDES=/"$WORKDIR"/mfem/miniapps/common .. make -j1 - cd /$WORKDIR/platypus + cd /"$WORKDIR"/platypus || exit 1 make -j"$compile_cores" } diff --git a/scripts/build-platypus-csd3-sapphire.sh b/scripts/build-platypus-csd3-sapphire.sh old mode 100644 new mode 100755 index c3d14427..6873ebb2 --- a/scripts/build-platypus-csd3-sapphire.sh +++ b/scripts/build-platypus-csd3-sapphire.sh @@ -8,7 +8,8 @@ #SBATCH --cpus-per-task=1 #SBATCH -o out_%j_%A_%a #SBATCH --exclusive -. /etc/profile.d/modules.sh +# shellcheck source=/dev/null +. /etc/profile.d/modules.sh #TODO: # - Remove xdr requirement from moose/scripts/configure_libmesh @@ -25,26 +26,25 @@ function load_modules() { module load python/3.8 module load ninja - export STACK_SRC=`mktemp -d /tmp/moose_stack_src.XXXXXX` - export WORKDIR=`pwd` + STACK_SRC=$(mktemp -d /tmp/moose_stack_src.XXXXXX) + export STACK_SRC + WORKDIR=$(pwd) + export WORKDIR export compile_cores=8 export OMPI_MCA_mca_base_component_show_load_errors=0 - USER=`whoami` + USER=$(whoami) BUILD_DIR_NAME=${WORKDIR} ROOT_PATH=/home/${USER}/rds/rds-ukaea-ap001/${USER} BUILD_PATH=${ROOT_PATH}/${BUILD_DIR_NAME} - USR_PATH=${BUILD_PATH}/usr HDF5_MAJ_VER=1.10 HDF5_MIN_VER=10 HDF5_DIR_NAME=hdf5 HDF5_INSTALL_PATH=${WORKDIR}/${HDF5_DIR_NAME} - PETSC_COMMIT=38aca504f6ea08cc814f159b2c9bcf837a5876f3 PETSC_DIR_NAME=petsc - PETSC_INSTALL_DIR=${BUILD_PATH}/petsc MOOSE_COMMIT=4e99faf9804480e7be302895ff9b8ded5b9944ea @@ -52,14 +52,14 @@ function load_modules() { export PATH=${BUILD_PATH}:${PATH} - cd ${WORKDIR} + cd "${WORKDIR}" || exit 1 #Need to set some compiler flags via config file" echo "-std=c++17" >> icpx.cfg echo "-Wno-tautological-constant-compare" >> icpx.cfg export ICPXCFG=${WORKDIR}/icpx.cfg - export CC=mpiicc + export CC=mpiicc export CXX=mpiicpc export FC=mpiifort export F77=mpiifort @@ -68,35 +68,41 @@ function load_modules() { export I_MPI_CXX=icpx export I_MPI_F90=ifx export I_MPI_FC=ifx - export I_MPI_F77=ifx + export I_MPI_F77=ifx } function _build_hdf5() { - cd ${WORKDIR} - mkdir -p ${HDF5_DIR_NAME} || { echo "Failed to create ${HDF5_DIR_NAME}" ; exit 1 ; } + cd "${WORKDIR}" || exit 1 + mkdir -p ${HDF5_DIR_NAME} || { + echo "Failed to create ${HDF5_DIR_NAME}" + exit 1 + } HDF5_MAJ_VER=1.10 HDF5_MIN_VER=10 HDF5_VER=${HDF5_MAJ_VER}.${HDF5_MIN_VER} echo "Downloading HDF5" curl -kLJO \ - https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_MAJ_VER}/hdf5-${HDF5_VER}/src/hdf5-${HDF5_VER}.tar.gz \ - || { echo "Failed to download hdf5" ; exit 1 ; } + https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_MAJ_VER}/hdf5-${HDF5_VER}/src/hdf5-${HDF5_VER}.tar.gz || + { + echo "Failed to download hdf5" + exit 1 + } tar -xf hdf5-${HDF5_VER}.tar.gz - cd hdf5-${HDF5_VER} + cd hdf5-${HDF5_VER} || exit 1 make clean - ./configure --prefix=${HDF5_INSTALL_PATH} --enable-cxx --enable-fortran --enable-build-mode=production + ./configure --prefix="${HDF5_INSTALL_PATH}" --enable-cxx --enable-fortran --enable-build-mode=production make install -j ${compile_cores} if [ $? -eq 2 ]; then echo "HDF5 Build failed" exit 1 fi - echo "HDF5 built" + echo "HDF5 built" } function _build_petsc() { - cd $WORKDIR + cd "$WORKDIR" || exit 1 # echo "Downloading SuperLU_dist" # curl -kLJO https://github.com/xiaoyeli/superlu_dist/archive/refs/tags/v8.1.0.tar.gz # curl -kLJO https://github.com/xiaoyeli/superlu_dist/archive/refs/tags/v8.1.0.tar.gz @@ -104,38 +110,41 @@ function _build_petsc() { # return # fi mkdir -p petsc - cd petsc + cd petsc || exit 1 curl -kL -O http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.19.3.tar.gz tar -xf petsc-3.19.3.tar.gz -C . - cd petsc-3.19.3 + cd petsc-3.19.3 || exit 1 ./configure \ - --with-cc=$CC --with-cxx=$CXX --with-fc=$FC -CXXPP=cpp \ - --prefix=${WORKDIR}/${PETSC_DIR_NAME} \ - --download-hypre=1 \ - --with-shared-libraries \ - --with-debugging=no \ - --with-hdf5-dir=${WORKDIR}/${HDF5_DIR_NAME} \ - --with-blaslapack-dir=${MKLROOT} \ - --download-metis=1 \ - --download-parmetis=1 \ - --download-ptscotch=1 \ - --download-mumps=1 \ - --download-superlu_dist=${WORKDIR}/superlu_dist-8.1.0.tar.gz \ - --download-scalapack=1 \ - --download-slepc=1 \ - --with-mpi=1 \ - --with-cxx-dialect=C++17 \ - --with-fortran-bindings=0 \ - --with-sowing=0 \ - --with-64-bit-indices \ - --with-make-np=${SLURM_NTASKS} \ - COPTFLAGS='-O3 -fno-slp-vectorize' \ - CXXOPTFLAGS='-O3 -fno-slp-vectorize' \ - FOPTFLAGS='-O3 -fno-slp-vectorize' \ - PETSC_DIR=`pwd` PETSC_ARCH=arch-linux-c-opt + --with-cc=$CC --with-cxx=$CXX --with-fc=$FC -CXXPP=cpp \ + --prefix="${WORKDIR}/${PETSC_DIR_NAME}" \ + --download-hypre=1 \ + --with-shared-libraries \ + --with-debugging=no \ + --with-hdf5-dir="${WORKDIR}"/${HDF5_DIR_NAME} \ + --with-blaslapack-dir="${MKLROOT}" \ + --download-metis=1 \ + --download-parmetis=1 \ + --download-ptscotch=1 \ + --download-mumps=1 \ + --download-superlu_dist="${WORKDIR}"/superlu_dist-8.1.0.tar.gz \ + --download-scalapack=1 \ + --download-slepc=1 \ + --with-mpi=1 \ + --with-cxx-dialect=C++17 \ + --with-fortran-bindings=0 \ + --with-sowing=0 \ + --with-64-bit-indices \ + --with-make-np="${SLURM_NTASKS}" \ + COPTFLAGS='-O3 -fno-slp-vectorize' \ + CXXOPTFLAGS='-O3 -fno-slp-vectorize' \ + FOPTFLAGS='-O3 -fno-slp-vectorize' \ + PETSC_DIR="$(pwd)" PETSC_ARCH=arch-linux-c-opt make - make PETSC_DIR=${WORKDIR}/${PETSC_DIR_NAME}/petsc-3.19.3 PETSC_ARCH=arch-linux-c-opt install \ - || { echo "Failed to build petsc" ; exit 1 ; } + make PETSC_DIR="${WORKDIR}"/${PETSC_DIR_NAME}/petsc-3.19.3 PETSC_ARCH=arch-linux-c-opt install || + { + echo "Failed to build petsc" + exit 1 + } cd .. cd .. export PETSC_DIR=$WORKDIR/petsc @@ -143,17 +152,20 @@ function _build_petsc() { function build_moose() { export MOOSE_JOBS=32 - cd $WORKDIR + cd "$WORKDIR" || exit 1 # if [ -d "$WORKDIR/moose" ] ; then # return # fi - cd $WORKDIR + cd "$WORKDIR" || exit 1 git clone https://github.com/idaholab/moose - cd moose - git checkout ${MOOSE_COMMIT} || { echo "Checkout failed" ; exit 1 ; } - if [ ! -f "$WORKDIR/petsc/lib/libpetsc.so" ] ; then - echo "PETSc Install Unsuccessful" - return + cd moose || exit 1 + git checkout ${MOOSE_COMMIT} || { + echo "Checkout failed" + exit 1 + } + if [ ! -f "$WORKDIR/petsc/lib/libpetsc.so" ]; then + echo "PETSc Install Unsuccessful" + return fi export PETSC_DIR=$WORKDIR/petsc export PETSC_ARCH=arch-linux-c-opt @@ -195,16 +207,16 @@ function build_moose() { export I_MPI_F90=ifx export I_MPI_F77=ifx export I_MPI_C=icx - + ./configure --with-derivative-size=200 --with-ad-indexing-type=global METHODS='opt' ./scripts/update_and_rebuild_wasp.sh - cd framework + cd framework || exit 1 METHOD=opt make -j"$compile_cores" cd .. - cd modules + cd modules || exit 1 METHOD=opt make -j"$compile_cores" cd .. - cd test + cd test || exit 1 METHOD=opt make -j"$compile_cores" ./run_tests -j"$compile_cores" cd .. @@ -212,69 +224,69 @@ function build_moose() { } function build_gslib() { - cd $WORKDIR - if [ -d "$WORKDIR/gslb" ] ; then - return + cd "$WORKDIR" || exit 1 + if [ -d "$WORKDIR/gslb" ]; then + return fi git clone https://github.com/Nek5000/gslib.git - cd gslib + cd gslib || exit 1 make CFLAGS='-O2 -fPIC' } function build_mfem() { - cd $WORKDIR + cd "$WORKDIR" || exit 1 # if [ -d "$WORKDIR/mfem" ] ; then # return # fi git clone https://github.com/Heinrich-BR/mfem.git - cd mfem + cd mfem || exit 1 git checkout SubmeshBoundary - sed -i "s|list|# list|g" $WORKDIR/mfem/config/cmake/modules/FindNetCDF.cmake + sed -i "s|list|# list|g" "$WORKDIR"/mfem/config/cmake/modules/FindNetCDF.cmake mkdir build - cd build + cd build || exit 1 echo "Building MFEM" cmake .. \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_POSITION_INDEPENDENT_CODE=YES \ - -DMFEM_USE_OPENMP=NO \ - -DMFEM_THREAD_SAFE=NO \ - -DHYPRE_DIR=/$WORKDIR/petsc/ \ + -DCMAKE_POSITION_INDEPENDENT_CODE=YES \ + -DMFEM_USE_OPENMP=NO \ + -DMFEM_THREAD_SAFE=NO \ + -DHYPRE_DIR=/"$WORKDIR"/petsc/ \ -DMFEM_USE_LAPACK=YES \ -DMFEM_USE_MPI=YES \ -DMFEM_USE_METIS_5=YES \ - -DMETIS_DIR=/$WORKDIR/petsc/ \ - -DParMETIS_DIR=/$WORKDIR/petsc/ \ + -DMETIS_DIR=/"$WORKDIR"/petsc/ \ + -DParMETIS_DIR=/"$WORKDIR"/petsc/ \ -DMFEM_USE_SUPERLU=YES \ - -DSuperLUDist_DIR=/$WORKDIR/petsc/ \ + -DSuperLUDist_DIR=/"$WORKDIR"/petsc/ \ -DSuperLUDist_VERSION_OK=YES \ -DMFEM_USE_NETCDF=YES \ - -DNETCDF_LIBRARIES=$WORKDIR/moose/libmesh/installed/lib/libnetcdf.so \ - -DNETCDF_INCLUDE_DIRS=$WORKDIR/moose/libmesh/contrib/netcdf/netcdf-c-4.6.2/include \ - -DHDF5_DIR=/$WORKDIR/${HDF5_DIR_NAME}/ \ + -DNETCDF_LIBRARIES="$WORKDIR"/moose/libmesh/installed/lib/libnetcdf.so \ + -DNETCDF_INCLUDE_DIRS="$WORKDIR"/moose/libmesh/contrib/netcdf/netcdf-c-4.6.2/include \ + -DHDF5_DIR=/"$WORKDIR"/${HDF5_DIR_NAME}/ \ -DMFEM_USE_GSLIB=YES \ - -DGSLIB_DIR=/$WORKDIR/gslib/build + -DGSLIB_DIR=/"$WORKDIR"/gslib/build make -j"$compile_cores" - cd miniapps/common + cd miniapps/common || exit 1 make -j"$compile_cores" } function build_platypus() { - cd $WORKDIR + cd "$WORKDIR" || exit 1 # if [ -d "$WORKDIR/platypus" ] ; then # return # fi git clone https://github.com/aurora-multiphysics/platypus.git - cd platypus + cd platypus || exit 1 git checkout ${PLATYPUS_COMMIT} git submodule update --init --recursive - cd contrib/hephaestus/ + cd contrib/hephaestus/ || exit 1 # git checkout master mkdir build - cd build - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DMFEM_DIR=/$WORKDIR/mfem/build .. + cd build || exit 1 + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DMFEM_DIR=/"$WORKDIR"/mfem/build .. ninja - cd /$WORKDIR/platypus + cd /"$WORKDIR"/platypus || exit 1 make -j"$compile_cores" } diff --git a/scripts/install-format-hook.sh b/scripts/install-format-hook.sh index 44a2037a..86e1958a 100755 --- a/scripts/install-format-hook.sh +++ b/scripts/install-format-hook.sh @@ -1,6 +1,6 @@ #!/bin/bash -REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../" +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../" hookfile="$REPO_DIR/.git/hooks/pre-commit" if [[ -f $hookfile ]]; then @@ -8,7 +8,8 @@ if [[ -f $hookfile ]]; then exit 1 fi -echo '#!/bin/bash +cat << 'EOF' > "$hookfile" +#!/bin/bash patch=$(git clang-format --diff -- $(git diff --staged --name-only -- src include tests unit)) if [[ "$patch" =~ "no modified files to format" || "$patch" =~ "clang-format did not modify any files" ]]; then echo "" > /dev/null @@ -20,7 +21,6 @@ else echo "$patch" exit 1 fi -' > $hookfile - -chmod a+x $hookfile +EOF +chmod a+x "$hookfile" diff --git a/scripts/upload-coverage.sh b/scripts/upload-coverage.sh new file mode 100755 index 00000000..980963ef --- /dev/null +++ b/scripts/upload-coverage.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd /opt/platypus || exit 1 +bash <(curl -s https://codecov.io/bash) diff --git a/src/postprocessors/ElementVectorL2Difference.C b/src/postprocessors/ElementVectorL2Difference.C index a2b70acb..7a47903f 100644 --- a/src/postprocessors/ElementVectorL2Difference.C +++ b/src/postprocessors/ElementVectorL2Difference.C @@ -47,13 +47,15 @@ ElementVectorL2Difference::computeQpIntegral() return difference_vector.norm_sq(); // dot product of difference vector. } -void ElementVectorL2Difference::checkVectorVariables() const +void +ElementVectorL2Difference::checkVectorVariables() const { auto & coupled_vector_variables = getCoupledVectorMooseVars(); if (coupled_vector_variables.size() != 2) { - mooseError("There are ", coupled_vector_variables.size(), " coupled vector variables. Expected 2."); + mooseError( + "There are ", coupled_vector_variables.size(), " coupled vector variables. Expected 2."); } auto first = coupled_vector_variables[0]; diff --git a/test/include/base/PlatypusTestApp.h b/test/include/base/PlatypusTestApp.h index ff8133e2..82119365 100644 --- a/test/include/base/PlatypusTestApp.h +++ b/test/include/base/PlatypusTestApp.h @@ -13,4 +13,3 @@ class PlatypusTestApp : public MooseApp static void registerApps(); static void registerAll(Factory & f, ActionFactory & af, Syntax & s, bool use_test_objs = false); }; - diff --git a/unit/run_tests b/unit/run_tests index f79debb7..2fef62c7 100755 --- a/unit/run_tests +++ b/unit/run_tests @@ -2,17 +2,15 @@ APPLICATION_NAME=platypus # If $METHOD is not set, use opt -if [ -z $METHOD ]; then - export METHOD=opt +if [ -z "$METHOD" ]; then + export METHOD=opt fi -if [ -e ./unit/$APPLICATION_NAME-unit-$METHOD ] -then - ./unit/$APPLICATION_NAME-unit-$METHOD -elif [ -e ./$APPLICATION_NAME-unit-$METHOD ] -then - ./$APPLICATION_NAME-unit-$METHOD +if [ -e ./unit/"$APPLICATION_NAME"-unit-"$METHOD" ]; then + ./unit/"$APPLICATION_NAME"-unit-"$METHOD" +elif [ -e ./"$APPLICATION_NAME"-unit-"$METHOD" ]; then + ./"$APPLICATION_NAME"-unit-"$METHOD" else - echo "Executable missing!" - exit 1 + echo "Executable missing!" + exit 1 fi