diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..7cd753dcb --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,12 @@ +# Setting file for clang-tidy + +Checks: > + -*, + boost-*, + modernize-*, + -modernize-avoid-c-arrays, + -modernize-use-trailing-return-type, + mpi-*, + performance-* + +WarningsAsErrors: '*' \ No newline at end of file diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 000000000..c7198fd9d --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,33 @@ +name: Clang-Format Check + +on: + push: + branches: + - master + pull_request: + branches: + - master + - development + +concurrency: + group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request'}} + +permissions: + contents: read + +jobs: + clang-format-check: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 30 + + - name: Run Clang-Format + uses: jidicula/clang-format-action@v4.13.0 + with: + clang-format-version: '16' diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 000000000..deb3271da --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,52 @@ +name: CI-Linux + +on: + push: + branches: + - master + pull_request: + branches: + - master + - development + types: + - opened + - reopened + - synchronize + - ready_for_review + paths-ignore: + - 'applications/**' + +concurrency: + group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request'}} + +permissions: + contents: read + +jobs: + CI-Linux: + runs-on: [ubuntu-22.04] + timeout-minutes: 120 + + container: + image: dealii/dealii:v9.6.0-jammy + options: --user root + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Compile PRISMS-PF + run: | + cmake . + make -j $(nproc) + + - name: Run PRISMS-PF tests + timeout-minutes: 60 + run: | + export OMPI_ALLOW_RUN_AS_ROOT=1 + export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 + + cd tests/automatic_tests + python3 run_automatic_tests.py + diff --git a/.gitignore b/.gitignore index bb4699f34..f9385a929 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,19 @@ +# Build folder +build/* + +# VS Code +.vscode/* + +# Python virtual environments +.venv/* +*.venv/ + +# clangd +.clangd + +# misc +compile_commands.json + # Compiled Object files *.slo *.lo @@ -19,6 +35,7 @@ *.exe *.out *.app +*.pbs #Output files *vtk @@ -82,10 +99,11 @@ DoxygenWarningLog.txt freeEnergy.txt output.txt -restart* +# Output files integratedFields.txt # Checkpoint/restart files +restart* restart.mesh restart.mesh.info restart.mesh.info.old diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 91a6c6607..000000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -sudo: required -dist: trusty -language: cpp - - -services: - - docker - -before_install: - - if [ "$TRAVIS_EVENT_TYPE" == "pull_request" ]; then export BRANCH=$TRAVIS_PULL_REQUEST_BRANCH; export SLUG=$TRAVIS_PULL_REQUEST_SLUG; fi - - if [ "$TRAVIS_EVENT_TYPE" == "push" ]; then export BRANCH=$TRAVIS_BRANCH; export SLUG=$TRAVIS_REPO_SLUG; fi - - docker pull dealii/dealii:v8.4.2-gcc-mpi-fulldepsmanual-debugrelease - - docker run dealii/dealii:v8.4.2-gcc-mpi-fulldepsmanual-debugrelease /bin/sh -c "wget https://github.com/$SLUG/archive/$BRANCH.zip; unzip -q $BRANCH.zip; echo 'Branch name:'; echo $BRANCH; python phaseField-${BRANCH#v}/tests/automatic_tests/run_automatic_tests.py" - -script: bash test_ci.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 3055abf22..1d51b703b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,11 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) # Find deal.II installation -FIND_PACKAGE(deal.II 8.3.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) - DEAL_II_INITIALIZE_CACHED_VARIABLES() # Set up the debug, release, and run targets @@ -25,38 +24,30 @@ ADD_CUSTOM_TARGET(release ADD_CUSTOM_TARGET(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" - ) +) # Set up the paths to the library files -INCLUDE_DIRECTORIES(include) - -FILE(GLOB headers include/*.h) -FILE(GLOB matrixfree_sources src/matrixfree/*.cc) - -FILE(GLOB userinputparameters_sources src/userInputParameters/*.cc) - -FILE(GLOB solverparameters_sources src/SolverParameters/*.cc) - -FILE(GLOB equationdependencyparser_sources src/EquationDependencyParser/*.cc) - -FILE(GLOB floodfiller_sources src/FloodFiller/*.cc) - -FILE(GLOB orderparameterremapper_sources src/OrderParameterRemapper/*.cc) - -FILE(GLOB simplifiedgrainrepresentation_sources src/SimplifiedGrainRepresentation/*.cc) - - +include_directories(include) + +file(GLOB headers include/*.h) +file(GLOB matrixfree_sources src/matrixfree/*.cc) +file(GLOB userinputparameters_sources src/userInputParameters/*.cc) +file(GLOB solverparameters_sources src/SolverParameters/*.cc) +file(GLOB equationdependencyparser_sources src/EquationDependencyParser/*.cc) +file(GLOB floodfiller_sources src/FloodFiller/*.cc) +file(GLOB orderparameterremapper_sources src/OrderParameterRemapper/*.cc) +file(GLOB simplifiedgrainrepresentation_sources src/SimplifiedGrainRepresentation/*.cc) + +# Add main project PROJECT(prisms_pf) -SET(CMAKE_BUILD_TYPE Release) +set(CMAKE_BUILD_TYPE Release) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Append extra flags for the GNU compiler to suppress some warnings if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(CMAKE_CXX_FLAGS "-Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") + set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") + set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") endif() ADD_LIBRARY(${PROJECT_NAME} ${matrixfree_sources} ${userinputparameters_sources} ${solverparameters_sources} ${equationdependencyparser_sources} ${floodfiller_sources} ${orderparameterremapper_sources} ${simplifiedgrainrepresentation_sources} src/utilities/sortIndexEntryPairList.cc src/variableAttributeLoader/variableAttributeLoader.cc src/utilities/vectorBCFunction.cc src/inputFileReader/inputFileReader.cc src/parallelNucleationList/parallelNucleationList.cc src/variableContainer/variableContainer.cc) @@ -67,11 +58,8 @@ SET(CMAKE_BUILD_TYPE Debug) # Append extra flags for the GNU compiler to suppress some warnings if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(CMAKE_CXX_FLAGS "-Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") + set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") + set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") endif() ADD_LIBRARY(${PROJECT_NAME} ${matrixfree_sources} ${userinputparameters_sources} ${solverparameters_sources} ${equationdependencyparser_sources} ${floodfiller_sources} ${orderparameterremapper_sources} ${simplifiedgrainrepresentation_sources} src/utilities/sortIndexEntryPairList.cc src/variableAttributeLoader/variableAttributeLoader.cc src/utilities/vectorBCFunction.cc src/inputFileReader/inputFileReader.cc src/parallelNucleationList/parallelNucleationList.cc src/variableContainer/variableContainer.cc) diff --git a/README.md b/README.md index 7013ac381..6c449d354 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ ![](logo_v2.png) -[![Build Status](https://travis-ci.org/prisms-center/phaseField.svg?branch=master)](https://travis-ci.org/prisms-center/phaseField) +[![GitHub Linux](https://github.com/prisms-center/phaseField/actions/workflows/linux.yml/badge.svg)](https://github.com/prisms-center/phaseField/actions/workflows/linux.yml) +[![Clang-Format](https://github.com/prisms-center/phaseField/actions/workflows/clang-format.yml/badge.svg)](https://github.com/prisms-center/phaseField/actions/workflows/clang-format.yml) + + [![License: LGPL v2.1](https://img.shields.io/badge/License-lgpl-blue.svg)](https://www.gnu.org/licenses/lgpl-2.1) [![DOI](https://zenodo.org/badge/22602327.svg)](https://zenodo.org/badge/latestdoi/22602327) diff --git a/applications/CHAC_anisotropy/CMakeLists.txt b/applications/CHAC_anisotropy/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/CHAC_anisotropy/CMakeLists.txt +++ b/applications/CHAC_anisotropy/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/CHAC_anisotropy/ICs_and_BCs.cc b/applications/CHAC_anisotropy/ICs_and_BCs.cc index d50a0bd8f..6bfac8aab 100644 --- a/applications/CHAC_anisotropy/ICs_and_BCs.cc +++ b/applications/CHAC_anisotropy/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -52,12 +52,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/CHAC_anisotropy/customPDE.h b/applications/CHAC_anisotropy/customPDE.h index 1aca9767b..c55aed029 100644 --- a/applications/CHAC_anisotropy/customPDE.h +++ b/applications/CHAC_anisotropy/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/CHAC_anisotropy/equations.cc b/applications/CHAC_anisotropy/equations.cc index 3dfef3a44..cf26337f2 100644 --- a/applications/CHAC_anisotropy/equations.cc +++ b/applications/CHAC_anisotropy/equations.cc @@ -49,8 +49,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -149,8 +150,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -171,6 +173,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/CHAC_anisotropy/postprocess.cc b/applications/CHAC_anisotropy/postprocess.cc index be1da81c9..4042fa6b7 100644 --- a/applications/CHAC_anisotropy/postprocess.cc +++ b/applications/CHAC_anisotropy/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- // c diff --git a/applications/CHAC_anisotropyRegularized/CMakeLists.txt b/applications/CHAC_anisotropyRegularized/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/CHAC_anisotropyRegularized/CMakeLists.txt +++ b/applications/CHAC_anisotropyRegularized/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/CHAC_anisotropyRegularized/ICs_and_BCs.cc b/applications/CHAC_anisotropyRegularized/ICs_and_BCs.cc index c55ec7273..75b1d8324 100644 --- a/applications/CHAC_anisotropyRegularized/ICs_and_BCs.cc +++ b/applications/CHAC_anisotropyRegularized/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -56,12 +56,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/CHAC_anisotropyRegularized/customPDE.h b/applications/CHAC_anisotropyRegularized/customPDE.h index 4ef826afb..016c952a3 100644 --- a/applications/CHAC_anisotropyRegularized/customPDE.h +++ b/applications/CHAC_anisotropyRegularized/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/CHAC_anisotropyRegularized/equations.cc b/applications/CHAC_anisotropyRegularized/equations.cc index 07c4aabb1..34d6efdd6 100644 --- a/applications/CHAC_anisotropyRegularized/equations.cc +++ b/applications/CHAC_anisotropyRegularized/equations.cc @@ -57,8 +57,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -162,8 +163,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -193,6 +195,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/CHAC_anisotropyRegularized/postprocess.cc b/applications/CHAC_anisotropyRegularized/postprocess.cc index c19116d5a..921fc6952 100644 --- a/applications/CHAC_anisotropyRegularized/postprocess.cc +++ b/applications/CHAC_anisotropyRegularized/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/CHAC_performance_test/CMakeLists.txt b/applications/CHAC_performance_test/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/CHAC_performance_test/CMakeLists.txt +++ b/applications/CHAC_performance_test/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/CHAC_performance_test/ICs_and_BCs.cc b/applications/CHAC_performance_test/ICs_and_BCs.cc index a15c17354..1dab9766c 100644 --- a/applications/CHAC_performance_test/ICs_and_BCs.cc +++ b/applications/CHAC_performance_test/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -67,12 +67,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/CHAC_performance_test/customPDE.h b/applications/CHAC_performance_test/customPDE.h index d98dbc6f0..e83b8b4b5 100644 --- a/applications/CHAC_performance_test/customPDE.h +++ b/applications/CHAC_performance_test/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -78,8 +90,8 @@ class customPDE : public MatrixFreePDE double Mn = userInputs.get_model_constant_double("Mn"); double Kn = userInputs.get_model_constant_double("Kn"); - dealii::Tensor<1, dim> center1 = userInputs.get_model_constant_rank_1_tensor("center1"); - dealii::Tensor<1, dim> center2 = userInputs.get_model_constant_rank_1_tensor("center2"); + Tensor<1, dim> center1 = userInputs.get_model_constant_rank_1_tensor("center1"); + Tensor<1, dim> center2 = userInputs.get_model_constant_rank_1_tensor("center2"); double radius1 = userInputs.get_model_constant_double("radius1"); double radius2 = userInputs.get_model_constant_double("radius2"); diff --git a/applications/CHAC_performance_test/equations.cc b/applications/CHAC_performance_test/equations.cc index 9096645de..d05a7e466 100644 --- a/applications/CHAC_performance_test/equations.cc +++ b/applications/CHAC_performance_test/equations.cc @@ -49,8 +49,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -110,8 +111,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -132,6 +134,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/CHAC_performance_test/postprocess.cc b/applications/CHAC_performance_test/postprocess.cc index 6c3fa02ef..a2a9ab921 100644 --- a/applications/CHAC_performance_test/postprocess.cc +++ b/applications/CHAC_performance_test/postprocess.cc @@ -36,9 +36,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/CHiMaD_benchmark1a/customPDE.h b/applications/CHiMaD_benchmark1a/customPDE.h deleted file mode 100644 index ed9048fc4..000000000 --- a/applications/CHiMaD_benchmark1a/customPDE.h +++ /dev/null @@ -1,81 +0,0 @@ -#include "../../include/matrixFreePDE.h" - -template -class customPDE : public MatrixFreePDE -{ -public: - // Constructor - customPDE(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - , userInputs(_userInputs) {}; - - // Function to set the initial conditions (in ICs_and_BCs.h) - void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); - - // Function to set the non-uniform Dirichlet boundary conditions (in - // ICs_and_BCs.h) - void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); - -private: -#include "../../include/typeDefs.h" - - const userInputParameters userInputs; - - // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) - void - explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the RHS of the governing equations for all other equations - // (in equations.h) - void - nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the LHS of the governing equations (in equations.h) - void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - -// Function to set postprocessing expressions (in postprocess.h) -#ifdef POSTPROCESS_FILE_EXISTS - void - postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; -#endif - -// Function to set the nucleation probability (in nucleation.h) -#ifdef NUCLEATION_FILE_EXISTS - double - getNucleationProbability(variableValueContainer variable_value, double dV) const; -#endif - - // ================================================================ - // Methods specific to this subclass - // ================================================================ - - // ================================================================ - // Model constants specific to this subclass - // ================================================================ - - double McV = userInputs.get_model_constant_double("McV"); - double KcV = userInputs.get_model_constant_double("KcV"); - - // ================================================================ -}; diff --git a/applications/CHiMaD_benchmark1a/integratedFields.txt b/applications/CHiMaD_benchmark1a/integratedFields.txt deleted file mode 100644 index d5edaf688..000000000 --- a/applications/CHiMaD_benchmark1a/integratedFields.txt +++ /dev/null @@ -1,6 +0,0 @@ -0 f_tot 319.0337102 -1 f_tot 318.825361 -5 f_tot 316.9773875 -10 f_tot 304.0120198 -20 f_tot 203.2778723 -100 f_tot 115.6186698 diff --git a/applications/CHiMaD_benchmark2a/customPDE.h b/applications/CHiMaD_benchmark2a/customPDE.h deleted file mode 100644 index 2c74a00ad..000000000 --- a/applications/CHiMaD_benchmark2a/customPDE.h +++ /dev/null @@ -1,85 +0,0 @@ -#include "../../include/matrixFreePDE.h" - -template -class customPDE : public MatrixFreePDE -{ -public: - // Constructor - customPDE(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - , userInputs(_userInputs) {}; - - // Function to set the initial conditions (in ICs_and_BCs.h) - void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); - - // Function to set the non-uniform Dirichlet boundary conditions (in - // ICs_and_BCs.h) - void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); - -private: -#include "../../include/typeDefs.h" - - const userInputParameters userInputs; - - // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) - void - explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the RHS of the governing equations for all other equations - // (in equations.h) - void - nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the LHS of the governing equations (in equations.h) - void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - -// Function to set postprocessing expressions (in postprocess.h) -#ifdef POSTPROCESS_FILE_EXISTS - void - postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; -#endif - -// Function to set the nucleation probability (in nucleation.h) -#ifdef NUCLEATION_FILE_EXISTS - double - getNucleationProbability(variableValueContainer variable_value, double dV) const; -#endif - - // ================================================================ - // Methods specific to this subclass - // ================================================================ - - // ================================================================ - // Model constants specific to this subclass - // ================================================================ - - double McV = userInputs.get_model_constant_double("McV"); - double MnV = userInputs.get_model_constant_double("MnV"); - double KcV = userInputs.get_model_constant_double("KcV"); - double KnV = userInputs.get_model_constant_double("KnV"); - double wV = userInputs.get_model_constant_double("wV"); - double alpha = userInputs.get_model_constant_double("alpha"); - - // ================================================================ -}; diff --git a/applications/CHiMaD_benchmark2a/integratedFields.txt b/applications/CHiMaD_benchmark2a/integratedFields.txt deleted file mode 100644 index 0a72307f9..000000000 --- a/applications/CHiMaD_benchmark2a/integratedFields.txt +++ /dev/null @@ -1,3 +0,0 @@ -0 f_tot 7107.740952 -1 f_tot 3486.538997 -5 f_tot 2794.077052 diff --git a/applications/CHiMaD_benchmark2a/main.cc b/applications/CHiMaD_benchmark2a/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/CHiMaD_benchmark2a/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/CHiMaD_benchmark3/customPDE.h b/applications/CHiMaD_benchmark3/customPDE.h deleted file mode 100644 index 8509dc1df..000000000 --- a/applications/CHiMaD_benchmark3/customPDE.h +++ /dev/null @@ -1,85 +0,0 @@ -#include "../../include/matrixFreePDE.h" - -template -class customPDE : public MatrixFreePDE -{ -public: - // Constructor - customPDE(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - , userInputs(_userInputs) {}; - - // Function to set the initial conditions (in ICs_and_BCs.h) - void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); - - // Function to set the non-uniform Dirichlet boundary conditions (in - // ICs_and_BCs.h) - void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); - -private: -#include "../../include/typeDefs.h" - - const userInputParameters userInputs; - - // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) - void - explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the RHS of the governing equations for all other equations - // (in equations.h) - void - nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the LHS of the governing equations (in equations.h) - void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - -// Function to set postprocessing expressions (in postprocess.h) -#ifdef POSTPROCESS_FILE_EXISTS - void - postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; -#endif - -// Function to set the nucleation probability (in nucleation.h) -#ifdef NUCLEATION_FILE_EXISTS - double - getNucleationProbability(variableValueContainer variable_value, double dV) const; -#endif - - // ================================================================ - // Methods specific to this subclass - // ================================================================ - - // ================================================================ - // Model constants specific to this subclass - // ================================================================ - - double D = userInputs.get_model_constant_double("D"); - double W0 = userInputs.get_model_constant_double("W0"); - double delta = userInputs.get_model_constant_double("delta"); - double epsilonM = userInputs.get_model_constant_double("epsilonM"); - double theta0 = userInputs.get_model_constant_double("theta0"); - double mult = userInputs.get_model_constant_double("mult"); - - // ================================================================ -}; diff --git a/applications/CHiMaD_benchmark3/main.cc b/applications/CHiMaD_benchmark3/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/CHiMaD_benchmark3/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/CHiMaD_benchmark6a/customPDE.h b/applications/CHiMaD_benchmark6a/customPDE.h deleted file mode 100644 index 8d161107f..000000000 --- a/applications/CHiMaD_benchmark6a/customPDE.h +++ /dev/null @@ -1,86 +0,0 @@ -#include "../../include/matrixFreePDE.h" - -template -class customPDE : public MatrixFreePDE -{ -public: - // Constructor - customPDE(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - , userInputs(_userInputs) {}; - - // Function to set the initial conditions (in ICs_and_BCs.h) - void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); - - // Function to set the non-uniform Dirichlet boundary conditions (in - // ICs_and_BCs.h) - void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); - -private: -#include "../../include/typeDefs.h" - - const userInputParameters userInputs; - - // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) - void - explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the RHS of the governing equations for all other equations - // (in equations.h) - void - nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the LHS of the governing equations (in equations.h) - void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - -// Function to set postprocessing expressions (in postprocess.h) -#ifdef POSTPROCESS_FILE_EXISTS - void - postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; -#endif - -// Function to set the nucleation probability (in nucleation.h) -#ifdef NUCLEATION_FILE_EXISTS - double - getNucleationProbability(variableValueContainer variable_value, double dV) const; -#endif - - // ================================================================ - // Methods specific to this subclass - // ================================================================ - - // ================================================================ - // Model constants specific to this subclass - // ================================================================ - - double McV = userInputs.get_model_constant_double("McV"); - double KcV = userInputs.get_model_constant_double("KcV"); - double rho = userInputs.get_model_constant_double("rho"); - double c_alpha = userInputs.get_model_constant_double("c_alpha"); - double c_beta = userInputs.get_model_constant_double("c_beta"); - double k = userInputs.get_model_constant_double("k"); - double epsilon = userInputs.get_model_constant_double("epsilon"); - - // ================================================================ -}; diff --git a/applications/CHiMaD_benchmark6a/main.cc b/applications/CHiMaD_benchmark6a/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/CHiMaD_benchmark6a/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/CHiMaD_benchmark6a/submit_mpi.pbs b/applications/CHiMaD_benchmark6a/submit_mpi.pbs deleted file mode 100644 index df5febc74..000000000 --- a/applications/CHiMaD_benchmark6a/submit_mpi.pbs +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -#### PBS preamble - -#PBS -l nodes=1:ppn=8,pmem=4gb,walltime=2:00:00 -#PBS -o out.txt -#PBS -e err.txt -#PBS -N chimad_bp2a -#PBS -V -#PBS -A kthorn_flux -#PBS -q flux -#PBS -l qos=flux - -# End PBS Settings -############################### - -# Change to the directory you submitted from -if [ -n "$PBS_O_WORKDIR" ]; then cd $PBS_O_WORKDIR; fi - -mkdir /scratch/kthorn_flux/dmontiel/CH_electrostatics_bp_2a/ - -cp main /scratch/kthorn_flux/dmontiel/CH_electrostatics_bp_2a/ -cp parameters.in /scratch/kthorn_flux/dmontiel/CH_electrostatics_bp_2a/ - -cd /scratch/kthorn_flux/dmontiel/CH_electrostatics_bp_2a/ - -# For mpi run -mpirun -n 8 ./main diff --git a/applications/CHiMaD_benchmark6b/CMakeLists.txt b/applications/CHiMaD_benchmark6b/CMakeLists.txt deleted file mode 100644 index 39b8e6bd3..000000000 --- a/applications/CHiMaD_benchmark6b/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -## -# CMake script for the PRISMS-PF applications: -## - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) - -# Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED - HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) - -# Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() - -# Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Debug" - ) - -ADD_CUSTOM_TARGET(release - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Release" - ) - -ADD_CUSTOM_TARGET(run COMMAND main - COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" - ) - -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") - add_definitions(-DPOSTPROCESS_FILE_EXISTS) -endif() -if (EXISTS "nucleation.cc") - add_definitions(-DNUCLEATION_FILE_EXISTS) -endif() - -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) - -DEAL_II_SETUP_TARGET(main) - -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) - -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) - -if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) -endif() diff --git a/applications/CHiMaD_benchmark6b/customPDE.h b/applications/CHiMaD_benchmark6b/customPDE.h deleted file mode 100644 index aea9d2bc1..000000000 --- a/applications/CHiMaD_benchmark6b/customPDE.h +++ /dev/null @@ -1,248 +0,0 @@ -#include "../../include/matrixFreePDE.h" - -template -class customPDE : public MatrixFreePDE -{ -public: - // Constructor - customPDE(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - , userInputs(_userInputs) {}; - - // Function to set the initial conditions (in ICs_and_BCs.h) - void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); - - // Function to set the non-uniform Dirichlet boundary conditions (in - // ICs_and_BCs.h) - void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); - -private: -#include "../../include/typeDefs.h" - - const userInputParameters userInputs; - - // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) - void - explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the RHS of the governing equations for all other equations - // (in equations.h) - void - nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the LHS of the governing equations (in equations.h) - void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - -// Function to set postprocessing expressions (in postprocess.h) -#ifdef POSTPROCESS_FILE_EXISTS - void - postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; -#endif - -// Function to set the nucleation probability (in nucleation.h) -#ifdef NUCLEATION_FILE_EXISTS - double - getNucleationProbability(variableValueContainer variable_value, double dV) const; -#endif - - // ================================================================ - // Methods specific to this subclass - // ================================================================ - - // Virtual method in MatrixFreePDE - void - makeTriangulation(parallel::distributed::Triangulation &) const; - - // ================================================================ - // Model constants specific to this subclass - // ================================================================ - - double McV = userInputs.get_model_constant_double("McV"); - double KcV = userInputs.get_model_constant_double("KcV"); - double rho = userInputs.get_model_constant_double("rho"); - double c_alpha = userInputs.get_model_constant_double("c_alpha"); - double c_beta = userInputs.get_model_constant_double("c_beta"); - double k = userInputs.get_model_constant_double("k"); - double epsilon = userInputs.get_model_constant_double("epsilon"); - - // ================================================================ -}; - -#include - -template -void -customPDE::makeTriangulation( - parallel::distributed::Triangulation &tria) const -{ - dealii::parallel::distributed::Triangulation tria_box(MPI_COMM_WORLD), - tria_semicircle(MPI_COMM_WORLD); - if (dim == 3) - { - GridGenerator::subdivided_hyper_rectangle(tria_box, - userInputs.subdivisions, - Point(), - Point(userInputs.domain_size[0], - userInputs.domain_size[1], - userInputs.domain_size[2])); - } - else if (dim == 2) - { - GridGenerator::subdivided_hyper_rectangle(tria_box, - userInputs.subdivisions, - Point(), - Point(userInputs.domain_size[0], - userInputs.domain_size[1])); - } - else - { - GridGenerator::subdivided_hyper_rectangle(tria_box, - userInputs.subdivisions, - Point(), - Point(userInputs.domain_size[0])); - } - - GridGenerator::half_hyper_ball(tria_semicircle, - Point(userInputs.domain_size[0], - userInputs.domain_size[1] / 2.0), - userInputs.domain_size[1] / 2.0); - - // Find the two non-corner vertices on the right side of the rectangular mesh - Point pt1, pt2; - typename parallel::distributed::Triangulation::active_cell_iterator - cell3 = tria_box.begin_active(), - endc3 = tria_box.end(); - for (; cell3 != endc3; ++cell3) - { - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) - { - Point &v = cell3->vertex(i); - if ((std::abs(v(0) - userInputs.domain_size[0]) < 1e-10) && - (v(1) > userInputs.domain_size[1] / 2.0) && - (v(1) < userInputs.domain_size[1] - 1.0e-10)) - { - pt1 = v; - } - if ((std::abs(v(0) - userInputs.domain_size[0]) < 1e-10) && - (v(1) < userInputs.domain_size[1] / 2.0) && (v(1) > 1.0e-10)) - { - pt2 = v; - } - } - } - // Move the vertices at the center of the half hyper ball so that they will - // align with non-corner vertices on the right side of the rectangular mesh - typename parallel::distributed::Triangulation::active_cell_iterator - cell2 = tria_semicircle.begin_active(), - endc2 = tria_semicircle.end(); - for (; cell2 != endc2; ++cell2) - { - for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) - { - Point &v = cell2->vertex(i); - if ((std::abs(v(0) - userInputs.domain_size[0]) < 1e-10) && - (v(1) > userInputs.domain_size[1] / 2.0) && - (v(1) < userInputs.domain_size[1] - 1.0e-10)) - { - v(1) = pt1(1); - } - if ((std::abs(v(0) - userInputs.domain_size[0]) < 1e-10) && - (v(1) < userInputs.domain_size[1] / 2.0) && (v(1) > 1.0e-10)) - { - v(1) = pt2(1); - } - } - } - // Merge the rectangle and the semicircle - GridGenerator::merge_triangulations(tria_box, tria_semicircle, tria); - - // Attach a spherical manifold to the semicircular part of the domain so that - // it gets refined with rounded edges - static const SphericalManifold boundary( - Point(userInputs.domain_size[0], userInputs.domain_size[1] / 2.0)); - tria.set_manifold(8, boundary); - - typename parallel::distributed::Triangulation::active_cell_iterator - cell = tria.begin_active(), - endc = tria.end(); - for (; cell != endc; ++cell) - { - for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) - { - const Point face_center = cell->face(f)->center(); - if (face_center[0] > userInputs.domain_size[0] + 1.0e-10) - { - cell->face(f)->set_all_manifold_ids(8); - if (face_center.distance(Point(userInputs.domain_size[0], - userInputs.domain_size[1] / 2.0)) > - 0.2 * userInputs.domain_size[1]) - { - cell->set_all_manifold_ids(8); - } - } - } - } - - // Mark the boundaries - typename parallel::distributed::Triangulation::cell_iterator cell4 = tria.begin(), - endc4 = tria.end(); - for (; cell4 != endc4; ++cell4) - { - // Mark all of the faces - for (unsigned int face_number = 0; face_number < GeometryInfo::faces_per_cell; - ++face_number) - { - if (cell4->face(face_number)->at_boundary()) - { - for (unsigned int i = 0; i < dim; i++) - { - if (i == 0) - { - if (std::fabs(cell4->face(face_number)->center()(i) - (0)) < 1e-12) - { - cell4->face(face_number)->set_boundary_id(2 * i); - } - else if (std::fabs(cell4->face(face_number)->center()(i) > - (userInputs.domain_size[i]))) - { - cell4->face(face_number)->set_boundary_id(2 * i + 1); - } - } - else - { - if (std::fabs(cell4->face(face_number)->center()(i) - (0)) < 1e-12) - { - cell4->face(face_number)->set_boundary_id(2 * i); - } - else if (std::fabs(cell4->face(face_number)->center()(i) - - (userInputs.domain_size[i])) < 1e-12) - { - cell4->face(face_number)->set_boundary_id(2 * i + 1); - } - } - } - } - } - } -} diff --git a/applications/CHiMaD_benchmark6b/integratedFields.txt b/applications/CHiMaD_benchmark6b/integratedFields.txt deleted file mode 100644 index ab3a19c4b..000000000 --- a/applications/CHiMaD_benchmark6b/integratedFields.txt +++ /dev/null @@ -1,2 +0,0 @@ -0 f_tot 148.8607333 -5 f_tot 139.2704197 diff --git a/applications/CHiMaD_benchmark6b/main.cc b/applications/CHiMaD_benchmark6b/main.cc deleted file mode 100644 index d85d2eb2f..000000000 --- a/applications/CHiMaD_benchmark6b/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -/// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/CHiMaD_benchmark6b/submit_mpi.pbs b/applications/CHiMaD_benchmark6b/submit_mpi.pbs deleted file mode 100644 index 4c0c1c6e4..000000000 --- a/applications/CHiMaD_benchmark6b/submit_mpi.pbs +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -#### PBS preamble - -#PBS -l nodes=2:ppn=8,pmem=4gb,walltime=2:00:00 -#PBS -o out.txt -#PBS -e err.txt -#PBS -N chimad_bp2b -#PBS -V -#PBS -A kthorn_flux -#PBS -q flux -#PBS -l qos=flux - -# End PBS Settings -############################### - -# Change to the directory you submitted from -if [ -n "$PBS_O_WORKDIR" ]; then cd $PBS_O_WORKDIR; fi - -mkdir /scratch/kthorn_flux/dmontiel/CH_electrostatics_bp_2b/ - -cp main /scratch/kthorn_flux/dmontiel/CH_electrostatics_bp_2b/ -cp parameters.in /scratch/kthorn_flux/dmontiel/CH_electrostatics_bp_2b/ - -cd /scratch/kthorn_flux/dmontiel/CH_electrostatics_bp_2b/ - -# For mpi run -mpirun -n 16 ./main diff --git a/applications/CHiMaD_benchmark7/CMakeLists.txt b/applications/CHiMaD_benchmark7/CMakeLists.txt deleted file mode 100644 index 39b8e6bd3..000000000 --- a/applications/CHiMaD_benchmark7/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -## -# CMake script for the PRISMS-PF applications: -## - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) - -# Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED - HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) - -# Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() - -# Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Debug" - ) - -ADD_CUSTOM_TARGET(release - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Release" - ) - -ADD_CUSTOM_TARGET(run COMMAND main - COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" - ) - -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") - add_definitions(-DPOSTPROCESS_FILE_EXISTS) -endif() -if (EXISTS "nucleation.cc") - add_definitions(-DNUCLEATION_FILE_EXISTS) -endif() - -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) - -DEAL_II_SETUP_TARGET(main) - -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) - -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) - -if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) -endif() diff --git a/applications/CHiMaD_benchmark7/customPDE.h b/applications/CHiMaD_benchmark7/customPDE.h deleted file mode 100644 index 4bc4913fd..000000000 --- a/applications/CHiMaD_benchmark7/customPDE.h +++ /dev/null @@ -1,88 +0,0 @@ -#include "../../include/matrixFreePDE.h" - -template -class customPDE : public MatrixFreePDE -{ -public: - // Constructor - customPDE(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - , userInputs(_userInputs) {}; - - // Function to set the initial conditions (in ICs_and_BCs.h) - void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); - - // Function to set the non-uniform Dirichlet boundary conditions (in - // ICs_and_BCs.h) - void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); - -private: -#include "../../include/typeDefs.h" - - const userInputParameters userInputs; - - // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) - void - explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the RHS of the governing equations for all other equations - // (in equations.h) - void - nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the LHS of the governing equations (in equations.h) - void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - -// Function to set postprocessing expressions (in postprocess.h) -#ifdef POSTPROCESS_FILE_EXISTS - void - postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; -#endif - -// Function to set the nucleation probability (in nucleation.h) -#ifdef NUCLEATION_FILE_EXISTS - double - getNucleationProbability(variableValueContainer variable_value, double dV) const; -#endif - // ================================================================ - // Methods specific to this subclass - // ================================================================ - - // ================================================================ - // Model constants specific to this subclass - // ================================================================ - - double pi = 2.0 * std::acos(0.0); - - double kappa = userInputs.get_model_constant_double("kappa"); - - double A1 = userInputs.get_model_constant_double("A1"); - double B1 = pi * userInputs.get_model_constant_double("B1"); - - double A2 = userInputs.get_model_constant_double("A2"); - double B2 = pi * userInputs.get_model_constant_double("B2"); - double C2 = pi * userInputs.get_model_constant_double("C2"); - - // ================================================================ -}; diff --git a/applications/CHiMaD_benchmark7/main.cc b/applications/CHiMaD_benchmark7/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/CHiMaD_benchmark7/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/CMakeLists.txt b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/CMakeLists.txt new file mode 100644 index 000000000..30e430a8f --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/CMakeLists.txt @@ -0,0 +1,68 @@ +## +# CMake script for the PRISMS-PF applications: +## + +cmake_minimum_required(VERSION 3.1.0) +project(myapp) + +# Find deal.II installation +find_package(deal.II 9.2.0 QUIET REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) + +# Check to make sure deal.II is configured with p4est +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() + +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + +# Set up the debug, release, and run targets +add_custom_target(debug + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) +add_custom_target(release + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) +add_custom_target(run COMMAND main + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" + ) + +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") + add_definitions(-DPOSTPROCESS_FILE_EXISTS) +endif() +if(EXISTS "nucleation.cc") + add_definitions(-DNUCLEATION_FILE_EXISTS) +endif() + +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../../src) +include_directories(${CMAKE_SOURCE_DIR}) + +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../../main.cc") + +# Add main.cc for executable target +add_executable(main ${MAIN}) + +# deal.II linker +DEAL_II_SETUP_TARGET(main) + +# Link libraries for the build type +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +else() + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) +endif() diff --git a/applications/_nucleating_precipitates_MgRE/ICs_and_BCs.h b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/ICs_and_BCs.cc similarity index 61% rename from applications/_nucleating_precipitates_MgRE/ICs_and_BCs.h rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/ICs_and_BCs.cc index 4e52ff304..05b0d2774 100644 --- a/applications/_nucleating_precipitates_MgRE/ICs_and_BCs.h +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/ICs_and_BCs.cc @@ -2,12 +2,14 @@ // FUNCTION FOR INITIAL CONDITIONS // =========================================================================== +#include + template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -16,30 +18,25 @@ customPDE::setInitialCondition(const dealii::Point &p, // Use "if" statements to set the initial condition for each variable // according to its variable index - // Initial condition parameters - double c_matrix = 0.006; - if (index == 0) { - scalar_IC = c_matrix; - } - else if (index == 1) - { - scalar_IC = 0.0; - } - else if (index == 2 || index == 3) - { - scalar_IC = 0.0; + double epsilon = 0.01; + double c0 = 0.5; + double x = p[0]; + double y = p[1]; + + scalar_IC = + c0 + epsilon * (std::cos(0.105 * x) * std::cos(0.11 * y) + + dealii::Utilities::fixed_power<2>(std::cos(0.13 * x) * + std::cos(0.087 * y)) + + std::cos(0.025 * x - 0.15 * y) * std::cos(0.07 * x - 0.02 * y)); } else { - for (unsigned int d = 0; d < dim; d++) - { - vector_IC(d) = 0.0; - } + scalar_IC = 0.0; } - // -------------------------------------------------------------------------- + // --------------------------------------------------------------------- } // =========================================================================== @@ -48,12 +45,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/customPDE.h b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/customPDE.h new file mode 100644 index 000000000..c7bebfc80 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/customPDE.h @@ -0,0 +1,96 @@ +#include "matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + scalarvalueType c_alpha = constV(0.3); + scalarvalueType c_beta = constV(0.7); + scalarvalueType rho_s = constV(5.0); + scalarvalueType kappa = constV(2.0); + scalarvalueType M = constV(5.0); + + // ================================================================ +}; diff --git a/applications/CHiMaD_benchmark1a/equations.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/equations.cc similarity index 83% rename from applications/CHiMaD_benchmark1a/equations.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/equations.cc index f5396be0e..2d2595da7 100644 --- a/applications/CHiMaD_benchmark1a/equations.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/equations.cc @@ -49,8 +49,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -62,8 +63,8 @@ customPDE::explicitEquationRHS( // --- Setting the expressions for the terms in the governing equations --- - scalarvalueType eq_c = (c); - scalargradType eqx_c = (constV(-McV * userInputs.dtValue) * mux); + scalarvalueType eq_c = c; + scalargradType eqx_c = constV(-userInputs.dtValue) * M * mux; // --- Submitting the terms for the governing equations --- @@ -88,8 +89,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -99,14 +101,13 @@ customPDE::nonExplicitEquationRHS( // --- Setting the expressions for the terms in the governing equations --- // The free energy and its derivative - // scalarvalueType fV = (5.0*(c-0.3)*(c-0.3)*(c-0.7)*(c-0.7)); // Not actually - // needed - scalarvalueType fcV = (5.0 * (2.0 * (c - 0.3) * (c - 0.7) * (c - 0.7) + - 2.0 * (c - 0.3) * (c - 0.3) * (c - 0.7))); + scalarvalueType fcV = constV(2.0) * rho_s * + ((c - c_alpha) * dealii::Utilities::fixed_power<2>(c - c_beta) + + (c - c_beta) * dealii::Utilities::fixed_power<2>(c - c_alpha)); // The terms for the governing equations - scalarvalueType eq_mu = (fcV); - scalargradType eqx_mu = (constV(KcV) * cx); + scalarvalueType eq_mu = fcV; + scalargradType eqx_mu = kappa * cx; // --- Submitting the terms for the governing equations --- @@ -132,6 +133,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/parameters.prm b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/parameters.prm new file mode 100644 index 000000000..d43cea326 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/parameters.prm @@ -0,0 +1,52 @@ +# ================================================================================= +# Set the number of dimensions (2 or 3 for a 2D or 3D calculation) +# ================================================================================= +set Number of dimensions = 2 + +# ================================================================================= +# Set the length of the domain in all three dimensions +# (Domain size Z ignored in 2D) +# ================================================================================= + +set Domain size X = 200 +set Domain size Y = 200 +set Domain size Z = 200 + +# ================================================================================= +# Set the element parameters +# ================================================================================= + +set Subdivisions X = 1 +set Subdivisions Y = 1 +set Subdivisions Z = 1 + +set Refine factor = 7 + +set Element degree = 1 + +# ================================================================================= +# Set the time step parameters +# ================================================================================= + +set Time step = 1.0e-2 + +set Simulation end time = 1000 + +# ================================================================================= +# Set the boundary conditions +# ================================================================================= + +set Boundary condition for variable c = PERIODIC +set Boundary condition for variable mu = PERIODIC + +# ================================================================================= +# Set the output parameters +# ================================================================================= + +set Output condition = EQUAL_SPACING + +set Number of outputs = 1 + +set Skip print steps = 1000 + +set Number of checkpoints = 0 diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/postprocess.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/postprocess.cc new file mode 100644 index 000000000..041e61e64 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1a/postprocess.cc @@ -0,0 +1,77 @@ +// ============================================================================================= +// loadPostProcessorVariableAttributes: Set the attributes of the postprocessing +// variables +// ============================================================================================= +// This function is analogous to 'loadVariableAttributes' in 'equations.h', but +// for the postprocessing expressions. It sets the attributes for each +// postprocessing expression, including its name, whether it is a vector or +// scalar (only scalars are supported at present), its dependencies on other +// variables and their derivatives, and whether to calculate an integral of the +// postprocessed quantity over the entire domain. Note: this function is not a +// member of customPDE. + +void +variableAttributeLoader::loadPostProcessorVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "f_tot"); + set_variable_type(0, SCALAR); + + set_dependencies_value_term_RHS(0, "c, grad(c)"); + set_dependencies_gradient_term_RHS(0, ""); + + set_output_integral(0, true); +} + +// ============================================================================================= +// postProcessedFields: Set the postprocessing expressions +// ============================================================================================= +// This function is analogous to 'explicitEquationRHS' and +// 'nonExplicitEquationRHS' in equations.h. It takes in "variable_list" and +// "q_point_loc" as inputs and outputs two terms in the expression for the +// postprocessing variable -- one proportional to the test function and one +// proportional to the gradient of the test function. The index for each +// variable in this list corresponds to the index given at the top of this file +// (for submitting the terms) and the index in 'equations.h' for assigning the +// values/derivatives of the primary variables. + +template +void +customPDE::postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // The concentration and its derivatives + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // --- Setting the expressions for the terms in the postprocessing expressions + // --- + + // The homogenous free energy + scalarvalueType f_chem = rho_s * dealii::Utilities::fixed_power<2>(c - c_alpha) * + dealii::Utilities::fixed_power<2>(c - c_beta); + + // The gradient free energy + scalarvalueType f_grad = constV(0.0); + + for (int i = 0; i < dim; i++) + { + for (int j = 0; j < dim; j++) + { + f_grad += constV(0.5) * kappa * cx[i] * cx[j]; + } + } + + // The total free energy + scalarvalueType f_tot = f_chem + f_grad; + + // --- Submitting the terms for the postprocessing expressions --- + pp_variable_list.set_scalar_value_term_RHS(0, f_tot); +} diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/CMakeLists.txt b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/CMakeLists.txt new file mode 100644 index 000000000..30e430a8f --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/CMakeLists.txt @@ -0,0 +1,68 @@ +## +# CMake script for the PRISMS-PF applications: +## + +cmake_minimum_required(VERSION 3.1.0) +project(myapp) + +# Find deal.II installation +find_package(deal.II 9.2.0 QUIET REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) + +# Check to make sure deal.II is configured with p4est +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() + +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + +# Set up the debug, release, and run targets +add_custom_target(debug + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) +add_custom_target(release + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) +add_custom_target(run COMMAND main + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" + ) + +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") + add_definitions(-DPOSTPROCESS_FILE_EXISTS) +endif() +if(EXISTS "nucleation.cc") + add_definitions(-DNUCLEATION_FILE_EXISTS) +endif() + +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../../src) +include_directories(${CMAKE_SOURCE_DIR}) + +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../../main.cc") + +# Add main.cc for executable target +add_executable(main ${MAIN}) + +# deal.II linker +DEAL_II_SETUP_TARGET(main) + +# Link libraries for the build type +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +else() + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) +endif() diff --git a/applications/CHiMaD_benchmark1a/ICs_and_BCs.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/ICs_and_BCs.cc similarity index 61% rename from applications/CHiMaD_benchmark1a/ICs_and_BCs.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/ICs_and_BCs.cc index b282b4287..05b0d2774 100644 --- a/applications/CHiMaD_benchmark1a/ICs_and_BCs.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/ICs_and_BCs.cc @@ -2,12 +2,14 @@ // FUNCTION FOR INITIAL CONDITIONS // =========================================================================== +#include + template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -20,13 +22,14 @@ customPDE::setInitialCondition(const dealii::Point &p, { double epsilon = 0.01; double c0 = 0.5; - double dx = userInputs.domain_size[0] / ((double) userInputs.subdivisions[0]) / - std::pow(2.0, userInputs.refine_factor); + double x = p[0]; + double y = p[1]; + scalar_IC = - c0 + epsilon * (std::cos(0.105 * p[0]) * std::cos(0.11 * p[1]) + - std::pow(std::cos(0.13 * p[0]) * std::cos(0.087 * p[1]), 2.0) + - std::cos(0.025 * p[0] - 0.15 * p[1]) * - std::cos(0.07 * p[0] - 0.02 * p[1])); + c0 + epsilon * (std::cos(0.105 * x) * std::cos(0.11 * y) + + dealii::Utilities::fixed_power<2>(std::cos(0.13 * x) * + std::cos(0.087 * y)) + + std::cos(0.025 * x - 0.15 * y) * std::cos(0.07 * x - 0.02 * y)); } else { @@ -42,12 +45,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/customPDE.h b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/customPDE.h new file mode 100644 index 000000000..c7bebfc80 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/customPDE.h @@ -0,0 +1,96 @@ +#include "matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + scalarvalueType c_alpha = constV(0.3); + scalarvalueType c_beta = constV(0.7); + scalarvalueType rho_s = constV(5.0); + scalarvalueType kappa = constV(2.0); + scalarvalueType M = constV(5.0); + + // ================================================================ +}; diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/equations.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/equations.cc new file mode 100644 index 000000000..2d2595da7 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/equations.cc @@ -0,0 +1,139 @@ +// ================================================================================= +// Set the attributes of the primary field variables +// ================================================================================= +// This function sets attributes for each variable/equation in the app. The +// attributes are set via standardized function calls. The first parameter for +// each function call is the variable index (starting at zero). The first set of +// variable/equation attributes are the variable name (any string), the variable +// type (SCALAR/VECTOR), and the equation type (EXPLICIT_TIME_DEPENDENT/ +// TIME_INDEPENDENT/AUXILIARY). The next set of attributes describe the +// dependencies for the governing equation on the values and derivatives of the +// other variables for the value term and gradient term of the RHS and the LHS. +// The final pair of attributes determine whether a variable represents a field +// that can nucleate and whether the value of the field is needed for nucleation +// rate calculations. + +void +variableAttributeLoader::loadVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "c"); + set_variable_type(0, SCALAR); + set_variable_equation_type(0, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(0, "c"); + set_dependencies_gradient_term_RHS(0, "grad(mu)"); + + // Variable 1 + set_variable_name(1, "mu"); + set_variable_type(1, SCALAR); + set_variable_equation_type(1, AUXILIARY); + + set_dependencies_value_term_RHS(1, "c"); + set_dependencies_gradient_term_RHS(1, "grad(c)"); +} + +// ============================================================================================= +// explicitEquationRHS (needed only if one or more equation is explict time +// dependent) +// ============================================================================================= +// This function calculates the right-hand-side of the explicit time-dependent +// equations for each variable. It takes "variable_list" as an input, which is a +// list of the value and derivatives of each of the variables at a specific +// quadrature point. The (x,y,z) location of that quadrature point is given by +// "q_point_loc". The function outputs two terms to variable_list -- one +// proportional to the test function and one proportional to the gradient of the +// test function. The index for each variable in this list corresponds to the +// index given at the top of this file. + +template +void +customPDE::explicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // The concentration and its derivatives + scalarvalueType c = variable_list.get_scalar_value(0); + + // The chemical potential and its derivatives + scalargradType mux = variable_list.get_scalar_gradient(1); + + // --- Setting the expressions for the terms in the governing equations --- + + scalarvalueType eq_c = c; + scalargradType eqx_c = constV(-userInputs.dtValue) * M * mux; + + // --- Submitting the terms for the governing equations --- + + // Terms for the equation to evolve the concentration + variable_list.set_scalar_value_term_RHS(0, eq_c); + variable_list.set_scalar_gradient_term_RHS(0, eqx_c); +} + +// ============================================================================================= +// nonExplicitEquationRHS (needed only if one or more equation is time +// independent or auxiliary) +// ============================================================================================= +// This function calculates the right-hand-side of all of the equations that are +// not explicit time-dependent equations. It takes "variable_list" as an input, +// which is a list of the value and derivatives of each of the variables at a +// specific quadrature point. The (x,y,z) location of that quadrature point is +// given by "q_point_loc". The function outputs two terms to variable_list -- +// one proportional to the test function and one proportional to the gradient of +// the test function. The index for each variable in this list corresponds to +// the index given at the top of this file. + +template +void +customPDE::nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // --- Setting the expressions for the terms in the governing equations --- + + // The free energy and its derivative + scalarvalueType fcV = constV(2.0) * rho_s * + ((c - c_alpha) * dealii::Utilities::fixed_power<2>(c - c_beta) + + (c - c_beta) * dealii::Utilities::fixed_power<2>(c - c_alpha)); + + // The terms for the governing equations + scalarvalueType eq_mu = fcV; + scalargradType eqx_mu = kappa * cx; + + // --- Submitting the terms for the governing equations --- + + variable_list.set_scalar_value_term_RHS(1, eq_mu); + variable_list.set_scalar_gradient_term_RHS(1, eqx_mu); +} + +// ============================================================================================= +// equationLHS (needed only if at least one equation is time independent) +// ============================================================================================= +// This function calculates the left-hand-side of time-independent equations. It +// takes "variable_list" as an input, which is a list of the value and +// derivatives of each of the variables at a specific quadrature point. The +// (x,y,z) location of that quadrature point is given by "q_point_loc". The +// function outputs two terms to variable_list -- one proportional to the test +// function and one proportional to the gradient of the test function -- for the +// left-hand-side of the equation. The index for each variable in this list +// corresponds to the index given at the top of this file. If there are multiple +// elliptic equations, conditional statements should be sed to ensure that the +// correct residual is being submitted. The index of the field being solved can +// be accessed by "this->currentFieldIndex". + +template +void +customPDE::equationLHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{} diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/parameters.prm b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/parameters.prm new file mode 100644 index 000000000..27da9d047 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/parameters.prm @@ -0,0 +1,52 @@ +# ================================================================================= +# Set the number of dimensions (2 or 3 for a 2D or 3D calculation) +# ================================================================================= +set Number of dimensions = 2 + +# ================================================================================= +# Set the length of the domain in all three dimensions +# (Domain size Z ignored in 2D) +# ================================================================================= + +set Domain size X = 200 +set Domain size Y = 200 +set Domain size Z = 200 + +# ================================================================================= +# Set the element parameters +# ================================================================================= + +set Subdivisions X = 1 +set Subdivisions Y = 1 +set Subdivisions Z = 1 + +set Refine factor = 7 + +set Element degree = 1 + +# ================================================================================= +# Set the time step parameters +# ================================================================================= + +set Time step = 1.0e-2 + +set Simulation end time = 1000 + +# ================================================================================= +# Set the boundary conditions +# ================================================================================= + +set Boundary condition for variable c = NATURAL +set Boundary condition for variable mu = NATURAL + +# ================================================================================= +# Set the output parameters +# ================================================================================= + +set Output condition = EQUAL_SPACING + +set Number of outputs = 1 + +set Skip print steps = 1000 + +set Number of checkpoints = 0 diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/postprocess.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/postprocess.cc new file mode 100644 index 000000000..041e61e64 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1b/postprocess.cc @@ -0,0 +1,77 @@ +// ============================================================================================= +// loadPostProcessorVariableAttributes: Set the attributes of the postprocessing +// variables +// ============================================================================================= +// This function is analogous to 'loadVariableAttributes' in 'equations.h', but +// for the postprocessing expressions. It sets the attributes for each +// postprocessing expression, including its name, whether it is a vector or +// scalar (only scalars are supported at present), its dependencies on other +// variables and their derivatives, and whether to calculate an integral of the +// postprocessed quantity over the entire domain. Note: this function is not a +// member of customPDE. + +void +variableAttributeLoader::loadPostProcessorVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "f_tot"); + set_variable_type(0, SCALAR); + + set_dependencies_value_term_RHS(0, "c, grad(c)"); + set_dependencies_gradient_term_RHS(0, ""); + + set_output_integral(0, true); +} + +// ============================================================================================= +// postProcessedFields: Set the postprocessing expressions +// ============================================================================================= +// This function is analogous to 'explicitEquationRHS' and +// 'nonExplicitEquationRHS' in equations.h. It takes in "variable_list" and +// "q_point_loc" as inputs and outputs two terms in the expression for the +// postprocessing variable -- one proportional to the test function and one +// proportional to the gradient of the test function. The index for each +// variable in this list corresponds to the index given at the top of this file +// (for submitting the terms) and the index in 'equations.h' for assigning the +// values/derivatives of the primary variables. + +template +void +customPDE::postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // The concentration and its derivatives + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // --- Setting the expressions for the terms in the postprocessing expressions + // --- + + // The homogenous free energy + scalarvalueType f_chem = rho_s * dealii::Utilities::fixed_power<2>(c - c_alpha) * + dealii::Utilities::fixed_power<2>(c - c_beta); + + // The gradient free energy + scalarvalueType f_grad = constV(0.0); + + for (int i = 0; i < dim; i++) + { + for (int j = 0; j < dim; j++) + { + f_grad += constV(0.5) * kappa * cx[i] * cx[j]; + } + } + + // The total free energy + scalarvalueType f_tot = f_chem + f_grad; + + // --- Submitting the terms for the postprocessing expressions --- + pp_variable_list.set_scalar_value_term_RHS(0, f_tot); +} diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/CMakeLists.txt b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/CMakeLists.txt new file mode 100644 index 000000000..30e430a8f --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/CMakeLists.txt @@ -0,0 +1,68 @@ +## +# CMake script for the PRISMS-PF applications: +## + +cmake_minimum_required(VERSION 3.1.0) +project(myapp) + +# Find deal.II installation +find_package(deal.II 9.2.0 QUIET REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) + +# Check to make sure deal.II is configured with p4est +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() + +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + +# Set up the debug, release, and run targets +add_custom_target(debug + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) +add_custom_target(release + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) +add_custom_target(run COMMAND main + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" + ) + +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") + add_definitions(-DPOSTPROCESS_FILE_EXISTS) +endif() +if(EXISTS "nucleation.cc") + add_definitions(-DNUCLEATION_FILE_EXISTS) +endif() + +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../../src) +include_directories(${CMAKE_SOURCE_DIR}) + +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../../main.cc") + +# Add main.cc for executable target +add_executable(main ${MAIN}) + +# deal.II linker +DEAL_II_SETUP_TARGET(main) + +# Link libraries for the build type +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +else() + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) +endif() diff --git a/applications/steadyStateAllenCahn/ICs_and_BCs.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/ICs_and_BCs.cc similarity index 59% rename from applications/steadyStateAllenCahn/ICs_and_BCs.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/ICs_and_BCs.cc index 9cab7ff3a..05b0d2774 100644 --- a/applications/steadyStateAllenCahn/ICs_and_BCs.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/ICs_and_BCs.cc @@ -2,12 +2,14 @@ // FUNCTION FOR INITIAL CONDITIONS // =========================================================================== +#include + template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -18,12 +20,23 @@ customPDE::setInitialCondition(const dealii::Point &p, if (index == 0) { - scalar_IC = 0.5 * (1.0 - std::tanh((p[0] - 50.0) / 1.5)); + double epsilon = 0.01; + double c0 = 0.5; + double x = p[0]; + double y = p[1]; + + scalar_IC = + c0 + epsilon * (std::cos(0.105 * x) * std::cos(0.11 * y) + + dealii::Utilities::fixed_power<2>(std::cos(0.13 * x) * + std::cos(0.087 * y)) + + std::cos(0.025 * x - 0.15 * y) * std::cos(0.07 * x - 0.02 * y)); } else { - scalar_IC = p[0] / 200.0; + scalar_IC = 0.0; } + + // --------------------------------------------------------------------- } // =========================================================================== @@ -32,12 +45,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/customPDE.h b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/customPDE.h new file mode 100644 index 000000000..43bc11487 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/customPDE.h @@ -0,0 +1,184 @@ +#include + +#include "matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + void + makeTriangulation(parallel::distributed::Triangulation &) const override; + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + scalarvalueType c_alpha = constV(0.3); + scalarvalueType c_beta = constV(0.7); + scalarvalueType rho_s = constV(5.0); + scalarvalueType kappa = constV(2.0); + scalarvalueType M = constV(5.0); + + // ================================================================ +}; + +#include + +template +void +customPDE::makeTriangulation( + parallel::distributed::Triangulation &tria) const +{ + parallel::distributed::Triangulation tria_horizontal_box(MPI_COMM_WORLD); + parallel::distributed::Triangulation tria_vertical_box(MPI_COMM_WORLD); + + // Box dimensions + double a = 100; + double c = 20; + + // Check that dimensions match the benchmark + AssertThrow(dim == 2, ExcMessage("CHiMaD Benchmark 1c should only be run in 2D.")); + + // Overriding user specified subdivisions. This way we don't have to move points on the + // mesh to match the two triangulations. + AssertThrow(userInputs.subdivisions[0] == userInputs.subdivisions[1], + ExcMessage("Subdivisions are automatically determined in this " + "application. Please make sure the x and y subdivisions match " + "in order to change the refinement.")); + std::vector horizontal_subdivisions(dim, userInputs.subdivisions[0]); + std::vector vertical_subdivisions(dim, userInputs.subdivisions[0]); + for (unsigned int i = 0; i < dim; i++) + { + if (i == 0) + { + horizontal_subdivisions[i] = 5 * userInputs.subdivisions[0]; + } + else if (i == 1) + { + vertical_subdivisions[i] = 5 * userInputs.subdivisions[0]; + } + } + + // Create bounding points for each part of the triangulation + Point horizontal_origin; + Point horizontal_corner; + Point vertical_origin; + Point vertical_corner; + + if (dim == 2) + { + horizontal_origin = Point(0.0, a); + horizontal_corner = Point(a, a + c); + vertical_origin = Point(0.5 * (a - c), 0.0); + vertical_corner = Point(0.5 * (a + c), a); + } + + GridGenerator::subdivided_hyper_rectangle(tria_horizontal_box, + horizontal_subdivisions, + horizontal_origin, + horizontal_corner); + GridGenerator::subdivided_hyper_rectangle(tria_vertical_box, + vertical_subdivisions, + vertical_origin, + vertical_corner); + + // Merge the two triangulations + GridGenerator::merge_triangulations(tria_horizontal_box, tria_vertical_box, tria); + + // Mark the boundaries + for (const auto &cell : tria.active_cell_iterators()) + { + // Mark all of the faces on the boundary with a boundary id of 0. This reduces the + // complexity of the code at the cost of flexibility in boundary conditions. For the + // benchmark case, we don't care about flexibility. If you plan to use this code to + // create your own triangulation, modify this section accordingly. + for (unsigned int face_number = 0; face_number < GeometryInfo::faces_per_cell; + ++face_number) + { + const auto &face = cell->face(face_number); + + if (face->at_boundary()) + { + face->set_boundary_id(0); + } + } + } +} \ No newline at end of file diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/equations.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/equations.cc new file mode 100644 index 000000000..2d2595da7 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/equations.cc @@ -0,0 +1,139 @@ +// ================================================================================= +// Set the attributes of the primary field variables +// ================================================================================= +// This function sets attributes for each variable/equation in the app. The +// attributes are set via standardized function calls. The first parameter for +// each function call is the variable index (starting at zero). The first set of +// variable/equation attributes are the variable name (any string), the variable +// type (SCALAR/VECTOR), and the equation type (EXPLICIT_TIME_DEPENDENT/ +// TIME_INDEPENDENT/AUXILIARY). The next set of attributes describe the +// dependencies for the governing equation on the values and derivatives of the +// other variables for the value term and gradient term of the RHS and the LHS. +// The final pair of attributes determine whether a variable represents a field +// that can nucleate and whether the value of the field is needed for nucleation +// rate calculations. + +void +variableAttributeLoader::loadVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "c"); + set_variable_type(0, SCALAR); + set_variable_equation_type(0, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(0, "c"); + set_dependencies_gradient_term_RHS(0, "grad(mu)"); + + // Variable 1 + set_variable_name(1, "mu"); + set_variable_type(1, SCALAR); + set_variable_equation_type(1, AUXILIARY); + + set_dependencies_value_term_RHS(1, "c"); + set_dependencies_gradient_term_RHS(1, "grad(c)"); +} + +// ============================================================================================= +// explicitEquationRHS (needed only if one or more equation is explict time +// dependent) +// ============================================================================================= +// This function calculates the right-hand-side of the explicit time-dependent +// equations for each variable. It takes "variable_list" as an input, which is a +// list of the value and derivatives of each of the variables at a specific +// quadrature point. The (x,y,z) location of that quadrature point is given by +// "q_point_loc". The function outputs two terms to variable_list -- one +// proportional to the test function and one proportional to the gradient of the +// test function. The index for each variable in this list corresponds to the +// index given at the top of this file. + +template +void +customPDE::explicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // The concentration and its derivatives + scalarvalueType c = variable_list.get_scalar_value(0); + + // The chemical potential and its derivatives + scalargradType mux = variable_list.get_scalar_gradient(1); + + // --- Setting the expressions for the terms in the governing equations --- + + scalarvalueType eq_c = c; + scalargradType eqx_c = constV(-userInputs.dtValue) * M * mux; + + // --- Submitting the terms for the governing equations --- + + // Terms for the equation to evolve the concentration + variable_list.set_scalar_value_term_RHS(0, eq_c); + variable_list.set_scalar_gradient_term_RHS(0, eqx_c); +} + +// ============================================================================================= +// nonExplicitEquationRHS (needed only if one or more equation is time +// independent or auxiliary) +// ============================================================================================= +// This function calculates the right-hand-side of all of the equations that are +// not explicit time-dependent equations. It takes "variable_list" as an input, +// which is a list of the value and derivatives of each of the variables at a +// specific quadrature point. The (x,y,z) location of that quadrature point is +// given by "q_point_loc". The function outputs two terms to variable_list -- +// one proportional to the test function and one proportional to the gradient of +// the test function. The index for each variable in this list corresponds to +// the index given at the top of this file. + +template +void +customPDE::nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // --- Setting the expressions for the terms in the governing equations --- + + // The free energy and its derivative + scalarvalueType fcV = constV(2.0) * rho_s * + ((c - c_alpha) * dealii::Utilities::fixed_power<2>(c - c_beta) + + (c - c_beta) * dealii::Utilities::fixed_power<2>(c - c_alpha)); + + // The terms for the governing equations + scalarvalueType eq_mu = fcV; + scalargradType eqx_mu = kappa * cx; + + // --- Submitting the terms for the governing equations --- + + variable_list.set_scalar_value_term_RHS(1, eq_mu); + variable_list.set_scalar_gradient_term_RHS(1, eqx_mu); +} + +// ============================================================================================= +// equationLHS (needed only if at least one equation is time independent) +// ============================================================================================= +// This function calculates the left-hand-side of time-independent equations. It +// takes "variable_list" as an input, which is a list of the value and +// derivatives of each of the variables at a specific quadrature point. The +// (x,y,z) location of that quadrature point is given by "q_point_loc". The +// function outputs two terms to variable_list -- one proportional to the test +// function and one proportional to the gradient of the test function -- for the +// left-hand-side of the equation. The index for each variable in this list +// corresponds to the index given at the top of this file. If there are multiple +// elliptic equations, conditional statements should be sed to ensure that the +// correct residual is being submitted. The index of the field being solved can +// be accessed by "this->currentFieldIndex". + +template +void +customPDE::equationLHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{} diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/parameters.prm b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/parameters.prm new file mode 100644 index 000000000..dbcf0c0a8 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/parameters.prm @@ -0,0 +1,52 @@ +# ================================================================================= +# Set the number of dimensions (2 or 3 for a 2D or 3D calculation) +# ================================================================================= +set Number of dimensions = 2 + +# ================================================================================= +# Set the length of the domain in all three dimensions +# (Domain size Z ignored in 2D) +# ================================================================================= + +set Domain size X = 200 +set Domain size Y = 200 +set Domain size Z = 200 + +# ================================================================================= +# Set the element parameters +# ================================================================================= + +set Subdivisions X = 3 +set Subdivisions Y = 3 +set Subdivisions Z = 3 + +set Refine factor = 2 + +set Element degree = 1 + +# ================================================================================= +# Set the time step parameters +# ================================================================================= + +set Time step = 1.0e-2 + +set Simulation end time = 1000 + +# ================================================================================= +# Set the boundary conditions +# ================================================================================= + +set Boundary condition for variable c = NATURAL +set Boundary condition for variable mu = NATURAL + +# ================================================================================= +# Set the output parameters +# ================================================================================= + +set Output condition = EQUAL_SPACING + +set Number of outputs = 1 + +set Skip print steps = 1000 + +set Number of checkpoints = 0 diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/postprocess.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/postprocess.cc new file mode 100644 index 000000000..041e61e64 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark1c/postprocess.cc @@ -0,0 +1,77 @@ +// ============================================================================================= +// loadPostProcessorVariableAttributes: Set the attributes of the postprocessing +// variables +// ============================================================================================= +// This function is analogous to 'loadVariableAttributes' in 'equations.h', but +// for the postprocessing expressions. It sets the attributes for each +// postprocessing expression, including its name, whether it is a vector or +// scalar (only scalars are supported at present), its dependencies on other +// variables and their derivatives, and whether to calculate an integral of the +// postprocessed quantity over the entire domain. Note: this function is not a +// member of customPDE. + +void +variableAttributeLoader::loadPostProcessorVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "f_tot"); + set_variable_type(0, SCALAR); + + set_dependencies_value_term_RHS(0, "c, grad(c)"); + set_dependencies_gradient_term_RHS(0, ""); + + set_output_integral(0, true); +} + +// ============================================================================================= +// postProcessedFields: Set the postprocessing expressions +// ============================================================================================= +// This function is analogous to 'explicitEquationRHS' and +// 'nonExplicitEquationRHS' in equations.h. It takes in "variable_list" and +// "q_point_loc" as inputs and outputs two terms in the expression for the +// postprocessing variable -- one proportional to the test function and one +// proportional to the gradient of the test function. The index for each +// variable in this list corresponds to the index given at the top of this file +// (for submitting the terms) and the index in 'equations.h' for assigning the +// values/derivatives of the primary variables. + +template +void +customPDE::postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // The concentration and its derivatives + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // --- Setting the expressions for the terms in the postprocessing expressions + // --- + + // The homogenous free energy + scalarvalueType f_chem = rho_s * dealii::Utilities::fixed_power<2>(c - c_alpha) * + dealii::Utilities::fixed_power<2>(c - c_beta); + + // The gradient free energy + scalarvalueType f_grad = constV(0.0); + + for (int i = 0; i < dim; i++) + { + for (int j = 0; j < dim; j++) + { + f_grad += constV(0.5) * kappa * cx[i] * cx[j]; + } + } + + // The total free energy + scalarvalueType f_tot = f_chem + f_grad; + + // --- Submitting the terms for the postprocessing expressions --- + pp_variable_list.set_scalar_value_term_RHS(0, f_tot); +} diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/CMakeLists.txt b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/CMakeLists.txt new file mode 100644 index 000000000..30e430a8f --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/CMakeLists.txt @@ -0,0 +1,68 @@ +## +# CMake script for the PRISMS-PF applications: +## + +cmake_minimum_required(VERSION 3.1.0) +project(myapp) + +# Find deal.II installation +find_package(deal.II 9.2.0 QUIET REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) + +# Check to make sure deal.II is configured with p4est +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() + +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + +# Set up the debug, release, and run targets +add_custom_target(debug + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) +add_custom_target(release + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) +add_custom_target(run COMMAND main + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" + ) + +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") + add_definitions(-DPOSTPROCESS_FILE_EXISTS) +endif() +if(EXISTS "nucleation.cc") + add_definitions(-DNUCLEATION_FILE_EXISTS) +endif() + +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../../src) +include_directories(${CMAKE_SOURCE_DIR}) + +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../../main.cc") + +# Add main.cc for executable target +add_executable(main ${MAIN}) + +# deal.II linker +DEAL_II_SETUP_TARGET(main) + +# Link libraries for the build type +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +else() + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) +endif() diff --git a/applications/CHiMaD_benchmark2a/ICs_and_BCs.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/ICs_and_BCs.cc similarity index 78% rename from applications/CHiMaD_benchmark2a/ICs_and_BCs.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/ICs_and_BCs.cc index d518d7a29..dd9c52c97 100644 --- a/applications/CHiMaD_benchmark2a/ICs_and_BCs.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -22,8 +22,6 @@ customPDE::setInitialCondition(const dealii::Point &p, double epsilon_n = 0.1; double psi = 1.5; - double dx = userInputs.domain_size[0] / ((double) userInputs.subdivisions[0]) / - std::pow(2.0, userInputs.refine_factor); double x = p[0]; double y = p[1]; @@ -83,12 +81,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/customPDE.h b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/customPDE.h new file mode 100644 index 000000000..35efe0f35 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/customPDE.h @@ -0,0 +1,97 @@ +#include "matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double McV = userInputs.get_model_constant_double("McV"); + double MnV = userInputs.get_model_constant_double("MnV"); + double KcV = userInputs.get_model_constant_double("KcV"); + double KnV = userInputs.get_model_constant_double("KnV"); + double wV = userInputs.get_model_constant_double("wV"); + double alpha = userInputs.get_model_constant_double("alpha"); + + // ================================================================ +}; diff --git a/applications/CHiMaD_benchmark2a/equations.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/equations.cc similarity index 84% rename from applications/CHiMaD_benchmark2a/equations.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/equations.cc index 8b833a58f..6d5c200b4 100644 --- a/applications/CHiMaD_benchmark2a/equations.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/equations.cc @@ -81,8 +81,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -105,19 +106,10 @@ customPDE::explicitEquationRHS( // --- Setting the expressions for the terms in the governing equations --- // Free energy for each phase and their first and second derivatives - scalarvalueType faV = (constV(2.0) * (c - constV(0.3)) * (c - constV(0.3))); - scalarvalueType facV = (constV(4.0) * (c - constV(0.3))); - scalarvalueType faccV = (constV(4.0)); - scalarvalueType fbV = (constV(2.0) * (c - constV(0.7)) * (c - constV(0.7))); - scalarvalueType fbcV = (constV(4.0) * (c - constV(0.7))); - scalarvalueType fbccV = (constV(4.0)); + scalarvalueType faV = (constV(2.0) * (c - constV(0.3)) * (c - constV(0.3))); + scalarvalueType fbV = (constV(2.0) * (c - constV(0.7)) * (c - constV(0.7))); // Interpolation function and its derivatives - scalarvalueType hV = - (n1 * n1 * n1 * (constV(6.0) * n1 * n1 - constV(15.0) * n1 + constV(10.0)) + - n2 * n2 * n2 * (constV(6.0) * n2 * n2 - constV(15.0) * n2 + constV(10.0)) + - n3 * n3 * n3 * (constV(6.0) * n3 * n3 - constV(15.0) * n3 + constV(10.0)) + - n4 * n4 * n4 * (constV(6.0) * n4 * n4 - constV(15.0) * n4 + constV(10.0))); scalarvalueType hn1V = (n1 * n1 * (constV(30.0) * n1 * n1 - constV(60.0) * n1 + constV(30.0))); scalarvalueType hn2V = @@ -127,19 +119,6 @@ customPDE::explicitEquationRHS( scalarvalueType hn4V = (n4 * n4 * (constV(30.0) * n4 * n4 - constV(60.0) * n4 + constV(30.0))); - // Combined double-well and interaction functions (function g) and its - // derivatives Double-well part - scalarvalueType gdwV = (n1 * n1 * (constV(1.0) - n1) * (constV(1.0) - n1) + - n2 * n2 * (constV(1.0) - n2) * (constV(1.0) - n2) + - n3 * n3 * (constV(1.0) - n3) * (constV(1.0) - n3) + - n4 * n4 * (constV(1.0) - n4) * (constV(1.0) - n4)); - // Interaction part - scalarvalueType gintV = - (alpha * (n1 * n1 * n2 * n2 + n1 * n1 * n3 * n3 + n1 * n1 * n4 * n4 + - n2 * n2 * n3 * n3 + n2 * n2 * n4 * n4 + n3 * n3 * n4 * n4)); - // Combined function (g) - // scalarvalueType gV = ( gdwV + gintV ); // Not actually needed - // Derivatives scalarvalueType dgn1V = (constV(2.0) * n1 * (constV(1.0) - n1) * (constV(1.0) - constV(2.0) * n1) + @@ -204,8 +183,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -259,6 +239,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/CHiMaD_benchmark2a/formulation_coupledCHAC.pdf b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/formulation_coupledCHAC.pdf similarity index 100% rename from applications/CHiMaD_benchmark2a/formulation_coupledCHAC.pdf rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/formulation_coupledCHAC.pdf diff --git a/applications/CHiMaD_benchmark2a/parameters.prm b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/parameters.prm similarity index 100% rename from applications/CHiMaD_benchmark2a/parameters.prm rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/parameters.prm diff --git a/applications/CHiMaD_benchmark2a/postprocess.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/postprocess.cc similarity index 93% rename from applications/CHiMaD_benchmark2a/postprocess.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/postprocess.cc index 6d92b1bc9..bc3c3f833 100644 --- a/applications/CHiMaD_benchmark2a/postprocess.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/postprocess.cc @@ -40,9 +40,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/CHiMaD_benchmark2a/tex_files/coupledCHAC.tex b/applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/tex_files/coupledCHAC.tex similarity index 100% rename from applications/CHiMaD_benchmark2a/tex_files/coupledCHAC.tex rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark2a/tex_files/coupledCHAC.tex diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/CMakeLists.txt b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/CMakeLists.txt new file mode 100755 index 000000000..30e430a8f --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/CMakeLists.txt @@ -0,0 +1,68 @@ +## +# CMake script for the PRISMS-PF applications: +## + +cmake_minimum_required(VERSION 3.1.0) +project(myapp) + +# Find deal.II installation +find_package(deal.II 9.2.0 QUIET REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) + +# Check to make sure deal.II is configured with p4est +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() + +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + +# Set up the debug, release, and run targets +add_custom_target(debug + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) +add_custom_target(release + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) +add_custom_target(run COMMAND main + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" + ) + +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") + add_definitions(-DPOSTPROCESS_FILE_EXISTS) +endif() +if(EXISTS "nucleation.cc") + add_definitions(-DNUCLEATION_FILE_EXISTS) +endif() + +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../../src) +include_directories(${CMAKE_SOURCE_DIR}) + +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../../main.cc") + +# Add main.cc for executable target +add_executable(main ${MAIN}) + +# deal.II linker +DEAL_II_SETUP_TARGET(main) + +# Link libraries for the build type +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +else() + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) +endif() diff --git a/applications/CHiMaD_benchmark3/ICs_and_BCs.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/ICs_and_BCs.cc old mode 100644 new mode 100755 similarity index 77% rename from applications/CHiMaD_benchmark3/ICs_and_BCs.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/ICs_and_BCs.cc index 49231997b..15bd1ab6e --- a/applications/CHiMaD_benchmark3/ICs_and_BCs.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -59,12 +59,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/customPDE.h b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/customPDE.h new file mode 100755 index 000000000..7193d7a02 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/customPDE.h @@ -0,0 +1,97 @@ +#include "matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double D = userInputs.get_model_constant_double("D"); + double W0 = userInputs.get_model_constant_double("W0"); + double delta = userInputs.get_model_constant_double("delta"); + double epsilonM = userInputs.get_model_constant_double("epsilonM"); + double theta0 = userInputs.get_model_constant_double("theta0"); + double mult = userInputs.get_model_constant_double("mult"); + + // ================================================================ +}; diff --git a/applications/CHiMaD_benchmark3/dendriticSolidification.pdf b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/dendriticSolidification.pdf old mode 100644 new mode 100755 similarity index 100% rename from applications/CHiMaD_benchmark3/dendriticSolidification.pdf rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/dendriticSolidification.pdf diff --git a/applications/CHiMaD_benchmark3/equations.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/equations.cc old mode 100644 new mode 100755 similarity index 91% rename from applications/CHiMaD_benchmark3/equations.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/equations.cc index c52d5e15f..37f6b39f2 --- a/applications/CHiMaD_benchmark3/equations.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/equations.cc @@ -57,8 +57,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -117,8 +118,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -152,7 +154,6 @@ customPDE::nonExplicitEquationRHS( scalarvalueType W_theta = constV(-W0) * (constV(epsilonM) * constV(mult) * std::sin(constV(mult) * (theta - constV(theta0)))); - scalarvalueType tau = W / constV(W0); // The anisotropy term that enters in to the equation for mu scalargradType aniso; @@ -187,6 +188,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/CHiMaD_benchmark3/getDendriteDim.py b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/getDendriteDim.py old mode 100644 new mode 100755 similarity index 100% rename from applications/CHiMaD_benchmark3/getDendriteDim.py rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/getDendriteDim.py diff --git a/applications/CHiMaD_benchmark3/parameters.prm b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/parameters.prm old mode 100644 new mode 100755 similarity index 100% rename from applications/CHiMaD_benchmark3/parameters.prm rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/parameters.prm diff --git a/applications/CHiMaD_benchmark3/postprocess.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/postprocess.cc old mode 100644 new mode 100755 similarity index 90% rename from applications/CHiMaD_benchmark3/postprocess.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/postprocess.cc index d11cf933e..d2df2a25f --- a/applications/CHiMaD_benchmark3/postprocess.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/CHiMaD_benchmark3/tex_files/dendriticSolidification.tex b/applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/tex_files/dendriticSolidification.tex old mode 100644 new mode 100755 similarity index 100% rename from applications/CHiMaD_benchmark3/tex_files/dendriticSolidification.tex rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark3a/tex_files/dendriticSolidification.tex diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/CMakeLists.txt b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/CMakeLists.txt new file mode 100644 index 000000000..30e430a8f --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/CMakeLists.txt @@ -0,0 +1,68 @@ +## +# CMake script for the PRISMS-PF applications: +## + +cmake_minimum_required(VERSION 3.1.0) +project(myapp) + +# Find deal.II installation +find_package(deal.II 9.2.0 QUIET REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) + +# Check to make sure deal.II is configured with p4est +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() + +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + +# Set up the debug, release, and run targets +add_custom_target(debug + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) +add_custom_target(release + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) +add_custom_target(run COMMAND main + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" + ) + +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") + add_definitions(-DPOSTPROCESS_FILE_EXISTS) +endif() +if(EXISTS "nucleation.cc") + add_definitions(-DNUCLEATION_FILE_EXISTS) +endif() + +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../../src) +include_directories(${CMAKE_SOURCE_DIR}) + +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../../main.cc") + +# Add main.cc for executable target +add_executable(main ${MAIN}) + +# deal.II linker +DEAL_II_SETUP_TARGET(main) + +# Link libraries for the build type +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +else() + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) +endif() diff --git a/applications/CHiMaD_benchmark6b/ICs_and_BCs.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/ICs_and_BCs.cc similarity index 76% rename from applications/CHiMaD_benchmark6b/ICs_and_BCs.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/ICs_and_BCs.cc index 00ff866b9..8617db09c 100644 --- a/applications/CHiMaD_benchmark6b/ICs_and_BCs.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -48,12 +48,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE @@ -71,7 +72,6 @@ customPDE::setNonUniformDirichletBCs(const dealii::Point &p, { if (direction == 1) { - double x = p[0]; double y = p[1]; scalar_BC = std::sin(y / 7.0); } diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/customPDE.h b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/customPDE.h new file mode 100644 index 000000000..533bb88c0 --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/customPDE.h @@ -0,0 +1,98 @@ +#include "matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double McV = userInputs.get_model_constant_double("McV"); + double KcV = userInputs.get_model_constant_double("KcV"); + double rho = userInputs.get_model_constant_double("rho"); + double c_alpha = userInputs.get_model_constant_double("c_alpha"); + double c_beta = userInputs.get_model_constant_double("c_beta"); + double k = userInputs.get_model_constant_double("k"); + double epsilon = userInputs.get_model_constant_double("epsilon"); + + // ================================================================ +}; diff --git a/applications/CHiMaD_benchmark6a/equations.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/equations.cc similarity index 90% rename from applications/CHiMaD_benchmark6a/equations.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/equations.cc index fb704842c..7e04322c0 100644 --- a/applications/CHiMaD_benchmark6a/equations.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/equations.cc @@ -59,8 +59,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -98,8 +99,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -151,8 +153,9 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/CHiMaD_benchmark6a/parameters.prm b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/parameters.prm similarity index 100% rename from applications/CHiMaD_benchmark6a/parameters.prm rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/parameters.prm diff --git a/applications/CHiMaD_benchmark6a/postprocess.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/postprocess.cc similarity index 89% rename from applications/CHiMaD_benchmark6a/postprocess.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/postprocess.cc index 1a0189d56..7292e9eb6 100644 --- a/applications/CHiMaD_benchmark6a/postprocess.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6a/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/CMakeLists.txt b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/CMakeLists.txt new file mode 100644 index 000000000..30e430a8f --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/CMakeLists.txt @@ -0,0 +1,68 @@ +## +# CMake script for the PRISMS-PF applications: +## + +cmake_minimum_required(VERSION 3.1.0) +project(myapp) + +# Find deal.II installation +find_package(deal.II 9.2.0 QUIET REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) + +# Check to make sure deal.II is configured with p4est +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() + +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + +# Set up the debug, release, and run targets +add_custom_target(debug + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) +add_custom_target(release + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) +add_custom_target(run COMMAND main + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" + ) + +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") + add_definitions(-DPOSTPROCESS_FILE_EXISTS) +endif() +if(EXISTS "nucleation.cc") + add_definitions(-DNUCLEATION_FILE_EXISTS) +endif() + +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../../src) +include_directories(${CMAKE_SOURCE_DIR}) + +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../../main.cc") + +# Add main.cc for executable target +add_executable(main ${MAIN}) + +# deal.II linker +DEAL_II_SETUP_TARGET(main) + +# Link libraries for the build type +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +else() + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) +endif() diff --git a/applications/CHiMaD_benchmark6a/ICs_and_BCs.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/ICs_and_BCs.cc similarity index 76% rename from applications/CHiMaD_benchmark6a/ICs_and_BCs.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/ICs_and_BCs.cc index 00ff866b9..8617db09c 100644 --- a/applications/CHiMaD_benchmark6a/ICs_and_BCs.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -48,12 +48,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE @@ -71,7 +72,6 @@ customPDE::setNonUniformDirichletBCs(const dealii::Point &p, { if (direction == 1) { - double x = p[0]; double y = p[1]; scalar_BC = std::sin(y / 7.0); } diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/customPDE.h b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/customPDE.h new file mode 100644 index 000000000..9afd1da6f --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/customPDE.h @@ -0,0 +1,252 @@ +#include +#include + +#include "matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // Virtual method in MatrixFreePDE + void + makeTriangulation(parallel::distributed::Triangulation &) const override; + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double McV = userInputs.get_model_constant_double("McV"); + double KcV = userInputs.get_model_constant_double("KcV"); + double rho = userInputs.get_model_constant_double("rho"); + double c_alpha = userInputs.get_model_constant_double("c_alpha"); + double c_beta = userInputs.get_model_constant_double("c_beta"); + double k = userInputs.get_model_constant_double("k"); + double epsilon = userInputs.get_model_constant_double("epsilon"); + + // ================================================================ +}; + +#include + +template +void +customPDE::makeTriangulation( + parallel::distributed::Triangulation &tria) const +{ + parallel::distributed::Triangulation tria_box(MPI_COMM_WORLD); + parallel::distributed::Triangulation tria_semicircle(MPI_COMM_WORLD); + + // Check that dimensions match the benchmark + AssertThrow(dim == 2, ExcMessage("CHiMaD Benchmark 6b should only be run in 2D.")); + + // Create bounding points for each part of the triangulation + Point box_origin; + Point box_corner; + Point semicircle_origin; + + if (dim == 2) + { + box_corner = Point(userInputs.domain_size[0], userInputs.domain_size[1]); + semicircle_origin = + Point(userInputs.domain_size[0], userInputs.domain_size[1] / 2.0); + } + + GridGenerator::subdivided_hyper_rectangle(tria_box, + userInputs.subdivisions, + box_origin, + box_corner); + + GridGenerator::half_hyper_ball(tria_semicircle, + semicircle_origin, + userInputs.domain_size[1] / 2.0); + + // Find the two non-corner vertices on the right side of the rectangular mesh + Point pt1; + Point pt2; + for (auto &cell : tria_box.active_cell_iterators()) + { + for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + { + Point &v = cell->vertex(i); + if ((std::abs(v(0) - userInputs.domain_size[0]) < 1e-10) && + (v(1) > userInputs.domain_size[1] / 2.0) && + (v(1) < userInputs.domain_size[1] - 1.0e-10)) + { + pt1 = v; + } + if ((std::abs(v(0) - userInputs.domain_size[0]) < 1e-10) && + (v(1) < userInputs.domain_size[1] / 2.0) && (v(1) > 1.0e-10)) + { + pt2 = v; + } + } + } + + // Move the vertices at the center of the half hyper ball so that they will + // align with non-corner vertices on the right side of the rectangular mesh + for (auto &cell : tria_semicircle.active_cell_iterators()) + { + for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) + { + Point &v = cell->vertex(i); + if ((std::abs(v(0) - userInputs.domain_size[0]) < 1e-10) && + (v(1) > userInputs.domain_size[1] / 2.0) && + (v(1) < userInputs.domain_size[1] - 1.0e-10)) + { + v(1) = pt1(1); + } + if ((std::abs(v(0) - userInputs.domain_size[0]) < 1e-10) && + (v(1) < userInputs.domain_size[1] / 2.0) && (v(1) > 1.0e-10)) + { + v(1) = pt2(1); + } + } + } + + // Merge the rectangle and the semicircle + GridGenerator::merge_triangulations(tria_box, tria_semicircle, tria); + + // Attach flat manifold to the entire domain + tria.reset_all_manifolds(); + tria.set_manifold(0, FlatManifold()); + tria.set_all_manifold_ids(0); + + // Attach spherical manifold + tria.set_manifold(8, SphericalManifold(semicircle_origin)); + + // Set the 3 outer cells of semicircle to the spherical manifold + for (const auto &cell : tria.active_cell_iterators()) + { + const Point cell_center = cell->center(); + const double distance_from_center = cell_center.distance(semicircle_origin); + + if (cell_center[0] > userInputs.domain_size[0] + 1.0e-10 && + distance_from_center > 0.1 * userInputs.domain_size[1]) + { + cell->set_all_manifold_ids(8); + } + } + + // Transfinite interpolation + TransfiniteInterpolationManifold transfinite_manifold; + transfinite_manifold.initialize(tria); + tria.set_manifold(0, transfinite_manifold); + + // Mark the boundaries + for (const auto &cell : tria.active_cell_iterators()) + { + // Mark all of the faces + for (unsigned int face_number = 0; face_number < GeometryInfo::faces_per_cell; + ++face_number) + { + if (cell->face(face_number)->at_boundary()) + { + for (unsigned int i = 0; i < dim; i++) + { + if (i == 0) + { + if (std::fabs(cell->face(face_number)->center()(i) - (0)) < 1e-12) + { + cell->face(face_number)->set_boundary_id(2 * i); + } + else if (std::fabs(cell->face(face_number)->center()(i) > + (userInputs.domain_size[i]))) + { + cell->face(face_number)->set_boundary_id(2 * i + 1); + } + } + else + { + if (std::fabs(cell->face(face_number)->center()(i) - (0)) < 1e-12) + { + cell->face(face_number)->set_boundary_id(2 * i); + } + else if (std::fabs(cell->face(face_number)->center()(i) - + (userInputs.domain_size[i])) < 1e-12) + { + cell->face(face_number)->set_boundary_id(2 * i + 1); + } + } + } + } + } + } +} diff --git a/applications/CHiMaD_benchmark6b/equations.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/equations.cc similarity index 90% rename from applications/CHiMaD_benchmark6b/equations.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/equations.cc index 6bd1c9178..96beda0e9 100644 --- a/applications/CHiMaD_benchmark6b/equations.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/equations.cc @@ -59,8 +59,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -98,8 +99,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -151,8 +153,9 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // grad(delta phi) scalargradType Dphix = variable_list.get_change_in_scalar_gradient(2); diff --git a/applications/CHiMaD_benchmark6b/parameters.prm b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/parameters.prm similarity index 99% rename from applications/CHiMaD_benchmark6b/parameters.prm rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/parameters.prm index d76bba216..7b5c6e4af 100644 --- a/applications/CHiMaD_benchmark6b/parameters.prm +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/parameters.prm @@ -31,7 +31,7 @@ set Element degree = 2 # Set the time step parameters # ================================================================================= # The size of the time step -set Time step = 0.2e-4 +set Time step = 0.1e-4 # The simulation ends when either the number of time steps is reached or the # simulation time is reached. diff --git a/applications/CHiMaD_benchmark6b/postprocess.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/postprocess.cc similarity index 89% rename from applications/CHiMaD_benchmark6b/postprocess.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/postprocess.cc index 1a0189d56..7292e9eb6 100644 --- a/applications/CHiMaD_benchmark6b/postprocess.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark6b/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/CMakeLists.txt b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/CMakeLists.txt new file mode 100644 index 000000000..30e430a8f --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/CMakeLists.txt @@ -0,0 +1,68 @@ +## +# CMake script for the PRISMS-PF applications: +## + +cmake_minimum_required(VERSION 3.1.0) +project(myapp) + +# Find deal.II installation +find_package(deal.II 9.2.0 QUIET REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) + +# Check to make sure deal.II is configured with p4est +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() + +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + +# Set up the debug, release, and run targets +add_custom_target(debug + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) +add_custom_target(release + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) +add_custom_target(run COMMAND main + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" + ) + +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") + add_definitions(-DPOSTPROCESS_FILE_EXISTS) +endif() +if(EXISTS "nucleation.cc") + add_definitions(-DNUCLEATION_FILE_EXISTS) +endif() + +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../../src) +include_directories(${CMAKE_SOURCE_DIR}) + +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../../main.cc") + +# Add main.cc for executable target +add_executable(main ${MAIN}) + +# deal.II linker +DEAL_II_SETUP_TARGET(main) + +# Link libraries for the build type +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +else() + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) +endif() diff --git a/applications/CHiMaD_benchmark7/ICs_and_BCs.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/ICs_and_BCs.cc similarity index 72% rename from applications/CHiMaD_benchmark7/ICs_and_BCs.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/ICs_and_BCs.cc index e7f6097b6..f39719f47 100644 --- a/applications/CHiMaD_benchmark7/ICs_and_BCs.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -20,8 +20,6 @@ customPDE::setInitialCondition(const dealii::Point &p, // by a hyperbolic tangent function. The center of each circle/sphere is // given by "center" and its radius is given by "radius". - double pi = 2.0 * std::acos(0.0); - double r0 = 0.25 + A2 * std::sin(B2 * p(0)); double delta = 1.0 / std::sqrt(kappa * 2.0); @@ -36,12 +34,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/customPDE.h b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/customPDE.h new file mode 100644 index 000000000..f63b270ef --- /dev/null +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/customPDE.h @@ -0,0 +1,100 @@ +#include "matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double pi = 2.0 * std::acos(0.0); + + double kappa = userInputs.get_model_constant_double("kappa"); + + double A1 = userInputs.get_model_constant_double("A1"); + double B1 = pi * userInputs.get_model_constant_double("B1"); + + double A2 = userInputs.get_model_constant_double("A2"); + double B2 = pi * userInputs.get_model_constant_double("B2"); + double C2 = pi * userInputs.get_model_constant_double("C2"); + + // ================================================================ +}; diff --git a/applications/CHiMaD_benchmark7/equations.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/equations.cc similarity index 88% rename from applications/CHiMaD_benchmark7/equations.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/equations.cc index c3940db6a..7292ae762 100644 --- a/applications/CHiMaD_benchmark7/equations.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/equations.cc @@ -41,8 +41,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -78,7 +79,7 @@ customPDE::explicitEquationRHS( (alpha_y[i] * alpha_y[i]) + std::sqrt(2.0) * (alpha_t[i] - kappa * alpha_yy[i])) / (4.0 * std::sqrt(kappa)) / - dealii::Utilities::fixed_power<2>( + Utilities::fixed_power<2>( std::cosh((q_point_loc(1)[i] - alpha[i]) / std::sqrt(2.0 * kappa))); } @@ -104,8 +105,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -126,6 +128,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/CHiMaD_benchmark7/parameters.prm b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/parameters.prm similarity index 100% rename from applications/CHiMaD_benchmark7/parameters.prm rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/parameters.prm diff --git a/applications/CHiMaD_benchmark7/postprocess.cc b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/postprocess.cc similarity index 92% rename from applications/CHiMaD_benchmark7/postprocess.cc rename to applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/postprocess.cc index 0f7d971b5..323aee7c0 100644 --- a/applications/CHiMaD_benchmark7/postprocess.cc +++ b/applications/CHiMaD_benchmarks/CHiMaD_benchmark7a/postprocess.cc @@ -65,9 +65,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -120,7 +123,7 @@ customPDE::postProcessedFields( (alpha_y[i] * alpha_y[i]) + std::sqrt(2.0) * (alpha_t[i] - kappa * alpha_yy[i])) / (4.0 * std::sqrt(kappa)) / - dealii::Utilities::fixed_power<2>( + Utilities::fixed_power<2>( std::cosh((q_point_loc(1)[i] - alpha[i]) / std::sqrt(2.0 * kappa))); n_sol[i] = diff --git a/applications/MgNd_precipitate_single_Bppp/CMakeLists.txt b/applications/MgNd_precipitate_single_Bppp/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/MgNd_precipitate_single_Bppp/CMakeLists.txt +++ b/applications/MgNd_precipitate_single_Bppp/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/MgNd_precipitate_single_Bppp/ICs_and_BCs.cc b/applications/MgNd_precipitate_single_Bppp/ICs_and_BCs.cc index 5ea3e07b8..ef9f52544 100644 --- a/applications/MgNd_precipitate_single_Bppp/ICs_and_BCs.cc +++ b/applications/MgNd_precipitate_single_Bppp/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -71,12 +71,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/MgNd_precipitate_single_Bppp/customPDE.h b/applications/MgNd_precipitate_single_Bppp/customPDE.h index f55e1a947..af13d1794 100644 --- a/applications/MgNd_precipitate_single_Bppp/customPDE.h +++ b/applications/MgNd_precipitate_single_Bppp/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -23,23 +25,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -47,35 +49,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -86,16 +98,15 @@ class customPDE : public MatrixFreePDE // Model constants specific to this subclass // ================================================================ - double McV = userInputs.get_model_constant_double("McV"); - double Mn1V = userInputs.get_model_constant_double("Mn1V"); - dealii::Tensor<2, dim> Kn1 = userInputs.get_model_constant_rank_2_tensor("Kn1"); - double W = userInputs.get_model_constant_double("W"); - bool n_dependent_stiffness = + double McV = userInputs.get_model_constant_double("McV"); + double Mn1V = userInputs.get_model_constant_double("Mn1V"); + Tensor<2, dim> Kn1 = userInputs.get_model_constant_rank_2_tensor("Kn1"); + double W = userInputs.get_model_constant_double("W"); + bool n_dependent_stiffness = userInputs.get_model_constant_bool("n_dependent_stiffness"); - dealii::Tensor<2, dim> sfts_linear1 = + Tensor<2, dim> sfts_linear1 = userInputs.get_model_constant_rank_2_tensor("sfts_linear1"); - dealii::Tensor<2, dim> sfts_const1 = - userInputs.get_model_constant_rank_2_tensor("sfts_const1"); + Tensor<2, dim> sfts_const1 = userInputs.get_model_constant_rank_2_tensor("sfts_const1"); double A2 = userInputs.get_model_constant_double("A2"); double A1 = userInputs.get_model_constant_double("A1"); @@ -104,10 +115,10 @@ class customPDE : public MatrixFreePDE double B1 = userInputs.get_model_constant_double("B1"); double B0 = userInputs.get_model_constant_double("B0"); - const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; - dealii::Tensor<2, CIJ_tensor_size> CIJ_Mg = + const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; + Tensor<2, CIJ_tensor_size> CIJ_Mg = userInputs.get_model_constant_elasticity_tensor("CIJ_Mg"); - dealii::Tensor<2, CIJ_tensor_size> CIJ_Beta = + Tensor<2, CIJ_tensor_size> CIJ_Beta = userInputs.get_model_constant_elasticity_tensor("CIJ_Beta"); bool c_dependent_misfit; diff --git a/applications/MgNd_precipitate_single_Bppp/equations.cc b/applications/MgNd_precipitate_single_Bppp/equations.cc index 42e14164b..ebecb287b 100644 --- a/applications/MgNd_precipitate_single_Bppp/equations.cc +++ b/applications/MgNd_precipitate_single_Bppp/equations.cc @@ -67,8 +67,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -102,11 +103,9 @@ customPDE::explicitEquationRHS( scalarvalueType facV = (2.0 * A2 * c_alpha + A1); scalarvalueType faccV = (constV(2.0) * A2); scalarvalueType fbV = (B2 * c_beta * c_beta + B1 * c_beta + B0); - scalarvalueType fbcV = (2.0 * B2 * c_beta + B1); scalarvalueType fbccV = (constV(2.0) * B2); // This double-well function can be used to tune the interfacial energy - scalarvalueType fbarrierV = (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1); scalarvalueType fbarriernV = (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1); // Calculate the derivatives of c_beta (derivatives of c_alpha aren't needed) @@ -124,8 +123,7 @@ customPDE::explicitEquationRHS( // Calculate the stress-free transformation strain and its derivatives at the // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, sfts1n, - sfts1cn; + Tensor<2, dim, VectorizedArray> sfts1, sfts1c, sfts1cc, sfts1n, sfts1cn; for (unsigned int i = 0; i < dim; i++) { @@ -142,7 +140,7 @@ customPDE::explicitEquationRHS( } // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; + VectorizedArray E2[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -155,7 +153,7 @@ customPDE::explicitEquationRHS( // compute stress // S=C*(E-E0) // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; if (n_dependent_stiffness == true) { @@ -176,7 +174,7 @@ customPDE::explicitEquationRHS( // Compute one of the stress terms in the order parameter chemical potential, // nDependentMisfitACp = -C*(E-E0)*(E0_n) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); + VectorizedArray nDependentMisfitAC1 = constV(0.0); for (unsigned int i = 0; i < dim; i++) { @@ -188,8 +186,8 @@ customPDE::explicitEquationRHS( // Compute the other stress term in the order parameter chemical potential, // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; + VectorizedArray heterMechAC1 = constV(0.0); + VectorizedArray S2[dim][dim]; if (n_dependent_stiffness == true) { @@ -252,8 +250,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -280,10 +279,8 @@ customPDE::nonExplicitEquationRHS( scalarvalueType c_beta = ((A2 * c + 0.5 * (A1 - B1) * (1.0 - h1V)) / (A2 * h1V + B2 * (1.0 - h1V))); - scalarvalueType faV = (A2 * c_alpha * c_alpha + A1 * c_alpha + A0); scalarvalueType facV = (2.0 * A2 * c_alpha + A1); scalarvalueType faccV = (constV(2.0) * A2); - scalarvalueType fbV = (B2 * c_beta * c_beta + B1 * c_beta + B0); scalarvalueType fbcV = (2.0 * B2 * c_beta + B1); scalarvalueType fbccV = (constV(2.0) * B2); @@ -306,8 +303,7 @@ customPDE::nonExplicitEquationRHS( // Calculate the stress-free transformation strain and its derivatives at the // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, sfts1n, - sfts1cn; + Tensor<2, dim, VectorizedArray> sfts1, sfts1c, sfts1cc, sfts1n, sfts1cn; for (unsigned int i = 0; i < dim; i++) { @@ -324,7 +320,7 @@ customPDE::nonExplicitEquationRHS( } // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; + VectorizedArray E2[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -337,7 +333,7 @@ customPDE::nonExplicitEquationRHS( // compute stress // S=C*(E-E0) // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; if (n_dependent_stiffness == true) { @@ -405,8 +401,9 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -419,14 +416,14 @@ customPDE::equationLHS( // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; + Tensor<2, dim, VectorizedArray> E; E = symmetrize(variable_list.get_change_in_vector_gradient(3)); // Compute stress tensor (which is equal to the residual, Rux) if (n_dependent_stiffness == true) { scalarvalueType h1V = (3.0 * n1 * n1 - 2.0 * n1 * n1 * n1); - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; + Tensor<2, CIJ_tensor_size, VectorizedArray> CIJ_combined; CIJ_combined = CIJ_Mg * (constV(1.0) - h1V); CIJ_combined += CIJ_Beta * (h1V); diff --git a/applications/MgNd_precipitate_single_Bppp/main.cc b/applications/MgNd_precipitate_single_Bppp/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/MgNd_precipitate_single_Bppp/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/MgNd_precipitate_single_Bppp/postprocess.cc b/applications/MgNd_precipitate_single_Bppp/postprocess.cc index 8a6f07dd9..4e00a269e 100644 --- a/applications/MgNd_precipitate_single_Bppp/postprocess.cc +++ b/applications/MgNd_precipitate_single_Bppp/postprocess.cc @@ -47,9 +47,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -57,8 +60,6 @@ customPDE::postProcessedFields( /// the macros above) scalarvalueType c = variable_list.get_scalar_value(0); - scalargradType mux = variable_list.get_scalar_gradient(1); - // The first order parameter and its derivatives (names here should match // those in the macros above) scalarvalueType n1 = variable_list.get_scalar_value(2); @@ -75,8 +76,7 @@ customPDE::postProcessedFields( scalarvalueType hn1V = (6.0 * n1 - 6.0 * n1 * n1); // This double-well function can be used to tune the interfacial energy - scalarvalueType fbarrierV = (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1); - scalarvalueType fbarriernV = (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1); + scalarvalueType fbarrierV = (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1); // Calculate c_alpha and c_beta from c scalarvalueType c_alpha = @@ -120,8 +120,7 @@ customPDE::postProcessedFields( // Calculate the stress-free transformation strain and its derivatives at the // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, sfts1n, - sfts1cn; + Tensor<2, dim, VectorizedArray> sfts1, sfts1c, sfts1cc, sfts1n, sfts1cn; for (unsigned int i = 0; i < dim; i++) { @@ -138,7 +137,7 @@ customPDE::postProcessedFields( } // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; + VectorizedArray E2[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -150,8 +149,7 @@ customPDE::postProcessedFields( // compute stress // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[2 * dim - 1 + dim / 3] - [2 * dim - 1 + dim / 3]; + VectorizedArray CIJ_combined[2 * dim - 1 + dim / 3][2 * dim - 1 + dim / 3]; if (n_dependent_stiffness == true) { @@ -203,7 +201,7 @@ customPDE::postProcessedFields( } // The Von Mises Stress - dealii::VectorizedArray vm_stress; + VectorizedArray vm_stress; if (dim == 3) { vm_stress = (S[0][0] - S[1][1]) * (S[0][0] - S[1][1]) + @@ -221,13 +219,11 @@ customPDE::postProcessedFields( vm_stress = std::sqrt(vm_stress); } - scalarvalueType dn_dt_chem, dn_dt_el; - // Compute one of the stress terms in the order parameter chemical potential, // nDependentMisfitACp = -C*(E-E0)*(E0_n) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC1_t1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC1_t2 = constV(0.0); + VectorizedArray nDependentMisfitAC1 = constV(0.0); + VectorizedArray nDependentMisfitAC1_t1 = constV(0.0); + VectorizedArray nDependentMisfitAC1_t2 = constV(0.0); for (unsigned int i = 0; i < dim; i++) { @@ -241,8 +237,8 @@ customPDE::postProcessedFields( // Compute the other stress term in the order parameter chemical potential, // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; + VectorizedArray heterMechAC1 = constV(0.0); + VectorizedArray S2[dim][dim]; if (n_dependent_stiffness == true) { diff --git a/applications/_allenCahn_implicit/CMakeLists.txt b/applications/_allenCahn_implicit/CMakeLists.txt deleted file mode 100644 index 39b8e6bd3..000000000 --- a/applications/_allenCahn_implicit/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -## -# CMake script for the PRISMS-PF applications: -## - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) - -# Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED - HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) - -# Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() - -# Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Debug" - ) - -ADD_CUSTOM_TARGET(release - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Release" - ) - -ADD_CUSTOM_TARGET(run COMMAND main - COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" - ) - -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") - add_definitions(-DPOSTPROCESS_FILE_EXISTS) -endif() -if (EXISTS "nucleation.cc") - add_definitions(-DNUCLEATION_FILE_EXISTS) -endif() - -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) - -DEAL_II_SETUP_TARGET(main) - -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) - -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) - -if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) -endif() diff --git a/applications/_allenCahn_implicit/ICs_and_BCs.h b/applications/_allenCahn_implicit/ICs_and_BCs.h deleted file mode 100644 index a37370076..000000000 --- a/applications/_allenCahn_implicit/ICs_and_BCs.h +++ /dev/null @@ -1,117 +0,0 @@ -// =========================================================================== -// FUNCTIONS FOR INITIAL CONDITIONS -// =========================================================================== - -template -double -InitialCondition::value(const dealii::Point &p, - const unsigned int component) const -{ - double scalar_IC; - // --------------------------------------------------------------------- - // ENTER THE INITIAL CONDITIONS HERE - // --------------------------------------------------------------------- - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // The initial condition is a set of overlapping circles/spheres defined - // by a hyperbolic tangent function. The center of each circle/sphere is - // given by "center" and its radius is given by "radius". - - double center[12][3] = { - {0.1, 0.3, 0}, - {0.8, 0.7, 0}, - {0.5, 0.2, 0}, - {0.4, 0.4, 0}, - {0.3, 0.9, 0}, - {0.8, 0.1, 0}, - {0.9, 0.5, 0}, - {0.0, 0.1, 0}, - {0.1, 0.6, 0}, - {0.5, 0.6, 0}, - {1, 1, 0}, - {0.7, 0.95, 0} - }; - double rad[12] = {12, 14, 19, 16, 11, 12, 17, 15, 20, 10, 11, 14}; - double dist; - scalar_IC = 0; - for (unsigned int i = 0; i < 12; i++) - { - dist = 0.0; - for (unsigned int dir = 0; dir < dim; dir++) - { - dist += (p[dir] - center[i][dir] * userInputs.domain_size[dir]) * - (p[dir] - center[i][dir] * userInputs.domain_size[dir]); - } - dist = std::sqrt(dist); - - scalar_IC += 0.5 * (1.0 - std::tanh((dist - rad[i]) / 1.5)); - } - if (scalar_IC > 1.0) - scalar_IC = 1.0; - - // --------------------------------------------------------------------- - return scalar_IC; -} - -template -void -InitialConditionVec::vector_value(const dealii::Point &p, - dealii::Vector &vector_IC) const -{ - // --------------------------------------------------------------------- - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // --------------------------------------------------------------------- - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // --------------------------------------------------------------------- -} - -// =========================================================================== -// FUNCTIONS FOR NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS -// =========================================================================== - -template -double -NonUniformDirichletBC::value(const dealii::Point &p, - const unsigned int component) const -{ - double scalar_BC = 0; - // -------------------------------------------------------------------------- - // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE FOR SCALAR FIELDS - // -------------------------------------------------------------------------- - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the boundary condition for each variable - // according to its variable index. This function can be left blank if there - // are no non-uniform Dirichlet boundary conditions. For BCs that change in - // time, you can access the current time through the variable "time". The - // boundary index can be accessed via the variable "direction", which starts - // at zero and uses the same order as the BC specification in parameters.in - // (i.e. left = 0, right = 1, bottom = 2, top = 3, front = 4, back = 5). - - // ------------------------------------------------------------------------- - return scalar_BC; -} - -template -void -NonUniformDirichletBCVec::vector_value(const dealii::Point &p, - dealii::Vector &vector_BC) const -{ - // -------------------------------------------------------------------------- - // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE FOR VECTOR FIELDS - // -------------------------------------------------------------------------- - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the boundary condition for each variable - // according to its variable index. This function can be left blank if there - // are no non-uniform Dirichlet boundary conditions. For BCs that change in - // time, you can access the current time through the variable "time". The - // boundary index can be accessed via the variable "direction", which starts - // at zero and uses the same order as the BC specification in parameters.in - // (i.e. left = 0, right = 1, bottom = 2, top = 3, front = 4, back = 5). - - // ------------------------------------------------------------------------- -} diff --git a/applications/_allenCahn_implicit/customPDE.h b/applications/_allenCahn_implicit/customPDE.h deleted file mode 100644 index 3ec5e4aae..000000000 --- a/applications/_allenCahn_implicit/customPDE.h +++ /dev/null @@ -1,60 +0,0 @@ -#include "../../include/matrixFreePDE.h" - -template -class customPDE : public MatrixFreePDE -{ -public: - customPDE(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - , userInputs(_userInputs) {}; - -private: -#include "../../include/typeDefs.h" - - const userInputParameters userInputs; - - // Pure virtual method in MatrixFreePDE - void - residualExplicitRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - void - residualNonexplicitRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Pure virtual method in MatrixFreePDE - void - residualLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - -// Virtual method in MatrixFreePDE that we override if we need postprocessing -#ifdef POSTPROCESS_FILE_EXISTS - void - postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; -#endif - -// Virtual method in MatrixFreePDE that we override if we need nucleation -#ifdef NUCLEATION_FILE_EXISTS - double - getNucleationProbability(variableValueContainer variable_value, double dV) const; -#endif - - // ================================================================ - // Methods specific to this subclass - // ================================================================ - - // ================================================================ - // Model constants specific to this subclass - // ================================================================ - - double MnV = userInputs.get_model_constant_double("MnV"); - double KnV = userInputs.get_model_constant_double("KnV"); - - // ================================================================ -}; diff --git a/applications/_allenCahn_implicit/equations.h b/applications/_allenCahn_implicit/equations.h deleted file mode 100644 index 7e8031594..000000000 --- a/applications/_allenCahn_implicit/equations.h +++ /dev/null @@ -1,97 +0,0 @@ -// List of residual equations for the coupled Allen-Cahn example application - -// ================================================================================= -// Set the attributes of the primary field variables -// ================================================================================= -void -variableAttributeLoader::loadVariableAttributes() -{ - // Variable 1 - set_variable_name(0, "psi"); - set_variable_type(0, SCALAR); - set_variable_equation_type(0, IMPLICIT_TIME_DEPENDENT); - - set_dependencies_value_residual_term_RHS(0, "psi"); - set_dependencies_gradient_residual_term_RHS(0, "grad(psi)"); - set_dependencies_value_residual_term_LHS(0, "psi, change(psi)"); - set_dependencies_gradient_residual_term_LHS(0, "grad(change(psi))"); -} - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "variable_list" as an input, which is a list of the value and derivatives of -// each of the variables at a specific quadrature point. The (x,y,z) location of -// that quadrature point is given by "q_point_loc". The function outputs -// residuals to variable_list. The index for each variable in this list -// corresponds to the index given at the top of this file. - -template -void -customPDE::residualExplicitRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const -{} - -template -void -customPDE::residualNonexplicitRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const -{ - // The order parameter and its derivatives - scalarvalueType psi = variable_list.get_scalar_value(0); - scalargradType psix = variable_list.get_scalar_gradient(0); - - scalarvalueType psi_old = variable_list.get_old_scalar_value(0); // not implemented yet! - - // Parameters in the residual equations and expressions for the residual - // equations can be set here. - scalarvalueType fnV = (4.0 * psi * (psi - 1.0) * (psi - 0.5)); - - // Residuals for the equation to evolve the order parameter - scalarvalueType rpsi = psi_old - psi - (constV(userInputs.dtValue * MnV) * fnV); - scalargradType rpsix = -(constV(userInputs.dtValue * KnV * MnV) * psix); - - // Submit the residuals - variable_list.set_scalar_value_residual_term(0, rpsi); - variable_list.set_scalar_gradient_residual_term(0, rpsix); -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "variable_list" as an input, -// which is a list of the value and derivatives of each of the variables at a -// specific quadrature point. The (x,y,z) location of that quadrature point is -// given by "q_point_loc". The function outputs residual terms to -// "variable_list" for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in this list corresponds to the -// index given at the top of this file. If there are multiple elliptic -// equations, conditional statements should be used to ensure that the correct -// residual is being submitted. The index of the field being solved can be -// accessed by "this->currentFieldIndex". - -template -void -customPDE::residualLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const -{ - // The order parameter and its derivatives - - scalarvalueType psi = variable_list.get_scalar_value(0); - - scalarvalueType Dpsi = variable_list.get_change_in_scalar_value(0); - scalargradType Dpsix = variable_list.get_change_in_scalar_gradient(0); - - scalarvalueType rpsi = - Dpsi + constV(userInputs.dtValue * MnV) * - (12.0 * psi * psi * Dpsi - 12.0 * psi * Dpsi + 2.0 * Dpsi); - scalargradType rpsix = constV(userInputs.dtValue * MnV * KnV) * Dpsix; - - variable_list.set_scalar_value_residual_term_LHS(0, rpsi); - variable_list.set_scalar_gradient_residual_term_LHS(0, rpsix); -} diff --git a/applications/_allenCahn_implicit/formulation_allenCahn.pdf b/applications/_allenCahn_implicit/formulation_allenCahn.pdf deleted file mode 100644 index aa82cf7b1..000000000 Binary files a/applications/_allenCahn_implicit/formulation_allenCahn.pdf and /dev/null differ diff --git a/applications/_allenCahn_implicit/main.cc b/applications/_allenCahn_implicit/main.cc deleted file mode 100644 index d082eaa8f..000000000 --- a/applications/_allenCahn_implicit/main.cc +++ /dev/null @@ -1,167 +0,0 @@ -// Allen-Cahn example application - -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.h" -#include "equations.h" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.h" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.h" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/_allenCahn_implicit/postprocess.h b/applications/_allenCahn_implicit/postprocess.h deleted file mode 100644 index 9acc4b432..000000000 --- a/applications/_allenCahn_implicit/postprocess.h +++ /dev/null @@ -1,52 +0,0 @@ -// ================================================================================= -// Set the attributes of the primary field variables -// ================================================================================= -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{ - set_variable_name(0, "f_tot"); - set_variable_type(0, SCALAR); - - set_output_integral(0, true); - - set_dependencies_value_residual_term_RHS(0, "psi, grad(psi)"); - set_dependencies_gradient_residual_term_RHS(0, ""); -} - -template -void -customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const -{ - // The order parameter and its derivatives - scalarvalueType n = variable_list.get_scalar_value(0); - scalargradType nx = variable_list.get_scalar_gradient(0); - - scalargradType pp_field; - pp_field[0] = nx[0]; - pp_field[1] = nx[1]; - - scalarvalueType f_tot = constV(0.0); - - // The homogenous free energy - scalarvalueType f_chem = (n * n * n * n - 2.0 * n * n * n + n * n); - - // The gradient free energy - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * KnV) * nx[i] * nx[j]; - } - } - - // The total free energy - f_tot = f_chem + f_grad; - - // Residuals for the equation to evolve the order parameter - pp_variable_list.set_scalar_value_residual_term(0, f_tot); -} diff --git a/applications/_allenCahn_implicit/tex_files/allenCahn.tex b/applications/_allenCahn_implicit/tex_files/allenCahn.tex deleted file mode 100644 index d2b763351..000000000 --- a/applications/_allenCahn_implicit/tex_files/allenCahn.tex +++ /dev/null @@ -1,223 +0,0 @@ -\documentclass[10pt]{article} -\usepackage{amsmath} -\usepackage{bm} -\usepackage{bbm} -\usepackage{mathrsfs} -\usepackage{graphicx} -\usepackage{wrapfig} -\usepackage{subcaption} -\usepackage{epsfig} -\usepackage{amsfonts} -\usepackage{amssymb} -\usepackage{amsmath} -\usepackage{wrapfig} -\usepackage{graphicx} -\usepackage{psfrag} -\newcommand{\sun}{\ensuremath{\odot}} % sun symbol is \sun -\let\vaccent=\v % rename builtin command \v{} to \vaccent{} -\renewcommand{\v}[1]{\ensuremath{\mathbf{#1}}} % for vectors -\newcommand{\gv}[1]{\ensuremath{\mbox{\boldmath$ #1 $}}} -\newcommand{\grad}[1]{\gv{\nabla} #1} -\renewcommand{\baselinestretch}{1.2} -\jot 5mm -\graphicspath{{./figures/}} -%text dimensions -\textwidth 6.5 in -\oddsidemargin .2 in -\topmargin -0.2 in -\textheight 8.5 in -\headheight 0.2in -\overfullrule = 0pt -\pagestyle{plain} -\def\newpar{\par\vskip 0.5cm} -\begin{document} -% -%---------------------------------------------------------------------- -% Define symbols -%---------------------------------------------------------------------- -% -\def\iso{\mathbbm{1}} -\def\half{{\textstyle{1 \over 2}}} -\def\third{{\textstyle{1 \over 3}}} -\def\fourth{{\textstyle{{1 \over 4}}}} -\def\twothird{{\textstyle {{2 \over 3}}}} -\def\ndim{{n_{\rm dim}}} -\def\nint{n_{\rm int}} -\def\lint{l_{\rm int}} -\def\nel{n_{\rm el}} -\def\nf{n_{\rm f}} -\def\DIV {\hbox{\af div}} -\def\GRAD{\hbox{\af Grad}} -\def\sym{\mathop{\rm sym}\nolimits} -\def\tr{\mathop{\rm tr}\nolimits} -\def\dev{\mathop{\rm dev}\nolimits} -\def\Dev{\mathop{\rm Dev}\nolimits} -\def\DEV{\mathop {\rm DEV}\nolimits} -\def\bfb {{\bi b}} -\def\Bnabla{\nabla} -\def\bG{{\bi G}} -\def\jmpdelu{{\lbrack\!\lbrack \Delta u\rbrack\!\rbrack}} -\def\jmpudot{{\lbrack\!\lbrack\dot u\rbrack\!\rbrack}} -\def\jmpu{{\lbrack\!\lbrack u\rbrack\!\rbrack}} -\def\jmphi{{\lbrack\!\lbrack\varphi\rbrack\!\rbrack}} -\def\ljmp{{\lbrack\!\lbrack}} -\def\rjmp{{\rbrack\!\rbrack}} -\def\sign{{\rm sign}} -\def\nn{{n+1}} -\def\na{{n+\vartheta}} -\def\nna{{n+(1-\vartheta)}} -\def\nt{{n+{1\over 2}}} -\def\nb{{n+\beta}} -\def\nbb{{n+(1-\beta)}} -%--------------------------------------------------------- -% Bold Face Math Characters: -% All In Format: \B***** . -%--------------------------------------------------------- -\def\bOne{\mbox{\boldmath$1$}} -\def\BGamma{\mbox{\boldmath$\Gamma$}} -\def\BDelta{\mbox{\boldmath$\Delta$}} -\def\BTheta{\mbox{\boldmath$\Theta$}} -\def\BLambda{\mbox{\boldmath$\Lambda$}} -\def\BXi{\mbox{\boldmath$\Xi$}} -\def\BPi{\mbox{\boldmath$\Pi$}} -\def\BSigma{\mbox{\boldmath$\Sigma$}} -\def\BUpsilon{\mbox{\boldmath$\Upsilon$}} -\def\BPhi{\mbox{\boldmath$\Phi$}} -\def\BPsi{\mbox{\boldmath$\Psi$}} -\def\BOmega{\mbox{\boldmath$\Omega$}} -\def\Balpha{\mbox{\boldmath$\alpha$}} -\def\Bbeta{\mbox{\boldmath$\beta$}} -\def\Bgamma{\mbox{\boldmath$\gamma$}} -\def\Bdelta{\mbox{\boldmath$\delta$}} -\def\Bepsilon{\mbox{\boldmath$\epsilon$}} -\def\Bzeta{\mbox{\boldmath$\zeta$}} -\def\Beta{\mbox{\boldmath$\eta$}} -\def\Btheta{\mbox{\boldmath$\theta$}} -\def\Biota{\mbox{\boldmath$\iota$}} -\def\Bkappa{\mbox{\boldmath$\kappa$}} -\def\Blambda{\mbox{\boldmath$\lambda$}} -\def\Bmu{\mbox{\boldmath$\mu$}} -\def\Bnu{\mbox{\boldmath$\nu$}} -\def\Bxi{\mbox{\boldmath$\xi$}} -\def\Bpi{\mbox{\boldmath$\pi$}} -\def\Brho{\mbox{\boldmath$\rho$}} -\def\Bsigma{\mbox{\boldmath$\sigma$}} -\def\Btau{\mbox{\boldmath$\tau$}} -\def\Bupsilon{\mbox{\boldmath$\upsilon$}} -\def\Bphi{\mbox{\boldmath$\phi$}} -\def\Bchi{\mbox{\boldmath$\chi$}} -\def\Bpsi{\mbox{\boldmath$\psi$}} -\def\Bomega{\mbox{\boldmath$\omega$}} -\def\Bvarepsilon{\mbox{\boldmath$\varepsilon$}} -\def\Bvartheta{\mbox{\boldmath$\vartheta$}} -\def\Bvarpi{\mbox{\boldmath$\varpi$}} -\def\Bvarrho{\mbox{\boldmath$\varrho$}} -\def\Bvarsigma{\mbox{\boldmath$\varsigma$}} -\def\Bvarphi{\mbox{\boldmath$\varphi$}} -\def\bone{\mathbf{1}} -\def\bzero{\mathbf{0}} -%--------------------------------------------------------- -% Bold Face Math Italic: -% All In Format: \b* . -%--------------------------------------------------------- -\def\bA{\mbox{\boldmath$ A$}} -\def\bB{\mbox{\boldmath$ B$}} -\def\bC{\mbox{\boldmath$ C$}} -\def\bD{\mbox{\boldmath$ D$}} -\def\bE{\mbox{\boldmath$ E$}} -\def\bF{\mbox{\boldmath$ F$}} -\def\bG{\mbox{\boldmath$ G$}} -\def\bH{\mbox{\boldmath$ H$}} -\def\bI{\mbox{\boldmath$ I$}} -\def\bJ{\mbox{\boldmath$ J$}} -\def\bK{\mbox{\boldmath$ K$}} -\def\bL{\mbox{\boldmath$ L$}} -\def\bM{\mbox{\boldmath$ M$}} -\def\bN{\mbox{\boldmath$ N$}} -\def\bO{\mbox{\boldmath$ O$}} -\def\bP{\mbox{\boldmath$ P$}} -\def\bQ{\mbox{\boldmath$ Q$}} -\def\bR{\mbox{\boldmath$ R$}} -\def\bS{\mbox{\boldmath$ S$}} -\def\bT{\mbox{\boldmath$ T$}} -\def\bU{\mbox{\boldmath$ U$}} -\def\bV{\mbox{\boldmath$ V$}} -\def\bW{\mbox{\boldmath$ W$}} -\def\bX{\mbox{\boldmath$ X$}} -\def\bY{\mbox{\boldmath$ Y$}} -\def\bZ{\mbox{\boldmath$ Z$}} -\def\ba{\mbox{\boldmath$ a$}} -\def\bb{\mbox{\boldmath$ b$}} -\def\bc{\mbox{\boldmath$ c$}} -\def\bd{\mbox{\boldmath$ d$}} -\def\be{\mbox{\boldmath$ e$}} -\def\bff{\mbox{\boldmath$ f$}} -\def\bg{\mbox{\boldmath$ g$}} -\def\bh{\mbox{\boldmath$ h$}} -\def\bi{\mbox{\boldmath$ i$}} -\def\bj{\mbox{\boldmath$ j$}} -\def\bk{\mbox{\boldmath$ k$}} -\def\bl{\mbox{\boldmath$ l$}} -\def\bm{\mbox{\boldmath$ m$}} -\def\bn{\mbox{\boldmath$ n$}} -\def\bo{\mbox{\boldmath$ o$}} -\def\bp{\mbox{\boldmath$ p$}} -\def\bq{\mbox{\boldmath$ q$}} -\def\br{\mbox{\boldmath$ r$}} -\def\bs{\mbox{\boldmath$ s$}} -\def\bt{\mbox{\boldmath$ t$}} -\def\bu{\mbox{\boldmath$ u$}} -\def\bv{\mbox{\boldmath$ v$}} -\def\bw{\mbox{\boldmath$ w$}} -\def\bx{\mbox{\boldmath$ x$}} -\def\by{\mbox{\boldmath$ y$}} -\def\bz{\mbox{\boldmath$ z$}} -%********************************* -%Start main paper -%********************************* -\centerline{\Large{\bf PRISMS PhaseField}} -\smallskip -\centerline{\Large{\bf Allen-Cahn Dynamics}} -\bigskip -Consider a free energy expression of the form: -\begin{equation} - \Pi(\eta, \grad \eta) = \int_{\Omega} f( \eta ) + \frac{\kappa}{2} \grad \eta \cdot \grad \eta ~dV -\end{equation} -where $\eta$ is the structural order parameter, and $\kappa$ is the gradient length scale parameter. - -\section{Variational treatment} -Considering variations on the primal field $\eta$ of the from $\eta+\epsilon w$, we have -\begin{align} -\delta \Pi &= \left. \frac{d}{d\epsilon} \int_{\Omega} f(\eta+\epsilon w) + \frac{\kappa}{2} \grad (\eta+\epsilon w) \cdot ~\grad (\eta+\epsilon w) ~dV \right\vert_{\epsilon=0} \\ -&= \int_{\Omega} w f_{,\eta} + \kappa \grad w \grad \eta ~dV \\ -&= \int_{\Omega} w \left( f_{,\eta} - \kappa \Delta \eta \right) ~dV + \int_{\partial \Omega} w \kappa \grad \eta \cdot n ~dS -\end{align} -Assuming $\kappa \grad \eta \cdot n = 0$, and using standard variational arguments on the equation $\delta \Pi =0$ we have the expression for chemical potential as -\begin{equation} - \mu = f_{,\eta} - \kappa \Delta \eta -\end{equation} - -\section{Kinetics} -Now the Parabolic PDE for Allen-Cahn dynamics is given by: -\begin{align} - \frac{\partial \eta}{\partial t} &= -M~(f_{,\eta} - \kappa \Delta \eta) -\end{align} -where $M$ is the constant mobility. -\section{Time discretization} -Considering forward Euler explicit time stepping, we have the time discretized kinetics equation: -\begin{align} - \eta^{n+1} &= \eta^{n} - \Delta t M~(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) -\end{align} - -\section{Weak formulation} -In the weak formulation, considering an arbitrary variation $w$, the above equation can be expressed as a residual equation: -\begin{align} -\int_{\Omega} w \eta^{n+1} ~dV&= \int_{\Omega} w \eta^{n} - w \Delta t M~(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) ~dV \\ -&= \int_{\Omega} w ( \underbrace{ \eta^{n} - \Delta t M~f_{,\eta}^{n} }_{r_{\eta}} ) + \grad w \underbrace{ (-\Delta t M \kappa)~ \cdot (\grad \eta^{n})}_{r_{\eta x}} ~dV \quad [\kappa \grad \eta \cdot n = 0 \quad \text{on} \quad \partial \Omega] -\end{align} -\vskip 0.25in -The above values of $r_{\eta}$ and $r_{\eta x}$ are used to define the residuals in the following parameters file: \\ -\textit{applications/allenCahn/parameters.h} - - -\end{document} \ No newline at end of file diff --git a/applications/_nucleating_precipitates_MgRE/CMakeLists.txt b/applications/_nucleating_precipitates_MgRE/CMakeLists.txt deleted file mode 100644 index 39b8e6bd3..000000000 --- a/applications/_nucleating_precipitates_MgRE/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -## -# CMake script for the PRISMS-PF applications: -## - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) - -# Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED - HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) - -# Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() - -# Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Debug" - ) - -ADD_CUSTOM_TARGET(release - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Release" - ) - -ADD_CUSTOM_TARGET(run COMMAND main - COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" - ) - -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") - add_definitions(-DPOSTPROCESS_FILE_EXISTS) -endif() -if (EXISTS "nucleation.cc") - add_definitions(-DNUCLEATION_FILE_EXISTS) -endif() - -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) - -DEAL_II_SETUP_TARGET(main) - -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) - -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) - -if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) -endif() diff --git a/applications/_nucleating_precipitates_MgRE/customPDE.h b/applications/_nucleating_precipitates_MgRE/customPDE.h deleted file mode 100644 index 53ce6c7f3..000000000 --- a/applications/_nucleating_precipitates_MgRE/customPDE.h +++ /dev/null @@ -1,128 +0,0 @@ -#include "../../include/matrixFreePDE.h" - -template -class customPDE : public MatrixFreePDE -{ -public: - // Constructor - customPDE(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - , userInputs(_userInputs) {}; - - // Function to set the initial conditions (in ICs_and_BCs.h) - void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); - - // Function to set the non-uniform Dirichlet boundary conditions (in - // ICs_and_BCs.h) - void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); - -private: -#include "../../include/typeDefs.h" - - const userInputParameters userInputs; - - // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) - void - explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the RHS of the governing equations for all other equations - // (in equations.h) - void - nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the LHS of the governing equations (in equations.h) - void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - -// Function to set postprocessing expressions (in postprocess.h) -#ifdef POSTPROCESS_FILE_EXISTS - void - postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; -#endif - -// Function to set the nucleation probability (in nucleation.h) -#ifdef NUCLEATION_FILE_EXISTS - double - getNucleationProbability(variableValueContainer variable_value, - double dV, - dealii::Point p, - unsigned int variable_index) const; -#endif - - // ================================================================ - // Methods specific to this subclass - // ================================================================ - - // Method to place the nucleus and calculate the mobility modifier in - // residualRHS - void - seedNucleus(const dealii::Point> &q_point_loc, - dealii::AlignedVector> &source_terms, - dealii::VectorizedArray &gamma) const; - - // ================================================================ - // Model constants specific to this subclass - // ================================================================ - - double McV = userInputs.get_model_constant_double("McV"); - double Mn1V = userInputs.get_model_constant_double("Mn1V"); - double Mn2V = userInputs.get_model_constant_double("Mn2V"); - double Mn3V = userInputs.get_model_constant_double("Mn3V"); - dealii::Tensor<2, dim> Kn1 = userInputs.get_model_constant_rank_2_tensor("Kn1"); - dealii::Tensor<2, dim> Kn2 = userInputs.get_model_constant_rank_2_tensor("Kn2"); - dealii::Tensor<2, dim> Kn3 = userInputs.get_model_constant_rank_2_tensor("Kn3"); - double W = userInputs.get_model_constant_double("W"); - bool n_dependent_stiffness = - userInputs.get_model_constant_bool("n_dependent_stiffness"); - dealii::Tensor<2, dim> sfts_const1 = - userInputs.get_model_constant_rank_2_tensor("sfts_const1"); - dealii::Tensor<2, dim> sfts_const2 = - userInputs.get_model_constant_rank_2_tensor("sfts_const2"); - dealii::Tensor<2, dim> sfts_const3 = - userInputs.get_model_constant_rank_2_tensor("sfts_const3"); - double A2 = userInputs.get_model_constant_double("A2"); - double A1 = userInputs.get_model_constant_double("A1"); - double A0 = userInputs.get_model_constant_double("A0"); - double B2 = userInputs.get_model_constant_double("B2"); - double B1 = userInputs.get_model_constant_double("B1"); - double B0 = userInputs.get_model_constant_double("B0"); - - const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; - dealii::Tensor<2, CIJ_tensor_size> CIJ_Mg = - userInputs.get_model_constant_elasticity_tensor("CIJ_Mg"); - dealii::Tensor<2, CIJ_tensor_size> CIJ_Beta1 = - userInputs.get_model_constant_elasticity_tensor("CIJ_Beta1"); - dealii::Tensor<2, CIJ_tensor_size> CIJ_Beta2 = - userInputs.get_model_constant_elasticity_tensor("CIJ_Beta2"); - dealii::Tensor<2, CIJ_tensor_size> CIJ_Beta3 = - userInputs.get_model_constant_elasticity_tensor("CIJ_Beta3"); - - double interface_coeff = userInputs.get_model_constant_double("interface_coeff"); - double k1 = userInputs.get_model_constant_double("k1"); - double k2 = userInputs.get_model_constant_double("k2"); - double tau = userInputs.get_model_constant_double("tau"); - - double pi = 2.0 * std::acos(0.0); - - // ================================================================ -}; diff --git a/applications/_nucleating_precipitates_MgRE/equations.h b/applications/_nucleating_precipitates_MgRE/equations.h deleted file mode 100644 index 5b87fcbba..000000000 --- a/applications/_nucleating_precipitates_MgRE/equations.h +++ /dev/null @@ -1,492 +0,0 @@ -// ================================================================================= -// Set the attributes of the primary field variables -// ================================================================================= -// This function sets attributes for each variable/equation in the app. The -// attributes are set via standardized function calls. The first parameter for -// each function call is the variable index (starting at zero). The first set of -// variable/equation attributes are the variable name (any string), the variable -// type (SCALAR/VECTOR), and the equation type (EXPLICIT_TIME_DEPENDENT/ -// TIME_INDEPENDENT/AUXILIARY). The next set of attributes describe the -// dependencies for the governing equation on the values and derivatives of the -// other variables for the value term and gradient term of the RHS and the LHS. -// The final pair of attributes determine whether a variable represents a field -// that can nucleate and whether the value of the field is needed for nucleation -// rate calculations. - -void -variableAttributeLoader::loadVariableAttributes() -{ - // Variable 0 - set_variable_name(0, "c"); - set_variable_type(0, SCALAR); - set_variable_equation_type(0, EXPLICIT_TIME_DEPENDENT); - - set_dependencies_value_term_RHS(0, "c"); - set_dependencies_gradient_term_RHS(0, "n1, grad(mu)"); - - set_allowed_to_nucleate(0, false); - set_need_value_nucleation(0, true); - - // Variable 1 - set_variable_name(1, "n1"); - set_variable_type(1, SCALAR); - set_variable_equation_type(1, EXPLICIT_TIME_DEPENDENT); - - set_dependencies_value_term_RHS(1, "c, n1, n2, n3, grad(u)"); - set_dependencies_gradient_term_RHS(1, "grad(n1)"); - - set_allowed_to_nucleate(1, true); - set_need_value_nucleation(1, true); - - // Variable 2 - set_variable_name(2, "n2"); - set_variable_type(2, SCALAR); - set_variable_equation_type(2, EXPLICIT_TIME_DEPENDENT); - - set_dependencies_value_term_RHS(2, "c, n1, n2, n3, grad(u)"); - set_dependencies_gradient_term_RHS(2, "grad(n2)"); - - set_allowed_to_nucleate(2, true); - set_need_value_nucleation(2, true); - - // Variable 3 - set_variable_name(3, "n3"); - set_variable_type(3, SCALAR); - set_variable_equation_type(3, EXPLICIT_TIME_DEPENDENT); - - set_dependencies_value_term_RHS(3, "c, n1, n2, n3, grad(u)"); - set_dependencies_gradient_term_RHS(3, "grad(n3)"); - - set_allowed_to_nucleate(3, true); - set_need_value_nucleation(3, true); - - // Variable 4 - set_variable_name(4, "u"); - set_variable_type(4, VECTOR); - set_variable_equation_type(4, TIME_INDEPENDENT); - - set_dependencies_value_term_RHS(3, ""); - set_dependencies_gradient_term_RHS(3, "n1, grad(u)"); - set_dependencies_value_term_LHS(3, ""); - set_dependencies_gradient_term_LHS(3, "n1, grad(change(u))"); -} - -// ============================================================================================= -// explicitEquationRHS (needed only if one or more equation is explict time -// dependent) -// ============================================================================================= -// This function calculates the right-hand-side of the explicit time-dependent -// equations for each variable. It takes "variable_list" as an input, which is a -// list of the value and derivatives of each of the variables at a specific -// quadrature point. The (x,y,z) location of that quadrature point is given by -// "q_point_loc". The function outputs two terms to variable_list -- one -// proportional to the test function and one proportional to the gradient of the -// test function. The index for each variable in this list corresponds to the -// index given at the top of this file. - -template -void -customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const -{ - // --- Getting the values and derivatives of the model variables --- - - // The concentration and its derivatives - scalarvalueType c = variable_list.get_scalar_value(0); - scalargradType cx = variable_list.get_scalar_gradient(0); - - // The first order parameter and its derivatives - scalarvalueType n1 = variable_list.get_scalar_value(1); - scalargradType n1x = variable_list.get_scalar_gradient(1); - - // The second order parameter and its derivatives - scalarvalueType n2 = variable_list.get_scalar_value(2); - scalargradType n2x = variable_list.get_scalar_gradient(2); - - // The third order parameter and its derivatives - scalarvalueType n3 = variable_list.get_scalar_value(3); - scalargradType n3x = variable_list.get_scalar_gradient(3); - - // The derivative of the displacement vector - vectorgradType ux = variable_list.get_vector_gradient(4); - - // --- Setting the expressions for the terms in the governing equations --- - - // --------------------------------------------------------------------- - // Nucleation section to seed nuclei and freeze the Allen-Cahn mobility - // --------------------------------------------------------------------- - dealii::AlignedVector> source_terms(3, constV(0.0)); - dealii::VectorizedArray gamma = constV(1.0); - seedNucleus(q_point_loc, source_terms, gamma); - // --------------------------------------------------------------------- - - // The interpolation functions and their derivatives - scalarvalueType h1V = (n1 * n1 * n1 * (10.0 - 15.0 * n1 + 6.0 * n1 * n1)); - scalarvalueType hn1V = (30.0 * (n1 - 1.0) * (n1 - 1.0) * n1 * n1); - scalarvalueType h2V = (n2 * n2 * n2 * (10.0 - 15.0 * n2 + 6.0 * n2 * n2)); - scalarvalueType hn2V = (30.0 * (n2 - 1.0) * (n2 - 1.0) * n2 * n2); - scalarvalueType h3V = (n3 * n3 * n3 * (10.0 - 15.0 * n3 + 6.0 * n3 * n3)); - scalarvalueType hn3V = (30.0 * (n3 - 1.0) * (n3 - 1.0) * n3 * n3); - - // Calculate c_alpha and c_beta from c - scalarvalueType sum_hpV = h1V + h2V + h3V; - scalarvalueType c_alpha = - ((B2 * c + 0.5 * (B1 - A1) * sum_hpV)) / (A2 * (sum_hpV) + B2 * (1.0 - sum_hpV)); - scalarvalueType c_beta = ((A2 * c + 0.5 * (A1 - B1) * (1.0 - sum_hpV)) / - (A2 * (sum_hpV) + B2 * (1.0 - sum_hpV))); - - // The free energy expressions and their derivatives - scalarvalueType faV = (A2 * c_alpha * c_alpha + A1 * c_alpha + A0); - scalarvalueType facV = (2.0 * A2 * c_alpha + A1); - scalarvalueType faccV = (constV(2.0) * A2); - scalarvalueType fbV = (B2 * c_beta * c_beta + B1 * c_beta + B0); - scalarvalueType fbcV = (2.0 * B2 * c_beta + B1); - scalarvalueType fbccV = (constV(2.0) * B2); - - // This double-well function can be used to tune the interfacial energy and - // its derivatives - scalarvalueType fbarrierV = - (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1 + n2 * n2 - 2.0 * n2 * n2 * n2 + - n2 * n2 * n2 * n2 + n3 * n3 - 2.0 * n3 * n3 * n3 + n3 * n3 * n3 * n3 + - 5.0 * (n1 * n1 * n2 * n2 + n1 * n1 * n3 * n3 + n2 * n2 * n3 * n3) + - 5.0 * n1 * n1 * n2 * n2 * n3 * n3); - scalarvalueType fbarriern1V = - (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1 + 10.0 * n1 * (n2 * n2 + n3 * n3) + - 10.0 * n1 * n2 * n2 * n3 * n3); - scalarvalueType fbarriern2V = - (2.0 * n2 - 6.0 * n2 * n2 + 4.0 * n2 * n2 * n2 + 10.0 * n2 * (n1 * n1 + n3 * n3) + - 10.0 * n2 * n1 * n1 * n3 * n3); - scalarvalueType fbarriern3V = - (2.0 * n3 - 6.0 * n3 * n3 + 4.0 * n3 * n3 * n3 + 10.0 * n3 * (n2 * n2 + n1 * n1) + - 10.0 * n3 * n2 * n2 * n1 * n1); - - // Calculate the derivatives of c_beta (derivatives of c_alpha aren't needed) - // Note: this section can be optimized to reduce recalculations (note: that - // doesn't change the performance) - scalarvalueType cbcV; - - cbcV = faccV / ((constV(1.0) - sum_hpV) * fbccV + (sum_hpV) *faccV); - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts2, sfts3; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c_beta + b_p - sfts1[i][j] = constV(sfts_const1[i][j]); - sfts2[i][j] = constV(sfts_const2[i][j]); - sfts3[i][j] = constV(sfts_const3[i][j]); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - // Compute stress tensor (which is equal to the residual, Rux) - computeStress(CIJ_Mg, E2, S); - - // Compute one of the stress terms in the order parameter chemical potential, - // nDependentMisfitACp = -C*(E-E0)*(E0_n) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); - - dealii::VectorizedArray E4[dim][dim]; // Intermediate variable - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - nDependentMisfitAC1 -= S[i][j] * (sfts1[i][j] * hn1V); - nDependentMisfitAC2 -= S[i][j] * (sfts2[i][j] * hn2V); - nDependentMisfitAC3 -= S[i][j] * (sfts3[i][j] * hn3V); - } - } - - // compute K*nx - scalargradType Knx1, Knx2, Knx3; - for (unsigned int a = 0; a < dim; a++) - { - Knx1[a] = 0.0; - Knx2[a] = 0.0; - Knx3[a] = 0.0; - for (unsigned int b = 0; b < dim; b++) - { - Knx1[a] += constV(Kn1[a][b]) * n1x[b]; - Knx2[a] += constV(Kn2[a][b]) * n2x[b]; - Knx3[a] += constV(Kn3[a][b]) * n3x[b]; - } - } - - // The terms in the governing equations - scalarvalueType eq_c = (c); - scalargradType eqx_c_temp = - (cx + (c_alpha - c_beta) * (hn1V * n1x + hn2V * n2x + hn3V * n3x)); - scalargradType eqx_c = (constV(-userInputs.dtValue) * McV * eqx_c_temp); - - scalarvalueType eq_n1 = (n1 - constV(userInputs.dtValue * Mn1V) * gamma * - ((fbV - faV) * hn1V - (c_beta - c_alpha) * facV * hn1V + - W * fbarriern1V + nDependentMisfitAC1)); - scalargradType eqx_n1 = (constV(-userInputs.dtValue * Mn1V) * gamma * Knx1); - - scalarvalueType eq_n2 = (n2 - constV(userInputs.dtValue * Mn2V) * gamma * - ((fbV - faV) * hn2V - (c_beta - c_alpha) * facV * hn2V + - W * fbarriern2V + nDependentMisfitAC2)); - scalargradType eqx_n2 = (constV(-userInputs.dtValue * Mn2V) * gamma * Knx2); - - scalarvalueType eq_n3 = (n3 - constV(userInputs.dtValue * Mn3V) * gamma * - ((fbV - faV) * hn3V - (c_beta - c_alpha) * facV * hn3V + - W * fbarriern3V + nDependentMisfitAC3)); - scalargradType eqx_n3 = (constV(-userInputs.dtValue * Mn3V) * gamma * Knx3); - - // --- Submitting the terms for the governing equations --- - - variable_list.set_scalar_value_term_RHS(0, eq_c); - variable_list.set_scalar_gradient_term_RHS(0, eqx_c); - - variable_list.set_scalar_value_term_RHS(1, eq_n1 + source_terms[0]); - variable_list.set_scalar_gradient_term_RHS(1, eqx_n1); - - variable_list.set_scalar_value_term_RHS(2, eq_n2 + source_terms[1]); - variable_list.set_scalar_gradient_term_RHS(2, eqx_n2); - - variable_list.set_scalar_value_term_RHS(3, eq_n3 + source_terms[2]); - variable_list.set_scalar_gradient_term_RHS(3, eqx_n2); -} - -// ================================================================================= -// seedNucleus: a function particular to this app -// ================================================================================= -template -void -customPDE::seedNucleus( - const dealii::Point> &q_point_loc, - // std::vector > & source_terms, - dealii::AlignedVector> &source_terms, - dealii::VectorizedArray &gamma) const -{ - for (typename std::vector>::const_iterator thisNucleus = - this->nuclei.begin(); - thisNucleus != this->nuclei.end(); - ++thisNucleus) - { - if (thisNucleus->seededTime + thisNucleus->seedingTime > this->currentTime) - { - // Calculate the weighted distance function to the order parameter - // freeze boundary (weighted_dist = 1.0 on that boundary) - dealii::VectorizedArray weighted_dist = - this->weightedDistanceFromNucleusCenter( - thisNucleus->center, - userInputs.get_nucleus_freeze_semiaxes(thisNucleus->orderParameterIndex), - userInputs.get_nucleus_rotation_matrix(thisNucleus->orderParameterIndex), - q_point_loc, - thisNucleus->orderParameterIndex); - - for (unsigned i = 0; i < gamma.size(); i++) - { - if (weighted_dist[i] <= 1.0) - { - gamma[i] = 0.0; - - // Seed a nucleus if it was added to the list of nuclei this - // time step - if (thisNucleus->seedingTimestep == this->currentIncrement) - { - // Set the rotation matrix for this nucleus (two possible - // per order parameter) - dealii::Tensor<2, dim, double> nucleus_rot_matrix; - nucleus_rot_matrix = userInputs.get_nucleus_rotation_matrix( - thisNucleus->orderParameterIndex); - - // Find the weighted distance to the outer edge of the - // nucleus and use it to calculate the order parameter - // source term (r = 1.0 on that boundary) - dealii::Point q_point_loc_element; - for (unsigned int j = 0; j < dim; j++) - { - q_point_loc_element(j) = q_point_loc(j)[i]; - } - double r = this->weightedDistanceFromNucleusCenter( - thisNucleus->center, - userInputs.get_nucleus_semiaxes(thisNucleus->orderParameterIndex), - nucleus_rot_matrix, - q_point_loc_element, - thisNucleus->orderParameterIndex); - - double avg_semiaxis = 0.0; - for (unsigned int j = 0; j < dim; j++) - { - avg_semiaxis += thisNucleus->semiaxes[j]; - } - avg_semiaxis /= dim; - - if (thisNucleus->orderParameterIndex == 1) - { - source_terms[0][i] = - 0.5 * - (1.0 - std::tanh(avg_semiaxis * (r - 1.0) / interface_coeff)); - } - else if (thisNucleus->orderParameterIndex == 2) - { - source_terms[1][i] = - 0.5 * - (1.0 - std::tanh(avg_semiaxis * (r - 1.0) / interface_coeff)); - } - else - { - source_terms[2][i] = - 0.5 * - (1.0 - std::tanh(avg_semiaxis * (r - 1.0) / interface_coeff)); - } - } - } - } - } - } -} - -// ============================================================================================= -// nonExplicitEquationRHS (needed only if one or more equation is time -// independent or auxiliary) -// ============================================================================================= -// This function calculates the right-hand-side of all of the equations that are -// not explicit time-dependent equations. It takes "variable_list" as an input, -// which is a list of the value and derivatives of each of the variables at a -// specific quadrature point. The (x,y,z) location of that quadrature point is -// given by "q_point_loc". The function outputs two terms to variable_list -- -// one proportional to the test function and one proportional to the gradient of -// the test function. The index for each variable in this list corresponds to -// the index given at the top of this file. - -template -void -customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const -{ - // --- Getting the values and derivatives of the model variables --- - - // The first order parameter and its derivatives - scalarvalueType n1 = variable_list.get_scalar_value(1); - - // The second order parameter and its derivatives - scalarvalueType n2 = variable_list.get_scalar_value(2); - - // The third order parameter and its derivatives - scalarvalueType n3 = variable_list.get_scalar_value(3); - - // The derivative of the displacement vector - vectorgradType ux = variable_list.get_vector_gradient(4); - - // --- Setting the expressions for the terms in the governing equations --- - - // The interpolation functions and their derivatives - scalarvalueType h1V = (n1 * n1 * n1 * (10.0 - 15.0 * n1 + 6.0 * n1 * n1)); - scalarvalueType h2V = (n2 * n2 * n2 * (10.0 - 15.0 * n2 + 6.0 * n2 * n2)); - scalarvalueType h3V = (n3 * n3 * n3 * (10.0 - 15.0 * n3 + 6.0 * n3 * n3)); - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts2, sfts3; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c_beta + b_p - sfts1[i][j] = constV(sfts_const1[i][j]); - sfts2[i][j] = constV(sfts_const2[i][j]); - sfts3[i][j] = constV(sfts_const3[i][j]); - } - } - - vectorgradType eqx_u; - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - // Compute stress tensor (which is equal to the residual, Rux) - computeStress(CIJ_Mg, E2, S); - - // Fill residual corresponding to mechanics - // R=-C*(E-E0) - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - eqx_u[i][j] = -S[i][j]; - } - } - - // --- Submitting the terms for the governing equations --- - - variable_list.set_vector_gradient_term_RHS(4, eqx_u); -} - -// ============================================================================================= -// equationLHS (needed only if at least one equation is time independent) -// ============================================================================================= -// This function calculates the left-hand-side of time-independent equations. It -// takes "variable_list" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs two terms to variable_list -- one proportional to the test -// function and one proportional to the gradient of the test function -- for the -// left-hand-side of the equation. The index for each variable in this list -// corresponds to the index given at the top of this file. If there are multiple -// elliptic equations, conditional statements should be sed to ensure that the -// correct residual is being submitted. The index of the field being solved can -// be accessed by "this->currentFieldIndex". - -template -void -customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const -{ - // --- Getting the values and derivatives of the model variables --- - - // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the - // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E = - symmetrize(variable_list.get_change_in_vector_gradient(4)); - - // --- Setting the expressions for the terms in the governing equations --- - - vectorgradType eqx_Du; - - // Compute stress tensor (which is equal to eqx_Du) - computeStress(CIJ_Mg, E, eqx_Du); - - variable_list.set_vector_gradient_term_LHS(4, eqx_Du); -} -} diff --git a/applications/_nucleating_precipitates_MgRE/main.cc b/applications/_nucleating_precipitates_MgRE/main.cc deleted file mode 100644 index d082eaa8f..000000000 --- a/applications/_nucleating_precipitates_MgRE/main.cc +++ /dev/null @@ -1,167 +0,0 @@ -// Allen-Cahn example application - -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.h" -#include "equations.h" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.h" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.h" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/_nucleating_precipitates_MgRE/nucleation.h b/applications/_nucleating_precipitates_MgRE/nucleation.h deleted file mode 100644 index e4e97c6b9..000000000 --- a/applications/_nucleating_precipitates_MgRE/nucleation.h +++ /dev/null @@ -1,30 +0,0 @@ -// ================================================================================= -// NUCLEATION FUNCTIONS -// ================================================================================= - -// ================================================================================= -// Nucleation probability -// ================================================================================= - -template -double -customPDE::getNucleationProbability(variableValueContainer variable_value, - double dV, - dealii::Point p, - unsigned int variable_index) const -{ - // Supersaturation factor - double ssf; - double calmin = 0.0001; - if (dim == 2) - ssf = variable_value(0) - calmin; - if (dim == 3) - ssf = (variable_value(0) - calmin) * (variable_value(0) - calmin); - // Calculate the nucleation rate - double J = k1 * exp(-k2 / (std::max(ssf, 1.0e-6))) * exp(-tau / (this->currentTime)); - double retProb = - 1.0 - exp(-J * userInputs.dtValue * - ((double) userInputs.steps_between_nucleation_attempts) * dV); - - return retProb; -} diff --git a/applications/_nucleating_precipitates_MgRE/parameters.prm b/applications/_nucleating_precipitates_MgRE/parameters.prm deleted file mode 100644 index 5600c702a..000000000 --- a/applications/_nucleating_precipitates_MgRE/parameters.prm +++ /dev/null @@ -1,205 +0,0 @@ -# Parameter list for the Mg-RE precipitate nucleation application - -# Refer to the PRISMS-PF manual for use of these parameters in the source code. - -# ================================================================================= -# Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -# ================================================================================= -set Number of dimensions = 2 - -# ================================================================================= -# Set the length of the domain in all three dimensions -# ================================================================================= -# Each axes spans from zero to the specified length -set Domain size X = 100.0 -set Domain size Y = 100.0 -set Domain size Z = 100.0 - -# ================================================================================= -# Set the element parameters -# ================================================================================= -# The number of elements in each direction is 2^(refineFactor) * subdivisions -# For optimal performance, use refineFactor primarily to determine the element size -set Subdivisions X = 3 -set Subdivisions Y = 3 -set Subdivisions Z = 3 - -set Refine factor = 1 - -# Set the polynomial degree of the element (allowed values: 1, 2, or 3) -set Element degree = 2 - -# ================================================================================= -# Set the adaptive mesh refinement parameters -# ================================================================================= -# Set the flag determining if adaptive meshing is activated -set Mesh adaptivity = true - -# Set the maximum and minimum level of refinement -set Max refinement level = 7 -set Min refinement level = 1 - -# Set the fields used to determine the refinement using their index. -set Refinement criteria fields = n1,n2,n3 - -# Set the maximum and minimum value of the fields where the mesh should be refined -set Refinement window max = 0.9995,0.9995,0.9995 -set Refinement window min = 0.0005,0.0005,0.0005 - -# Set the number of time steps between remeshing operations -set Steps between remeshing operations = 5000 - -# ================================================================================= -# Set the time step parameters -# ================================================================================= -# The size of the time step -set Time step = 0.00125 - -# The simulation ends when either the number of time steps is reached or the -# simulation time is reached. - -set Number of time steps = 500000 - -# ================================================================================= -# Set the elliptic solver parameters -# ================================================================================= -# The solver type (currently the only recommended option is conjugate gradient) -set Linear solver = SolverCG - -# The flag that determines whether the tolerance for solver convergence should -# be an absolute tolerance or a relative tolerance -set Use absolute convergence tolerance = true - -# The tolerance for convergence (L2 norm of the residual) -set Solver tolerance value = 5.0e-3 - -# The maximum number of solver iterations per time step -set Maximum allowed solver iterations = 10000 - -# ================================================================================= -# Set the output parameters -# ================================================================================= -# Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", "N_PER_DECADE", -# or "LIST") -set Output condition = EQUAL_SPACING - -# Number of times the program outputs the fields (total number for "EQUAL_SPACING" -# and "LOG_SPACING", number per decade for "N_PER_DECADE", ignored for "LIST") -set Number of outputs = 100 - -# The number of time steps between updates being printed to the screen -set Skip print steps = 1000 - -# ================================================================================= -# Set the checkpoint/restart parameters -# ================================================================================= - -set Load from a checkpoint = false -set Checkpoint condition = EQUAL_SPACING -set Number of checkpoints = 10 - -# ================================================================================= -# Set the nucleation parameters -# ================================================================================= - -set Time steps between nucleation attempts = 2000 -set Minimum allowed distance between nuclei = 10.0 -set Order parameter cutoff value = 0.01 - -subsection Nucleation parameters: n1 - set Nucleus semiaxes (x, y, z) = 2, 3, 10 - set Nucleus rotation in degrees (x, y, z) = 0, 0, 0 - set Freeze zone semiaxes (x, y, z) = 6, 6, 20 - set Freeze time following nucleation = 25.0 - set Nucleation-free border thickness = 3.0 -end - -subsection Nucleation parameters: n2 - set Nucleus semiaxes (x, y, z) = 2, 3, 10 - set Nucleus rotation in degrees (x, y, z) = 0, 0, 120 - set Freeze zone semiaxes (x, y, z) = 6, 6, 20 - set Freeze time following nucleation = 25.0 - set Nucleation-free border thickness = 3.0 -end - -subsection Nucleation parameters: n3 - set Nucleus semiaxes (x, y, z) = 2, 3, 10 - set Nucleus rotation in degrees (x, y, z) = 0, 0, -120 - set Freeze zone semiaxes (x, y, z) = 6, 6, 20 - set Freeze time following nucleation = 25.0 - set Nucleation-free border thickness = 3.0 -end - -# ================================================================================= -# Set the boundary conditions -# ================================================================================= - -set Boundary condition for variable c = PERIODIC -set Boundary condition for variable n1 = PERIODIC -set Boundary condition for variable n2 = PERIODIC -set Boundary condition for variable n3 = PERIODIC -set Boundary condition for variable u, x component = PERIODIC -set Boundary condition for variable u, y component = PERIODIC -set Boundary condition for variable u, z component = PERIODIC - -# ================================================================================= -# Set the model constants -# ================================================================================= -# Type options currently are double, int, bool, and tensor - -# McV, the Cahn-Hilliard mobility -set Model constant McV = 1.0, double - -# Mn1V, Mn2V, and Mn3V, the Allen-Cahn mobilities -set Model constant Mn1V = 8.0, double #0.0125, double -set Model constant Mn2V = 8.0, double #0.0125, double -set Model constant Mn3V = 8.0, double #0.0125, double - -# Kn1, Kn2, and Kn3, the gradient energy coefficients -set Model constant Kn1 = ((0.0341,0,0),(0,0.0341,0),(0,0,0.0341)), tensor # l* = 1 nm -set Model constant Kn2 = ((0.0341,0,0),(0,0.0341,0),(0,0,0.0341)), tensor # l* = 1 nm -set Model constant Kn3 = ((0.0341,0,0),(0,0.0341,0),(0,0,0.0341)), tensor # l* = 1 nm - -# W, the energy barrier coefficient -set Model constant W = 0.33, double - -# Whether or not the elastic constants depend on the order parameters -set Model constant n_dependent_stiffness = false, bool - -# Stress free transformation strain tensor for order parameter 1 -set Model constant sfts_const1 = ((0.1,0,0),(0,0,0),(0,0,0)), tensor - -# Stress free transformation strain tensor for order parameter 2 -set Model constant sfts_const2 = ((0.025,0.04330,0),(0.04330,0.075,0),(0,0,0)), tensor - -# Stress free transformation strain tensor for order parameter 3 -set Model constant sfts_const3 = ((0.025,-0.04330,0),(-0.04330,0.075,0),(0,0,0)), tensor - -# A2, A1, and A0 Mg-Nd matrix free energy parameters -set Model constant A2 = 160, double -set Model constant A1 = -0.032, double -set Model constant A0 = 16.0e-7, double - -# B2, B1, and B0 Mg-Nd B1 precipitate free energy parameters -set Model constant B2 = 160.0, double -set Model constant B1 = -80.0, double -set Model constant B0 = 10.0, double - -# Elastic constants (for the matrix and each precipitate orientation variant) -set Model constant CIJ_Mg = (31.3,31.3,32.45,6.65,6.65,9.15,13.0,10.45,0,0,0,10.45,0,0,0,0,0,0,0,0,0), anisotropic elastic constants -set Model constant CIJ_Beta1 = (31.3,31.3,32.45,6.65,6.65,9.15,13.0,10.45,0,0,0,10.45,0,0,0,0,0,0,0,0,0), anisotropic elastic constants -set Model constant CIJ_Beta2 = (31.3,31.3,32.45,6.65,6.65,9.15,13.0,10.45,0,0,0,10.45,0,0,0,0,0,0,0,0,0), anisotropic elastic constants -set Model constant CIJ_Beta3 = (31.3,31.3,32.45,6.65,6.65,9.15,13.0,10.45,0,0,0,10.45,0,0,0,0,0,0,0,0,0), anisotropic elastic constants - -# Nucleation parameters: -# Coefficient that controls the initial interfacial thickness of a seeded nucleus -set Model constant interface_coeff = 0.6, double - -# Pre-exponential coefficient for the nucleation rate -set Model constant k1 = 5e-6 , double - -# Coefficient for the nucleation rate in the exponential -set Model constant k2 = 0.01, double - -# Nucleation incubation time -set Model constant tau = 1.0e1 , double diff --git a/applications/_nucleating_precipitates_MgRE/postprocess.h b/applications/_nucleating_precipitates_MgRE/postprocess.h deleted file mode 100644 index cdbbf24b8..000000000 --- a/applications/_nucleating_precipitates_MgRE/postprocess.h +++ /dev/null @@ -1,247 +0,0 @@ -// ============================================================================================= -// loadPostProcessorVariableAttributes: Set the attributes of the postprocessing -// variables -// ============================================================================================= -// This function is analogous to 'loadVariableAttributes' in 'equations.h', but -// for the postprocessing expressions. It sets the attributes for each -// postprocessing expression, including its name, whether it is a vector or -// scalar (only scalars are supported at present), its dependencies on other -// variables and their derivatives, and whether to calculate an integral of the -// postprocessed quantity over the entire domain. Note: this function is not a -// member of customPDE. - -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{ - // Variable 0 - set_variable_name(0, "f_tot"); - set_variable_type(0, SCALAR); - - set_dependencies_value_term_RHS(0, - "c, n1, grad(n1), n2, grad(n2), n2, grad(n3), grad(u)"); - set_dependencies_gradient_term_RHS(0, ""); - - set_output_integral(0, true); - - // Variable 1 - set_variable_name(1, "f_el"); - set_variable_type(1, SCALAR); - - set_dependencies_value_term_RHS(0, "grad(u)"); - set_dependencies_gradient_term_RHS(0, ""); - - set_output_integral(1, false); - - // Variable 2 - set_variable_name(2, "von_mises_stress"); - set_variable_type(2, SCALAR); - - set_dependencies_value_term_RHS(0, "grad(u)"); - set_dependencies_gradient_term_RHS(0, ""); - - set_output_integral(2, false); -} - -// ============================================================================================= -// postProcessedFields: Set the postprocessing expressions -// ============================================================================================= -// This function is analogous to 'explicitEquationRHS' and -// 'nonExplicitEquationRHS' in equations.h. It takes in "variable_list" and -// "q_point_loc" as inputs and outputs two terms in the expression for the -// postprocessing variable -- one proportional to the test function and one -// proportional to the gradient of the test function. The index for each -// variable in this list corresponds to the index given at the top of this file -// (for submitting the terms) and the index in 'equations.h' for assigning the -// values/derivatives of the primary variables. - -template -void -customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const -{ - // --- Getting the values and derivatives of the model variables --- - - // The concentration and its derivatives - scalarvalueType c = variable_list.get_scalar_value(0); - - // The first order parameter and its derivatives - scalarvalueType n1 = variable_list.get_scalar_value(1); - scalargradType n1x = variable_list.get_scalar_gradient(1); - - // The second order parameter and its derivatives - scalarvalueType n2 = variable_list.get_scalar_value(2); - scalargradType n2x = variable_list.get_scalar_gradient(2); - - // The third order parameter and its derivatives - scalarvalueType n3 = variable_list.get_scalar_value(3); - scalargradType n3x = variable_list.get_scalar_gradient(3); - - // The derivative of the displacement vector - vectorgradType ux = variable_list.get_vector_gradient(4); - - // The interpolation functions and their derivatives - scalarvalueType h1V = (n1 * n1 * n1 * (10.0 - 15.0 * n1 + 6.0 * n1 * n1)); - scalarvalueType hn1V = (30.0 * (n1 - 1.0) * (n1 - 1.0) * n1 * n1); - scalarvalueType h2V = (n2 * n2 * n2 * (10.0 - 15.0 * n2 + 6.0 * n2 * n2)); - scalarvalueType hn2V = (30.0 * (n2 - 1.0) * (n2 - 1.0) * n2 * n2); - scalarvalueType h3V = (n3 * n3 * n3 * (10.0 - 15.0 * n3 + 6.0 * n3 * n3)); - scalarvalueType hn3V = (30.0 * (n3 - 1.0) * (n3 - 1.0) * n3 * n3); - - scalarvalueType sum_hpV = h1V + h2V + h3V; - scalarvalueType c_alpha = - ((B2 * c + 0.5 * (B1 - A1) * sum_hpV)) / (A2 * (sum_hpV) + B2 * (1.0 - sum_hpV)); - scalarvalueType c_beta = ((A2 * c + 0.5 * (A1 - B1) * (1.0 - sum_hpV)) / - (A2 * (sum_hpV) + B2 * (1.0 - sum_hpV))); - - // The free energy expressions and their derivatives - scalarvalueType faV = (A2 * c_alpha * c_alpha + A1 * c_alpha + A0); - scalarvalueType facV = (2.0 * A2 * c_alpha + A1); - scalarvalueType faccV = (constV(2.0) * A2); - scalarvalueType fbV = (B2 * c_beta * c_beta + B1 * c_beta + B0); - scalarvalueType fbcV = (2.0 * B2 * c_beta + B1); - scalarvalueType fbccV = (constV(2.0) * B2); - - // This double-well function can be used to tune the interfacial energy and - // its derivatives - scalarvalueType fbarrierV = - (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1 + n2 * n2 - 2.0 * n2 * n2 * n2 + - n2 * n2 * n2 * n2 + n3 * n3 - 2.0 * n3 * n3 * n3 + n3 * n3 * n3 * n3 + - 5.0 * (n1 * n1 * n2 * n2 + n1 * n1 * n3 * n3 + n2 * n2 * n3 * n3) + - 5.0 * n1 * n1 * n2 * n2 * n3 * n3); - scalarvalueType fbarriern1V = - (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1 + 10.0 * n1 * (n2 * n2 + n3 * n3) + - 10.0 * n1 * n2 * n2 * n3 * n3); - scalarvalueType fbarriern2V = - (2.0 * n2 - 6.0 * n2 * n2 + 4.0 * n2 * n2 * n2 + 10.0 * n2 * (n1 * n1 + n3 * n3) + - 10.0 * n2 * n1 * n1 * n3 * n3); - scalarvalueType fbarriern3V = - (2.0 * n3 - 6.0 * n3 * n3 + 4.0 * n3 * n3 * n3 + 10.0 * n3 * (n2 * n2 + n1 * n1) + - 10.0 * n3 * n2 * n2 * n1 * n1); - - // Calculate the derivatives of c_beta (derivatives of c_alpha aren't needed) - // Note: this section can be optimized to reduce recalculations - scalarvalueType cbn1V, cbn2V, cbn3V, cbcV, cbcn1V, cbcn2V, cbcn3V, cacV; - - cbcV = faccV / ((constV(1.0) - sum_hpV) * fbccV + (sum_hpV) *faccV); - cacV = fbccV / ((constV(1.0) - sum_hpV) * fbccV + (sum_hpV) *faccV); - - cbn1V = hn1V * (c_alpha - c_beta) * cbcV; - cbn2V = hn2V * (c_alpha - c_beta) * cbcV; - cbn3V = hn3V * (c_alpha - c_beta) * cbcV; - - cbcn1V = (faccV * (fbccV - faccV) * hn1V) / - (((1.0 - sum_hpV) * fbccV + sum_hpV * faccV) * - ((1.0 - sum_hpV) * fbccV + - sum_hpV * faccV)); // Note: this is only true if faV and fbV are quadratic - cbcn2V = (faccV * (fbccV - faccV) * hn2V) / - (((1.0 - sum_hpV) * fbccV + sum_hpV * faccV) * - ((1.0 - sum_hpV) * fbccV + - sum_hpV * faccV)); // Note: this is only true if faV and fbV are quadratic - cbcn3V = (faccV * (fbccV - faccV) * hn3V) / - (((1.0 - sum_hpV) * fbccV + sum_hpV * faccV) * - ((1.0 - sum_hpV) * fbccV + - sum_hpV * faccV)); // Note: this is only true if faV and fbV are quadratic - - scalarvalueType f_chem = - (constV(1.0) - (h1V + h2V + h3V)) * faV + (h1V + h2V + h3V) * fbV + W * (fbarrierV); - - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn1[i][j]) * n1x[i] * n1x[j] + - constV(0.5 * Kn2[i][j]) * n2x[i] * n2x[j] + - constV(0.5 * Kn3[i][j]) * n3x[i] * n3x[j]; - } - } - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, - sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c_beta + b_p - sfts1[i][j] = constV(sfts_const1[i][j]); - sfts2[i][j] = constV(sfts_const2[i][j]); - sfts3[i][j] = constV(sfts_const3[i][j]); - } - } - - // compute E2=(E-E0) - scalarvalueType E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - scalarvalueType CIJ_combined[2 * dim - 1 + dim / 3][2 * dim - 1 + dim / 3]; - - if (n_dependent_stiffness == true) - { - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = CIJ_Mg[i][j] * (constV(1.0) - sum_hpV) + - CIJ_Beta1[i][j] * (h1V) + CIJ_Beta2[i][j] * (h2V) + - CIJ_Beta3[i][j] * (h3V); - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_Mg, E2, S); - } - - dealii::VectorizedArray f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E2[i][j]; - } - } - - scalarvalueType total_energy_density = f_chem + f_grad + f_el; - - dealii::VectorizedArray vm_stress; - if (dim == 3) - { - vm_stress = (S[0][0] - S[1][1]) * (S[0][0] - S[1][1]) + - (S[1][1] - S[2][2]) * (S[1][1] - S[2][2]) + - (S[2][2] - S[0][0]) * (S[2][2] - S[0][0]); - vm_stress += - constV(6.0) * (S[0][1] * S[0][1] + S[1][2] * S[1][2] + S[2][0] * S[2][0]); - vm_stress *= constV(0.5); - vm_stress = std::sqrt(vm_stress); - } - else - { - vm_stress = S[0][0] * S[0][0] - S[0][0] * S[1][1] + S[1][1] * S[1][1] + - constV(3.0) * S[0][1] * S[0][1]; - vm_stress = std::sqrt(vm_stress); - } - - // --- Submitting the terms for the postprocessing expressions --- - pp_variable_list.set_scalar_value_term_RHS(0, total_energy_density); - pp_variable_list.set_scalar_value_term_RHS(1, f_el); - pp_variable_list.set_scalar_value_term_RHS(2, vm_stress); -} diff --git a/applications/allenCahn/CMakeLists.txt b/applications/allenCahn/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/allenCahn/CMakeLists.txt +++ b/applications/allenCahn/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/allenCahn/ICs_and_BCs.cc b/applications/allenCahn/ICs_and_BCs.cc index 377509e4d..e68550084 100644 --- a/applications/allenCahn/ICs_and_BCs.cc +++ b/applications/allenCahn/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -61,12 +61,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/allenCahn/allenCahn.md b/applications/allenCahn/allenCahn.md new file mode 100644 index 000000000..d1b3d01cf --- /dev/null +++ b/applications/allenCahn/allenCahn.md @@ -0,0 +1,75 @@ +## PRISMS-PF: Allen-Cahn Dynamics +Consider a free energy expression of the form: + +$$ +\begin{align} +\Pi(\eta, \nabla \eta) = \int_{\Omega} f(\eta) + \frac{\kappa}{2} \nabla \eta \cdot \nabla \eta ~dV +\end{align} +$$ + +where $\eta$ is the structural order parameter, and $\kappa$ is the gradient length scale parameter. + +### Variational treatment +Considering variations on the primal field $\eta$ of the from $\eta+\epsilon w$, we have + +$$ +\begin{align} +\delta \Pi &= \left. \frac{d}{d\epsilon} \int_{\Omega} f(\eta+\epsilon w) + \frac{\kappa}{2} \nabla (\eta+\epsilon w) \cdot ~\nabla (\eta+\epsilon w) ~dV \right\vert_{\epsilon=0} \\ +&= \int_{\Omega} w f_{,\eta} + \kappa \nabla w \nabla \eta ~dV \\ +&= \int_{\Omega} w \left( f_{,\eta} - \kappa \Delta \eta \right) ~dV + \int_{\partial \Omega} w \kappa \nabla \eta \cdot n ~dS +\end{align} +$$ + +Assuming $\kappa \nabla \eta \cdot n = 0$, and using standard variational arguments on the equation $\delta \Pi =0$, we have the expression for chemical potential as + +$$ +\begin{align} +\mu = f_{,\eta} - \kappa \Delta \eta +\end{align} +$$ + +## Kinetics +Now the parabolic PDE for Allen-Cahn dynamics is given by: + +$$ +\begin{align} +\frac{\partial \eta}{\partial t} = -M(f_{,\eta} - \kappa \Delta \eta) +\end{align} +$$ + +where $M$ is the constant mobility. + +## Time discretization + +Considering forward Euler explicit time stepping, we have the time discretized kinetics equation: + +$$ +\begin{align} +\eta^{n+1} = \eta^{n} - \Delta t M(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) +\end{align} +$$ + +## Weak formulation + +In the weak formulation, considering an arbitrary variation $w$, the above equation can be expressed as a residual equation: + +$$ +\begin{align} +\int_{\Omega} w \eta^{n+1} ~dV &= \int_{\Omega} w \eta^{n} - w \Delta t M(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) ~dV \\ +&= \int_{\Omega} w \left( \eta^{n} - \Delta t M f_{,\eta}^{n} \right) + \nabla w (-\Delta t M \kappa) \cdot (\nabla \eta^{n}) ~dV \quad [\kappa \nabla \eta \cdot n = 0 \quad \text{on} \quad \partial \Omega] +\end{align} +$$ + +$$ +\begin{align} +r_{\eta}= \eta^{n} - \Delta t M f_{,\eta}^{n} +\end{align} +$$ + +$$ +\begin{align} +r_{\eta x} = -\Delta t M \kappa\nabla \eta^{n} +\end{align} +$$ + +The above values of $r_{\eta}$ and $r_{\eta x}$ are used to define the residuals in `applications/allenCahn/equations.cc`. \ No newline at end of file diff --git a/applications/allenCahn/allenCahn.pdf b/applications/allenCahn/allenCahn.pdf deleted file mode 100644 index ec837ec26..000000000 Binary files a/applications/allenCahn/allenCahn.pdf and /dev/null differ diff --git a/applications/allenCahn/customPDE.h b/applications/allenCahn/customPDE.h index 450e14e3f..8a08cc33e 100644 --- a/applications/allenCahn/customPDE.h +++ b/applications/allenCahn/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.cc) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.cc) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.cc) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/allenCahn/equations.cc b/applications/allenCahn/equations.cc index 8959e7473..9ba53a23d 100644 --- a/applications/allenCahn/equations.cc +++ b/applications/allenCahn/equations.cc @@ -41,8 +41,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -78,8 +79,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -100,6 +102,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/allenCahn/main.cc b/applications/allenCahn/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/allenCahn/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/allenCahn/postprocess.cc b/applications/allenCahn/postprocess.cc index a35864785..9dc68bc25 100644 --- a/applications/allenCahn/postprocess.cc +++ b/applications/allenCahn/postprocess.cc @@ -45,9 +45,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/allenCahn/tex_files/allenCahn.tex b/applications/allenCahn/tex_files/allenCahn.tex deleted file mode 100644 index c396538bb..000000000 --- a/applications/allenCahn/tex_files/allenCahn.tex +++ /dev/null @@ -1,223 +0,0 @@ -\documentclass[10pt]{article} -\usepackage{amsmath} -\usepackage{bm} -\usepackage{bbm} -\usepackage{mathrsfs} -\usepackage{graphicx} -\usepackage{wrapfig} -\usepackage{subcaption} -\usepackage{epsfig} -\usepackage{amsfonts} -\usepackage{amssymb} -\usepackage{amsmath} -\usepackage{wrapfig} -\usepackage{graphicx} -\usepackage{psfrag} -\newcommand{\sun}{\ensuremath{\odot}} % sun symbol is \sun -\let\vaccent=\v % rename builtin command \v{} to \vaccent{} -\renewcommand{\v}[1]{\ensuremath{\mathbf{#1}}} % for vectors -\newcommand{\gv}[1]{\ensuremath{\mbox{\boldmath$ #1 $}}} -\newcommand{\grad}[1]{\gv{\nabla} #1} -\renewcommand{\baselinestretch}{1.2} -\jot 5mm -\graphicspath{{./figures/}} -%text dimensions -\textwidth 6.5 in -\oddsidemargin .2 in -\topmargin -0.2 in -\textheight 8.5 in -\headheight 0.2in -\overfullrule = 0pt -\pagestyle{plain} -\def\newpar{\par\vskip 0.5cm} -\begin{document} -% -%---------------------------------------------------------------------- -% Define symbols -%---------------------------------------------------------------------- -% -\def\iso{\mathbbm{1}} -\def\half{{\textstyle{1 \over 2}}} -\def\third{{\textstyle{1 \over 3}}} -\def\fourth{{\textstyle{{1 \over 4}}}} -\def\twothird{{\textstyle {{2 \over 3}}}} -\def\ndim{{n_{\rm dim}}} -\def\nint{n_{\rm int}} -\def\lint{l_{\rm int}} -\def\nel{n_{\rm el}} -\def\nf{n_{\rm f}} -\def\DIV {\hbox{\af div}} -\def\GRAD{\hbox{\af Grad}} -\def\sym{\mathop{\rm sym}\nolimits} -\def\tr{\mathop{\rm tr}\nolimits} -\def\dev{\mathop{\rm dev}\nolimits} -\def\Dev{\mathop{\rm Dev}\nolimits} -\def\DEV{\mathop {\rm DEV}\nolimits} -\def\bfb {{\bi b}} -\def\Bnabla{\nabla} -\def\bG{{\bi G}} -\def\jmpdelu{{\lbrack\!\lbrack \Delta u\rbrack\!\rbrack}} -\def\jmpudot{{\lbrack\!\lbrack\dot u\rbrack\!\rbrack}} -\def\jmpu{{\lbrack\!\lbrack u\rbrack\!\rbrack}} -\def\jmphi{{\lbrack\!\lbrack\varphi\rbrack\!\rbrack}} -\def\ljmp{{\lbrack\!\lbrack}} -\def\rjmp{{\rbrack\!\rbrack}} -\def\sign{{\rm sign}} -\def\nn{{n+1}} -\def\na{{n+\vartheta}} -\def\nna{{n+(1-\vartheta)}} -\def\nt{{n+{1\over 2}}} -\def\nb{{n+\beta}} -\def\nbb{{n+(1-\beta)}} -%--------------------------------------------------------- -% Bold Face Math Characters: -% All In Format: \B***** . -%--------------------------------------------------------- -\def\bOne{\mbox{\boldmath$1$}} -\def\BGamma{\mbox{\boldmath$\Gamma$}} -\def\BDelta{\mbox{\boldmath$\Delta$}} -\def\BTheta{\mbox{\boldmath$\Theta$}} -\def\BLambda{\mbox{\boldmath$\Lambda$}} -\def\BXi{\mbox{\boldmath$\Xi$}} -\def\BPi{\mbox{\boldmath$\Pi$}} -\def\BSigma{\mbox{\boldmath$\Sigma$}} -\def\BUpsilon{\mbox{\boldmath$\Upsilon$}} -\def\BPhi{\mbox{\boldmath$\Phi$}} -\def\BPsi{\mbox{\boldmath$\Psi$}} -\def\BOmega{\mbox{\boldmath$\Omega$}} -\def\Balpha{\mbox{\boldmath$\alpha$}} -\def\Bbeta{\mbox{\boldmath$\beta$}} -\def\Bgamma{\mbox{\boldmath$\gamma$}} -\def\Bdelta{\mbox{\boldmath$\delta$}} -\def\Bepsilon{\mbox{\boldmath$\epsilon$}} -\def\Bzeta{\mbox{\boldmath$\zeta$}} -\def\Beta{\mbox{\boldmath$\eta$}} -\def\Btheta{\mbox{\boldmath$\theta$}} -\def\Biota{\mbox{\boldmath$\iota$}} -\def\Bkappa{\mbox{\boldmath$\kappa$}} -\def\Blambda{\mbox{\boldmath$\lambda$}} -\def\Bmu{\mbox{\boldmath$\mu$}} -\def\Bnu{\mbox{\boldmath$\nu$}} -\def\Bxi{\mbox{\boldmath$\xi$}} -\def\Bpi{\mbox{\boldmath$\pi$}} -\def\Brho{\mbox{\boldmath$\rho$}} -\def\Bsigma{\mbox{\boldmath$\sigma$}} -\def\Btau{\mbox{\boldmath$\tau$}} -\def\Bupsilon{\mbox{\boldmath$\upsilon$}} -\def\Bphi{\mbox{\boldmath$\phi$}} -\def\Bchi{\mbox{\boldmath$\chi$}} -\def\Bpsi{\mbox{\boldmath$\psi$}} -\def\Bomega{\mbox{\boldmath$\omega$}} -\def\Bvarepsilon{\mbox{\boldmath$\varepsilon$}} -\def\Bvartheta{\mbox{\boldmath$\vartheta$}} -\def\Bvarpi{\mbox{\boldmath$\varpi$}} -\def\Bvarrho{\mbox{\boldmath$\varrho$}} -\def\Bvarsigma{\mbox{\boldmath$\varsigma$}} -\def\Bvarphi{\mbox{\boldmath$\varphi$}} -\def\bone{\mathbf{1}} -\def\bzero{\mathbf{0}} -%--------------------------------------------------------- -% Bold Face Math Italic: -% All In Format: \b* . -%--------------------------------------------------------- -\def\bA{\mbox{\boldmath$ A$}} -\def\bB{\mbox{\boldmath$ B$}} -\def\bC{\mbox{\boldmath$ C$}} -\def\bD{\mbox{\boldmath$ D$}} -\def\bE{\mbox{\boldmath$ E$}} -\def\bF{\mbox{\boldmath$ F$}} -\def\bG{\mbox{\boldmath$ G$}} -\def\bH{\mbox{\boldmath$ H$}} -\def\bI{\mbox{\boldmath$ I$}} -\def\bJ{\mbox{\boldmath$ J$}} -\def\bK{\mbox{\boldmath$ K$}} -\def\bL{\mbox{\boldmath$ L$}} -\def\bM{\mbox{\boldmath$ M$}} -\def\bN{\mbox{\boldmath$ N$}} -\def\bO{\mbox{\boldmath$ O$}} -\def\bP{\mbox{\boldmath$ P$}} -\def\bQ{\mbox{\boldmath$ Q$}} -\def\bR{\mbox{\boldmath$ R$}} -\def\bS{\mbox{\boldmath$ S$}} -\def\bT{\mbox{\boldmath$ T$}} -\def\bU{\mbox{\boldmath$ U$}} -\def\bV{\mbox{\boldmath$ V$}} -\def\bW{\mbox{\boldmath$ W$}} -\def\bX{\mbox{\boldmath$ X$}} -\def\bY{\mbox{\boldmath$ Y$}} -\def\bZ{\mbox{\boldmath$ Z$}} -\def\ba{\mbox{\boldmath$ a$}} -\def\bb{\mbox{\boldmath$ b$}} -\def\bc{\mbox{\boldmath$ c$}} -\def\bd{\mbox{\boldmath$ d$}} -\def\be{\mbox{\boldmath$ e$}} -\def\bff{\mbox{\boldmath$ f$}} -\def\bg{\mbox{\boldmath$ g$}} -\def\bh{\mbox{\boldmath$ h$}} -\def\bi{\mbox{\boldmath$ i$}} -\def\bj{\mbox{\boldmath$ j$}} -\def\bk{\mbox{\boldmath$ k$}} -\def\bl{\mbox{\boldmath$ l$}} -\def\bm{\mbox{\boldmath$ m$}} -\def\bn{\mbox{\boldmath$ n$}} -\def\bo{\mbox{\boldmath$ o$}} -\def\bp{\mbox{\boldmath$ p$}} -\def\bq{\mbox{\boldmath$ q$}} -\def\br{\mbox{\boldmath$ r$}} -\def\bs{\mbox{\boldmath$ s$}} -\def\bt{\mbox{\boldmath$ t$}} -\def\bu{\mbox{\boldmath$ u$}} -\def\bv{\mbox{\boldmath$ v$}} -\def\bw{\mbox{\boldmath$ w$}} -\def\bx{\mbox{\boldmath$ x$}} -\def\by{\mbox{\boldmath$ y$}} -\def\bz{\mbox{\boldmath$ z$}} -%********************************* -%Start main paper -%********************************* -\centerline{\Large{\bf PRISMS PhaseField}} -\smallskip -\centerline{\Large{\bf Allen-Cahn Dynamics}} -\bigskip -Consider a free energy expression of the form: -\begin{equation} - \Pi(\eta, \grad \eta) = \int_{\Omega} f( \eta ) + \frac{\kappa}{2} \grad \eta \cdot \grad \eta ~dV -\end{equation} -where $\eta$ is the structural order parameter, and $\kappa$ is the gradient length scale parameter. - -\section{Variational treatment} -Considering variations on the primal field $\eta$ of the from $\eta+\epsilon w$, we have -\begin{align} -\delta \Pi &= \left. \frac{d}{d\epsilon} \int_{\Omega} f(\eta+\epsilon w) + \frac{\kappa}{2} \grad (\eta+\epsilon w) \cdot ~\grad (\eta+\epsilon w) ~dV \right\vert_{\epsilon=0} \\ -&= \int_{\Omega} w f_{,\eta} + \kappa \grad w \grad \eta ~dV \\ -&= \int_{\Omega} w \left( f_{,\eta} - \kappa \Delta \eta \right) ~dV + \int_{\partial \Omega} w \kappa \grad \eta \cdot n ~dS -\end{align} -Assuming $\kappa \grad \eta \cdot n = 0$, and using standard variational arguments on the equation $\delta \Pi =0$ we have the expression for chemical potential as -\begin{equation} - \mu = f_{,\eta} - \kappa \Delta \eta -\end{equation} - -\section{Kinetics} -Now the Parabolic PDE for Allen-Cahn dynamics is given by: -\begin{align} - \frac{\partial \eta}{\partial t} &= -M~(f_{,\eta} - \kappa \Delta \eta) -\end{align} -where $M$ is the constant mobility. -\section{Time discretization} -Considering forward Euler explicit time stepping, we have the time discretized kinetics equation: -\begin{align} - \eta^{n+1} &= \eta^{n} - \Delta t M~(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) -\end{align} - -\section{Weak formulation} -In the weak formulation, considering an arbitrary variation $w$, the above equation can be expressed as a residual equation: -\begin{align} -\int_{\Omega} w \eta^{n+1} ~dV&= \int_{\Omega} w \eta^{n} - w \Delta t M~(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) ~dV \\ -&= \int_{\Omega} w ( \underbrace{ \eta^{n} - \Delta t M~f_{,\eta}^{n} }_{r_{\eta}} ) + \grad w \underbrace{ (-\Delta t M \kappa)~ \cdot (\grad \eta^{n})}_{r_{\eta x}} ~dV \quad [\kappa \grad \eta \cdot n = 0 \quad \text{on} \quad \partial \Omega] -\end{align} -\vskip 0.25in -The above values of $r_{\eta}$ and $r_{\eta x}$ are used to define the residuals in the following parameters file: \\ -\textit{applications/allenCahn/equations.cc} - - -\end{document} \ No newline at end of file diff --git a/applications/allenCahn_conserved/CMakeLists.txt b/applications/allenCahn_conserved/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/allenCahn_conserved/CMakeLists.txt +++ b/applications/allenCahn_conserved/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/allenCahn_conserved/ICs_and_BCs.cc b/applications/allenCahn_conserved/ICs_and_BCs.cc index 62c7c4c1d..16567f4f6 100644 --- a/applications/allenCahn_conserved/ICs_and_BCs.cc +++ b/applications/allenCahn_conserved/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -67,12 +67,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/allenCahn_conserved/customPDE.h b/applications/allenCahn_conserved/customPDE.h index 5f2190461..711ffcc74 100644 --- a/applications/allenCahn_conserved/customPDE.h +++ b/applications/allenCahn_conserved/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,59 +13,69 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) + // dependent equations (in equations.cc) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; - // Function to set the LHS of the governing equations (in equations.h) + // Function to set the LHS of the governing equations (in equations.cc) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; -// Function to set postprocessing expressions (in postprocess.h) +// Function to set postprocessing expressions (in postprocess.cc) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif -// Function to set the nucleation probability (in nucleation.h) +// Function to set the nucleation probability (in nucleation.cc) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -73,7 +85,7 @@ class customPDE : public MatrixFreePDE // Function to override solveIncrement from // ../../src/matrixfree/solveIncrement.cc void - solveIncrement(bool skip_time_dependent); + solveIncrement(bool skip_time_dependent) override; // ================================================================ // Model constants specific to this subclass @@ -202,291 +214,11 @@ customPDE::solveIncrement(bool skip_time_dependent) this->pcout << buffer; } - dealii::LinearAlgebra::distributed::Vector solution_diff = - *this->solutionSet[fieldIndex]; - - // apply Dirichlet BC's - // Loops through all DoF to which ones have Dirichlet BCs - // applied, replace the ones that do with the Dirichlet value - // This clears the residual where we want to apply Dirichlet - // BCs, otherwise the solver sees a positive residual - for (std::map::const_iterator it = - this->valuesDirichletSet[fieldIndex]->begin(); - it != this->valuesDirichletSet[fieldIndex]->end(); - ++it) - { - if (this->residualSet[fieldIndex]->in_local_range(it->first)) - { - (*this->residualSet[fieldIndex])(it->first) = 0.0; - } - } - - // solver controls - double tol_value; - if (MatrixFreePDE::userInputs.linear_solver_parameters - .getToleranceType(fieldIndex) == ABSOLUTE_RESIDUAL) - { - tol_value = - MatrixFreePDE::userInputs.linear_solver_parameters - .getToleranceValue(fieldIndex); - } - else - { - tol_value = - MatrixFreePDE::userInputs.linear_solver_parameters - .getToleranceValue(fieldIndex) * - this->residualSet[fieldIndex]->l2_norm(); - } - - SolverControl solver_control( - MatrixFreePDE::userInputs.linear_solver_parameters - .getMaxIterations(fieldIndex), - tol_value); - - // Currently the only allowed solver is SolverCG, the - // SolverType input variable is a dummy - SolverCG solver(solver_control); - - // solve - try - { - if (this->fields[fieldIndex].type == SCALAR) - { - this->dU_scalar = 0.0; - solver.solve(*this, - this->dU_scalar, - *this->residualSet[fieldIndex], - IdentityMatrix( - this->solutionSet[fieldIndex]->size())); - } - else - { - this->dU_vector = 0.0; - solver.solve(*this, - this->dU_vector, - *this->residualSet[fieldIndex], - IdentityMatrix( - this->solutionSet[fieldIndex]->size())); - } - } - catch (...) - { - this->pcout << "\nWarning: linear solver did not converge as per " - "set tolerances. consider increasing the maximum " - "number of iterations or decreasing the solver " - "tolerance.\n"; - } - - if (userInputs.var_nonlinear[fieldIndex]) - { - // Now that we have the calculated change in the solution, - // we need to select a damping coefficient - double damping_coefficient; - - if (MatrixFreePDE::userInputs - .nonlinear_solver_parameters.getBacktrackDampingFlag( - fieldIndex)) - { - vectorType solutionSet_old = *this->solutionSet[fieldIndex]; - double residual_old = this->residualSet[fieldIndex]->l2_norm(); - - damping_coefficient = 1.0; - bool damping_coefficient_found = false; - while (!damping_coefficient_found) - { - if (this->fields[fieldIndex].type == SCALAR) - { - this->solutionSet[fieldIndex]->sadd(1.0, - damping_coefficient, - this->dU_scalar); - } - else - { - this->solutionSet[fieldIndex]->sadd(1.0, - damping_coefficient, - this->dU_vector); - } - - this->computeNonexplicitRHS(); - - for (std::map::const_iterator it = - this->valuesDirichletSet[fieldIndex]->begin(); - it != this->valuesDirichletSet[fieldIndex]->end(); - ++it) - { - if (this->residualSet[fieldIndex]->in_local_range( - it->first)) - { - (*this->residualSet[fieldIndex])(it->first) = 0.0; - } - } - - double residual_new = - this->residualSet[fieldIndex]->l2_norm(); - - if (this->currentIncrement % userInputs.skip_print_steps == - 0) - { - this->pcout << " Old residual: " << residual_old - << " Damping Coeff: " << damping_coefficient - << " New Residual: " << residual_new - << std::endl; - } - - // An improved approach would use the - // Armijo–Goldstein condition to ensure a - // sufficent decrease in the residual. This way is - // just scales the residual. - if ((residual_new < - (residual_old * - MatrixFreePDE::userInputs - .nonlinear_solver_parameters - .getBacktrackResidualDecreaseCoeff(fieldIndex))) || - damping_coefficient < 1.0e-4) - { - damping_coefficient_found = true; - } - else - { - damping_coefficient *= - MatrixFreePDE::userInputs - .nonlinear_solver_parameters - .getBacktrackStepModifier(fieldIndex); - *this->solutionSet[fieldIndex] = solutionSet_old; - } - } - } - else - { - damping_coefficient = - MatrixFreePDE::userInputs - .nonlinear_solver_parameters.getDefaultDampingCoefficient( - fieldIndex); - - if (this->fields[fieldIndex].type == SCALAR) - { - this->solutionSet[fieldIndex]->sadd(1.0, - damping_coefficient, - this->dU_scalar); - } - else - { - this->solutionSet[fieldIndex]->sadd(1.0, - damping_coefficient, - this->dU_vector); - } - } - - if (this->currentIncrement % userInputs.skip_print_steps == 0) - { - double dU_norm; - if (this->fields[fieldIndex].type == SCALAR) - { - dU_norm = this->dU_scalar.l2_norm(); - } - else - { - dU_norm = this->dU_vector.l2_norm(); - } - snprintf(buffer, - sizeof(buffer), - "field '%2s' [linear solve]: initial " - "residual:%12.6e, current residual:%12.6e, " - "nsteps:%u, tolerance criterion:%12.6e, " - "solution: %12.6e, dU: %12.6e\n", - this->fields[fieldIndex].name.c_str(), - this->residualSet[fieldIndex]->l2_norm(), - solver_control.last_value(), - solver_control.last_step(), - solver_control.tolerance(), - this->solutionSet[fieldIndex]->l2_norm(), - dU_norm); - this->pcout << buffer; - } - - // Check to see if this individual variable has converged - if (MatrixFreePDE::userInputs - .nonlinear_solver_parameters.getToleranceType(fieldIndex) == - ABSOLUTE_SOLUTION_CHANGE) - { - double diff; + nonlinear_it_converged = + this->updateImplicitSolution(fieldIndex, nonlinear_it_index); - if (this->fields[fieldIndex].type == SCALAR) - { - diff = this->dU_scalar.l2_norm(); - } - else - { - diff = this->dU_vector.l2_norm(); - } - if (this->currentIncrement % userInputs.skip_print_steps == 0) - { - this->pcout << "Relative difference between " - "nonlinear iterations: " - << diff << " " << nonlinear_it_index << " " - << this->currentIncrement << std::endl; - } - - if (diff > MatrixFreePDE::userInputs - .nonlinear_solver_parameters.getToleranceValue( - fieldIndex) && - nonlinear_it_index < - MatrixFreePDE::userInputs - .nonlinear_solver_parameters.getMaxIterations()) - { - nonlinear_it_converged = false; - } - } - else - { - std::cerr << "PRISMS-PF Error: Nonlinear solver tolerance " - "types other than ABSOLUTE_CHANGE have yet to " - "be implemented." - << std::endl; - } - } - else - { - if (nonlinear_it_index == 0) - { - if (this->fields[fieldIndex].type == SCALAR) - { - *this->solutionSet[fieldIndex] += this->dU_scalar; - } - else - { - *this->solutionSet[fieldIndex] += this->dU_vector; - } - - if (this->currentIncrement % userInputs.skip_print_steps == 0) - { - double dU_norm; - if (this->fields[fieldIndex].type == SCALAR) - { - dU_norm = this->dU_scalar.l2_norm(); - } - else - { - dU_norm = this->dU_vector.l2_norm(); - } - snprintf(buffer, - sizeof(buffer), - "field '%2s' [linear solve]: initial " - "residual:%12.6e, current residual:%12.6e, " - "nsteps:%u, tolerance criterion:%12.6e, " - "solution: %12.6e, dU: %12.6e\n", - this->fields[fieldIndex].name.c_str(), - this->residualSet[fieldIndex]->l2_norm(), - solver_control.last_value(), - solver_control.last_step(), - solver_control.tolerance(), - this->solutionSet[fieldIndex]->l2_norm(), - dU_norm); - this->pcout << buffer; - } - } - } + // Apply Boundary conditions + this->applyBCs(fieldIndex); } else if (this->fields[fieldIndex].pdetype == AUXILIARY) { diff --git a/applications/allenCahn_conserved/equations.cc b/applications/allenCahn_conserved/equations.cc index 5584ef4d5..5e8c428f5 100644 --- a/applications/allenCahn_conserved/equations.cc +++ b/applications/allenCahn_conserved/equations.cc @@ -48,8 +48,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -87,8 +88,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // The order parameter and its derivatives scalarvalueType n = variable_list.get_scalar_value(0); @@ -127,6 +129,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/allenCahn_conserved/main.cc b/applications/allenCahn_conserved/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/allenCahn_conserved/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/allenCahn_conserved/postprocess.cc b/applications/allenCahn_conserved/postprocess.cc index 2c0beb4f6..5b2c72361 100644 --- a/applications/allenCahn_conserved/postprocess.cc +++ b/applications/allenCahn_conserved/postprocess.cc @@ -45,9 +45,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/alloySolidification/CMakeLists.txt b/applications/alloySolidification/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/alloySolidification/CMakeLists.txt +++ b/applications/alloySolidification/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/alloySolidification/ICs_and_BCs.cc b/applications/alloySolidification/ICs_and_BCs.cc index df788db20..f683b1c9b 100644 --- a/applications/alloySolidification/ICs_and_BCs.cc +++ b/applications/alloySolidification/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -59,12 +59,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/alloySolidification/customPDE.h b/applications/alloySolidification/customPDE.h index 0362a9733..23c6c3e81 100644 --- a/applications/alloySolidification/customPDE.h +++ b/applications/alloySolidification/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/alloySolidification/equations.cc b/applications/alloySolidification/equations.cc index b362357e8..0e2af5ad4 100644 --- a/applications/alloySolidification/equations.cc +++ b/applications/alloySolidification/equations.cc @@ -57,8 +57,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -155,8 +156,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -242,6 +244,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/alloySolidification/main.cc b/applications/alloySolidification/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/alloySolidification/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/alloySolidification/postprocess.cc b/applications/alloySolidification/postprocess.cc index 8ab4d5bac..4467a101b 100644 --- a/applications/alloySolidification/postprocess.cc +++ b/applications/alloySolidification/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/alloySolidification_uniform/CMakeLists.txt b/applications/alloySolidification_uniform/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/alloySolidification_uniform/CMakeLists.txt +++ b/applications/alloySolidification_uniform/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/alloySolidification_uniform/ICs_and_BCs.cc b/applications/alloySolidification_uniform/ICs_and_BCs.cc index de3c8f58d..d621343c9 100644 --- a/applications/alloySolidification_uniform/ICs_and_BCs.cc +++ b/applications/alloySolidification_uniform/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -60,12 +60,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/alloySolidification_uniform/customPDE.h b/applications/alloySolidification_uniform/customPDE.h index ca88d7938..fe4bc994a 100644 --- a/applications/alloySolidification_uniform/customPDE.h +++ b/applications/alloySolidification_uniform/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/alloySolidification_uniform/equations.cc b/applications/alloySolidification_uniform/equations.cc index 860258709..983c82883 100644 --- a/applications/alloySolidification_uniform/equations.cc +++ b/applications/alloySolidification_uniform/equations.cc @@ -57,8 +57,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -155,8 +156,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -237,6 +239,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/alloySolidification_uniform/main.cc b/applications/alloySolidification_uniform/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/alloySolidification_uniform/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/anisotropyFacet/CMakeLists.txt b/applications/anisotropyFacet/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/anisotropyFacet/CMakeLists.txt +++ b/applications/anisotropyFacet/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/anisotropyFacet/ICs_and_BCs.cc b/applications/anisotropyFacet/ICs_and_BCs.cc index c55ec7273..75b1d8324 100644 --- a/applications/anisotropyFacet/ICs_and_BCs.cc +++ b/applications/anisotropyFacet/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -56,12 +56,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/anisotropyFacet/anisotropy_facet.h b/applications/anisotropyFacet/anisotropy_facet.h index 9360e646a..474479b7e 100644 --- a/applications/anisotropyFacet/anisotropy_facet.h +++ b/applications/anisotropyFacet/anisotropy_facet.h @@ -4,9 +4,9 @@ template void customPDE::anisotropy( - const dealii::Tensor<1, dim, dealii::VectorizedArray> &normal, - dealii::VectorizedArray &gamma, - dealii::Tensor<1, dim, dealii::VectorizedArray> &dgammadnormal) const + const Tensor<1, dim, VectorizedArray> &normal, + VectorizedArray &gamma, + Tensor<1, dim, VectorizedArray> &dgammadnormal) const { // Orientations // Defining orientations in a static array greatly improves performance, but diff --git a/applications/anisotropyFacet/customPDE.h b/applications/anisotropyFacet/customPDE.h index c27fd2086..1adcf50be 100644 --- a/applications/anisotropyFacet/customPDE.h +++ b/applications/anisotropyFacet/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -71,10 +83,9 @@ class customPDE : public MatrixFreePDE // ================================================================ void - anisotropy( - const dealii::Tensor<1, dim, dealii::VectorizedArray> &normal, - dealii::VectorizedArray &gamma, - dealii::Tensor<1, dim, dealii::VectorizedArray> &dgammadnormal) const; + anisotropy(const Tensor<1, dim, VectorizedArray> &normal, + VectorizedArray &gamma, + Tensor<1, dim, VectorizedArray> &dgammadnormal) const; // ================================================================ // Model constants specific to this subclass diff --git a/applications/anisotropyFacet/equations.cc b/applications/anisotropyFacet/equations.cc index 6ba275b58..60203f10b 100644 --- a/applications/anisotropyFacet/equations.cc +++ b/applications/anisotropyFacet/equations.cc @@ -59,8 +59,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -142,8 +143,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -173,6 +175,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/anisotropyFacet/main.cc b/applications/anisotropyFacet/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/anisotropyFacet/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/anisotropyFacet/postprocess.cc b/applications/anisotropyFacet/postprocess.cc index bde4e20b5..8a8c60d66 100644 --- a/applications/anisotropyFacet/postprocess.cc +++ b/applications/anisotropyFacet/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/cahnHilliard/CMakeLists.txt b/applications/cahnHilliard/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/cahnHilliard/CMakeLists.txt +++ b/applications/cahnHilliard/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/cahnHilliard/ICs_and_BCs.cc b/applications/cahnHilliard/ICs_and_BCs.cc index c6f4a48cd..659087692 100644 --- a/applications/cahnHilliard/ICs_and_BCs.cc +++ b/applications/cahnHilliard/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -68,12 +68,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/cahnHilliard/customPDE.h b/applications/cahnHilliard/customPDE.h index ed9048fc4..c2bf3bf41 100644 --- a/applications/cahnHilliard/customPDE.h +++ b/applications/cahnHilliard/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/cahnHilliard/equations.cc b/applications/cahnHilliard/equations.cc index 7efed12b5..8dbe9cb53 100644 --- a/applications/cahnHilliard/equations.cc +++ b/applications/cahnHilliard/equations.cc @@ -49,8 +49,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- scalarvalueType c = variable_list.get_scalar_value(0); @@ -81,8 +82,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -122,6 +124,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/cahnHilliard/main.cc b/applications/cahnHilliard/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/cahnHilliard/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/cahnHilliard/postprocess.cc b/applications/cahnHilliard/postprocess.cc index 173f2f24f..031f595cb 100644 --- a/applications/cahnHilliard/postprocess.cc +++ b/applications/cahnHilliard/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/corrosion/CMakeLists.txt b/applications/corrosion/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/corrosion/CMakeLists.txt +++ b/applications/corrosion/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/corrosion/ICs_and_BCs.cc b/applications/corrosion/ICs_and_BCs.cc index 11c68bb11..37357f318 100644 --- a/applications/corrosion/ICs_and_BCs.cc +++ b/applications/corrosion/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS @@ -62,12 +62,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/corrosion/customPDE.h b/applications/corrosion/customPDE.h index b0ee6082c..83d895b91 100644 --- a/applications/corrosion/customPDE.h +++ b/applications/corrosion/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -72,10 +84,10 @@ class customPDE : public MatrixFreePDE // Method that caps the value of the order parameter and the domain parameter void - capFields(dealii::VectorizedArray &ncp, - dealii::VectorizedArray &psicp, - dealii::VectorizedArray n, - dealii::VectorizedArray psi) const; + capFields(VectorizedArray &ncp, + VectorizedArray &psicp, + VectorizedArray n, + VectorizedArray psi) const; // ================================================================ // Model constants specific to this subclass diff --git a/applications/corrosion/equations.cc b/applications/corrosion/equations.cc index bfdfaafe8..a583208d0 100644 --- a/applications/corrosion/equations.cc +++ b/applications/corrosion/equations.cc @@ -101,8 +101,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Parameters in the explicit equations can be set here --- @@ -228,8 +229,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -370,8 +372,9 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // The order parameter and its derivatives scalarvalueType n = variable_list.get_scalar_value(0); @@ -475,10 +478,10 @@ customPDE::equationLHS( // Method that caps the value of the order parameter and the domain parameter template void -customPDE::capFields(dealii::VectorizedArray &ncp, - dealii::VectorizedArray &psicp, - dealii::VectorizedArray n, - dealii::VectorizedArray psi) const +customPDE::capFields(VectorizedArray &ncp, + VectorizedArray &psicp, + VectorizedArray n, + VectorizedArray psi) const { // Capping n to lower threshold bound and upper bound of 1 for (unsigned j = 0; j < ncp.size(); j++) diff --git a/applications/corrosion/main.cc b/applications/corrosion/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/corrosion/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/corrosion_microgalvanic/CMakeLists.txt b/applications/corrosion_microgalvanic/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/corrosion_microgalvanic/CMakeLists.txt +++ b/applications/corrosion_microgalvanic/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/corrosion_microgalvanic/ICs_and_BCs.cc b/applications/corrosion_microgalvanic/ICs_and_BCs.cc index 62d2fc6d8..63501011d 100644 --- a/applications/corrosion_microgalvanic/ICs_and_BCs.cc +++ b/applications/corrosion_microgalvanic/ICs_and_BCs.cc @@ -7,10 +7,11 @@ using namespace std; template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition( + [[maybe_unused]] const dealii::Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] dealii::Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS @@ -91,12 +92,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const dealii::Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] dealii::Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/corrosion_microgalvanic/customPDE.h b/applications/corrosion_microgalvanic/customPDE.h index c1a6432a4..256728642 100644 --- a/applications/corrosion_microgalvanic/customPDE.h +++ b/applications/corrosion_microgalvanic/customPDE.h @@ -1,4 +1,5 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + #include #include using namespace std; @@ -14,23 +15,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const dealii::Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] dealii::Vector &vector_IC) override; // Function to set the non-uniform Dirichlet // boundary conditions (in ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const dealii::Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] dealii::Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -39,37 +40,47 @@ class customPDE : public MatrixFreePDE void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations // for all other equations (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) // Not useful for this application #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/corrosion_microgalvanic/equations.cc b/applications/corrosion_microgalvanic/equations.cc index ceaf97a93..b0b827fd3 100644 --- a/applications/corrosion_microgalvanic/equations.cc +++ b/applications/corrosion_microgalvanic/equations.cc @@ -122,8 +122,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Parameters in the explicit equations can be set here --- @@ -182,13 +183,11 @@ customPDE::explicitEquationRHS( // --- Calculation of irxn --- // Overpotentials for the anodic and cathodic phases - scalarvalueType etaAnodic = VsV - EcorrAnodic - Phi; - scalarvalueType etaCathodic = VsV - EcorrCathodic - Phi; + scalarvalueType etaAnodic = VsV - EcorrAnodic - Phi; // Calculation of anodic/cathodic current density - scalarvalueType itafel = i0Anodic * exp(etaAnodic / AAnodic); - scalarvalueType iAnodic = itafel / (constV(1.0) + (itafel / iMax)); - scalarvalueType iCathodic = -i0Cathodic * exp(etaCathodic / ACathodic); + scalarvalueType itafel = i0Anodic * exp(etaAnodic / AAnodic); + scalarvalueType iAnodic = itafel / (constV(1.0) + (itafel / iMax)); // Time for initial equilibration of all the interfaces present in the // domain @@ -256,8 +255,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -396,8 +396,9 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // The order parameter of the anodic phase scalarvalueType nAnodic = variable_list.get_scalar_value(0); @@ -450,7 +451,6 @@ customPDE::equationLHS( // Calculation of anodic/cathodic current density scalarvalueType itafel = i0Anodic * exp(etaAnodic / AAnodic); - scalarvalueType iAnodic = itafel / (constV(1.0) + (itafel / iMax)); scalarvalueType iCathodic = -i0Cathodic * exp(etaCathodic / ACathodic); // The interpolation factor for the cathodic phase diff --git a/applications/corrosion_microgalvanic/main.cc b/applications/corrosion_microgalvanic/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/corrosion_microgalvanic/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/coupledCahnHilliardAllenCahn/CMakeLists.txt b/applications/coupledCahnHilliardAllenCahn/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/coupledCahnHilliardAllenCahn/CMakeLists.txt +++ b/applications/coupledCahnHilliardAllenCahn/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/coupledCahnHilliardAllenCahn/ICs_and_BCs.cc b/applications/coupledCahnHilliardAllenCahn/ICs_and_BCs.cc index d82840d83..5993e873c 100644 --- a/applications/coupledCahnHilliardAllenCahn/ICs_and_BCs.cc +++ b/applications/coupledCahnHilliardAllenCahn/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -70,12 +70,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/coupledCahnHilliardAllenCahn/customPDE.h b/applications/coupledCahnHilliardAllenCahn/customPDE.h index d98dbc6f0..e83b8b4b5 100644 --- a/applications/coupledCahnHilliardAllenCahn/customPDE.h +++ b/applications/coupledCahnHilliardAllenCahn/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -78,8 +90,8 @@ class customPDE : public MatrixFreePDE double Mn = userInputs.get_model_constant_double("Mn"); double Kn = userInputs.get_model_constant_double("Kn"); - dealii::Tensor<1, dim> center1 = userInputs.get_model_constant_rank_1_tensor("center1"); - dealii::Tensor<1, dim> center2 = userInputs.get_model_constant_rank_1_tensor("center2"); + Tensor<1, dim> center1 = userInputs.get_model_constant_rank_1_tensor("center1"); + Tensor<1, dim> center2 = userInputs.get_model_constant_rank_1_tensor("center2"); double radius1 = userInputs.get_model_constant_double("radius1"); double radius2 = userInputs.get_model_constant_double("radius2"); diff --git a/applications/coupledCahnHilliardAllenCahn/equations.cc b/applications/coupledCahnHilliardAllenCahn/equations.cc index 56e65154e..d3e5554c9 100644 --- a/applications/coupledCahnHilliardAllenCahn/equations.cc +++ b/applications/coupledCahnHilliardAllenCahn/equations.cc @@ -49,8 +49,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -111,8 +112,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -133,6 +135,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/coupledCahnHilliardAllenCahn/main.cc b/applications/coupledCahnHilliardAllenCahn/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/coupledCahnHilliardAllenCahn/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/coupledCahnHilliardAllenCahn/postprocess.cc b/applications/coupledCahnHilliardAllenCahn/postprocess.cc index 207bc4def..73ec2dab4 100644 --- a/applications/coupledCahnHilliardAllenCahn/postprocess.cc +++ b/applications/coupledCahnHilliardAllenCahn/postprocess.cc @@ -45,9 +45,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/dendriticSolidification/CMakeLists.txt b/applications/dendriticSolidification/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/dendriticSolidification/CMakeLists.txt +++ b/applications/dendriticSolidification/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/dendriticSolidification/ICs_and_BCs.cc b/applications/dendriticSolidification/ICs_and_BCs.cc index 78e5e9583..3cb996c73 100644 --- a/applications/dendriticSolidification/ICs_and_BCs.cc +++ b/applications/dendriticSolidification/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -59,12 +59,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/dendriticSolidification/customPDE.h b/applications/dendriticSolidification/customPDE.h index 8509dc1df..7193d7a02 100644 --- a/applications/dendriticSolidification/customPDE.h +++ b/applications/dendriticSolidification/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/dendriticSolidification/equations.cc b/applications/dendriticSolidification/equations.cc index 7915cbfbb..b44731950 100644 --- a/applications/dendriticSolidification/equations.cc +++ b/applications/dendriticSolidification/equations.cc @@ -57,8 +57,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -119,8 +120,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -154,7 +156,6 @@ customPDE::nonExplicitEquationRHS( scalarvalueType W_theta = constV(-W0) * (constV(epsilonM) * constV(mult) * std::sin(constV(mult) * (theta - constV(theta0)))); - scalarvalueType tau = W / constV(W0); // The anisotropy term that enters in to the equation for mu scalargradType aniso; @@ -189,6 +190,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/dendriticSolidification/main.cc b/applications/dendriticSolidification/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/dendriticSolidification/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/eshelbyInclusion/CMakeLists.txt b/applications/eshelbyInclusion/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/eshelbyInclusion/CMakeLists.txt +++ b/applications/eshelbyInclusion/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/eshelbyInclusion/ICs_and_BCs.cc b/applications/eshelbyInclusion/ICs_and_BCs.cc index 4f1e11030..ff9cead6a 100644 --- a/applications/eshelbyInclusion/ICs_and_BCs.cc +++ b/applications/eshelbyInclusion/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -30,12 +30,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/eshelbyInclusion/customPDE.h b/applications/eshelbyInclusion/customPDE.h index 568e7b41b..07f3a40ea 100644 --- a/applications/eshelbyInclusion/customPDE.h +++ b/applications/eshelbyInclusion/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -74,9 +86,8 @@ class customPDE : public MatrixFreePDE // Model constants specific to this subclass // ================================================================ - const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; - dealii::Tensor<2, CIJ_tensor_size> CIJ = - userInputs.get_model_constant_elasticity_tensor("CIJ"); + const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; + Tensor<2, CIJ_tensor_size> CIJ = userInputs.get_model_constant_elasticity_tensor("CIJ"); // ================================================================ }; diff --git a/applications/eshelbyInclusion/equations.cc b/applications/eshelbyInclusion/equations.cc index 2b0d52d38..a93ea5cf0 100644 --- a/applications/eshelbyInclusion/equations.cc +++ b/applications/eshelbyInclusion/equations.cc @@ -43,8 +43,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -63,8 +64,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -106,7 +108,7 @@ customPDE::nonExplicitEquationRHS( } // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; + VectorizedArray E[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { for (unsigned int j = 0; j < dim; j++) @@ -150,8 +152,9 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -163,7 +166,7 @@ customPDE::equationLHS( vectorgradType eqx_Du; // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; + VectorizedArray E[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { for (unsigned int j = 0; j < dim; j++) diff --git a/applications/eshelbyInclusion/main.cc b/applications/eshelbyInclusion/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/eshelbyInclusion/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/fickianDiffusion/CMakeLists.txt b/applications/fickianDiffusion/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/fickianDiffusion/CMakeLists.txt +++ b/applications/fickianDiffusion/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/fickianDiffusion/ICs_and_BCs.cc b/applications/fickianDiffusion/ICs_and_BCs.cc index 12bc18cd2..ffce45fef 100644 --- a/applications/fickianDiffusion/ICs_and_BCs.cc +++ b/applications/fickianDiffusion/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -27,12 +27,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/fickianDiffusion/customPDE.h b/applications/fickianDiffusion/customPDE.h index 7f2cfe3f7..83b0fe738 100644 --- a/applications/fickianDiffusion/customPDE.h +++ b/applications/fickianDiffusion/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/fickianDiffusion/equations.cc b/applications/fickianDiffusion/equations.cc index 070db49f4..95e859551 100644 --- a/applications/fickianDiffusion/equations.cc +++ b/applications/fickianDiffusion/equations.cc @@ -41,8 +41,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -104,8 +105,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -126,6 +128,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/fickianDiffusion/integratedFields.txt b/applications/fickianDiffusion/integratedFields.txt deleted file mode 100644 index 0486bcf32..000000000 --- a/applications/fickianDiffusion/integratedFields.txt +++ /dev/null @@ -1,3 +0,0 @@ -0 c_x 0 -5 c_x -50.42273226 -10 c_x -71.00777182 diff --git a/applications/fickianDiffusion/main.cc b/applications/fickianDiffusion/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/fickianDiffusion/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/grainGrowth/CMakeLists.txt b/applications/grainGrowth/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/grainGrowth/CMakeLists.txt +++ b/applications/grainGrowth/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/grainGrowth/ICs_and_BCs.cc b/applications/grainGrowth/ICs_and_BCs.cc index 72b5a53d2..a0db76df7 100644 --- a/applications/grainGrowth/ICs_and_BCs.cc +++ b/applications/grainGrowth/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -18,76 +18,76 @@ customPDE::setInitialCondition(const dealii::Point &p, // The initial condition is a set of overlapping circles/spheres defined // by a hyperbolic tangent function. The center of each circle/sphere is - // given by "center" and its radius is given by "radius". + // given by "center_list" and its radius is given by "radius". if (index < 5) { - std::vector> center; + std::vector> center_list; // The big grains { - dealii::Point p(0.2, 0.15); - center.push_back(p); + Point center(0.2, 0.15); + center_list.push_back(center); } { - dealii::Point p(0.25, 0.7); - center.push_back(p); + Point center(0.25, 0.7); + center_list.push_back(center); } { - dealii::Point p(0.5, 0.5); - center.push_back(p); + Point center(0.5, 0.5); + center_list.push_back(center); } { - dealii::Point p(0.6, 0.85); - center.push_back(p); + Point center(0.6, 0.85); + center_list.push_back(center); } { - dealii::Point p(0.85, 0.35); - center.push_back(p); + Point center(0.85, 0.35); + center_list.push_back(center); } // The medium grains { - dealii::Point p(0.08, 0.92); - center.push_back(p); + Point center(0.08, 0.92); + center_list.push_back(center); } { - dealii::Point p(0.75, 0.6); - center.push_back(p); + Point center(0.75, 0.6); + center_list.push_back(center); } { - dealii::Point p(0.75, 0.1); - center.push_back(p); + Point center(0.75, 0.1); + center_list.push_back(center); } { - dealii::Point p(0.2, 0.45); - center.push_back(p); + Point center(0.2, 0.45); + center_list.push_back(center); } { - dealii::Point p(0.85, 0.85); - center.push_back(p); + Point center(0.85, 0.85); + center_list.push_back(center); } // The small grains { - dealii::Point p(0.55, 0.05); - center.push_back(p); + Point center(0.55, 0.05); + center_list.push_back(center); } { - dealii::Point p(0.1, 0.35); - center.push_back(p); + Point center(0.1, 0.35); + center_list.push_back(center); } { - dealii::Point p(0.95, 0.65); - center.push_back(p); + Point center(0.95, 0.65); + center_list.push_back(center); } { - dealii::Point p(0.9, 0.15); - center.push_back(p); + Point center(0.9, 0.15); + center_list.push_back(center); } { - dealii::Point p(0.45, 0.25); - center.push_back(p); + Point center(0.45, 0.25); + center_list.push_back(center); } std::vector rad = {0.14, @@ -111,8 +111,8 @@ customPDE::setInitialCondition(const dealii::Point &p, for (unsigned int dir = 0; dir < dim; dir++) { - dist += (p[dir] - center[index][dir] * userInputs.domain_size[dir]) * - (p[dir] - center[index][dir] * userInputs.domain_size[dir]); + dist += (p[dir] - center_list[index][dir] * userInputs.domain_size[dir]) * + (p[dir] - center_list[index][dir] * userInputs.domain_size[dir]); } dist = std::sqrt(dist); @@ -122,8 +122,8 @@ customPDE::setInitialCondition(const dealii::Point &p, dist = 0.0; for (unsigned int dir = 0; dir < dim; dir++) { - dist += (p[dir] - center[index + 5][dir] * userInputs.domain_size[dir]) * - (p[dir] - center[index + 5][dir] * userInputs.domain_size[dir]); + dist += (p[dir] - center_list[index + 5][dir] * userInputs.domain_size[dir]) * + (p[dir] - center_list[index + 5][dir] * userInputs.domain_size[dir]); } dist = std::sqrt(dist); @@ -134,8 +134,8 @@ customPDE::setInitialCondition(const dealii::Point &p, dist = 0.0; for (unsigned int dir = 0; dir < dim; dir++) { - dist += (p[dir] - center[index + 10][dir] * userInputs.domain_size[dir]) * - (p[dir] - center[index + 10][dir] * userInputs.domain_size[dir]); + dist += (p[dir] - center_list[index + 10][dir] * userInputs.domain_size[dir]) * + (p[dir] - center_list[index + 10][dir] * userInputs.domain_size[dir]); } dist = std::sqrt(dist); @@ -157,12 +157,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/grainGrowth/customPDE.h b/applications/grainGrowth/customPDE.h index 425587d56..8665df4b0 100644 --- a/applications/grainGrowth/customPDE.h +++ b/applications/grainGrowth/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/grainGrowth/equations.cc b/applications/grainGrowth/equations.cc index 0049614c6..34542af81 100644 --- a/applications/grainGrowth/equations.cc +++ b/applications/grainGrowth/equations.cc @@ -48,14 +48,15 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- - dealii::VectorizedArray fnV = constV(0.0); - scalarvalueType ni, nj; - scalargradType nix; + VectorizedArray fnV = constV(0.0); + scalarvalueType ni, nj; + scalargradType nix; // In this application, create temporary variables for the residual terms. We // cannot call 'set_scalar_value_residual_term' and @@ -111,8 +112,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -133,6 +135,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/grainGrowth/integratedFields.txt b/applications/grainGrowth/integratedFields.txt deleted file mode 100644 index c57b33fb5..000000000 --- a/applications/grainGrowth/integratedFields.txt +++ /dev/null @@ -1,21 +0,0 @@ -0 diff1 6.302753372 -2 diff1 9.272165056 -4 diff1 10.48934769 -6 diff1 9.87554228 -8 diff1 8.068710441 -10 diff1 4.365246041 -12 diff1 3.011654139 -14 diff1 2.078855898 -16 diff1 1.452358016 -18 diff1 1.076649095 -20 diff1 0.8341042436 -22 diff1 0.4586567388 -24 diff1 0.3095193461 -26 diff1 0.2290179444 -28 diff1 0.1510074249 -30 diff1 0.05453975367 -32 diff1 -0.009341608481 -34 diff1 -0.009585723581 -36 diff1 -0.008783314296 -38 diff1 -0.008392747583 -40 diff1 -0.008305823929 diff --git a/applications/grainGrowth/main.cc b/applications/grainGrowth/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/grainGrowth/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/grainGrowth/postprocess.cc b/applications/grainGrowth/postprocess.cc index f0ee32c00..45d013506 100644 --- a/applications/grainGrowth/postprocess.cc +++ b/applications/grainGrowth/postprocess.cc @@ -45,9 +45,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -79,7 +82,7 @@ customPDE::postProcessedFields( if (this->simplified_grain_representations[g].getOrderParameterId() == max_op_nonvec) { - dealii::Point q_point_loc_nonvec; + Point q_point_loc_nonvec; for (unsigned int d = 0; d < dim; d++) { q_point_loc_nonvec(d) = q_point_loc(d)[v]; diff --git a/applications/grainGrowth_dream3d/CMakeLists.txt b/applications/grainGrowth_dream3d/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/grainGrowth_dream3d/CMakeLists.txt +++ b/applications/grainGrowth_dream3d/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/grainGrowth_dream3d/ICs_and_BCs.cc b/applications/grainGrowth_dream3d/ICs_and_BCs.cc index a31e9be4c..7103514e3 100644 --- a/applications/grainGrowth_dream3d/ICs_and_BCs.cc +++ b/applications/grainGrowth_dream3d/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -25,12 +25,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/grainGrowth_dream3d/customPDE.h b/applications/grainGrowth_dream3d/customPDE.h index 425587d56..8665df4b0 100644 --- a/applications/grainGrowth_dream3d/customPDE.h +++ b/applications/grainGrowth_dream3d/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/grainGrowth_dream3d/equations.cc b/applications/grainGrowth_dream3d/equations.cc index 015f1d6c7..99a25a6a9 100644 --- a/applications/grainGrowth_dream3d/equations.cc +++ b/applications/grainGrowth_dream3d/equations.cc @@ -59,14 +59,15 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- - dealii::VectorizedArray fnV = constV(0.0); - scalarvalueType ni, nj; - scalargradType nix; + VectorizedArray fnV = constV(0.0); + scalarvalueType ni, nj; + scalargradType nix; // In this application, create temporary variables for the residual terms. We // cannot call 'set_scalar_value_residual_term' and @@ -122,8 +123,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -144,6 +146,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/grainGrowth_dream3d/main.cc b/applications/grainGrowth_dream3d/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/grainGrowth_dream3d/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/grainGrowth_dream3d/postprocess.cc b/applications/grainGrowth_dream3d/postprocess.cc index 322208f67..700f10ec8 100644 --- a/applications/grainGrowth_dream3d/postprocess.cc +++ b/applications/grainGrowth_dream3d/postprocess.cc @@ -57,9 +57,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -91,7 +94,7 @@ customPDE::postProcessedFields( if (this->simplified_grain_representations[g].getOrderParameterId() == max_op_nonvec) { - dealii::Point q_point_loc_nonvec; + Point q_point_loc_nonvec; for (unsigned int d = 0; d < dim; d++) { q_point_loc_nonvec(d) = q_point_loc(d)[v]; diff --git a/applications/main.cc b/applications/main.cc new file mode 100644 index 000000000..5f5514d14 --- /dev/null +++ b/applications/main.cc @@ -0,0 +1,212 @@ +// Header files +#include "customPDE.h" + +#include "ICs_and_BCs.cc" +#include "ParseCommandLineOpts.h" +#include "equations.cc" +#include "inputFileReader.h" +#include "variableAttributeLoader/variableAttributeLoader.cc" + +// Header file for postprocessing that may or may not exist +#ifdef POSTPROCESS_FILE_EXISTS +# include "postprocess.cc" +#else +void +variableAttributeLoader::loadPostProcessorVariableAttributes() +{} +#endif + +// Header files for nucleation that may or may not exist +#ifdef NUCLEATION_FILE_EXISTS +# include "nucleation.cc" + +# include +# include +#endif + +// main +int +main(int argc, char **argv) +{ + dealii::Utilities::MPI::MPI_InitFinalize + mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); + + // Parse the command line options (if there are any) to get the name of the + // input file + std::string parameters_filename; + try + { + ParseCommandLineOpts cli_options(argc, argv); + parameters_filename = cli_options.getParametersFilename(); + } + catch (const char *msg) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" << std::endl; + std::cerr << "PRISMS-PF: Exception on processing: " << std::endl + << msg << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" << std::endl; + return 1; + } + + // Run the main part of the code + try + { + dealii::deallog.depth_console(0); + + // Before fully parsing the parameter file, we need to know how many field + // variables there are and whether they are scalars or vectors, how many + // postprocessing variables there are, how many sets of elastic constants + // there are, and how many user-defined constants there are. + + variableAttributeLoader variable_attributes; + inputFileReader input_file_reader(parameters_filename, variable_attributes); + + // Continue based on the number of dimensions and degree of the elements + // specified in the input file + switch (input_file_reader.number_of_dimensions) + { + case 2: + { + userInputParameters<2> userInputs(input_file_reader, + input_file_reader.parameter_handler, + variable_attributes); + switch (userInputs.degree) + { + case (1): + { + customPDE<2, 1> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (2): + { + customPDE<2, 2> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (3): + { + customPDE<2, 3> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (4): + { + customPDE<2, 4> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (5): + { + customPDE<2, 5> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (6): + { + customPDE<2, 6> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + } + break; + } + case 3: + { + userInputParameters<3> userInputs(input_file_reader, + input_file_reader.parameter_handler, + variable_attributes); + switch (userInputs.degree) + { + case (1): + { + customPDE<3, 1> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (2): + { + customPDE<3, 2> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (3): + { + customPDE<3, 3> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (4): + { + customPDE<3, 4> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (5): + { + customPDE<3, 5> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (6): + { + customPDE<3, 6> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + } + } + break; + } + } + catch (std::exception &exc) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" << std::endl; + std::cerr << "PRISMS-PF: Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" << std::endl; + return 1; + } + catch (...) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" << std::endl; + return 1; + } + + return 0; +} diff --git a/applications/mechanics/CMakeLists.txt b/applications/mechanics/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/mechanics/CMakeLists.txt +++ b/applications/mechanics/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/mechanics/ICs_and_BCs.cc b/applications/mechanics/ICs_and_BCs.cc index e5dbaec0a..0572c1ec8 100644 --- a/applications/mechanics/ICs_and_BCs.cc +++ b/applications/mechanics/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -29,12 +29,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/mechanics/customPDE.h b/applications/mechanics/customPDE.h index 568e7b41b..07f3a40ea 100644 --- a/applications/mechanics/customPDE.h +++ b/applications/mechanics/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -11,23 +13,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -35,35 +37,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -74,9 +86,8 @@ class customPDE : public MatrixFreePDE // Model constants specific to this subclass // ================================================================ - const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; - dealii::Tensor<2, CIJ_tensor_size> CIJ = - userInputs.get_model_constant_elasticity_tensor("CIJ"); + const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; + Tensor<2, CIJ_tensor_size> CIJ = userInputs.get_model_constant_elasticity_tensor("CIJ"); // ================================================================ }; diff --git a/applications/mechanics/equations.cc b/applications/mechanics/equations.cc index 34d05e623..287c27407 100644 --- a/applications/mechanics/equations.cc +++ b/applications/mechanics/equations.cc @@ -34,8 +34,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -54,8 +55,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -67,7 +69,7 @@ customPDE::nonExplicitEquationRHS( vectorgradType eqx_u; // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; + VectorizedArray E[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { for (unsigned int j = 0; j < dim; j++) @@ -111,8 +113,9 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -124,7 +127,7 @@ customPDE::equationLHS( vectorgradType eqx_Du; // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; + VectorizedArray E[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { for (unsigned int j = 0; j < dim; j++) diff --git a/applications/mechanics/main.cc b/applications/mechanics/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/mechanics/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/nucleationModel/CMakeLists.txt b/applications/nucleationModel/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/nucleationModel/CMakeLists.txt +++ b/applications/nucleationModel/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/nucleationModel/ICs_and_BCs.cc b/applications/nucleationModel/ICs_and_BCs.cc index 18a3d5e29..0a1a20799 100644 --- a/applications/nucleationModel/ICs_and_BCs.cc +++ b/applications/nucleationModel/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -16,11 +16,6 @@ customPDE::setInitialCondition(const dealii::Point &p, // Use "if" statements to set the initial condition for each variable // according to its variable index - double dx = userInputs.domain_size[0] / ((double) userInputs.subdivisions[0]) / - std::pow(2.0, userInputs.refine_factor); - - double r = 0.0; - // Initial condition for the concentration field if (index == 0) { @@ -41,12 +36,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/nucleationModel/customPDE.h b/applications/nucleationModel/customPDE.h index 1dd80daef..bd3a5bcec 100644 --- a/applications/nucleationModel/customPDE.h +++ b/applications/nucleationModel/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -10,23 +12,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -34,38 +36,47 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Virtual method in MatrixFreePDE that we override if we need nucleation #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, - double dV, - dealii::Point p, - unsigned int variable_index) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV, + [[maybe_unused]] Point p, + [[maybe_unused]] unsigned int variable_index) const override; #endif // ================================================================ @@ -75,9 +86,9 @@ class customPDE : public MatrixFreePDE // Method to place the nucleus and calculate the mobility modifier in // residualRHS void - seedNucleus(const dealii::Point> &q_point_loc, - dealii::VectorizedArray &source_term, - dealii::VectorizedArray &gamma) const; + seedNucleus(const Point> &q_point_loc, + VectorizedArray &source_term, + VectorizedArray &gamma) const; // ================================================================ // Model constants specific to this subclass diff --git a/applications/nucleationModel/equations.cc b/applications/nucleationModel/equations.cc index 99f9aea8b..d74c6e3a0 100644 --- a/applications/nucleationModel/equations.cc +++ b/applications/nucleationModel/equations.cc @@ -55,8 +55,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -81,22 +82,18 @@ customPDE::explicitEquationRHS( (A2 * hV + B2 * (1.0 - hV)); // Free energy for each phase and their first and second derivatives - scalarvalueType faV = A0 + A2 * (c_alpha - calmin) * (c_alpha - calmin); - scalarvalueType facV = 2.0 * A2 * (c_alpha - calmin); - scalarvalueType faccV = constV(2.0) * A2; - scalarvalueType fbV = B0 + B2 * (c_beta - cbtmin) * (c_beta - cbtmin); - scalarvalueType fbcV = 2.0 * B2 * (c_beta - cbtmin); - scalarvalueType fbccV = constV(2.0) * B2; + scalarvalueType faV = A0 + A2 * (c_alpha - calmin) * (c_alpha - calmin); + scalarvalueType fbV = B0 + B2 * (c_beta - cbtmin) * (c_beta - cbtmin); + scalarvalueType fbcV = 2.0 * B2 * (c_beta - cbtmin); // Double-Well function (can be used to tune the interfacial energy) - scalarvalueType fbarrierV = n * n - 2.0 * n * n * n + n * n * n * n; scalarvalueType fbarriernV = 2.0 * n - 6.0 * n * n + 4.0 * n * n * n; // ------------------------------------------------- // Nucleation expressions // ------------------------------------------------- - dealii::VectorizedArray source_term = constV(0.0); - dealii::VectorizedArray gamma = constV(1.0); + VectorizedArray source_term = constV(0.0); + VectorizedArray gamma = constV(1.0); seedNucleus(q_point_loc, source_term, gamma); // ------------------------------------------------- @@ -129,25 +126,21 @@ customPDE::explicitEquationRHS( template void customPDE::seedNucleus( - const dealii::Point> &q_point_loc, - dealii::VectorizedArray &source_term, - dealii::VectorizedArray &gamma) const + const Point> &q_point_loc, + VectorizedArray &source_term, + VectorizedArray &gamma) const { - for (typename std::vector>::const_iterator thisNucleus = - this->nuclei.begin(); - thisNucleus != this->nuclei.end(); - ++thisNucleus) + for (const auto &thisNucleus : this->nuclei) { - if (thisNucleus->seededTime + thisNucleus->seedingTime > this->currentTime) + if (thisNucleus.seededTime + thisNucleus.seedingTime > this->currentTime) { // Calculate the weighted distance function to the order parameter // freeze boundary (weighted_dist = 1.0 on that boundary) - dealii::VectorizedArray weighted_dist = - this->weightedDistanceFromNucleusCenter( - thisNucleus->center, - userInputs.get_nucleus_freeze_semiaxes(thisNucleus->orderParameterIndex), - q_point_loc, - thisNucleus->orderParameterIndex); + VectorizedArray weighted_dist = this->weightedDistanceFromNucleusCenter( + thisNucleus.center, + userInputs.get_nucleus_freeze_semiaxes(thisNucleus.orderParameterIndex), + q_point_loc, + thisNucleus.orderParameterIndex); for (unsigned i = 0; i < gamma.size(); i++) { @@ -157,26 +150,26 @@ customPDE::seedNucleus( // Seed a nucleus if it was added to the list of nuclei this // time step - if (thisNucleus->seedingTimestep == this->currentIncrement) + if (thisNucleus.seedingTimestep == this->currentIncrement) { // Find the weighted distance to the outer edge of the // nucleus and use it to calculate the order parameter // source term - dealii::Point q_point_loc_element; + Point q_point_loc_element; for (unsigned int j = 0; j < dim; j++) { q_point_loc_element(j) = q_point_loc(j)[i]; } double r = this->weightedDistanceFromNucleusCenter( - thisNucleus->center, - userInputs.get_nucleus_semiaxes(thisNucleus->orderParameterIndex), + thisNucleus.center, + userInputs.get_nucleus_semiaxes(thisNucleus.orderParameterIndex), q_point_loc_element, - thisNucleus->orderParameterIndex); + thisNucleus.orderParameterIndex); double avg_semiaxis = 0.0; for (unsigned int j = 0; j < dim; j++) { - avg_semiaxis += thisNucleus->semiaxes[j]; + avg_semiaxis += thisNucleus.semiaxes[j]; } avg_semiaxis /= dim; @@ -206,8 +199,9 @@ customPDE::seedNucleus( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -228,6 +222,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/nucleationModel/main.cc b/applications/nucleationModel/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/nucleationModel/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/nucleationModel/nucleation.cc b/applications/nucleationModel/nucleation.cc index cba19215e..7a3c1fae0 100644 --- a/applications/nucleationModel/nucleation.cc +++ b/applications/nucleationModel/nucleation.cc @@ -7,10 +7,11 @@ // ================================================================================= template double -customPDE::getNucleationProbability(variableValueContainer variable_value, - double dV, - dealii::Point p, - unsigned int variable_index) const +customPDE::getNucleationProbability( + [[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV, + [[maybe_unused]] dealii::Point p, + [[maybe_unused]] unsigned int variable_index) const { // Supersaturation factor double ssf; diff --git a/applications/nucleationModel_preferential/CMakeLists.txt b/applications/nucleationModel_preferential/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/nucleationModel_preferential/CMakeLists.txt +++ b/applications/nucleationModel_preferential/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/nucleationModel_preferential/ICs_and_BCs.cc b/applications/nucleationModel_preferential/ICs_and_BCs.cc index 18a3d5e29..0a1a20799 100644 --- a/applications/nucleationModel_preferential/ICs_and_BCs.cc +++ b/applications/nucleationModel_preferential/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -16,11 +16,6 @@ customPDE::setInitialCondition(const dealii::Point &p, // Use "if" statements to set the initial condition for each variable // according to its variable index - double dx = userInputs.domain_size[0] / ((double) userInputs.subdivisions[0]) / - std::pow(2.0, userInputs.refine_factor); - - double r = 0.0; - // Initial condition for the concentration field if (index == 0) { @@ -41,12 +36,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/nucleationModel_preferential/customPDE.h b/applications/nucleationModel_preferential/customPDE.h index cab0326a8..1fcca29cc 100644 --- a/applications/nucleationModel_preferential/customPDE.h +++ b/applications/nucleationModel_preferential/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -10,23 +12,23 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -34,38 +36,47 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Virtual method in MatrixFreePDE that we override if we need nucleation #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, - double dV, - dealii::Point p, - unsigned int variable_index) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV, + [[maybe_unused]] Point p, + [[maybe_unused]] unsigned int variable_index) const override; #endif // ================================================================ @@ -75,13 +86,13 @@ class customPDE : public MatrixFreePDE // Method to place the nucleus and calculate the mobility modifier in // residualRHS void - seedNucleus(const dealii::Point> &q_point_loc, - dealii::VectorizedArray &source_term, - dealii::VectorizedArray &gamma) const; + seedNucleus(const Point> &q_point_loc, + VectorizedArray &source_term, + VectorizedArray &gamma) const; // Method to refine the mesh void - adaptiveRefineCriterion(); + adaptive_refinement_criterion(); // ================================================================ // Model constants specific to this subclass @@ -118,7 +129,7 @@ class customPDE : public MatrixFreePDE // region is adapted to the highest level template void -customPDE::adaptiveRefineCriterion() +customPDE::adaptive_refinement_criterion() { // Custom defined estimation criterion @@ -129,8 +140,8 @@ customPDE::adaptiveRefineCriterion() *(this->FESet[userInputs.refinement_criteria[0].variable_index]), quadrature, update_values | update_quadrature_points); - const unsigned int num_quad_points = quadrature.size(); - std::vector> q_point_list(num_quad_points); + const unsigned int num_quad_points = quadrature.size(); + std::vector> q_point_list(num_quad_points); std::vector errorOut(num_quad_points); diff --git a/applications/nucleationModel_preferential/equations.cc b/applications/nucleationModel_preferential/equations.cc index b3e3c48a6..637dddf4a 100644 --- a/applications/nucleationModel_preferential/equations.cc +++ b/applications/nucleationModel_preferential/equations.cc @@ -55,8 +55,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -81,22 +82,18 @@ customPDE::explicitEquationRHS( (A2 * hV + B2 * (1.0 - hV)); // Free energy for each phase and their first and second derivatives - scalarvalueType faV = A0 + A2 * (c_alpha - calmin) * (c_alpha - calmin); - scalarvalueType facV = 2.0 * A2 * (c_alpha - calmin); - scalarvalueType faccV = constV(2.0) * A2; - scalarvalueType fbV = B0 + B2 * (c_beta - cbtmin) * (c_beta - cbtmin); - scalarvalueType fbcV = 2.0 * B2 * (c_beta - cbtmin); - scalarvalueType fbccV = constV(2.0 * B2); + scalarvalueType faV = A0 + A2 * (c_alpha - calmin) * (c_alpha - calmin); + scalarvalueType fbV = B0 + B2 * (c_beta - cbtmin) * (c_beta - cbtmin); + scalarvalueType fbcV = 2.0 * B2 * (c_beta - cbtmin); // Double-Well function (can be used to tune the interfacial energy) - scalarvalueType fbarrierV = n * n - 2.0 * n * n * n + n * n * n * n; scalarvalueType fbarriernV = 2.0 * n - 6.0 * n * n + 4.0 * n * n * n; // ------------------------------------------------- // Nucleation expressions // ------------------------------------------------- - dealii::VectorizedArray source_term = constV(0.0); - dealii::VectorizedArray gamma = constV(1.0); + VectorizedArray source_term = constV(0.0); + VectorizedArray gamma = constV(1.0); seedNucleus(q_point_loc, source_term, gamma); // ------------------------------------------------- @@ -129,26 +126,22 @@ customPDE::explicitEquationRHS( template void customPDE::seedNucleus( - const dealii::Point> &q_point_loc, - dealii::VectorizedArray &source_term, - dealii::VectorizedArray &gamma) const + const Point> &q_point_loc, + VectorizedArray &source_term, + VectorizedArray &gamma) const { // Loop through all of the seeded nuclei - for (typename std::vector>::const_iterator thisNucleus = - this->nuclei.begin(); - thisNucleus != this->nuclei.end(); - ++thisNucleus) + for (const auto &thisNucleus : this->nuclei) { - if (thisNucleus->seededTime + thisNucleus->seedingTime > this->currentTime) + if (thisNucleus.seededTime + thisNucleus.seedingTime > this->currentTime) { // Calculate the weighted distance function to the order parameter // freeze boundary (weighted_dist = 1.0 on that boundary) - dealii::VectorizedArray weighted_dist = - this->weightedDistanceFromNucleusCenter( - thisNucleus->center, - userInputs.get_nucleus_freeze_semiaxes(thisNucleus->orderParameterIndex), - q_point_loc, - thisNucleus->orderParameterIndex); + VectorizedArray weighted_dist = this->weightedDistanceFromNucleusCenter( + thisNucleus.center, + userInputs.get_nucleus_freeze_semiaxes(thisNucleus.orderParameterIndex), + q_point_loc, + thisNucleus.orderParameterIndex); for (unsigned i = 0; i < gamma.size(); i++) { @@ -158,26 +151,26 @@ customPDE::seedNucleus( // Seed a nucleus if it was added to the list of nuclei this // time step - if (thisNucleus->seedingTimestep == this->currentIncrement) + if (thisNucleus.seedingTimestep == this->currentIncrement) { // Find the weighted distance to the outer edge of the // nucleus and use it to calculate the order parameter // source term (r = 1.0 on that boundary) - dealii::Point q_point_loc_element; + Point q_point_loc_element; for (unsigned int j = 0; j < dim; j++) { q_point_loc_element(j) = q_point_loc(j)[i]; } double r = this->weightedDistanceFromNucleusCenter( - thisNucleus->center, - userInputs.get_nucleus_semiaxes(thisNucleus->orderParameterIndex), + thisNucleus.center, + userInputs.get_nucleus_semiaxes(thisNucleus.orderParameterIndex), q_point_loc_element, - thisNucleus->orderParameterIndex); + thisNucleus.orderParameterIndex); double avg_semiaxis = 0.0; for (unsigned int j = 0; j < dim; j++) { - avg_semiaxis += thisNucleus->semiaxes[j]; + avg_semiaxis += thisNucleus.semiaxes[j]; } avg_semiaxis /= dim; @@ -207,8 +200,9 @@ customPDE::seedNucleus( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} // ============================================================================================= @@ -229,6 +223,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/nucleationModel_preferential/main.cc b/applications/nucleationModel_preferential/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/nucleationModel_preferential/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/nucleationModel_preferential/nucleation.cc b/applications/nucleationModel_preferential/nucleation.cc index b2fb70929..4a5638f58 100644 --- a/applications/nucleationModel_preferential/nucleation.cc +++ b/applications/nucleationModel_preferential/nucleation.cc @@ -7,10 +7,11 @@ // ================================================================================= template double -customPDE::getNucleationProbability(variableValueContainer variable_value, - double dV, - dealii::Point p, - unsigned int variable_index) const +customPDE::getNucleationProbability( + [[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV, + [[maybe_unused]] Point p, + [[maybe_unused]] unsigned int variable_index) const { // Supersaturation factor double ssf; diff --git a/applications/precipitateEvolution/CMakeLists.txt b/applications/precipitateEvolution/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/precipitateEvolution/CMakeLists.txt +++ b/applications/precipitateEvolution/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/precipitateEvolution/ICs_and_BCs.cc b/applications/precipitateEvolution/ICs_and_BCs.cc index b4faf0280..bfb3b7a84 100644 --- a/applications/precipitateEvolution/ICs_and_BCs.cc +++ b/applications/precipitateEvolution/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -70,12 +70,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/precipitateEvolution/customPDE.h b/applications/precipitateEvolution/customPDE.h index 45c4d5c97..6f15d6c46 100644 --- a/applications/precipitateEvolution/customPDE.h +++ b/applications/precipitateEvolution/customPDE.h @@ -1,4 +1,6 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; template class customPDE : public MatrixFreePDE @@ -9,23 +11,23 @@ class customPDE : public MatrixFreePDE , userInputs(_userInputs) {}; // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -33,35 +35,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -72,40 +84,37 @@ class customPDE : public MatrixFreePDE // Model constants specific to this subclass // ================================================================ - double McV = userInputs.get_model_constant_double("McV"); - double Mn1V = userInputs.get_model_constant_double("Mn1V"); - double Mn2V = userInputs.get_model_constant_double("Mn2V"); - double Mn3V = userInputs.get_model_constant_double("Mn3V"); - dealii::Tensor<2, dim> Kn1 = userInputs.get_model_constant_rank_2_tensor("Kn1"); - dealii::Tensor<2, dim> Kn2 = userInputs.get_model_constant_rank_2_tensor("Kn2"); - dealii::Tensor<2, dim> Kn3 = userInputs.get_model_constant_rank_2_tensor("Kn3"); - bool n_dependent_stiffness = + double McV = userInputs.get_model_constant_double("McV"); + double Mn1V = userInputs.get_model_constant_double("Mn1V"); + double Mn2V = userInputs.get_model_constant_double("Mn2V"); + double Mn3V = userInputs.get_model_constant_double("Mn3V"); + Tensor<2, dim> Kn1 = userInputs.get_model_constant_rank_2_tensor("Kn1"); + Tensor<2, dim> Kn2 = userInputs.get_model_constant_rank_2_tensor("Kn2"); + Tensor<2, dim> Kn3 = userInputs.get_model_constant_rank_2_tensor("Kn3"); + bool n_dependent_stiffness = userInputs.get_model_constant_bool("n_dependent_stiffness"); - dealii::Tensor<2, dim> sfts_linear1 = + Tensor<2, dim> sfts_linear1 = userInputs.get_model_constant_rank_2_tensor("sfts_linear1"); - dealii::Tensor<2, dim> sfts_const1 = - userInputs.get_model_constant_rank_2_tensor("sfts_const1"); - dealii::Tensor<2, dim> sfts_linear2 = + Tensor<2, dim> sfts_const1 = userInputs.get_model_constant_rank_2_tensor("sfts_const1"); + Tensor<2, dim> sfts_linear2 = userInputs.get_model_constant_rank_2_tensor("sfts_linear2"); - dealii::Tensor<2, dim> sfts_const2 = - userInputs.get_model_constant_rank_2_tensor("sfts_const2"); - dealii::Tensor<2, dim> sfts_linear3 = + Tensor<2, dim> sfts_const2 = userInputs.get_model_constant_rank_2_tensor("sfts_const2"); + Tensor<2, dim> sfts_linear3 = userInputs.get_model_constant_rank_2_tensor("sfts_linear3"); - dealii::Tensor<2, dim> sfts_const3 = - userInputs.get_model_constant_rank_2_tensor("sfts_const3"); - double A4 = userInputs.get_model_constant_double("A4"); - double A3 = userInputs.get_model_constant_double("A3"); - double A2 = userInputs.get_model_constant_double("A2"); - double A1 = userInputs.get_model_constant_double("A1"); - double A0 = userInputs.get_model_constant_double("A0"); - double B2 = userInputs.get_model_constant_double("B2"); - double B1 = userInputs.get_model_constant_double("B1"); - double B0 = userInputs.get_model_constant_double("B0"); + Tensor<2, dim> sfts_const3 = userInputs.get_model_constant_rank_2_tensor("sfts_const3"); + double A4 = userInputs.get_model_constant_double("A4"); + double A3 = userInputs.get_model_constant_double("A3"); + double A2 = userInputs.get_model_constant_double("A2"); + double A1 = userInputs.get_model_constant_double("A1"); + double A0 = userInputs.get_model_constant_double("A0"); + double B2 = userInputs.get_model_constant_double("B2"); + double B1 = userInputs.get_model_constant_double("B1"); + double B0 = userInputs.get_model_constant_double("B0"); - const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; - dealii::Tensor<2, CIJ_tensor_size> CIJ_Mg = + const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; + Tensor<2, CIJ_tensor_size> CIJ_Mg = userInputs.get_model_constant_elasticity_tensor("CIJ_Mg"); - dealii::Tensor<2, CIJ_tensor_size> CIJ_Beta = + Tensor<2, CIJ_tensor_size> CIJ_Beta = userInputs.get_model_constant_elasticity_tensor("CIJ_Beta"); // ================================================================ diff --git a/applications/precipitateEvolution/equations.cc b/applications/precipitateEvolution/equations.cc index 4fb3bab7d..2277cdf5b 100644 --- a/applications/precipitateEvolution/equations.cc +++ b/applications/precipitateEvolution/equations.cc @@ -77,8 +77,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -144,8 +145,8 @@ customPDE::explicitEquationRHS( // Calculate the stress-free transformation strain and its derivatives at the // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, - sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; + Tensor<2, dim, VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, sfts2c, sfts2cc, + sfts3, sfts3c, sfts3cc; for (unsigned int i = 0; i < dim; i++) { @@ -172,7 +173,7 @@ customPDE::explicitEquationRHS( } // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; + VectorizedArray E2[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -186,11 +187,11 @@ customPDE::explicitEquationRHS( // compute stress // S=C*(E-E0) // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; if (n_dependent_stiffness == true) { - dealii::VectorizedArray sum_hV; + VectorizedArray sum_hV; sum_hV = h1V + h2V + h3V; for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) { @@ -209,9 +210,9 @@ customPDE::explicitEquationRHS( // Compute one of the stress terms in the order parameter chemical potential, // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); + VectorizedArray nDependentMisfitAC1 = constV(0.0); + VectorizedArray nDependentMisfitAC2 = constV(0.0); + VectorizedArray nDependentMisfitAC3 = constV(0.0); for (unsigned int i = 0; i < dim; i++) { @@ -229,10 +230,10 @@ customPDE::explicitEquationRHS( // Compute the other stress term in the order parameter chemical potential, // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray heterMechAC2 = constV(0.0); - dealii::VectorizedArray heterMechAC3 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; + VectorizedArray heterMechAC1 = constV(0.0); + VectorizedArray heterMechAC2 = constV(0.0); + VectorizedArray heterMechAC3 = constV(0.0); + VectorizedArray S2[dim][dim]; if (n_dependent_stiffness == true) { @@ -258,7 +259,7 @@ customPDE::explicitEquationRHS( if (c_dependent_misfit == true) { - dealii::VectorizedArray E3[dim][dim], S3[dim][dim]; + VectorizedArray E3[dim][dim], S3[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -373,8 +374,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -405,7 +407,7 @@ customPDE::nonExplicitEquationRHS( // Calculate the stress-free transformation strain and its derivatives at the // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts2, sfts3; + Tensor<2, dim, VectorizedArray> sfts1, sfts2, sfts3; for (unsigned int i = 0; i < dim; i++) { @@ -424,7 +426,7 @@ customPDE::nonExplicitEquationRHS( } // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; + VectorizedArray E2[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -438,11 +440,11 @@ customPDE::nonExplicitEquationRHS( // compute stress // S=C*(E-E0) // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; if (n_dependent_stiffness == true) { - dealii::VectorizedArray sum_hV; + VectorizedArray sum_hV; sum_hV = h1V + h2V + h3V; for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) { @@ -491,8 +493,9 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -523,13 +526,13 @@ customPDE::equationLHS( // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; + Tensor<2, dim, VectorizedArray> E; E = symmetrize(Dux); // Compute stress tensor (which is equal to the residual, Rux) if (n_dependent_stiffness == true) { - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; + Tensor<2, CIJ_tensor_size, VectorizedArray> CIJ_combined; CIJ_combined = CIJ_Mg * (constV(1.0) - h1V - h2V - h3V) + CIJ_Beta * (h1V + h2V + h3V); diff --git a/applications/precipitateEvolution/main.cc b/applications/precipitateEvolution/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/precipitateEvolution/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/precipitateEvolution/postprocess.cc b/applications/precipitateEvolution/postprocess.cc index 727a498b7..7c1950d64 100644 --- a/applications/precipitateEvolution/postprocess.cc +++ b/applications/precipitateEvolution/postprocess.cc @@ -32,15 +32,17 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- // The concentration and its derivatives - scalarvalueType c = variable_list.get_scalar_value(0); - scalargradType cx = variable_list.get_scalar_gradient(0); + scalarvalueType c = variable_list.get_scalar_value(0); // The first order parameter and its derivatives scalarvalueType n1 = variable_list.get_scalar_value(1); @@ -103,8 +105,8 @@ customPDE::postProcessedFields( // Calculate the stress-free transformation strain and its derivatives at the // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, - sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; + Tensor<2, dim, VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, sfts2c, sfts2cc, + sfts3, sfts3c, sfts3cc; for (unsigned int i = 0; i < dim; i++) { @@ -131,7 +133,7 @@ customPDE::postProcessedFields( } // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; + VectorizedArray E2[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -146,11 +148,11 @@ customPDE::postProcessedFields( // compute stress // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; if (n_dependent_stiffness == true) { - dealii::VectorizedArray sum_hV; + VectorizedArray sum_hV; sum_hV = h1V + h2V + h3V; for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) { diff --git a/applications/precipitateEvolution_pfunction/CMakeLists.txt b/applications/precipitateEvolution_pfunction/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/precipitateEvolution_pfunction/CMakeLists.txt +++ b/applications/precipitateEvolution_pfunction/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/precipitateEvolution_pfunction/ICs_and_BCs.cc b/applications/precipitateEvolution_pfunction/ICs_and_BCs.cc index b4faf0280..bfb3b7a84 100644 --- a/applications/precipitateEvolution_pfunction/ICs_and_BCs.cc +++ b/applications/precipitateEvolution_pfunction/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -70,12 +70,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.hh b/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.hh index 4dbfcfee3..429fa896f 100644 --- a/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.hh +++ b/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.hh @@ -6,37 +6,35 @@ #ifndef PLIBRARY_HH #define PLIBRARY_HH -#include -#include "IntegrationTools/PFunction.hh" -#include "IntegrationTools/PPieceWise.hh" +#include "../../../include/IntegrationTools/PFunction.hh" +#include "../../../include/IntegrationTools/PPieceWise.hh" +#include namespace PRISMS { - /// Library where you can find functions and basis sets - /// - namespace PLibrary - { - // Use these functions to checkout objects which manage their own memory + /// Library where you can find functions and basis sets + /// + namespace PLibrary + { + // Use these functions to checkout objects which manage their own memory - void checkout( std::string name, PSimpleFunction< double*, double > &simplefunc); + void + checkout(std::string name, PSimpleFunction &simplefunc); - void checkout( std::string name, PFunction< double*, double > &func); + void + checkout(std::string name, PFunction &func); + // Use these functions to checkout new 'Base' objects which the user must delete + void + checkout(std::string name, PSimpleBase *&simplefunc); + void + checkout(std::string name, PFuncBase *&func); - // Use these functions to checkout new 'Base' objects which the user must delete - - void checkout( std::string name, PSimpleBase< double*, double > *&simplefunc); - - void checkout( std::string name, PFuncBase< double*, double > *&func); - - - - } - -} + } // namespace PLibrary +} // namespace PRISMS #endif diff --git a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh index d267db05b..5faba57b2 100644 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh +++ b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh @@ -6,128 +6,136 @@ #ifndef pfunct_McV_HH #define pfunct_McV_HH +#include "../../../include/IntegrationTools/PFunction.hh" #include #include -#include "IntegrationTools/PFunction.hh" namespace PRISMS { - template< class VarContainer> - class pfunct_McV_f : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return 1.0000000000000000e+00; - } - - public: - - pfunct_McV_f() - { - this->_name = "pfunct_McV_f"; - } - - std::string csrc() const - { - return "1.0000000000000000e+00"; - } - - std::string sym() const - { - return "1.0"; - } - - std::string latex() const - { - return "1.0"; - } - - pfunct_McV_f* clone() const - { - return new pfunct_McV_f(*this); - } - }; - - template - class pfunct_McV : public PFuncBase< VarContainer, double> - { - public: - - typedef typename PFuncBase< VarContainer, double>::size_type size_type; - - PSimpleBase< VarContainer, double> *_val; - PSimpleBase< VarContainer, double> **_grad_val; - PSimpleBase< VarContainer, double> ***_hess_val; - - pfunct_McV() - { - construct(); - } - - pfunct_McV(const pfunct_McV &RHS ) - { - construct(false); - - _val = RHS._val->clone(); - - } - - pfunct_McV& operator=( pfunct_McV RHS ) - { - using std::swap; - - swap(_val, RHS._val); - - return *this; - } - - ~pfunct_McV() - { - delete _val; - - } - - pfunct_McV* clone() const - { - return new pfunct_McV(*this); - } - - PSimpleFunction< VarContainer, double> simplefunction() const - { - return PSimpleFunction< VarContainer, double>( *_val ); - } - - double operator()(const VarContainer &var) - { - return (*_val)(var); - } - - void eval(const VarContainer &var) - { - (*_val)(var); - } - - double operator()() const - { - return (*_val)(); - } - - private: - void construct(bool allocate = true) - { - this->_name = "pfunct_McV"; - this->_var_name.clear(); - this->_var_name.push_back("c"); - this->_var_description.clear(); - this->_var_description.push_back("concentration"); - - if(!allocate) return; - - _val = new pfunct_McV_f(); - } - - }; - - -} + template + class pfunct_McV_f : public PSimpleBase + { + double + eval([[maybe_unused]] const VarContainer &var) const override + { + return 1.0000000000000000e+00; + } + + public: + pfunct_McV_f() + { + this->_name = "pfunct_McV_f"; + } + + std::string + csrc() const override + { + return "1.0000000000000000e+00"; + } + + std::string + sym() const override + { + return "1.0"; + } + + std::string + latex() const override + { + return "1.0"; + } + + pfunct_McV_f * + clone() const override + { + return new pfunct_McV_f(*this); + } + }; + + template + class pfunct_McV : public PFuncBase + { + public: + typedef typename PFuncBase::size_type size_type; + + PSimpleBase *_val; + PSimpleBase **_grad_val; + PSimpleBase ***_hess_val; + + pfunct_McV() + { + construct(); + } + + pfunct_McV(const pfunct_McV &RHS) + : PFuncBase(RHS) + { + construct(false); + + _val = RHS._val->clone(); + } + + pfunct_McV & + operator=(pfunct_McV RHS) + { + using std::swap; + + swap(_val, RHS._val); + + return *this; + } + + ~pfunct_McV() + { + delete _val; + } + + pfunct_McV * + clone() const override + { + return new pfunct_McV(*this); + } + + PSimpleFunction + simplefunction() const override + { + return PSimpleFunction(*_val); + } + + double + operator()(const VarContainer &var) override + { + return (*_val)(var); + } + + void + eval(const VarContainer &var) override + { + (*_val)(var); + } + + double + operator()() const override + { + return (*_val)(); + } + + private: + void + construct(bool allocate = true) + { + this->_name = "pfunct_McV"; + this->_var_name.clear(); + this->_var_name.push_back("c"); + this->_var_description.clear(); + this->_var_description.push_back("concentration"); + + if (!allocate) + return; + + _val = new pfunct_McV_f(); + } + }; + +} // namespace PRISMS #endif diff --git a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn1V.hh b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn1V.hh index eea85cc73..a1c8c2460 100644 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn1V.hh +++ b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn1V.hh @@ -6,128 +6,136 @@ #ifndef pfunct_Mn1V_HH #define pfunct_Mn1V_HH +#include "../../../include/IntegrationTools/PFunction.hh" #include #include -#include "IntegrationTools/PFunction.hh" namespace PRISMS { - template< class VarContainer> - class pfunct_Mn1V_f : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return 1.0000000000000000e+02; - } - - public: - - pfunct_Mn1V_f() - { - this->_name = "pfunct_Mn1V_f"; - } - - std::string csrc() const - { - return "1.0000000000000000e+02"; - } - - std::string sym() const - { - return "100.0"; - } - - std::string latex() const - { - return "100.0"; - } - - pfunct_Mn1V_f* clone() const - { - return new pfunct_Mn1V_f(*this); - } - }; - - template - class pfunct_Mn1V : public PFuncBase< VarContainer, double> - { - public: - - typedef typename PFuncBase< VarContainer, double>::size_type size_type; - - PSimpleBase< VarContainer, double> *_val; - PSimpleBase< VarContainer, double> **_grad_val; - PSimpleBase< VarContainer, double> ***_hess_val; - - pfunct_Mn1V() - { - construct(); - } - - pfunct_Mn1V(const pfunct_Mn1V &RHS ) - { - construct(false); - - _val = RHS._val->clone(); - - } - - pfunct_Mn1V& operator=( pfunct_Mn1V RHS ) - { - using std::swap; - - swap(_val, RHS._val); - - return *this; - } - - ~pfunct_Mn1V() - { - delete _val; - - } - - pfunct_Mn1V* clone() const - { - return new pfunct_Mn1V(*this); - } - - PSimpleFunction< VarContainer, double> simplefunction() const - { - return PSimpleFunction< VarContainer, double>( *_val ); - } - - double operator()(const VarContainer &var) - { - return (*_val)(var); - } - - void eval(const VarContainer &var) - { - (*_val)(var); - } - - double operator()() const - { - return (*_val)(); - } - - private: - void construct(bool allocate = true) - { - this->_name = "pfunct_Mn1V"; - this->_var_name.clear(); - this->_var_name.push_back("n1"); - this->_var_description.clear(); - this->_var_description.push_back("concentration"); - - if(!allocate) return; - - _val = new pfunct_Mn1V_f(); - } - - }; - - -} + template + class pfunct_Mn1V_f : public PSimpleBase + { + double + eval([[maybe_unused]] const VarContainer &var) const override + { + return 1.0000000000000000e+02; + } + + public: + pfunct_Mn1V_f() + { + this->_name = "pfunct_Mn1V_f"; + } + + std::string + csrc() const override + { + return "1.0000000000000000e+02"; + } + + std::string + sym() const override + { + return "100.0"; + } + + std::string + latex() const override + { + return "100.0"; + } + + pfunct_Mn1V_f * + clone() const override + { + return new pfunct_Mn1V_f(*this); + } + }; + + template + class pfunct_Mn1V : public PFuncBase + { + public: + typedef typename PFuncBase::size_type size_type; + + PSimpleBase *_val; + PSimpleBase **_grad_val; + PSimpleBase ***_hess_val; + + pfunct_Mn1V() + { + construct(); + } + + pfunct_Mn1V(const pfunct_Mn1V &RHS) + : PFuncBase(RHS) + { + construct(false); + + _val = RHS._val->clone(); + } + + pfunct_Mn1V & + operator=(pfunct_Mn1V RHS) + { + using std::swap; + + swap(_val, RHS._val); + + return *this; + } + + ~pfunct_Mn1V() + { + delete _val; + } + + pfunct_Mn1V * + clone() const override + { + return new pfunct_Mn1V(*this); + } + + PSimpleFunction + simplefunction() const override + { + return PSimpleFunction(*_val); + } + + double + operator()(const VarContainer &var) override + { + return (*_val)(var); + } + + void + eval(const VarContainer &var) override + { + (*_val)(var); + } + + double + operator()() const override + { + return (*_val)(); + } + + private: + void + construct(bool allocate = true) + { + this->_name = "pfunct_Mn1V"; + this->_var_name.clear(); + this->_var_name.push_back("n1"); + this->_var_description.clear(); + this->_var_description.push_back("concentration"); + + if (!allocate) + return; + + _val = new pfunct_Mn1V_f(); + } + }; + +} // namespace PRISMS #endif diff --git a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn2V.hh b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn2V.hh index 7d0d2d531..1d5d86b8e 100644 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn2V.hh +++ b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn2V.hh @@ -6,128 +6,136 @@ #ifndef pfunct_Mn2V_HH #define pfunct_Mn2V_HH +#include "../../../include/IntegrationTools/PFunction.hh" #include #include -#include "IntegrationTools/PFunction.hh" namespace PRISMS { - template< class VarContainer> - class pfunct_Mn2V_f : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return 1.0000000000000000e+02; - } - - public: - - pfunct_Mn2V_f() - { - this->_name = "pfunct_Mn2V_f"; - } - - std::string csrc() const - { - return "1.0000000000000000e+02"; - } - - std::string sym() const - { - return "100.0"; - } - - std::string latex() const - { - return "100.0"; - } - - pfunct_Mn2V_f* clone() const - { - return new pfunct_Mn2V_f(*this); - } - }; - - template - class pfunct_Mn2V : public PFuncBase< VarContainer, double> - { - public: - - typedef typename PFuncBase< VarContainer, double>::size_type size_type; - - PSimpleBase< VarContainer, double> *_val; - PSimpleBase< VarContainer, double> **_grad_val; - PSimpleBase< VarContainer, double> ***_hess_val; - - pfunct_Mn2V() - { - construct(); - } - - pfunct_Mn2V(const pfunct_Mn2V &RHS ) - { - construct(false); - - _val = RHS._val->clone(); - - } - - pfunct_Mn2V& operator=( pfunct_Mn2V RHS ) - { - using std::swap; - - swap(_val, RHS._val); - - return *this; - } - - ~pfunct_Mn2V() - { - delete _val; - - } - - pfunct_Mn2V* clone() const - { - return new pfunct_Mn2V(*this); - } - - PSimpleFunction< VarContainer, double> simplefunction() const - { - return PSimpleFunction< VarContainer, double>( *_val ); - } - - double operator()(const VarContainer &var) - { - return (*_val)(var); - } - - void eval(const VarContainer &var) - { - (*_val)(var); - } - - double operator()() const - { - return (*_val)(); - } - - private: - void construct(bool allocate = true) - { - this->_name = "pfunct_Mn2V"; - this->_var_name.clear(); - this->_var_name.push_back("n2"); - this->_var_description.clear(); - this->_var_description.push_back("concentration"); - - if(!allocate) return; - - _val = new pfunct_Mn2V_f(); - } - - }; - - -} + template + class pfunct_Mn2V_f : public PSimpleBase + { + double + eval([[maybe_unused]] const VarContainer &var) const override + { + return 1.0000000000000000e+02; + } + + public: + pfunct_Mn2V_f() + { + this->_name = "pfunct_Mn2V_f"; + } + + std::string + csrc() const override + { + return "1.0000000000000000e+02"; + } + + std::string + sym() const override + { + return "100.0"; + } + + std::string + latex() const override + { + return "100.0"; + } + + pfunct_Mn2V_f * + clone() const override + { + return new pfunct_Mn2V_f(*this); + } + }; + + template + class pfunct_Mn2V : public PFuncBase + { + public: + typedef typename PFuncBase::size_type size_type; + + PSimpleBase *_val; + PSimpleBase **_grad_val; + PSimpleBase ***_hess_val; + + pfunct_Mn2V() + { + construct(); + } + + pfunct_Mn2V(const pfunct_Mn2V &RHS) + : PFuncBase(RHS) + { + construct(false); + + _val = RHS._val->clone(); + } + + pfunct_Mn2V & + operator=(pfunct_Mn2V RHS) + { + using std::swap; + + swap(_val, RHS._val); + + return *this; + } + + ~pfunct_Mn2V() + { + delete _val; + } + + pfunct_Mn2V * + clone() const override + { + return new pfunct_Mn2V(*this); + } + + PSimpleFunction + simplefunction() const override + { + return PSimpleFunction(*_val); + } + + double + operator()(const VarContainer &var) override + { + return (*_val)(var); + } + + void + eval(const VarContainer &var) override + { + (*_val)(var); + } + + double + operator()() const override + { + return (*_val)(); + } + + private: + void + construct(bool allocate = true) + { + this->_name = "pfunct_Mn2V"; + this->_var_name.clear(); + this->_var_name.push_back("n2"); + this->_var_description.clear(); + this->_var_description.push_back("concentration"); + + if (!allocate) + return; + + _val = new pfunct_Mn2V_f(); + } + }; + +} // namespace PRISMS #endif diff --git a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn3V.hh b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn3V.hh index 6b2b87f23..5ffe9207a 100644 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn3V.hh +++ b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn3V.hh @@ -6,128 +6,136 @@ #ifndef pfunct_Mn3V_HH #define pfunct_Mn3V_HH +#include "../../../include/IntegrationTools/PFunction.hh" #include #include -#include "IntegrationTools/PFunction.hh" namespace PRISMS { - template< class VarContainer> - class pfunct_Mn3V_f : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return 1.0000000000000000e+02; - } - - public: - - pfunct_Mn3V_f() - { - this->_name = "pfunct_Mn3V_f"; - } - - std::string csrc() const - { - return "1.0000000000000000e+02"; - } - - std::string sym() const - { - return "100.0"; - } - - std::string latex() const - { - return "100.0"; - } - - pfunct_Mn3V_f* clone() const - { - return new pfunct_Mn3V_f(*this); - } - }; - - template - class pfunct_Mn3V : public PFuncBase< VarContainer, double> - { - public: - - typedef typename PFuncBase< VarContainer, double>::size_type size_type; - - PSimpleBase< VarContainer, double> *_val; - PSimpleBase< VarContainer, double> **_grad_val; - PSimpleBase< VarContainer, double> ***_hess_val; - - pfunct_Mn3V() - { - construct(); - } - - pfunct_Mn3V(const pfunct_Mn3V &RHS ) - { - construct(false); - - _val = RHS._val->clone(); - - } - - pfunct_Mn3V& operator=( pfunct_Mn3V RHS ) - { - using std::swap; - - swap(_val, RHS._val); - - return *this; - } - - ~pfunct_Mn3V() - { - delete _val; - - } - - pfunct_Mn3V* clone() const - { - return new pfunct_Mn3V(*this); - } - - PSimpleFunction< VarContainer, double> simplefunction() const - { - return PSimpleFunction< VarContainer, double>( *_val ); - } - - double operator()(const VarContainer &var) - { - return (*_val)(var); - } - - void eval(const VarContainer &var) - { - (*_val)(var); - } - - double operator()() const - { - return (*_val)(); - } - - private: - void construct(bool allocate = true) - { - this->_name = "pfunct_Mn3V"; - this->_var_name.clear(); - this->_var_name.push_back("n3"); - this->_var_description.clear(); - this->_var_description.push_back("concentration"); - - if(!allocate) return; - - _val = new pfunct_Mn3V_f(); - } - - }; - - -} + template + class pfunct_Mn3V_f : public PSimpleBase + { + double + eval([[maybe_unused]] const VarContainer &var) const override + { + return 1.0000000000000000e+02; + } + + public: + pfunct_Mn3V_f() + { + this->_name = "pfunct_Mn3V_f"; + } + + std::string + csrc() const override + { + return "1.0000000000000000e+02"; + } + + std::string + sym() const override + { + return "100.0"; + } + + std::string + latex() const override + { + return "100.0"; + } + + pfunct_Mn3V_f * + clone() const override + { + return new pfunct_Mn3V_f(*this); + } + }; + + template + class pfunct_Mn3V : public PFuncBase + { + public: + typedef typename PFuncBase::size_type size_type; + + PSimpleBase *_val; + PSimpleBase **_grad_val; + PSimpleBase ***_hess_val; + + pfunct_Mn3V() + { + construct(); + } + + pfunct_Mn3V(const pfunct_Mn3V &RHS) + : PFuncBase(RHS) + { + construct(false); + + _val = RHS._val->clone(); + } + + pfunct_Mn3V & + operator=(pfunct_Mn3V RHS) + { + using std::swap; + + swap(_val, RHS._val); + + return *this; + } + + ~pfunct_Mn3V() + { + delete _val; + } + + pfunct_Mn3V * + clone() const override + { + return new pfunct_Mn3V(*this); + } + + PSimpleFunction + simplefunction() const override + { + return PSimpleFunction(*_val); + } + + double + operator()(const VarContainer &var) override + { + return (*_val)(var); + } + + void + eval(const VarContainer &var) override + { + (*_val)(var); + } + + double + operator()() const override + { + return (*_val)(); + } + + private: + void + construct(bool allocate = true) + { + this->_name = "pfunct_Mn3V"; + this->_var_name.clear(); + this->_var_name.push_back("n3"); + this->_var_description.clear(); + this->_var_description.push_back("concentration"); + + if (!allocate) + return; + + _val = new pfunct_Mn3V_f(); + } + }; + +} // namespace PRISMS #endif diff --git a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_faV.hh b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_faV.hh index 57557931b..e3b6cdf3d 100644 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_faV.hh +++ b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_faV.hh @@ -6,259 +6,295 @@ #ifndef pfunct_faV_HH #define pfunct_faV_HH +#include "../../../include/IntegrationTools/PFunction.hh" #include #include -#include "IntegrationTools/PFunction.hh" namespace PRISMS { - template< class VarContainer> - class pfunct_faV_f : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return 5.1622000000000003e+00*(var[0]*var[0])+-2.7374999999999998e+00*(var[0]*var[0]*var[0])+-4.7759999999999998e+00*var[0]+1.3687000000000000e+00*((var[0]*var[0])*(var[0]*var[0]))-1.6704000000000001e+00; - } - - public: - - pfunct_faV_f() - { - this->_name = "pfunct_faV_f"; - } - - std::string csrc() const - { - return " 5.1622000000000003e+00*(var[0]*var[0])+-2.7374999999999998e+00*(var[0]*var[0]*var[0])+-4.7759999999999998e+00*var[0]+1.3687000000000000e+00*((var[0]*var[0])*(var[0]*var[0]))-1.6704000000000001e+00"; - } - - std::string sym() const - { - return "-1.6704+(1.3687)*c^4+(5.1622)*c^2-(2.7375)*c^3-(4.776)*c"; - } - - std::string latex() const - { - return "-1.6704+{(5.1622)} c^{2}-{(4.776)} c-{(2.7375)} c^{3}+{(1.3687)} c^{4}"; - } - - pfunct_faV_f* clone() const - { - return new pfunct_faV_f(*this); - } - }; - - template< class VarContainer> - class pfunct_faV_grad_0 : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return 5.4748000000000001e+00*(var[0]*var[0]*var[0])+-8.2125000000000004e+00*(var[0]*var[0])+1.0324400000000001e+01*var[0]-4.7759999999999998e+00; - } - - public: - - pfunct_faV_grad_0() - { - this->_name = "pfunct_faV_grad_0"; - } - - std::string csrc() const - { - return " 5.4748000000000001e+00*(var[0]*var[0]*var[0])+-8.2125000000000004e+00*(var[0]*var[0])+1.0324400000000001e+01*var[0]-4.7759999999999998e+00"; - } - - std::string sym() const - { - return "-4.776+(10.3244)*c+(5.4748)*c^3-(8.2125)*c^2"; - } - - std::string latex() const - { - return "-4.776+{(5.4748)} c^{3}-{(8.2125)} c^{2}+{(10.3244)} c"; - } - - pfunct_faV_grad_0* clone() const - { - return new pfunct_faV_grad_0(*this); - } - }; - - template< class VarContainer> - class pfunct_faV_hess_0_0 : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return 1.6424399999999999e+01*(var[0]*var[0])+-1.6425000000000001e+01*var[0]+1.0324400000000001e+01; - } - - public: - - pfunct_faV_hess_0_0() - { - this->_name = "pfunct_faV_hess_0_0"; - } - - std::string csrc() const - { - return " 1.6424399999999999e+01*(var[0]*var[0])+-1.6425000000000001e+01*var[0]+1.0324400000000001e+01"; - } - - std::string sym() const - { - return "10.3244-(16.425)*c+(16.4244)*c^2"; - } - - std::string latex() const - { - return "10.3244+{(16.4244)} c^{2}-{(16.425)} c"; - } - - pfunct_faV_hess_0_0* clone() const - { - return new pfunct_faV_hess_0_0(*this); - } - }; - - template - class pfunct_faV : public PFuncBase< VarContainer, double> - { - public: - - typedef typename PFuncBase< VarContainer, double>::size_type size_type; - - PSimpleBase< VarContainer, double> *_val; - PSimpleBase< VarContainer, double> **_grad_val; - PSimpleBase< VarContainer, double> ***_hess_val; - - pfunct_faV() - { - construct(); - } - - pfunct_faV(const pfunct_faV &RHS ) - { - construct(false); - - _val = RHS._val->clone(); - _grad_val[0] = RHS._grad_val[0]->clone(); - _hess_val[0][0] = RHS._hess_val[0][0]->clone(); - - } - - pfunct_faV& operator=( pfunct_faV RHS ) - { - using std::swap; - - swap(_val, RHS._val); - swap(_grad_val[0], RHS._grad_val[0]); - swap(_hess_val[0][0], RHS._hess_val[0][0]); - - return *this; - } - - ~pfunct_faV() - { - delete _val; - - delete _grad_val[0]; - delete [] _grad_val; - - delete _hess_val[0][0]; - delete [] _hess_val[0]; - delete [] _hess_val; - } - - pfunct_faV* clone() const - { - return new pfunct_faV(*this); - } - - PSimpleFunction< VarContainer, double> simplefunction() const - { - return PSimpleFunction< VarContainer, double>( *_val ); - } - - PSimpleFunction< VarContainer, double> grad_simplefunction(size_type di) const - { - return PSimpleFunction< VarContainer, double>( *_grad_val[di] ); - } - - PSimpleFunction< VarContainer, double> hess_simplefunction(size_type di, size_type dj) const - { - return PSimpleFunction< VarContainer, double>( *_hess_val[di][dj] ); - } - - double operator()(const VarContainer &var) - { - return (*_val)(var); - } - - double grad(const VarContainer &var, size_type di) - { - return (*_grad_val[di])(var); - } - - double hess(const VarContainer &var, size_type di, size_type dj) - { - return (*_hess_val[di][dj])(var); - } - - void eval(const VarContainer &var) - { - (*_val)(var); - } - - void eval_grad(const VarContainer &var) - { - (*_grad_val[0])(var); - } - - void eval_hess(const VarContainer &var) - { - (*_hess_val[0][0])(var); - } - - double operator()() const - { - return (*_val)(); - } - - double grad(size_type di) const - { - return (*_grad_val[di])(); - } - - double hess(size_type di, size_type dj) const - { - return (*_hess_val[di][dj])(); - } - - private: - void construct(bool allocate = true) - { - this->_name = "pfunct_faV"; - this->_var_name.clear(); - this->_var_name.push_back("c"); - this->_var_description.clear(); - this->_var_description.push_back("concentration"); - - _grad_val = new PSimpleBase< VarContainer, double>*[1]; - - _hess_val = new PSimpleBase< VarContainer, double>**[1]; - _hess_val[0] = new PSimpleBase< VarContainer, double>*[1]; - - if(!allocate) return; - - _val = new pfunct_faV_f(); - - _grad_val[0] = new pfunct_faV_grad_0(); - - _hess_val[0][0] = new pfunct_faV_hess_0_0(); - } - - }; - - -} + template + class pfunct_faV_f : public PSimpleBase + { + double + eval(const VarContainer &var) const override + { + return 5.1622000000000003e+00 * (var[0] * var[0]) + + -2.7374999999999998e+00 * (var[0] * var[0] * var[0]) + + -4.7759999999999998e+00 * var[0] + + 1.3687000000000000e+00 * ((var[0] * var[0]) * (var[0] * var[0])) - + 1.6704000000000001e+00; + } + + public: + pfunct_faV_f() + { + this->_name = "pfunct_faV_f"; + } + + std::string + csrc() const override + { + return " 5.1622000000000003e+00*(var[0]*var[0])+-2.7374999999999998e+00*(var[0]*" + "var[0]*var[0])+-4.7759999999999998e+00*var[0]+1.3687000000000000e+00*((var[" + "0]*var[0])*(var[0]*var[0]))-1.6704000000000001e+00"; + } + + std::string + sym() const override + { + return "-1.6704+(1.3687)*c^4+(5.1622)*c^2-(2.7375)*c^3-(4.776)*c"; + } + + std::string + latex() const override + { + return "-1.6704+{(5.1622)} c^{2}-{(4.776)} c-{(2.7375)} c^{3}+{(1.3687)} c^{4}"; + } + + pfunct_faV_f * + clone() const override + { + return new pfunct_faV_f(*this); + } + }; + + template + class pfunct_faV_grad_0 : public PSimpleBase + { + double + eval(const VarContainer &var) const override + { + return 5.4748000000000001e+00 * (var[0] * var[0] * var[0]) + + -8.2125000000000004e+00 * (var[0] * var[0]) + + 1.0324400000000001e+01 * var[0] - 4.7759999999999998e+00; + } + + public: + pfunct_faV_grad_0() + { + this->_name = "pfunct_faV_grad_0"; + } + + std::string + csrc() const override + { + return " 5.4748000000000001e+00*(var[0]*var[0]*var[0])+-8.2125000000000004e+00*(" + "var[0]*var[0])+1.0324400000000001e+01*var[0]-4.7759999999999998e+00"; + } + + std::string + sym() const override + { + return "-4.776+(10.3244)*c+(5.4748)*c^3-(8.2125)*c^2"; + } + + std::string + latex() const override + { + return "-4.776+{(5.4748)} c^{3}-{(8.2125)} c^{2}+{(10.3244)} c"; + } + + pfunct_faV_grad_0 * + clone() const override + { + return new pfunct_faV_grad_0(*this); + } + }; + + template + class pfunct_faV_hess_0_0 : public PSimpleBase + { + double + eval(const VarContainer &var) const override + { + return 1.6424399999999999e+01 * (var[0] * var[0]) + + -1.6425000000000001e+01 * var[0] + 1.0324400000000001e+01; + } + + public: + pfunct_faV_hess_0_0() + { + this->_name = "pfunct_faV_hess_0_0"; + } + + std::string + csrc() const override + { + return " 1.6424399999999999e+01*(var[0]*var[0])+-1.6425000000000001e+01*var[0]+1." + "0324400000000001e+01"; + } + + std::string + sym() const override + { + return "10.3244-(16.425)*c+(16.4244)*c^2"; + } + + std::string + latex() const override + { + return "10.3244+{(16.4244)} c^{2}-{(16.425)} c"; + } + + pfunct_faV_hess_0_0 * + clone() const override + { + return new pfunct_faV_hess_0_0(*this); + } + }; + + template + class pfunct_faV : public PFuncBase + { + public: + typedef typename PFuncBase::size_type size_type; + + PSimpleBase *_val; + PSimpleBase **_grad_val; + PSimpleBase ***_hess_val; + + pfunct_faV() + { + construct(); + } + + pfunct_faV(const pfunct_faV &RHS) + : PFuncBase(RHS) + { + construct(false); + + _val = RHS._val->clone(); + _grad_val[0] = RHS._grad_val[0]->clone(); + _hess_val[0][0] = RHS._hess_val[0][0]->clone(); + } + + pfunct_faV & + operator=(pfunct_faV RHS) + { + using std::swap; + + swap(_val, RHS._val); + swap(_grad_val[0], RHS._grad_val[0]); + swap(_hess_val[0][0], RHS._hess_val[0][0]); + + return *this; + } + + ~pfunct_faV() + { + delete _val; + + delete _grad_val[0]; + delete[] _grad_val; + + delete _hess_val[0][0]; + delete[] _hess_val[0]; + delete[] _hess_val; + } + + pfunct_faV * + clone() const override + { + return new pfunct_faV(*this); + } + + PSimpleFunction + simplefunction() const override + { + return PSimpleFunction(*_val); + } + + PSimpleFunction + grad_simplefunction(size_type di) const override + { + return PSimpleFunction(*_grad_val[di]); + } + + PSimpleFunction + hess_simplefunction(size_type di, size_type dj) const override + { + return PSimpleFunction(*_hess_val[di][dj]); + } + + double + operator()(const VarContainer &var) override + { + return (*_val)(var); + } + + double + grad(const VarContainer &var, size_type di) override + { + return (*_grad_val[di])(var); + } + + double + hess(const VarContainer &var, size_type di, size_type dj) override + { + return (*_hess_val[di][dj])(var); + } + + void + eval(const VarContainer &var) override + { + (*_val)(var); + } + + void + eval_grad(const VarContainer &var) override + { + (*_grad_val[0])(var); + } + + void + eval_hess(const VarContainer &var) override + { + (*_hess_val[0][0])(var); + } + + double + operator()() const override + { + return (*_val)(); + } + + double + grad(size_type di) const override + { + return (*_grad_val[di])(); + } + + double + hess(size_type di, size_type dj) const override + { + return (*_hess_val[di][dj])(); + } + + private: + void + construct(bool allocate = true) + { + this->_name = "pfunct_faV"; + this->_var_name.clear(); + this->_var_name.push_back("c"); + this->_var_description.clear(); + this->_var_description.push_back("concentration"); + + _grad_val = new PSimpleBase *[1]; + + _hess_val = new PSimpleBase **[1]; + _hess_val[0] = new PSimpleBase *[1]; + + if (!allocate) + return; + + _val = new pfunct_faV_f(); + + _grad_val[0] = new pfunct_faV_grad_0(); + + _hess_val[0][0] = new pfunct_faV_hess_0_0(); + } + }; + +} // namespace PRISMS #endif diff --git a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_fbV.hh b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_fbV.hh index a9bafc7f3..ce90a1c82 100644 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_fbV.hh +++ b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_fbV.hh @@ -6,259 +6,286 @@ #ifndef pfunct_fbV_HH #define pfunct_fbV_HH +#include "../../../include/IntegrationTools/PFunction.hh" #include #include -#include "IntegrationTools/PFunction.hh" namespace PRISMS { - template< class VarContainer> - class pfunct_fbV_f : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return -5.9745999999999997e+00*var[0]+5.0000000000000000e+00*(var[0]*var[0])-1.5924000000000000e+00; - } - - public: - - pfunct_fbV_f() - { - this->_name = "pfunct_fbV_f"; - } - - std::string csrc() const - { - return " -5.9745999999999997e+00*var[0]+5.0000000000000000e+00*(var[0]*var[0])-1.5924000000000000e+00"; - } - - std::string sym() const - { - return "-1.5924-(5.9746)*c+(5.0)*c^2"; - } - - std::string latex() const - { - return "-1.5924+{(5.0)} c^{2}-{(5.9746)} c"; - } - - pfunct_fbV_f* clone() const - { - return new pfunct_fbV_f(*this); - } - }; - - template< class VarContainer> - class pfunct_fbV_grad_0 : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return 1.0000000000000000e+01*var[0]-5.9745999999999997e+00; - } - - public: - - pfunct_fbV_grad_0() - { - this->_name = "pfunct_fbV_grad_0"; - } - - std::string csrc() const - { - return " 1.0000000000000000e+01*var[0]-5.9745999999999997e+00"; - } - - std::string sym() const - { - return "-5.9746+(10.0)*c"; - } - - std::string latex() const - { - return "-5.9746+{(10.0)} c"; - } - - pfunct_fbV_grad_0* clone() const - { - return new pfunct_fbV_grad_0(*this); - } - }; - - template< class VarContainer> - class pfunct_fbV_hess_0_0 : public PSimpleBase< VarContainer, double> - { - double eval( const VarContainer &var) const - { - return 1.0000000000000000e+01; - } - - public: - - pfunct_fbV_hess_0_0() - { - this->_name = "pfunct_fbV_hess_0_0"; - } - - std::string csrc() const - { - return "1.0000000000000000e+01"; - } - - std::string sym() const - { - return "10.0"; - } - - std::string latex() const - { - return "10.0"; - } - - pfunct_fbV_hess_0_0* clone() const - { - return new pfunct_fbV_hess_0_0(*this); - } - }; - - template - class pfunct_fbV : public PFuncBase< VarContainer, double> - { - public: - - typedef typename PFuncBase< VarContainer, double>::size_type size_type; - - PSimpleBase< VarContainer, double> *_val; - PSimpleBase< VarContainer, double> **_grad_val; - PSimpleBase< VarContainer, double> ***_hess_val; - - pfunct_fbV() - { - construct(); - } - - pfunct_fbV(const pfunct_fbV &RHS ) - { - construct(false); - - _val = RHS._val->clone(); - _grad_val[0] = RHS._grad_val[0]->clone(); - _hess_val[0][0] = RHS._hess_val[0][0]->clone(); - - } - - pfunct_fbV& operator=( pfunct_fbV RHS ) - { - using std::swap; - - swap(_val, RHS._val); - swap(_grad_val[0], RHS._grad_val[0]); - swap(_hess_val[0][0], RHS._hess_val[0][0]); - - return *this; - } - - ~pfunct_fbV() - { - delete _val; - - delete _grad_val[0]; - delete [] _grad_val; - - delete _hess_val[0][0]; - delete [] _hess_val[0]; - delete [] _hess_val; - } - - pfunct_fbV* clone() const - { - return new pfunct_fbV(*this); - } - - PSimpleFunction< VarContainer, double> simplefunction() const - { - return PSimpleFunction< VarContainer, double>( *_val ); - } - - PSimpleFunction< VarContainer, double> grad_simplefunction(size_type di) const - { - return PSimpleFunction< VarContainer, double>( *_grad_val[di] ); - } - - PSimpleFunction< VarContainer, double> hess_simplefunction(size_type di, size_type dj) const - { - return PSimpleFunction< VarContainer, double>( *_hess_val[di][dj] ); - } - - double operator()(const VarContainer &var) - { - return (*_val)(var); - } - - double grad(const VarContainer &var, size_type di) - { - return (*_grad_val[di])(var); - } - - double hess(const VarContainer &var, size_type di, size_type dj) - { - return (*_hess_val[di][dj])(var); - } - - void eval(const VarContainer &var) - { - (*_val)(var); - } - - void eval_grad(const VarContainer &var) - { - (*_grad_val[0])(var); - } - - void eval_hess(const VarContainer &var) - { - (*_hess_val[0][0])(var); - } - - double operator()() const - { - return (*_val)(); - } - - double grad(size_type di) const - { - return (*_grad_val[di])(); - } - - double hess(size_type di, size_type dj) const - { - return (*_hess_val[di][dj])(); - } - - private: - void construct(bool allocate = true) - { - this->_name = "pfunct_fbV"; - this->_var_name.clear(); - this->_var_name.push_back("c"); - this->_var_description.clear(); - this->_var_description.push_back("concentration"); - - _grad_val = new PSimpleBase< VarContainer, double>*[1]; - - _hess_val = new PSimpleBase< VarContainer, double>**[1]; - _hess_val[0] = new PSimpleBase< VarContainer, double>*[1]; - - if(!allocate) return; - - _val = new pfunct_fbV_f(); - - _grad_val[0] = new pfunct_fbV_grad_0(); - - _hess_val[0][0] = new pfunct_fbV_hess_0_0(); - } - - }; - - -} + template + class pfunct_fbV_f : public PSimpleBase + { + double + eval(const VarContainer &var) const override + { + return -5.9745999999999997e+00 * var[0] + + 5.0000000000000000e+00 * (var[0] * var[0]) - 1.5924000000000000e+00; + } + + public: + pfunct_fbV_f() + { + this->_name = "pfunct_fbV_f"; + } + + std::string + csrc() const override + { + return " -5.9745999999999997e+00*var[0]+5.0000000000000000e+00*(var[0]*var[0])-1." + "5924000000000000e+00"; + } + + std::string + sym() const override + { + return "-1.5924-(5.9746)*c+(5.0)*c^2"; + } + + std::string + latex() const override + { + return "-1.5924+{(5.0)} c^{2}-{(5.9746)} c"; + } + + pfunct_fbV_f * + clone() const override + { + return new pfunct_fbV_f(*this); + } + }; + + template + class pfunct_fbV_grad_0 : public PSimpleBase + { + double + eval(const VarContainer &var) const override + { + return 1.0000000000000000e+01 * var[0] - 5.9745999999999997e+00; + } + + public: + pfunct_fbV_grad_0() + { + this->_name = "pfunct_fbV_grad_0"; + } + + std::string + csrc() const override + { + return " 1.0000000000000000e+01*var[0]-5.9745999999999997e+00"; + } + + std::string + sym() const override + { + return "-5.9746+(10.0)*c"; + } + + std::string + latex() const override + { + return "-5.9746+{(10.0)} c"; + } + + pfunct_fbV_grad_0 * + clone() const override + { + return new pfunct_fbV_grad_0(*this); + } + }; + + template + class pfunct_fbV_hess_0_0 : public PSimpleBase + { + double + eval([[maybe_unused]] const VarContainer &var) const override + { + return 1.0000000000000000e+01; + } + + public: + pfunct_fbV_hess_0_0() + { + this->_name = "pfunct_fbV_hess_0_0"; + } + + std::string + csrc() const override + { + return "1.0000000000000000e+01"; + } + + std::string + sym() const override + { + return "10.0"; + } + + std::string + latex() const override + { + return "10.0"; + } + + pfunct_fbV_hess_0_0 * + clone() const override + { + return new pfunct_fbV_hess_0_0(*this); + } + }; + + template + class pfunct_fbV : public PFuncBase + { + public: + typedef typename PFuncBase::size_type size_type; + + PSimpleBase *_val; + PSimpleBase **_grad_val; + PSimpleBase ***_hess_val; + + pfunct_fbV() + { + construct(); + } + + pfunct_fbV(const pfunct_fbV &RHS) + : PFuncBase(RHS) + { + construct(false); + + _val = RHS._val->clone(); + _grad_val[0] = RHS._grad_val[0]->clone(); + _hess_val[0][0] = RHS._hess_val[0][0]->clone(); + } + + pfunct_fbV & + operator=(pfunct_fbV RHS) + { + using std::swap; + + swap(_val, RHS._val); + swap(_grad_val[0], RHS._grad_val[0]); + swap(_hess_val[0][0], RHS._hess_val[0][0]); + + return *this; + } + + ~pfunct_fbV() + { + delete _val; + + delete _grad_val[0]; + delete[] _grad_val; + + delete _hess_val[0][0]; + delete[] _hess_val[0]; + delete[] _hess_val; + } + + pfunct_fbV * + clone() const override + { + return new pfunct_fbV(*this); + } + + PSimpleFunction + simplefunction() const override + { + return PSimpleFunction(*_val); + } + + PSimpleFunction + grad_simplefunction(size_type di) const override + { + return PSimpleFunction(*_grad_val[di]); + } + + PSimpleFunction + hess_simplefunction(size_type di, size_type dj) const override + { + return PSimpleFunction(*_hess_val[di][dj]); + } + + double + operator()(const VarContainer &var) override + { + return (*_val)(var); + } + + double + grad(const VarContainer &var, size_type di) override + { + return (*_grad_val[di])(var); + } + + double + hess(const VarContainer &var, size_type di, size_type dj) override + { + return (*_hess_val[di][dj])(var); + } + + void + eval(const VarContainer &var) override + { + (*_val)(var); + } + + void + eval_grad(const VarContainer &var) override + { + (*_grad_val[0])(var); + } + + void + eval_hess(const VarContainer &var) override + { + (*_hess_val[0][0])(var); + } + + double + operator()() const override + { + return (*_val)(); + } + + double + grad(size_type di) const override + { + return (*_grad_val[di])(); + } + + double + hess(size_type di, size_type dj) const override + { + return (*_hess_val[di][dj])(); + } + + private: + void + construct(bool allocate = true) + { + this->_name = "pfunct_fbV"; + this->_var_name.clear(); + this->_var_name.push_back("c"); + this->_var_description.clear(); + this->_var_description.push_back("concentration"); + + _grad_val = new PSimpleBase *[1]; + + _hess_val = new PSimpleBase **[1]; + _hess_val[0] = new PSimpleBase *[1]; + + if (!allocate) + return; + + _val = new pfunct_fbV_f(); + + _grad_val[0] = new pfunct_fbV_grad_0(); + + _hess_val[0][0] = new pfunct_fbV_hess_0_0(); + } + }; + +} // namespace PRISMS #endif diff --git a/applications/precipitateEvolution_pfunction/customPDE.h b/applications/precipitateEvolution_pfunction/customPDE.h index 486e77ccc..969f98d04 100644 --- a/applications/precipitateEvolution_pfunction/customPDE.h +++ b/applications/precipitateEvolution_pfunction/customPDE.h @@ -1,11 +1,12 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + +using namespace dealii; // Header files for PFunctions -typedef dealii::VectorizedArray scalarvalueType; +typedef VectorizedArray scalarvalueType; #include "PLibrary/PLibrary.cc" #include "PLibrary/PLibrary.hh" - -#include "../../src/pFunction/pFunction.h" +#include "pFunction/pFunction.h" // Declare the PFunctions to be used PFunctions::pFunction pfunct_McV("pfunct_McV"), pfunct_Mn1V("pfunct_Mn1V"), @@ -21,23 +22,23 @@ class customPDE : public MatrixFreePDE , userInputs(_userInputs) {}; // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -45,35 +46,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ @@ -84,36 +95,33 @@ class customPDE : public MatrixFreePDE // Model constants specific to this subclass // ================================================================ - dealii::Tensor<2, dim> Kn1 = userInputs.get_model_constant_rank_2_tensor("Kn1"); - dealii::Tensor<2, dim> Kn2 = userInputs.get_model_constant_rank_2_tensor("Kn2"); - dealii::Tensor<2, dim> Kn3 = userInputs.get_model_constant_rank_2_tensor("Kn3"); - bool n_dependent_stiffness = + Tensor<2, dim> Kn1 = userInputs.get_model_constant_rank_2_tensor("Kn1"); + Tensor<2, dim> Kn2 = userInputs.get_model_constant_rank_2_tensor("Kn2"); + Tensor<2, dim> Kn3 = userInputs.get_model_constant_rank_2_tensor("Kn3"); + bool n_dependent_stiffness = userInputs.get_model_constant_bool("n_dependent_stiffness"); - dealii::Tensor<2, dim> sfts_linear1 = + Tensor<2, dim> sfts_linear1 = userInputs.get_model_constant_rank_2_tensor("sfts_linear1"); - dealii::Tensor<2, dim> sfts_const1 = - userInputs.get_model_constant_rank_2_tensor("sfts_const1"); - dealii::Tensor<2, dim> sfts_linear2 = + Tensor<2, dim> sfts_const1 = userInputs.get_model_constant_rank_2_tensor("sfts_const1"); + Tensor<2, dim> sfts_linear2 = userInputs.get_model_constant_rank_2_tensor("sfts_linear2"); - dealii::Tensor<2, dim> sfts_const2 = - userInputs.get_model_constant_rank_2_tensor("sfts_const2"); - dealii::Tensor<2, dim> sfts_linear3 = + Tensor<2, dim> sfts_const2 = userInputs.get_model_constant_rank_2_tensor("sfts_const2"); + Tensor<2, dim> sfts_linear3 = userInputs.get_model_constant_rank_2_tensor("sfts_linear3"); - dealii::Tensor<2, dim> sfts_const3 = - userInputs.get_model_constant_rank_2_tensor("sfts_const3"); - double A4 = userInputs.get_model_constant_double("A4"); - double A3 = userInputs.get_model_constant_double("A3"); - double A2 = userInputs.get_model_constant_double("A2"); - double A1 = userInputs.get_model_constant_double("A1"); - double A0 = userInputs.get_model_constant_double("A0"); - double B2 = userInputs.get_model_constant_double("B2"); - double B1 = userInputs.get_model_constant_double("B1"); - double B0 = userInputs.get_model_constant_double("B0"); - - const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; - dealii::Tensor<2, CIJ_tensor_size> CIJ_Mg = + Tensor<2, dim> sfts_const3 = userInputs.get_model_constant_rank_2_tensor("sfts_const3"); + double A4 = userInputs.get_model_constant_double("A4"); + double A3 = userInputs.get_model_constant_double("A3"); + double A2 = userInputs.get_model_constant_double("A2"); + double A1 = userInputs.get_model_constant_double("A1"); + double A0 = userInputs.get_model_constant_double("A0"); + double B2 = userInputs.get_model_constant_double("B2"); + double B1 = userInputs.get_model_constant_double("B1"); + double B0 = userInputs.get_model_constant_double("B0"); + + const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; + Tensor<2, CIJ_tensor_size> CIJ_Mg = userInputs.get_model_constant_elasticity_tensor("CIJ_Mg"); - dealii::Tensor<2, CIJ_tensor_size> CIJ_Beta = + Tensor<2, CIJ_tensor_size> CIJ_Beta = userInputs.get_model_constant_elasticity_tensor("CIJ_Beta"); // ================================================================ diff --git a/applications/precipitateEvolution_pfunction/equations.cc b/applications/precipitateEvolution_pfunction/equations.cc index 4a0c265f3..edaa6603b 100644 --- a/applications/precipitateEvolution_pfunction/equations.cc +++ b/applications/precipitateEvolution_pfunction/equations.cc @@ -77,8 +77,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -137,15 +138,6 @@ customPDE::explicitEquationRHS( scalarvalueType fbV = pfunct_fbV.val(c); scalarvalueType fbcV = pfunct_fbV.grad(c, 0); scalarvalueType fbccV = pfunct_fbV.hess(c, 0, 0); - double A4 = 1.3687; - double A3 = -2.7375; - double A2 = 5.1622; - double A1 = -4.776; - double A0 = -1.6704; - - double B2 = 5.0; - double B1 = -5.9746; - double B0 = -1.5924; scalarvalueType h1V = (10.0 * n1 * n1 * n1 - 15.0 * n1 * n1 * n1 * n1 + 6.0 * n1 * n1 * n1 * n1 * n1); @@ -162,8 +154,8 @@ customPDE::explicitEquationRHS( // Calculate the stress-free transformation strain and its derivatives at the // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, - sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; + Tensor<2, dim, VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, sfts2c, sfts2cc, + sfts3, sfts3c, sfts3cc; for (unsigned int i = 0; i < dim; i++) { @@ -190,7 +182,7 @@ customPDE::explicitEquationRHS( } // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; + VectorizedArray E2[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -204,11 +196,11 @@ customPDE::explicitEquationRHS( // compute stress // S=C*(E-E0) // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; if (n_dependent_stiffness == true) { - dealii::VectorizedArray sum_hV; + VectorizedArray sum_hV; sum_hV = h1V + h2V + h3V; for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) { @@ -227,9 +219,9 @@ customPDE::explicitEquationRHS( // Compute one of the stress terms in the order parameter chemical potential, // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); + VectorizedArray nDependentMisfitAC1 = constV(0.0); + VectorizedArray nDependentMisfitAC2 = constV(0.0); + VectorizedArray nDependentMisfitAC3 = constV(0.0); for (unsigned int i = 0; i < dim; i++) { @@ -247,10 +239,10 @@ customPDE::explicitEquationRHS( // Compute the other stress term in the order parameter chemical potential, // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray heterMechAC2 = constV(0.0); - dealii::VectorizedArray heterMechAC3 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; + VectorizedArray heterMechAC1 = constV(0.0); + VectorizedArray heterMechAC2 = constV(0.0); + VectorizedArray heterMechAC3 = constV(0.0); + VectorizedArray S2[dim][dim]; if (n_dependent_stiffness == true) { @@ -276,7 +268,7 @@ customPDE::explicitEquationRHS( if (c_dependent_misfit == true) { - dealii::VectorizedArray E3[dim][dim], S3[dim][dim]; + VectorizedArray E3[dim][dim], S3[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -391,8 +383,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -423,7 +416,7 @@ customPDE::nonExplicitEquationRHS( // Calculate the stress-free transformation strain and its derivatives at the // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts2, sfts3; + Tensor<2, dim, VectorizedArray> sfts1, sfts2, sfts3; for (unsigned int i = 0; i < dim; i++) { @@ -442,7 +435,7 @@ customPDE::nonExplicitEquationRHS( } // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; + VectorizedArray E2[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -456,11 +449,11 @@ customPDE::nonExplicitEquationRHS( // compute stress // S=C*(E-E0) // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; if (n_dependent_stiffness == true) { - dealii::VectorizedArray sum_hV; + VectorizedArray sum_hV; sum_hV = h1V + h2V + h3V; for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) { @@ -509,8 +502,9 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -541,13 +535,13 @@ customPDE::equationLHS( // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; + Tensor<2, dim, VectorizedArray> E; E = symmetrize(Dux); // Compute stress tensor (which is equal to the residual, Rux) if (n_dependent_stiffness == true) { - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; + Tensor<2, CIJ_tensor_size, VectorizedArray> CIJ_combined; CIJ_combined = CIJ_Mg * (constV(1.0) - h1V - h2V - h3V) + CIJ_Beta * (h1V + h2V + h3V); diff --git a/applications/precipitateEvolution_pfunction/integratedFields.txt b/applications/precipitateEvolution_pfunction/integratedFields.txt deleted file mode 100644 index ba0faea6a..000000000 --- a/applications/precipitateEvolution_pfunction/integratedFields.txt +++ /dev/null @@ -1,2 +0,0 @@ -0 f_tot -2961.102683 -1.2 f_tot -2965.677538 diff --git a/applications/precipitateEvolution_pfunction/main.cc b/applications/precipitateEvolution_pfunction/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/precipitateEvolution_pfunction/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/precipitateEvolution_pfunction/postprocess.cc b/applications/precipitateEvolution_pfunction/postprocess.cc index 81fafee21..077889a5c 100644 --- a/applications/precipitateEvolution_pfunction/postprocess.cc +++ b/applications/precipitateEvolution_pfunction/postprocess.cc @@ -32,15 +32,17 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- // The concentration and its derivatives - scalarvalueType c = variable_list.get_scalar_value(0); - scalargradType cx = variable_list.get_scalar_gradient(0); + scalarvalueType c = variable_list.get_scalar_value(0); // The first order parameter and its derivatives scalarvalueType n1 = variable_list.get_scalar_value(1); @@ -103,8 +105,8 @@ customPDE::postProcessedFields( // Calculate the stress-free transformation strain and its derivatives at the // quadrature point - dealii::Tensor<2, dim, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, - sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; + Tensor<2, dim, VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, sfts2c, sfts2cc, + sfts3, sfts3c, sfts3cc; for (unsigned int i = 0; i < dim; i++) { @@ -131,7 +133,7 @@ customPDE::postProcessedFields( } // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; + VectorizedArray E2[dim][dim], S[dim][dim]; for (unsigned int i = 0; i < dim; i++) { @@ -146,11 +148,11 @@ customPDE::postProcessedFields( // compute stress // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; if (n_dependent_stiffness == true) { - dealii::VectorizedArray sum_hV; + VectorizedArray sum_hV; sum_hV = h1V + h2V + h3V; for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) { diff --git a/applications/spinodalDecomposition/CMakeLists.txt b/applications/spinodalDecomposition/CMakeLists.txt index 39b8e6bd3..9522ce21e 100644 --- a/applications/spinodalDecomposition/CMakeLists.txt +++ b/applications/spinodalDecomposition/CMakeLists.txt @@ -2,80 +2,67 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.0) +project(myapp) # Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED +find_package(deal.II 9.2.0 QUIET REQUIRED HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) # Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() +if(NOT ${DEAL_II_WITH_P4EST}) + message(FATAL_ERROR "deal.II must be installed with p4est.") +endif() DEAL_II_INITIALIZE_CACHED_VARIABLES() +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) +endif() + # Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug +add_custom_target(debug COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Debug" ) - -ADD_CUSTOM_TARGET(release +add_custom_target(release COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all COMMENT "Switch CMAKE_BUILD_TYPE to Release" ) - -ADD_CUSTOM_TARGET(run COMMAND main +add_custom_target(run COMMAND main COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" ) -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") +# Add postprocess.cc and nucleation.cc if they exist +if(EXISTS "postprocess.cc") add_definitions(-DPOSTPROCESS_FILE_EXISTS) endif() -if (EXISTS "nucleation.cc") +if(EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) +# Set location of files +include_directories(${CMAKE_SOURCE_DIR}/../../include) +include_directories(${CMAKE_SOURCE_DIR}/../../src) +include_directories(${CMAKE_SOURCE_DIR}) -DEAL_II_SETUP_TARGET(main) +# Set the location of the main.cc file +set(MAIN "${CMAKE_SOURCE_DIR}/../main.cc") -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) +# Add main.cc for executable target +add_executable(main ${MAIN}) -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) +# deal.II linker +DEAL_II_SETUP_TARGET(main) +# Link libraries for the build type if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + target_link_libraries(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) endif() diff --git a/applications/spinodalDecomposition/ICs_and_BCs.cc b/applications/spinodalDecomposition/ICs_and_BCs.cc index f8a86ee38..95046044b 100644 --- a/applications/spinodalDecomposition/ICs_and_BCs.cc +++ b/applications/spinodalDecomposition/ICs_and_BCs.cc @@ -4,10 +4,10 @@ template void -customPDE::setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) { // --------------------------------------------------------------------- // ENTER THE INITIAL CONDITIONS HERE @@ -38,12 +38,13 @@ customPDE::setInitialCondition(const dealii::Point &p, template void -customPDE::setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) { // -------------------------------------------------------------------------- // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE diff --git a/applications/spinodalDecomposition/customPDE.h b/applications/spinodalDecomposition/customPDE.h index eb84b8ff2..92f03c4a9 100644 --- a/applications/spinodalDecomposition/customPDE.h +++ b/applications/spinodalDecomposition/customPDE.h @@ -1,6 +1,9 @@ -#include "../../include/matrixFreePDE.h" +#include "matrixFreePDE.h" + #include +using namespace dealii; + template class customPDE : public MatrixFreePDE { @@ -20,26 +23,26 @@ class customPDE : public MatrixFreePDE // Function to set the initial conditions (in ICs_and_BCs.h) void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; typedef std::mt19937_64 engine; typedef std::uniform_real_distribution distribution; private: -#include "../../include/typeDefs.h" +#include "typeDefs.h" const userInputParameters userInputs; @@ -47,35 +50,45 @@ class customPDE : public MatrixFreePDE // dependent equations (in equations.h) void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; // Function to set postprocessing expressions (in postprocess.h) #ifdef POSTPROCESS_FILE_EXISTS void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; #endif // Function to set the nucleation probability (in nucleation.h) #ifdef NUCLEATION_FILE_EXISTS double - getNucleationProbability(variableValueContainer variable_value, double dV) const; + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; #endif // ================================================================ diff --git a/applications/spinodalDecomposition/equations.cc b/applications/spinodalDecomposition/equations.cc index 88ff54450..467f47544 100644 --- a/applications/spinodalDecomposition/equations.cc +++ b/applications/spinodalDecomposition/equations.cc @@ -49,8 +49,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- scalarvalueType c = variable_list.get_scalar_value(0); @@ -81,8 +82,9 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -122,6 +124,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {} diff --git a/applications/spinodalDecomposition/main.cc b/applications/spinodalDecomposition/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/spinodalDecomposition/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/spinodalDecomposition/postprocess.cc b/applications/spinodalDecomposition/postprocess.cc index 83a89d082..d4486ebc6 100644 --- a/applications/spinodalDecomposition/postprocess.cc +++ b/applications/spinodalDecomposition/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- diff --git a/applications/steadyStateAllenCahn/CMakeLists.txt b/applications/steadyStateAllenCahn/CMakeLists.txt deleted file mode 100644 index 39b8e6bd3..000000000 --- a/applications/steadyStateAllenCahn/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -## -# CMake script for the PRISMS-PF applications: -## - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) - -# Find deal.II installation -FIND_PACKAGE(deal.II 9.2.0 REQUIRED - HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) - -# Check to make sure deal.II is configured with p4est -IF(NOT ${DEAL_II_WITH_P4EST}) - MESSAGE(FATAL_ERROR "\n" - "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() - -# Set up the debug, release, and run targets -ADD_CUSTOM_TARGET(debug - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Debug" - ) - -ADD_CUSTOM_TARGET(release - COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} - COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all - COMMENT "Switch CMAKE_BUILD_TYPE to Release" - ) - -ADD_CUSTOM_TARGET(run COMMAND main - COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" - ) - -PROJECT(myapp) -if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) - SET(CMAKE_BUILD_TYPE Debug) -endif() - -# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables -if (EXISTS "postprocess.cc") - add_definitions(-DPOSTPROCESS_FILE_EXISTS) -endif() -if (EXISTS "nucleation.cc") - add_definitions(-DNUCLEATION_FILE_EXISTS) -endif() - -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - -ADD_EXECUTABLE(main main.cc ) - -DEAL_II_SETUP_TARGET(main) - -set(cmd "cmake") -set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND ${cmd} ${arg} - WORKING_DIRECTORY ${dir}) - -set(cmd "make") - -EXECUTE_PROCESS(COMMAND ${cmd} - WORKING_DIRECTORY ${dir}) - -if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) -else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) -endif() diff --git a/applications/steadyStateAllenCahn/customPDE.h b/applications/steadyStateAllenCahn/customPDE.h deleted file mode 100644 index 29592f466..000000000 --- a/applications/steadyStateAllenCahn/customPDE.h +++ /dev/null @@ -1,81 +0,0 @@ -#include "../../include/matrixFreePDE.h" - -template -class customPDE : public MatrixFreePDE -{ -public: - // Constructor - customPDE(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - , userInputs(_userInputs) {}; - - // Function to set the initial conditions (in ICs_and_BCs.h) - void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC); - - // Function to set the non-uniform Dirichlet boundary conditions (in - // ICs_and_BCs.h) - void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC); - -private: -#include "../../include/typeDefs.h" - - const userInputParameters userInputs; - - // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) - void - explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the RHS of the governing equations for all other equations - // (in equations.h) - void - nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - - // Function to set the LHS of the governing equations (in equations.h) - void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const; - -// Function to set postprocessing expressions (in postprocess.h) -#ifdef POSTPROCESS_FILE_EXISTS - void - postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const; -#endif - -// Function to set the nucleation probability (in nucleation.h) -#ifdef NUCLEATION_FILE_EXISTS - double - getNucleationProbability(variableValueContainer variable_value, double dV) const; -#endif - - // ================================================================ - // Methods specific to this subclass - // ================================================================ - - // ================================================================ - // Model constants specific to this subclass - // ================================================================ - - double MnV = userInputs.get_model_constant_double("MnV"); - double KnV = userInputs.get_model_constant_double("KnV"); - - // ================================================================ -}; diff --git a/applications/steadyStateAllenCahn/formulation_allenCahn.pdf b/applications/steadyStateAllenCahn/formulation_allenCahn.pdf deleted file mode 100644 index aa82cf7b1..000000000 Binary files a/applications/steadyStateAllenCahn/formulation_allenCahn.pdf and /dev/null differ diff --git a/applications/steadyStateAllenCahn/main.cc b/applications/steadyStateAllenCahn/main.cc deleted file mode 100644 index aa697a929..000000000 --- a/applications/steadyStateAllenCahn/main.cc +++ /dev/null @@ -1,165 +0,0 @@ -// Header files -#include "customPDE.h" - -#include "ICs_and_BCs.cc" -#include "equations.cc" - -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" - -// Header file for postprocessing that may or may not exist -#ifdef POSTPROCESS_FILE_EXISTS -# include "postprocess.cc" -#else -void -variableAttributeLoader::loadPostProcessorVariableAttributes() -{} -#endif - -// Header files for nucleation that may or may not exist -#ifdef NUCLEATION_FILE_EXISTS -# include "nucleation.cc" - -# include -# include -#endif - -// main -int -main(int argc, char **argv) -{ - dealii::Utilities::MPI::MPI_InitFinalize - mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); - - // Parse the command line options (if there are any) to get the name of the - // input file - std::string parameters_filename; - try - { - ParseCommandLineOpts cli_options(argc, argv); - parameters_filename = cli_options.getParametersFilename(); - } - catch (const char *msg) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << msg << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - // Run the main part of the code - try - { - dealii::deallog.depth_console(0); - - // Before fully parsing the parameter file, we need to know how many field - // variables there are and whether they are scalars or vectors, how many - // postprocessing variables there are, how many sets of elastic constants - // there are, and how many user-defined constants there are. - - variableAttributeLoader variable_attributes; - inputFileReader input_file_reader(parameters_filename, variable_attributes); - - // Continue based on the number of dimensions and degree of the elements - // specified in the input file - switch (input_file_reader.number_of_dimensions) - { - case 2: - { - userInputParameters<2> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<2, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<2, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<2, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - break; - } - case 3: - { - userInputParameters<3> userInputs(input_file_reader, - input_file_reader.parameter_handler, - variable_attributes); - switch (userInputs.degree) - { - case (1): - { - customPDE<3, 1> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (2): - { - customPDE<3, 2> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - case (3): - { - customPDE<3, 3> problem(userInputs); - problem.buildFields(); - problem.init(); - problem.solve(); - break; - } - } - } - break; - } - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "PRISMS-PF: Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/applications/steadyStateAllenCahn/tex_files/allenCahn.tex b/applications/steadyStateAllenCahn/tex_files/allenCahn.tex deleted file mode 100644 index d2b763351..000000000 --- a/applications/steadyStateAllenCahn/tex_files/allenCahn.tex +++ /dev/null @@ -1,223 +0,0 @@ -\documentclass[10pt]{article} -\usepackage{amsmath} -\usepackage{bm} -\usepackage{bbm} -\usepackage{mathrsfs} -\usepackage{graphicx} -\usepackage{wrapfig} -\usepackage{subcaption} -\usepackage{epsfig} -\usepackage{amsfonts} -\usepackage{amssymb} -\usepackage{amsmath} -\usepackage{wrapfig} -\usepackage{graphicx} -\usepackage{psfrag} -\newcommand{\sun}{\ensuremath{\odot}} % sun symbol is \sun -\let\vaccent=\v % rename builtin command \v{} to \vaccent{} -\renewcommand{\v}[1]{\ensuremath{\mathbf{#1}}} % for vectors -\newcommand{\gv}[1]{\ensuremath{\mbox{\boldmath$ #1 $}}} -\newcommand{\grad}[1]{\gv{\nabla} #1} -\renewcommand{\baselinestretch}{1.2} -\jot 5mm -\graphicspath{{./figures/}} -%text dimensions -\textwidth 6.5 in -\oddsidemargin .2 in -\topmargin -0.2 in -\textheight 8.5 in -\headheight 0.2in -\overfullrule = 0pt -\pagestyle{plain} -\def\newpar{\par\vskip 0.5cm} -\begin{document} -% -%---------------------------------------------------------------------- -% Define symbols -%---------------------------------------------------------------------- -% -\def\iso{\mathbbm{1}} -\def\half{{\textstyle{1 \over 2}}} -\def\third{{\textstyle{1 \over 3}}} -\def\fourth{{\textstyle{{1 \over 4}}}} -\def\twothird{{\textstyle {{2 \over 3}}}} -\def\ndim{{n_{\rm dim}}} -\def\nint{n_{\rm int}} -\def\lint{l_{\rm int}} -\def\nel{n_{\rm el}} -\def\nf{n_{\rm f}} -\def\DIV {\hbox{\af div}} -\def\GRAD{\hbox{\af Grad}} -\def\sym{\mathop{\rm sym}\nolimits} -\def\tr{\mathop{\rm tr}\nolimits} -\def\dev{\mathop{\rm dev}\nolimits} -\def\Dev{\mathop{\rm Dev}\nolimits} -\def\DEV{\mathop {\rm DEV}\nolimits} -\def\bfb {{\bi b}} -\def\Bnabla{\nabla} -\def\bG{{\bi G}} -\def\jmpdelu{{\lbrack\!\lbrack \Delta u\rbrack\!\rbrack}} -\def\jmpudot{{\lbrack\!\lbrack\dot u\rbrack\!\rbrack}} -\def\jmpu{{\lbrack\!\lbrack u\rbrack\!\rbrack}} -\def\jmphi{{\lbrack\!\lbrack\varphi\rbrack\!\rbrack}} -\def\ljmp{{\lbrack\!\lbrack}} -\def\rjmp{{\rbrack\!\rbrack}} -\def\sign{{\rm sign}} -\def\nn{{n+1}} -\def\na{{n+\vartheta}} -\def\nna{{n+(1-\vartheta)}} -\def\nt{{n+{1\over 2}}} -\def\nb{{n+\beta}} -\def\nbb{{n+(1-\beta)}} -%--------------------------------------------------------- -% Bold Face Math Characters: -% All In Format: \B***** . -%--------------------------------------------------------- -\def\bOne{\mbox{\boldmath$1$}} -\def\BGamma{\mbox{\boldmath$\Gamma$}} -\def\BDelta{\mbox{\boldmath$\Delta$}} -\def\BTheta{\mbox{\boldmath$\Theta$}} -\def\BLambda{\mbox{\boldmath$\Lambda$}} -\def\BXi{\mbox{\boldmath$\Xi$}} -\def\BPi{\mbox{\boldmath$\Pi$}} -\def\BSigma{\mbox{\boldmath$\Sigma$}} -\def\BUpsilon{\mbox{\boldmath$\Upsilon$}} -\def\BPhi{\mbox{\boldmath$\Phi$}} -\def\BPsi{\mbox{\boldmath$\Psi$}} -\def\BOmega{\mbox{\boldmath$\Omega$}} -\def\Balpha{\mbox{\boldmath$\alpha$}} -\def\Bbeta{\mbox{\boldmath$\beta$}} -\def\Bgamma{\mbox{\boldmath$\gamma$}} -\def\Bdelta{\mbox{\boldmath$\delta$}} -\def\Bepsilon{\mbox{\boldmath$\epsilon$}} -\def\Bzeta{\mbox{\boldmath$\zeta$}} -\def\Beta{\mbox{\boldmath$\eta$}} -\def\Btheta{\mbox{\boldmath$\theta$}} -\def\Biota{\mbox{\boldmath$\iota$}} -\def\Bkappa{\mbox{\boldmath$\kappa$}} -\def\Blambda{\mbox{\boldmath$\lambda$}} -\def\Bmu{\mbox{\boldmath$\mu$}} -\def\Bnu{\mbox{\boldmath$\nu$}} -\def\Bxi{\mbox{\boldmath$\xi$}} -\def\Bpi{\mbox{\boldmath$\pi$}} -\def\Brho{\mbox{\boldmath$\rho$}} -\def\Bsigma{\mbox{\boldmath$\sigma$}} -\def\Btau{\mbox{\boldmath$\tau$}} -\def\Bupsilon{\mbox{\boldmath$\upsilon$}} -\def\Bphi{\mbox{\boldmath$\phi$}} -\def\Bchi{\mbox{\boldmath$\chi$}} -\def\Bpsi{\mbox{\boldmath$\psi$}} -\def\Bomega{\mbox{\boldmath$\omega$}} -\def\Bvarepsilon{\mbox{\boldmath$\varepsilon$}} -\def\Bvartheta{\mbox{\boldmath$\vartheta$}} -\def\Bvarpi{\mbox{\boldmath$\varpi$}} -\def\Bvarrho{\mbox{\boldmath$\varrho$}} -\def\Bvarsigma{\mbox{\boldmath$\varsigma$}} -\def\Bvarphi{\mbox{\boldmath$\varphi$}} -\def\bone{\mathbf{1}} -\def\bzero{\mathbf{0}} -%--------------------------------------------------------- -% Bold Face Math Italic: -% All In Format: \b* . -%--------------------------------------------------------- -\def\bA{\mbox{\boldmath$ A$}} -\def\bB{\mbox{\boldmath$ B$}} -\def\bC{\mbox{\boldmath$ C$}} -\def\bD{\mbox{\boldmath$ D$}} -\def\bE{\mbox{\boldmath$ E$}} -\def\bF{\mbox{\boldmath$ F$}} -\def\bG{\mbox{\boldmath$ G$}} -\def\bH{\mbox{\boldmath$ H$}} -\def\bI{\mbox{\boldmath$ I$}} -\def\bJ{\mbox{\boldmath$ J$}} -\def\bK{\mbox{\boldmath$ K$}} -\def\bL{\mbox{\boldmath$ L$}} -\def\bM{\mbox{\boldmath$ M$}} -\def\bN{\mbox{\boldmath$ N$}} -\def\bO{\mbox{\boldmath$ O$}} -\def\bP{\mbox{\boldmath$ P$}} -\def\bQ{\mbox{\boldmath$ Q$}} -\def\bR{\mbox{\boldmath$ R$}} -\def\bS{\mbox{\boldmath$ S$}} -\def\bT{\mbox{\boldmath$ T$}} -\def\bU{\mbox{\boldmath$ U$}} -\def\bV{\mbox{\boldmath$ V$}} -\def\bW{\mbox{\boldmath$ W$}} -\def\bX{\mbox{\boldmath$ X$}} -\def\bY{\mbox{\boldmath$ Y$}} -\def\bZ{\mbox{\boldmath$ Z$}} -\def\ba{\mbox{\boldmath$ a$}} -\def\bb{\mbox{\boldmath$ b$}} -\def\bc{\mbox{\boldmath$ c$}} -\def\bd{\mbox{\boldmath$ d$}} -\def\be{\mbox{\boldmath$ e$}} -\def\bff{\mbox{\boldmath$ f$}} -\def\bg{\mbox{\boldmath$ g$}} -\def\bh{\mbox{\boldmath$ h$}} -\def\bi{\mbox{\boldmath$ i$}} -\def\bj{\mbox{\boldmath$ j$}} -\def\bk{\mbox{\boldmath$ k$}} -\def\bl{\mbox{\boldmath$ l$}} -\def\bm{\mbox{\boldmath$ m$}} -\def\bn{\mbox{\boldmath$ n$}} -\def\bo{\mbox{\boldmath$ o$}} -\def\bp{\mbox{\boldmath$ p$}} -\def\bq{\mbox{\boldmath$ q$}} -\def\br{\mbox{\boldmath$ r$}} -\def\bs{\mbox{\boldmath$ s$}} -\def\bt{\mbox{\boldmath$ t$}} -\def\bu{\mbox{\boldmath$ u$}} -\def\bv{\mbox{\boldmath$ v$}} -\def\bw{\mbox{\boldmath$ w$}} -\def\bx{\mbox{\boldmath$ x$}} -\def\by{\mbox{\boldmath$ y$}} -\def\bz{\mbox{\boldmath$ z$}} -%********************************* -%Start main paper -%********************************* -\centerline{\Large{\bf PRISMS PhaseField}} -\smallskip -\centerline{\Large{\bf Allen-Cahn Dynamics}} -\bigskip -Consider a free energy expression of the form: -\begin{equation} - \Pi(\eta, \grad \eta) = \int_{\Omega} f( \eta ) + \frac{\kappa}{2} \grad \eta \cdot \grad \eta ~dV -\end{equation} -where $\eta$ is the structural order parameter, and $\kappa$ is the gradient length scale parameter. - -\section{Variational treatment} -Considering variations on the primal field $\eta$ of the from $\eta+\epsilon w$, we have -\begin{align} -\delta \Pi &= \left. \frac{d}{d\epsilon} \int_{\Omega} f(\eta+\epsilon w) + \frac{\kappa}{2} \grad (\eta+\epsilon w) \cdot ~\grad (\eta+\epsilon w) ~dV \right\vert_{\epsilon=0} \\ -&= \int_{\Omega} w f_{,\eta} + \kappa \grad w \grad \eta ~dV \\ -&= \int_{\Omega} w \left( f_{,\eta} - \kappa \Delta \eta \right) ~dV + \int_{\partial \Omega} w \kappa \grad \eta \cdot n ~dS -\end{align} -Assuming $\kappa \grad \eta \cdot n = 0$, and using standard variational arguments on the equation $\delta \Pi =0$ we have the expression for chemical potential as -\begin{equation} - \mu = f_{,\eta} - \kappa \Delta \eta -\end{equation} - -\section{Kinetics} -Now the Parabolic PDE for Allen-Cahn dynamics is given by: -\begin{align} - \frac{\partial \eta}{\partial t} &= -M~(f_{,\eta} - \kappa \Delta \eta) -\end{align} -where $M$ is the constant mobility. -\section{Time discretization} -Considering forward Euler explicit time stepping, we have the time discretized kinetics equation: -\begin{align} - \eta^{n+1} &= \eta^{n} - \Delta t M~(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) -\end{align} - -\section{Weak formulation} -In the weak formulation, considering an arbitrary variation $w$, the above equation can be expressed as a residual equation: -\begin{align} -\int_{\Omega} w \eta^{n+1} ~dV&= \int_{\Omega} w \eta^{n} - w \Delta t M~(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) ~dV \\ -&= \int_{\Omega} w ( \underbrace{ \eta^{n} - \Delta t M~f_{,\eta}^{n} }_{r_{\eta}} ) + \grad w \underbrace{ (-\Delta t M \kappa)~ \cdot (\grad \eta^{n})}_{r_{\eta x}} ~dV \quad [\kappa \grad \eta \cdot n = 0 \quad \text{on} \quad \partial \Omega] -\end{align} -\vskip 0.25in -The above values of $r_{\eta}$ and $r_{\eta x}$ are used to define the residuals in the following parameters file: \\ -\textit{applications/allenCahn/parameters.h} - - -\end{document} \ No newline at end of file diff --git a/include/AdaptiveRefinement.h b/include/AdaptiveRefinement.h new file mode 100644 index 000000000..609a7716e --- /dev/null +++ b/include/AdaptiveRefinement.h @@ -0,0 +1,81 @@ +#ifndef INCLUDE_ADAPTIVEREFINEMENT_H_ +#define INCLUDE_ADAPTIVEREFINEMENT_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fields.h" +#include "userInputParameters.h" + +using namespace dealii; + +/** + * A class that handles the determination and application of AMR criterion. + */ +template +class AdaptiveRefinement +{ +public: + using vectorType = dealii::LinearAlgebra::distributed::Vector; + + /** + * Default constructor. + */ + AdaptiveRefinement( + const userInputParameters &_userInputs, + parallel::distributed::Triangulation &_triangulation, + std::vector> &_fields, + std::vector &_solutionSet, + std::vector *> &_soltransSet, + std::vector *> &_FESet, + std::vector *> &_dofHandlersSet_nonconst, + std::vector *> &_constraintsDirichletSet, + std::vector *> &_constraintsOtherSet); + + /** + * Perform the adaptive refinement based on the specified AMR criterion. Also apply + * constraints when in the 0th timestep. + */ + void + do_adaptive_refinement(unsigned int _currentIncrement); + + /** + * Refine the triangulation and transfer the solution. + */ + void + refine_grid(); + +protected: + /** + * Mark cells to be coarsened or refined based on the specified AMR criterion. + */ + void + adaptive_refinement_criterion(); + +private: + userInputParameters userInputs; + + parallel::distributed::Triangulation &triangulation; + + std::vector> &fields; + + std::vector &solutionSet; + + std::vector *> &soltransSet; + + std::vector *> &FESet; + + std::vector *> &dofHandlersSet_nonconst; + + std::vector *> &constraintsDirichletSet; + + std::vector *> &constraintsOtherSet; +}; + +#endif \ No newline at end of file diff --git a/include/EquationDependencyParser.h b/include/EquationDependencyParser.h index 45f4e9aad..4a8dd1b03 100644 --- a/include/EquationDependencyParser.h +++ b/include/EquationDependencyParser.h @@ -1,8 +1,11 @@ #ifndef INCLUDE_EQUATIONDEPENDECYPARSER_H_ #define INCLUDE_EQUATIONDEPENDECYPARSER_H_ +#include + #include "varTypeEnums.h" +#include #include #include @@ -15,87 +18,88 @@ class EquationDependencyParser { public: void - parse(std::vector var_name, - std::vector var_eq_type, - std::vector sorted_dependencies_value_RHS, - std::vector sorted_dependencies_gradient_RHS, - std::vector sorted_dependencies_value_LHS, - std::vector sorted_dependencies_gradient_LHS, - std::vector &var_nonlinear); + parse(std::vector &var_name, + std::vector var_eq_type, + std::vector sorted_dependencies_value_RHS, + std::vector sorted_dependencies_gradient_RHS, + std::vector sorted_dependencies_value_LHS, + std::vector sorted_dependencies_gradient_LHS, + std::vector &var_nonlinear); void - pp_parse(std::vector var_name, - std::vector pp_var_name, - std::vector sorted_dependencies_value, - std::vector sorted_dependencies_gradient); + pp_parse(std::vector &var_name, + std::vector &pp_var_name, + std::vector sorted_dependencies_value, + std::vector sorted_dependencies_gradient); + + // Evaluation flags for each type of solution variable (e.g., explicit, nonexplicit, + // nonexplicit_change, etc.) + std::vector eval_flags_explicit_RHS; + std::vector eval_flags_nonexplicit_RHS; + std::vector eval_flags_nonexplicit_LHS; + std::vector eval_flags_change_nonexplicit_LHS; - // All of the vectors of flags for what is needed for the solution variables - std::vector need_value_explicit_RHS, need_gradient_explicit_RHS, - need_hessian_explicit_RHS, need_value_nonexplicit_RHS, need_gradient_nonexplicit_RHS, - need_hessian_nonexplicit_RHS, need_value_nonexplicit_LHS, - need_gradient_nonexplicit_LHS, need_hessian_nonexplicit_LHS, - need_value_change_nonexplicit_LHS, need_gradient_change_nonexplicit_LHS, - need_hessian_change_nonexplicit_LHS, need_value_residual_explicit_RHS, - need_gradient_residual_explicit_RHS, need_value_residual_nonexplicit_RHS, - need_gradient_residual_nonexplicit_RHS, need_value_residual_nonexplicit_LHS, - need_gradient_residual_nonexplicit_LHS; + std::vector eval_flags_residual_explicit_RHS; + std::vector + eval_flags_residual_nonexplicit_RHS; + std::vector + eval_flags_residual_nonexplicit_LHS; // All of the vectors of flags for what is needed for the postprocessing // variables - std::vector pp_need_value, pp_need_gradient, pp_need_hessian, - pp_need_value_residual, pp_need_gradient_residual; + std::vector eval_flags_postprocess; + std::vector eval_flags_residual_postprocess; protected: + /* + * Method to strip excess whitespace for the dependency lists + */ + void + strip_dependency_whitespace(std::string &dependency_list); + /** * Method to parse the RHS dependency strings and populate the vectors for * whether values, gradients, or hessians are needed. */ void - parseDependencyListRHS(std::vector var_name, - std::vector var_eq_type, - unsigned int var_index, - std::string value_dependencies, - std::string gradient_dependencies, - std::vector &need_value, - std::vector &need_gradient, - std::vector &need_hessian, - bool &need_value_residual, - bool &need_gradient_residual, - bool &is_nonlinear); + parseDependencyListRHS( + std::vector &variable_name_list, + std::vector variable_eq_type, + unsigned int variable_index, + std::string &value_dependencies, + std::string &gradient_dependencies, + std::vector &evaluation_flags, + std::vector &residual_flags, + bool &is_nonlinear); /** * Method to parse the LHS dependency strings and populate the vectors for * whether values, gradients, or hessians are needed. */ void - parseDependencyListLHS(std::vector var_name, - std::vector var_eq_type, - unsigned int var_index, - std::string value_dependencies, - std::string gradient_dependencies, - std::vector &need_value, - std::vector &need_gradient, - std::vector &need_hessian, - std::vector &need_value_change, - std::vector &need_gradient_change, - std::vector &need_hessian_change, - bool &need_value_residual, - bool &need_gradient_residual, - bool &is_nonlinear); + parseDependencyListLHS( + std::vector &variable_name_list, + std::vector variable_eq_type, + unsigned int variable_index, + std::string &value_dependencies, + std::string &gradient_dependencies, + std::vector &evaluation_flags, + std::vector &change_flags, + std::vector &residual_flags, + bool &is_nonlinear); /** * Method to parse the postprocessing dependency strings and populate the * vectors for whether values, gradients, or hessians are needed. */ void - parseDependencyListPP(std::vector var_name, - std::string value_dependencies, - std::string gradient_dependencies, - std::vector &need_value, - std::vector &need_gradient, - std::vector &need_hessian, - bool &need_value_residual, - bool &need_gradient_residual); + parseDependencyListPP( + std::vector &variable_name_list, + unsigned int variable_index, + std::string &value_dependencies, + std::string &gradient_dependencies, + std::vector &evaluation_flags, + std::vector &residual_flags); }; #endif diff --git a/include/FloodFiller.h b/include/FloodFiller.h index 5c9bf6838..7a29bf71c 100644 --- a/include/FloodFiller.h +++ b/include/FloodFiller.h @@ -125,6 +125,7 @@ class FloodFiller vectorType *solution_field, double threshold_lower, double threshold_upper, + int min_id, unsigned int order_parameter_index, std::vector> &grain_sets); @@ -139,6 +140,7 @@ class FloodFiller vectorType *solution_field, double threshold_lower, double threshold_upper, + int min_id, unsigned int &grain_index, std::vector> &grain_sets, bool &grain_assigned); diff --git a/include/IntegrationTools/PPieceWise.hh b/include/IntegrationTools/PPieceWise.hh index 3ba618892..23c7288be 100644 --- a/include/IntegrationTools/PPieceWise.hh +++ b/include/IntegrationTools/PPieceWise.hh @@ -1,4 +1,4 @@ -#include "piecewise/SimplePiece.hh" +#include "piecewise/PPieceWiseFuncBase.hh" #include "piecewise/PPieceWiseSimpleBase.hh" #include "piecewise/Piece.hh" -#include "piecewise/PPieceWiseFuncBase.hh" +#include "piecewise/SimplePiece.hh" diff --git a/include/IntegrationTools/datastruc/Bin.hh b/include/IntegrationTools/datastruc/Bin.hh index a595474a5..06a5e4d7b 100644 --- a/include/IntegrationTools/datastruc/Bin.hh +++ b/include/IntegrationTools/datastruc/Bin.hh @@ -2,226 +2,239 @@ #ifndef Bin_HH #define Bin_HH +#include "PNDArray.hh" + #include #include -#include "PNDArray.hh" namespace PRISMS { - - /// A class for binning things - /// template class T: the type of thing being binned - /// - should have T::operator==() defined to use 'Bin::add_once' - /// template class Coordinate: - /// - expected to be 'vector like' - /// - should have Coordinate::operator[]() defined + + /// A class for binning things + /// template class T: the type of thing being binned + /// - should have T::operator==() defined to use 'Bin::add_once' + /// template class Coordinate: + /// - expected to be 'vector like' + /// - should have Coordinate::operator[]() defined + /// + template + class Bin + { + PNDArray> _item; + + std::vector _min; // min coord + std::vector _incr; // histogram spacing along each direction (uniform along + // each dimension) + std::vector _N; // number of bins along each direction + std::vector _max; // max coord + std::vector _indices; + + public: + Bin() {}; + + /// Construct a Bin + /// 'min': minimum value of each coordinate component + /// 'incr': bin spacing along each direction (this is uniform along each dimension) + /// 'N': number of bins along each direction /// - template< class T, class Coordinate> - class Bin + /// For example, to bin the range (0->10, 0->20, 10->100), with size 1 bin spacing: + /// Bin( {0,0,10}, {1,1,1}, {10, 20, 90}) + /// + Bin(const std::vector &min, std::vector &incr, std::vector &N) { - PNDArray > _item; - - std::vector _min; // min coord - std::vector _incr; // histogram spacing along each direction (uniform along each dimension) - std::vector _N; // number of bins along each direction - std::vector _max; // max coord - std::vector _indices; - - public: - - Bin(){}; - - /// Construct a Bin - /// 'min': minimum value of each coordinate component - /// 'incr': bin spacing along each direction (this is uniform along each dimension) - /// 'N': number of bins along each direction - /// - /// For example, to bin the range (0->10, 0->20, 10->100), with size 1 bin spacing: - /// Bin( {0,0,10}, {1,1,1}, {10, 20, 90}) - /// - Bin(const std::vector &min, std::vector &incr, std::vector &N) - { - _min = min; - _incr = incr; - _N = N; - _max = std::vector(_min.size()); - for( unsigned int i=0; i<_min.size(); i++) - _max[i] = _min[i] + _incr[i]*_N[i]; - _indices = _N; - _item.resize(_N); - } - - void clear() - { - (*this) = Bin(); - } - - std::vector& min() - { - return _min; - } - - std::vector& max() - { - return _max; - } - - /// Add a new item to the bin containing a given coordinate - void add( const T &newitem, const Coordinate &coord) - { - indices( coord, _indices); - _item(_indices).push_back(newitem); - } - - /// Add a new item to the bin containing a given coordinate, - /// if an equivalent item is not already present - /// return 'true' if added succesfully, 'false' if not - void add_once( const T &newitem, const Coordinate &coord) + _min = min; + _incr = incr; + _N = N; + _max = std::vector(_min.size()); + for (unsigned int i = 0; i < _min.size(); i++) + _max[i] = _min[i] + _incr[i] * _N[i]; + _indices = _N; + _item.resize(_N); + } + + void + clear() + { + (*this) = Bin(); + } + + std::vector & + min() + { + return _min; + } + + std::vector & + max() + { + return _max; + } + + /// Add a new item to the bin containing a given coordinate + void + add(const T &newitem, const Coordinate &coord) + { + indices(coord, _indices); + _item(_indices).push_back(newitem); + } + + /// Add a new item to the bin containing a given coordinate, + /// if an equivalent item is not already present + /// return 'true' if added succesfully, 'false' if not + void + add_once(const T &newitem, const Coordinate &coord) + { + indices(coord, _indices); + std::vector &singlebin = _item(_indices); + for (int i = 0; i < singlebin.size(); i++) { - indices( coord, _indices); - std::vector &singlebin = _item(_indices); - for( int i=0; i - void add_range( const T &newitem, const PCoord &min, const PCoord &max) + + singlebin.push_back(newitem); + } + + /// Add a new item to all bins that fall in cuboid defined by 'min' and 'max' + /// Coordinates + template + void + add_range(const T &newitem, const PCoord &min, const PCoord &max) + { + // std::cout << "begin add_range()" << std::endl; + + // std::cout << "min: " << min << " max: " << max << std::endl; + + int i; + std::vector index_min(_item.order()); + std::vector index_max(_item.order()); + indices(min, index_min); + indices(max, index_max); + + // std::cout << "MIN: "; + // for( j=0; j index_min(_item.order()); - std::vector index_max(_item.order()); - indices( min, index_min); - indices( max, index_max); - - //std::cout << "MIN: "; - //for( j=0; j=0; i--) + i++; + if (i == _item.order()) { - _indices[i]=index_min[i]; + return; } - /////////////// } - - //std::cout << "finish add_range()" << std::endl; - - } - - std::vector& contents( const Coordinate &coord) - { - indices( coord, _indices); - return _item(_indices); + + _indices[i]++; + + for (i = i - 1; i >= 0; i--) + { + _indices[i] = index_min[i]; + } + /////////////// } - - // maximum size of any bin - int max_size() + + // std::cout << "finish add_range()" << std::endl; + } + + std::vector & + contents(const Coordinate &coord) + { + indices(coord, _indices); + return _item(_indices); + } + + // maximum size of any bin + int + max_size() + { + unsigned int max = 0; + for (int i = 0; i < _item.volume(); i++) + if (_item(i).size() > max) + max = _item(i).size(); + return max; + } + + private: + /// Set 'term' to be the indices into '_item' PNDArray of the bin that contains + /// 'coord' + /// Return 'false' if unsuccesful, 'true' if succesful + template + void + indices(const PCoord &coord, std::vector &term) + { + for (int i = 0; i < _item.order(); i++) { - unsigned int max = 0; - for( int i=0; i<_item.volume(); i++) - if( _item(i).size() > max) - max = _item(i).size(); - return max; + // std::cout << "i: " << i << std::endl; + // std::cout << "coord: " << coord[i] << std::endl; + // std::cout << "_min: " << _min[i] << std::endl; + // std::cout << "_max: " << _max[i] << std::endl; + // std::cout << "_incr: " << _incr[i] << std::endl; + + if ((coord[i] < _min[i]) || (coord[i] > _max[i])) + throw std::domain_error("Invalid coord, out of bin range"); + term[i] = std::floor((coord[i] - _min[i]) / _incr[i]); } - - private: - - /// Set 'term' to be the indices into '_item' PNDArray of the bin that contains 'coord' - /// Return 'false' if unsuccesful, 'true' if succesful - template< class PCoord> - void indices(const PCoord &coord, std::vector &term) + } + + /// Set 'term' to be the indices into '_item' PNDArray of the bin that contains + /// 'coord' + /// Return 'false' if unsuccesful, 'true' if succesful + template + void + max_indices(const PCoord &coord, std::vector &term) + { + for (int i = 0; i < _item.order(); i++) { - for( int i=0; i<_item.order(); i++) + // std::cout << "i: " << i << std::endl; + // std::cout << "coord: " << coord[i] << std::endl; + // std::cout << "_min: " << _min[i] << std::endl; + // std::cout << "_max: " << _max[i] << std::endl; + // std::cout << "_incr: " << _incr[i] << std::endl; + + if ((coord[i] < _min[i]) || (coord[i] > _max[i])) + throw std::domain_error("Invalid coord, out of bin range"); + + // std::cout << "coord: " << coord[i] << " _min: " << _min[i] << " _incr: " << + // _incr[i] << std::endl; std::cout << std::floor( (coord[i] - + // _min[i])/_incr[i]) << " " << (coord[i] - _min[i])/_incr[i] << std::endl; + + if (std::floor((coord[i] - _min[i]) / _incr[i]) == + (coord[i] - _min[i]) / _incr[i]) { - //std::cout << "i: " << i << std::endl; - //std::cout << "coord: " << coord[i] << std::endl; - //std::cout << "_min: " << _min[i] << std::endl; - //std::cout << "_max: " << _max[i] << std::endl; - //std::cout << "_incr: " << _incr[i] << std::endl; - - if( (coord[i] < _min[i]) || (coord[i] > _max[i]) ) - throw std::domain_error("Invalid coord, out of bin range"); - term[i] = std::floor( (coord[i] - _min[i])/_incr[i]); + // std::cout << "reduce max" << std::endl; + term[i] = std::floor((coord[i] - _min[i]) / _incr[i]); + term[i]--; } - } - - /// Set 'term' to be the indices into '_item' PNDArray of the bin that contains 'coord' - /// Return 'false' if unsuccesful, 'true' if succesful - template< class PCoord> - void max_indices(const PCoord &coord, std::vector &term) - { - for( int i=0; i<_item.order(); i++) + else { - //std::cout << "i: " << i << std::endl; - //std::cout << "coord: " << coord[i] << std::endl; - //std::cout << "_min: " << _min[i] << std::endl; - //std::cout << "_max: " << _max[i] << std::endl; - //std::cout << "_incr: " << _incr[i] << std::endl; - - if( (coord[i] < _min[i]) || (coord[i] > _max[i]) ) - throw std::domain_error("Invalid coord, out of bin range"); - - //std::cout << "coord: " << coord[i] << " _min: " << _min[i] << " _incr: " << _incr[i] << std::endl; - //std::cout << std::floor( (coord[i] - _min[i])/_incr[i]) << " " << (coord[i] - _min[i])/_incr[i] << std::endl; - - if( std::floor( (coord[i] - _min[i])/_incr[i]) == (coord[i] - _min[i])/_incr[i]) - { - //std::cout << "reduce max" << std::endl; - term[i] = std::floor( (coord[i] - _min[i])/_incr[i]); - term[i]--; - } - else - { - term[i] = std::floor( (coord[i] - _min[i])/_incr[i]); - } + term[i] = std::floor((coord[i] - _min[i]) / _incr[i]); } } - }; - -} + } + }; +} // namespace PRISMS #endif diff --git a/include/IntegrationTools/datastruc/PNDArray.hh b/include/IntegrationTools/datastruc/PNDArray.hh index 9efc6190c..1d16163cd 100644 --- a/include/IntegrationTools/datastruc/PNDArray.hh +++ b/include/IntegrationTools/datastruc/PNDArray.hh @@ -2,159 +2,175 @@ #ifndef PNDArray_HH #define PNDArray_HH -#include -#include #include +#include +#include namespace PRISMS { - - /// A Tensor class, - /// takes int valued IndexContainer and returns OutType value - /// - template< class OutType> - class PNDArray + + /// A Tensor class, + /// takes int valued IndexContainer and returns OutType value + /// + template + class PNDArray + { + std::vector _dim; // dimension along each compenent + std::vector _unroll; // used to translate from tensor indices to linear index + std::vector _val; // unrolled list of coefficients (first index is outer + // loop) + int _order; // _dim.size() + int _volume; // _coeff_tensor.size() = product_i(_dim[i]) + + public: + PNDArray() + : _order(0) + , _volume(0) + {} + + PNDArray(const std::vector &dim) { - std::vector< int > _dim; // dimension along each compenent - std::vector< int > _unroll; // used to translate from tensor indices to linear index - std::vector< OutType > _val; // unrolled list of coefficients (first index is outer loop) - int _order; // _dim.size() - int _volume; // _coeff_tensor.size() = product_i(_dim[i]) - - public: - - PNDArray() : _order(0), _volume(0) {} - PNDArray(const std::vector &dim) - { - resize(dim); - } - - PNDArray(const std::vector &dim, const std::vector &value) - { - resize(dim); - if( _volume != value.size()) - { - std::cerr << "Error in PNDArray(const std::vector &dim, const std::vector &value)." << std::endl; - std::cerr << " value.size() does not match volume based on dim." << std::endl; - exit(1); - } - _val = value; - } - - int order() const - { - return _order; - } - - int volume() const - { - return _volume; - } - - void resize(const std::vector &dim) - { - _dim = dim; - _order = _dim.size(); - _volume = calc_volume(_dim); - _val.resize(_volume); - generate_unroll(); - } - - void reshape(const std::vector &dim) - { - if( calc_volume(dim) == _volume) - { - _dim = dim; - _order = _dim.size(); - generate_unroll(); - } - else - { - std::cerr << "Error in PNDArray::reshape. Volume is not equivalent." << std::endl; - exit(1); - } - } - - void clear() - { - _val.clear(); - _dim.clear(); - _unroll.clear(); - _order = 0; - _volume = 0; - - } - - const std::vector& dim() const - { - return _dim; - } - - int dim(int i) const + resize(dim); + } + + PNDArray(const std::vector &dim, const std::vector &value) + { + resize(dim); + if (_volume != value.size()) { - return _dim[i]; + std::cerr << "Error in PNDArray(const std::vector &dim, const " + "std::vector &value)." + << std::endl; + std::cerr << " value.size() does not match volume based on dim." << std::endl; + exit(1); } - - OutType& operator()( int i) + _val = value; + } + + int + order() const + { + return _order; + } + + int + volume() const + { + return _volume; + } + + void + resize(const std::vector &dim) + { + _dim = dim; + _order = _dim.size(); + _volume = calc_volume(_dim); + _val.resize(_volume); + generate_unroll(); + } + + void + reshape(const std::vector &dim) + { + if (calc_volume(dim) == _volume) { - return _val[i]; + _dim = dim; + _order = _dim.size(); + generate_unroll(); } - - template - OutType& operator()( const IndexContainer &term) + else { - return _val[linear_index(term)]; + std::cerr << "Error in PNDArray::reshape. Volume is not equivalent." + << std::endl; + exit(1); } - - template - int linear_index( const IndexContainer &term) const + } + + void + clear() + { + _val.clear(); + _dim.clear(); + _unroll.clear(); + _order = 0; + _volume = 0; + } + + const std::vector & + dim() const + { + return _dim; + } + + int + dim(int i) const + { + return _dim[i]; + } + + OutType & + operator()(int i) + { + return _val[i]; + } + + template + OutType & + operator()(const IndexContainer &term) + { + return _val[linear_index(term)]; + } + + template + int + linear_index(const IndexContainer &term) const + { + int lindex = 0; + for (unsigned int i = 0; i < _unroll.size(); i++) + lindex += term[i] * _unroll[i]; + return lindex; + } + + template + void + tensor_indices(int lindex, IndexContainer &term) const + { // assumes term.size() == order() (the tensor order) + // not sure if this is how we want to do it, but it avoids assuming push_back() or + // resize() + + for (int i = 0; i < _unroll.size(); i++) { - int lindex = 0; - for( unsigned int i=0; i<_unroll.size(); i++) - lindex += term[i]*_unroll[i]; - return lindex; - } - - template - void tensor_indices( int lindex, IndexContainer &term) const - { // assumes term.size() == order() (the tensor order) - // not sure if this is how we want to do it, but it avoids assuming push_back() or resize() - - for( int i=0; i<_unroll.size(); i++) - { - term[i] = lindex/_unroll[i]; - lindex -= term[i]*_unroll[i]; - } + term[i] = lindex / _unroll[i]; + lindex -= term[i] * _unroll[i]; } - - - private: - - int calc_volume( const std::vector &dim) + } + + private: + int + calc_volume(const std::vector &dim) + { + if (dim.size() == 0) { - if( dim.size() == 0) - { - return 0; - } - - int vol = 1; - for( unsigned int i=0; i=0; i--) - _unroll[i] = _unroll[i+1]*_dim[i+1]; + vol *= dim[i]; } - - }; -} + return vol; + } + void + generate_unroll() + { + _unroll.resize(_dim.size()); + _unroll[_dim.size() - 1] = 1; + for (int i = _dim.size() - 2; i >= 0; i--) + _unroll[i] = _unroll[i + 1] * _dim[i + 1]; + } + }; +} // namespace PRISMS #endif diff --git a/include/IntegrationTools/extern/PExtern.hh b/include/IntegrationTools/extern/PExtern.hh index 8fe5e57d9..e193a6002 100644 --- a/include/IntegrationTools/extern/PExtern.hh +++ b/include/IntegrationTools/extern/PExtern.hh @@ -2,284 +2,510 @@ #ifndef PExtern_HH #define PExtern_HH -#include -#include -#include -#include - -#include "../PFunction.hh" #include "../PField.hh" +#include "../PFunction.hh" +#include +#include +#include +#include -// In future, might have more complicated OutType, +// In future, might have more complicated OutType, // so make all have 'void' return and pass everything by reference - extern "C" { - // Functions for using a PSimpleBase externally (say Python or Fortran) - // written for VarContainer=double*, OutType=double, hence 'dsd' in function names - - void PSimpleFunction_dsd_new(char* name, PRISMS::PSimpleBase* &f); - - void PSimpleFunction_dsd_delete(PRISMS::PSimpleBase* &f); - - void PSimpleFunction_dsd_name(PRISMS::PSimpleBase* f, char* name); - - void PSimpleFunction_dsd_calc( PRISMS::PSimpleBase* f, double* var, double &val); - - void PSimpleFunction_dsd_get( PRISMS::PSimpleBase* f, double &val); - - - - // Functions for using a PSimpleBase externally (say Python or Fortran) - // written for VarContainer=double, OutType=double, hence 'dd' in function names - - void PSimpleFunction_dd_new(char* name, PRISMS::PSimpleBase* &f); - - void PSimpleFunction_dd_delete(PRISMS::PSimpleBase* &f); - - void PSimpleFunction_dd_name(PRISMS::PSimpleBase* f, char* name); - - void PSimpleFunction_dd_calc( PRISMS::PSimpleBase* f, double var, double &val); - - void PSimpleFunction_dd_get( PRISMS::PSimpleBase* f, double &val); - - - - - - // Functions for using a PFuncBase externally (say Python or Fortran) - // written for VarContainer=double*, OutType=double, hence 'dsd' in function names - - void PFunction_dsd_new(char* name, PRISMS::PFuncBase* &f); - - void PFunction_dsd_delete(PRISMS::PFuncBase* &f); - - void PFunction_dsd_name(PRISMS::PFuncBase* f, char* name); - - void PFunction_dsd_size(PRISMS::PFuncBase* f, int &size); - - void PFunction_dsd_var_name(PRISMS::PFuncBase* f, int i, char* var_name); - - void PFunction_dsd_var_description(PRISMS::PFuncBase* f, int i, char* var_description); - - //void PFunction_dsd_simplefunc(PRISMS::PFuncBase* f, PSimpleBase* &simplefunc); - //void PFunction_dsd_grad_simplefunc(PRISMS::PFuncBase* f, int di, PSimpleBase* &simplefunc); - //void PFunction_dsd_hess_simplefunc(PRISMS::PFuncBase* f, int di, int dj, PSimpleBase* &simplefunc); - - void PFunction_dsd_calc(PRISMS::PFuncBase* f, double* var, double &val); - - void PFunction_dsd_calc_grad(PRISMS::PFuncBase* f, double* var, int di, double &val); - - void PFunction_dsd_calc_hess(PRISMS::PFuncBase* f, double* var, int di, int dj, double &val); - - void PFunction_dsd_eval(PRISMS::PFuncBase* f, double* var); - - void PFunction_dsd_eval_grad(PRISMS::PFuncBase* f, double* var, int di); - - void PFunction_dsd_eval_hess(PRISMS::PFuncBase* f, double* var, int di, int dj); - - void PFunction_dsd_get(PRISMS::PFuncBase* f, double &val); - - void PFunction_dsd_get_grad(PRISMS::PFuncBase* f, int di, double &val); - - void PFunction_dsd_get_hess(PRISMS::PFuncBase* f, int di, int dj, double &val); - - - - - - // Functions for using a PBasisSetBase externally (say Python or Fortran) - // written for InType=double, OutType=double, hence 'dd' in function names - - void PBasisSet_dd_new(char* name, PRISMS::PBasisSetBase* &b, int N); - - void PBasisSet_dd_delete(PRISMS::PBasisSetBase* &b); - - void PBasisSet_dd_name(PRISMS::PBasisSetBase* b, char* name); - - void PBasisSet_dd_description(PRISMS::PBasisSetBase* b, char* description); - - void PBasisSet_dd_size(PRISMS::PBasisSetBase* b, int &size); - - void PBasisSet_dd_resize(PRISMS::PBasisSetBase* b, int N); - - void PBasisSet_dd_max_size(PRISMS::PBasisSetBase* b, int &max_size); - - //void PBasisSet_dd_basis_function(PRISMS::PFuncBase* b, int term, PFuncBase* &f); - - void PBasisSet_dd_calc(PRISMS::PBasisSetBase* b, int term, double var, double &val); - - void PBasisSet_dd_calc_grad(PRISMS::PBasisSetBase* b, int term, double var, double &val); - - void PBasisSet_dd_calc_hess(PRISMS::PBasisSetBase* b, int term, double var, double &val); - - void PBasisSet_dd_eval(PRISMS::PBasisSetBase* b, double var); - - void PBasisSet_dd_eval_grad(PRISMS::PBasisSetBase* b, double var); - - void PBasisSet_dd_eval_hess(PRISMS::PBasisSetBase* b, double var); - - void PBasisSet_dd_get(PRISMS::PBasisSetBase* b, int term, double &val); - - void PBasisSet_dd_get_grad(PRISMS::PBasisSetBase* b, int term, double &val); - - void PBasisSet_dd_get_hess(PRISMS::PBasisSetBase* b, int term, double &val); - - //void PBasisSet_dd_getall(PRISMS::PBasisSetBase* b, const double* &val); - //void PBasisSet_dd_getall_grad(PRISMS::PBasisSetBase* b, const double* &val); - //void PBasisSet_dd_getall_hess(PRISMS::PBasisSetBase* b, const double* &val); - - - - - - // Functions for using a PSeriesFunction externally (say Python or Fortran) - // written for InType=double, OutType=double, VarContainer=double*, IndexContainer=int*, hence 'dsis' - - // Functions for using a PSeriesFunction externally (say Python or Fortran) - // written for InType=double, OutType=double, VarContainer=double*, IndexContainer=int*, hence 'dsis' - - void PSeriesFunction_dsis_new(PRISMS::PSeriesFunction* &f); - - void PSeriesFunction_dsis_setnew(PRISMS::PSeriesFunction* &f, PRISMS::PBasisSetBase** basis_set, int order); - - void PSeriesFunction_dsis_delete(PRISMS::PSeriesFunction* &f); - - void PSeriesFunction_dsis_clear(PRISMS::PSeriesFunction* f); - - void PSeriesFunction_dsis_set(PRISMS::PSeriesFunction* f, PRISMS::PBasisSetBase** basis_set, int order); - - void PSeriesFunction_dsis_order(PRISMS::PSeriesFunction* f, int &order); - - void PSeriesFunction_dsis_volume(PRISMS::PSeriesFunction* f, int &volume); - - void PSeriesFunction_dsis_dim(PRISMS::PSeriesFunction* f, int i, int &dim); - - void PSeriesFunction_dsis_get_linear_coeff(PRISMS::PSeriesFunction* f, int i, double &coeff); - - void PSeriesFunction_dsis_get_tensor_coeff(PRISMS::PSeriesFunction* f, int* term, double &coeff); - - void PSeriesFunction_dsis_set_linear_coeff(PRISMS::PSeriesFunction* f, int i, double coeff); - - void PSeriesFunction_dsis_set_tensor_coeff(PRISMS::PSeriesFunction* f, int* term, double coeff); - - void PSeriesFunction_dsis_linear_index(PRISMS::PSeriesFunction* f, int* term, int &linear_index); - - void PSeriesFunction_dsis_tensor_indices(PRISMS::PSeriesFunction* f, int linear_index, int* term); - - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value - - void PSeriesFunction_dsis_calc(PRISMS::PSeriesFunction* f, double* var, double &val); - - void PSeriesFunction_dsis_calc_grad(PRISMS::PSeriesFunction* f, double* var, int di, double &val); - - void PSeriesFunction_dsis_calc_hess(PRISMS::PSeriesFunction* f, double* var, int di, int dj, double &val); - - // ---------------------------------------------------------- - // Use these functions to evaluate several values, then use 'get' methods to access results - - void PSeriesFunction_dsis_eval(PRISMS::PSeriesFunction* f, double* var); - - void PSeriesFunction_dsis_eval_grad(PRISMS::PSeriesFunction* f, double* var); - - void PSeriesFunction_dsis_eval_hess(PRISMS::PSeriesFunction* f, double* var); - - void PSeriesFunction_dsis_get(PRISMS::PSeriesFunction* f, double &val); - - void PSeriesFunction_dsis_get_grad(PRISMS::PSeriesFunction* f, int di, double &val); - - void PSeriesFunction_dsis_get_hess(PRISMS::PSeriesFunction* f, int di, int dj, double &val); - - - // ---------------------------------------------------------- - // Functions for evaluating basis functions & their derivatives: - - // Use these functions if you want to evaluate a single value - - // use basis index and term index for individual basis function - - void PSeriesFunction_dsis_calc_basis(PRISMS::PSeriesFunction* f, int bindex, int term, double* var, double &val); - - void PSeriesFunction_dsis_calc_basis_grad(PRISMS::PSeriesFunction* f, int bindex, int term, double* var, double &val); - - void PSeriesFunction_dsis_calc_basis_hess(PRISMS::PSeriesFunction* f, int bindex, int term, double* var, double &val); - - // or use tensor indices to evaluate basis function product - void PSeriesFunction_dsis_calc_tensor_basis(PRISMS::PSeriesFunction* f, int* term, double* var, double &val); - - void PSeriesFunction_dsis_calc_tensor_basis_grad(PRISMS::PSeriesFunction* f, int* term, double* var, int di, double &val); - - void PSeriesFunction_dsis_calc_tensor_basis_hess(PRISMS::PSeriesFunction* f, int* term, double* var, int di, int dj, double &val); - - // ---------------------------------------------------------- - // Use these functions to evaluate all basis functions, - // then use following methods to access results. - - void PSeriesFunction_dsis_eval_basis_all(PRISMS::PSeriesFunction* f, double* var); - - void PSeriesFunction_dsis_eval_basis(PRISMS::PSeriesFunction* f, double* var, int i); - - void PSeriesFunction_dsis_eval_basis_grad_all(PRISMS::PSeriesFunction* f, double* var); - - void PSeriesFunction_dsis_eval_basis_grad(PRISMS::PSeriesFunction* f, double* var, int i); - - void PSeriesFunction_dsis_eval_basis_hess_all(PRISMS::PSeriesFunction* f, double* var); - - void PSeriesFunction_dsis_eval_basis_hess(PRISMS::PSeriesFunction* f, double* var, int i); - - - // use basis index and term index for individual basis function - void PSeriesFunction_dsis_get_basis(PRISMS::PSeriesFunction* f, int bindex, int term, double &val); - - void PSeriesFunction_dsis_get_basis_grad(PRISMS::PSeriesFunction* f, int bindex, int term, double &val); - - void PSeriesFunction_dsis_get_basis_hess(PRISMS::PSeriesFunction* f, int bindex, int term, double &val); - - // or use tensor indices to evaluate basis function product - void PSeriesFunction_dsis_get_tensor_basis(PRISMS::PSeriesFunction* f, int* term, double &val); - - void PSeriesFunction_dsis_get_tensor_basis_grad(PRISMS::PSeriesFunction* f, int* term, int di, double &val); - - void PSeriesFunction_dsis_get_tensor_basis_hess(PRISMS::PSeriesFunction* f, int* term, int di, int dj, double &val); - - - - // Functions for using constructing a 2D PRISMS::Body externally (say Python or Fortran), - // allowing access to PFields - // written for Coordinate=double*, DIM=2 - - void Body2D_new(char* vtkfile, PRISMS::Body* &b); - - void Body2D_delete(PRISMS::Body* &b); - - - // Functions for using a 2D scalar PField externally (say Python or Fortran), as a PFunction. - // From a Body pointer, returns a pointer to a PFuncBase - // written for Coordinate=double*, OutType=double, DIM=2 - - void ScalarField2D(char* name, PRISMS::Body* b, PRISMS::PFuncBase* &f); - - - - // Functions for using constructing a 3D PRISMS::Body externally (say Python or Fortran), - // allowing access to PFields - // written for Coordinate=double*, DIM=3 - - void Body3D_new(char* vtkfile, PRISMS::Body* &b); - - void Body3D_delete(PRISMS::Body* &b); - - - // Functions for using a 3D scalar PField externally (say Python or Fortran), as a PFunction. - // From a Body pointer, returns a pointer to a PFuncBase - // written for Coordinate=double*, OutType=double, DIM=3 - - void ScalarField3D(char* name, PRISMS::Body* b, PRISMS::PFuncBase* &f); - - -} + // Functions for using a PSimpleBase externally (say Python or Fortran) + // written for VarContainer=double*, OutType=double, hence 'dsd' in function names + + void + PSimpleFunction_dsd_new(char *name, PRISMS::PSimpleBase *&f); + + void + PSimpleFunction_dsd_delete(PRISMS::PSimpleBase *&f); + + void + PSimpleFunction_dsd_name(PRISMS::PSimpleBase *f, char *name); + + void + PSimpleFunction_dsd_calc(PRISMS::PSimpleBase *f, + double *var, + double &val); + + void + PSimpleFunction_dsd_get(PRISMS::PSimpleBase *f, double &val); + + // Functions for using a PSimpleBase externally (say Python or Fortran) + // written for VarContainer=double, OutType=double, hence 'dd' in function names + + void + PSimpleFunction_dd_new(char *name, PRISMS::PSimpleBase *&f); + + void + PSimpleFunction_dd_delete(PRISMS::PSimpleBase *&f); + + void + PSimpleFunction_dd_name(PRISMS::PSimpleBase *f, char *name); + + void + PSimpleFunction_dd_calc(PRISMS::PSimpleBase *f, + double var, + double &val); + + void + PSimpleFunction_dd_get(PRISMS::PSimpleBase *f, double &val); + + // Functions for using a PFuncBase externally (say Python or Fortran) + // written for VarContainer=double*, OutType=double, hence 'dsd' in function names + + void + PFunction_dsd_new(char *name, PRISMS::PFuncBase *&f); + + void + PFunction_dsd_delete(PRISMS::PFuncBase *&f); + + void + PFunction_dsd_name(PRISMS::PFuncBase *f, char *name); + + void + PFunction_dsd_size(PRISMS::PFuncBase *f, int &size); + + void + PFunction_dsd_var_name(PRISMS::PFuncBase *f, int i, char *var_name); + + void + PFunction_dsd_var_description(PRISMS::PFuncBase *f, + int i, + char *var_description); + + // void PFunction_dsd_simplefunc(PRISMS::PFuncBase* f, + // PSimpleBase* &simplefunc); void + // PFunction_dsd_grad_simplefunc(PRISMS::PFuncBase* f, int di, + // PSimpleBase* &simplefunc); void + // PFunction_dsd_hess_simplefunc(PRISMS::PFuncBase* f, int di, int dj, + // PSimpleBase* &simplefunc); + + void + PFunction_dsd_calc(PRISMS::PFuncBase *f, double *var, double &val); + + void + PFunction_dsd_calc_grad(PRISMS::PFuncBase *f, + double *var, + int di, + double &val); + + void + PFunction_dsd_calc_hess(PRISMS::PFuncBase *f, + double *var, + int di, + int dj, + double &val); + + void + PFunction_dsd_eval(PRISMS::PFuncBase *f, double *var); + + void + PFunction_dsd_eval_grad(PRISMS::PFuncBase *f, double *var, int di); + + void + PFunction_dsd_eval_hess(PRISMS::PFuncBase *f, + double *var, + int di, + int dj); + + void + PFunction_dsd_get(PRISMS::PFuncBase *f, double &val); + + void + PFunction_dsd_get_grad(PRISMS::PFuncBase *f, int di, double &val); + + void + PFunction_dsd_get_hess(PRISMS::PFuncBase *f, + int di, + int dj, + double &val); + + // Functions for using a PBasisSetBase externally (say Python or Fortran) + // written for InType=double, OutType=double, hence 'dd' in function names + + void + PBasisSet_dd_new(char *name, PRISMS::PBasisSetBase *&b, int N); + + void + PBasisSet_dd_delete(PRISMS::PBasisSetBase *&b); + + void + PBasisSet_dd_name(PRISMS::PBasisSetBase *b, char *name); + + void + PBasisSet_dd_description(PRISMS::PBasisSetBase *b, char *description); + + void + PBasisSet_dd_size(PRISMS::PBasisSetBase *b, int &size); + + void + PBasisSet_dd_resize(PRISMS::PBasisSetBase *b, int N); + + void + PBasisSet_dd_max_size(PRISMS::PBasisSetBase *b, int &max_size); + + // void PBasisSet_dd_basis_function(PRISMS::PFuncBase* b, int term, + // PFuncBase* &f); + + void + PBasisSet_dd_calc(PRISMS::PBasisSetBase *b, + int term, + double var, + double &val); + + void + PBasisSet_dd_calc_grad(PRISMS::PBasisSetBase *b, + int term, + double var, + double &val); + + void + PBasisSet_dd_calc_hess(PRISMS::PBasisSetBase *b, + int term, + double var, + double &val); + + void + PBasisSet_dd_eval(PRISMS::PBasisSetBase *b, double var); + + void + PBasisSet_dd_eval_grad(PRISMS::PBasisSetBase *b, double var); + + void + PBasisSet_dd_eval_hess(PRISMS::PBasisSetBase *b, double var); + + void + PBasisSet_dd_get(PRISMS::PBasisSetBase *b, int term, double &val); + + void + PBasisSet_dd_get_grad(PRISMS::PBasisSetBase *b, int term, double &val); + + void + PBasisSet_dd_get_hess(PRISMS::PBasisSetBase *b, int term, double &val); + + // void PBasisSet_dd_getall(PRISMS::PBasisSetBase* b, const double* + // &val); void PBasisSet_dd_getall_grad(PRISMS::PBasisSetBase* b, const + // double* &val); void PBasisSet_dd_getall_hess(PRISMS::PBasisSetBase* b, + // const double* &val); + + // Functions for using a PSeriesFunction externally (say Python or Fortran) + // written for InType=double, OutType=double, VarContainer=double*, + // IndexContainer=int*, hence 'dsis' + + // Functions for using a PSeriesFunction externally (say Python or Fortran) + // written for InType=double, OutType=double, VarContainer=double*, + // IndexContainer=int*, hence 'dsis' + + void + PSeriesFunction_dsis_new(PRISMS::PSeriesFunction *&f); + + void + PSeriesFunction_dsis_setnew( + PRISMS::PSeriesFunction *&f, + PRISMS::PBasisSetBase **basis_set, + int order); + void + PSeriesFunction_dsis_delete( + PRISMS::PSeriesFunction *&f); + + void + PSeriesFunction_dsis_clear(PRISMS::PSeriesFunction *f); + + void + PSeriesFunction_dsis_set(PRISMS::PSeriesFunction *f, + PRISMS::PBasisSetBase **basis_set, + int order); + + void + PSeriesFunction_dsis_order(PRISMS::PSeriesFunction *f, + int &order); + + void + PSeriesFunction_dsis_volume(PRISMS::PSeriesFunction *f, + int &volume); + + void + PSeriesFunction_dsis_dim(PRISMS::PSeriesFunction *f, + int i, + int &dim); + + void + PSeriesFunction_dsis_get_linear_coeff( + PRISMS::PSeriesFunction *f, + int i, + double &coeff); + + void + PSeriesFunction_dsis_get_tensor_coeff( + PRISMS::PSeriesFunction *f, + int *term, + double &coeff); + + void + PSeriesFunction_dsis_set_linear_coeff( + PRISMS::PSeriesFunction *f, + int i, + double coeff); + + void + PSeriesFunction_dsis_set_tensor_coeff( + PRISMS::PSeriesFunction *f, + int *term, + double coeff); + + void + PSeriesFunction_dsis_linear_index( + PRISMS::PSeriesFunction *f, + int *term, + int &linear_index); + + void + PSeriesFunction_dsis_tensor_indices( + PRISMS::PSeriesFunction *f, + int linear_index, + int *term); + + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + + void + PSeriesFunction_dsis_calc(PRISMS::PSeriesFunction *f, + double *var, + double &val); + + void + PSeriesFunction_dsis_calc_grad( + PRISMS::PSeriesFunction *f, + double *var, + int di, + double &val); + + void + PSeriesFunction_dsis_calc_hess( + PRISMS::PSeriesFunction *f, + double *var, + int di, + int dj, + double &val); + + // ---------------------------------------------------------- + // Use these functions to evaluate several values, then use 'get' methods to access + // results + + void + PSeriesFunction_dsis_eval(PRISMS::PSeriesFunction *f, + double *var); + + void + PSeriesFunction_dsis_eval_grad( + PRISMS::PSeriesFunction *f, + double *var); + + void + PSeriesFunction_dsis_eval_hess( + PRISMS::PSeriesFunction *f, + double *var); + + void + PSeriesFunction_dsis_get(PRISMS::PSeriesFunction *f, + double &val); + + void + PSeriesFunction_dsis_get_grad( + PRISMS::PSeriesFunction *f, + int di, + double &val); + + void + PSeriesFunction_dsis_get_hess( + PRISMS::PSeriesFunction *f, + int di, + int dj, + double &val); + + // ---------------------------------------------------------- + // Functions for evaluating basis functions & their derivatives: + + // Use these functions if you want to evaluate a single value + + // use basis index and term index for individual basis function + + void + PSeriesFunction_dsis_calc_basis( + PRISMS::PSeriesFunction *f, + int bindex, + int term, + double *var, + double &val); + + void + PSeriesFunction_dsis_calc_basis_grad( + PRISMS::PSeriesFunction *f, + int bindex, + int term, + double *var, + double &val); + + void + PSeriesFunction_dsis_calc_basis_hess( + PRISMS::PSeriesFunction *f, + int bindex, + int term, + double *var, + double &val); + + // or use tensor indices to evaluate basis function product + void + PSeriesFunction_dsis_calc_tensor_basis( + PRISMS::PSeriesFunction *f, + int *term, + double *var, + double &val); + + void + PSeriesFunction_dsis_calc_tensor_basis_grad( + PRISMS::PSeriesFunction *f, + int *term, + double *var, + int di, + double &val); + + void + PSeriesFunction_dsis_calc_tensor_basis_hess( + PRISMS::PSeriesFunction *f, + int *term, + double *var, + int di, + int dj, + double &val); + + // ---------------------------------------------------------- + // Use these functions to evaluate all basis functions, + // then use following methods to access results. + + void + PSeriesFunction_dsis_eval_basis_all( + PRISMS::PSeriesFunction *f, + double *var); + + void + PSeriesFunction_dsis_eval_basis( + PRISMS::PSeriesFunction *f, + double *var, + int i); + + void + PSeriesFunction_dsis_eval_basis_grad_all( + PRISMS::PSeriesFunction *f, + double *var); + + void + PSeriesFunction_dsis_eval_basis_grad( + PRISMS::PSeriesFunction *f, + double *var, + int i); + + void + PSeriesFunction_dsis_eval_basis_hess_all( + PRISMS::PSeriesFunction *f, + double *var); + + void + PSeriesFunction_dsis_eval_basis_hess( + PRISMS::PSeriesFunction *f, + double *var, + int i); + + // use basis index and term index for individual basis function + void + PSeriesFunction_dsis_get_basis( + PRISMS::PSeriesFunction *f, + int bindex, + int term, + double &val); + + void + PSeriesFunction_dsis_get_basis_grad( + PRISMS::PSeriesFunction *f, + int bindex, + int term, + double &val); + + void + PSeriesFunction_dsis_get_basis_hess( + PRISMS::PSeriesFunction *f, + int bindex, + int term, + double &val); + + // or use tensor indices to evaluate basis function product + void + PSeriesFunction_dsis_get_tensor_basis( + PRISMS::PSeriesFunction *f, + int *term, + double &val); + + void + PSeriesFunction_dsis_get_tensor_basis_grad( + PRISMS::PSeriesFunction *f, + int *term, + int di, + double &val); + + void + PSeriesFunction_dsis_get_tensor_basis_hess( + PRISMS::PSeriesFunction *f, + int *term, + int di, + int dj, + double &val); + + // Functions for using constructing a 2D PRISMS::Body externally (say Python or + // Fortran), + // allowing access to PFields + // written for Coordinate=double*, DIM=2 + + void + Body2D_new(char *vtkfile, PRISMS::Body *&b); + + void + Body2D_delete(PRISMS::Body *&b); + + // Functions for using a 2D scalar PField externally (say Python or Fortran), as a + // PFunction. + // From a Body pointer, returns a pointer to a PFuncBase + // written for Coordinate=double*, OutType=double, DIM=2 + + void + ScalarField2D(char *name, + PRISMS::Body *b, + PRISMS::PFuncBase *&f); + + // Functions for using constructing a 3D PRISMS::Body externally (say Python or + // Fortran), + // allowing access to PFields + // written for Coordinate=double*, DIM=3 + + void + Body3D_new(char *vtkfile, PRISMS::Body *&b); + + void + Body3D_delete(PRISMS::Body *&b); + + // Functions for using a 3D scalar PField externally (say Python or Fortran), as a + // PFunction. + // From a Body pointer, returns a pointer to a PFuncBase + // written for Coordinate=double*, OutType=double, DIM=3 + + void + ScalarField3D(char *name, + PRISMS::Body *b, + PRISMS::PFuncBase *&f); +} #endif \ No newline at end of file diff --git a/include/IntegrationTools/extern/PLibraryExtern.hh b/include/IntegrationTools/extern/PLibraryExtern.hh index 1d442ab19..d2a27768a 100644 --- a/include/IntegrationTools/extern/PLibraryExtern.hh +++ b/include/IntegrationTools/extern/PLibraryExtern.hh @@ -1,43 +1,52 @@ #ifndef PLIBRARY_HH #define PLIBRARY_HH -#include -#include #include "../PFunction.hh" +#include +#include namespace PRISMS { - /// Library where you can find functions and basis sets - /// - namespace PLibrary - { - // Use these functions to checkout objects which manage their own memory - - void checkout( std::string name, PSimpleFunction< double, double > &simplefunc); - void checkout( std::string name, PSimpleFunction< std::vector, double > &simplefunc); - void checkout( std::string name, PSimpleFunction< double*, double > &simplefunc); - - void checkout( std::string name, PFunction< std::vector, double > &func); - void checkout( std::string name, PFunction< double*, double > &func); - - void checkout( std::string name, PBasisSet< double, double > &basis_set, int N); - - - - // Use these functions to checkout new 'Base' objects which the user must delete - - void checkout( std::string name, PSimpleBase< double, double > *&simplefunc); - void checkout( std::string name, PSimpleBase< std::vector, double > *&simplefunc); - void checkout( std::string name, PSimpleBase< double*, double > *&simplefunc); - - void checkout( std::string name, PFuncBase< std::vector, double > *&func); - void checkout( std::string name, PFuncBase< double*, double > *&func); - - void checkout( std::string name, PBasisSetBase< double, double > *&basis_set, int N); - } - -} - + /// Library where you can find functions and basis sets + /// + namespace PLibrary + { + // Use these functions to checkout objects which manage their own memory + + void + checkout(std::string name, PSimpleFunction &simplefunc); + void + checkout(std::string name, PSimpleFunction, double> &simplefunc); + void + checkout(std::string name, PSimpleFunction &simplefunc); + + void + checkout(std::string name, PFunction, double> &func); + void + checkout(std::string name, PFunction &func); + + void + checkout(std::string name, PBasisSet &basis_set, int N); + + // Use these functions to checkout new 'Base' objects which the user must delete + + void + checkout(std::string name, PSimpleBase *&simplefunc); + void + checkout(std::string name, PSimpleBase, double> *&simplefunc); + void + checkout(std::string name, PSimpleBase *&simplefunc); + + void + checkout(std::string name, PFuncBase, double> *&func); + void + checkout(std::string name, PFuncBase *&func); + + void + checkout(std::string name, PBasisSetBase *&basis_set, int N); + } // namespace PLibrary + +} // namespace PRISMS #endif diff --git a/include/IntegrationTools/pfield/Body.hh b/include/IntegrationTools/pfield/Body.hh index 5cb94a668..2fb4ea0bd 100644 --- a/include/IntegrationTools/pfield/Body.hh +++ b/include/IntegrationTools/pfield/Body.hh @@ -4,192 +4,188 @@ #include "./Mesh.hh" #include "./PField.hh" -#include #include -#include +#include #include +#include namespace PRISMS { - /// A class for a Body: a combination of Mesh and Field(s)) - /// - template< class Coordinate, int DIM> - class Body - { - public: - - Mesh mesh; + /// A class for a Body: a combination of Mesh and Field(s)) + /// + template + class Body + { + public: + Mesh mesh; - std::vector< PField > scalar_field; + std::vector> scalar_field; - //std::vector< PField, DIM > > vector_field; + // std::vector< PField, DIM > > vector_field; - //std::vector< PField, DIM > > tensor_field; + // std::vector< PField, DIM > > tensor_field; + // ---------------------------------------------------------- + // Constructors + Body() {}; - // ---------------------------------------------------------- - // Constructors - Body(){}; - - /// Read from a 2D vtk file - /// For now: - /// only ASCII files - /// only rectilinear grids (though output as UNSTRUCTURED_GRID) - /// only (2d) Quad elements - /// - void read_vtk( const std::string &vtkfile) - { - std::cout << "Begin reading vtk file" << std::endl; + /// Read from a 2D vtk file + /// For now: + /// only ASCII files + /// only rectilinear grids (though output as UNSTRUCTURED_GRID) + /// only (2d) Quad elements + /// + void + read_vtk(const std::string &vtkfile) + { + std::cout << "Begin reading vtk file" << std::endl; + // read in vtk file here + std::ifstream infile_mesh(vtkfile.c_str()); - // read in vtk file here - std::ifstream infile_mesh(vtkfile.c_str()); + // read mesh info + mesh.read_vtk(infile_mesh); - // read mesh info - mesh.read_vtk(infile_mesh); + std::ifstream infile(vtkfile.c_str()); - std::ifstream infile(vtkfile.c_str()); + // read point data + std::istringstream ss; + std::string str, name, type, line; + int numcomp; + unsigned long int Npoints; - // read point data - std::istringstream ss; - std::string str, name, type, line; - int numcomp; - unsigned long int Npoints; + while (!infile.eof()) + { + std::getline(infile, line); - while(!infile.eof()) + if (line[0] == 'P') { - - std::getline( infile, line); - - if( line[0] == 'P') + if (line.size() > 9 && line.substr(0, 10) == "POINT_DATA") { - if( line.size() > 9 && line.substr(0,10) == "POINT_DATA") - { - //std::cout << line << "\n"; - ss.clear(); - ss.str(line); - ss >> str >> Npoints; - - } + // std::cout << line << "\n"; + ss.clear(); + ss.str(line); + ss >> str >> Npoints; } - else if( line[0] == 'S') + } + else if (line[0] == 'S') + { + if (line.size() > 6 && line.substr(0, 7) == "SCALARS") { - if( line.size() > 6 && line.substr(0,7) == "SCALARS") - { - ss.clear(); - ss.str(line); - ss >> str >> name >> type >> numcomp; - - // read LOOKUP_TABLE line - std::getline( infile, line); + ss.clear(); + ss.str(line); + ss >> str >> name >> type >> numcomp; - // read data - std::cout << "begin reading data" << std::endl; - std::vector data(Npoints); - for( unsigned int i=0; i> data[i]; - //std::cout << data[i] << std::endl; - } - std::cout << " done" << std::endl; - - - // construct field - std::vector var_name(DIM); - std::vector var_description(DIM); - - if( DIM >= 2) - { - var_name[0] = "x"; - var_description[0] = "x coordinate"; - var_name[1] = "y"; - var_description[1] = "y coordinate"; - - } - if( DIM >= 3) - { - var_name[2] = "z"; - var_description[2] = "z coordinate"; - - } + // read LOOKUP_TABLE line + std::getline(infile, line); + // read data + std::cout << "begin reading data" << std::endl; + std::vector data(Npoints); + for (unsigned int i = 0; i < Npoints; i++) + { + infile >> data[i]; + // std::cout << data[i] << std::endl; + } + std::cout << " done" << std::endl; - std::cout << "Construct PField '" << name << "'" << std::endl; - scalar_field.push_back( PField( name, var_name, var_description, mesh, data, 0.0) ); - std::cout << " done" << std::endl; + // construct field + std::vector var_name(DIM); + std::vector var_description(DIM); + if (DIM >= 2) + { + var_name[0] = "x"; + var_description[0] = "x coordinate"; + var_name[1] = "y"; + var_description[1] = "y coordinate"; } - } - // Alternative field descriptor used by ParaView (holds the same information as the "SCALAR" line above) - else if( line[0] == 'F') - { - if( line.size() > 14 && line.substr(0,15) == "FIELD FieldData") + if (DIM >= 3) { - ss.clear(); - ss.str(line); - ss >> str >> numcomp; - - // read LOOKUP_TABLE line - std::getline( infile, line); - - ss.clear(); - ss.str(line); - ss >> name >> numcomp >> Npoints >> type; - - - // read data - std::cout << "begin reading data" << std::endl; - std::vector data(Npoints); - for( unsigned int i=0; i> data[i]; - } - std::cout << " done" << std::endl; - - - // construct field - std::vector var_name(DIM); - std::vector var_description(DIM); + var_name[2] = "z"; + var_description[2] = "z coordinate"; + } - if( DIM >= 2) - { - var_name[0] = "x"; - var_description[0] = "x coordinate"; - var_name[1] = "y"; - var_description[1] = "y coordinate"; + std::cout << "Construct PField '" << name << "'" << std::endl; + scalar_field.push_back(PField(name, + var_name, + var_description, + mesh, + data, + 0.0)); + std::cout << " done" << std::endl; + } + } + // Alternative field descriptor used by ParaView (holds the same information as + // the "SCALAR" line above) + else if (line[0] == 'F') + { + if (line.size() > 14 && line.substr(0, 15) == "FIELD FieldData") + { + ss.clear(); + ss.str(line); + ss >> str >> numcomp; - } - if( DIM >= 3) - { - var_name[2] = "z"; - var_description[2] = "z coordinate"; + // read LOOKUP_TABLE line + std::getline(infile, line); - } + ss.clear(); + ss.str(line); + ss >> name >> numcomp >> Npoints >> type; + // read data + std::cout << "begin reading data" << std::endl; + std::vector data(Npoints); + for (unsigned int i = 0; i < Npoints; i++) + { + infile >> data[i]; + } + std::cout << " done" << std::endl; - std::cout << "Construct PField '" << name << "'" << std::endl; - scalar_field.push_back( PField( name, var_name, var_description, mesh, data, 0.0) ); - std::cout << " done" << std::endl; + // construct field + std::vector var_name(DIM); + std::vector var_description(DIM); + if (DIM >= 2) + { + var_name[0] = "x"; + var_description[0] = "x coordinate"; + var_name[1] = "y"; + var_description[1] = "y coordinate"; } + if (DIM >= 3) + { + var_name[2] = "z"; + var_description[2] = "z coordinate"; + } + + std::cout << "Construct PField '" << name << "'" << std::endl; + scalar_field.push_back(PField(name, + var_name, + var_description, + mesh, + data, + 0.0)); + std::cout << " done" << std::endl; } } - - infile.close(); } - PField& find_scalar_field(std::string name) + infile.close(); + } + + PField & + find_scalar_field(std::string name) + { + for (unsigned int i = 0; i < scalar_field.size(); i++) { - for( unsigned int i=0; i - class Coordinate + + /// A class for a coordinate, templated by dimension + /// This is a possible option anyplace 'Coordinate' class template is used + /// but it is not the only option. Any class that implements + /// 'Coordinate::operator[]()' should work + + template + class Coordinate + { + double _coord[DIM]; + + public: + int + size() const { - double _coord[DIM]; - public: - - - int size() const - { - return DIM; - } - - double& operator[](int i) - { - return _coord[i]; - } - - const double& operator[](int i) const - { - return _coord[i]; - } - - template< int D> friend std::ostream &operator<<(std::ostream &outstream, const Coordinate &coord); - - }; - - template std::ostream &operator<<(std::ostream &outstream, const Coordinate &coord) + return DIM; + } + + double & + operator[](int i) { - for( int i=0; i + friend std::ostream & + operator<<(std::ostream &outstream, const Coordinate &coord); + }; + + template + std::ostream & + operator<<(std::ostream &outstream, const Coordinate &coord) + { + for (int i = 0; i < coord.size(); i++) + { + outstream << coord[i]; + if (i < coord.size() - 1) + outstream << " "; + } + return outstream; + } +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/pfield/Mesh.hh b/include/IntegrationTools/pfield/Mesh.hh index 173da9e4c..a66d62d83 100644 --- a/include/IntegrationTools/pfield/Mesh.hh +++ b/include/IntegrationTools/pfield/Mesh.hh @@ -2,799 +2,856 @@ #ifndef Mesh_HH #define Mesh_HH -#include -#include -#include -#include - #include "../datastruc/Bin.hh" #include "../pfunction/PFuncBase.hh" +#include "./interpolation/Hexahedron.hh" #include "./interpolation/Interpolator.hh" #include "./interpolation/Quad.hh" -#include "./interpolation/Hexahedron.hh" +#include +#include +#include +#include namespace PRISMS { - inline void construct_basis_function( PFuncBase >, double>* &bfunc, const std::string &name) - { - if( name == "Quad") - { - bfunc = new Quad(); - } - else - { - std::cout << "Error in construct_basis_function (2D): unknown name: " << name << std::endl; - exit(1); - } - } - - inline void construct_basis_function( PFuncBase >, double>* &bfunc, const std::string &name) - { - if( name == "Hexahedron") - { - bfunc = new Hexahedron(); - } - else - { - std::cout << "Error in construct_basis_function (3D): unknown name: " << name << std::endl; - exit(1); - } - } + inline void + construct_basis_function(PFuncBase>, double> *&bfunc, + const std::string &name) + { + if (name == "Quad") + { + bfunc = new Quad(); + } + else + { + std::cout << "Error in construct_basis_function (2D): unknown name: " << name + << std::endl; + exit(1); + } + } + + inline void + construct_basis_function(PFuncBase>, double> *&bfunc, + const std::string &name) + { + if (name == "Hexahedron") + { + bfunc = new Hexahedron(); + } + else + { + std::cout << "Error in construct_basis_function (3D): unknown name: " << name + << std::endl; + exit(1); + } + } + + template + void + construct_interpolating_functions( + std::vector *> &interp, + const std::string &name, + unsigned long int cell, + PFuncBase>, double> *bfunc_ptr, + const std::vector &cell_node, + const std::vector> &node) + { + if (name == "Quad") + { + Interpolator *interp_ptr = nullptr; + + // std::cout << "cell nodes: " << cell_node[0] << " " << cell_node[2] << + // std::endl; + + PRISMS::Coordinate<2> dim; + dim[0] = node[cell_node[2]][0] - node[cell_node[0]][0]; + dim[1] = node[cell_node[2]][1] - node[cell_node[0]][1]; + + // QuadValues(const Coordinate &node, const Coordinate &dim, int node_index) + for (int j = 0; j < 4; j++) + { + interp.push_back(interp_ptr); + interp.back() = new PRISMS::QuadValues(cell_node[j], + cell, + bfunc_ptr, + node[cell_node[j]], + dim, + j); + } + } + else + { + std::cout << "Error in construct_interpolating_function (2D): unknown name: " + << name << std::endl; + exit(1); + } + } + + template + void + construct_interpolating_functions( + std::vector *> &interp, + const std::string &name, + unsigned long int cell, + PFuncBase>, double> *bfunc_ptr, + const std::vector &cell_node, + const std::vector> &node) + { + if (name == "Hexahedron") + { + Interpolator *interp_ptr = nullptr; + + PRISMS::Coordinate<3> dim; + dim[0] = node[cell_node[6]][0] - node[cell_node[0]][0]; + dim[1] = node[cell_node[6]][1] - node[cell_node[0]][1]; + dim[2] = node[cell_node[6]][2] - node[cell_node[0]][2]; + + // QuadValues(const Coordinate &node, const Coordinate &dim, int node_index) + for (int j = 0; j < 8; j++) + { + interp.push_back(interp_ptr); + interp.back() = new PRISMS::HexahedronValues(cell_node[j], + cell, + bfunc_ptr, + node[cell_node[j]], + dim, + j); + } + } + else + { + std::cout << "Error in construct_interpolating_function (3D): unknown name: " + << name << std::endl; + exit(1); + } + } + + /// A template class for a finite element mesh + /// Needs: Coordinate::operator[]() for use in Bin + /// + template + class Mesh + { + // min and max coordinate of cuboid surrounding the body + PRISMS::Coordinate _min; + PRISMS::Coordinate _max; + + /// Vector of nodal coordinates + /// nodal values live in 'Field' class + /// + std::vector> _node; - template< class Coordinate> - void construct_interpolating_functions( std::vector* > &interp, - const std::string &name, - unsigned long int cell, - PFuncBase >, double>* bfunc_ptr, - const std::vector &cell_node, - const std::vector > &node) - { - if( name == "Quad") - { - Interpolator* interp_ptr; + /// array containing interpolating functions: + /// owns the interpolating functions + /// interpolating functions contain basis function / element info, + /// these point to _bfunc pfunctions which are used to evaluate + /// + std::vector *> _interp; - //std::cout << "cell nodes: " << cell_node[0] << " " << cell_node[2] << std::endl; + /// array containing PFunctions evaluated by interpolating functions + /// owns the pfunctions, which are pointed to by the interpolating functions + /// !!! do not modify after initial construction or pointers will be messed up !!! + /// + std::vector>, double> *> _bfunc; + /// bin of interpolating functions (this might be updated to be either Element or + /// Spline Bins) + /// + Bin *, Coordinate> _bin; - PRISMS::Coordinate<2> dim; - dim[0] = node[ cell_node[2]][0] - node[ cell_node[0]][0]; - dim[1] = node[ cell_node[2]][1] - node[ cell_node[0]][1]; + public: + // still need a constructor + Mesh() {}; - // QuadValues(const Coordinate &node, const Coordinate &dim, int node_index) - for( int j=0; j<4; j++) - { - interp.push_back(interp_ptr); - interp.back() = new PRISMS::QuadValues(cell_node[j], cell, bfunc_ptr, node[ cell_node[j]], dim, j); - } - } - else - { - std::cout << "Error in construct_interpolating_function (2D): unknown name: " << name << std::endl; - exit(1); - } - } - - template< class Coordinate> - void construct_interpolating_functions( std::vector* > &interp, - const std::string &name, - unsigned long int cell, - PFuncBase >, double>* bfunc_ptr, - const std::vector &cell_node, - const std::vector > &node) + ~Mesh() { - if( name == "Hexahedron") + for (unsigned int i = 0; i < _interp.size(); i++) { - Interpolator* interp_ptr; - - PRISMS::Coordinate<3> dim; - dim[0] = node[ cell_node[6]][0] - node[ cell_node[0]][0]; - dim[1] = node[ cell_node[6]][1] - node[ cell_node[0]][1]; - dim[2] = node[ cell_node[6]][2] - node[ cell_node[0]][2]; - - // QuadValues(const Coordinate &node, const Coordinate &dim, int node_index) - for( int j=0; j<8; j++) - { - interp.push_back(interp_ptr); - interp.back() = new PRISMS::HexahedronValues(cell_node[j], cell, bfunc_ptr, node[ cell_node[j]], dim, j); - } + delete _interp[i]; } - else + + for (unsigned int i = 0; i < _bfunc.size(); i++) { - std::cout << "Error in construct_interpolating_function (3D): unknown name: " << name << std::endl; - exit(1); + delete _bfunc[i]; } - } - - + }; - /// A template class for a finite element mesh - /// Needs: Coordinate::operator[]() for use in Bin - /// - template - class Mesh + // reads vtk file through 'CELL_TYPES' and then returns + void + read_vtk(std::ifstream &infile) { - // min and max coordinate of cuboid surrounding the body - PRISMS::Coordinate _min; - PRISMS::Coordinate _max; - - /// Vector of nodal coordinates - /// nodal values live in 'Field' class - /// - std::vector > _node; - - /// array containing interpolating functions: - /// owns the interpolating functions - /// interpolating functions contain basis function / element info, - /// these point to _bfunc pfunctions which are used to evaluate - /// - std::vector* > _interp; - - /// array containing PFunctions evaluated by interpolating functions - /// owns the pfunctions, which are pointed to by the interpolating functions - /// !!! do not modify after initial construction or pointers will be messed up !!! - /// - std::vector< PFuncBase >, double>* > _bfunc; - - /// bin of interpolating functions (this might be updated to be either Element or Spline Bins) - /// - Bin*, Coordinate > _bin; - - public: - - // still need a constructor - Mesh(){}; - - ~Mesh() - { - for( unsigned int i=0; i<_interp.size(); i++) - { - delete _interp[i]; - } - - for( unsigned int i=0; i<_bfunc.size(); i++) - { - delete _bfunc[i]; - } - }; + bool mesh_as_points = true; + std::vector x_coord, y_coord, z_coord; - // reads vtk file through 'CELL_TYPES' and then returns - void read_vtk(std::ifstream &infile) - { - bool mesh_as_points = true; - std::vector x_coord, y_coord, z_coord; + std::istringstream ss; + std::string line, str, type; - std::istringstream ss; - std::string line, str, type; + unsigned long int uli_dummy; + double d_dummy; - unsigned long int uli_dummy; - double d_dummy; + unsigned long int Npoints, Ncells, Ncell_numbers; + std::vector cell_node; - unsigned long int Npoints, Ncells, Ncell_numbers; - std::vector cell_node; + PRISMS::Coordinate _coord; - PRISMS::Coordinate _coord; + while (!infile.eof()) + { + std::getline(infile, line); + // std::cout << "line: " << line << std::endl; - while(!infile.eof()) + if (line[0] == 'P') { - std::getline( infile, line); - //std::cout << "line: " << line << std::endl; - - if( line[0] == 'P') + // read POINTS info: + // POINTS # type + // x y z + // x y z + // ... + if (line.size() > 5 && line.substr(0, 6) == "POINTS") { - // read POINTS info: - // POINTS # type - // x y z - // x y z - // ... - if( line.size() > 5 && line.substr(0,6) == "POINTS") + // read header line + // std::cout << line << "\n"; + ss.clear(); + ss.str(line); + ss >> str >> Npoints >> type; + + // read points + std::vector> value(DIM); + std::vector> hist(DIM); + + std::cout << "Read POINTS: " << Npoints << std::endl; + _node.reserve(Npoints); + std::cout << " reserve OK" << std::endl; + for (unsigned int i = 0; i < Npoints; i++) { - // read header line - //std::cout << line << "\n"; - ss.clear(); - ss.str(line); - ss >> str >> Npoints >> type; - - // read points - std::vector< std::vector > value(DIM); - std::vector< std::vector > hist(DIM); - - std::cout << "Read POINTS: " << Npoints << std::endl; - _node.reserve(Npoints); - std::cout << " reserve OK" << std::endl; - for( unsigned int i=0; i> _coord[0] >> _coord[1] >> d_dummy; - //std::cout << _coord[0] << " " << _coord[1] << " " << d_dummy << std::endl; - } - else if( DIM == 3) - { - infile >> _coord[0] >> _coord[1] >> _coord[2]; - //std::cout << _coord[0] << " " << _coord[1] << " " << _coord[3] << std::endl; - } - - for( int j=0; j> _coord[0] >> _coord[1] >> d_dummy; + // std::cout << _coord[0] << " " << _coord[1] << " " << d_dummy + // << std::endl; + } + else if (DIM == 3) + { + infile >> _coord[0] >> _coord[1] >> _coord[2]; + // std::cout << _coord[0] << " " << _coord[1] << " " << + // _coord[3] << std::endl; } - std::cout << " done" << std::endl; - // create bins - std::vector min; - std::vector N; - std::vector incr; + for (int j = 0; j < DIM; j++) + add_once(value[j], hist[j], _coord[j]); + _node.push_back(_coord); + } + std::cout << " done" << std::endl; - std::cout << "Determine Body size" << std::endl; - for( int j=0; j min; + std::vector N; + std::vector incr; + + std::cout << "Determine Body size" << std::endl; + for (int j = 0; j < DIM; j++) + { + for (unsigned int i = 1; i < hist[j].size(); i++) { - for( unsigned int i=1; i*, Coordinate>(min, incr, N); - std::cout << " done" << std::endl; + std::cout << " done" << std::endl; + std::cout << "Initialize Bin" << std::endl; + _bin = Bin *, Coordinate>(min, incr, N); + std::cout << " done" << std::endl; } - - } - else if( line[0] == 'C') + else if (line[0] == 'C') { - - if( line.size() > 4 && line.substr(0,5) == "CELLS") + if (line.size() > 4 && line.substr(0, 5) == "CELLS") { - //std::cout << line << "\n"; - ss.clear(); - ss.str(line); + // std::cout << line << "\n"; + ss.clear(); + ss.str(line); - ss >> str >> Ncells >> Ncell_numbers; + ss >> str >> Ncells >> Ncell_numbers; - PFuncBase >, double>* bfunc_ptr; - _bfunc.push_back( bfunc_ptr); + PFuncBase>, double> *bfunc_ptr = + nullptr; + _bfunc.push_back(bfunc_ptr); - if( DIM == 2) + if (DIM == 2) { - // add Quad basis function - _interp.reserve(Ncells*4); - construct_basis_function(_bfunc.back(), "Quad"); + // add Quad basis function + _interp.reserve(Ncells * 4); + construct_basis_function(_bfunc.back(), "Quad"); } - else if( DIM == 3) + else if (DIM == 3) { - // add Hexahedron basis function - _interp.reserve(Ncells*8); - construct_basis_function(_bfunc.back(), "Hexahedron"); + // add Hexahedron basis function + _interp.reserve(Ncells * 8); + construct_basis_function(_bfunc.back(), "Hexahedron"); } - bfunc_ptr = _bfunc.back(); + bfunc_ptr = _bfunc.back(); - std::cout << "Read CELLS: " << Ncells << std::endl; - for( unsigned int i=0; i> uli_dummy; + infile >> uli_dummy; - cell_node.resize(uli_dummy); - for( unsigned int j=0; j> cell_node[j]; + infile >> cell_node[j]; } - //std::cout << cell_node[0] << " " << cell_node[1] << " " << cell_node[2] << " " << cell_node[3] << std::endl; + // std::cout << cell_node[0] << " " << cell_node[1] << " " << + // cell_node[2] << " " << cell_node[3] << std::endl; - // create interpolator - if( DIM == 2) + // create interpolator + if (DIM == 2) { - construct_interpolating_functions(_interp, "Quad", i, bfunc_ptr, cell_node, _node); + construct_interpolating_functions(_interp, + "Quad", + i, + bfunc_ptr, + cell_node, + _node); } - else if(DIM == 3) + else if (DIM == 3) { - construct_interpolating_functions(_interp, "Hexahedron", i, bfunc_ptr, cell_node, _node); + construct_interpolating_functions(_interp, + "Hexahedron", + i, + bfunc_ptr, + cell_node, + _node); } - } - std::cout << " done" << std::endl; + std::cout << " done" << std::endl; - // bin interpolators - std::cout << "Bin interpolating functions" << std::endl; + // bin interpolators + std::cout << "Bin interpolating functions" << std::endl; - for( unsigned int i=0; i<_interp.size(); i++) + for (unsigned int i = 0; i < _interp.size(); i++) { - _bin.add_range(_interp[i], _interp[i]->min(), _interp[i]->max()); + _bin.add_range(_interp[i], _interp[i]->min(), _interp[i]->max()); } - std::cout << " done max_bin_size: " << _bin.max_size() << std::endl; - - + std::cout << " done max_bin_size: " << _bin.max_size() << std::endl; } - else if( line.size() > 9 && line.substr(0,10) == "CELL_TYPES") + else if (line.size() > 9 && line.substr(0, 10) == "CELL_TYPES") { - //std::cout << line << "\n"; - ss.clear(); - ss.str(line); + // std::cout << line << "\n"; + ss.clear(); + ss.str(line); - //std::cout << "ss.str()" << ss.str() << std::endl; - ss >> str >> Ncells; + // std::cout << "ss.str()" << ss.str() << std::endl; + ss >> str >> Ncells; - for( unsigned int i=0; i> uli_dummy; + infile >> uli_dummy; - if( uli_dummy != 9 && uli_dummy != 12) + if (uli_dummy != 9 && uli_dummy != 12) { - std::cout << "Error reading CELL_TYPES: CELL TYPE != 9 && != 12" << std::endl; - std::cout << " CELL TYPE: " << uli_dummy << std::endl; - exit(1); + std::cout << "Error reading CELL_TYPES: CELL TYPE != 9 && != 12" + << std::endl; + std::cout << " CELL TYPE: " << uli_dummy << std::endl; + exit(1); } } - return; + return; } - } - if( line[0] == 'X') + if (line[0] == 'X') { - mesh_as_points = false; - - // read X_COORDINATES info: - // X_COORDINATES # type - // x - // x - // ... - if( line.size() > 12 && line.substr(0,13) == "X_COORDINATES") + mesh_as_points = false; + + // read X_COORDINATES info: + // X_COORDINATES # type + // x + // x + // ... + if (line.size() > 12 && line.substr(0, 13) == "X_COORDINATES") { - // read header line - //std::cout << line << "\n"; - ss.clear(); - ss.str(line); - ss >> str >> Npoints >> type; - - std::cout << "Read X_COORDINATES: " << Npoints << std::endl; - _node.reserve(Npoints); - std::cout << " reserve OK" << std::endl; - for( unsigned int i=0; i> str >> Npoints >> type; + + std::cout << "Read X_COORDINATES: " << Npoints << std::endl; + _node.reserve(Npoints); + std::cout << " reserve OK" << std::endl; + for (unsigned int i = 0; i < Npoints; i++) { - double temp_coord; - - infile >> temp_coord; + double temp_coord; - x_coord.push_back(temp_coord); + infile >> temp_coord; + x_coord.push_back(temp_coord); } } } - if( line[0] == 'Y') + if (line[0] == 'Y') { - mesh_as_points = false; - - // read Y_COORDINATES info: - // Y_COORDINATES # type - // y - // y - // ... - if( line.size() > 12 && line.substr(0,13) == "Y_COORDINATES") + mesh_as_points = false; + + // read Y_COORDINATES info: + // Y_COORDINATES # type + // y + // y + // ... + if (line.size() > 12 && line.substr(0, 13) == "Y_COORDINATES") { - - - // read header line - //std::cout << line << "\n"; - ss.clear(); - ss.str(line); - ss >> str >> Npoints >> type; - - // read points - std::vector< std::vector > value(DIM); - std::vector< std::vector > hist(DIM); - - std::cout << "Read Y_COORDINATES: " << Npoints << std::endl; - _node.reserve(Npoints); - std::cout << " reserve OK" << std::endl; - for( unsigned int i=0; i> str >> Npoints >> type; + + // read points + std::vector> value(DIM); + std::vector> hist(DIM); + + std::cout << "Read Y_COORDINATES: " << Npoints << std::endl; + _node.reserve(Npoints); + std::cout << " reserve OK" << std::endl; + for (unsigned int i = 0; i < Npoints; i++) { - double temp_coord; - - infile >> temp_coord; + double temp_coord; - y_coord.push_back(temp_coord); + infile >> temp_coord; + y_coord.push_back(temp_coord); } } } - if( line[0] == 'Z') + if (line[0] == 'Z') { - mesh_as_points = false; - - // read Z_COORDINATES info: - // Z_COORDINATES # type - // z - // z - // ... - if( line.size() > 12 && line.substr(0,13) == "Z_COORDINATES") + mesh_as_points = false; + + // read Z_COORDINATES info: + // Z_COORDINATES # type + // z + // z + // ... + if (line.size() > 12 && line.substr(0, 13) == "Z_COORDINATES") { - - - // read header line - //std::cout << line << "\n"; - ss.clear(); - ss.str(line); - ss >> str >> Npoints >> type; - - // read points - - std::cout << "Read Z_COORDINATES: " << Npoints << std::endl; - _node.reserve(Npoints); - std::cout << " reserve OK" << std::endl; - for( unsigned int i=0; i> str >> Npoints >> type; + + // read points + + std::cout << "Read Z_COORDINATES: " << Npoints << std::endl; + _node.reserve(Npoints); + std::cout << " reserve OK" << std::endl; + for (unsigned int i = 0; i < Npoints; i++) { - double temp_coord; + double temp_coord; - infile >> temp_coord; - - z_coord.push_back(temp_coord); + infile >> temp_coord; + z_coord.push_back(temp_coord); } } } } - if (!mesh_as_points){ - std::vector< std::vector > value(DIM); - std::vector< std::vector > hist(DIM); - - for (unsigned int i=0; i 2){ - _coord[2] = z_coord.at(k); + if (!mesh_as_points) + { + std::vector> value(DIM); + std::vector> hist(DIM); + + for (unsigned int i = 0; i < x_coord.size(); i++) + { + for (unsigned int j = 0; j < y_coord.size(); j++) + { + for (unsigned int k = 0; k < z_coord.size(); k++) + { + _coord[0] = x_coord.at(i); + _coord[1] = y_coord.at(j); + if (DIM > 2) + { + _coord[2] = z_coord.at(k); } - for( int m=0; m min; - std::vector N; - std::vector incr; + // create bins + std::vector min; + std::vector N; + std::vector incr; - std::cout << "Determine Body size" << std::endl; - for( int j=0; j*, Coordinate>(min, incr, N); - std::cout << " done" << std::endl; - - // Now add the cell data - unsigned int Ncells = (x_coord.size()-1) * (y_coord.size()-1); - if (DIM > 2){ - Ncells *= (z_coord.size()-1); - } + std::sort(value[j].begin(), value[j].end()); + // std::cout << "j: " << j << " back(): " << value[j].back() << std::endl; + min.push_back(value[j][0]); + N.push_back(value[j].size()); + incr.push_back((value[j].back() - value[j][0]) / (1.0 * N.back())); - PFuncBase >, double>* bfunc_ptr; - _bfunc.push_back( bfunc_ptr); + // get min and max surrounding coordinates + _min[j] = value[j][0]; + _max[j] = value[j].back(); - if( DIM == 2) - { - // add Quad basis function - _interp.reserve(Ncells*4); - construct_basis_function(_bfunc.back(), "Quad"); - } - else if( DIM == 3) - { - // add Hexahedron basis function - _interp.reserve(Ncells*8); - construct_basis_function(_bfunc.back(), "Hexahedron"); - } - bfunc_ptr = _bfunc.back(); + // for short term, expand bin to avoid edge issues + min[j] -= incr[j]; + N[j] += 2; + } + std::cout << " Min Coordinate: "; + for (int j = 0; j < DIM; j++) + std::cout << _min[j] << " "; + std::cout << std::endl; + std::cout << " Max Coordinate: "; + for (int j = 0; j < DIM; j++) + std::cout << _max[j] << " "; + std::cout << std::endl; + + std::cout << " done" << std::endl; + + std::cout << "Initialize Bin" << std::endl; + _bin = Bin *, Coordinate>(min, incr, N); + std::cout << " done" << std::endl; + + // Now add the cell data + unsigned int Ncells = (x_coord.size() - 1) * (y_coord.size() - 1); + if (DIM > 2) + { + Ncells *= (z_coord.size() - 1); + } - std::cout << "Read CELLS: " << Ncells << std::endl; + PFuncBase>, double> *bfunc_ptr = nullptr; + _bfunc.push_back(bfunc_ptr); - unsigned int uli_dummy; - if (DIM > 2){ - uli_dummy = 8; - } - else { - uli_dummy = 4; - } - for( unsigned int i=0; i 2) { - construct_interpolating_functions(_interp, "Quad", i, bfunc_ptr, cell_node, _node); + uli_dummy = 8; } - else if(DIM == 3) + else { - construct_interpolating_functions(_interp, "Hexahedron", i, bfunc_ptr, cell_node, _node); + uli_dummy = 4; } + for (unsigned int i = 0; i < Ncells; i++) + { + cell_node.resize(uli_dummy); + for (unsigned int j = 0; j < uli_dummy; j++) + { + cell_node[j] = i * uli_dummy + j; + } - } - std::cout << " done" << std::endl; - - // bin interpolators - std::cout << "Bin interpolating functions" << std::endl; - std::cout << "num nodes: " << _node.size() << std::endl; - for( unsigned int i=0; i<_interp.size(); i++) - { - std::cout << "interp: " << _interp[i] << " " << _interp[i]->min() << " " << _interp[i]->max() << std::endl; - _bin.add_range(_interp[i], _interp[i]->min(), _interp[i]->max()); - } - std::cout << " done max_bin_size: " << _bin.max_size() << std::endl; - - } + if (DIM == 2) + { + double temp = cell_node[2]; + cell_node[2] = cell_node[3]; + cell_node[3] = temp; + } + // std::cout << cell_node[0] << " " << cell_node[1] << " " << cell_node[2] + // << " " << cell_node[3] << std::endl; -} + // create interpolator + if (DIM == 2) + { + construct_interpolating_functions(_interp, + "Quad", + i, + bfunc_ptr, + cell_node, + _node); + } + else if (DIM == 3) + { + construct_interpolating_functions(_interp, + "Hexahedron", + i, + bfunc_ptr, + cell_node, + _node); + } + } + std::cout << " done" << std::endl; - void min( Coordinate &coord) - { - for( int i=0; imin() << " " + << _interp[i]->max() << std::endl; + _bin.add_range(_interp[i], _interp[i]->min(), _interp[i]->max()); + } + std::cout << " done max_bin_size: " << _bin.max_size() << std::endl; } + } - void max( Coordinate &coord) - { - for( int i=0; i &bfunc, std::vector &node_index, int &s) - { - std::vector* > &bin = _bin.contents(coord); - s = bin.size(); + // Set 'bfunc' to evaluated basis functions at 'coord', + // 'node_index' to node indices for each basis function, + // and 's' is the length (number of basis functions) + // - 'bfunc' and 'node_index' are not resized, they must be big enough + // + void + basis_functions(const Coordinate &coord, + std::vector &bfunc, + std::vector &node_index, + int &s) + { + std::vector *> &bin = _bin.contents(coord); + s = bin.size(); - int i=0; - unsigned long int element; + int i = 0; + unsigned long int element; - for( i=0; i &bfunc, std::vector &node_index, int &s) - { - //std::cout << "begin Mesh::grad_basis_functions()" << std::endl; - std::vector* > &bin = _bin.contents(coord); - s = bin.size(); + // Set 'bfunc' to evaluated grad basis functions at coord, and 's' is the length + void + grad_basis_functions(const Coordinate &coord, + int di, + std::vector &bfunc, + std::vector &node_index, + int &s) + { + // std::cout << "begin Mesh::grad_basis_functions()" << std::endl; + std::vector *> &bin = _bin.contents(coord); + s = bin.size(); - int i=0; - unsigned long int element; + int i = 0; + unsigned long int element; - for( i=0; i &bfunc, std::vector &node_index, int &s) - { - std::vector* > &bin = _bin.contents(coord); - s = bin.size(); + // Set 'bfunc' to evaluated hess basis functions at coord, and 's' is the length + void + hess_basis_functions(Coordinate coord, + int di, + int dj, + std::vector &bfunc, + std::vector &node_index, + int &s) + { + std::vector *> &bin = _bin.contents(coord); + s = bin.size(); - int i=0; - unsigned long int element; + int i = 0; + unsigned long int element; - for( i=0; i &list, std::vector &hist, double val) + { + // std::cout << "begin add_once()" << std::endl; - void add_once( std::vector &list, std::vector &hist, double val) + for (unsigned int i = 0; i < list.size(); i++) { - //std::cout << "begin add_once()" << std::endl; - - for( unsigned int i=0; i' for x, y, z - /// FieldType is the datatype for the field, - /// for instance 'double' for temperature or 'std::vector' for vector displacement - /// - /// A field consists of a pointer to a mesh, a list field values (at mesh nodes) - template - class PField : public PFuncBase - { - public: - - typedef typename PFuncBase::size_type size_type; - - // pointer to a Mesh that lives in a Body - Mesh *_mesh; - - // array of field values at mesh nodes - std::vector _field; - - FieldType _zero; - - FieldType _val; - std::vector _grad_val; - std::vector< std::vector > _hess_val; - - // ---------------------------------------------------------- - // Constructors - // PField(); - - PField( const std::string &name, - const std::vector &var_name, - const std::vector &var_description, - Mesh &mesh, - const std::vector &field, - const FieldType &zero) : - PFuncBase(name, var_name, var_description), - _mesh(&mesh), - _field(field), - _zero(zero) - - { - int max = mesh.max_bin_size(); - _bfunc.resize(max); - _node_index.resize(max); - _grad_val.resize(DIM); - _hess_val.resize(DIM); - for( int i=0; i* clone() const - { - return new PField(*this); - } - - - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value - FieldType operator()(const Coordinate &coord); - FieldType grad(const Coordinate &coord, size_type di); - FieldType hess(const Coordinate &coord, size_type di, size_type dj); - - // ---------------------------------------------------------- - // Use these functions to evaluate several values, then use 'get' methods to access results - void eval(const Coordinate &coord); - void eval_grad(const Coordinate &coord); - void eval_hess(const Coordinate &coord); - - FieldType operator()() const; - FieldType grad(size_type di) const; - FieldType hess(size_type di, size_type dj) const; - - // PField unique members ------------------------------------------ - - private: - - // temporary vector - std::vector _bfunc; - std::vector _node_index; - int _Nbfunc; - - - }; - - template - FieldType PField::operator()( const Coordinate &coord) - { - //std::cout << "begin calc" << std::endl; - - //std::cout << "coord: "; - //for( int i=0; i - FieldType PField::grad( const Coordinate &coord, size_type di) - { - //std::cout << "begin PField::grad()" << std::endl; - // get evaluated basis functions - (*_mesh).grad_basis_functions(coord, di, _bfunc, _node_index, _Nbfunc); - - // sum them - _grad_val[di] = _zero; - for( int i=0; i<_Nbfunc; i++) - _grad_val[di] += _bfunc[i]*_field[_node_index[i]]; - return _grad_val[di]; - //std::cout << "finish PField::grad()" << std::endl; - - } - - template - FieldType PField::hess( const Coordinate &coord, size_type di, size_type dj) - { - // get evaluated basis functions - (*_mesh).hess_basis_functions(coord, di, dj, _bfunc, _node_index, _Nbfunc); - - // sum them - _hess_val[di][dj] = _zero; - for( int i=0; i<_Nbfunc; i++) - _hess_val[di][dj] += _bfunc[i]*_field[_node_index[i]]; - return _hess_val[di][dj]; - } - - template - void PField::eval( const Coordinate &coord) - { - (*this)(coord); - } + /// A class for a field + /// + /// Varcontainer contains variables, for instance 'std::vector' for x, y, z + /// FieldType is the datatype for the field, + /// for instance 'double' for temperature or 'std::vector' for vector + /// displacement + /// + /// A field consists of a pointer to a mesh, a list field values (at mesh nodes) + template + class PField : public PFuncBase + { + public: + typedef typename PFuncBase::size_type size_type; + + // pointer to a Mesh that lives in a Body + Mesh *_mesh; + + // array of field values at mesh nodes + std::vector _field; + + FieldType _zero; + + FieldType _val; + std::vector _grad_val; + std::vector> _hess_val; + + // ---------------------------------------------------------- + // Constructors + // PField(); + + PField(const std::string &name, + const std::vector &var_name, + const std::vector &var_description, + Mesh &mesh, + const std::vector &field, + const FieldType &zero) + : PFuncBase(name, var_name, var_description) + , _mesh(&mesh) + , _field(field) + , _zero(zero) - template - void PField::eval_grad( const Coordinate &coord) { - for( int di=0; di - void PField::eval_hess( const Coordinate &coord) - { - for( int di=0; di - FieldType PField::operator()() const + PField * + clone() const override { - return _val; + return new PField(*this); } - template - FieldType PField::grad( size_type di) const - { - return _grad_val[di]; - } - - template - FieldType PField::hess( size_type di, size_type dj) const - { - return _hess_val[di][dj]; - } - -} - + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + FieldType + operator()(const Coordinate &coord) override; + FieldType + grad(const Coordinate &coord, size_type di) override; + FieldType + hess(const Coordinate &coord, size_type di, size_type dj) override; + + // ---------------------------------------------------------- + // Use these functions to evaluate several values, then use 'get' methods to access + // results + void + eval(const Coordinate &coord) override; + void + eval_grad(const Coordinate &coord) override; + void + eval_hess(const Coordinate &coord) override; + + FieldType + operator()() const override; + FieldType + grad(size_type di) const override; + FieldType + hess(size_type di, size_type dj) const override; + + // PField unique members ------------------------------------------ + + private: + // temporary vector + std::vector _bfunc; + std::vector _node_index; + int _Nbfunc; + }; + + template + FieldType + PField::operator()(const Coordinate &coord) + { + // std::cout << "begin calc" << std::endl; + + // std::cout << "coord: "; + // for( int i=0; i + FieldType + PField::grad(const Coordinate &coord, size_type di) + { + // std::cout << "begin PField::grad()" << std::endl; + // get evaluated basis functions + (*_mesh).grad_basis_functions(coord, di, _bfunc, _node_index, _Nbfunc); + + // sum them + _grad_val[di] = _zero; + for (int i = 0; i < _Nbfunc; i++) + _grad_val[di] += _bfunc[i] * _field[_node_index[i]]; + return _grad_val[di]; + // std::cout << "finish PField::grad()" << std::endl; + } + + template + FieldType + PField::hess(const Coordinate &coord, + size_type di, + size_type dj) + { + // get evaluated basis functions + (*_mesh).hess_basis_functions(coord, di, dj, _bfunc, _node_index, _Nbfunc); + + // sum them + _hess_val[di][dj] = _zero; + for (int i = 0; i < _Nbfunc; i++) + _hess_val[di][dj] += _bfunc[i] * _field[_node_index[i]]; + return _hess_val[di][dj]; + } + + template + void + PField::eval(const Coordinate &coord) + { + (*this)(coord); + } + + template + void + PField::eval_grad(const Coordinate &coord) + { + for (int di = 0; di < DIM; di++) + (*this).grad(coord, di); + } + + template + void + PField::eval_hess(const Coordinate &coord) + { + for (int di = 0; di < DIM; di++) + for (int dj = 0; dj < DIM; dj++) + (*this).hess(coord, di, dj); + } + + template + FieldType + PField::operator()() const + { + return _val; + } + + template + FieldType + PField::grad(size_type di) const + { + return _grad_val[di]; + } + + template + FieldType + PField::hess(size_type di, size_type dj) const + { + return _hess_val[di][dj]; + } + +} // namespace PRISMS #endif diff --git a/include/IntegrationTools/pfield/interpolation/Hexahedron.hh b/include/IntegrationTools/pfield/interpolation/Hexahedron.hh index 78118ffda..c87ab3aee 100644 --- a/include/IntegrationTools/pfield/interpolation/Hexahedron.hh +++ b/include/IntegrationTools/pfield/interpolation/Hexahedron.hh @@ -2,617 +2,657 @@ #ifndef Hexahedron_HH #define Hexahedron_HH +#include "../../pfunction/PFuncBase.hh" #include "../../pfunction/PSimpleBase.hh" #include "../../pfunction/PSimpleFunction.hh" -#include "../../pfunction/PFuncBase.hh" -#include "./Interpolator.hh" #include "../Coordinate.hh" +#include "./Interpolator.hh" namespace PRISMS { - class Hexahedron_f : public PSimpleBase< std::vector >, double> + class Hexahedron_f : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override { - double eval( const std::vector > &var) const - { - // var[0]: coordinate to be evaluated - // var[1]: nodal coordinate - // var[2]: element dimension - // var[3]: +/- 1 depending on which 'corner' of quad - // - // f = (1.0 - e0)*(1.0 - e1)*(1.0 - e2) - // e = var[3]*(var[0] - var[1])/var[2] - - return (1.0 - var[3][0]*(var[0][0] - var[1][0])/var[2][0])* - (1.0 - var[3][1]*(var[0][1] - var[1][1])/var[2][1])* - (1.0 - var[3][2]*(var[0][2] - var[1][2])/var[2][2]); - } + // var[0]: coordinate to be evaluated + // var[1]: nodal coordinate + // var[2]: element dimension + // var[3]: +/- 1 depending on which 'corner' of quad + // + // f = (1.0 - e0)*(1.0 - e1)*(1.0 - e2) + // e = var[3]*(var[0] - var[1])/var[2] + + return (1.0 - var[3][0] * (var[0][0] - var[1][0]) / var[2][0]) * + (1.0 - var[3][1] * (var[0][1] - var[1][1]) / var[2][1]) * + (1.0 - var[3][2] * (var[0][2] - var[1][2]) / var[2][2]); + } + + public: + Hexahedron_f() + { + this->_name = "Hexahedron_f"; + } - public: + Hexahedron_f * + clone() const override + { + return new Hexahedron_f(*this); + } + }; + + class Hexahedron_grad_0 : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return -var[3][0] * (1.0 - var[3][1] * (var[0][1] - var[1][1]) / var[2][1]) * + (1.0 - var[3][2] * (var[0][2] - var[1][2]) / var[2][2]) / var[2][0]; + } - Hexahedron_f() - { - this->_name = "Hexahedron_f"; - } + public: + Hexahedron_grad_0() + { + this->_name = "Hexahedron_grad_0"; + } - Hexahedron_f* clone() const - { - return new Hexahedron_f(*this); - } - }; - - class Hexahedron_grad_0 : public PSimpleBase< std::vector >, double> + Hexahedron_grad_0 * + clone() const override { - double eval( const std::vector > &var) const - { - return -var[3][0]*(1.0 - var[3][1]*(var[0][1] - var[1][1])/var[2][1])* - (1.0 - var[3][2]*(var[0][2] - var[1][2])/var[2][2])/var[2][0]; - } + return new Hexahedron_grad_0(*this); + } + }; + + class Hexahedron_grad_1 : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return -var[3][1] * (1.0 - var[3][0] * (var[0][0] - var[1][0]) / var[2][0]) * + (1.0 - var[3][2] * (var[0][2] - var[1][2]) / var[2][2]) / var[2][1]; + } - public: + public: + Hexahedron_grad_1() + { + this->_name = "Hexahedron_grad_1"; + } - Hexahedron_grad_0() - { - this->_name = "Hexahedron_grad_0"; - } + Hexahedron_grad_1 * + clone() const override + { + return new Hexahedron_grad_1(*this); + } + }; + + class Hexahedron_grad_2 : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return -var[3][2] * (1.0 - var[3][0] * (var[0][0] - var[1][0]) / var[2][0]) * + (1.0 - var[3][1] * (var[0][1] - var[1][1]) / var[2][1]) / var[2][2]; + } - Hexahedron_grad_0* clone() const - { - return new Hexahedron_grad_0(*this); - } - }; - - class Hexahedron_grad_1 : public PSimpleBase< std::vector >, double> + public: + Hexahedron_grad_2() { - double eval( const std::vector > &var) const - { - return -var[3][1]*(1.0 - var[3][0]*(var[0][0] - var[1][0])/var[2][0])* - (1.0 - var[3][2]*(var[0][2] - var[1][2])/var[2][2])/var[2][1]; - - } + this->_name = "Hexahedron_grad_2"; + } - public: + Hexahedron_grad_2 * + clone() const override + { + return new Hexahedron_grad_2(*this); + } + }; + + class Hexahedron_hess_0_0 + : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return 0.0; + } - Hexahedron_grad_1() - { - this->_name = "Hexahedron_grad_1"; - } + public: + Hexahedron_hess_0_0() + { + this->_name = "Hexahedron_hess_0_0"; + } - Hexahedron_grad_1* clone() const - { - return new Hexahedron_grad_1(*this); - } - }; - - class Hexahedron_grad_2 : public PSimpleBase< std::vector >, double> + Hexahedron_hess_0_0 * + clone() const override { - double eval( const std::vector > &var) const - { - return -var[3][2]*(1.0 - var[3][0]*(var[0][0] - var[1][0])/var[2][0])* - (1.0 - var[3][1]*(var[0][1] - var[1][1])/var[2][1])/var[2][2]; - - } + return new Hexahedron_hess_0_0(*this); + } + }; + + class Hexahedron_hess_0_1 + : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return var[3][0] * var[3][1] / var[2][0] / var[2][1]; + } - public: + public: + Hexahedron_hess_0_1() + { + this->_name = "Hexahedron_hess_0_1"; + } - Hexahedron_grad_2() - { - this->_name = "Hexahedron_grad_2"; - } + Hexahedron_hess_0_1 * + clone() const override + { + return new Hexahedron_hess_0_1(*this); + } + }; + + class Hexahedron_hess_0_2 + : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return var[3][0] * var[3][2] / var[2][0] / var[2][2]; + } - Hexahedron_grad_2* clone() const - { - return new Hexahedron_grad_2(*this); - } - }; - - class Hexahedron_hess_0_0 : public PSimpleBase< std::vector >, double> + public: + Hexahedron_hess_0_2() { - double eval( const std::vector > &var) const - { - return 0.0; - } + this->_name = "Hexahedron_hess_0_2"; + } - public: + Hexahedron_hess_0_2 * + clone() const override + { + return new Hexahedron_hess_0_2(*this); + } + }; + + class Hexahedron_hess_1_0 + : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return var[3][1] * var[3][0] / var[2][1] / var[2][0]; + } - Hexahedron_hess_0_0() - { - this->_name = "Hexahedron_hess_0_0"; - } + public: + Hexahedron_hess_1_0() + { + this->_name = "Hexahedron_hess_1_0"; + } - Hexahedron_hess_0_0* clone() const - { - return new Hexahedron_hess_0_0(*this); - } - }; - - class Hexahedron_hess_0_1 : public PSimpleBase< std::vector >, double> + Hexahedron_hess_1_0 * + clone() const override { - double eval( const std::vector > &var) const - { - return var[3][0]*var[3][1]/var[2][0]/var[2][1]; - } + return new Hexahedron_hess_1_0(*this); + } + }; + + class Hexahedron_hess_1_1 + : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return 0.0; + } - public: + public: + Hexahedron_hess_1_1() + { + this->_name = "Hexahedron_hess_1_1"; + } - Hexahedron_hess_0_1() - { - this->_name = "Hexahedron_hess_0_1"; - } + Hexahedron_hess_1_1 * + clone() const override + { + return new Hexahedron_hess_1_1(*this); + } + }; + + class Hexahedron_hess_1_2 + : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return var[3][1] * var[3][2] / var[2][1] / var[2][2]; + } - Hexahedron_hess_0_1* clone() const - { - return new Hexahedron_hess_0_1(*this); - } - }; - - class Hexahedron_hess_0_2 : public PSimpleBase< std::vector >, double> + public: + Hexahedron_hess_1_2() { - double eval( const std::vector > &var) const - { - return var[3][0]*var[3][2]/var[2][0]/var[2][2]; - } + this->_name = "Hexahedron_hess_1_2"; + } - public: + Hexahedron_hess_1_2 * + clone() const override + { + return new Hexahedron_hess_1_2(*this); + } + }; + + class Hexahedron_hess_2_0 + : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return var[3][2] * var[3][0] / var[2][2] / var[2][0]; + } - Hexahedron_hess_0_2() - { - this->_name = "Hexahedron_hess_0_2"; - } + public: + Hexahedron_hess_2_0() + { + this->_name = "Hexahedron_hess_2_0"; + } - Hexahedron_hess_0_2* clone() const - { - return new Hexahedron_hess_0_2(*this); - } - }; - - class Hexahedron_hess_1_0 : public PSimpleBase< std::vector >, double> + Hexahedron_hess_2_0 * + clone() const override { - double eval( const std::vector > &var) const - { - return var[3][1]*var[3][0]/var[2][1]/var[2][0]; - } + return new Hexahedron_hess_2_0(*this); + } + }; + + class Hexahedron_hess_2_1 + : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return var[3][2] * var[3][1] / var[2][2] / var[2][1]; + } - public: + public: + Hexahedron_hess_2_1() + { + this->_name = "Hexahedron_hess_2_1"; + } - Hexahedron_hess_1_0() - { - this->_name = "Hexahedron_hess_1_0"; - } + Hexahedron_hess_2_1 * + clone() const override + { + return new Hexahedron_hess_2_1(*this); + } + }; + + class Hexahedron_hess_2_2 + : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return 0.0; + } - Hexahedron_hess_1_0* clone() const - { - return new Hexahedron_hess_1_0(*this); - } - }; - - class Hexahedron_hess_1_1 : public PSimpleBase< std::vector >, double> + public: + Hexahedron_hess_2_2() { - double eval( const std::vector > &var) const - { - return 0.0; - } + this->_name = "Hexahedron_hess_2_2"; + } - public: + Hexahedron_hess_2_2 * + clone() const override + { + return new Hexahedron_hess_2_2(*this); + } + }; + + class Hexahedron : public PFuncBase>, double> + { + PSimpleBase>, double> *_val; + PSimpleBase>, double> **_grad_val; + PSimpleBase>, double> ***_hess_val; + + public: + Hexahedron() + : PFuncBase>, double>() + { + construct(); + } - Hexahedron_hess_1_1() - { - this->_name = "Hexahedron_hess_1_1"; - } + Hexahedron(const Hexahedron &RHS) + : PFuncBase>, double>(RHS) + { + construct(); + } - Hexahedron_hess_1_1* clone() const - { - return new Hexahedron_hess_1_1(*this); - } - }; - - class Hexahedron_hess_1_2 : public PSimpleBase< std::vector >, double> + ~Hexahedron() { - double eval( const std::vector > &var) const - { - return var[3][1]*var[3][2]/var[2][1]/var[2][2]; - } + delete _val; + + delete _grad_val[0]; + delete _grad_val[1]; + delete _grad_val[2]; + delete[] _grad_val; + + delete _hess_val[0][0]; + delete _hess_val[0][1]; + delete _hess_val[0][2]; + delete _hess_val[1][0]; + delete _hess_val[1][1]; + delete _hess_val[1][2]; + delete _hess_val[2][0]; + delete _hess_val[2][1]; + delete _hess_val[2][2]; + delete[] _hess_val[0]; + delete[] _hess_val[1]; + delete[] _hess_val[2]; + delete[] _hess_val; + } + + Hexahedron * + clone() const override + { + return new Hexahedron(*this); + } - public: + PSimpleFunction>, double> + simplefunction() const override + { + return PSimpleFunction>, double>(*_val); + } - Hexahedron_hess_1_2() - { - this->_name = "Hexahedron_hess_1_2"; - } + PSimpleFunction>, double> + grad_simplefunction(size_type di) const override + { + return PSimpleFunction>, double>(*_grad_val[di]); + } - Hexahedron_hess_1_2* clone() const - { - return new Hexahedron_hess_1_2(*this); - } - }; - - class Hexahedron_hess_2_0 : public PSimpleBase< std::vector >, double> + PSimpleFunction>, double> + hess_simplefunction(size_type di, size_type dj) const override { - double eval( const std::vector > &var) const - { - return var[3][2]*var[3][0]/var[2][2]/var[2][0]; - } + return PSimpleFunction>, double>( + *_hess_val[di][dj]); + } - public: + double + operator()(const std::vector> &var) override + { + return (*_val)(var); + } - Hexahedron_hess_2_0() - { - this->_name = "Hexahedron_hess_2_0"; - } + double + grad(const std::vector> &var, size_type di) override + { + return (*_grad_val[di])(var); + } - Hexahedron_hess_2_0* clone() const - { - return new Hexahedron_hess_2_0(*this); - } - }; - - class Hexahedron_hess_2_1 : public PSimpleBase< std::vector >, double> + double + hess(const std::vector> &var, + size_type di, + size_type dj) override { - double eval( const std::vector > &var) const - { - return var[3][2]*var[3][1]/var[2][2]/var[2][1]; - } + return (*_hess_val[di][dj])(var); + } - public: + void + eval(const std::vector> &var) override + { + (*_val)(var); + } - Hexahedron_hess_2_1() - { - this->_name = "Hexahedron_hess_2_1"; - } + void + eval_grad(const std::vector> &var) override + { + (*_grad_val[0])(var); + (*_grad_val[1])(var); + } - Hexahedron_hess_2_1* clone() const - { - return new Hexahedron_hess_2_1(*this); - } - }; - - class Hexahedron_hess_2_2 : public PSimpleBase< std::vector >, double> + void + eval_hess(const std::vector> &var) override { - double eval( const std::vector > &var) const - { - return 0.0; - } + (*_hess_val[0][0])(var); + (*_hess_val[0][1])(var); + (*_hess_val[1][0])(var); + (*_hess_val[1][1])(var); + } + + double + operator()() const override + { + return (*_val)(); + } - public: + double + grad(size_type di) const override + { + return (*_grad_val[di])(); + } - Hexahedron_hess_2_2() - { - this->_name = "Hexahedron_hess_2_2"; - } + double + hess(size_type di, size_type dj) const override + { + return (*_hess_val[di][dj])(); + } + + private: + void + construct() + { + this->_name = "Hexahedron"; + this->_var_name.clear(); + this->_var_name.push_back("r"); + this->_var_name.push_back("n"); + this->_var_name.push_back("h"); + this->_var_name.push_back("s"); + this->_var_description.clear(); + this->_var_description.push_back("Coordinate to be evaluated (Cartesian)"); + this->_var_description.push_back("Coordinate of node"); + this->_var_description.push_back("Coordinate containing element dimensions"); + this->_var_description.push_back( + "Coordinate containing +/- 1.0, depending on which corner of quad element"); + + _val = new Hexahedron_f(); + + _grad_val = new PSimpleBase>, double> *[3]; + _grad_val[0] = new Hexahedron_grad_0(); + _grad_val[1] = new Hexahedron_grad_1(); + _grad_val[2] = new Hexahedron_grad_2(); + + _hess_val = new PSimpleBase>, double> **[3]; + _hess_val[0] = new PSimpleBase>, double> *[3]; + _hess_val[1] = new PSimpleBase>, double> *[3]; + _hess_val[2] = new PSimpleBase>, double> *[3]; + _hess_val[0][0] = new Hexahedron_hess_0_0(); + _hess_val[0][1] = new Hexahedron_hess_0_1(); + _hess_val[0][2] = new Hexahedron_hess_0_2(); + _hess_val[1][0] = new Hexahedron_hess_1_0(); + _hess_val[1][1] = new Hexahedron_hess_1_1(); + _hess_val[1][2] = new Hexahedron_hess_1_2(); + _hess_val[2][0] = new Hexahedron_hess_2_0(); + _hess_val[2][1] = new Hexahedron_hess_2_1(); + _hess_val[2][2] = new Hexahedron_hess_2_2(); + } + }; + + /// A base class for interpolating functions + /// + template + class HexahedronValues : public Interpolator + { + //_var[0]: Coordinate _r; // coordinate to evaluate field at + //_var[1]: Coordinate _n; // coordinate of node + //_var[2]: Coordinate _h; // quad dimensions + //_var[3]: Coordinate _s; // +/- 1, depending on orientation of basis function + std::vector> _var; + + public: + typedef typename Interpolator::size_type size_type; + + // node_index: index of node in mesh + // node_index: index of element in mesh + // bfunc: PFuncBase, double>* + // node_coord: Coordinate of node + // dim: Coordinate containing x and y dimension of element + // element_node_index: 0 == bottom left, proceed counter clockwise to 3 == top left of + // element + + HexahedronValues(unsigned long int node_index, + unsigned long int element_index, + PFuncBase>, double> *bfunc, + const PRISMS::Coordinate<3> &node_coord, + const PRISMS::Coordinate<3> &dim, + int element_node_index) + : Interpolator(node_index, element_index, bfunc) + { + _var.resize(4); + + _var[1][0] = node_coord[0]; + _var[1][1] = node_coord[1]; + _var[1][2] = node_coord[2]; + + _var[2][0] = dim[0]; + _var[2][1] = dim[1]; + _var[2][2] = dim[2]; - Hexahedron_hess_2_2* clone() const + if (element_node_index == 0) { - return new Hexahedron_hess_2_2(*this); + _var[3][0] = 1.0; + _var[3][1] = 1.0; + _var[3][2] = 1.0; } - }; - - - class Hexahedron : public PFuncBase >, double> - { - PSimpleBase >, double>* _val; - PSimpleBase >, double>** _grad_val; - PSimpleBase >, double>*** _hess_val; - - public: - Hexahedron() + else if (element_node_index == 1) { - construct(); + _var[3][0] = -1.0; + _var[3][1] = 1.0; + _var[3][2] = 1.0; } - - Hexahedron( const Hexahedron &RHS) + else if (element_node_index == 2) { - construct(); + _var[3][0] = -1.0; + _var[3][1] = -1.0; + _var[3][2] = 1.0; } - - ~Hexahedron() + else if (element_node_index == 3) { - delete _val; - - delete _grad_val[0]; - delete _grad_val[1]; - delete _grad_val[2]; - delete [] _grad_val; - - delete _hess_val[0][0]; - delete _hess_val[0][1]; - delete _hess_val[0][2]; - delete _hess_val[1][0]; - delete _hess_val[1][1]; - delete _hess_val[1][2]; - delete _hess_val[2][0]; - delete _hess_val[2][1]; - delete _hess_val[2][2]; - delete [] _hess_val[0]; - delete [] _hess_val[1]; - delete [] _hess_val[2]; - delete [] _hess_val; + _var[3][0] = 1.0; + _var[3][1] = -1.0; + _var[3][2] = 1.0; } - - Hexahedron* clone() const + else if (element_node_index == 4) { - return new Hexahedron(*this); + _var[3][0] = 1.0; + _var[3][1] = 1.0; + _var[3][2] = -1.0; } - - PSimpleFunction< std::vector >, double> simplefunction() const + else if (element_node_index == 5) { - return PSimpleFunction< std::vector >, double>( *_val ); + _var[3][0] = -1.0; + _var[3][1] = 1.0; + _var[3][2] = -1.0; } - - PSimpleFunction< std::vector >, double> grad_simplefunction(size_type di) const + else if (element_node_index == 6) { - return PSimpleFunction< std::vector >, double>( *_grad_val[di] ); + _var[3][0] = -1.0; + _var[3][1] = -1.0; + _var[3][2] = -1.0; } - - PSimpleFunction< std::vector >, double> hess_simplefunction(size_type di, size_type dj) const + else if (element_node_index == 7) { - return PSimpleFunction< std::vector >, double>( *_hess_val[di][dj] ); + _var[3][0] = 1.0; + _var[3][1] = -1.0; + _var[3][2] = -1.0; } + } - double operator()(const std::vector > &var) - { - return (*_val)(var); - } + PRISMS::Coordinate<3> + min() const override + { + PRISMS::Coordinate<3> coord = _var[1]; - double grad(const std::vector > &var, size_type di) - { - return (*_grad_val[di])(var); - } + if (_var[3][0] == -1.0) + coord[0] -= _var[2][0]; + if (_var[3][1] == -1.0) + coord[1] -= _var[2][1]; + if (_var[3][2] == -1.0) + coord[2] -= _var[2][2]; - double hess(const std::vector > &var, size_type di, size_type dj) - { - return (*_hess_val[di][dj])(var); - } + return coord; + } - void eval(const std::vector > &var) - { - (*_val)(var); - } + PRISMS::Coordinate<3> + max() const override + { + PRISMS::Coordinate<3> coord = _var[1]; - void eval_grad(const std::vector > &var) - { - (*_grad_val[0])(var); - (*_grad_val[1])(var); - } + if (_var[3][0] == 1.0) + coord[0] += _var[2][0]; + if (_var[3][1] == 1.0) + coord[1] += _var[2][1]; + if (_var[3][2] == 1.0) + coord[2] += _var[2][2]; - void eval_hess(const std::vector > &var) - { - (*_hess_val[0][0])(var); - (*_hess_val[0][1])(var); - (*_hess_val[1][0])(var); - (*_hess_val[1][1])(var); - } + return coord; + } - double operator()() const - { - return (*_val)(); - } + bool + is_in_range(const Coordinate &coord) override + { + _var[0][0] = coord[0]; + _var[0][1] = coord[1]; + _var[0][2] = coord[2]; + double e; - double grad(size_type di) const + for (int i = 0; i < 3; i++) { - return (*_grad_val[di])(); - } + e = _var[3][i] * (_var[0][i] - _var[1][i]) / _var[2][i]; + if (e < 0.0 || e >= 1.0) + return false; - double hess(size_type di, size_type dj) const - { - return (*_hess_val[di][dj])(); - } - - private: - void construct() - { - this->_name = "Hexahedron"; - this->_var_name.clear(); - this->_var_name.push_back("r"); - this->_var_name.push_back("n"); - this->_var_name.push_back("h"); - this->_var_name.push_back("s"); - this->_var_description.clear(); - this->_var_description.push_back("Coordinate to be evaluated (Cartesian)"); - this->_var_description.push_back("Coordinate of node"); - this->_var_description.push_back("Coordinate containing element dimensions"); - this->_var_description.push_back("Coordinate containing +/- 1.0, depending on which corner of quad element"); - - _val = new Hexahedron_f(); - - _grad_val = new PSimpleBase< std::vector >, double>*[3]; - _grad_val[0] = new Hexahedron_grad_0(); - _grad_val[1] = new Hexahedron_grad_1(); - _grad_val[2] = new Hexahedron_grad_2(); - - _hess_val = new PSimpleBase< std::vector >, double>**[3]; - _hess_val[0] = new PSimpleBase< std::vector >, double>*[3]; - _hess_val[1] = new PSimpleBase< std::vector >, double>*[3]; - _hess_val[2] = new PSimpleBase< std::vector >, double>*[3]; - _hess_val[0][0] = new Hexahedron_hess_0_0(); - _hess_val[0][1] = new Hexahedron_hess_0_1(); - _hess_val[0][2] = new Hexahedron_hess_0_2(); - _hess_val[1][0] = new Hexahedron_hess_1_0(); - _hess_val[1][1] = new Hexahedron_hess_1_1(); - _hess_val[1][2] = new Hexahedron_hess_1_2(); - _hess_val[2][0] = new Hexahedron_hess_2_0(); - _hess_val[2][1] = new Hexahedron_hess_2_1(); - _hess_val[2][2] = new Hexahedron_hess_2_2(); - } - }; - - - /// A base class for interpolating functions - /// - template - class HexahedronValues : public Interpolator - { - //_var[0]: Coordinate _r; // coordinate to evaluate field at - //_var[1]: Coordinate _n; // coordinate of node - //_var[2]: Coordinate _h; // quad dimensions - //_var[3]: Coordinate _s; // +/- 1, depending on orientation of basis function - std::vector< PRISMS::Coordinate<3> > _var; - - public: - - typedef typename Interpolator::size_type size_type; - - // node_index: index of node in mesh - // node_index: index of element in mesh - // bfunc: PFuncBase, double>* - // node_coord: Coordinate of node - // dim: Coordinate containing x and y dimension of element - // element_node_index: 0 == bottom left, proceed counter clockwise to 3 == top left of element - - HexahedronValues( unsigned long int node_index, - unsigned long int element_index, - PFuncBase >, double>* bfunc, - const PRISMS::Coordinate<3> &node_coord, - const PRISMS::Coordinate<3> &dim, - int element_node_index) - : Interpolator(node_index, element_index, bfunc) - { - _var.resize(4); - - _var[1][0] = node_coord[0]; - _var[1][1] = node_coord[1]; - _var[1][2] = node_coord[2]; - - _var[2][0] = dim[0]; - _var[2][1] = dim[1]; - _var[2][2] = dim[2]; - - if( element_node_index == 0) - { - _var[3][0] = 1.0; - _var[3][1] = 1.0; - _var[3][2] = 1.0; - } - else if( element_node_index == 1) - { - _var[3][0] = -1.0; - _var[3][1] = 1.0; - _var[3][2] = 1.0; - } - else if( element_node_index == 2) - { - _var[3][0] = -1.0; - _var[3][1] = -1.0; - _var[3][2] = 1.0; - } - else if( element_node_index == 3) - { - _var[3][0] = 1.0; - _var[3][1] = -1.0; - _var[3][2] = 1.0; - } - else if( element_node_index == 4) - { - _var[3][0] = 1.0; - _var[3][1] = 1.0; - _var[3][2] = -1.0; - } - else if( element_node_index == 5) - { - _var[3][0] = -1.0; - _var[3][1] = 1.0; - _var[3][2] = -1.0; - } - else if( element_node_index == 6) - { - _var[3][0] = -1.0; - _var[3][1] = -1.0; - _var[3][2] = -1.0; - } - else if( element_node_index == 7) - { - _var[3][0] = 1.0; - _var[3][1] = -1.0; - _var[3][2] = -1.0; - } - } - - PRISMS::Coordinate<3> min() const - { - PRISMS::Coordinate<3> coord = _var[1]; - - if( _var[3][0] == -1.0) - coord[0] -= _var[2][0]; - if( _var[3][1] == -1.0) - coord[1] -= _var[2][1]; - if( _var[3][2] == -1.0) - coord[2] -= _var[2][2]; - - return coord; - } - - PRISMS::Coordinate<3> max() const - { - PRISMS::Coordinate<3> coord = _var[1]; - - if( _var[3][0] == 1.0) - coord[0] += _var[2][0]; - if( _var[3][1] == 1.0) - coord[1] += _var[2][1]; - if( _var[3][2] == 1.0) - coord[2] += _var[2][2]; - - return coord; - } - - bool is_in_range(const Coordinate &coord) - { - _var[0][0] = coord[0]; - _var[0][1] = coord[1]; - _var[0][2] = coord[2]; - double e; - - for( int i=0; i<3; i++) - { - e = _var[3][i]*(_var[0][i] - _var[1][i])/_var[2][i]; - if( e < 0.0 || e >= 1.0) - return false; - - //if( e == 0.0 && std::signbit(e)) - // return false; - } - - - - //std::cout << "e: " ; - //for( int i=0; i<2; i++) - //{ - // e = _var[3][i]*(_var[0][i] - _var[1][i])/_var[2][i]; - // std::cout << e << " "; - //} - //std::cout << std::endl; - - return true; - } - - // for the following, - // you are expected to KNOW that the coord is_in_range!!! - - double operator()(const Coordinate &coord) - { - _var[0][0] = coord[0]; - _var[0][1] = coord[1]; - _var[0][2] = coord[2]; - return (*this->_bfunc)(_var); - } - - double grad(const Coordinate &coord, size_type di) - { - _var[0][0] = coord[0]; - _var[0][1] = coord[1]; - _var[0][2] = coord[2]; - return (*this->_bfunc).grad(_var,di); - } - - double hess(const Coordinate &coord, size_type di, size_type dj) - { - _var[0][0] = coord[0]; - _var[0][1] = coord[1]; - _var[0][2] = coord[2]; - return (*this->_bfunc).hess(_var,di,dj); + // if( e == 0.0 && std::signbit(e)) + // return false; } - }; + // std::cout << "e: " ; + // for( int i=0; i<2; i++) + //{ + // e = _var[3][i]*(_var[0][i] - _var[1][i])/_var[2][i]; + // std::cout << e << " "; + // } + // std::cout << std::endl; + + return true; + } -} + // for the following, + // you are expected to KNOW that the coord is_in_range!!! + double + operator()(const Coordinate &coord) override + { + _var[0][0] = coord[0]; + _var[0][1] = coord[1]; + _var[0][2] = coord[2]; + return (*this->_bfunc)(_var); + } + + double + grad(const Coordinate &coord, size_type di) override + { + _var[0][0] = coord[0]; + _var[0][1] = coord[1]; + _var[0][2] = coord[2]; + return (*this->_bfunc).grad(_var, di); + } + + double + hess(const Coordinate &coord, size_type di, size_type dj) override + { + _var[0][0] = coord[0]; + _var[0][1] = coord[1]; + _var[0][2] = coord[2]; + return (*this->_bfunc).hess(_var, di, dj); + } + }; + +} // namespace PRISMS #endif diff --git a/include/IntegrationTools/pfield/interpolation/Interpolator.hh b/include/IntegrationTools/pfield/interpolation/Interpolator.hh index 325eebb87..8094d6d18 100644 --- a/include/IntegrationTools/pfield/interpolation/Interpolator.hh +++ b/include/IntegrationTools/pfield/interpolation/Interpolator.hh @@ -7,86 +7,96 @@ namespace PRISMS { - - /// A base class for interpolating functions - /// - template - class Interpolator + + /// A base class for interpolating functions + /// + template + class Interpolator + { + protected: + unsigned long int _node; // index of nodal value or control point + unsigned long int _element; // index of element + PFuncBase>, double> *_bfunc; // basis function to + // evaluate + + public: + typedef typename PFuncBase>, double>::size_type + size_type; + + Interpolator(unsigned long int node, + unsigned long int element, + PFuncBase>, double> *bfunc) + : _node(node) + , _element(element) + , _bfunc(bfunc) {}; + + virtual ~Interpolator() {}; + + unsigned long int + node() + { + return _node; + } + + unsigned long int + element() + { + return _element; + } + + virtual PRISMS::Coordinate + min() const + { + undefined("void min(Coordinate &coord) const"); + return PRISMS::Coordinate(); + } + + virtual PRISMS::Coordinate + max() const + { + undefined("void max(Coordinate &coord) const"); + return PRISMS::Coordinate(); + } + + virtual bool + is_in_range(const Coordinate &coord) + { + undefined("bool is_in_range(Coordinate coord) const"); + return false; + } + + virtual double + operator()(const Coordinate &coord) + { + undefined("double operator()(Coordinate coord)"); + return double(); + } + + virtual double + grad(const Coordinate &coord, size_type di) + { + undefined("double grad()(Coordinate coord, size_type di)"); + return double(); + } + + virtual double + hess(const Coordinate &coord, size_type di, size_type dj) + { + undefined("double hess()(Coordinate coord, size_type di, size_type dj)"); + return double(); + } + + private: + void + undefined(std::string fname) const { - protected: - - unsigned long int _node; //index of nodal value or control point - unsigned long int _element; //index of element - PFuncBase >, double>* _bfunc; // basis function to evaluate - - public: - - typedef typename PFuncBase >, double>::size_type size_type; - - Interpolator( unsigned long int node, unsigned long int element, PFuncBase >, double>* bfunc): - _node(node), _element(element), _bfunc(bfunc) - {}; - - virtual ~Interpolator() {}; - - unsigned long int node() - { - return _node; - } - - unsigned long int element() - { - return _element; - } - - virtual PRISMS::Coordinate min() const - { - undefined("void min(Coordinate &coord) const"); - return PRISMS::Coordinate(); - } - - virtual PRISMS::Coordinate max() const - { - undefined("void max(Coordinate &coord) const"); - return PRISMS::Coordinate(); - } - - virtual bool is_in_range(const Coordinate &coord) - { - undefined("bool is_in_range(Coordinate coord) const"); - return false; - } - - virtual double operator()(const Coordinate &coord) - { - undefined("double operator()(Coordinate coord)"); - return double(); - } - - virtual double grad(const Coordinate &coord, size_type di) - { - undefined("double grad()(Coordinate coord, size_type di)"); - return double(); - } - - virtual double hess(const Coordinate &coord, size_type di, size_type dj) - { - undefined("double hess()(Coordinate coord, size_type di, size_type dj)"); - return double(); - } - - private: - - void undefined(std::string fname) const - { - std::cout << "Error in Interpolator." << std::endl; - std::cout << " The member function '" << fname << "' has not been defined." << std::endl; - exit(1); - } - - }; - -} + std::cout << "Error in Interpolator." << std::endl; + std::cout << " The member function '" << fname << "' has not been defined." + << std::endl; + exit(1); + } + }; +} // namespace PRISMS #endif diff --git a/include/IntegrationTools/pfield/interpolation/Quad.hh b/include/IntegrationTools/pfield/interpolation/Quad.hh index 6dc808165..bc7ad7349 100644 --- a/include/IntegrationTools/pfield/interpolation/Quad.hh +++ b/include/IntegrationTools/pfield/interpolation/Quad.hh @@ -2,454 +2,482 @@ #ifndef Quad_HH #define Quad_HH +#include "../../pfunction/PFuncBase.hh" #include "../../pfunction/PSimpleBase.hh" #include "../../pfunction/PSimpleFunction.hh" -#include "../../pfunction/PFuncBase.hh" -#include "./Interpolator.hh" #include "../Coordinate.hh" +#include "./Interpolator.hh" namespace PRISMS { - class Quad_f : public PSimpleBase< std::vector >, double> + class Quad_f : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override { - double eval( const std::vector > &var) const - { - // var[0]: coordinate to be evaluated - // var[1]: nodal coordinate - // var[2]: element dimension - // var[3]: +/- 1 depending on which 'corner' of quad - // - // f = (1.0 - e0)*(1.0 - e1) - // e = var[3]*(var[0] - var[1])/var[2] - - return (1.0 - var[3][0]*(var[0][0] - var[1][0])/var[2][0])*(1.0 - var[3][1]*(var[0][1] - var[1][1])/var[2][1]); - } + // var[0]: coordinate to be evaluated + // var[1]: nodal coordinate + // var[2]: element dimension + // var[3]: +/- 1 depending on which 'corner' of quad + // + // f = (1.0 - e0)*(1.0 - e1) + // e = var[3]*(var[0] - var[1])/var[2] + + return (1.0 - var[3][0] * (var[0][0] - var[1][0]) / var[2][0]) * + (1.0 - var[3][1] * (var[0][1] - var[1][1]) / var[2][1]); + } + + public: + Quad_f() + { + this->_name = "Quad_f"; + } - public: + Quad_f * + clone() const override + { + return new Quad_f(*this); + } + }; + + class Quad_grad_0 : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return -var[3][0] * (1.0 - var[3][1] * (var[0][1] - var[1][1]) / var[2][1]) / + var[2][0]; + } - Quad_f() - { - this->_name = "Quad_f"; - } + public: + Quad_grad_0() + { + this->_name = "Quad_grad_0"; + } - Quad_f* clone() const - { - return new Quad_f(*this); - } - }; - - class Quad_grad_0 : public PSimpleBase< std::vector >, double> + Quad_grad_0 * + clone() const override { - double eval( const std::vector > &var) const - { - return -var[3][0]*(1.0 - var[3][1]*(var[0][1] - var[1][1])/var[2][1])/var[2][0]; - } + return new Quad_grad_0(*this); + } + }; + + class Quad_grad_1 : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return -var[3][1] * (1.0 - var[3][0] * (var[0][0] - var[1][0]) / var[2][0]) / + var[2][1]; + } - public: + public: + Quad_grad_1() + { + this->_name = "Quad_grad_1"; + } - Quad_grad_0() - { - this->_name = "Quad_grad_0"; - } + Quad_grad_1 * + clone() const override + { + return new Quad_grad_1(*this); + } + }; + + class Quad_hess_0_0 : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return 0.0; + } - Quad_grad_0* clone() const - { - return new Quad_grad_0(*this); - } - }; - - class Quad_grad_1 : public PSimpleBase< std::vector >, double> + public: + Quad_hess_0_0() { - double eval( const std::vector > &var) const - { - return -var[3][1]*(1.0 - var[3][0]*(var[0][0] - var[1][0])/var[2][0])/var[2][1]; - - } + this->_name = "Quad_hess_0_0"; + } - public: + Quad_hess_0_0 * + clone() const override + { + return new Quad_hess_0_0(*this); + } + }; + + class Quad_hess_0_1 : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return var[3][0] * var[3][1] / var[2][0] / var[2][1]; + } - Quad_grad_1() - { - this->_name = "Quad_grad_1"; - } + public: + Quad_hess_0_1() + { + this->_name = "Quad_hess_0_1"; + } - Quad_grad_1* clone() const - { - return new Quad_grad_1(*this); - } - }; - - class Quad_hess_0_0 : public PSimpleBase< std::vector >, double> + Quad_hess_0_1 * + clone() const override { - double eval( const std::vector > &var) const - { - return 0.0; - } + return new Quad_hess_0_1(*this); + } + }; + + class Quad_hess_1_0 : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return var[3][0] * var[3][1] / var[2][0] / var[2][1]; + } - public: + public: + Quad_hess_1_0() + { + this->_name = "Quad_hess_1_0"; + } - Quad_hess_0_0() - { - this->_name = "Quad_hess_0_0"; - } + Quad_hess_1_0 * + clone() const override + { + return new Quad_hess_1_0(*this); + } + }; + + class Quad_hess_1_1 : public PSimpleBase>, double> + { + double + eval(const std::vector> &var) const override + { + return 0.0; + } - Quad_hess_0_0* clone() const - { - return new Quad_hess_0_0(*this); - } - }; - - class Quad_hess_0_1 : public PSimpleBase< std::vector >, double> + public: + Quad_hess_1_1() { - double eval( const std::vector > &var) const - { - return var[3][0]*var[3][1]/var[2][0]/var[2][1]; - } + this->_name = "Quad_hess_1_1"; + } - public: + Quad_hess_1_1 * + clone() const override + { + return new Quad_hess_1_1(*this); + } + }; - Quad_hess_0_1() - { - this->_name = "Quad_hess_0_1"; - } + class Quad : public PFuncBase>, double> + { + PSimpleBase>, double> *_val; + PSimpleBase>, double> **_grad_val; + PSimpleBase>, double> ***_hess_val; - Quad_hess_0_1* clone() const - { - return new Quad_hess_0_1(*this); - } - }; - - class Quad_hess_1_0 : public PSimpleBase< std::vector >, double> + public: + typedef PFuncBase>, double>::size_type size_type; + + Quad() + : PFuncBase>, double>() { - double eval( const std::vector > &var) const - { - return var[3][0]*var[3][1]/var[2][0]/var[2][1]; - } + construct(); + } - public: + Quad(const Quad &RHS) + : PFuncBase>, double>(RHS) + { + construct(); + } - Quad_hess_1_0() - { - this->_name = "Quad_hess_1_0"; - } + ~Quad() + { + delete _val; + + delete _grad_val[0]; + delete _grad_val[1]; + delete[] _grad_val; + + delete _hess_val[0][0]; + delete _hess_val[0][1]; + delete _hess_val[1][0]; + delete _hess_val[1][1]; + delete[] _hess_val[0]; + delete[] _hess_val[1]; + delete[] _hess_val; + } + + Quad * + clone() const override + { + return new Quad(*this); + } - Quad_hess_1_0* clone() const - { - return new Quad_hess_1_0(*this); - } - }; - - class Quad_hess_1_1 : public PSimpleBase< std::vector >, double> + PSimpleFunction>, double> + simplefunction() const override { - double eval( const std::vector > &var) const - { - return 0.0; - } + return PSimpleFunction>, double>(*_val); + } - public: + PSimpleFunction>, double> + grad_simplefunction(size_type di) const override + { + return PSimpleFunction>, double>(*_grad_val[di]); + } - Quad_hess_1_1() - { - this->_name = "Quad_hess_1_1"; - } + PSimpleFunction>, double> + hess_simplefunction(size_type di, size_type dj) const override + { + return PSimpleFunction>, double>( + *_hess_val[di][dj]); + } - Quad_hess_1_1* clone() const - { - return new Quad_hess_1_1(*this); - } - }; - - - class Quad : public PFuncBase >, double> - { - PSimpleBase >, double>* _val; - PSimpleBase >, double>** _grad_val; - PSimpleBase >, double>*** _hess_val; - - public: - - typedef PFuncBase >, double>::size_type size_type; - - Quad() - { - construct(); - } - - Quad( const Quad &RHS) - { - construct(); - } - - ~Quad() - { - delete _val; - - delete _grad_val[0]; - delete _grad_val[1]; - delete [] _grad_val; - - delete _hess_val[0][0]; - delete _hess_val[0][1]; - delete _hess_val[1][0]; - delete _hess_val[1][1]; - delete [] _hess_val[0]; - delete [] _hess_val[1]; - delete [] _hess_val; - } - - Quad* clone() const - { - return new Quad(*this); - } + double + operator()(const std::vector> &var) override + { + return (*_val)(var); + } - PSimpleFunction< std::vector >, double> simplefunction() const - { - return PSimpleFunction< std::vector >, double>( *_val ); - } + double + grad(const std::vector> &var, size_type di) override + { + return (*_grad_val[di])(var); + } - PSimpleFunction< std::vector >, double> grad_simplefunction(size_type di) const - { - return PSimpleFunction< std::vector >, double>( *_grad_val[di] ); - } + double + hess(const std::vector> &var, + size_type di, + size_type dj) override + { + return (*_hess_val[di][dj])(var); + } - PSimpleFunction< std::vector >, double> hess_simplefunction(size_type di, size_type dj) const - { - return PSimpleFunction< std::vector >, double>( *_hess_val[di][dj] ); - } + void + eval(const std::vector> &var) override + { + (*_val)(var); + } - double operator()(const std::vector > &var) - { - return (*_val)(var); - } + void + eval_grad(const std::vector> &var) override + { + (*_grad_val[0])(var); + (*_grad_val[1])(var); + } - double grad(const std::vector > &var, size_type di) - { - return (*_grad_val[di])(var); - } + void + eval_hess(const std::vector> &var) override + { + (*_hess_val[0][0])(var); + (*_hess_val[0][1])(var); + (*_hess_val[1][0])(var); + (*_hess_val[1][1])(var); + } + + double + operator()() const override + { + return (*_val)(); + } - double hess(const std::vector > &var, size_type di, size_type dj) - { - return (*_hess_val[di][dj])(var); - } + double + grad(size_type di) const override + { + return (*_grad_val[di])(); + } - void eval(const std::vector > &var) - { - (*_val)(var); - } + double + hess(size_type di, size_type dj) const override + { + return (*_hess_val[di][dj])(); + } - void eval_grad(const std::vector > &var) - { - (*_grad_val[0])(var); - (*_grad_val[1])(var); - } + private: + void + construct() + { + this->_name = "Quad"; + this->_var_name.clear(); + this->_var_name.push_back("r"); + this->_var_name.push_back("n"); + this->_var_name.push_back("h"); + this->_var_name.push_back("s"); + this->_var_description.clear(); + this->_var_description.push_back("Coordinate to be evaluated (Cartesian)"); + this->_var_description.push_back("Coordinate of node"); + this->_var_description.push_back("Coordinate containing element dimensions"); + this->_var_description.push_back( + "Coordinate containing +/- 1.0, depending on which corner of quad element"); + + _val = new Quad_f(); + + _grad_val = new PSimpleBase>, double> *[2]; + _grad_val[0] = new Quad_grad_0(); + _grad_val[1] = new Quad_grad_1(); + + _hess_val = new PSimpleBase>, double> **[2]; + _hess_val[0] = new PSimpleBase>, double> *[2]; + _hess_val[1] = new PSimpleBase>, double> *[2]; + _hess_val[0][0] = new Quad_hess_0_0(); + _hess_val[0][1] = new Quad_hess_0_1(); + _hess_val[1][0] = new Quad_hess_1_0(); + _hess_val[1][1] = new Quad_hess_1_1(); + } + }; + + /// A base class for interpolating functions + /// + template + class QuadValues : public Interpolator + { + //_var[0]: Coordinate _r; // coordinate to evaluate field at + //_var[1]: Coordinate _n; // coordinate of node + //_var[2]: Coordinate _h; // quad dimensions + //_var[3]: Coordinate _s; // +/- 1, depending on orientation of basis function + std::vector> _var; + + public: + typedef typename Interpolator::size_type size_type; + + // node_index: index of node in mesh + // node_index: index of element in mesh + // bfunc: PFuncBase, double>* + // node_coord: Coordinate of node + // dim: Coordinate containing x and y dimension of element + // element_node_index: 0 == bottom left, proceed counter clockwise to 3 == top left of + // element + + QuadValues(unsigned long int node_index, + unsigned long int element_index, + PFuncBase>, double> *bfunc, + const PRISMS::Coordinate<2> &node_coord, + const PRISMS::Coordinate<2> &dim, + int element_node_index) + : Interpolator(node_index, element_index, bfunc) + { + _var.resize(4); - void eval_hess(const std::vector > &var) - { - (*_hess_val[0][0])(var); - (*_hess_val[0][1])(var); - (*_hess_val[1][0])(var); - (*_hess_val[1][1])(var); - } + _var[1][0] = node_coord[0]; + _var[1][1] = node_coord[1]; - double operator()() const - { - return (*_val)(); - } + _var[2][0] = dim[0]; + _var[2][1] = dim[1]; - double grad(size_type di) const + if (element_node_index == 0) { - return (*_grad_val[di])(); - } + //_var[1][0] = node_coord[0]; + //_var[1][1] = node_coord[1]; - double hess(size_type di, size_type dj) const - { - return (*_hess_val[di][dj])(); + _var[3][0] = 1.0; + _var[3][1] = 1.0; } - - private: - void construct() + else if (element_node_index == 1) { - this->_name = "Quad"; - this->_var_name.clear(); - this->_var_name.push_back("r"); - this->_var_name.push_back("n"); - this->_var_name.push_back("h"); - this->_var_name.push_back("s"); - this->_var_description.clear(); - this->_var_description.push_back("Coordinate to be evaluated (Cartesian)"); - this->_var_description.push_back("Coordinate of node"); - this->_var_description.push_back("Coordinate containing element dimensions"); - this->_var_description.push_back("Coordinate containing +/- 1.0, depending on which corner of quad element"); - - _val = new Quad_f(); - - _grad_val = new PSimpleBase< std::vector >, double>*[2]; - _grad_val[0] = new Quad_grad_0(); - _grad_val[1] = new Quad_grad_1(); - - _hess_val = new PSimpleBase< std::vector >, double>**[2]; - _hess_val[0] = new PSimpleBase< std::vector >, double>*[2]; - _hess_val[1] = new PSimpleBase< std::vector >, double>*[2]; - _hess_val[0][0] = new Quad_hess_0_0(); - _hess_val[0][1] = new Quad_hess_0_1(); - _hess_val[1][0] = new Quad_hess_1_0(); - _hess_val[1][1] = new Quad_hess_1_1(); - } - }; - - - /// A base class for interpolating functions - /// - template - class QuadValues : public Interpolator - { - //_var[0]: Coordinate _r; // coordinate to evaluate field at - //_var[1]: Coordinate _n; // coordinate of node - //_var[2]: Coordinate _h; // quad dimensions - //_var[3]: Coordinate _s; // +/- 1, depending on orientation of basis function - std::vector< PRISMS::Coordinate<2> > _var; - - public: - - typedef typename Interpolator::size_type size_type; - - // node_index: index of node in mesh - // node_index: index of element in mesh - // bfunc: PFuncBase, double>* - // node_coord: Coordinate of node - // dim: Coordinate containing x and y dimension of element - // element_node_index: 0 == bottom left, proceed counter clockwise to 3 == top left of element - - QuadValues( unsigned long int node_index, - unsigned long int element_index, - PFuncBase >, double>* bfunc, - const PRISMS::Coordinate<2> &node_coord, - const PRISMS::Coordinate<2> &dim, - int element_node_index) - : Interpolator(node_index, element_index, bfunc) - { - _var.resize(4); - - _var[1][0] = node_coord[0]; - _var[1][1] = node_coord[1]; - - _var[2][0] = dim[0]; - _var[2][1] = dim[1]; - - if( element_node_index == 0) - { - //_var[1][0] = node_coord[0]; - //_var[1][1] = node_coord[1]; - - _var[3][0] = 1.0; - _var[3][1] = 1.0; - } - else if( element_node_index == 1) - { - //_var[1][0] = node_coord[0] + _var[2][0]; - //_var[1][1] = node_coord[1]; - - _var[3][0] = -1.0; - _var[3][1] = 1.0; - } - else if( element_node_index == 2) - { - //_var[1][0] = node_coord[0] + _var[2][0]; - //_var[1][1] = node_coord[1] + _var[2][1]; - - _var[3][0] = -1.0; - _var[3][1] = -1.0; - } - else if( element_node_index == 3) - { - //_var[1][0] = node_coord[0]; - //_var[1][1] = node_coord[1] + _var[2][1]; - - _var[3][0] = 1.0; - _var[3][1] = -1.0; - } - } - - PRISMS::Coordinate<2> min() const - { - PRISMS::Coordinate<2> coord = _var[1]; - - if( _var[3][0] == -1.0) - coord[0] -= _var[2][0]; - if( _var[3][1] == -1.0) - coord[1] -= _var[2][1]; - - return coord; - } - - PRISMS::Coordinate<2> max() const - { - PRISMS::Coordinate<2> coord = _var[1]; - - if( _var[3][0] == 1.0) - coord[0] += _var[2][0]; - if( _var[3][1] == 1.0) - coord[1] += _var[2][1]; - - return coord; - } - - bool is_in_range(const Coordinate &coord) - { - _var[0][0] = coord[0]; - _var[0][1] = coord[1]; - double e; - - for( int i=0; i<2; i++) - { - e = _var[3][i]*(_var[0][i] - _var[1][i])/_var[2][i]; - if( e < 0.0 || e >= 1.0) - return false; - - //if( e == 0.0 && std::signbit(e)) - // return false; - } - - - - //std::cout << "e: " ; - //for( int i=0; i<2; i++) - //{ - // e = _var[3][i]*(_var[0][i] - _var[1][i])/_var[2][i]; - // std::cout << e << " "; - //} - //std::cout << std::endl; - - return true; + //_var[1][0] = node_coord[0] + _var[2][0]; + //_var[1][1] = node_coord[1]; + + _var[3][0] = -1.0; + _var[3][1] = 1.0; } - - // for the following, - // you are expected to KNOW that the coord is_in_range!!! - - double operator()(const Coordinate &coord) + else if (element_node_index == 2) { - _var[0][0] = coord[0]; - _var[0][1] = coord[1]; - return (*this->_bfunc)(_var); + //_var[1][0] = node_coord[0] + _var[2][0]; + //_var[1][1] = node_coord[1] + _var[2][1]; + + _var[3][0] = -1.0; + _var[3][1] = -1.0; } - - double grad(const Coordinate &coord, size_type di) + else if (element_node_index == 3) { - _var[0][0] = coord[0]; - _var[0][1] = coord[1]; - return (*this->_bfunc).grad(_var,di); + //_var[1][0] = node_coord[0]; + //_var[1][1] = node_coord[1] + _var[2][1]; + + _var[3][0] = 1.0; + _var[3][1] = -1.0; } - - double hess(const Coordinate &coord, size_type di, size_type dj) + } + + PRISMS::Coordinate<2> + min() const override + { + PRISMS::Coordinate<2> coord = _var[1]; + + if (_var[3][0] == -1.0) + coord[0] -= _var[2][0]; + if (_var[3][1] == -1.0) + coord[1] -= _var[2][1]; + + return coord; + } + + PRISMS::Coordinate<2> + max() const override + { + PRISMS::Coordinate<2> coord = _var[1]; + + if (_var[3][0] == 1.0) + coord[0] += _var[2][0]; + if (_var[3][1] == 1.0) + coord[1] += _var[2][1]; + + return coord; + } + + bool + is_in_range(const Coordinate &coord) override + { + _var[0][0] = coord[0]; + _var[0][1] = coord[1]; + double e; + + for (int i = 0; i < 2; i++) { - _var[0][0] = coord[0]; - _var[0][1] = coord[1]; - return (*this->_bfunc).hess(_var,di,dj); + e = _var[3][i] * (_var[0][i] - _var[1][i]) / _var[2][i]; + if (e < 0.0 || e >= 1.0) + return false; + + // if( e == 0.0 && std::signbit(e)) + // return false; } - }; + // std::cout << "e: " ; + // for( int i=0; i<2; i++) + //{ + // e = _var[3][i]*(_var[0][i] - _var[1][i])/_var[2][i]; + // std::cout << e << " "; + // } + // std::cout << std::endl; + + return true; + } + + // for the following, + // you are expected to KNOW that the coord is_in_range!!! + + double + operator()(const Coordinate &coord) override + { + _var[0][0] = coord[0]; + _var[0][1] = coord[1]; + return (*this->_bfunc)(_var); + } + + double + grad(const Coordinate &coord, size_type di) override + { + _var[0][0] = coord[0]; + _var[0][1] = coord[1]; + return (*this->_bfunc).grad(_var, di); + } -} + double + hess(const Coordinate &coord, size_type di, size_type dj) override + { + _var[0][0] = coord[0]; + _var[0][1] = coord[1]; + return (*this->_bfunc).hess(_var, di, dj); + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/pfunction/PBasisSet.hh b/include/IntegrationTools/pfunction/PBasisSet.hh index 54c13495c..e48a849b9 100644 --- a/include/IntegrationTools/pfunction/PBasisSet.hh +++ b/include/IntegrationTools/pfunction/PBasisSet.hh @@ -2,191 +2,213 @@ #ifndef PBasisSet_HH #define PBasisSet_HH -#include -#include -#include -#include - -#include "./PFunction.hh" #include "./PBasisSetBase.hh" +#include "./PFunction.hh" +#include +#include +#include +#include namespace PRISMS { - /// Evaluate basis functions and their derivatives. Store and access the results. - /// - template< class InType, class OutType> - class PBasisSet - { - public: - - - std::string name() const - { - return (*ptr).name(); - } - std::string description() const - { - return (*ptr)._description(); - } - int size() const - { - return (*ptr).size(); - } - - - virtual void resize( int N) - { - (*ptr).resize(N); - } - - virtual int max_size() - { - // default to (essentially) no limit - return (*ptr).max_size(); - } - - - // Output PFunction for individual basis functions: - - - PFunction basis_function(int term) - { - return (*ptr).basis_function(term); - }; - - - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value - OutType operator()(int term, const InType &var) - { - return (*ptr)(term,var); - } - OutType grad(int term, const InType &var) - { - return (*ptr).grad(term, var); - } - OutType hess(int term, const InType &var) - { - return (*ptr).hess(term, var); - } - - - // ---------------------------------------------------------- - // Use these functions to evaluate several values, then use 'get' methods to access results - - // By default, evaluate each individual term one-by-one. - // These are virtual so derived classes may implement more efficient methods. - // Returns vector containing results - virtual const std::vector& eval(const InType &var) - { - return (*ptr).eval(var); - } - virtual const std::vector& eval_grad(const InType &var) - { - return (*ptr).eval_grad(var); - } - virtual const std::vector& eval_hess(const InType &var) - { - return (*ptr).eval_hess(var); - } + /// Evaluate basis functions and their derivatives. Store and access the results. + /// + template + class PBasisSet + { + public: + std::string + name() const + { + return (*ptr).name(); + } - // Getters for individual terms - OutType operator()(int term) const - { - return (*ptr)(term); - } - OutType grad(int term) const - { - return (*ptr).grad(term); - } - OutType hess(int term) const - { - return (*ptr).hess(term); - } - - // Getters returning vector containing all terms - const std::vector& operator()() const - { - return (*ptr)(); - } - const std::vector& grad() const - { - return (*ptr).grad(); - } - const std::vector& hess() const - { - return (*ptr).hess(); - } - - // PFunction unique members ------------------------------------------ + std::string + description() const + { + return (*ptr)._description(); + } - PBasisSet &operator=(const PBasisSet &RHS) - { - if(ptr != NULL) - delete ptr; - ptr = RHS.ptr->clone(); - return *this; - } + int + size() const + { + return (*ptr).size(); + } - template PBasisSet &operator=(const T &RHS) - { - RHS.is_derived_from_PBasisSetBase(); + virtual void + resize(int N) + { + (*ptr).resize(N); + } - if(ptr != NULL) - delete ptr; - ptr = RHS.clone(); - return *this; - } + virtual int + max_size() + { + // default to (essentially) no limit + return (*ptr).max_size(); + } - // If you use this, PBasisSet becomes the 'owner' of the function RHS points to - // and it will delete it - PBasisSet &set( PBasisSet *RHS) - { - if(RHS == NULL) - { - std::cout << "Error in PBasisSet::set. RHS == NULL." << std::endl; - exit(1); - } - if(ptr != NULL) - delete ptr; - ptr = RHS; - return *this; - } + // Output PFunction for individual basis functions: - PBasisSet() - { - ptr = NULL; - } + PFunction + basis_function(int term) + { + return (*ptr).basis_function(term); + }; - PBasisSet(const PBasisSet &RHS) - { - if( RHS.ptr != NULL) - ptr = RHS.ptr->clone(); - else - ptr = NULL; - } - - template PBasisSet(const T &RHS) - { - RHS.is_derived_from_PBasisSetBase(); + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + OutType + operator()(int term, const InType &var) + { + return (*ptr)(term, var); + } - ptr = RHS.clone(); - } + OutType + grad(int term, const InType &var) + { + return (*ptr).grad(term, var); + } + + OutType + hess(int term, const InType &var) + { + return (*ptr).hess(term, var); + } + + // ---------------------------------------------------------- + // Use these functions to evaluate several values, then use 'get' methods to access + // results + + // By default, evaluate each individual term one-by-one. + // These are virtual so derived classes may implement more efficient methods. + // Returns vector containing results + virtual const std::vector & + eval(const InType &var) + { + return (*ptr).eval(var); + } + + virtual const std::vector & + eval_grad(const InType &var) + { + return (*ptr).eval_grad(var); + } + + virtual const std::vector & + eval_hess(const InType &var) + { + return (*ptr).eval_hess(var); + } + + // Getters for individual terms + OutType + operator()(int term) const + { + return (*ptr)(term); + } + + OutType + grad(int term) const + { + return (*ptr).grad(term); + } + + OutType + hess(int term) const + { + return (*ptr).hess(term); + } + + // Getters returning vector containing all terms + const std::vector & + operator()() const + { + return (*ptr)(); + } + + const std::vector & + grad() const + { + return (*ptr).grad(); + } + + const std::vector & + hess() const + { + return (*ptr).hess(); + } - ~PBasisSet() + // PFunction unique members ------------------------------------------ + + PBasisSet & + operator=(const PBasisSet &RHS) + { + if (ptr != NULL) + delete ptr; + ptr = RHS.ptr->clone(); + return *this; + } + + template + PBasisSet & + operator=(const T &RHS) + { + RHS.is_derived_from_PBasisSetBase(); + + if (ptr != NULL) + delete ptr; + ptr = RHS.clone(); + return *this; + } + + // If you use this, PBasisSet becomes the 'owner' of the function RHS points to + // and it will delete it + PBasisSet & + set(PBasisSet *RHS) + { + if (RHS == NULL) { - if(ptr != NULL) - delete ptr; + std::cout << "Error in PBasisSet::set. RHS == NULL." << std::endl; + exit(1); } + if (ptr != NULL) + delete ptr; + ptr = RHS; + return *this; + } + PBasisSet() + { + ptr = NULL; + } - private: - - PBasisSetBase *ptr; - - }; + PBasisSet(const PBasisSet &RHS) + { + if (RHS.ptr != NULL) + ptr = RHS.ptr->clone(); + else + ptr = NULL; + } + + template + PBasisSet(const T &RHS) + { + RHS.is_derived_from_PBasisSetBase(); + + ptr = RHS.clone(); + } + + ~PBasisSet() + { + if (ptr != NULL) + delete ptr; + } -} + private: + PBasisSetBase *ptr; + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/pfunction/PBasisSetBase.hh b/include/IntegrationTools/pfunction/PBasisSetBase.hh index c4ef5c3f6..bf96d42da 100644 --- a/include/IntegrationTools/pfunction/PBasisSetBase.hh +++ b/include/IntegrationTools/pfunction/PBasisSetBase.hh @@ -2,182 +2,213 @@ #ifndef PBasisSetBase_HH #define PBasisSetBase_HH -#include -#include -#include -#include - #include "./PFunction.hh" +#include +#include +#include +#include namespace PRISMS { - /// Evaluate basis functions and their derivatives. Store and access the results. - /// - template< class InType, class OutType> - class PBasisSetBase - { - public: - - typedef typename std::vector::size_type size_type; - - std::string _name; - std::string _description; - - std::vector _val; - std::vector _grad_val; - std::vector _hess_val; - - std::string name() const - { - return _name; - } - std::string description() const - { - return _description; - } - size_type size() const - { - return _val.size(); - } - - PBasisSetBase( size_type N) - { - resize(N); - } - - void is_derived_from_PBasisSetBase() const - { - return; - } - - virtual void resize( size_type N) - { - _val.resize(N); - _grad_val.resize(N); - _hess_val.resize(N); - } - - virtual ~PBasisSetBase() - { - - } - - virtual size_type max_size() const - { - // default to (essentially) no limit - return std::numeric_limits::max(); - } - - virtual PBasisSetBase* clone() const - { - return new PBasisSetBase(*this); - } - - virtual PFunction basis_function(size_type term) const - { - undefined("const PFunction& basis_function(size_type term) const"); - return PFunction(); - } - - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value - OutType operator()(size_type term, const InType &var) - { - return _val[term] = eval(term, var); - } - OutType grad(size_type term, const InType &var) - { - return _grad_val[term] = eval_grad(term, var); - } - OutType hess(size_type term, const InType &var) - { - return _hess_val[term] = eval_hess(term, var); - } - - - // ---------------------------------------------------------- - // Use these functions to evaluate several values, then use 'get' methods to access results - - // By default, evaluate each individual term one-by-one. - // These are virtual so derived classes may implement more efficient methods. - // Returns vector containing results - virtual const std::vector& eval(const InType &var) - { - for( size_type i=0; i<_val.size(); i++) - (*this)(i,var); - return _val; - } - virtual const std::vector& eval_grad(const InType &var) - { - for( size_type i=0; i<_val.size(); i++) - (*this).grad(i,var); - return _grad_val; - } - virtual const std::vector& eval_hess(const InType &var) - { - for( size_type i=0; i<_val.size(); i++) - (*this).hess(i,var); - return _hess_val; - } - - // Getters for individual terms - OutType operator()(size_type term) const - { - return _val[term]; - } - OutType grad(size_type term) const - { - return _grad_val[term]; - } - OutType hess(size_type term) const - { - return _hess_val[term]; - } - - // Getters returning vector containing all terms - const std::vector& operator()() const - { - return _val; - } - const std::vector& grad() const - { - return _grad_val; - } - const std::vector& hess() const - { - return _hess_val; - } - - private: - - /// ---------------------------------------------------------- - /// !!! Derived classes must define these functions !!! - /// Usually this is done using PBasisSetWriter - virtual OutType eval(size_type term, const InType &var) - { - undefined("OutType PBasisSetBase::eval(size_type term, const InType &var)"); - return OutType(); - } - virtual OutType eval_grad(size_type term, const InType &var) - { - undefined("OutType PBasisSetBase::eval_grad(size_type term, const InType &var)"); - return OutType(); - } - virtual OutType eval_hess(size_type term, const InType &var) - { - undefined("OutType PBasisSetBase::eval_hess(size_type term, const InType &var)"); - return OutType(); - } - - void undefined(std::string fname) const - { - std::cout << "Error. In PBasisSetBase '" << _name << "'." << std::endl; - std::cout << " The member function '" << fname << "' has not been defined." << std::endl; - exit(1); - } - }; - -} + /// Evaluate basis functions and their derivatives. Store and access the results. + /// + template + class PBasisSetBase + { + public: + typedef typename std::vector::size_type size_type; + + std::string _name; + std::string _description; + + std::vector _val; + std::vector _grad_val; + std::vector _hess_val; + + std::string + name() const + { + return _name; + } + + std::string + description() const + { + return _description; + } + + size_type + size() const + { + return _val.size(); + } + + PBasisSetBase(size_type N) + { + resize(N); + } + + void + is_derived_from_PBasisSetBase() const + { + return; + } + + virtual void + resize(size_type N) + { + _val.resize(N); + _grad_val.resize(N); + _hess_val.resize(N); + } + + virtual ~PBasisSetBase() + {} + + virtual size_type + max_size() const + { + // default to (essentially) no limit + return std::numeric_limits::max(); + } + + virtual PBasisSetBase * + clone() const + { + return new PBasisSetBase(*this); + } + + virtual PFunction + basis_function(size_type term) const + { + undefined("const PFunction& basis_function(size_type term) const"); + return PFunction(); + } + + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + OutType + operator()(size_type term, const InType &var) + { + return _val[term] = eval(term, var); + } + + OutType + grad(size_type term, const InType &var) + { + return _grad_val[term] = eval_grad(term, var); + } + + OutType + hess(size_type term, const InType &var) + { + return _hess_val[term] = eval_hess(term, var); + } + + // ---------------------------------------------------------- + // Use these functions to evaluate several values, then use 'get' methods to access + // results + + // By default, evaluate each individual term one-by-one. + // These are virtual so derived classes may implement more efficient methods. + // Returns vector containing results + virtual const std::vector & + eval(const InType &var) + { + for (size_type i = 0; i < _val.size(); i++) + (*this)(i, var); + return _val; + } + + virtual const std::vector & + eval_grad(const InType &var) + { + for (size_type i = 0; i < _val.size(); i++) + (*this).grad(i, var); + return _grad_val; + } + + virtual const std::vector & + eval_hess(const InType &var) + { + for (size_type i = 0; i < _val.size(); i++) + (*this).hess(i, var); + return _hess_val; + } + + // Getters for individual terms + OutType + operator()(size_type term) const + { + return _val[term]; + } + + OutType + grad(size_type term) const + { + return _grad_val[term]; + } + + OutType + hess(size_type term) const + { + return _hess_val[term]; + } + + // Getters returning vector containing all terms + const std::vector & + operator()() const + { + return _val; + } + + const std::vector & + grad() const + { + return _grad_val; + } + + const std::vector & + hess() const + { + return _hess_val; + } + + private: + /// ---------------------------------------------------------- + /// !!! Derived classes must define these functions !!! + /// Usually this is done using PBasisSetWriter + virtual OutType + eval(size_type term, const InType &var) + { + undefined("OutType PBasisSetBase::eval(size_type term, const InType &var)"); + return OutType(); + } + + virtual OutType + eval_grad(size_type term, const InType &var) + { + undefined("OutType PBasisSetBase::eval_grad(size_type term, const InType &var)"); + return OutType(); + } + + virtual OutType + eval_hess(size_type term, const InType &var) + { + undefined("OutType PBasisSetBase::eval_hess(size_type term, const InType &var)"); + return OutType(); + } + + void + undefined(std::string fname) const + { + std::cout << "Error. In PBasisSetBase '" << _name << "'." << std::endl; + std::cout << " The member function '" << fname << "' has not been defined." + << std::endl; + exit(1); + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/pfunction/PFlexFunction.hh b/include/IntegrationTools/pfunction/PFlexFunction.hh index 4da065846..f10fcf229 100644 --- a/include/IntegrationTools/pfunction/PFlexFunction.hh +++ b/include/IntegrationTools/pfunction/PFlexFunction.hh @@ -2,203 +2,219 @@ #ifndef PFlexFunction_HH #define PFlexFunction_HH -#include -#include -#include -#include - #include "./PFuncBase.hh" #include "./PSimpleFunction.hh" +#include +#include +#include +#include namespace PRISMS { - /// A class to create functions consisting of PSimpleFunctions - /// Used to create basis_functions from PSimpleFunctions for f, grad_f, and hess_f - /// - template - class PFlexFunction : public PFuncBase< VarContainer, OutType> - { - PSimpleFunction< VarContainer, OutType> _val; - std::vector< PSimpleFunction< VarContainer, OutType> > _grad_val; - std::vector< std::vector< PSimpleFunction< VarContainer, OutType> > > _hess_val; - - public: - - typedef typename PFuncBase< VarContainer, OutType>::size_type size_type; - - PFlexFunction() - { - - } - - PFlexFunction( const std::string &name, - const std::vector &var_name, - const std::vector &var_description, - const PSimpleFunction< VarContainer, OutType> &simplef, - const std::vector< PSimpleFunction< VarContainer, OutType> > &grad_simplef, - const std::vector< std::vector< PSimpleFunction< VarContainer, OutType> > > &hess_simplef) : - PFuncBase< VarContainer, OutType>(name, var_name, var_description), - _val(simplef), _grad_val(grad_simplef), _hess_val(hess_simplef) - { - check(); - } - - void clear() - { - this->_name = ""; - this->_var_name.clear(); - this->_var_description.clear(); - _val = PSimpleFunction< VarContainer, OutType>(); - _grad_val.clear(); - _hess_val.clear(); - } - - void set( const std::string &name, - const std::vector &var_name, - const std::vector &var_description, - const PSimpleFunction< VarContainer, OutType> &simplef, - const std::vector< PSimpleFunction< VarContainer, OutType> > &grad_simplef, - const std::vector< std::vector< PSimpleFunction< VarContainer, OutType> > > &hess_simplef) - { - this->_name = name; - this->_var_name = var_name; - this->_var_description = var_description; - _val = simplef; - _grad_val = grad_simplef; - _hess_val = hess_simplef; - - check(); - } + /// A class to create functions consisting of PSimpleFunctions + /// Used to create basis_functions from PSimpleFunctions for f, grad_f, and hess_f + /// + template + class PFlexFunction : public PFuncBase + { + PSimpleFunction _val; + std::vector> _grad_val; + std::vector>> _hess_val; + + public: + typedef typename PFuncBase::size_type size_type; + + PFlexFunction() + {} + + PFlexFunction(const std::string &name, + const std::vector &var_name, + const std::vector &var_description, + const PSimpleFunction &simplef, + const std::vector> &grad_simplef, + const std::vector>> + &hess_simplef) + : PFuncBase(name, var_name, var_description) + , _val(simplef) + , _grad_val(grad_simplef) + , _hess_val(hess_simplef) + { + check(); + } - PFlexFunction(const PFlexFunction &RHS ) - { - this->_name = RHS._name; - this->_var_name = RHS._var_name; - this->_var_description = RHS._var_description; - - _val = RHS._val; - _grad_val = RHS._grad_val; - _hess_val = RHS._hess_val; - } + void + clear() + { + this->_name = ""; + this->_var_name.clear(); + this->_var_description.clear(); + _val = PSimpleFunction(); + _grad_val.clear(); + _hess_val.clear(); + } + + void + set(const std::string &name, + const std::vector &var_name, + const std::vector &var_description, + const PSimpleFunction &simplef, + const std::vector> &grad_simplef, + const std::vector>> + &hess_simplef) + { + this->_name = name; + this->_var_name = var_name; + this->_var_description = var_description; + _val = simplef; + _grad_val = grad_simplef; + _hess_val = hess_simplef; - PFlexFunction& operator=(const PFlexFunction &RHS ) - { - this->_name = RHS._name; - this->_var_name = RHS._var_name; - this->_var_description = RHS._var_description; - - _val = RHS._val; - _grad_val = RHS._grad_val; - _hess_val = RHS._hess_val; - - } + check(); + } - ~PFlexFunction() - { - - } + PFlexFunction(const PFlexFunction &RHS) + { + this->_name = RHS._name; + this->_var_name = RHS._var_name; + this->_var_description = RHS._var_description; - PFlexFunction* clone() const - { - return new PFlexFunction(*this); - } + _val = RHS._val; + _grad_val = RHS._grad_val; + _hess_val = RHS._hess_val; + } - PSimpleFunction< VarContainer, OutType> simplefunction() const - { - return _val; - } + PFlexFunction & + operator=(const PFlexFunction &RHS) + { + this->_name = RHS._name; + this->_var_name = RHS._var_name; + this->_var_description = RHS._var_description; - PSimpleFunction< VarContainer, OutType> grad_simplefunction(size_type di) const - { - return _grad_val[di]; - } + _val = RHS._val; + _grad_val = RHS._grad_val; + _hess_val = RHS._hess_val; + } - PSimpleFunction< VarContainer, OutType> hess_simplefunction(size_type di, size_type dj) const - { - return _hess_val[di][dj]; - } + ~PFlexFunction() + {} - OutType operator()(const VarContainer &var) - { - return _val(var); - } + PFlexFunction * + clone() const + { + return new PFlexFunction(*this); + } - OutType grad(const VarContainer &var, size_type di) - { - return _grad_val[di](var); - } + PSimpleFunction + simplefunction() const + { + return _val; + } - OutType hess(const VarContainer &var, size_type di, size_type dj) - { - return _hess_val[di][dj](var); - } - - void eval(const VarContainer &var) - { - (*this)(var); - } + PSimpleFunction + grad_simplefunction(size_type di) const + { + return _grad_val[di]; + } - void eval_grad(const VarContainer &var) - { - for( size_type i=0; i<_grad_val.size(); i++) - _grad_val[i](var); - } + PSimpleFunction + hess_simplefunction(size_type di, size_type dj) const + { + return _hess_val[di][dj]; + } - void eval_hess(const VarContainer &var) - { - for( size_type i=0; i<_hess_val.size(); i++) - for( size_type j=0; j<_hess_val[i].size(); j++) - _hess_val[i][j](var); - } + OutType + operator()(const VarContainer &var) + { + return _val(var); + } + + OutType + grad(const VarContainer &var, size_type di) + { + return _grad_val[di](var); + } + + OutType + hess(const VarContainer &var, size_type di, size_type dj) + { + return _hess_val[di][dj](var); + } + + void + eval(const VarContainer &var) + { + (*this)(var); + } + + void + eval_grad(const VarContainer &var) + { + for (size_type i = 0; i < _grad_val.size(); i++) + _grad_val[i](var); + } + + void + eval_hess(const VarContainer &var) + { + for (size_type i = 0; i < _hess_val.size(); i++) + for (size_type j = 0; j < _hess_val[i].size(); j++) + _hess_val[i][j](var); + } + + OutType + operator()() const + { + return _val(); + } + + OutType + grad(size_type di) const + { + return _grad_val[di](); + } - OutType operator()() const + OutType + hess(size_type di, size_type dj) const + { + return _hess_val[di][dj](); + } + + private: + void + check() + { + size_type n = this->_var_name.size(); + if (this->_var_description.size() != n) { - return _val(); + std::cerr + << "Error in PFlexFunction. _var_name.size() != _var_description.size()." + << std::endl; + exit(1); } - - OutType grad(size_type di) const + if (_grad_val.size() != n) { - return _grad_val[di](); + std::cerr << "Error in PFlexFunction. _var_name.size() != _grad_val.size()." + << std::endl; + exit(1); } - - OutType hess(size_type di, size_type dj) const + if (_hess_val.size() != n) { - return _hess_val[di][dj](); + std::cerr << "Error in PFlexFunction. _var_name.size() != _hess_val.size()." + << std::endl; + exit(1); } - - private: - - void check() + for (size_type i = 0; i < _hess_val.size(); i++) { - size_type n = this->_var_name.size(); - if( this->_var_description.size() != n) + if (_hess_val[i].size() != n) { - std::cerr << "Error in PFlexFunction. _var_name.size() != _var_description.size()." << std::endl; - exit(1); - } - if( _grad_val.size() != n) - { - std::cerr << "Error in PFlexFunction. _var_name.size() != _grad_val.size()." << std::endl; - exit(1); - } - if( _hess_val.size() != n) - { - std::cerr << "Error in PFlexFunction. _var_name.size() != _hess_val.size()." << std::endl; - exit(1); - } - for( size_type i=0; i<_hess_val.size(); i++) - { - if( _hess_val[i].size() != n) - { - std::cerr << "Error in PFlexFunction. _var_name.size() != _hess_val[" << i << "].size()." << std::endl; - exit(1); - } + std::cerr << "Error in PFlexFunction. _var_name.size() != _hess_val[" << i + << "].size()." << std::endl; + exit(1); } } + } + }; - }; - -} - +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/pfunction/PFuncBase.hh b/include/IntegrationTools/pfunction/PFuncBase.hh index 56455ec1e..50c56e601 100644 --- a/include/IntegrationTools/pfunction/PFuncBase.hh +++ b/include/IntegrationTools/pfunction/PFuncBase.hh @@ -2,152 +2,190 @@ #ifndef PFuncBase_HH #define PFuncBase_HH -#include -#include -#include -#include -#include - #include "./PSimpleFunction.hh" +#include +#include +#include +#include +#include namespace PRISMS -{ - /// A Base class for a function, including grad & hess - /// - template< class VarContainer, class OutType> - class PFuncBase - { - protected: - std::string _name; - std::vector _var_name; - std::vector _var_description; - - public: - typedef std::vector::size_type size_type; - - PFuncBase(){} - - PFuncBase( const std::string &name, - const std::vector &var_name, - const std::vector &var_description) : - _name(name), _var_name(var_name), _var_description(var_description) - { - } - - virtual ~PFuncBase(){} - - std::string name() - { - return _name; - } - size_type size() const - { - return _var_name.size(); - } - std::vector var_name() - { - return _var_name; - } - std::string var_name(size_type i) - { - return _var_name[i]; - } - std::vector var_description() - { - return _var_description; - } - std::string var_description(size_type i) - { - return _var_description[i]; - } - - void is_derived_from_PFuncBase() const - { - return; - } - - virtual PFuncBase *clone() const - { - return new PFuncBase(*this); - } - - virtual PSimpleFunction simplefunction() const - { - undefined("PSimpleFunction simplefunction() const"); - return PSimpleFunction(); - } - - virtual PSimpleFunction grad_simplefunction(size_type di) const - { - undefined("PSimpleFunction grad_simplefunction() const"); - return PSimpleFunction(); - } - - virtual PSimpleFunction hess_simplefunction(size_type di, size_type dj) const - { - undefined("PSimpleFunction hess_simplefunction(size_type di, size_type dj) const"); - return PSimpleFunction(); - } - - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value - virtual OutType operator()(const VarContainer &var) - { - undefined("OutType operator()(const VarContainer &var)"); - return OutType(); - } - virtual OutType grad(const VarContainer &var, size_type di) - { - undefined("OutType grad(const VarContainer &var, size_type di)"); - return OutType(); - } - virtual OutType hess(const VarContainer &var, size_type di, size_type dj) - { - undefined("OutType hess(const VarContainer &var, size_type di, size_type dj)"); - return OutType(); - } - - // ---------------------------------------------------------- - // Use these functions to evaluate several values, then use 'get' methods to access results - virtual void eval(const VarContainer &var) - { - undefined("void eval_grad( const VarContainer &var)"); - } - virtual void eval_grad(const VarContainer &var) - { - undefined("void eval_grad( const VarContainer &var)"); - } - virtual void eval_hess(const VarContainer &var) - { - undefined("void eval_hess( const VarContainer &var)"); - } - - virtual OutType operator()() const - { - undefined("OutType operator()"); - return OutType(); - } - virtual OutType grad(size_type di) const - { - undefined("OutType grad(size_type di)"); - return OutType(); - } - virtual OutType hess(size_type di, size_type dj) const - { - undefined("OutType hess(size_type di, size_type dj)"); - return OutType(); - } - - private: - void undefined(std::string fname) const - { - std::string msg = "Error in PFuncBase '" + _name + "'.\n" + " The member function '" + fname + "' has not been defined.\n"; - throw std::runtime_error(msg); - } - - }; - -} +{ + /// A Base class for a function, including grad & hess + /// + template + class PFuncBase + { + protected: + std::string _name; + std::vector _var_name; + std::vector _var_description; + + public: + typedef std::vector::size_type size_type; + + PFuncBase() + {} + + PFuncBase(const std::string &name, + const std::vector &var_name, + const std::vector &var_description) + : _name(name) + , _var_name(var_name) + , _var_description(var_description) + {} + + virtual ~PFuncBase() + {} + + std::string + name() + { + return _name; + } + + size_type + size() const + { + return _var_name.size(); + } + + std::vector + var_name() + { + return _var_name; + } + + std::string + var_name(size_type i) + { + return _var_name[i]; + } + + std::vector + var_description() + { + return _var_description; + } + + std::string + var_description(size_type i) + { + return _var_description[i]; + } + + void + is_derived_from_PFuncBase() const + { + return; + } + + virtual PFuncBase * + clone() const + { + return new PFuncBase(*this); + } + + virtual PSimpleFunction + simplefunction() const + { + undefined("PSimpleFunction simplefunction() const"); + return PSimpleFunction(); + } + + virtual PSimpleFunction + grad_simplefunction([[maybe_unused]] size_type di) const + { + undefined("PSimpleFunction grad_simplefunction() const"); + return PSimpleFunction(); + } + + virtual PSimpleFunction + hess_simplefunction([[maybe_unused]] size_type di, + [[maybe_unused]] size_type dj) const + { + undefined("PSimpleFunction hess_simplefunction(size_type " + "di, size_type dj) const"); + return PSimpleFunction(); + } + + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + virtual OutType + operator()([[maybe_unused]] const VarContainer &var) + { + undefined("OutType operator()(const VarContainer &var)"); + return OutType(); + } + + virtual OutType + grad([[maybe_unused]] const VarContainer &var, [[maybe_unused]] size_type di) + { + undefined("OutType grad(const VarContainer &var, size_type di)"); + return OutType(); + } + + virtual OutType + hess([[maybe_unused]] const VarContainer &var, + [[maybe_unused]] size_type di, + [[maybe_unused]] size_type dj) + { + undefined("OutType hess(const VarContainer &var, size_type di, size_type dj)"); + return OutType(); + } + + // ---------------------------------------------------------- + // Use these functions to evaluate several values, then use 'get' methods to access + // results + virtual void + eval([[maybe_unused]] const VarContainer &var) + { + undefined("void eval_grad( const VarContainer &var)"); + } + + virtual void + eval_grad([[maybe_unused]] const VarContainer &var) + { + undefined("void eval_grad( const VarContainer &var)"); + } + + virtual void + eval_hess([[maybe_unused]] const VarContainer &var) + { + undefined("void eval_hess( const VarContainer &var)"); + } + + virtual OutType + operator()() const + { + undefined("OutType operator()"); + return OutType(); + } + + virtual OutType + grad([[maybe_unused]] size_type di) const + { + undefined("OutType grad(size_type di)"); + return OutType(); + } + + virtual OutType + hess([[maybe_unused]] size_type di, [[maybe_unused]] size_type dj) const + { + undefined("OutType hess(size_type di, size_type dj)"); + return OutType(); + } + + private: + void + undefined(std::string fname) const + { + std::string msg = "Error in PFuncBase '" + _name + "'.\n" + + " The member function '" + fname + "' has not been defined.\n"; + throw std::runtime_error(msg); + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/pfunction/PFunction.hh b/include/IntegrationTools/pfunction/PFunction.hh index fbad8cb60..c2238b225 100644 --- a/include/IntegrationTools/pfunction/PFunction.hh +++ b/include/IntegrationTools/pfunction/PFunction.hh @@ -2,204 +2,235 @@ #ifndef PFunction_HH #define PFunction_HH -#include -#include -#include -#include - -#include "./PSimpleFunction.hh" #include "./PFuncBase.hh" +#include "./PSimpleFunction.hh" +#include +#include +#include +#include namespace PRISMS -{ - - /// A class that contains a ptr to a PFuncBase object - /// - like a smart ptr class - /// - same interface as PFuncBase - /// - allows for using PFuncBase objects polymorphically - /// without dereferencing and without worrying about new/delete - /// - VarContainer is either a scalar or something whose elements can be accessed with operator[] - /// - /// example: MyFuncA, MyFuncB, MyFuncC, etc. are defined: - /// template< class VarContainer> - /// MyFuncX : public PFuncBase - /// - /// // Then you can do things like this: - /// - /// MyFuncA > my_func_a; - /// MyFuncB > my_func_b; - /// - /// PFuncBase, double>* my_func_c_ptr; - /// my_func_c_ptr = new MyFuncC, double >(); - /// - /// PFunction, double > f, g, h; - /// - /// f = my_func_a; - /// f = my_func_b; - /// g.set(my_func_c_ptr->clone()); - /// h.set(my_func_c_ptr); - /// double result = f(3.0) + g(4.0) + h(5.0); - /// - /// - No deletions are used in this example. - /// PFunction::set makes PFunction the 'owner' of the MyFuncC object and it will delete it. - /// - template< class VarContainer, class OutType> - class PFunction - { - public: - - std::string name() const - { - return (*ptr).name(); - } - int size() const - { - return (*ptr).size(); - } - std::vector var_name() - { - return (*ptr).var_name(); - } - std::string var_name(int i) - { - return (*ptr).var_name(i); - } - std::vector var_description() - { - return (*ptr).var_description(); - } - std::string var_description(int i) - { - return (*ptr).var_description(i); - } - - PSimpleFunction simplefunction() const - { - return (*ptr).simplefunction(); - } - - PSimpleFunction grad_simplefunction(int di) const - { - return (*ptr).grad_simplefunction(di); - } - - PSimpleFunction hess_simplefunction(int di, int dj) const - { - return (*ptr).hess_simplefunction(di, dj); - } +{ + + /// A class that contains a ptr to a PFuncBase object + /// - like a smart ptr class + /// - same interface as PFuncBase + /// - allows for using PFuncBase objects polymorphically + /// without dereferencing and without worrying about new/delete + /// - VarContainer is either a scalar or something whose elements can be accessed with + /// operator[] + /// + /// example: MyFuncA, MyFuncB, MyFuncC, etc. are defined: + /// template< class VarContainer> + /// MyFuncX : public PFuncBase + /// + /// // Then you can do things like this: + /// + /// MyFuncA > my_func_a; + /// MyFuncB > my_func_b; + /// + /// PFuncBase, double>* my_func_c_ptr; + /// my_func_c_ptr = new MyFuncC, double >(); + /// + /// PFunction, double > f, g, h; + /// + /// f = my_func_a; + /// f = my_func_b; + /// g.set(my_func_c_ptr->clone()); + /// h.set(my_func_c_ptr); + /// double result = f(3.0) + g(4.0) + h(5.0); + /// + /// - No deletions are used in this example. + /// PFunction::set makes PFunction the 'owner' of the MyFuncC object and it will + /// delete it. + /// + template + class PFunction + { + public: + std::string + name() const + { + return (*ptr).name(); + } - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value - OutType operator()(const VarContainer &var) - { - return (*ptr)(var); - } - OutType grad(const VarContainer &var, int di) - { - return (*ptr).grad(var, di); - } - OutType hess(const VarContainer &var, int di, int dj) - { - return (*ptr).hess(var, di, dj); - } + int + size() const + { + return (*ptr).size(); + } - // ---------------------------------------------------------- - // Use these functions to evaluate several values, then use 'get' methods to access results - void eval(const VarContainer &var) - { - return (*ptr).eval(var); - } - void eval_grad(const VarContainer &var) - { - return (*ptr).eval_grad(var); - } - void eval_hess(const VarContainer &var) - { - return (*ptr).eval_hess(var); - } + std::vector + var_name() + { + return (*ptr).var_name(); + } - OutType operator()() const - { - return (*ptr)(); - } - OutType grad(int di) const - { - return (*ptr).grad(di); - } - OutType hess(int di, int dj) const - { - return (*ptr).hess(di, dj); - } + std::string + var_name(int i) + { + return (*ptr).var_name(i); + } + std::vector + var_description() + { + return (*ptr).var_description(); + } - // PFunction unique members ------------------------------------------ + std::string + var_description(int i) + { + return (*ptr).var_description(i); + } - PFunction &operator=(const PFunction &RHS) - { - if(ptr != NULL) - delete ptr; - ptr = RHS.ptr->clone(); - return *this; - } + PSimpleFunction + simplefunction() const + { + return (*ptr).simplefunction(); + } - template PFunction &operator=(const T &RHS) - { - RHS.is_derived_from_PFuncBase(); + PSimpleFunction + grad_simplefunction(int di) const + { + return (*ptr).grad_simplefunction(di); + } - if(ptr != NULL) - delete ptr; - ptr = RHS.clone(); - return *this; - } + PSimpleFunction + hess_simplefunction(int di, int dj) const + { + return (*ptr).hess_simplefunction(di, dj); + } - // If you use this, PFunction becomes the 'owner' of the function RHS points to - // and it will delete it - PFunction &set( PFuncBase *RHS) - { - if(RHS == NULL) - { - std::cout << "Error in PFunction::set. RHS == NULL." << std::endl; - exit(1); - } - if(ptr != NULL) - delete ptr; - ptr = RHS; - return *this; - } + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + OutType + operator()(const VarContainer &var) + { + return (*ptr)(var); + } - PFunction() - { - ptr = NULL; - } + OutType + grad(const VarContainer &var, int di) + { + return (*ptr).grad(var, di); + } - PFunction(const PFunction &RHS) - { - if( RHS.ptr != NULL) - ptr = RHS.ptr->clone(); - else - ptr = NULL; - } - - template PFunction(const T &RHS) - { - RHS.is_derived_from_PFuncBase(); + OutType + hess(const VarContainer &var, int di, int dj) + { + return (*ptr).hess(var, di, dj); + } + + // ---------------------------------------------------------- + // Use these functions to evaluate several values, then use 'get' methods to access + // results + void + eval(const VarContainer &var) + { + return (*ptr).eval(var); + } - ptr = RHS.clone(); - - } + void + eval_grad(const VarContainer &var) + { + return (*ptr).eval_grad(var); + } + + void + eval_hess(const VarContainer &var) + { + return (*ptr).eval_hess(var); + } + + OutType + operator()() const + { + return (*ptr)(); + } + + OutType + grad(int di) const + { + return (*ptr).grad(di); + } + + OutType + hess(int di, int dj) const + { + return (*ptr).hess(di, dj); + } - ~PFunction() + // PFunction unique members ------------------------------------------ + + PFunction & + operator=(const PFunction &RHS) + { + if (ptr != NULL) + delete ptr; + ptr = RHS.ptr->clone(); + return *this; + } + + template + PFunction & + operator=(const T &RHS) + { + RHS.is_derived_from_PFuncBase(); + + if (ptr != NULL) + delete ptr; + ptr = RHS.clone(); + return *this; + } + + // If you use this, PFunction becomes the 'owner' of the function RHS points to + // and it will delete it + PFunction & + set(PFuncBase *RHS) + { + if (RHS == NULL) { - if(ptr != NULL) - delete ptr; + std::cout << "Error in PFunction::set. RHS == NULL." << std::endl; + exit(1); } + if (ptr != NULL) + delete ptr; + ptr = RHS; + return *this; + } + + PFunction() + { + ptr = NULL; + } - private: - PFuncBase *ptr; + PFunction(const PFunction &RHS) + { + if (RHS.ptr != NULL) + ptr = RHS.ptr->clone(); + else + ptr = NULL; + } + + template + PFunction(const T &RHS) + { + RHS.is_derived_from_PFuncBase(); - }; + ptr = RHS.clone(); + } + + ~PFunction() + { + if (ptr != NULL) + delete ptr; + } -} + private: + PFuncBase *ptr; + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/pfunction/PSeriesFunction.hh b/include/IntegrationTools/pfunction/PSeriesFunction.hh index b8d1eed79..a001ae5fc 100644 --- a/include/IntegrationTools/pfunction/PSeriesFunction.hh +++ b/include/IntegrationTools/pfunction/PSeriesFunction.hh @@ -2,566 +2,617 @@ #ifndef PSeriesFunction_HH #define PSeriesFunction_HH -#include -#include -#include -#include - -#include "./PFuncBase.hh" -#include "./PBasisSet.hh" #include "../datastruc/PNDArray.hh" +#include "./PBasisSet.hh" +#include "./PFuncBase.hh" +#include +#include +#include +#include namespace PRISMS { - /// This class is for a series function that is the tensor product of indepedent bases - /// - /// Example for order-3 tensor: - /// - /// f(x,y,z) = sum_i sum_j sum_k T_ijk * phix_i(x) * phiy_j(y) * phiz_k(z) - /// - /// summations run from i to _dim[i] - /// x, y, z are independent variables (dx/dy = 0, etc.) - /// - /// Template parameters: - /// - InType: input type for BasisSets (must be the same for all BasisSets) - /// - OutType: output type for SeriesFunction and BasisSets - /// - VarContainer: container for input - /// - IndexContainer: container for tensor indices - /// - /// Example template parameters are: , std::vector > + /// This class is for a series function that is the tensor product of indepedent bases + /// + /// Example for order-3 tensor: + /// + /// f(x,y,z) = sum_i sum_j sum_k T_ijk * phix_i(x) * phiy_j(y) * phiz_k(z) + /// + /// summations run from i to _dim[i] + /// x, y, z are independent variables (dx/dy = 0, etc.) + /// + /// Template parameters: + /// - InType: input type for BasisSets (must be the same for all BasisSets) + /// - OutType: output type for SeriesFunction and BasisSets + /// - VarContainer: container for input + /// - IndexContainer: container for tensor indices + /// + /// Example template parameters are: , + /// std::vector > + /// + template + class PSeriesFunction : public PFuncBase + { + protected: + // coefficient tensor + PNDArray _coeff; + + OutType _identity_val; + OutType _zero_val; + + // basis sets + std::vector> _basis_set; + + // evaluated values + OutType _val; + std::vector _grad_val; + std::vector> _hess_val; + + public: + PSeriesFunction(OutType zero, OutType identity) + { + _zero_val = zero; + _identity_val = identity; + } + + PSeriesFunction(OutType zero, + OutType identity, + const std::vector> &basis_set) + { + _zero_val = zero; + _identity_val = identity; + + set(basis_set); + } + + virtual ~PSeriesFunction() + { + clear(); + } + + void + clear() + { + _basis_set.clear(); + + _coeff.clear(); + + _val = _zero_val; + _grad_val.clear(); + _hess_val.clear(); + } + + /// generate the PSeriesFunction, by cloning 'basis_set' and resizing everything to + /// match /// - template< class InType, class OutType, class VarContainer, class IndexContainer> - class PSeriesFunction : public PFuncBase - { - protected: - - // coefficient tensor - PNDArray _coeff; - - OutType _identity_val; - OutType _zero_val; - - // basis sets - std::vector< PBasisSet > _basis_set; - - // evaluated values - OutType _val; - std::vector _grad_val; - std::vector< std::vector< OutType> > _hess_val; - - public: - PSeriesFunction(OutType zero, OutType identity) - { - _zero_val = zero; - _identity_val = identity; - } - - PSeriesFunction( OutType zero, OutType identity, const std::vector > &basis_set) - { - _zero_val = zero; - _identity_val = identity; + void + set(const std::vector> &basis_set) + { + // std::cout << "begin PSeriesFunction::set()" << std::endl; + clear(); - set(basis_set); - } - - virtual ~PSeriesFunction() - { - clear(); - } - - void clear() + std::vector dim(basis_set.size()); + for (int i = 0; i < basis_set.size(); i++) + dim[i] = basis_set[i].size(); + _coeff.resize(dim); + + // std::cout << " resize: " << basis_set.size() << std::endl; + _basis_set.resize(basis_set.size()); + + _grad_val.resize(_coeff.order()); + _hess_val.resize(_coeff.order()); + + for (int i = 0; i < _coeff.order(); i++) { - _basis_set.clear(); - - _coeff.clear(); - - _val = _zero_val; - _grad_val.clear(); - _hess_val.clear(); - + // std::cout << " i: " << i << std::endl; + _hess_val[i].resize(_coeff.order()); + // std::cout << " copy basis set" << std::endl; + _basis_set[i] = basis_set[i]; } - - /// generate the PSeriesFunction, by cloning 'basis_set' and resizing everything to match - /// - void set( const std::vector > &basis_set) + } + + PNDArray & + coeff() + { + return _coeff; + } + + virtual PSeriesFunction * + clone() const + { + return new PSeriesFunction(*this); + } + + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + virtual OutType + operator()(const VarContainer &var) + { + // evaluate basis functions needed + eval_basis(var); + + // evaluate basis function products, multiply by _coeff_tensor & sum + return calc_val(); + } + + virtual OutType + grad(const VarContainer &var, int di) + { + // evaluate basis functions needed + for (int i = 0; i < _coeff.order(); i++) { - //std::cout << "begin PSeriesFunction::set()" << std::endl; - clear(); - - std::vector dim(basis_set.size()); - for( int i=0; i& coeff() - { - return _coeff; } - virtual PSeriesFunction *clone() const - { - return new PSeriesFunction(*this); - } + // evaluate basis function products, multiply by _coeff_tensor & sum + return calc_grad_val(di); + } - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value - virtual OutType operator()(const VarContainer &var) - { - // evaluate basis functions needed - eval_basis(var); - - // evaluate basis function products, multiply by _coeff_tensor & sum - return calc_val(); - } - - virtual OutType grad(const VarContainer &var, int di) + virtual OutType + hess(const VarContainer &var, int di, int dj) + { + // evaluate basis functions needed + for (int i = 0; i < _coeff.order(); i++) { - // evaluate basis functions needed - for( int i=0; i<_coeff.order(); i++) + if (i == di || i == dj) { - if( i == di) - { - _basis_set[i].eval_grad(var[i]); + if (di == dj) + { + _basis_set[i].eval_hess(var[i]); } - else + else { - _basis_set[i](var[i]); + _basis_set[i].eval_grad(var[i]); } } - - // evaluate basis function products, multiply by _coeff_tensor & sum - return calc_grad_val(di); - } - - virtual OutType hess(const VarContainer &var, int di, int dj) - { - // evaluate basis functions needed - for( int i=0; i<_coeff.order(); i++) + else { - if( i == di || i == dj) - { - if( di == dj) - { - _basis_set[i].eval_hess(var[i]); - } - else - { - _basis_set[i].eval_grad(var[i]); - } - } - else - { - _basis_set[i](var[i]); - } + _basis_set[i](var[i]); } - - // evaluate basis function products, multiply by _coeff_tensor & sum - return calc_hess_val(di,dj); - } - - // ---------------------------------------------------------- - // Use these functions to evaluate several values, then use 'get' methods to access results - virtual void eval(const VarContainer &var) - { - (*this)(var); - } - virtual void eval_grad(const VarContainer &var) - { - eval_basis(var); - - eval_basis_grad(var); - - for( int i=0; i<_coeff.order(); i++) - (*this).calc_grad_val(i); - } - virtual void eval_hess(const VarContainer &var) - { - eval_basis(var); - - eval_basis_grad(var); - - eval_basis_hess(var); - - - for( int i=0; i<_coeff.order(); i++) - for( int j=0; j<_coeff.order(); j++) - (*this).calc_hess_val(i,j); } - virtual OutType operator()() const - { - return _val; - } - virtual OutType grad(int di) const - { - return _grad_val[di]; - } - virtual OutType hess(int di, int dj) const - { - return _hess_val[di][dj]; - } + // evaluate basis function products, multiply by _coeff_tensor & sum + return calc_hess_val(di, dj); + } + // ---------------------------------------------------------- + // Use these functions to evaluate several values, then use 'get' methods to access + // results + virtual void + eval(const VarContainer &var) + { + (*this)(var); + } - // Functions for evaluating basis functions & their derivatives: + virtual void + eval_grad(const VarContainer &var) + { + eval_basis(var); - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value + eval_basis_grad(var); - // use basis index and term index for individual basis function - virtual OutType basis(int bindex, int term, const VarContainer &var) - { - return _basis_set[bindex](term,var[bindex]); - } - virtual OutType basis_grad(int bindex, int term, const VarContainer &var) - { - return _basis_set[bindex].grad(term, var[bindex]); - } - virtual OutType basis_hess(int bindex, int term, const VarContainer &var) - { - return _basis_set[bindex].hess(term, var[bindex]); - } + for (int i = 0; i < _coeff.order(); i++) + (*this).calc_grad_val(i); + } - // or use tensor indices to evaluate basis function product - virtual OutType basis(const IndexContainer &term, const VarContainer &var) - { - // evaluate basis functions needed - OutType tmp = _identity_val; - for( int i=0; i<_coeff.order(); i++) - tmp *= _basis_set[i](term[i],var[i]); - - return tmp; - } - virtual OutType basis_grad(const IndexContainer &term, const VarContainer &var, int di) + virtual void + eval_hess(const VarContainer &var) + { + eval_basis(var); + + eval_basis_grad(var); + + eval_basis_hess(var); + + for (int i = 0; i < _coeff.order(); i++) + for (int j = 0; j < _coeff.order(); j++) + (*this).calc_hess_val(i, j); + } + + virtual OutType + operator()() const + { + return _val; + } + + virtual OutType + grad(int di) const + { + return _grad_val[di]; + } + + virtual OutType + hess(int di, int dj) const + { + return _hess_val[di][dj]; + } + + // Functions for evaluating basis functions & their derivatives: + + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + + // use basis index and term index for individual basis function + virtual OutType + basis(int bindex, int term, const VarContainer &var) + { + return _basis_set[bindex](term, var[bindex]); + } + + virtual OutType + basis_grad(int bindex, int term, const VarContainer &var) + { + return _basis_set[bindex].grad(term, var[bindex]); + } + + virtual OutType + basis_hess(int bindex, int term, const VarContainer &var) + { + return _basis_set[bindex].hess(term, var[bindex]); + } + + // or use tensor indices to evaluate basis function product + virtual OutType + basis(const IndexContainer &term, const VarContainer &var) + { + // evaluate basis functions needed + OutType tmp = _identity_val; + for (int i = 0; i < _coeff.order(); i++) + tmp *= _basis_set[i](term[i], var[i]); + + return tmp; + } + + virtual OutType + basis_grad(const IndexContainer &term, const VarContainer &var, int di) + { + // evaluate basis functions needed + OutType tmp = _identity_val; + for (int i = 0; i < _coeff.order(); i++) { - // evaluate basis functions needed - OutType tmp = _identity_val; - for( int i=0; i<_coeff.order(); i++) + if (i == di) { - if( i == di) - { - tmp *= _basis_set[i].grad(term[i], var[i]); - } - else - { - tmp *= _basis_set[i](term[i], var[i]); - } + tmp *= _basis_set[i].grad(term[i], var[i]); + } + else + { + tmp *= _basis_set[i](term[i], var[i]); } - - return tmp; } - virtual OutType basis_hess(const IndexContainer &term, const VarContainer &var, int di, int dj) + + return tmp; + } + + virtual OutType + basis_hess(const IndexContainer &term, const VarContainer &var, int di, int dj) + { + // evaluate basis functions needed + OutType tmp = _identity_val; + for (int i = 0; i < _coeff.order(); i++) { - // evaluate basis functions needed - OutType tmp = _identity_val; - for( int i=0; i<_coeff.order(); i++) + if (i == di || i == dj) { - if( i == di || i == dj) - { - if( di == dj) - { - tmp *= _basis_set[i].hess(term[i], var[i]); - } - else - { - tmp *= _basis_set[i].grad(term[i], var[i]); - } + if (di == dj) + { + tmp *= _basis_set[i].hess(term[i], var[i]); } - else + else { - tmp *= _basis_set[i](term[i], var[i]); + tmp *= _basis_set[i].grad(term[i], var[i]); } } - - return tmp; + else + { + tmp *= _basis_set[i](term[i], var[i]); + } } - // ---------------------------------------------------------- - // Use these functions to evaluate all basis functions, - // then use following methods to access results. + return tmp; + } - virtual void eval_basis(const VarContainer &var) - { - // evaluate basis functions - for( int i=0; i<_coeff.order(); i++) - _basis_set[i].eval(var[i]); - - } - virtual void eval_basis(const VarContainer &var, int i) - { - // evaluate basis functions - _basis_set[i].eval(var[i]); - - } - virtual void eval_basis_grad(const VarContainer &var) - { - // evaluate basis grad functions - for( int i=0; i<_coeff.order(); i++) - _basis_set[i].eval_grad(var[i]); - } - virtual void eval_basis_grad(const VarContainer &var, int i) - { - // evaluate basis grad functions - _basis_set[i].eval_grad(var[i]); - } - virtual void eval_basis_hess(const VarContainer &var) - { - // evaluate basis hess functions - for( int i=0; i<_coeff.order(); i++) - _basis_set[i].eval_hess(var[i]); - } - virtual void eval_basis_hess(const VarContainer &var, int i) - { - // evaluate basis hess functions - _basis_set[i].eval_hess(var[i]); - } + // ---------------------------------------------------------- + // Use these functions to evaluate all basis functions, + // then use following methods to access results. - // use basis index and term index for individual basis function - virtual OutType basis(int bindex, int term) const - { - return _basis_set[bindex](term); - } - virtual OutType basis_grad(int bindex, int term) const - { - return _basis_set[bindex].grad(term); - } - virtual OutType basis_hess(int bindex, int term) const - { - return _basis_set[bindex].hess(term); - } + virtual void + eval_basis(const VarContainer &var) + { + // evaluate basis functions + for (int i = 0; i < _coeff.order(); i++) + _basis_set[i].eval(var[i]); + } - // or use tensor indices to evaluate basis function product - virtual OutType basis(const IndexContainer &term) const - { - // evaluate basis function product - OutType tmp = _identity_val; - for( int i=0; i<_coeff.order(); i++) - tmp *= _basis_set[i](term[i]); - - return tmp; - } - virtual OutType basis_grad(const IndexContainer &term, int di) const + virtual void + eval_basis(const VarContainer &var, int i) + { + // evaluate basis functions + _basis_set[i].eval(var[i]); + } + + virtual void + eval_basis_grad(const VarContainer &var) + { + // evaluate basis grad functions + for (int i = 0; i < _coeff.order(); i++) + _basis_set[i].eval_grad(var[i]); + } + + virtual void + eval_basis_grad(const VarContainer &var, int i) + { + // evaluate basis grad functions + _basis_set[i].eval_grad(var[i]); + } + + virtual void + eval_basis_hess(const VarContainer &var) + { + // evaluate basis hess functions + for (int i = 0; i < _coeff.order(); i++) + _basis_set[i].eval_hess(var[i]); + } + + virtual void + eval_basis_hess(const VarContainer &var, int i) + { + // evaluate basis hess functions + _basis_set[i].eval_hess(var[i]); + } + + // use basis index and term index for individual basis function + virtual OutType + basis(int bindex, int term) const + { + return _basis_set[bindex](term); + } + + virtual OutType + basis_grad(int bindex, int term) const + { + return _basis_set[bindex].grad(term); + } + + virtual OutType + basis_hess(int bindex, int term) const + { + return _basis_set[bindex].hess(term); + } + + // or use tensor indices to evaluate basis function product + virtual OutType + basis(const IndexContainer &term) const + { + // evaluate basis function product + OutType tmp = _identity_val; + for (int i = 0; i < _coeff.order(); i++) + tmp *= _basis_set[i](term[i]); + + return tmp; + } + + virtual OutType + basis_grad(const IndexContainer &term, int di) const + { + // evaluate basis function product + OutType tmp = _identity_val; + for (int i = 0; i < _coeff.order(); i++) { - // evaluate basis function product - OutType tmp = _identity_val; - for( int i=0; i<_coeff.order(); i++) + if (i == di) { - if( i == di) - { - tmp *= _basis_set[i].grad(term[i]); - } - else - { - tmp *= _basis_set[i](term[i]); - } + tmp *= _basis_set[i].grad(term[i]); + } + else + { + tmp *= _basis_set[i](term[i]); } - - return tmp; } - virtual OutType basis_hess(const IndexContainer &term, int di, int dj) const + + return tmp; + } + + virtual OutType + basis_hess(const IndexContainer &term, int di, int dj) const + { + // evaluate basis function product + OutType tmp = _identity_val; + for (int i = 0; i < _coeff.order(); i++) { - // evaluate basis function product - OutType tmp = _identity_val; - for( int i=0; i<_coeff.order(); i++) + if (i == di || i == dj) { - if( i == di || i == dj) - { - if( di == dj) - { - tmp *= _basis_set[i].hess(term[i]); - } - else - { - tmp *= _basis_set[i].grad(term[i]); - } + if (di == dj) + { + tmp *= _basis_set[i].hess(term[i]); } - else + else { - tmp *= _basis_set[i](term[i]); + tmp *= _basis_set[i].grad(term[i]); } } - - return tmp; - } - - // ---------------------------------------------------------- - // Read and write routines: - // Write routines only uses 'getters', they assume you have - // already evaluated the necessary basis functions - // - // These are not included in PExtern - - void print_basis(std::ostream &sout) - { - std::vector term = std::vector(_coeff.order(),0); - for( int i=0; i<_coeff.volume(); i++) + else { - _coeff.tensor_indices(i,term); - for( int j=0; j term = std::vector(_coeff.order(), 0); + for (int i = 0; i < _coeff.volume(); i++) + { + _coeff.tensor_indices(i, term); + for (int j = 0; j < term.size(); j++) + sout << term[j] << " "; + sout << basis(term) << "\n"; + } + } + + void + print_basis_grad(std::ostream &sout, int di) + { + std::vector term = std::vector(_coeff.order(), 0); + for (int i = 0; i < _coeff.volume(); i++) { - std::vector term = std::vector(_coeff.order(),0); - for( int i=0; i<_coeff.volume(); i++) - { - _coeff.tensor_indices(i,term); - for( int j=0; j term = std::vector(_coeff.order(), 0); + for (int i = 0; i < _coeff.volume(); i++) { - std::vector term = std::vector(_coeff.order(),0); - for( int i=0; i<_coeff.volume(); i++) - { - _coeff.tensor_indices(i,term); - for( int j=0; j term = std::vector(_coeff.order(), 0); + for (int i = 0; i < _coeff.volume(); i++) { - std::vector term = std::vector(_coeff.order(),0); - for( int i=0; i<_coeff.volume(); i++) - { - _coeff.tensor_indices(i,term); - for( int j=0; j term = std::vector(_coeff.order(), 0); + for (int i = 0; i < _coeff.volume(); i++) { - // no error checking, - // assumes format identical to print_coeff output - std::vector term = std::vector(_coeff.order(),0); - for( int i=0; i<_coeff.volume(); i++) + // ignores tensor indices + for (int j = 0; j < term.size(); j++) { - // ignores tensor indices - for( int j=0; j> term[j]; - } - sin >> _coeff(i); + sin >> term[j]; } + sin >> _coeff(i); } - - - /// - private: - - // ---------------------------------------------------------- - // These assume you've evaluated the necessary _basis, _basis_grad, and _basis_hess functions - // and just need to take products & sum - - // evaluate basis function products, multiply by _coeff_tensor & sum - OutType calc_val() + } + + /// + + private: + // ---------------------------------------------------------- + // These assume you've evaluated the necessary _basis, _basis_grad, and _basis_hess + // functions + // and just need to take products & sum + + // evaluate basis function products, multiply by _coeff_tensor & sum + OutType + calc_val() + { + std::vector tindex(_coeff.order()); + OutType tmp; + _val = _zero_val; + for (int i = 0; i < _coeff.volume(); i++) { - std::vector tindex(_coeff.order()); - OutType tmp; - _val = _zero_val; - for( int i=0; i<_coeff.volume(); i++) + tmp = _coeff(i); + _coeff.tensor_indices(i, tindex); + + for (int j = 0; j < _coeff.order(); j++) { - tmp = _coeff(i); - _coeff.tensor_indices(i, tindex); - - for( int j=0; j<_coeff.order(); j++) - { - tmp *= _basis_set[j](tindex[j]); - } - _val += tmp; + tmp *= _basis_set[j](tindex[j]); } - - return _val; + _val += tmp; } - - // evaluate basis function products, multiply by _coeff_tensor & sum - OutType calc_grad_val(int di) - { - std::vector tindex(_coeff.order()); - OutType tmp; - _grad_val[di] = _zero_val; - for( int i=0; i<_coeff.volume(); i++) + + return _val; + } + + // evaluate basis function products, multiply by _coeff_tensor & sum + OutType + calc_grad_val(int di) + { + std::vector tindex(_coeff.order()); + OutType tmp; + _grad_val[di] = _zero_val; + for (int i = 0; i < _coeff.volume(); i++) + { + tmp = _coeff(i); + _coeff.tensor_indices(i, tindex); + for (int j = 0; j < _coeff.order(); j++) { - tmp = _coeff(i); - _coeff.tensor_indices(i, tindex); - for( int j=0; j<_coeff.order(); j++) + if (j == di) { - if( j == di) - { - tmp *= _basis_set[j].grad(tindex[j]); - } - else - { - tmp *= _basis_set[j](tindex[j]); - } + tmp *= _basis_set[j].grad(tindex[j]); + } + else + { + tmp *= _basis_set[j](tindex[j]); } - - _grad_val[di] += tmp; - } - return _grad_val[di]; + + _grad_val[di] += tmp; } - - // evaluate basis function products, multiply by _coeff_tensor & sum - OutType calc_hess_val(int di, int dj) - { - std::vector tindex(_coeff.order()); - OutType tmp; - _hess_val[di][dj] = _zero_val; - for( int i=0; i<_coeff.volume(); i++) + return _grad_val[di]; + } + + // evaluate basis function products, multiply by _coeff_tensor & sum + OutType + calc_hess_val(int di, int dj) + { + std::vector tindex(_coeff.order()); + OutType tmp; + _hess_val[di][dj] = _zero_val; + for (int i = 0; i < _coeff.volume(); i++) + { + tmp = _coeff(i); + _coeff.tensor_indices(i, tindex); + for (int j = 0; j < _coeff.order(); j++) { - tmp = _coeff(i); - _coeff.tensor_indices(i, tindex); - for( int j=0; j<_coeff.order(); j++) + if (j == di || j == dj) { - if( j == di || j == dj) + if (di == dj) { - if( di == dj) - { - tmp *= _basis_set[j].hess(tindex[j]); - } - else - { - tmp *= _basis_set[j].grad(tindex[j]); - } + tmp *= _basis_set[j].hess(tindex[j]); } - else + else { - tmp *= _basis_set[j](tindex[j]); + tmp *= _basis_set[j].grad(tindex[j]); } } - _hess_val[di][dj] += tmp; + else + { + tmp *= _basis_set[j](tindex[j]); + } } - return _hess_val[di][dj]; + _hess_val[di][dj] += tmp; } - }; - - -} + return _hess_val[di][dj]; + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/pfunction/PSimpleBase.hh b/include/IntegrationTools/pfunction/PSimpleBase.hh index 055547e74..80653265f 100644 --- a/include/IntegrationTools/pfunction/PSimpleBase.hh +++ b/include/IntegrationTools/pfunction/PSimpleBase.hh @@ -2,73 +2,98 @@ #ifndef PSimpleBase_HH #define PSimpleBase_HH -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace PRISMS { - /// Base classes for functions that can be hard-coded, - /// then shared and used elsewhere - - /// A simple expression evaluator - /// - template< class VarContainer, class OutType> - class PSimpleBase + /// Base classes for functions that can be hard-coded, + /// then shared and used elsewhere + + /// A simple expression evaluator + /// + template + class PSimpleBase + { + protected: + std::string _name; + OutType _val; + + public: + virtual ~PSimpleBase() {}; + + std::string + name() const + { + return _name; + } + + OutType + operator()(const VarContainer &var) + { + return _val = eval(var); + } + + OutType + operator()() const + { + return _val; + } + + void + is_derived_from_PSimpleBase() const + { + return; + } + + virtual PSimpleBase * + clone() const + { + return new PSimpleBase(*this); + } + + virtual std::string + csrc() const + { + undefined("std::string csrc()"); + return std::string(); + } + + virtual std::string + sym() const + { + undefined("std::string sym()"); + return std::string(); + } + + virtual std::string + latex() const + { + undefined("std::string latex()"); + return std::string(); + } + + private: + virtual OutType + eval([[maybe_unused]] const VarContainer &var) const + { + undefined("OutType eval( const VarContainer &var)"); + return OutType(); + } + + void + undefined(std::string fname) const { - protected: - std::string _name; - OutType _val; - - public: - virtual ~PSimpleBase(){}; - - std::string name() const { return _name;} - OutType operator()( const VarContainer &var){ return _val = eval(var);} - OutType operator()() const { return _val;} - - void is_derived_from_PSimpleBase() const - { - return; - } - - virtual PSimpleBase* clone() const - { - return new PSimpleBase(*this); - } - - virtual std::string csrc() const - { - undefined("std::string csrc()"); - return std::string(); - } - - virtual std::string sym() const - { - undefined("std::string sym()"); - return std::string(); - } - - virtual std::string latex() const - { - undefined("std::string latex()"); - return std::string(); - } - - private: - virtual OutType eval( const VarContainer &var) const { undefined("OutType eval( const VarContainer &var)"); return OutType();} - - void undefined(std::string fname) const - { - std::string msg = "Error in PSimpleBase '" + _name + "'.\n" + " The member function '" + fname + "' has not been defined.\n"; - throw std::runtime_error(msg); - } - }; - -} + std::string msg = "Error in PSimpleBase '" + _name + "'.\n" + + " The member function '" + fname + "' has not been defined.\n"; + throw std::runtime_error(msg); + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/pfunction/PSimpleFunction.hh b/include/IntegrationTools/pfunction/PSimpleFunction.hh index d85ae32b6..efd93227d 100644 --- a/include/IntegrationTools/pfunction/PSimpleFunction.hh +++ b/include/IntegrationTools/pfunction/PSimpleFunction.hh @@ -2,128 +2,135 @@ #ifndef PSimpleFunction_HH #define PSimpleFunction_HH -#include -#include -#include -#include - #include "./PSimpleBase.hh" +#include +#include +#include +#include namespace PRISMS { - template< class VarContainer, class OutType> - class PSimpleFunction + template + class PSimpleFunction + { + private: + PSimpleBase *ptr; + + public: + std::string + name() const { - private: - PSimpleBase *ptr; - - public: - - std::string name() const - { - return (*ptr).name(); - } - std::string csrc() const - { - return (*ptr).csrc(); - } - std::string sym() const - { - return (*ptr).sym(); - } - std::string latex() const - { - return (*ptr).latex(); - } - + return (*ptr).name(); + } - // ---------------------------------------------------------- - // Use this function if you want to evaluate, - // return and store result - OutType operator()(const VarContainer &var) - { - return (*ptr)(var); - } - - // ---------------------------------------------------------- - // Then use 'get' methods to access results later - void eval(const VarContainer &var) - { - (*ptr)(var); - } - - OutType operator()() const - { - return (*ptr)(); - } + std::string + csrc() const + { + return (*ptr).csrc(); + } - // PFunction unique members ------------------------------------------ + std::string + sym() const + { + return (*ptr).sym(); + } - PSimpleFunction& operator=(const PSimpleFunction &RHS) - { - if(ptr != NULL) - delete ptr; - ptr = RHS.ptr->clone(); - return *this; - } + std::string + latex() const + { + return (*ptr).latex(); + } + + // ---------------------------------------------------------- + // Use this function if you want to evaluate, + // return and store result + OutType + operator()(const VarContainer &var) + { + return (*ptr)(var); + } - template - PSimpleFunction& operator=(const T &RHS) - { - RHS.is_derived_from_PSimpleBase(); + // ---------------------------------------------------------- + // Then use 'get' methods to access results later + void + eval(const VarContainer &var) + { + (*ptr)(var); + } - if(ptr != NULL) - delete ptr; - ptr = RHS.clone(); - return *this; - } + OutType + operator()() const + { + return (*ptr)(); + } - // If you use this, PSimpleFunction becomes the 'owner' of the function RHS points to - // and it will delete it - PSimpleFunction& set( PSimpleBase *RHS) - { - if(RHS == NULL) - { - std::cout << "Error in PSimpleFunction::set. RHS == NULL." << std::endl; - exit(1); - } - if(ptr != NULL) - delete ptr; - ptr = RHS; - return *this; - } - - PSimpleFunction() - { - ptr = NULL; - } + // PFunction unique members ------------------------------------------ - PSimpleFunction(const PSimpleFunction &RHS) + PSimpleFunction & + operator=(const PSimpleFunction &RHS) + { + if (ptr != NULL) + delete ptr; + ptr = RHS.ptr->clone(); + return *this; + } + + template + PSimpleFunction & + operator=(const T &RHS) + { + RHS.is_derived_from_PSimpleBase(); + + if (ptr != NULL) + delete ptr; + ptr = RHS.clone(); + return *this; + } + + // If you use this, PSimpleFunction becomes the 'owner' of the function RHS points to + // and it will delete it + PSimpleFunction & + set(PSimpleBase *RHS) + { + if (RHS == NULL) { - if( RHS.ptr != NULL) - ptr = RHS.ptr->clone(); - else - ptr = NULL; + std::cout << "Error in PSimpleFunction::set. RHS == NULL." << std::endl; + exit(1); } - - template PSimpleFunction(const T &RHS) - { - RHS.is_derived_from_PSimpleBase(); + if (ptr != NULL) + delete ptr; + ptr = RHS; + return *this; + } - ptr = RHS.clone(); - - } + PSimpleFunction() + { + ptr = NULL; + } - ~PSimpleFunction() - { - if(ptr != NULL) - delete ptr; - } + PSimpleFunction(const PSimpleFunction &RHS) + { + if (RHS.ptr != NULL) + ptr = RHS.ptr->clone(); + else + ptr = NULL; + } + + template + PSimpleFunction(const T &RHS) + { + RHS.is_derived_from_PSimpleBase(); - - }; + ptr = RHS.clone(); + } -} + ~PSimpleFunction() + { + if (ptr != NULL) + delete ptr; + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/piecewise/PPieceWiseFuncBase.hh b/include/IntegrationTools/piecewise/PPieceWiseFuncBase.hh index 10c701e9f..bd802ab74 100644 --- a/include/IntegrationTools/piecewise/PPieceWiseFuncBase.hh +++ b/include/IntegrationTools/piecewise/PPieceWiseFuncBase.hh @@ -2,148 +2,172 @@ #ifndef PPieceWiseFuncBase_HH #define PPieceWiseFuncBase_HH -#include -#include -#include - #include "../pfunction/PFuncBase.hh" -#include "./SimplePiece.hh" #include "./PPieceWiseSimpleBase.hh" #include "./Piece.hh" +#include "./SimplePiece.hh" +#include +#include +#include namespace PRISMS -{ - - /// Class to define a PieceWise Function - /// - /// Contains a vector of 'Piece'. Throws a domain_error if it - /// is evaluated outside of the valid domain of any piece. - /// - template< class VarContainer, class OutType> - class PPieceWiseFuncBase : public PFuncBase - { - public: - typedef typename PFuncBase::size_type size_type; - - size_type _curr_piece; - std::vector > _piece; - - PPieceWiseFuncBase() {} - - PPieceWiseFuncBase( const std::vector > &piece) - { - _piece = piece; - } - - bool in_piece( const VarContainer &var) const - { - for( size_type i=0; i<_piece.size(); i++) - { - if( _piece[i].in_piece(var) ) - return true; - } - return false; - } - - size_type piece(const VarContainer &var) - { - for( size_type i=0; i<_piece.size(); i++) - { - if( _piece[i].in_piece(var)) - return _curr_piece = i; - } - - throw std::domain_error("PPieceWiseFuncBase: Not in any piece"); - } - - virtual PPieceWiseFuncBase *clone() const - { - return new PPieceWiseFuncBase(*this); - } - - virtual PSimpleFunction simplefunction() const - { - std::vector > piece; - - for( size_type i=0; i<_piece.size(); i++) - { - piece.push_back( _piece[i].simplepiece() ); - } - - return PSimpleFunction( PPieceWiseSimpleBase(piece) ); - } - - virtual PSimpleFunction grad_simplefunction(size_type di) const - { - std::vector > piece; - - for( size_type i=0; i<_piece.size(); i++) - { - piece.push_back( _piece[i].grad_simplepiece(di)); - } - - return PSimpleFunction( PPieceWiseSimpleBase(piece)); - } - - virtual PSimpleFunction hess_simplefunction(size_type di, size_type dj) const - { - std::vector > piece; - - for( size_type i=0; i<_piece.size(); i++) - { - piece.push_back( _piece[i].hess_simplepiece(di,dj)); - } - - return PSimpleFunction( PPieceWiseSimpleBase(piece) ); - } +{ - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value - - virtual OutType operator()(const VarContainer &var) - { - return _piece[piece(var)](var); - } - virtual OutType grad(const VarContainer &var, size_type di) - { - return _piece[piece(var)].grad(var, di); - } - virtual OutType hess(const VarContainer &var, size_type di, size_type dj) - { - return _piece[piece(var)].hess(var, di, dj); - } + /// Class to define a PieceWise Function + /// + /// Contains a vector of 'Piece'. Throws a domain_error if it + /// is evaluated outside of the valid domain of any piece. + /// + template + class PPieceWiseFuncBase : public PFuncBase + { + public: + typedef typename PFuncBase::size_type size_type; - // ---------------------------------------------------------- - // Use these functions to evaluate several values, then use 'get' methods to access results - virtual void eval(const VarContainer &var) - { - _piece[piece(var)].eval(var); - } - virtual void eval_grad(const VarContainer &var) + size_type _curr_piece; + std::vector> _piece; + + PPieceWiseFuncBase() + {} + + PPieceWiseFuncBase(const std::vector> &piece) + { + _piece = piece; + } + + bool + in_piece(const VarContainer &var) const + { + for (size_type i = 0; i < _piece.size(); i++) { - _piece[piece(var)].eval_grad(var); + if (_piece[i].in_piece(var)) + return true; } - virtual void eval_hess(const VarContainer &var) + return false; + } + + size_type + piece(const VarContainer &var) + { + for (size_type i = 0; i < _piece.size(); i++) { - _piece[piece(var)].eval_hess(var); + if (_piece[i].in_piece(var)) + return _curr_piece = i; } - - /// These don't recheck the domain - virtual OutType operator()() const + + throw std::domain_error("PPieceWiseFuncBase: Not in any piece"); + } + + virtual PPieceWiseFuncBase * + clone() const + { + return new PPieceWiseFuncBase(*this); + } + + virtual PSimpleFunction + simplefunction() const + { + std::vector> piece; + + for (size_type i = 0; i < _piece.size(); i++) { - return _piece[_curr_piece](); + piece.push_back(_piece[i].simplepiece()); } - virtual OutType grad(size_type di) const + + return PSimpleFunction( + PPieceWiseSimpleBase(piece)); + } + + virtual PSimpleFunction + grad_simplefunction(size_type di) const + { + std::vector> piece; + + for (size_type i = 0; i < _piece.size(); i++) { - return _piece[_curr_piece].grad(di); + piece.push_back(_piece[i].grad_simplepiece(di)); } - virtual OutType hess(size_type di, size_type dj) const + + return PSimpleFunction( + PPieceWiseSimpleBase(piece)); + } + + virtual PSimpleFunction + hess_simplefunction(size_type di, size_type dj) const + { + std::vector> piece; + + for (size_type i = 0; i < _piece.size(); i++) { - return _piece[_curr_piece].hess(di, dj); + piece.push_back(_piece[i].hess_simplepiece(di, dj)); } - }; -} + return PSimpleFunction( + PPieceWiseSimpleBase(piece)); + } + + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + + virtual OutType + operator()(const VarContainer &var) + { + return _piece[piece(var)](var); + } + + virtual OutType + grad(const VarContainer &var, size_type di) + { + return _piece[piece(var)].grad(var, di); + } + + virtual OutType + hess(const VarContainer &var, size_type di, size_type dj) + { + return _piece[piece(var)].hess(var, di, dj); + } + + // ---------------------------------------------------------- + // Use these functions to evaluate several values, then use 'get' methods to access + // results + virtual void + eval(const VarContainer &var) + { + _piece[piece(var)].eval(var); + } + + virtual void + eval_grad(const VarContainer &var) + { + _piece[piece(var)].eval_grad(var); + } + + virtual void + eval_hess(const VarContainer &var) + { + _piece[piece(var)].eval_hess(var); + } + + /// These don't recheck the domain + virtual OutType + operator()() const + { + return _piece[_curr_piece](); + } + + virtual OutType + grad(size_type di) const + { + return _piece[_curr_piece].grad(di); + } + + virtual OutType + hess(size_type di, size_type dj) const + { + return _piece[_curr_piece].hess(di, dj); + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/piecewise/PPieceWiseSimpleBase.hh b/include/IntegrationTools/piecewise/PPieceWiseSimpleBase.hh index 9cae8ab8d..6672b930d 100644 --- a/include/IntegrationTools/piecewise/PPieceWiseSimpleBase.hh +++ b/include/IntegrationTools/piecewise/PPieceWiseSimpleBase.hh @@ -2,138 +2,143 @@ #ifndef PPieceWiseSimpleBase_HH #define PPieceWiseSimpleBase_HH -#include -#include -#include - #include "../pfunction/PSimpleBase.hh" #include "./SimplePiece.hh" +#include +#include +#include namespace PRISMS { - /// Class to define a PieceWise SimpleFunction - /// - /// Contains a vector of 'SimplePiece'. Throws a domain_error if it - /// is evaluated outside of the valid domain of any piece. - /// - template< class VarContainer, class OutType> - class PPieceWiseSimpleBase : public PSimpleBase + /// Class to define a PieceWise SimpleFunction + /// + /// Contains a vector of 'SimplePiece'. Throws a domain_error if it + /// is evaluated outside of the valid domain of any piece. + /// + template + class PPieceWiseSimpleBase : public PSimpleBase + { + public: + mutable std::vector> _piece; + + PPieceWiseSimpleBase() + {} + + PPieceWiseSimpleBase(const std::vector> &piece) { - public: - - mutable std::vector > _piece; - - PPieceWiseSimpleBase() {} - - PPieceWiseSimpleBase( const std::vector > &piece) - { - _piece = piece; - } - - virtual std::string csrc() const + _piece = piece; + } + + virtual std::string + csrc() const + { + std::string str = ""; + for (int i = 0; i < _piece.size(); i++) { - std::string str = ""; - for( int i=0; i<_piece.size(); i++) + if (i == 0) { - if( i == 0) - { - str += _piece[i].csrc(); - } - else if( i == _piece.size()-1 ) - { - str += "; and " + _piece[i].csrc(); - } - else - { - str += "; " + _piece[i].csrc(); - } + str += _piece[i].csrc(); } - return str; - } - - virtual std::string sym() const - { - std::string str = ""; - for( int i=0; i<_piece.size(); i++) + else if (i == _piece.size() - 1) { - if( i == 0) - { - str += _piece[i].sym(); - } - else if( i == _piece.size()-1 ) - { - str += "; and " + _piece[i].sym(); - } - else - { - str += "; " + _piece[i].sym(); - } + str += "; and " + _piece[i].csrc(); } - return str; - } - - virtual std::string latex() const - { - std::string str = ""; - for( int i=0; i<_piece.size(); i++) + else { - if( i == 0) - { - str += "\\left\\{ \\begin{array}{ll} " + _piece[i].latex(); - } - else if( i == _piece.size()-1 ) - { - str += " \\\\ " + _piece[i].latex(); - } - else - { - str += " \\\\ " + _piece[i].latex(); - } + str += "; " + _piece[i].csrc(); } - - str += " \\end{array} \\right."; - return str; - } - - virtual PPieceWiseSimpleBase* clone() const - { - return new PPieceWiseSimpleBase(*this); } - - bool in_piece( const VarContainer &var) const + return str; + } + + virtual std::string + sym() const + { + std::string str = ""; + for (int i = 0; i < _piece.size(); i++) { - for( int i=0; i<_piece.size(); i++) + if (i == 0) { - if( _piece[i].in_piece(var) ) - return true; + str += _piece[i].sym(); + } + else if (i == _piece.size() - 1) + { + str += "; and " + _piece[i].sym(); + } + else + { + str += "; " + _piece[i].sym(); } - return false; } - - int piece(const VarContainer &var) + return str; + } + + virtual std::string + latex() const + { + std::string str = ""; + for (int i = 0; i < _piece.size(); i++) { - for( int i=0; i<_piece.size(); i++) + if (i == 0) { - if( _piece[i].in_piece(var)) - return i; + str += "\\left\\{ \\begin{array}{ll} " + _piece[i].latex(); } - - throw std::domain_error("PPieceWiseSimpleBase: Not in any piece"); - } - - private: - virtual OutType eval( const VarContainer &var) const - { - for( int i=0; i<_piece.size(); i++) + else if (i == _piece.size() - 1) { - if( _piece[i].in_piece(var)) - return _piece[i](var); + str += " \\\\ " + _piece[i].latex(); } - - throw std::domain_error("PPieceWiseSimpleBase: Not in any piece"); + else + { + str += " \\\\ " + _piece[i].latex(); + } + } + + str += " \\end{array} \\right."; + return str; + } + + virtual PPieceWiseSimpleBase * + clone() const + { + return new PPieceWiseSimpleBase(*this); + } + + bool + in_piece(const VarContainer &var) const + { + for (int i = 0; i < _piece.size(); i++) + { + if (_piece[i].in_piece(var)) + return true; + } + return false; + } + + int + piece(const VarContainer &var) + { + for (int i = 0; i < _piece.size(); i++) + { + if (_piece[i].in_piece(var)) + return i; + } + + throw std::domain_error("PPieceWiseSimpleBase: Not in any piece"); + } + + private: + virtual OutType + eval(const VarContainer &var) const + { + for (int i = 0; i < _piece.size(); i++) + { + if (_piece[i].in_piece(var)) + return _piece[i](var); } - }; -} + throw std::domain_error("PPieceWiseSimpleBase: Not in any piece"); + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/piecewise/Piece.hh b/include/IntegrationTools/piecewise/Piece.hh index 9be936e8e..61ed1e72d 100644 --- a/include/IntegrationTools/piecewise/Piece.hh +++ b/include/IntegrationTools/piecewise/Piece.hh @@ -2,147 +2,177 @@ #ifndef Piece_HH #define Piece_HH -#include -#include - #include "../pfunction/PFunction.hh" #include "./SimplePiece.hh" +#include +#include namespace PRISMS -{ - - /// Class to contain a Function and the piece in which it is valid. - /// - /// This can be evaluated in or out of the piece in which it is declared valid - /// - template< class VarContainer, class OutType> - class Piece : public PFuncBase - { - protected: - - PFunction _expr; - mutable std::vector< PSimpleFunction > _condition; - - typedef typename std::vector< PSimpleFunction >::size_type cond_size_type; - - public: - - typedef typename PFuncBase< VarContainer, OutType>::size_type size_type; - - Piece( const PFunction &expr, const std::vector > &condition) - { - _expr = expr; - _condition = condition; - this->_name = _expr.name(); - this->_var_name = _expr.var_name(); - this->_var_description = _expr.var_description(); - } - - bool in_piece( const VarContainer &var) const - { - for( cond_size_type i=0; i<_condition.size(); i++) - { - if( !_condition[i](var) ) - return false; - } - return true; - } - - PFunction expr() const - { - return _expr; - } - - std::vector< PSimpleFunction > condition() const - { - return _condition; - } - - SimplePiece simplepiece() const - { - return SimplePiece(_expr.simplefunction(), _condition); - } - - SimplePiece grad_simplepiece(size_type di) const - { - return SimplePiece(_expr.grad_simplefunction(di), _condition); - } - - SimplePiece hess_simplepiece(size_type di, size_type dj) const - { - return SimplePiece(_expr.hess_simplefunction(di, dj), _condition); - } - - virtual Piece *clone() const - { - return new Piece(*this); - } - - virtual PSimpleFunction simplefunction() const - { - return PSimpleFunction( SimplePiece(_expr.simplefunction(), _condition)); - } - - virtual PSimpleFunction grad_simplefunction(size_type di) const - { - return PSimpleFunction( SimplePiece(_expr.grad_simplefunction(di), _condition)); - } - - virtual PSimpleFunction hess_simplefunction(size_type di, size_type dj) const - { - return PSimpleFunction( SimplePiece(_expr.hess_simplefunction(di,dj), _condition)); - } +{ - // ---------------------------------------------------------- - // Use these functions if you want to evaluate a single value - - /// These will return '_expr' evaluated anywhere. Must check in_piece first. We - /// don't check it here to avoid double checking when evaluating PPieceWiseFuncBase - /// - virtual OutType operator()(const VarContainer &var) - { - return _expr(var); - } - virtual OutType grad(const VarContainer &var, size_type di) - { - return _expr.grad(var, di); - } - virtual OutType hess(const VarContainer &var, size_type di, size_type dj) - { - return _expr.hess(var, di, dj); - } + /// Class to contain a Function and the piece in which it is valid. + /// + /// This can be evaluated in or out of the piece in which it is declared valid + /// + template + class Piece : public PFuncBase + { + protected: + PFunction _expr; + mutable std::vector> _condition; - // ---------------------------------------------------------- - // Use these functions to evaluate several values, then use 'get' methods to access results - virtual void eval(const VarContainer &var) - { - _expr(var); - } - virtual void eval_grad(const VarContainer &var) - { - _expr.eval_grad(var); - } - virtual void eval_hess(const VarContainer &var) - { - _expr.eval_hess(var); - } - - /// These don't recheck the domain - virtual OutType operator()() const - { - return _expr(); - } - virtual OutType grad(size_type di) const - { - return _expr.grad(di); - } - virtual OutType hess(size_type di, size_type dj) const + typedef + typename std::vector>::size_type cond_size_type; + + public: + typedef typename PFuncBase::size_type size_type; + + Piece(const PFunction &expr, + const std::vector> &condition) + { + _expr = expr; + _condition = condition; + this->_name = _expr.name(); + this->_var_name = _expr.var_name(); + this->_var_description = _expr.var_description(); + } + + bool + in_piece(const VarContainer &var) const + { + for (cond_size_type i = 0; i < _condition.size(); i++) { - return _expr.hess(di, dj); + if (!_condition[i](var)) + return false; } - }; + return true; + } + + PFunction + expr() const + { + return _expr; + } -} + std::vector> + condition() const + { + return _condition; + } + + SimplePiece + simplepiece() const + { + return SimplePiece(_expr.simplefunction(), _condition); + } + + SimplePiece + grad_simplepiece(size_type di) const + { + return SimplePiece(_expr.grad_simplefunction(di), + _condition); + } + + SimplePiece + hess_simplepiece(size_type di, size_type dj) const + { + return SimplePiece(_expr.hess_simplefunction(di, dj), + _condition); + } + + virtual Piece * + clone() const + { + return new Piece(*this); + } + + virtual PSimpleFunction + simplefunction() const + { + return PSimpleFunction( + SimplePiece(_expr.simplefunction(), _condition)); + } + + virtual PSimpleFunction + grad_simplefunction(size_type di) const + { + return PSimpleFunction( + SimplePiece(_expr.grad_simplefunction(di), _condition)); + } + + virtual PSimpleFunction + hess_simplefunction(size_type di, size_type dj) const + { + return PSimpleFunction( + SimplePiece(_expr.hess_simplefunction(di, dj), + _condition)); + } + + // ---------------------------------------------------------- + // Use these functions if you want to evaluate a single value + + /// These will return '_expr' evaluated anywhere. Must check in_piece first. We + /// don't check it here to avoid double checking when evaluating PPieceWiseFuncBase + /// + virtual OutType + operator()(const VarContainer &var) + { + return _expr(var); + } + + virtual OutType + grad(const VarContainer &var, size_type di) + { + return _expr.grad(var, di); + } + + virtual OutType + hess(const VarContainer &var, size_type di, size_type dj) + { + return _expr.hess(var, di, dj); + } + + // ---------------------------------------------------------- + // Use these functions to evaluate several values, then use 'get' methods to access + // results + virtual void + eval(const VarContainer &var) + { + _expr(var); + } + + virtual void + eval_grad(const VarContainer &var) + { + _expr.eval_grad(var); + } + + virtual void + eval_hess(const VarContainer &var) + { + _expr.eval_hess(var); + } + + /// These don't recheck the domain + virtual OutType + operator()() const + { + return _expr(); + } + + virtual OutType + grad(size_type di) const + { + return _expr.grad(di); + } + + virtual OutType + hess(size_type di, size_type dj) const + { + return _expr.hess(di, dj); + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/IntegrationTools/piecewise/SimplePiece.hh b/include/IntegrationTools/piecewise/SimplePiece.hh index 82ce7c3be..9c1a20e2e 100644 --- a/include/IntegrationTools/piecewise/SimplePiece.hh +++ b/include/IntegrationTools/piecewise/SimplePiece.hh @@ -2,135 +2,141 @@ #ifndef SimplePiece_HH #define SimplePiece_HH -#include -#include - #include "../pfunction/PSimpleFunction.hh" +#include +#include namespace PRISMS -{ - /// Class to contain a SimpleFunction and the piece in which it is valid. - /// - /// This can be evaluated in or out of the piece in which it is declared valid - /// - template< class VarContainer, class OutType> - class SimplePiece : public PSimpleBase +{ + /// Class to contain a SimpleFunction and the piece in which it is valid. + /// + /// This can be evaluated in or out of the piece in which it is declared valid + /// + template + class SimplePiece : public PSimpleBase + { + protected: + mutable PSimpleFunction _expr; + mutable std::vector> _condition; + typedef + typename std::vector>::size_type size_type; + + public: + SimplePiece(const PSimpleFunction &expr, + const std::vector> &condition) { - protected: - - mutable PSimpleFunction _expr; - mutable std::vector< PSimpleFunction > _condition; - typedef typename std::vector< PSimpleFunction >::size_type size_type; - - public: - - SimplePiece( const PSimpleFunction &expr, const std::vector< PSimpleFunction > &condition) - { - _expr = expr; - _condition = condition; - this->_name = _expr.name(); - } - - virtual std::string csrc() const + _expr = expr; + _condition = condition; + this->_name = _expr.name(); + } + + virtual std::string + csrc() const + { + std::string str = _expr.csrc(); + for (size_type i = 0; i < _condition.size(); i++) { - std::string str = _expr.csrc(); - for( size_type i=0; i<_condition.size(); i++) + if (i == 0) { - if( i == 0) - { - str += " if " + _condition[i].csrc(); - } - else if( i == _condition.size()-1 ) - { - str += " and " + _condition[i].csrc(); - } - else - { - str += ", " + _condition[i].csrc(); - } + str += " if " + _condition[i].csrc(); } - return str; - } - - virtual std::string sym() const - { - std::string str = _expr.sym(); - for( size_type i=0; i<_condition.size(); i++) + else if (i == _condition.size() - 1) { - if( i == 0) - { - str += " if " + _condition[i].sym(); - } - else if( i == _condition.size()-1 ) - { - str += " and " + _condition[i].sym(); - } - else - { - str += ", " + _condition[i].sym(); - } + str += " and " + _condition[i].csrc(); } - return str; - } - - virtual std::string latex() const - { - std::string str = _expr.latex(); - for( size_type i=0; i<_condition.size(); i++) + else { - if( i == 0) - { - str += " & \\mbox{ if } " + _condition[i].latex(); - } - else if( i == _condition.size()-1 ) - { - str += " \\mbox{ and } " + _condition[i].latex(); - } - else - { - str += " \\mbox{, } " + _condition[i].sym(); - } + str += ", " + _condition[i].csrc(); } - return str; - } - - virtual SimplePiece* clone() const - { - return new SimplePiece(*this); } - - bool in_piece( const VarContainer &var) const + return str; + } + + virtual std::string + sym() const + { + std::string str = _expr.sym(); + for (size_type i = 0; i < _condition.size(); i++) { - for( size_type i=0; i<_condition.size(); i++) + if (i == 0) + { + str += " if " + _condition[i].sym(); + } + else if (i == _condition.size() - 1) + { + str += " and " + _condition[i].sym(); + } + else { - if( !_condition[i](var) ) - return false; + str += ", " + _condition[i].sym(); } - return true; } - - PSimpleFunction expr() const + return str; + } + + virtual std::string + latex() const + { + std::string str = _expr.latex(); + for (size_type i = 0; i < _condition.size(); i++) { - return _expr; + if (i == 0) + { + str += " & \\mbox{ if } " + _condition[i].latex(); + } + else if (i == _condition.size() - 1) + { + str += " \\mbox{ and } " + _condition[i].latex(); + } + else + { + str += " \\mbox{, } " + _condition[i].sym(); + } } - - std::vector< PSimpleFunction > condition() const + return str; + } + + virtual SimplePiece * + clone() const + { + return new SimplePiece(*this); + } + + bool + in_piece(const VarContainer &var) const + { + for (size_type i = 0; i < _condition.size(); i++) { - return _condition; - } - - private: - - /// This will return '_expr' evaluated anywhere. Must check in_piece first. We - /// don't check it here to avoid double checking when evaluating PPieceWiseSimpleBase - /// - virtual OutType eval( const VarContainer &var) const - { - return _expr(var); + if (!_condition[i](var)) + return false; } - }; + return true; + } + + PSimpleFunction + expr() const + { + return _expr; + } -} + std::vector> + condition() const + { + return _condition; + } + + private: + /// This will return '_expr' evaluated anywhere. Must check in_piece first. We + /// don't check it here to avoid double checking when evaluating + /// PPieceWiseSimpleBase + /// + virtual OutType + eval(const VarContainer &var) const + { + return _expr(var); + } + }; +} // namespace PRISMS #endif \ No newline at end of file diff --git a/include/RefinementCriterion.h b/include/RefinementCriterion.h index 6a0dd2cf3..2979581b6 100644 --- a/include/RefinementCriterion.h +++ b/include/RefinementCriterion.h @@ -1,13 +1,45 @@ #ifndef INCLUDE_REFINMENTCRITERION_H_ #define INCLUDE_REFINMENTCRITERION_H_ -enum criterionType +enum RefinementCriterionFlags { - VALUE, - GRADIENT, - VALUE_AND_GRADIENT + criterion_default = 0, + criterion_value = 0x0001, + criterion_gradient = 0x0002 }; +// Function that enables bitwise OR between flags +inline RefinementCriterionFlags +operator|(const RefinementCriterionFlags f1, const RefinementCriterionFlags f2) +{ + return static_cast(static_cast(f1) | + static_cast(f2)); +} + +// Function that enables bitwise compound OR between flags +inline RefinementCriterionFlags & +operator|=(RefinementCriterionFlags &f1, const RefinementCriterionFlags f2) +{ + f1 = f1 | f2; + return f1; +} + +// Function that enables bitwise AND between flags +inline RefinementCriterionFlags +operator&(const RefinementCriterionFlags f1, const RefinementCriterionFlags f2) +{ + return static_cast(static_cast(f1) & + static_cast(f2)); +} + +// Function that enables bitwise compound AND between flags +inline RefinementCriterionFlags & +operator&=(RefinementCriterionFlags &f1, const RefinementCriterionFlags f2) +{ + f1 = f1 & f2; + return f1; +} + /** * This class holds information for a determining whether the mesh should be * refined. @@ -15,12 +47,12 @@ enum criterionType class RefinementCriterion { public: - std::string variable_name; - unsigned int variable_index; - criterionType criterion_type; - double value_lower_bound; - double value_upper_bound; - double gradient_lower_bound; + std::string variable_name; + unsigned int variable_index; + RefinementCriterionFlags criterion_type; + double value_lower_bound; + double value_upper_bound; + double gradient_lower_bound; }; #endif /* INCLUDE_REFINMENTCRITERION_H_ */ diff --git a/include/SimplifiedGrainRepresentation.h b/include/SimplifiedGrainRepresentation.h index 46eeb0fcb..6c3f1ebf6 100644 --- a/include/SimplifiedGrainRepresentation.h +++ b/include/SimplifiedGrainRepresentation.h @@ -133,7 +133,7 @@ class SimplifiedGrainManipulator void reassignGrains(std::vector> &grain_representations, double buffer_distance, - std::vector order_parameter_id_list); + std::vector &order_parameter_id_list); /** * This method checks the centers of two lists of diff --git a/include/initialConditions.h b/include/initialConditions.h index 543a066b7..0dfb332d3 100644 --- a/include/initialConditions.h +++ b/include/initialConditions.h @@ -32,7 +32,7 @@ class InitialCondition : public dealii::Function // IC for scalar values double - value(const dealii::Point &p, const unsigned int component = 0) const + value(const dealii::Point &p, const unsigned int component = 0) const override { double scalar_IC = 0.0; dealii::Vector vector_IC(dim); @@ -66,7 +66,8 @@ class InitialConditionVector : public dealii::Function // IC for vector values void - vector_value(const dealii::Point &p, dealii::Vector &vector_IC) const + vector_value(const dealii::Point &p, + dealii::Vector &vector_IC) const override { double scalar_IC = 0.0; vector_IC.reinit(dim); diff --git a/include/inputFileReader.h b/include/inputFileReader.h index 362b58b26..9364c5394 100644 --- a/include/inputFileReader.h +++ b/include/inputFileReader.h @@ -15,45 +15,45 @@ class inputFileReader { public: // Constructor - inputFileReader(std::string input_file_name, - variableAttributeLoader variable_attributes); + inputFileReader(const std::string &input_file_name, + variableAttributeLoader &variable_attributes); // Method to get a list of entry values from multiple subsections in an input // file std::vector - get_subsection_entry_list(const std::string parameters_file_name, - const std::string subsec_name, - const std::string entry_name, - const std::string default_entry) const; + get_subsection_entry_list(const std::string ¶meters_file_name, + const std::string &subsec_name, + const std::string &entry_name, + const std::string &default_entry) const; // Method to count the number of related entries in an input file unsigned int - get_number_of_entries(const std::string parameters_file_name, - const std::string keyword, - const std::string entry_name) const; + get_number_of_entries(const std::string ¶meters_file_name, + const std::string &keyword, + const std::string &entry_name) const; // Get the trailing part of the entry name after a specified string (used to // extract the model constant names) std::vector - get_entry_name_ending_list(const std::string parameters_file_name, - const std::string keyword, - const std::string entry_name_begining) const; + get_entry_name_ending_list(const std::string ¶meters_file_name, + const std::string &keyword, + const std::string &entry_name_begining) const; // Method to declare the parameters to be read from an input file void - declare_parameters(dealii::ParameterHandler ¶meter_handler, - const std::vector var_types, - const std::vector var_eq_types, - const unsigned int num_of_constants, - const std::vector) const; + declare_parameters(dealii::ParameterHandler ¶meter_handler, + const std::vector &var_types, + const std::vector &var_eq_types, + const unsigned int num_of_constants, + const std::vector &var_nucleates) const; // Method to check if a line has the desired contents and if so, extract it bool - parse_line(std::string line, - const std::string keyword, - const std::string entry_name, - std::string &out_string, - bool expect_equals_sign) const; + parse_line(std::string line, + const std::string &keyword, + const std::string &entry_name, + std::string &out_string, + bool expect_equals_sign) const; // Variables dealii::ParameterHandler parameter_handler; diff --git a/include/matrixFreePDE.h b/include/matrixFreePDE.h index 86d6075b4..27be76f2b 100644 --- a/include/matrixFreePDE.h +++ b/include/matrixFreePDE.h @@ -35,6 +35,7 @@ #include // PRISMS headers +#include "AdaptiveRefinement.h" #include "SimplifiedGrainRepresentation.h" #include "fields.h" #include "nucleus.h" @@ -44,20 +45,19 @@ #include "../src/models/mechanics/computeStress.h" +using namespace dealii; + // define data types #ifndef scalarType -typedef dealii::VectorizedArray scalarType; +typedef VectorizedArray scalarType; #endif #ifndef vectorType -typedef dealii::LinearAlgebra::distributed::Vector vectorType; +typedef LinearAlgebra::distributed::Vector vectorType; #endif // macro for constants #define constV(a) make_vectorized_array(a) -// -using namespace dealii; - // // base class for matrix free PDE's // @@ -128,19 +128,19 @@ class MatrixFreePDE : public Subscriptor // Initial conditions function virtual void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) = 0; + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) = 0; // Non-uniform boundary conditions function virtual void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) = 0; + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) = 0; protected: userInputParameters userInputs; @@ -262,30 +262,24 @@ class MatrixFreePDE : public Subscriptor void updateExplicitSolution(unsigned int fieldIndex); + /*Method to compute an implicit timestep*/ + bool + updateImplicitSolution(unsigned int fieldIndex, unsigned int nonlinear_it_index); + /*Method to apply boundary conditions*/ void applyBCs(unsigned int fieldIndex); - /*AMR methods*/ /** - * Method that actually changes the triangulation based on refine/coarsen - * flags set previously. + * \brief Compute element volume for the triangulation */ void - refineGrid(); + compute_element_volume(); /** - * Method to control the overall flow of adaptive mesh refinement. + * \brief Vector that stores element volumes */ - void - adaptiveRefine(unsigned int _currentIncrement); - - /** - * Virtual method to define the the criterion for refining or coarsening the - * mesh. This method sets refine/coarsen flags that are read by refineGrid. - */ - virtual void - adaptiveRefineCriterion(); + dealii::AlignedVector> element_volume; /*Method to compute the right hand side (RHS) residual vectors*/ void @@ -335,29 +329,37 @@ class MatrixFreePDE : public Subscriptor virtual void explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const = 0; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const = 0; virtual void nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const = 0; + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const = 0; virtual void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const = 0; + equationLHS([[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const = 0; virtual void postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const {}; + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const {}; void computePostProcessedFields(std::vector &postProcessedSet); void - getPostProcessedFields(const dealii::MatrixFree &data, + getPostProcessedFields(const MatrixFree &data, std::vector &dst, const std::vector &src, const std::pair &cell_range); @@ -365,7 +367,7 @@ class MatrixFreePDE : public Subscriptor // methods to apply dirichlet BC's /*Map of degrees of freedom to the corresponding Dirichlet boundary * conditions, if any.*/ - std::vector *> valuesDirichletSet; + std::vector *> valuesDirichletSet; /*Virtual method to mark the boundaries for applying Dirichlet boundary * conditions. This is usually expected to be provided by the user.*/ void @@ -383,12 +385,21 @@ class MatrixFreePDE : public Subscriptor setPeriodicity(); void setPeriodicityConstraints(AffineConstraints *, const DoFHandler *) const; + + /** + * \brief Set constraints to pin the solution to 0 at a certain vertex. This is + * automatically done at the origin if no value terms are detected in your dependencies + * in a time_independent or implicit solve. + * + * \param constraints The constraint set. + * \param dof_handler The list of the degrees of freedom. + * \param target_point The point where the solution is constrained. This is the origin + * by default. + */ void - getComponentsWithRigidBodyModes(std::vector &) const; - void - setRigidBodyModeConstraints(const std::vector, - AffineConstraints *, - const DoFHandler *) const; + set_rigid_body_mode_constraints(AffineConstraints *constraints, + const DoFHandler *dof_handler, + const Point target_point = Point()) const; // methods to apply initial conditions /*Virtual method to apply initial conditions. This is usually expected to be @@ -415,7 +426,7 @@ class MatrixFreePDE : public Subscriptor move_file(const std::string &, const std::string &); void - verify_checkpoint_file_exists(const std::string filename); + verify_checkpoint_file_exists(const std::string &filename); // -------------------------------------------------------------------------- // Nucleation methods and variables @@ -436,24 +447,23 @@ class MatrixFreePDE : public Subscriptor void refineMeshNearNuclei(std::vector> newnuclei); double - weightedDistanceFromNucleusCenter(const dealii::Point center, - const std::vector semiaxes, - const dealii::Point q_point_loc, - const unsigned int var_index) const; - dealii::VectorizedArray - weightedDistanceFromNucleusCenter( - const dealii::Point center, - const std::vector semiaxes, - const dealii::Point> q_point_loc, - const unsigned int var_index) const; + weightedDistanceFromNucleusCenter(const Point center, + const std::vector &semiaxes, + const Point q_point_loc, + const unsigned int var_index) const; + VectorizedArray + weightedDistanceFromNucleusCenter(const Point center, + const std::vector &semiaxes, + const Point> q_point_loc, + const unsigned int var_index) const; // Method to obtain the nucleation probability for an element, nontrival case // must be implemented in the subsclass virtual double getNucleationProbability(variableValueContainer, double, - dealii::Point, - unsigned int variable_index) const + Point, + [[maybe_unused]] unsigned int variable_index) const { return 0.0; }; @@ -482,7 +492,6 @@ class MatrixFreePDE : public Subscriptor bool hasExplicitEquation; bool hasNonExplicitEquation; // - unsigned int parabolicFieldIndex, ellipticFieldIndex; double currentTime; unsigned int currentIncrement, currentOutput, currentCheckpoint, current_grain_reassignment; @@ -499,16 +508,8 @@ class MatrixFreePDE : public Subscriptor unsigned int integral_index; std::mutex assembler_lock; - void - computeIntegralMF(double &integratedField, - int index, - const std::vector postProcessedSet); - - void - getIntegralMF(const MatrixFree &data, - std::vector &dst, - const std::vector &src, - const std::pair &cell_range); + /*AMR methods*/ + AdaptiveRefinement AMR; }; #endif diff --git a/include/matrixFreePDE_template_instantiations.h b/include/matrixFreePDE_template_instantiations.h index 9f4d87488..05789f31b 100644 --- a/include/matrixFreePDE_template_instantiations.h +++ b/include/matrixFreePDE_template_instantiations.h @@ -10,14 +10,24 @@ #ifndef MATRIXFREEPDE_TEMPLATE_INSTANTIATION # define MATRIXFREEPDE_TEMPLATE_INSTANTIATION + template class MatrixFreePDE<2, 1>; template class MatrixFreePDE<3, 1>; + template class MatrixFreePDE<2, 2>; template class MatrixFreePDE<3, 2>; + template class MatrixFreePDE<3, 3>; template class MatrixFreePDE<2, 3>; + template class MatrixFreePDE<3, 4>; template class MatrixFreePDE<2, 4>; + +template class MatrixFreePDE<3, 5>; +template class MatrixFreePDE<2, 5>; + +template class MatrixFreePDE<3, 6>; +template class MatrixFreePDE<2, 6>; #endif #endif /* INCLUDE_MATRIXFREEPDE_TEMPLATE_INSTANTIATIONS_H_ */ diff --git a/include/model_variables.h b/include/model_variables.h index ff299db04..6f3da0c2e 100644 --- a/include/model_variables.h +++ b/include/model_variables.h @@ -5,6 +5,7 @@ #include #include +#include template class modelVariable @@ -32,15 +33,11 @@ class modelResidual struct variable_info { - bool is_scalar; - unsigned int scalar_or_vector_index; - unsigned int global_var_index; - bool need_value; - bool need_gradient; - bool need_hessian; - bool value_residual; - bool gradient_residual; - bool var_needed; + bool is_scalar; + unsigned int global_var_index; + dealii::EvaluationFlags::EvaluationFlags evaluation_flags; + dealii::EvaluationFlags::EvaluationFlags residual_flags; + bool var_needed; }; #endif /* INCLUDE_MODELVARIABLE_H_ */ diff --git a/include/nonUniformDirichletBC.h b/include/nonUniformDirichletBC.h index 1729006e4..a14e3d0f5 100644 --- a/include/nonUniformDirichletBC.h +++ b/include/nonUniformDirichletBC.h @@ -25,7 +25,7 @@ class NonUniformDirichletBC : public dealii::Function // IC for scalar values double - value(const dealii::Point &p, const unsigned int component = 0) const + value(const dealii::Point &p, const unsigned int component = 0) const override { double scalar_BC = 0.0; dealii::Vector vector_BC(dim); @@ -64,7 +64,8 @@ class NonUniformDirichletBCVector : public dealii::Function // IC for vector values void - vector_value(const dealii::Point &p, dealii::Vector &vector_BC) const + vector_value(const dealii::Point &p, + dealii::Vector &vector_BC) const override { double scalar_BC = 0.0; diff --git a/include/sortIndexEntryPairList.h b/include/sortIndexEntryPairList.h index c15e50557..71673f26e 100644 --- a/include/sortIndexEntryPairList.h +++ b/include/sortIndexEntryPairList.h @@ -10,23 +10,23 @@ std::vector sortIndexEntryPairList( - const std::vector> unsorted_pair_list, - unsigned int number_of_variables, - bool default_value); + const std::vector> &unsorted_pair_list, + unsigned int number_of_variables, + bool default_value); std::vector sortIndexEntryPairList( - const std::vector> unsorted_pair_list, - unsigned int number_of_variables, - std::string default_value); + const std::vector> &unsorted_pair_list, + unsigned int number_of_variables, + const std::string &default_value); std::vector sortIndexEntryPairList( - const std::vector> unsorted_pair_list, - unsigned int number_of_variables, - fieldType default_value); + const std::vector> &unsorted_pair_list, + unsigned int number_of_variables, + fieldType default_value); std::vector sortIndexEntryPairList( - const std::vector> unsorted_pair_list, - unsigned int number_of_variables, - PDEType default_value); + const std::vector> &unsorted_pair_list, + unsigned int number_of_variables, + PDEType default_value); #endif diff --git a/include/userInputParameters.h b/include/userInputParameters.h index b9cccc756..92af67224 100644 --- a/include/userInputParameters.h +++ b/include/userInputParameters.h @@ -5,11 +5,14 @@ #define INCLUDE_USERINPUTPARAMETERS_H_ #include +#include +#include #include #include #include #include +#include #include #include "RefinementCriterion.h" @@ -47,49 +50,118 @@ class userInputParameters // Method to create the list of BCs from the user input strings (called from // the constructor) void - load_BC_list(const std::vector list_of_BCs); + load_BC_list(const std::vector &list_of_BCs); // Map linking the model constant name to its index std::unordered_map model_constant_name_map; - // Methods to access members of 'model_constant', one for each type (since one - // can't template based on return values) These are really just wrappers for - // Boost's 'get' function + /** + * \brief Retrieve the double from the `model_constants` that are defined from the + * parameters.prm parser. This is essentially just a wrapper for boost::get. + * + * \param constant_name Name of the constant to retrieve. + */ double get_model_constant_double(const std::string constant_name) const { + Assert(model_constant_name_map.find(constant_name) != model_constant_name_map.end(), + dealii::ExcMessage( + "PRISMS-PF Error: Mismatch between constants in parameters.prm and " + "customPDE.h. The constant that you attempted to access was " + + constant_name + ".")); + return boost::get(model_constants[model_constant_name_map.at(constant_name)]); }; + /** + * \brief Retrieve the int from the `model_constants` that are defined from the + * parameters.prm parser. This is essentially just a wrapper for boost::get. + * + * \param constant_name Name of the constant to retrieve. + */ int get_model_constant_int(const std::string constant_name) const { + Assert(model_constant_name_map.find(constant_name) != model_constant_name_map.end(), + dealii::ExcMessage( + "PRISMS-PF Error: Mismatch between constants in parameters.prm and " + "customPDE.h. The constant that you attempted to access was " + + constant_name + ".")); + return boost::get(model_constants[model_constant_name_map.at(constant_name)]); }; + /** + * \brief Retrieve the bool from the `model_constants` that are defined from the + * parameters.prm parser. This is essentially just a wrapper for boost::get. + * + * \param constant_name Name of the constant to retrieve. + */ bool get_model_constant_bool(const std::string constant_name) const { + Assert(model_constant_name_map.find(constant_name) != model_constant_name_map.end(), + dealii::ExcMessage( + "PRISMS-PF Error: Mismatch between constants in parameters.prm and " + "customPDE.h. The constant that you attempted to access was " + + constant_name + ".")); + return boost::get(model_constants[model_constant_name_map.at(constant_name)]); }; + /** + * \brief Retrieve the rank 1 tensor from the `model_constants` that are defined from + * the parameters.prm parser. This is essentially just a wrapper for boost::get. + * + * \param constant_name Name of the constant to retrieve. + */ dealii::Tensor<1, dim> get_model_constant_rank_1_tensor(const std::string constant_name) const { + Assert(model_constant_name_map.find(constant_name) != model_constant_name_map.end(), + dealii::ExcMessage( + "PRISMS-PF Error: Mismatch between constants in parameters.prm and " + "customPDE.h. The constant that you attempted to access was " + + constant_name + ".")); + return boost::get>( model_constants[model_constant_name_map.at(constant_name)]); }; + /** + * \brief Retrieve the rank 2 tensor from the `model_constants` that are defined from + * the parameters.prm parser. This is essentially just a wrapper for boost::get. + * + * \param constant_name Name of the constant to retrieve. + */ dealii::Tensor<2, dim> get_model_constant_rank_2_tensor(const std::string constant_name) const { + Assert(model_constant_name_map.find(constant_name) != model_constant_name_map.end(), + dealii::ExcMessage( + "PRISMS-PF Error: Mismatch between constants in parameters.prm and " + "customPDE.h. The constant that you attempted to access was " + + constant_name + ".")); + return boost::get>( model_constants[model_constant_name_map.at(constant_name)]); }; + /** + * \brief Retrieve the elasticity tensor from the `model_constants` that are defined + * from the parameters.prm parser. This is essentially just a wrapper for boost::get. + * + * \param constant_name Name of the constant to retrieve. + */ dealii::Tensor<2, 2 * dim - 1 + dim / 3> get_model_constant_elasticity_tensor(const std::string constant_name) const { + Assert(model_constant_name_map.find(constant_name) != model_constant_name_map.end(), + dealii::ExcMessage( + "PRISMS-PF Error: Mismatch between constants in parameters.prm and " + "customPDE.h. The constant that you attempted to access was " + + constant_name + ".")); + return boost::get>( model_constants[model_constant_name_map.at(constant_name)]); }; @@ -173,6 +245,9 @@ class userInputParameters // Nonlinear solver parameters NonlinearSolverParameters nonlinear_solver_parameters; + // Pinning point parameters + boost::unordered_map> pinned_point; + // Variable inputs (I might be able to leave some/all of these in // variable_attributes) unsigned int number_of_variables; @@ -259,7 +334,7 @@ class userInputParameters // Method to create the list of time steps where the results should be output // (called from loadInputParameters) std::vector - setTimeStepList(const std::string outputSpacingType, + setTimeStepList(const std::string &outputSpacingType, unsigned int numberOfOutputs, const std::vector &userGivenTimeStepList); @@ -269,11 +344,11 @@ class userInputParameters dealii::Tensor<2, 2 * dim - 1 + dim / 3> get_Cij_tensor(std::vector elastic_constants, - const std::string elastic_const_symmetry) const; + const std::string &elastic_const_symmetry) const; dealii::Tensor<2, 2 * dim - 1 + dim / 3> getCIJMatrix(const elasticityModel model, - const std::vector constants, + const std::vector &constants, dealii::ConditionalOStream &pcout) const; // Private nucleation variables diff --git a/include/variableContainer.h b/include/variableContainer.h index 0462984ac..e5a0fb9be 100644 --- a/include/variableContainer.h +++ b/include/variableContainer.h @@ -3,54 +3,35 @@ #ifndef VARIBLECONTAINER_H #define VARIBLECONTAINER_H +#include +#include +#include #include #include -#include "userInputParameters.h" +#include -// #include -// #include -#include - -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include +#include "userInputParameters.h" template class variableContainer { public: #include "typeDefs.h" - // Constructors // Standard contructor, used for most situations variableContainer(const dealii::MatrixFree &data, - std::vector _varInfoList, - std::vector _varChangeInfoList); + const std::vector &_varInfoList, + const std::vector &_varChangeInfoList); + variableContainer(const dealii::MatrixFree &data, - std::vector _varInfoList); + const std::vector &_varInfoList); // Nonstandard constructor, used when only one index of "data" should be used, // use with care! variableContainer(const dealii::MatrixFree &data, - std::vector _varInfoList, - unsigned int fixed_index); + const std::vector &_varInfoList, + const unsigned int &fixed_index); // Methods to get the value/grad/hess in the residual method (this is how the // user gets these values in equations.h) @@ -113,11 +94,6 @@ class variableContainer reinit_and_eval_change_in_solution(const vectorType &src, unsigned int cell, unsigned int var_being_solved); - void - reinit_and_eval_LHS(const vectorType &src, - const std::vector solutionSet, - unsigned int cell, - unsigned int var_being_solved); // Only initialize the FEEvaluation object for each variable (used for // post-processing) @@ -134,29 +110,34 @@ class variableContainer // The quadrature point index, a method to get the number of quadrature points // per cell, and a method to get the xyz coordinates for the quadrature point unsigned int q_point; + unsigned int - get_num_q_points(); + get_num_q_points() const; + dealii::Point - get_q_point_location(); + get_q_point_location() const; private: - // The number of variables - unsigned int num_var; - // Vectors of the actual FEEvaluation objects for each active variable, split // into scalar variables and vector variables for type reasons - std::vector> scalar_vars; - std::vector> vector_vars; + using scalar_FEEval = dealii::FEEvaluation; + using vector_FEEval = dealii::FEEvaluation; - std::vector> - scalar_change_in_vars; - std::vector> - vector_change_in_vars; + boost::unordered_map> scalar_vars_map; + boost::unordered_map> vector_vars_map; + + boost::unordered_map> + scalar_change_in_vars_map; + boost::unordered_map> + vector_change_in_vars_map; // Object containing some information about each variable (indices, whether // the val/grad/hess is needed, etc) std::vector varInfoList; std::vector varChangeInfoList; + + // The number of variables + unsigned int num_var; }; #endif diff --git a/include/vectorBCFunction.h b/include/vectorBCFunction.h index ff37903c6..d504c9116 100644 --- a/include/vectorBCFunction.h +++ b/include/vectorBCFunction.h @@ -18,11 +18,12 @@ class vectorBCFunction : public dealii::Function public: vectorBCFunction(const std::vector BC_values); virtual void - vector_value(const dealii::Point &p, dealii::Vector &values) const; + vector_value(const dealii::Point &p, + dealii::Vector &values) const override; virtual void vector_value_list(const std::vector> &points, - std::vector> &value_list) const; + std::vector> &value_list) const override; private: const std::vector BC_values; diff --git a/src/EquationDependencyParser/EquationDependencyParser.cc b/src/EquationDependencyParser/EquationDependencyParser.cc index 713e299f9..ba199ba84 100644 --- a/src/EquationDependencyParser/EquationDependencyParser.cc +++ b/src/EquationDependencyParser/EquationDependencyParser.cc @@ -1,175 +1,119 @@ #include "../../include/EquationDependencyParser.h" +#include #include #include void -EquationDependencyParser::parse(std::vector var_name, - std::vector var_eq_type, - std::vector sorted_dependencies_value_RHS, +EquationDependencyParser::strip_dependency_whitespace(std::string &dependency_list) +{ + dependency_list.erase(std::remove(dependency_list.begin(), dependency_list.end(), ' '), + dependency_list.end()); +} + +void +EquationDependencyParser::parse(std::vector &var_name, + std::vector var_eq_type, + std::vector sorted_dependencies_value_RHS, std::vector sorted_dependencies_gradient_RHS, std::vector sorted_dependencies_value_LHS, std::vector sorted_dependencies_gradient_LHS, std::vector &var_nonlinear) { - // Initialize the calculation needed flags to false - for (unsigned int i = 0; i < var_name.size(); i++) - { - need_value_explicit_RHS.push_back(false); - need_gradient_explicit_RHS.push_back(false); - need_hessian_explicit_RHS.push_back(false); - need_value_nonexplicit_RHS.push_back(false); - need_gradient_nonexplicit_RHS.push_back(false); - need_hessian_nonexplicit_RHS.push_back(false); - need_value_nonexplicit_LHS.push_back(false); - need_gradient_nonexplicit_LHS.push_back(false); - need_hessian_nonexplicit_LHS.push_back(false); - need_value_change_nonexplicit_LHS.push_back(false); - need_gradient_change_nonexplicit_LHS.push_back(false); - need_hessian_change_nonexplicit_LHS.push_back(false); - } + // Determine the number of variables + size_t n_variables = var_name.size(); + + // Resize the dependency evaluation flag vectors + eval_flags_explicit_RHS.resize(n_variables, dealii::EvaluationFlags::nothing); + eval_flags_nonexplicit_RHS.resize(n_variables, dealii::EvaluationFlags::nothing); + eval_flags_nonexplicit_LHS.resize(n_variables, dealii::EvaluationFlags::nothing); + eval_flags_change_nonexplicit_LHS.resize(n_variables, dealii::EvaluationFlags::nothing); + + // Resize the residual evaluation flag vectors + eval_flags_residual_explicit_RHS.resize(n_variables, dealii::EvaluationFlags::nothing); + eval_flags_residual_nonexplicit_RHS.resize(n_variables, + dealii::EvaluationFlags::nothing); + eval_flags_residual_nonexplicit_LHS.resize(n_variables, + dealii::EvaluationFlags::nothing); // Now parse the dependency strings to set the flags to true where needed for (unsigned int i = 0; i < var_name.size(); i++) { - // First strip excess whitespace - for (unsigned int j = 0; j < sorted_dependencies_value_RHS.at(i).length(); j++) - { - if (sorted_dependencies_value_RHS.at(i)[j] == ' ') - sorted_dependencies_value_RHS.at(i).erase(j, 1); - } - for (unsigned int j = 0; j < sorted_dependencies_gradient_RHS.at(i).length(); j++) - { - if (sorted_dependencies_gradient_RHS.at(i)[j] == ' ') - sorted_dependencies_gradient_RHS.at(i).erase(j, 1); - } + // Strip excess whitespace + strip_dependency_whitespace(sorted_dependencies_value_RHS[i]); + strip_dependency_whitespace(sorted_dependencies_gradient_RHS[i]); + // Now check for each variable_eq_type if (var_eq_type[i] == EXPLICIT_TIME_DEPENDENT) { - bool need_value_residual_entry, need_gradient_residual_entry, - single_var_nonlinear; + bool single_var_nonlinear; parseDependencyListRHS(var_name, var_eq_type, i, - sorted_dependencies_value_RHS.at(i), - sorted_dependencies_gradient_RHS.at(i), - need_value_explicit_RHS, - need_gradient_explicit_RHS, - need_hessian_explicit_RHS, - need_value_residual_entry, - need_gradient_residual_entry, + sorted_dependencies_value_RHS[i], + sorted_dependencies_gradient_RHS[i], + eval_flags_explicit_RHS, + eval_flags_residual_explicit_RHS, single_var_nonlinear); - // std::cout << "RHS Nonlinear flag for var " << i << " :" << - // single_var_nonlinear << std::endl; - var_nonlinear.push_back(single_var_nonlinear); - - need_value_residual_explicit_RHS.push_back(need_value_residual_entry); - need_gradient_residual_explicit_RHS.push_back(need_gradient_residual_entry); - - need_value_residual_nonexplicit_RHS.push_back(false); - need_gradient_residual_nonexplicit_RHS.push_back(false); - need_value_residual_nonexplicit_LHS.push_back(false); - need_gradient_residual_nonexplicit_LHS.push_back(false); } else if (var_eq_type[i] == AUXILIARY) { - bool need_value_residual_entry, need_gradient_residual_entry, - single_var_nonlinear; + bool single_var_nonlinear; parseDependencyListRHS(var_name, var_eq_type, i, - sorted_dependencies_value_RHS.at(i), - sorted_dependencies_gradient_RHS.at(i), - need_value_nonexplicit_RHS, - need_gradient_nonexplicit_RHS, - need_hessian_nonexplicit_RHS, - need_value_residual_entry, - need_gradient_residual_entry, + sorted_dependencies_value_RHS[i], + sorted_dependencies_gradient_RHS[i], + eval_flags_nonexplicit_RHS, + eval_flags_residual_nonexplicit_RHS, single_var_nonlinear); var_nonlinear.push_back(single_var_nonlinear); - - // std::cout << "RHS Nonlinear flag for var " << i << " :" << - // single_var_nonlinear << std::endl; - - need_value_residual_explicit_RHS.push_back(false); - need_gradient_residual_explicit_RHS.push_back(false); - - need_value_residual_nonexplicit_RHS.push_back(need_value_residual_entry); - need_gradient_residual_nonexplicit_RHS.push_back(need_gradient_residual_entry); - need_value_residual_nonexplicit_LHS.push_back(false); - need_gradient_residual_nonexplicit_LHS.push_back(false); } else if (var_eq_type[i] == IMPLICIT_TIME_DEPENDENT || var_eq_type[i] == TIME_INDEPENDENT) { - bool need_value_residual_entry, need_gradient_residual_entry, - single_var_nonlinear_RHS, single_var_nonlinear_LHS; + bool single_var_nonlinear_RHS, single_var_nonlinear_LHS; parseDependencyListRHS(var_name, var_eq_type, i, - sorted_dependencies_value_RHS.at(i), - sorted_dependencies_gradient_RHS.at(i), - need_value_nonexplicit_RHS, - need_gradient_nonexplicit_RHS, - need_hessian_nonexplicit_RHS, - need_value_residual_entry, - need_gradient_residual_entry, + sorted_dependencies_value_RHS[i], + sorted_dependencies_gradient_RHS[i], + eval_flags_nonexplicit_RHS, + eval_flags_residual_nonexplicit_RHS, single_var_nonlinear_RHS); - // std::cout << "RHS Nonlinear flag for var " << i << " :" << - // single_var_nonlinear_RHS << std::endl; - - need_value_residual_nonexplicit_RHS.push_back(need_value_residual_entry); - need_gradient_residual_nonexplicit_RHS.push_back(need_gradient_residual_entry); - parseDependencyListLHS(var_name, var_eq_type, i, - sorted_dependencies_value_LHS.at(i), - sorted_dependencies_gradient_LHS.at(i), - need_value_nonexplicit_LHS, - need_gradient_nonexplicit_LHS, - need_hessian_nonexplicit_LHS, - need_value_change_nonexplicit_LHS, - need_gradient_change_nonexplicit_LHS, - need_hessian_change_nonexplicit_LHS, - need_value_residual_entry, - need_gradient_residual_entry, + sorted_dependencies_value_LHS[i], + sorted_dependencies_gradient_LHS[i], + eval_flags_nonexplicit_LHS, + eval_flags_change_nonexplicit_LHS, + eval_flags_residual_nonexplicit_LHS, single_var_nonlinear_LHS); - // std::cout << "LHS Nonlinear flag for var " << i << " :" << - // single_var_nonlinear_LHS << std::endl; - var_nonlinear.push_back(single_var_nonlinear_RHS || single_var_nonlinear_LHS); - - need_value_residual_nonexplicit_LHS.push_back(need_value_residual_entry); - need_gradient_residual_nonexplicit_LHS.push_back(need_gradient_residual_entry); - - need_value_residual_explicit_RHS.push_back(false); - need_gradient_residual_explicit_RHS.push_back(false); } } } void -EquationDependencyParser::parseDependencyListRHS(std::vector var_name, - std::vector var_eq_type, - unsigned int var_index, - std::string value_dependencies, - std::string gradient_dependencies, - std::vector &need_value, - std::vector &need_gradient, - std::vector &need_hessian, - bool &need_value_residual, - bool &need_gradient_residual, - bool &is_nonlinear) +EquationDependencyParser::parseDependencyListRHS( + std::vector &variable_name_list, + std::vector variable_eq_type, + unsigned int variable_index, + std::string &value_dependencies, + std::string &gradient_dependencies, + std::vector &evaluation_flags, + std::vector &residual_flags, + bool &is_nonlinear) { // Split the dependency strings into lists of entries std::vector split_value_dependency_list = @@ -177,24 +121,15 @@ EquationDependencyParser::parseDependencyListRHS(std::vector var_na std::vector split_gradient_dependency_list = dealii::Utilities::split_string_list(gradient_dependencies); - // Check if either is empty and set need_value_residual and need_gradient + // Check if either is empty and set value and gradient flags for the // residual appropriately if (split_value_dependency_list.size() > 0) { - need_value_residual = true; + residual_flags[variable_index] |= dealii::EvaluationFlags::values; } - else - { - need_value_residual = false; - } - if (split_gradient_dependency_list.size() > 0) { - need_gradient_residual = true; - } - else - { - need_gradient_residual = false; + residual_flags[variable_index] |= dealii::EvaluationFlags::gradients; } // Merge the lists of dependency entries @@ -203,83 +138,91 @@ EquationDependencyParser::parseDependencyListRHS(std::vector var_na split_gradient_dependency_list.begin(), split_gradient_dependency_list.end()); - // Cycle through each dependency entry - // NOTE: This section is pretty confusing I think it needs refactoring or more - // comments + // Set nonlinearity to false is_nonlinear = false; - for (unsigned int dep = 0; dep < split_dependency_list.size(); dep++) - { - bool dependency_entry_assigned = false; - for (unsigned int var = 0; var < var_name.size(); var++) + // Cycle through each dependency entry + for (const auto &dependency : split_dependency_list) + { + // Flag to make sure we have assigned a dependency entry + [[maybe_unused]] bool dependency_entry_assigned = false; + + // Loop through all known variable names [x, grad(x), and hess(x)] to see which ones + // are on our dependency list. If we have two variables x and y this will loop twice + // to see if the supplied dependency needs either two of the variables. A successful + // match will update the values/gradient/hessian flag for that dependency variable. + std::size_t dependency_variable_index = 0; + for (const auto &variable : variable_name_list) { // Create grad() and hess() variants of the variable name - std::string grad_var_name = {"grad()"}; - grad_var_name.insert(--grad_var_name.end(), - var_name.at(var).begin(), - var_name.at(var).end()); + std::string gradient_variable = {"grad()"}; + gradient_variable.insert(--gradient_variable.end(), + variable.begin(), + variable.end()); + + std::string hessian_variable = {"hess()"}; + hessian_variable.insert(--hessian_variable.end(), + variable.begin(), + variable.end()); - std::string hess_var_name = {"hess()"}; - hess_var_name.insert(--hess_var_name.end(), - var_name.at(var).begin(), - var_name.at(var).end()); + // Is the variable we are finding the dependencies for explicit + bool variable_is_explicit = + variable_eq_type[variable_index] == EXPLICIT_TIME_DEPENDENT; - if (split_dependency_list.at(dep) == var_name.at(var)) + // Is the dependency variable explicit + bool dependency_variable_is_explicit = + variable_eq_type[dependency_variable_index] == EXPLICIT_TIME_DEPENDENT; + + // Is the dependency the variable + bool same_variable = variable_index == dependency_variable_index; + + // Case if the dependency is x + if (dependency == variable) { - need_value.at(var) = true; + evaluation_flags[dependency_variable_index] |= + dealii::EvaluationFlags::values; dependency_entry_assigned = true; - - if ((var_eq_type[var_index] != EXPLICIT_TIME_DEPENDENT) && - (var_index != var) && (var_eq_type[var] != EXPLICIT_TIME_DEPENDENT)) - { - is_nonlinear = true; - } } - else if (split_dependency_list.at(dep) == grad_var_name) + // Case if the dependency is grad(x) + else if (dependency == gradient_variable) { - need_gradient.at(var) = true; + evaluation_flags[dependency_variable_index] |= + dealii::EvaluationFlags::gradients; dependency_entry_assigned = true; - if ((var_eq_type[var_index] != EXPLICIT_TIME_DEPENDENT) && - (var_index != var) && (var_eq_type[var] != EXPLICIT_TIME_DEPENDENT)) - { - is_nonlinear = true; - } } - else if (split_dependency_list.at(dep) == hess_var_name) + // Case if the dependency is hess(x) + else if (dependency == hessian_variable) { - need_hessian.at(var) = true; + evaluation_flags[dependency_variable_index] |= + dealii::EvaluationFlags::hessians; dependency_entry_assigned = true; - if ((var_eq_type[var_index] != EXPLICIT_TIME_DEPENDENT) && - (var_index != var) && (var_eq_type[var] != EXPLICIT_TIME_DEPENDENT)) - { - is_nonlinear = true; - } } + + // Check for nonlinearity + is_nonlinear = + !variable_is_explicit && !same_variable && !dependency_variable_is_explicit; + + // Increment counter + ++dependency_variable_index; } - if (!dependency_entry_assigned) - { - std::cerr << "PRISMS-PF Error: Dependency entry " - << split_dependency_list.at(dep) << " is not valid." << std::endl; - abort(); - } + + Assert(dependency_entry_assigned, + dealii::StandardExceptions::ExcMessage("PRISMS-PF Error: Dependency entry " + + dependency + " is not valid.")); } } void -EquationDependencyParser::parseDependencyListLHS(std::vector var_name, - std::vector var_eq_type, - unsigned int var_index, - std::string value_dependencies, - std::string gradient_dependencies, - std::vector &need_value, - std::vector &need_gradient, - std::vector &need_hessian, - std::vector &need_value_change, - std::vector &need_gradient_change, - std::vector &need_hessian_change, - bool &need_value_residual, - bool &need_gradient_residual, - bool &is_nonlinear) +EquationDependencyParser::parseDependencyListLHS( + std::vector &variable_name_list, + std::vector variable_eq_type, + unsigned int variable_index, + std::string &value_dependencies, + std::string &gradient_dependencies, + std::vector &evaluation_flags, + std::vector &change_flags, + std::vector &residual_flags, + bool &is_nonlinear) { // Split the dependency strings into lists of entries std::vector split_value_dependency_list = @@ -287,24 +230,15 @@ EquationDependencyParser::parseDependencyListLHS(std::vector var_na std::vector split_gradient_dependency_list = dealii::Utilities::split_string_list(gradient_dependencies); - // Check if either is empty and set need_value_residual and need_gradient + // Check if either is empty and set value and gradient flags for the // residual appropriately if (split_value_dependency_list.size() > 0) { - need_value_residual = true; + residual_flags[variable_index] |= dealii::EvaluationFlags::values; } - else - { - need_value_residual = false; - } - if (split_gradient_dependency_list.size() > 0) { - need_gradient_residual = true; - } - else - { - need_gradient_residual = false; + residual_flags[variable_index] |= dealii::EvaluationFlags::gradients; } // Merge the lists of dependency entries @@ -313,181 +247,173 @@ EquationDependencyParser::parseDependencyListLHS(std::vector var_na split_gradient_dependency_list.begin(), split_gradient_dependency_list.end()); + // Set nonlinearity to false is_nonlinear = false; - for (unsigned int dep = 0; dep < split_dependency_list.size(); dep++) - { - bool dependency_entry_assigned = false; - for (unsigned int var = 0; var < var_name.size(); var++) + // Cycle through each dependency entry + for (const auto &dependency : split_dependency_list) + { + // Flag to make sure we have assigned a dependency entry + [[maybe_unused]] bool dependency_entry_assigned = false; + + // Loop through all known variable names [x, grad(x), and hess(x)] to see which ones + // are on our dependency list. If we have two variables x and y this will loop twice + // to see if the supplied dependency needs either two of the variables. A successful + // match will update the values/gradient/hessian flag for that dependency variable. + std::size_t dependency_variable_index = 0; + for (const auto &variable : variable_name_list) { - std::string grad_var_name = {"grad()"}; - grad_var_name.insert(--grad_var_name.end(), - var_name.at(var).begin(), - var_name.at(var).end()); - - std::string hess_var_name = {"hess()"}; - hess_var_name.insert(--hess_var_name.end(), - var_name.at(var).begin(), - var_name.at(var).end()); - - std::string val_change_var_name = {"change()"}; - val_change_var_name.insert(--val_change_var_name.end(), - var_name.at(var).begin(), - var_name.at(var).end()); - - std::string grad_change_var_name = {"grad(change())"}; - grad_change_var_name.insert(--(--grad_change_var_name.end()), - var_name.at(var).begin(), - var_name.at(var).end()); - - std::string hess_change_var_name = {"hess(change())"}; - hess_change_var_name.insert(--(--hess_change_var_name.end()), - var_name.at(var).begin(), - var_name.at(var).end()); - - if (split_dependency_list.at(dep) == var_name.at(var)) + // Create grad(), hess(), change(), grad(change()), and hess(change()) variants + // of the variable name + std::string gradient_variable = {"grad()"}; + gradient_variable.insert(--gradient_variable.end(), + variable.begin(), + variable.end()); + + std::string hessian_variable = {"hess()"}; + hessian_variable.insert(--hessian_variable.end(), + variable.begin(), + variable.end()); + + std::string change_value_variable = {"change()"}; + change_value_variable.insert(--change_value_variable.end(), + variable.begin(), + variable.end()); + + std::string change_gradient_variable = {"grad(change())"}; + change_gradient_variable.insert(--(--change_gradient_variable.end()), + variable.begin(), + variable.end()); + + std::string change_hessian_variable = {"hess(change())"}; + change_hessian_variable.insert(--(--change_hessian_variable.end()), + variable.begin(), + variable.end()); + + // Is the variable we are finding the dependencies for explicit + bool dependency_variable_is_explicit = + variable_eq_type[dependency_variable_index] == EXPLICIT_TIME_DEPENDENT; + + // Case if the dependency is x + if (dependency == variable) { - need_value.at(var) = true; + evaluation_flags[dependency_variable_index] |= + dealii::EvaluationFlags::values; dependency_entry_assigned = true; - if ((var_eq_type[var] != EXPLICIT_TIME_DEPENDENT)) - { - is_nonlinear = true; - } + + // Check for nonlinearity + is_nonlinear = !dependency_variable_is_explicit; } - else if (split_dependency_list.at(dep) == grad_var_name) + // Case if the dependency is grad(x) + else if (dependency == gradient_variable) { - need_gradient.at(var) = true; + evaluation_flags[dependency_variable_index] |= + dealii::EvaluationFlags::gradients; dependency_entry_assigned = true; - if ((var_eq_type[var] != EXPLICIT_TIME_DEPENDENT)) - { - is_nonlinear = true; - } + + // Check for nonlinearity + is_nonlinear = !dependency_variable_is_explicit; } - else if (split_dependency_list.at(dep) == hess_var_name) + // Case if the dependency is hess(x) + else if (dependency == hessian_variable) { - need_hessian.at(var) = true; + evaluation_flags[dependency_variable_index] |= + dealii::EvaluationFlags::hessians; dependency_entry_assigned = true; - if ((var_eq_type[var] != EXPLICIT_TIME_DEPENDENT)) - { - is_nonlinear = true; - } + + // Check for nonlinearity + is_nonlinear = !dependency_variable_is_explicit; } - else if (split_dependency_list.at(dep) == val_change_var_name) + // Case if the dependency is change(x) + else if (dependency == change_value_variable) { - need_value_change.at(var) = true; + change_flags[dependency_variable_index] |= dealii::EvaluationFlags::values; dependency_entry_assigned = true; - if (var_index != var) - { - std::cerr << "PRISMS-PF Error: Dependency entry " - << split_dependency_list.at(dep) - << " is not valid because the change in a variable can " - "only be accessed in its own governing equation." - << std::endl; - abort(); - } + + Assert(variable_index == dependency_variable_index, + dealii::StandardExceptions::ExcMessage( + "PRISMS-PF Error: Dependency entry " + dependency + + " is not valid because the change in a variable can " + "only be accessed in its own governing equation.")); } - else if (split_dependency_list.at(dep) == grad_change_var_name) + // Case if the dependency is grad(change(x)) + else if (dependency == change_gradient_variable) { - need_gradient_change.at(var) = true; - dependency_entry_assigned = true; - if (var_index != var) - { - std::cerr << "PRISMS-PF Error: Dependency entry " - << split_dependency_list.at(dep) - << " is not valid because the change in a variable can " - "only be accessed in its own governing equation." - << std::endl; - abort(); - } + change_flags[dependency_variable_index] |= + dealii::EvaluationFlags::gradients; + dependency_entry_assigned = true; + + Assert(variable_index == dependency_variable_index, + dealii::StandardExceptions::ExcMessage( + "PRISMS-PF Error: Dependency entry " + dependency + + " is not valid because the change in a variable can " + "only be accessed in its own governing equation.")); } - else if (split_dependency_list.at(dep) == hess_change_var_name) + // Case if the dependency is hess(change(x)) + else if (dependency == change_hessian_variable) { - need_hessian_change.at(var) = true; - dependency_entry_assigned = true; - if (var_index != var) - { - std::cerr << "PRISMS-PF Error: Dependency entry " - << split_dependency_list.at(dep) - << " is not valid because the change in a variable can " - "only be accessed in its own governing equation." - << std::endl; - abort(); - } + change_flags[dependency_variable_index] |= + dealii::EvaluationFlags::hessians; + dependency_entry_assigned = true; + + Assert(variable_index == dependency_variable_index, + dealii::StandardExceptions::ExcMessage( + "PRISMS-PF Error: Dependency entry " + dependency + + " is not valid because the change in a variable can " + "only be accessed in its own governing equation.")); } + + // Increment counter + ++dependency_variable_index; } - if (!dependency_entry_assigned) - { - std::cerr << "PRISMS-PF Error: Dependency entry " - << split_dependency_list.at(dep) << " is not valid." << std::endl; - abort(); - } + + Assert(dependency_entry_assigned, + dealii::StandardExceptions::ExcMessage("PRISMS-PF Error: Dependency entry " + + dependency + " is not valid.")); } } void -EquationDependencyParser::pp_parse(std::vector var_name, - std::vector pp_var_name, - std::vector sorted_dependencies_value, - std::vector sorted_dependencies_gradient) +EquationDependencyParser::pp_parse(std::vector &var_name, + std::vector &pp_var_name, + std::vector sorted_dependencies_value, + std::vector sorted_dependencies_gradient) { - // Initialize the calculation needed flags to false - for (unsigned int i = 0; i < var_name.size(); i++) - { - pp_need_value.push_back(false); - pp_need_gradient.push_back(false); - pp_need_hessian.push_back(false); - } + // Determine the number of variables + size_t n_variables = var_name.size(); + size_t n_postprocess_variables = pp_var_name.size(); - // Delete whitespace in the dependencies - for (unsigned int i = 0; i < pp_var_name.size(); i++) - { - if (sorted_dependencies_value.size() > 0) - { - for (unsigned int j = 0; j < sorted_dependencies_value.at(i).length(); j++) - { - if (sorted_dependencies_value.at(i)[j] == ' ') - sorted_dependencies_value.at(i).erase(j, 1); - } - } + // Resize the dependency evaluation flag vectors + eval_flags_postprocess.resize(n_variables, dealii::EvaluationFlags::nothing); - if (sorted_dependencies_gradient.size() > 0) - { - for (unsigned int j = 0; j < sorted_dependencies_gradient.at(i).length(); j++) - { - if (sorted_dependencies_gradient.at(i)[j] == ' ') - sorted_dependencies_gradient.at(i).erase(j, 1); - } - } - } + // Resize the residual evaluation flag vectors + eval_flags_residual_postprocess.resize(n_postprocess_variables, + dealii::EvaluationFlags::nothing); // Now parse the dependency strings to set the flags to true where needed for (unsigned int i = 0; i < pp_var_name.size(); i++) { - bool need_value_residual_entry, need_gradient_residual_entry; + // Strip excess whitespace + strip_dependency_whitespace(sorted_dependencies_value[i]); + strip_dependency_whitespace(sorted_dependencies_gradient[i]); parseDependencyListPP(var_name, - sorted_dependencies_value.at(i), - sorted_dependencies_gradient.at(i), - pp_need_value, - pp_need_gradient, - pp_need_hessian, - need_value_residual_entry, - need_gradient_residual_entry); - - pp_need_value_residual.push_back(need_value_residual_entry); - pp_need_gradient_residual.push_back(need_gradient_residual_entry); + i, + sorted_dependencies_value[i], + sorted_dependencies_gradient[i], + eval_flags_postprocess, + eval_flags_residual_postprocess); } } void -EquationDependencyParser::parseDependencyListPP(std::vector var_name, - std::string value_dependencies, - std::string gradient_dependencies, - std::vector &need_value, - std::vector &need_gradient, - std::vector &need_hessian, - bool &need_value_residual, - bool &need_gradient_residual) +EquationDependencyParser::parseDependencyListPP( + std::vector &variable_name_list, + unsigned int variable_index, + std::string &value_dependencies, + std::string &gradient_dependencies, + std::vector &evaluation_flags, + std::vector &residual_flags) { // Split the dependency strings into lists of entries std::vector split_value_dependency_list = @@ -495,84 +421,72 @@ EquationDependencyParser::parseDependencyListPP(std::vector var_nam std::vector split_gradient_dependency_list = dealii::Utilities::split_string_list(gradient_dependencies); - // Check if either is empty and set need_value_residual and need_gradient + // Check if either is empty and set value and gradient flags for the // residual appropriately if (split_value_dependency_list.size() > 0) { - need_value_residual = true; - } - else - { - need_value_residual = false; + residual_flags[variable_index] |= dealii::EvaluationFlags::values; } - if (split_gradient_dependency_list.size() > 0) { - need_gradient_residual = true; - } - else - { - need_gradient_residual = false; + residual_flags[variable_index] |= dealii::EvaluationFlags::gradients; } // Merge the lists of dependency entries - /* std::vector split_dependency_list = split_value_dependency_list; - split_dependency_list.insert(split_dependency_list.end(),split_gradient_dependency_list.begin(),split_gradient_dependency_list.end()); - */ - - std::vector split_dependency_list; - if (need_value_residual) - { - split_dependency_list = split_value_dependency_list; - split_dependency_list.insert(split_dependency_list.end(), - split_gradient_dependency_list.begin(), - split_gradient_dependency_list.end()); - } - else - { - split_dependency_list = split_gradient_dependency_list; - } + split_dependency_list.insert(split_dependency_list.end(), + split_gradient_dependency_list.begin(), + split_gradient_dependency_list.end()); // Cycle through each dependency entry - for (unsigned int dep = 0; dep < split_dependency_list.size(); dep++) + for (const auto &dependency : split_dependency_list) { - bool dependency_entry_assigned = false; - - for (unsigned int var = 0; var < var_name.size(); var++) + // Flag to make sure we have assigned a dependency entry + [[maybe_unused]] bool dependency_entry_assigned = false; + + // Loop through all known variable names [x, grad(x), and hess(x)] to see which ones + // are on our dependency list. If we have two variables x and y this will loop twice + // to see if the supplied dependency needs either two of the variables. A successful + // match will update the values/gradient/hessian flag for that dependency variable. + std::size_t dependency_variable_index = 0; + for (const auto &variable : variable_name_list) { // Create grad() and hess() variants of the variable name - std::string grad_var_name = {"grad()"}; - grad_var_name.insert(--grad_var_name.end(), - var_name.at(var).begin(), - var_name.at(var).end()); + std::string gradient_variable = {"grad()"}; + gradient_variable.insert(--gradient_variable.end(), + variable.begin(), + variable.end()); - std::string hess_var_name = {"hess()"}; - hess_var_name.insert(--hess_var_name.end(), - var_name.at(var).begin(), - var_name.at(var).end()); + std::string hessian_variable = {"hess()"}; + hessian_variable.insert(--hessian_variable.end(), + variable.begin(), + variable.end()); - if (split_dependency_list.at(dep) == var_name.at(var)) + if (dependency == variable) { - need_value.at(var) = true; + evaluation_flags[dependency_variable_index] |= + dealii::EvaluationFlags::values; dependency_entry_assigned = true; } - else if (split_dependency_list.at(dep) == grad_var_name) + else if (dependency == gradient_variable) { - need_gradient.at(var) = true; + evaluation_flags[dependency_variable_index] |= + dealii::EvaluationFlags::gradients; dependency_entry_assigned = true; } - else if (split_dependency_list.at(dep) == hess_var_name) + else if (dependency == hessian_variable) { - need_hessian.at(var) = true; + evaluation_flags[dependency_variable_index] |= + dealii::EvaluationFlags::hessians; dependency_entry_assigned = true; } + + // Increment counter + ++dependency_variable_index; } - if (!dependency_entry_assigned) - { - std::cerr << "PRISMS-PF Error: Dependency entry " - << split_dependency_list.at(dep) << " is not valid." << std::endl; - abort(); - } + + Assert(dependency_entry_assigned, + dealii::StandardExceptions::ExcMessage("PRISMS-PF Error: Dependency entry " + + dependency + " is not valid.")); } } diff --git a/src/FloodFiller/FloodFiller.cc b/src/FloodFiller/FloodFiller.cc index 2bfa8b8e3..f292fc66d 100644 --- a/src/FloodFiller/FloodFiller.cc +++ b/src/FloodFiller/FloodFiller.cc @@ -9,6 +9,7 @@ FloodFiller::calcGrainSets(dealii::FESystem &fe, vectorType *solution_field, double threshold_lower, double threshold_upper, + int min_id, unsigned int order_parameter_index, std::vector> &grain_sets) { @@ -40,6 +41,7 @@ FloodFiller::calcGrainSets(dealii::FESystem &fe, solution_field, threshold_lower, threshold_upper, + min_id, grain_index, grain_sets, grain_assigned); @@ -63,16 +65,15 @@ FloodFiller::calcGrainSets(dealii::FESystem &fe, grain_sets.pop_back(); } - // Generate global list of the grains, merging grains split between multiple - // processors + // Generate global list of the grains & send the grain set info to all processors so + // everyone has the full list if (dealii::Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD) > 1) { - // Send the grain set info to all processors so everyone has the full list createGlobalGrainSetList(grain_sets); - - // Merge grains that are split across processors - mergeSplitGrains(grain_sets); } + + // Merge grains sharing common vertices + mergeSplitGrains(grain_sets); } template @@ -83,6 +84,7 @@ FloodFiller::recursiveFloodFill(T di, vectorType *solution_field, double threshold_lower, double threshold_upper, + int min_id, unsigned int &grain_index, std::vector> &grain_sets, bool &grain_assigned) @@ -104,6 +106,7 @@ FloodFiller::recursiveFloodFill(T di, solution_field, threshold_lower, threshold_upper, + min_id, grain_index, grain_sets, grain_assigned); @@ -131,7 +134,10 @@ FloodFiller::recursiveFloodFill(T di, { // Add the number of times that var_values[q_point] has // been seen - ++quadratureValues[var_values[q_point]]; + if (var_values[q_point] > min_id) + { + ++quadratureValues[var_values[q_point]]; + } if (quadratureValues[var_values[q_point]] > maxNumberSeen) { maxNumberSeen = quadratureValues[var_values[q_point]]; @@ -161,6 +167,7 @@ FloodFiller::recursiveFloodFill(T di, solution_field, threshold_lower, threshold_upper, + min_id, grain_index, grain_sets, grain_assigned); @@ -181,7 +188,6 @@ FloodFiller::createGlobalGrainSetList( std::vector> &grain_sets) const { int numProcs = dealii::Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); - int thisProc = dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); unsigned int num_grains_local = grain_sets.size(); @@ -402,10 +408,19 @@ FloodFiller::mergeSplitGrains(std::vector> &grain_set // Template instantiations template class FloodFiller<2, 1>; -template class FloodFiller<2, 2>; -template class FloodFiller<2, 3>; -template class FloodFiller<2, 4>; template class FloodFiller<3, 1>; + +template class FloodFiller<2, 2>; template class FloodFiller<3, 2>; + +template class FloodFiller<2, 3>; template class FloodFiller<3, 3>; + +template class FloodFiller<2, 4>; template class FloodFiller<3, 4>; + +template class FloodFiller<2, 5>; +template class FloodFiller<3, 5>; + +template class FloodFiller<2, 6>; +template class FloodFiller<3, 6>; diff --git a/src/OrderParameterRemapper/OrderParameterRemapper.cc b/src/OrderParameterRemapper/OrderParameterRemapper.cc index 3d62cee45..ec67ec959 100644 --- a/src/OrderParameterRemapper/OrderParameterRemapper.cc +++ b/src/OrderParameterRemapper/OrderParameterRemapper.cc @@ -17,17 +17,14 @@ OrderParameterRemapper::remap( double transfer_buffer = std::max(0.0, grain_representations.at(g).getDistanceToNeighbor() / 2.0); - typename dealii::DoFHandler::active_cell_iterator di = - dof_handler.begin_active(); - // For now I have two loops, one where I copy the values from the old // order parameter to the new one and a second where I zero out the // old order parameter. This separation prevents writing zero-out // values to the new order parameter. There probably is a more // efficient way of doing this. - while (di != dof_handler.end()) + for (const auto &dof : dof_handler.active_cell_iterators()) { - if (di->is_locally_owned()) + if (dof->is_locally_owned()) { unsigned int op_new = grain_representations.at(g).getOrderParameterId(); unsigned int op_old = @@ -40,7 +37,7 @@ OrderParameterRemapper::remap( v < dealii::GeometryInfo::vertices_per_cell; v++) { - if (di->vertex(v).distance( + if (dof->vertex(v).distance( grain_representations.at(g).getCenter()) > grain_representations.at(g).getRadius() + transfer_buffer) { @@ -56,24 +53,20 @@ OrderParameterRemapper::remap( std::vector dof_indices( dofs_per_cell, 0); - di->get_dof_indices(dof_indices); - for (unsigned int i = 0; i < dof_indices.size(); i++) + dof->get_dof_indices(dof_indices); + for (const auto &index : dof_indices) { - (*solution_fields.at(op_new))[dof_indices.at(i)] = - (*solution_fields.at(op_old))[dof_indices.at(i)]; + (*solution_fields.at(op_new))[index] = + (*solution_fields.at(op_old))[index]; } } } - ++di; } - di = dof_handler.begin_active(); - - while (di != dof_handler.end()) + for (const auto &dof : dof_handler.active_cell_iterators()) { - if (di->is_locally_owned()) + if (dof->is_locally_owned()) { - unsigned int op_new = grain_representations.at(g).getOrderParameterId(); unsigned int op_old = grain_representations.at(g).getOldOrderParameterId(); @@ -84,7 +77,7 @@ OrderParameterRemapper::remap( v < dealii::GeometryInfo::vertices_per_cell; v++) { - if (di->vertex(v).distance( + if (dof->vertex(v).distance( grain_representations.at(g).getCenter()) > grain_representations.at(g).getRadius() + transfer_buffer) { @@ -99,15 +92,14 @@ OrderParameterRemapper::remap( std::vector dof_indices( dofs_per_cell, 0); - di->get_dof_indices(dof_indices); + dof->get_dof_indices(dof_indices); - for (unsigned int i = 0; i < dof_indices.size(); i++) + for (const auto &index : dof_indices) { - (*solution_fields.at(op_old))[dof_indices.at(i)] = 0.0; + (*solution_fields.at(op_old))[index] = 0.0; } } } - ++di; } } } @@ -133,27 +125,23 @@ OrderParameterRemapper::remap_from_index_field( double transfer_buffer = std::max(0.0, grain_representations.at(g).getDistanceToNeighbor() / 2.0); - typename dealii::DoFHandler::active_cell_iterator di = - dof_handler.begin_active(); - // For now I have two loops, one where I copy the values from the old // order parameter to the new one and a second where I zero out the old // order parameter. This separation prevents writing zero-out values to // the new order parameter. There probably is a more efficient way of // doing this. - while (di != dof_handler.end()) + for (const auto &dof : dof_handler.active_cell_iterators()) { - if (di->is_locally_owned()) + if (dof->is_locally_owned()) { unsigned int op_new = grain_representations.at(g).getOrderParameterId(); - unsigned int op_old = grain_representations.at(g).getOldOrderParameterId(); // Check if the cell is within the simplified grain representation bool in_grain = true; for (unsigned int v = 0; v < dealii::GeometryInfo::vertices_per_cell; v++) { - if (di->vertex(v).distance(grain_representations.at(g).getCenter()) > + if (dof->vertex(v).distance(grain_representations.at(g).getCenter()) > grain_representations.at(g).getRadius() + transfer_buffer) { in_grain = false; @@ -167,19 +155,18 @@ OrderParameterRemapper::remap_from_index_field( { std::vector dof_indices(dofs_per_cell, 0); - di->get_dof_indices(dof_indices); - for (unsigned int i = 0; i < dof_indices.size(); i++) + dof->get_dof_indices(dof_indices); + for (const auto &index : dof_indices) { - if (std::abs((*grain_index_field)[dof_indices.at(i)] - + if (std::abs((*grain_index_field)[index] - (double) grain_representations.at(g).getGrainId()) < 1e-6) { - (*solution_fields.at(op_new))[dof_indices.at(i)] = 1.0; + (*solution_fields.at(op_new))[index] = 1.0; } } } } - ++di; } } } diff --git a/src/SimplifiedGrainRepresentation/SimplifiedGrainRepresentation.cc b/src/SimplifiedGrainRepresentation/SimplifiedGrainRepresentation.cc index bc68f9260..67c49d2df 100644 --- a/src/SimplifiedGrainRepresentation/SimplifiedGrainRepresentation.cc +++ b/src/SimplifiedGrainRepresentation/SimplifiedGrainRepresentation.cc @@ -145,10 +145,8 @@ void SimplifiedGrainManipulator::reassignGrains( std::vector> &grain_representations, double buffer_distance, - std::vector order_parameter_id_list) + std::vector &order_parameter_id_list) { - int thisProc = dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); - for (int cycle = order_parameter_id_list.size(); cycle >= 0; cycle--) { for (unsigned int g_base = 0; g_base < grain_representations.size(); g_base++) diff --git a/src/inputFileReader/inputFileReader.cc b/src/inputFileReader/inputFileReader.cc index f541022c9..5290efbeb 100644 --- a/src/inputFileReader/inputFileReader.cc +++ b/src/inputFileReader/inputFileReader.cc @@ -10,8 +10,8 @@ #include // Constructor -inputFileReader::inputFileReader(std::string input_file_name, - variableAttributeLoader variable_attributes) +inputFileReader::inputFileReader(const std::string &input_file_name, + variableAttributeLoader &variable_attributes) { // Extract an ordered vector of the variable types from variable_attributes unsigned int number_of_variables = variable_attributes.var_name_list.size(); @@ -54,11 +54,11 @@ inputFileReader::inputFileReader(std::string input_file_name, // Method to parse a single line to find a target key value pair bool -inputFileReader::parse_line(std::string line, - const std::string keyword, - const std::string entry_name, - std::string &out_string, - const bool expect_equals_sign) const +inputFileReader::parse_line(std::string line, + const std::string &keyword, + const std::string &entry_name, + std::string &out_string, + const bool expect_equals_sign) const { // Strip spaces at the front and back while ((line.size() > 0) && (line[0] == ' ' || line[0] == '\t')) @@ -127,10 +127,10 @@ inputFileReader::parse_line(std::string line, // Method to parse an input file to get a list of variables from related // subsections std::vector -inputFileReader::get_subsection_entry_list(const std::string parameters_file_name, - const std::string subsec_name, - const std::string entry_name, - const std::string default_entry) const +inputFileReader::get_subsection_entry_list(const std::string ¶meters_file_name, + const std::string &subsec_name, + const std::string &entry_name, + const std::string &default_entry) const { std::ifstream input_file; input_file.open(parameters_file_name); @@ -201,9 +201,9 @@ inputFileReader::get_subsection_entry_list(const std::string parameters_file_nam // Method to parse an input file to get a list of variables from related // subsections unsigned int -inputFileReader::get_number_of_entries(const std::string parameters_file_name, - const std::string keyword, - const std::string entry_name) const +inputFileReader::get_number_of_entries(const std::string ¶meters_file_name, + const std::string &keyword, + const std::string &entry_name) const { std::ifstream input_file; input_file.open(parameters_file_name); @@ -226,9 +226,9 @@ inputFileReader::get_number_of_entries(const std::string parameters_file_name, // Method to parse an input file to get a list of variables from related // subsections std::vector -inputFileReader::get_entry_name_ending_list(const std::string parameters_file_name, - const std::string keyword, - const std::string entry_name_begining) const +inputFileReader::get_entry_name_ending_list(const std::string ¶meters_file_name, + const std::string &keyword, + const std::string &entry_name_begining) const { std::ifstream input_file; input_file.open(parameters_file_name); @@ -271,11 +271,11 @@ inputFileReader::get_entry_name_ending_list(const std::string parameters_file_na } void -inputFileReader::declare_parameters(dealii::ParameterHandler ¶meter_handler, - const std::vector var_types, - const std::vector var_eq_types, - const unsigned int num_of_constants, - const std::vector var_nucleates) const +inputFileReader::declare_parameters(dealii::ParameterHandler ¶meter_handler, + const std::vector &var_types, + const std::vector &var_eq_types, + const unsigned int num_of_constants, + const std::vector &var_nucleates) const { // Declare all of the entries parameter_handler.declare_entry("Number of dimensions", @@ -555,12 +555,14 @@ inputFileReader::declare_parameters(dealii::ParameterHandler ¶meter_handl "The list of time steps to save checkpoints, used for the LIST type."); parameter_handler.declare_entry( "Number of checkpoints", - "1", + "0", dealii::Patterns::Integer(), "The number of checkpoints (or number of checkpoints per decade for the " "N_PER_DECADE type)."); - // Declare the boundary condition variables + /*---------------------- + | Boundary conditions + -----------------------*/ for (unsigned int i = 0; i < var_types.size(); i++) { if (var_types[i] == SCALAR) @@ -604,6 +606,31 @@ inputFileReader::declare_parameters(dealii::ParameterHandler ¶meter_handl } } + /*---------------------- + | Pinning point + -----------------------*/ + for (unsigned int i = 0; i < var_types.size(); i++) + { + std::string pinning_text = "Pinning point: "; + pinning_text.append(var_names.at(i)); + parameter_handler.enter_subsection(pinning_text); + { + parameter_handler.declare_entry("x", + "-1.0", + dealii::Patterns::Double(), + "X-coordinate of the point"); + parameter_handler.declare_entry("y", + "0.0", + dealii::Patterns::Double(), + "Y-coordinate of the point"); + parameter_handler.declare_entry("z", + "0.0", + dealii::Patterns::Double(), + "Z-coordinate of the point"); + } + parameter_handler.leave_subsection(); + } + // Declare the nucleation parameters parameter_handler.declare_entry( "Enable evolution before nucleation", diff --git a/src/matrixfree/AdaptiveRefinement.cc b/src/matrixfree/AdaptiveRefinement.cc new file mode 100644 index 000000000..e618bd4ee --- /dev/null +++ b/src/matrixfree/AdaptiveRefinement.cc @@ -0,0 +1,186 @@ +#include "../../include/AdaptiveRefinement.h" + +using namespace dealii; + +template +AdaptiveRefinement::AdaptiveRefinement( + const userInputParameters &_userInputs, + parallel::distributed::Triangulation &_triangulation, + std::vector> &_fields, + std::vector &_solutionSet, + std::vector *> &_soltransSet, + std::vector *> &_FESet, + std::vector *> &_dofHandlersSet_nonconst, + std::vector *> &_constraintsDirichletSet, + std::vector *> &_constraintsOtherSet) + : userInputs(_userInputs) + , triangulation(_triangulation) + , fields(_fields) + , solutionSet(_solutionSet) + , soltransSet(_soltransSet) + , FESet(_FESet) + , dofHandlersSet_nonconst(_dofHandlersSet_nonconst) + , constraintsDirichletSet(_constraintsDirichletSet) + , constraintsOtherSet(_constraintsOtherSet) +{} + +template +void +AdaptiveRefinement::do_adaptive_refinement(unsigned int currentIncrement) +{ + // Apply constraints for the initial condition so they are considered when remeshing + if (currentIncrement != 0) + { + for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) + { + constraintsDirichletSet[fieldIndex]->distribute(*solutionSet[fieldIndex]); + constraintsOtherSet[fieldIndex]->distribute(*solutionSet[fieldIndex]); + solutionSet[fieldIndex]->update_ghost_values(); + } + } + + adaptive_refinement_criterion(); + refine_grid(); +} + +template +void +AdaptiveRefinement::adaptive_refinement_criterion() +{ + QGaussLobatto quadrature(degree + 1); + const unsigned int num_quad_points = quadrature.size(); + + // Set the update flags + dealii::UpdateFlags update_flags = update_default; + for (const auto &criterion : userInputs.refinement_criteria) + { + if (criterion.criterion_type & criterion_value) + { + update_flags |= update_values; + } + else if (criterion.criterion_type & criterion_gradient) + { + update_flags |= update_gradients; + } + } + + FEValues fe_values(*FESet[userInputs.refinement_criteria[0].variable_index], + quadrature, + update_flags); + + std::vector values(num_quad_points); + std::vector gradient_magnitudes(num_quad_points); + std::vector> gradients(num_quad_points); + + typename parallel::distributed::Triangulation::active_cell_iterator t_cell = + triangulation.begin_active(); + + for (const auto &cell : + dofHandlersSet_nonconst[userInputs.refinement_criteria[0].variable_index] + ->active_cell_iterators()) + { + if (cell->is_locally_owned()) + { + fe_values.reinit(cell); + + bool mark_refine = false; + + // Loop through the refinement criteria to determine whether a cell needs to be + // refined or coarsened + for (const auto &criterion : userInputs.refinement_criteria) + { + // Get the values and/or gradients + if (update_values & update_flags) + { + fe_values.get_function_values(*solutionSet[criterion.variable_index], + values); + } + if (update_gradients & update_flags) + { + fe_values.get_function_gradients(*solutionSet[criterion.variable_index], + gradients); + + for (unsigned int q_point = 0; q_point < num_quad_points; ++q_point) + { + gradient_magnitudes[q_point] = gradients[q_point].norm(); + } + } + + // Loop through the quadrature points and determine if the cell needs to be + // refined + for (unsigned int q_point = 0; q_point < num_quad_points; ++q_point) + { + if (criterion.criterion_type & criterion_value && + values[q_point] > criterion.value_lower_bound && + values[q_point] < criterion.value_upper_bound) + { + mark_refine = true; + break; + } + if (criterion.criterion_type & criterion_gradient && + gradient_magnitudes[q_point] > criterion.gradient_lower_bound) + { + mark_refine = true; + break; + } + } + + // Early exit for when there are multiple refinement criteria + if (mark_refine) + { + break; + } + } + + // Limit the max and min refinement depth of the mesh + unsigned int current_level = t_cell->level(); + + if ((mark_refine && current_level < userInputs.max_refinement_level)) + { + cell->set_refine_flag(); + } + else if (!mark_refine && current_level > userInputs.min_refinement_level) + { + cell->set_coarsen_flag(); + } + } + ++t_cell; + } +} + +template +void +AdaptiveRefinement::refine_grid() +{ + // Prepare for refinement + triangulation.prepare_coarsening_and_refinement(); + + // Transfer solution + for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) + { + soltransSet[fieldIndex]->prepare_for_coarsening_and_refinement( + *solutionSet[fieldIndex]); + } + + // Execute refinement + triangulation.execute_coarsening_and_refinement(); +} + +// Explicit instantiation +template class AdaptiveRefinement<2, 1>; +template class AdaptiveRefinement<3, 1>; + +template class AdaptiveRefinement<2, 2>; +template class AdaptiveRefinement<3, 2>; + +template class AdaptiveRefinement<2, 3>; +template class AdaptiveRefinement<3, 3>; + +template class AdaptiveRefinement<2, 4>; +template class AdaptiveRefinement<3, 4>; + +template class AdaptiveRefinement<2, 5>; +template class AdaptiveRefinement<3, 5>; + +template class AdaptiveRefinement<2, 6>; +template class AdaptiveRefinement<3, 6>; \ No newline at end of file diff --git a/src/matrixfree/boundaryConditions.cc b/src/matrixfree/boundaryConditions.cc index c199d3382..8053e41dd 100644 --- a/src/matrixfree/boundaryConditions.cc +++ b/src/matrixfree/boundaryConditions.cc @@ -39,10 +39,6 @@ MatrixFreePDE::applyNeumannBCs() if (userInputs.BC_list[starting_BC_list_index].var_BC_type[direction] == NEUMANN) { - typename DoFHandler::active_cell_iterator cell = dofHandlersSet[0] - ->begin_active(), - endc = - dofHandlersSet[0]->end(); FESystem *fe = FESet[currentFieldIndex]; QGaussLobatto face_quadrature_formula(degree + 1); FEFaceValues fe_face_values(*fe, @@ -54,7 +50,7 @@ MatrixFreePDE::applyNeumannBCs() std::vector local_dof_indices(dofs_per_cell); // Loop over each face on a boundary - for (; cell != endc; ++cell) + for (const auto &cell : dofHandlersSet[0]->active_cell_iterators()) { for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) { @@ -194,9 +190,10 @@ MatrixFreePDE::applyDirichletBCs() } } - // VectorTools::interpolate_boundary_values (*dofHandlersSet[currentFieldIndex],\ - // direction, NonUniformDirichletBC(currentFieldIndex,direction,currentTime,this), *(AffineConstraints*) \ - // constraintsDirichletSet[currentFieldIndex],mask); + // VectorTools::interpolate_boundary_values + // (*dofHandlersSet[currentFieldIndex],direction, + // NonUniformDirichletBC(currentFieldIndex,direction,currentTime,this), + // *(AffineConstraints*)constraintsDirichletSet[currentFieldIndex],mask); VectorTools::interpolate_boundary_values( *dofHandlersSet[currentFieldIndex], direction, @@ -284,102 +281,35 @@ MatrixFreePDE::setPeriodicityConstraints( #endif } -// Determine which (if any) components of the current field have rigid body -// modes (i.e no Dirichlet BCs) if the equation is elliptic template void -MatrixFreePDE::getComponentsWithRigidBodyModes( - std::vector &rigidBodyModeComponents) const -{ - // Rigid body modes only matter for elliptic equations - if (userInputs.var_eq_type[currentFieldIndex] == IMPLICIT_TIME_DEPENDENT || - userInputs.var_eq_type[currentFieldIndex] == TIME_INDEPENDENT) - { - // First, get the variable index of the current field - unsigned int starting_BC_list_index = 0; - for (unsigned int i = 0; i < currentFieldIndex; i++) - { - if (userInputs.var_type[i] == SCALAR) - { - starting_BC_list_index++; - } - else - { - starting_BC_list_index += dim; - } - } - - // Get number of components of the field - unsigned int num_components = 1; - if (userInputs.var_type[currentFieldIndex] == VECTOR) - { - num_components = dim; - } - - // Loop over each component and determine if it has a rigid body mode - // (i.e. no Dirichlet BCs) - for (unsigned int component = 0; component < num_components; component++) - { - bool rigidBodyMode = true; - for (unsigned int direction = 0; direction < 2 * dim; direction++) - { - if (userInputs.BC_list[starting_BC_list_index + component] - .var_BC_type[direction] == DIRICHLET) - { - rigidBodyMode = false; - } - } - // If the component has a rigid body mode, add it to the list - if (rigidBodyMode == true) - { - rigidBodyModeComponents.push_back(component); - } - } - } -} - -// Set constraints to pin the solution if there are no Dirichlet BCs for a -// component of a variable in an elliptic equation -template -void -MatrixFreePDE::setRigidBodyModeConstraints( - const std::vector rigidBodyModeComponents, +MatrixFreePDE::set_rigid_body_mode_constraints( AffineConstraints *constraints, - const DoFHandler *dof_handler) const + const DoFHandler *dof_handler, + const Point target_point) const { - if (rigidBodyModeComponents.size() > 0) - { - // Choose the point where the constraint will be placed. Must be the - // coordinates of a vertex. - dealii::Point target_point; // default constructor places the point at the - // origin - - unsigned int vertices_per_cell = GeometryInfo::vertices_per_cell; + // Determine the number of components in the field. For a scalar field this is 1, for a + // vector dim, etc. + unsigned int n_components = 0; + userInputs.var_type[currentFieldIndex] == VECTOR ? n_components = dim + : n_components = 1; - // Loop over each locally owned cell - typename DoFHandler::active_cell_iterator cell = dof_handler->begin_active(), - endc = dof_handler->end(); - - for (; cell != endc; ++cell) + // Loop over each locally owned cell + for (const auto &cell : dof_handler->active_cell_iterators()) + { + if (cell->is_locally_owned()) { - if (cell->is_locally_owned()) + for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) { - for (unsigned int i = 0; i < vertices_per_cell; ++i) + // Check if the vertex is the target vertex + if (target_point.distance(cell->vertex(i)) < 1.0e-2 * cell->diameter()) { - // Check if the vertex is the target vertex - if (target_point.distance(cell->vertex(i)) < 1e-2 * cell->diameter()) + // Loop through the number of components and add the constraint + for (unsigned int component = 0; component < n_components; component++) { - // Loop through the list of components with rigid body - // modes and add an inhomogeneous constraint for each - for (unsigned int component_num = 0; - component_num < rigidBodyModeComponents.size(); - component_num++) - { - unsigned int nodeID = cell->vertex_dof_index(i, component_num); - // Temporarily disabling the addition of inhomogeneous - // constraints constraints->add_line(nodeID); - // constraints->set_inhomogeneity(nodeID,0.0); - } + unsigned int nodeID = cell->vertex_dof_index(i, component); + constraints->add_line(nodeID); + constraints->set_inhomogeneity(nodeID, 0.0); } } } diff --git a/src/matrixfree/checkpoint.cc b/src/matrixfree/checkpoint.cc index 11ee9a4ee..827a57127 100644 --- a/src/matrixfree/checkpoint.cc +++ b/src/matrixfree/checkpoint.cc @@ -242,7 +242,7 @@ MatrixFreePDE::move_file(const std::string &old_name, template void -MatrixFreePDE::verify_checkpoint_file_exists(const std::string filename) +MatrixFreePDE::verify_checkpoint_file_exists(const std::string &filename) { std::ifstream in(filename); if (!in) diff --git a/src/matrixfree/computeIntegral.cc b/src/matrixfree/computeIntegral.cc index 3832318d2..398eb898e 100644 --- a/src/matrixfree/computeIntegral.cc +++ b/src/matrixfree/computeIntegral.cc @@ -19,13 +19,9 @@ MatrixFreePDE::computeIntegral(double &integrated // constraintsOtherSet[index]->distribute(*variableSet[index]); // variableSet[index]->update_ghost_values(); - typename DoFHandler::active_cell_iterator cell = this->dofHandlersSet[0] - ->begin_active(), - endc = this->dofHandlersSet[0]->end(); - double value = 0.0; - for (; cell != endc; ++cell) + for (const auto &cell : dofHandlersSet[0]->active_cell_iterators()) { if (cell->is_locally_owned()) { @@ -49,65 +45,4 @@ MatrixFreePDE::computeIntegral(double &integrated integratedField = value; } -//----------------------------------- - -// update RHS of each field -template -void -MatrixFreePDE::computeIntegralMF(double &integratedField, - int index, - const std::vector variableSet) -{ - // log time - computing_timer.enter_subsection("matrixFreePDE: computeIntegralMF"); - - integrated_var = 0.0; - integral_index = index; - - // call to integrate and assemble - matrixFreeObject.cell_loop(&MatrixFreePDE::getIntegralMF, - this, - residualSet, - variableSet); - - integratedField = Utilities::MPI::sum(integrated_var, MPI_COMM_WORLD); - - // end log - computing_timer.leave_subsection("matrixFreePDE: computeIntegralMF"); -} - -template -void -MatrixFreePDE::getIntegralMF( - const MatrixFree &data, - std::vector &dst, - const std::vector &src, - const std::pair &cell_range) -{ - dealii::FEEvaluation var(data, 0); - - // loop over cells - for (unsigned int cell = cell_range.first; cell < cell_range.second; ++cell) - { - var.reinit(cell); - var.read_dof_values_plain(*src[0]); - var.evaluate(true, false, false); - - unsigned int num_q_points = var.n_q_points; - - // loop over quadrature points - for (unsigned int q = 0; q < num_q_points; ++q) - { - dealii::VectorizedArray val = var.get_value(q); - dealii::VectorizedArray jxw = var.JxW(q); - assembler_lock.lock(); - for (unsigned i = 0; i < val.size(); i++) - { - integrated_var += val[i] * jxw[i]; - } - assembler_lock.unlock(); - } - } -} - #include "../../include/matrixFreePDE_template_instantiations.h" diff --git a/src/matrixfree/computeLHS.cc b/src/matrixfree/computeLHS.cc index b77584b99..d975e560b 100644 --- a/src/matrixfree/computeLHS.cc +++ b/src/matrixfree/computeLHS.cc @@ -37,14 +37,11 @@ MatrixFreePDE::vmult(vectorType &dst, const vectorType &src) const // Account for Dirichlet BC's (essentially copy dirichlet DOF values present in src to // dst, although it is unclear why the constraints can't just be distributed here) - for (std::map::const_iterator it = - valuesDirichletSet[currentFieldIndex]->begin(); - it != valuesDirichletSet[currentFieldIndex]->end(); - ++it) + for (auto &it : *valuesDirichletSet[currentFieldIndex]) { - if (dst.in_local_range(it->first)) + if (dst.in_local_range(it.first)) { - dst(it->first) = src(it->first); //*jacobianDiagonal(it->first); + dst(it.first) = src(it.first); //*jacobianDiagonal(it->first); } } @@ -67,12 +64,13 @@ MatrixFreePDE::getLHS( for (unsigned int cell = cell_range.first; cell < cell_range.second; ++cell) { // Initialize, read DOFs, and set evaulation flags for each variable - // variable_list.reinit_and_eval_LHS(src,solutionSet,cell,currentFieldIndex); variable_list.reinit_and_eval(solutionSet, cell); variable_list.reinit_and_eval_change_in_solution(src, cell, currentFieldIndex); unsigned int num_q_points = variable_list.get_num_q_points(); + dealii::VectorizedArray local_element_volume = element_volume[cell]; + // loop over quadrature points for (unsigned int q = 0; q < num_q_points; ++q) { @@ -82,7 +80,7 @@ MatrixFreePDE::getLHS( variable_list.get_q_point_location(); // Calculate the residuals - equationLHS(variable_list, q_point_loc); + equationLHS(variable_list, q_point_loc, local_element_volume); } // Integrate the residuals and distribute from local to global diff --git a/src/matrixfree/computeRHS.cc b/src/matrixfree/computeRHS.cc index 2e1a48d3d..8b0cd96c6 100644 --- a/src/matrixfree/computeRHS.cc +++ b/src/matrixfree/computeRHS.cc @@ -42,6 +42,8 @@ MatrixFreePDE::getExplicitRHS( unsigned int num_q_points = variable_list.get_num_q_points(); + dealii::VectorizedArray local_element_volume = element_volume[cell]; + // loop over quadrature points for (unsigned int q = 0; q < num_q_points; ++q) { @@ -51,7 +53,7 @@ MatrixFreePDE::getExplicitRHS( variable_list.get_q_point_location(); // Calculate the residuals - explicitEquationRHS(variable_list, q_point_loc); + explicitEquationRHS(variable_list, q_point_loc, local_element_volume); } variable_list.integrate_and_distribute(dst); @@ -97,6 +99,8 @@ MatrixFreePDE::getNonexplicitRHS( unsigned int num_q_points = variable_list.get_num_q_points(); + dealii::VectorizedArray local_element_volume = element_volume[cell]; + // loop over quadrature points for (unsigned int q = 0; q < num_q_points; ++q) { @@ -106,7 +110,7 @@ MatrixFreePDE::getNonexplicitRHS( variable_list.get_q_point_location(); // Calculate the residuals - nonExplicitEquationRHS(variable_list, q_point_loc); + nonExplicitEquationRHS(variable_list, q_point_loc, local_element_volume); } variable_list.integrate_and_distribute(dst); diff --git a/src/matrixfree/init.cc b/src/matrixfree/init.cc index b0c319906..58d4342d9 100644 --- a/src/matrixfree/init.cc +++ b/src/matrixfree/init.cc @@ -51,28 +51,27 @@ MatrixFreePDE::init() // Setup system pcout << "initializing matrix free object\n"; totalDOFs = 0; - for (typename std::vector>::iterator it = fields.begin(); it != fields.end(); - ++it) + for (auto &field : fields) { - currentFieldIndex = it->index; + currentFieldIndex = field.index; char buffer[100]; // print to std::out std::string var_type; - if (it->pdetype == EXPLICIT_TIME_DEPENDENT) + if (field.pdetype == EXPLICIT_TIME_DEPENDENT) { var_type = "EXPLICIT_TIME_DEPENDENT"; } - else if (it->pdetype == IMPLICIT_TIME_DEPENDENT) + else if (field.pdetype == IMPLICIT_TIME_DEPENDENT) { var_type = "IMPLICIT_TIME_DEPENDENT"; } - else if (it->pdetype == TIME_INDEPENDENT) + else if (field.pdetype == TIME_INDEPENDENT) { var_type = "TIME_INDEPENDENT"; } - else if (it->pdetype == AUXILIARY) + else if (field.pdetype == AUXILIARY) { var_type = "AUXILIARY"; } @@ -82,50 +81,43 @@ MatrixFreePDE::init() "initializing finite element space P^%u for %9s:%6s field '%s'\n", degree, var_type.c_str(), - (it->type == SCALAR ? "SCALAR" : "VECTOR"), - it->name.c_str()); + (field.type == SCALAR ? "SCALAR" : "VECTOR"), + field.name.c_str()); pcout << buffer; - // Check if any time dependent fields present (note: I should get rid of - // parabolicFieldIndex and ellipticFieldIndex, they only work if there is - // at max one of each) - if (it->pdetype == EXPLICIT_TIME_DEPENDENT) + // Check if any time dependent fields present + if (field.pdetype == EXPLICIT_TIME_DEPENDENT) { isTimeDependentBVP = true; - parabolicFieldIndex = it->index; hasExplicitEquation = true; } - else if (it->pdetype == IMPLICIT_TIME_DEPENDENT) + else if (field.pdetype == IMPLICIT_TIME_DEPENDENT) { isTimeDependentBVP = true; - ellipticFieldIndex = it->index; hasNonExplicitEquation = true; std::cerr << "PRISMS-PF Error: IMPLICIT_TIME_DEPENDENT equation " "types are not currently supported" << std::endl; abort(); } - else if (it->pdetype == AUXILIARY) + else if (field.pdetype == AUXILIARY) { - parabolicFieldIndex = it->index; - ellipticFieldIndex = it->index; hasNonExplicitEquation = true; } - else if (it->pdetype == TIME_INDEPENDENT) + else if (field.pdetype == TIME_INDEPENDENT) { isEllipticBVP = true; - ellipticFieldIndex = it->index; hasNonExplicitEquation = true; } // create FESystem FESystem *fe; - if (it->type == SCALAR) + if (field.type == SCALAR) { fe = new FESystem(FE_Q(QGaussLobatto<1>(degree + 1)), 1); } - else if (it->type == VECTOR) + else if (field.type == VECTOR) { fe = new FESystem(FE_Q(QGaussLobatto<1>(degree + 1)), dim); } @@ -175,11 +167,14 @@ MatrixFreePDE::init() // Get hanging node constraints DoFTools::make_hanging_node_constraints(*dof_handler, *constraintsOther); - // Add a constraint to fix the value at the origin to zero if all BCs are - // zero-derivative or periodic - std::vector rigidBodyModeComponents; - // getComponentsWithRigidBodyModes(rigidBodyModeComponents); - // setRigidBodyModeConstraints(rigidBodyModeComponents,constraintsOther,dof_handler); + // Pin solution + if (userInputs.pinned_point.find(currentFieldIndex) != + userInputs.pinned_point.end()) + { + set_rigid_body_mode_constraints(constraintsOther, + dof_handler, + userInputs.pinned_point[currentFieldIndex]); + } // Get constraints for periodic BCs setPeriodicityConstraints(constraintsOther, dof_handler); @@ -191,16 +186,16 @@ MatrixFreePDE::init() { if (userInputs.BC_list[i].var_BC_type[direction] == DIRICHLET) { - it->hasDirichletBCs = true; + field.hasDirichletBCs = true; } else if (userInputs.BC_list[i].var_BC_type[direction] == NON_UNIFORM_DIRICHLET) { - it->hasnonuniformDirichletBCs = true; + field.hasnonuniformDirichletBCs = true; } else if (userInputs.BC_list[i].var_BC_type[direction] == NEUMANN) { - it->hasNeumannBCs = true; + field.hasNeumannBCs = true; } } } @@ -212,14 +207,14 @@ MatrixFreePDE::init() constraintsOther->close(); // Store Dirichlet BC DOF's - valuesDirichletSet[it->index]->clear(); + valuesDirichletSet[field.index]->clear(); for (types::global_dof_index i = 0; i < dof_handler->n_dofs(); i++) { if (locally_relevant_dofs->is_element(i)) { if (constraintsDirichlet->is_constrained(i)) { - (*valuesDirichletSet[it->index])[i] = + (*valuesDirichletSet[field.index])[i] = constraintsDirichlet->get_inhomogeneity(i); } } @@ -228,7 +223,7 @@ MatrixFreePDE::init() snprintf(buffer, sizeof(buffer), "field '%2s' DOF : %u (Constraint DOF : %u)\n", - it->name.c_str(), + field.name.c_str(), dof_handler->n_dofs(), constraintsDirichlet->n_constraints()); pcout << buffer; @@ -314,7 +309,7 @@ MatrixFreePDE::init() } // Apply the initial conditions to the solution vectors - // The initial conditions are re-applied below in the "adaptiveRefine" + // The initial conditions are re-applied below in the "do_adaptive_refinement" // function so that the mesh can adapt based on the initial conditions. if (userInputs.resume_from_checkpoint) { @@ -325,7 +320,7 @@ MatrixFreePDE::init() applyInitialConditions(); } - // Create new solution transfer sets (needed for the "refineGrid" call, might + // Create new solution transfer sets (needed for the "refine_grid" call, might // be able to move this elsewhere) soltransSet.clear(); for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) @@ -343,11 +338,26 @@ MatrixFreePDE::init() solutionSet[fieldIndex]->update_ghost_values(); } - // If not resuming from a checkpoint, check and perform adaptive mesh - // refinement, which reinitializes the system with the new mesh - if (!userInputs.resume_from_checkpoint) + // If not resuming from a checkpoint, check and perform adaptive mesh refinement, which + // reinitializes the system with the new mesh + if (!userInputs.resume_from_checkpoint && userInputs.h_adaptivity == true) { - adaptiveRefine(0); + computing_timer.enter_subsection("matrixFreePDE: AMR"); + + unsigned int numDoF_preremesh = totalDOFs; + for (unsigned int remesh_index = 0; + remesh_index < + (userInputs.max_refinement_level - userInputs.min_refinement_level); + remesh_index++) + { + AMR.do_adaptive_refinement(currentIncrement); + reinit(); + if (totalDOFs == numDoF_preremesh) + break; + numDoF_preremesh = totalDOFs; + } + + computing_timer.leave_subsection("matrixFreePDE: AMR"); } // If resuming from a checkpoint, load the proper starting increment and time @@ -356,6 +366,9 @@ MatrixFreePDE::init() load_checkpoint_time_info(); } + // Once the initial triangulation has been set, compute element volume + compute_element_volume(); + computing_timer.leave_subsection("matrixFreePDE: initialization"); } @@ -393,4 +406,51 @@ MatrixFreePDE::makeTriangulation( markBoundaries(tria); } +template +void +MatrixFreePDE::compute_element_volume() +{ + // Get the number of cell batches. Note this is the same as the cell range in + // cell_loop() + const unsigned int n_cells = matrixFreeObject.n_cell_batches(); + + // Resize vector + element_volume.resize(n_cells); + + // Set quadrature rule and FEValues to update the JxW values + QGaussLobatto quadrature(degree + 1); + FEValues fe_values(*(FESet[0]), quadrature, update_JxW_values); + + // Get the number of quadrature points + const unsigned int num_quad_points = quadrature.size(); + + // Loop over the cells and each lane in the vectorized array + for (unsigned int cell = 0; cell < n_cells; cell++) + { + for (unsigned int lane = 0; + lane < matrixFreeObject.n_active_entries_per_cell_batch(cell); + lane++) + { + // Get the iterator for the current cell + auto cell_iterator = matrixFreeObject.get_cell_iterator(cell, lane); + + // Reinitialize the cell + fe_values.reinit(cell_iterator); + + // Initialize volume to 0 for the current cell + double cell_volume = 0.0; + + // Sum up the JxW values at each quadrature point to compute the element volume + // in 3D or area in 2D. + for (unsigned int q_point = 0; q_point < num_quad_points; ++q_point) + { + cell_volume += fe_values.JxW(q_point); + } + + // Store the element volume + element_volume[cell][lane] = cell_volume; + } + } +} + #include "../../include/matrixFreePDE_template_instantiations.h" diff --git a/src/matrixfree/initForTests.cc b/src/matrixfree/initForTests.cc index 0d3adf0f9..6c75dbfb7 100644 --- a/src/matrixfree/initForTests.cc +++ b/src/matrixfree/initForTests.cc @@ -38,16 +38,15 @@ MatrixFreePDE::initForTests(std::vector> fields) } // setup system - for (typename std::vector>::iterator it = fields.begin(); it != fields.end(); - ++it) + for (auto &field : fields) { // create FESystem - FESystem *fe; - if (it->type == SCALAR) + FESystem *fe = nullptr; + if (field.type == SCALAR) { fe = new FESystem(FE_Q(QGaussLobatto<1>(degree + 1)), 1); } - else if (it->type == VECTOR) + else if (field.type == VECTOR) { fe = new FESystem(FE_Q(QGaussLobatto<1>(degree + 1)), dim); } diff --git a/src/matrixfree/initialConditions.cc b/src/matrixfree/initialConditions.cc index 35585c00e..de534695c 100644 --- a/src/matrixfree/initialConditions.cc +++ b/src/matrixfree/initialConditions.cc @@ -10,10 +10,11 @@ template class InitialConditionPField : public Function { public: - unsigned int index; - Vector values; - typedef PRISMS::PField ScalarField; - ScalarField &inputField; + unsigned int index; + Vector values; + + using ScalarField = PRISMS::PField; + ScalarField &inputField; InitialConditionPField(const unsigned int _index, ScalarField &_inputField) : Function(1) @@ -22,7 +23,7 @@ class InitialConditionPField : public Function {} double - value(const Point &p, const unsigned int component = 0) const + value(const Point &p, const unsigned int component = 0) const override { double scalar_IC; @@ -102,7 +103,7 @@ MatrixFreePDE::applyInitialConditions() grain_index_field.update_ghost_values(); // Get the max and min grain ids - unsigned int max_id = (unsigned int) grain_index_field.linfty_norm(); + auto max_id = (unsigned int) grain_index_field.linfty_norm(); unsigned int min_id = 0; // Now locate all of the grains and create simplified representations of @@ -123,6 +124,7 @@ MatrixFreePDE::applyInitialConditions() &grain_index_field, (double) id - userInputs.order_parameter_threshold, (double) id + userInputs.order_parameter_threshold, + min_id, 0, grain_sets_single_id); @@ -296,6 +298,78 @@ MatrixFreePDE::applyInitialConditions() } } + // Create map of vtk files that are read in + std::unordered_map> file_field_map; + for (size_t i = 0; i < userInputs.number_of_variables; ++i) + { + if (userInputs.load_ICs[i]) + { + file_field_map[userInputs.load_file_name[i]].push_back(i); + } + } + // Read out unique filenames + if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0 && !file_field_map.empty()) + { + std::cout << "Unique VTK input files: " << std::endl; + for (const auto &pair : file_field_map) + { + std::cout << pair.first << ", "; + } + } + // Read in each vtk once and apply initial conditions + using ScalarField = PRISMS::PField; + using Body = PRISMS::Body; + Body body; + + for (const auto &pair : file_field_map) + { + bool using_parallel_files = false; + std::string filename = pair.first; + std::vector index_list = pair.second; + // For parallel file capability + for (const auto &index : index_list) + { + using_parallel_files = + using_parallel_files || userInputs.load_parallel_file[index]; + } + if (using_parallel_files) + { + std::ostringstream conversion; + conversion << Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + filename = filename + "." + conversion.str() + ".vtk"; + } + else + { + filename = filename + ".vtk"; // add file extension + } + + std::cout << "Reading " << filename << "\n"; + body.read_vtk(filename); + + for (const auto &index : index_list) + { + std::string var_name = userInputs.load_field_name[index]; + + // Find the scalar field in the file + ScalarField &field = body.find_scalar_field(var_name); + + if (userInputs.var_type[index] == SCALAR) + { + pcout << "Applying PField initial condition for " + << userInputs.load_field_name[index] << "...\n"; + VectorTools::interpolate(*dofHandlersSet[index], + InitialConditionPField(index, field), + *solutionSet[index]); + } + else + { + AssertThrow(false, + ExcMessage("PRISMS-PF Error: We do not support the loading of " + "vector fields from vtks at this moment.")); + } + } + } + unsigned int op_list_index = 0; for (unsigned int var_index = 0; var_index < userInputs.number_of_variables; var_index++) @@ -333,50 +407,6 @@ MatrixFreePDE::applyInitialConditions() *solutionSet[var_index]); } } - - else - { - // Declare the PField types and containers - typedef PRISMS::PField ScalarField; - typedef PRISMS::Body Body; - Body body; - - // Create the filename of the the file to be loaded - std::string filename; - if (userInputs.load_parallel_file[var_index] == false) - { - filename = userInputs.load_file_name[var_index] + ".vtk"; - } - else - { - int proc_num = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); - std::ostringstream conversion; - conversion << proc_num; - filename = userInputs.load_file_name[var_index] + "." + - conversion.str() + ".vtk"; - } - - // Load the data from the file using a PField - body.read_vtk(filename); - ScalarField &conc = - body.find_scalar_field(userInputs.load_field_name[var_index]); - - if (userInputs.var_type[var_index] == SCALAR) - { - pcout << "Applying PField initial condition...\n"; - VectorTools::interpolate(*dofHandlersSet[var_index], - InitialConditionPField(var_index, conc), - *solutionSet[var_index]); - } - else - { - std::cout << "PRISMS-PF Error: Cannot load vector fields. " - "Loading initial conditions from file is " - "currently limited to scalar fields" - << std::endl; - } - } - pcout << "Application of initial conditions for field number " << var_index << " complete \n"; } diff --git a/src/matrixfree/invM.cc b/src/matrixfree/invM.cc index 4ae7d55ba..bd39ab70a 100644 --- a/src/matrixfree/invM.cc +++ b/src/matrixfree/invM.cc @@ -1,6 +1,8 @@ // computeInvM() method for MatrixFreePDE class +#include #include "../../include/matrixFreePDE.h" +#include #include // compute inverse of the diagonal mass matrix and store in vector invM @@ -62,13 +64,17 @@ MatrixFreePDE::computeInvM() matrixFreeObject.initialize_dof_vector(invMvector, parabolicVectorFieldIndex); invMvector = 0.0; + // invM evaluation flags + dealii::EvaluationFlags::EvaluationFlags invM_flags = dealii::EvaluationFlags::values; + // Compute mass matrix for the given type of quadrature. Selecting gauss // lobatto quadrature points which are suboptimal but give diagonal M if (fields[parabolicScalarFieldIndex].type == SCALAR) { VectorizedArray one = make_vectorized_array(1.0); FEEvaluation fe_eval(matrixFreeObject, parabolicScalarFieldIndex); - const unsigned int n_q_points = fe_eval.n_q_points; + + const unsigned int n_q_points = fe_eval.n_q_points; for (unsigned int cell = 0; cell < matrixFreeObject.n_cell_batches(); ++cell) { fe_eval.reinit(cell); @@ -76,7 +82,7 @@ MatrixFreePDE::computeInvM() { fe_eval.submit_value(one, q); } - fe_eval.integrate(true, false); + fe_eval.integrate(invM_flags); fe_eval.distribute_local_to_global(invMscalar); } } @@ -99,7 +105,7 @@ MatrixFreePDE::computeInvM() { fe_eval.submit_value(oneV, q); } - fe_eval.integrate(true, false); + fe_eval.integrate(invM_flags); fe_eval.distribute_local_to_global(invMvector); } } @@ -120,8 +126,8 @@ MatrixFreePDE::computeInvM() } double min_cell_volume = std::accumulate(begin(min_element_length), end(min_element_length), - 1, - std::multiplies()); + 1.0, + std::multiplies<>()); // Invert scalar mass matrix diagonal elements #if (DEAL_II_VERSION_MAJOR == 9 && DEAL_II_VERSION_MINOR < 4) diff --git a/src/matrixfree/markBoundaries.cc b/src/matrixfree/markBoundaries.cc index 212ee5886..06bff54b7 100644 --- a/src/matrixfree/markBoundaries.cc +++ b/src/matrixfree/markBoundaries.cc @@ -10,9 +10,7 @@ void MatrixFreePDE::markBoundaries( parallel::distributed::Triangulation &tria) const { - typename Triangulation::cell_iterator cell = tria.begin(), endc = tria.end(); - - for (; cell != endc; ++cell) + for (const auto &cell : tria.active_cell_iterators()) { // Mark all of the faces for (unsigned int face_number = 0; face_number < GeometryInfo::faces_per_cell; diff --git a/src/matrixfree/matrixFreePDE.cc b/src/matrixfree/matrixFreePDE.cc index 26059d6a2..6fa9c7708 100644 --- a/src/matrixfree/matrixFreePDE.cc +++ b/src/matrixfree/matrixFreePDE.cc @@ -14,8 +14,6 @@ MatrixFreePDE::MatrixFreePDE(userInputParameters _userInputs) , isEllipticBVP(false) , hasExplicitEquation(false) , hasNonExplicitEquation(false) - , parabolicFieldIndex(0) - , ellipticFieldIndex(0) , currentTime(0.0) , currentIncrement(0) , currentOutput(0) @@ -23,6 +21,15 @@ MatrixFreePDE::MatrixFreePDE(userInputParameters _userInputs) , current_grain_reassignment(0) , computing_timer(pcout, TimerOutput::summary, TimerOutput::wall_times) , first_integrated_var_output_complete(false) + , AMR(_userInputs, + triangulation, + fields, + solutionSet, + soltransSet, + FESet, + dofHandlersSet_nonconst, + constraintsDirichletSet, + constraintsOtherSet) {} // destructor @@ -34,33 +41,33 @@ MatrixFreePDE::~MatrixFreePDE() // Delete the pointers contained in several member variable vectors // The size of each of these must be checked individually in case an exception // is thrown as they are being initialized. - for (unsigned int iter = 0; iter < locally_relevant_dofsSet.size(); iter++) + for (const auto &locally_relevant_dofs : locally_relevant_dofsSet) { - delete locally_relevant_dofsSet[iter]; + delete locally_relevant_dofs; } - for (unsigned int iter = 0; iter < constraintsDirichletSet.size(); iter++) + for (const auto &constraintsDirichlet : constraintsDirichletSet) { - delete constraintsDirichletSet[iter]; + delete constraintsDirichlet; } - for (unsigned int iter = 0; iter < soltransSet.size(); iter++) + for (const auto &soltrans : soltransSet) { - delete soltransSet[iter]; + delete soltrans; } - for (unsigned int iter = 0; iter < dofHandlersSet.size(); iter++) + for (const auto &dofHandlers : dofHandlersSet) { - delete dofHandlersSet[iter]; + delete dofHandlers; } - for (unsigned int iter = 0; iter < FESet.size(); iter++) + for (const auto &FE : FESet) { - delete FESet[iter]; + delete FE; } - for (unsigned int iter = 0; iter < solutionSet.size(); iter++) + for (const auto &solution : solutionSet) { - delete solutionSet[iter]; + delete solution; } - for (unsigned int iter = 0; iter < residualSet.size(); iter++) + for (const auto &residual : residualSet) { - delete residualSet[iter]; + delete residual; } } diff --git a/src/matrixfree/nucleation.cc b/src/matrixfree/nucleation.cc index 8037acfcb..c1972bf31 100644 --- a/src/matrixfree/nucleation.cc +++ b/src/matrixfree/nucleation.cc @@ -2,8 +2,8 @@ #include "../../include/matrixFreePDE.h" #include "../../include/parallelNucleationList.h" #include "../../include/varBCs.h" +#include #include -#include // ======================================================================================================= // Function called in solve to update the global list of nuclei @@ -129,9 +129,6 @@ MatrixFreePDE::getLocalNucleiList(std::vector> &newnuc std::vector> q_point_list_overlap(num_quad_points); - typename DoFHandler::active_cell_iterator di = - dofHandlersSet_nonconst[0]->begin_active(); - // What used to be in nuc_attempt double rand_val; // Better random no. generator @@ -140,13 +137,13 @@ MatrixFreePDE::getLocalNucleiList(std::vector> &newnuc std::uniform_real_distribution<> distr(0.0, 1.0); // Element cycle - while (di != this->dofHandlersSet_nonconst[0]->end()) + for (const auto &dof : dofHandlersSet_nonconst[0]->active_cell_iterators()) { - if (di->is_locally_owned()) + if (dof->is_locally_owned()) { // Obtaining average element concentration by averaging over element's // quadrature points - fe_values.reinit(di); + fe_values.reinit(dof); for (unsigned int var = 0; var < userInputs.nucleation_need_value.size(); var++) { fe_values.get_function_values( @@ -304,9 +301,9 @@ MatrixFreePDE::getLocalNucleiList(std::vector> &newnuc std::cout << "Nucleus center: " << nuc_ele_pos << std::endl; std::cout << "Nucleus order parameter: " << variable_index << std::endl; - nucleus *temp = new nucleus; - temp->index = nuclei.size(); - temp->center = nuc_ele_pos; + auto *temp = new nucleus; + temp->index = nuclei.size(); + temp->center = nuc_ele_pos; temp->semiaxes = userInputs.get_nucleus_semiaxes(variable_index); temp->seededTime = t; @@ -320,8 +317,6 @@ MatrixFreePDE::getLocalNucleiList(std::vector> &newnuc } } } - // Increment the cell iterators - ++di; } } @@ -346,20 +341,17 @@ MatrixFreePDE::safetyCheckNewNuclei(std::vector> newn std::vector> q_point_list(num_quad_points); // Nucleus cycle - for (typename std::vector>::iterator thisNucleus = newnuclei.begin(); - thisNucleus != newnuclei.end(); - ++thisNucleus) + for (const auto &thisNucleus : newnuclei) { bool isClose = false; // Element cycle - typename DoFHandler::active_cell_iterator di = - dofHandlersSet_nonconst[0]->begin_active(); - while (di != dofHandlersSet_nonconst[0]->end()) + + for (const auto &dof : dofHandlersSet_nonconst[0]->active_cell_iterators()) { - if (di->is_locally_owned()) + if (dof->is_locally_owned()) { - fe_values.reinit(di); + fe_values.reinit(dof); for (unsigned int var = 0; var < userInputs.nucleating_variable_indices.size(); var++) @@ -376,11 +368,11 @@ MatrixFreePDE::safetyCheckNewNuclei(std::vector> newn // Calculate the ellipsoidal distance to the center of the // nucleus double weighted_dist = weightedDistanceFromNucleusCenter( - thisNucleus->center, + thisNucleus.center, userInputs.get_nucleus_freeze_semiaxes( - thisNucleus->orderParameterIndex), + thisNucleus.orderParameterIndex), q_point_list[q_point], - thisNucleus->orderParameterIndex); + thisNucleus.orderParameterIndex); if (weighted_dist < 1.0) { @@ -397,7 +389,7 @@ MatrixFreePDE::safetyCheckNewNuclei(std::vector> newn std::cout << "Attempted nucleation failed due to " "overlap w/ existing particle!!!!!!" << std::endl; - conflict_ids.push_back(thisNucleus->index); + conflict_ids.push_back(thisNucleus.index); break; } } @@ -405,8 +397,6 @@ MatrixFreePDE::safetyCheckNewNuclei(std::vector> newn if (isClose) break; } - // Increment the cell iterators - ++di; } } } @@ -427,7 +417,6 @@ MatrixFreePDE::refineMeshNearNuclei(std::vector> newnu std::vector> q_point_list(num_quad_points); typename Triangulation::active_cell_iterator ti; - typename DoFHandler::active_cell_iterator di; unsigned int numDoF_preremesh = totalDOFs; @@ -436,14 +425,13 @@ MatrixFreePDE::refineMeshNearNuclei(std::vector> newnu remesh_index++) { ti = triangulation.begin_active(); - di = dofHandlersSet_nonconst[0]->begin_active(); - while (di != dofHandlersSet_nonconst[0]->end()) + for (const auto &dof : dofHandlersSet_nonconst[0]->active_cell_iterators()) { - if (di->is_locally_owned()) + if (dof->is_locally_owned()) { bool mark_refine = false; - fe_values.reinit(di); + fe_values.reinit(dof); q_point_list = fe_values.get_quadrature_points(); // Calculate the distance from the corner of the cell to the @@ -459,22 +447,19 @@ MatrixFreePDE::refineMeshNearNuclei(std::vector> newnu for (unsigned int q_point = 0; q_point < num_quad_points; ++q_point) { - for (typename std::vector>::iterator thisNucleus = - newnuclei.begin(); - thisNucleus != newnuclei.end(); - ++thisNucleus) + for (const auto &thisNucleus : newnuclei) { // Calculate the ellipsoidal distance to the center of the // nucleus double weighted_dist = weightedDistanceFromNucleusCenter( - thisNucleus->center, + thisNucleus.center, userInputs.get_nucleus_freeze_semiaxes( - thisNucleus->orderParameterIndex), + thisNucleus.orderParameterIndex), q_point_list[q_point], - thisNucleus->orderParameterIndex); + thisNucleus.orderParameterIndex); if (weighted_dist < 1.0 || - thisNucleus->center.distance(q_point_list[q_point]) < diag_dist) + thisNucleus.center.distance(q_point_list[q_point]) < diag_dist) { if ((unsigned int) ti->level() < userInputs.max_refinement_level) @@ -490,14 +475,13 @@ MatrixFreePDE::refineMeshNearNuclei(std::vector> newnu break; } if (mark_refine) - di->set_refine_flag(); + dof->set_refine_flag(); } - ++di; ++ti; } - // The bulk of all of modifySolutionFields is spent in the following two - // function calls - refineGrid(); + // The bulk of all of modifySolutionFields is spent in the following two function + // calls + AMR.refine_grid(); reinit(); // If the mesh hasn't changed from the previous cycle, stop remeshing @@ -514,7 +498,7 @@ template double MatrixFreePDE::weightedDistanceFromNucleusCenter( const dealii::Point center, - const std::vector semiaxes, + const std::vector &semiaxes, const dealii::Point q_point_loc, const unsigned int var_index) const { @@ -547,7 +531,7 @@ template dealii::VectorizedArray MatrixFreePDE::weightedDistanceFromNucleusCenter( const dealii::Point center, - const std::vector semiaxes, + const std::vector &semiaxes, const dealii::Point> q_point_loc, const unsigned int var_index) const { diff --git a/src/matrixfree/outputResults.cc b/src/matrixfree/outputResults.cc index 707790fe2..aac7d1078 100644 --- a/src/matrixfree/outputResults.cc +++ b/src/matrixfree/outputResults.cc @@ -45,28 +45,22 @@ MatrixFreePDE::outputResults() computePostProcessedFields(postProcessedSet); #if (DEAL_II_VERSION_MAJOR == 9 && DEAL_II_VERSION_MINOR < 4) unsigned int invM_size = invMscalar.local_size(); - for (unsigned int fieldIndex = 0; fieldIndex < postProcessedSet.size(); - fieldIndex++) + for (auto &field : postProcessedSet) { - for (unsigned int dof = 0; dof < postProcessedSet[fieldIndex]->local_size(); - ++dof) + for (unsigned int dof = 0; dof < field->local_size(); ++dof) { #else unsigned int invM_size = invMscalar.locally_owned_size(); - for (unsigned int fieldIndex = 0; fieldIndex < postProcessedSet.size(); - fieldIndex++) + for (auto &field : postProcessedSet) { - for (unsigned int dof = 0; - dof < postProcessedSet[fieldIndex]->locally_owned_size(); - ++dof) + for (unsigned int dof = 0; dof < field->locally_owned_size(); ++dof) { #endif - postProcessedSet[fieldIndex]->local_element(dof) = - invMscalar.local_element(dof % invM_size) * - postProcessedSet[fieldIndex]->local_element(dof); + field->local_element(dof) = + invMscalar.local_element(dof % invM_size) * field->local_element(dof); } - constraintsOtherSet[0]->distribute(*postProcessedSet[fieldIndex]); - postProcessedSet[fieldIndex]->update_ghost_values(); + constraintsOtherSet[0]->distribute(*field); + field->update_ghost_values(); } // Integrate over selected post-processed fields and output them to the @@ -158,23 +152,26 @@ MatrixFreePDE::outputResults() data_out.build_patches(degree); + // Defining snprintf with no warnings because we don't can about truncation +#define snprintf_nowarn(...) (snprintf(__VA_ARGS__) < 0 ? abort() : (void) 0) + // write to results file // file name std::ostringstream cycleAsString; cycleAsString << std::setw(std::floor(std::log10(userInputs.totalIncrements)) + 1) << std::setfill('0') << currentIncrement; char baseFileName[100], vtuFileName[100]; - snprintf(baseFileName, - sizeof(baseFileName), - "%s-%s", - userInputs.output_file_name.c_str(), - cycleAsString.str().c_str()); - snprintf(vtuFileName, - sizeof(vtuFileName), - "%s.%u.%s", - baseFileName, - Utilities::MPI::this_mpi_process(MPI_COMM_WORLD), - userInputs.output_file_type.c_str()); + snprintf_nowarn(baseFileName, + sizeof(baseFileName), + "%s-%s", + userInputs.output_file_name.c_str(), + cycleAsString.str().c_str()); + snprintf_nowarn(vtuFileName, + sizeof(vtuFileName), + "%s.%u.%s", + baseFileName, + Utilities::MPI::this_mpi_process(MPI_COMM_WORLD), + userInputs.output_file_type.c_str()); // Write to file in either vtu or vtk format if (userInputs.output_file_type == "vtu") @@ -202,21 +199,21 @@ MatrixFreePDE::outputResults() ++i) { char vtuProcFileName[100]; - snprintf(vtuProcFileName, - sizeof(vtuProcFileName), - "%s-%s.%u.%s", - userInputs.output_file_name.c_str(), - cycleAsString.str().c_str(), - i, - userInputs.output_file_type.c_str()); - filenames.push_back(vtuProcFileName); + snprintf_nowarn(vtuProcFileName, + sizeof(vtuProcFileName), + "%s-%s.%u.%s", + userInputs.output_file_name.c_str(), + cycleAsString.str().c_str(), + i, + userInputs.output_file_type.c_str()); + filenames.emplace_back(vtuProcFileName); } char pvtuFileName[100]; - snprintf(pvtuFileName, - sizeof(pvtuFileName), - "%s.p%s", - baseFileName, - userInputs.output_file_type.c_str()); + snprintf_nowarn(pvtuFileName, + sizeof(pvtuFileName), + "%s.p%s", + baseFileName, + userInputs.output_file_type.c_str()); std::ofstream master_output(pvtuFileName); data_out.write_pvtu_record(master_output, filenames); @@ -227,11 +224,11 @@ MatrixFreePDE::outputResults() { // Write the results to a file shared between all processes char svtuFileName[100]; - snprintf(svtuFileName, - sizeof(svtuFileName), - "%s.%s", - baseFileName, - userInputs.output_file_type.c_str()); + snprintf_nowarn(svtuFileName, + sizeof(svtuFileName), + "%s.%s", + baseFileName, + userInputs.output_file_type.c_str()); data_out.write_vtu_in_parallel(svtuFileName, MPI_COMM_WORLD); pcout << "Output written to:" << svtuFileName << "\n\n"; } diff --git a/src/matrixfree/postprocessor.cc b/src/matrixfree/postprocessor.cc index b92162a9b..06fa05f05 100644 --- a/src/matrixfree/postprocessor.cc +++ b/src/matrixfree/postprocessor.cc @@ -54,6 +54,8 @@ MatrixFreePDE::getPostProcessedFields( unsigned int num_q_points = variable_list.get_num_q_points(); + dealii::VectorizedArray local_element_volume = element_volume[cell]; + // loop over quadrature points for (unsigned int q = 0; q < num_q_points; ++q) { @@ -64,7 +66,10 @@ MatrixFreePDE::getPostProcessedFields( variable_list.get_q_point_location(); // Calculate the residuals - postProcessedFields(variable_list, pp_variable_list, q_point_loc); + postProcessedFields(variable_list, + pp_variable_list, + q_point_loc, + local_element_volume); } pp_variable_list.integrate_and_distribute(dst); diff --git a/src/matrixfree/reassignGrains.cc b/src/matrixfree/reassignGrains.cc index 7eb9a5348..be6f86293 100644 --- a/src/matrixfree/reassignGrains.cc +++ b/src/matrixfree/reassignGrains.cc @@ -46,6 +46,7 @@ MatrixFreePDE::reassignGrains() solutionSet.at(fieldIndex), userInputs.order_parameter_threshold, 1.0 + userInputs.order_parameter_threshold, + 0, fieldIndex, single_OP_grain_sets); diff --git a/src/matrixfree/refine.cc b/src/matrixfree/refine.cc deleted file mode 100644 index 3d3eda63c..000000000 --- a/src/matrixfree/refine.cc +++ /dev/null @@ -1,261 +0,0 @@ -// mesh refinement methods for MatrixFreePDE class - -#include - -#include "../../include/matrixFreePDE.h" - -// default implementation of adaptive mesh refinement -template -void -MatrixFreePDE::adaptiveRefine(unsigned int currentIncrement) -{ - if (userInputs.h_adaptivity == true) - { - if ((currentIncrement == 0)) - { - computing_timer.enter_subsection("matrixFreePDE: AMR"); - unsigned int numDoF_preremesh = totalDOFs; - for (unsigned int remesh_index = 0; - remesh_index < - (userInputs.max_refinement_level - userInputs.min_refinement_level); - remesh_index++) - { - adaptiveRefineCriterion(); - refineGrid(); - reinit(); - - // If the mesh hasn't changed from the previous cycle, stop - // remeshing - if (totalDOFs == numDoF_preremesh) - break; - numDoF_preremesh = totalDOFs; - } - computing_timer.leave_subsection("matrixFreePDE: AMR"); - } - else if ((currentIncrement % userInputs.skip_remeshing_steps == 0)) - { - computing_timer.enter_subsection("matrixFreePDE: AMR"); - - // Apply constraints before remeshing - for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) - { - constraintsDirichletSet[fieldIndex]->distribute(*solutionSet[fieldIndex]); - constraintsOtherSet[fieldIndex]->distribute(*solutionSet[fieldIndex]); - solutionSet[fieldIndex]->update_ghost_values(); - } - adaptiveRefineCriterion(); - refineGrid(); - reinit(); - computing_timer.leave_subsection("matrixFreePDE: AMR"); - } - } -} - -// default implementation of adaptive mesh criterion -template -void -MatrixFreePDE::adaptiveRefineCriterion() -{ - // Old code to implement a Kelly error estimator - // Kelly error estimation criterion - // estimate cell wise errors for mesh refinement - // #if hAdaptivity==true - // #ifdef adaptivityType - // #if adaptivityType=="KELLY" - // Vector estimated_error_per_cell - // (triangulation.n_locally_owned_active_cells()); - // KellyErrorEstimator::estimate - // (*dofHandlersSet_nonconst[refinementDOF], - // QGaussLobatto(degree+1), - // typename FunctionMap::type(), - // *solutionSet[refinementDOF], - // estimated_error_per_cell, - // ComponentMask(), - // 0, - // 1, - // triangulation.locally_owned_subdomain()); - // //flag cells for refinement - // parallel::distributed::GridRefinement::refine_and_coarsen_fixed_fraction - // (triangulation, - // estimated_error_per_cell, - // topRefineFraction, - // bottomCoarsenFraction); - // #endif - // #endif - // #endif - - { - std::vector> valuesV; - std::vector> gradientsV; - - QGaussLobatto quadrature(degree + 1); - const unsigned int num_quad_points = quadrature.size(); - - // Set the correct update flags - bool need_value = false; - bool need_gradient = false; - for (unsigned int field_index = 0; - field_index < userInputs.refinement_criteria.size(); - field_index++) - { - if (userInputs.refinement_criteria[field_index].criterion_type == VALUE || - userInputs.refinement_criteria[field_index].criterion_type == - VALUE_AND_GRADIENT) - { - need_value = true; - } - else if (userInputs.refinement_criteria[field_index].criterion_type == GRADIENT || - userInputs.refinement_criteria[field_index].criterion_type == - VALUE_AND_GRADIENT) - { - need_gradient = true; - } - } - dealii::UpdateFlags update_flags; - if (need_value && !need_gradient) - { - update_flags = update_values; - } - else if (!need_value && need_gradient) - { - update_flags = update_gradients; - } - else - { - update_flags = update_values | update_gradients; - } - - FEValues fe_values(*FESet[userInputs.refinement_criteria[0].variable_index], - quadrature, - update_flags); - - std::vector values(num_quad_points); - std::vector gradient_magnitudes(num_quad_points); - std::vector> gradients(num_quad_points); - - typename DoFHandler::active_cell_iterator - cell = dofHandlersSet_nonconst[userInputs.refinement_criteria[0].variable_index] - ->begin_active(), - endc = - dofHandlersSet_nonconst[userInputs.refinement_criteria[0].variable_index]->end(); - - typename parallel::distributed::Triangulation::active_cell_iterator t_cell = - triangulation.begin_active(); - - for (; cell != endc; ++cell) - { - if (cell->is_locally_owned()) - { - fe_values.reinit(cell); - - for (unsigned int field_index = 0; - field_index < userInputs.refinement_criteria.size(); - field_index++) - { - if (need_value) - { - fe_values.get_function_values( - *solutionSet[userInputs.refinement_criteria[field_index] - .variable_index], - values); - valuesV.push_back(values); - } - if (need_gradient) - { - fe_values.get_function_gradients( - *solutionSet[userInputs.refinement_criteria[field_index] - .variable_index], - gradients); - - for (unsigned int q_point = 0; q_point < num_quad_points; ++q_point) - { - gradient_magnitudes.at(q_point) = gradients.at(q_point).norm(); - } - - gradientsV.push_back(gradient_magnitudes); - } - } - - bool mark_refine = false; - - for (unsigned int q_point = 0; q_point < num_quad_points; ++q_point) - { - for (unsigned int field_index = 0; - field_index < userInputs.refinement_criteria.size(); - field_index++) - { - if (userInputs.refinement_criteria[field_index].criterion_type == - VALUE || - userInputs.refinement_criteria[field_index].criterion_type == - VALUE_AND_GRADIENT) - { - if ((valuesV[field_index][q_point] > - userInputs.refinement_criteria[field_index] - .value_lower_bound) && - (valuesV[field_index][q_point] < - userInputs.refinement_criteria[field_index] - .value_upper_bound)) - { - mark_refine = true; - break; - } - } - if (userInputs.refinement_criteria[field_index].criterion_type == - GRADIENT || - userInputs.refinement_criteria[field_index].criterion_type == - VALUE_AND_GRADIENT) - { - if (gradientsV[field_index][q_point] > - userInputs.refinement_criteria[field_index] - .gradient_lower_bound) - { - mark_refine = true; - break; - } - } - } - } - - valuesV.clear(); - gradientsV.clear(); - - // limit the maximal and minimal refinement depth of the mesh - unsigned int current_level = t_cell->level(); - - if ((mark_refine && current_level < userInputs.max_refinement_level)) - { - cell->set_refine_flag(); - } - else if (!mark_refine && current_level > userInputs.min_refinement_level) - { - cell->set_coarsen_flag(); - } - } - ++t_cell; - } - } -} - -// refine grid method -template -void -MatrixFreePDE::refineGrid() -{ - // prepare and refine - triangulation.prepare_coarsening_and_refinement(); - for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++) - { - // The following lines were from an earlier version. - // residualSet is cleared in reinit(), so I don't see the reason for the - // pointer assignment Changing to the new version has no impact on the - // solution. - //(*residualSet[fieldIndex])=(*solutionSet[fieldIndex]); - // soltransSet[fieldIndex]->prepare_for_coarsening_and_refinement(*residualSet[fieldIndex]); - - soltransSet[fieldIndex]->prepare_for_coarsening_and_refinement( - *solutionSet[fieldIndex]); - } - triangulation.execute_coarsening_and_refinement(); -} - -#include "../../include/matrixFreePDE_template_instantiations.h" diff --git a/src/matrixfree/reinit.cc b/src/matrixfree/reinit.cc index 0837f7b96..031598846 100644 --- a/src/matrixfree/reinit.cc +++ b/src/matrixfree/reinit.cc @@ -12,27 +12,26 @@ MatrixFreePDE::reinit() // setup system pcout << "Reinitializing matrix free object\n"; totalDOFs = 0; - for (typename std::vector>::iterator it = fields.begin(); it != fields.end(); - ++it) + for (const auto &field : fields) { - currentFieldIndex = it->index; + currentFieldIndex = field.index; char buffer[100]; // create FESystem FESystem *fe; - fe = FESet.at(it->index); + fe = FESet.at(field.index); // distribute DOFs DoFHandler *dof_handler; - dof_handler = dofHandlersSet_nonconst.at(it->index); + dof_handler = dofHandlersSet_nonconst.at(field.index); dof_handler->distribute_dofs(*fe); totalDOFs += dof_handler->n_dofs(); // extract locally_relevant_dofs IndexSet *locally_relevant_dofs; - locally_relevant_dofs = locally_relevant_dofsSet_nonconst.at(it->index); + locally_relevant_dofs = locally_relevant_dofsSet_nonconst.at(field.index); locally_relevant_dofs->clear(); DoFTools::extract_locally_relevant_dofs(*dof_handler, *locally_relevant_dofs); @@ -40,8 +39,8 @@ MatrixFreePDE::reinit() // create constraints AffineConstraints *constraintsDirichlet, *constraintsOther; - constraintsDirichlet = constraintsDirichletSet_nonconst.at(it->index); - constraintsOther = constraintsOtherSet_nonconst.at(it->index); + constraintsDirichlet = constraintsDirichletSet_nonconst.at(field.index); + constraintsOther = constraintsOtherSet_nonconst.at(field.index); constraintsDirichlet->clear(); constraintsDirichlet->reinit(*locally_relevant_dofs); @@ -51,11 +50,14 @@ MatrixFreePDE::reinit() // Get hanging node constraints DoFTools::make_hanging_node_constraints(*dof_handler, *constraintsOther); - // Add a constraint to fix the value at the origin to zero if all BCs are - // zero-derivative or periodic - std::vector rigidBodyModeComponents; - getComponentsWithRigidBodyModes(rigidBodyModeComponents); - setRigidBodyModeConstraints(rigidBodyModeComponents, constraintsOther, dof_handler); + // Pin solution + if (userInputs.pinned_point.find(currentFieldIndex) != + userInputs.pinned_point.end()) + { + set_rigid_body_mode_constraints(constraintsOther, + dof_handler, + userInputs.pinned_point[currentFieldIndex]); + } // Get constraints for periodic BCs setPeriodicityConstraints(constraintsOther, dof_handler); @@ -67,14 +69,14 @@ MatrixFreePDE::reinit() constraintsOther->close(); // Store Dirichlet BC DOF's - valuesDirichletSet[it->index]->clear(); + valuesDirichletSet[field.index]->clear(); for (types::global_dof_index i = 0; i < dof_handler->n_dofs(); i++) { if (locally_relevant_dofs->is_element(i)) { if (constraintsDirichlet->is_constrained(i)) { - (*valuesDirichletSet[it->index])[i] = + (*valuesDirichletSet[field.index])[i] = constraintsDirichlet->get_inhomogeneity(i); } } @@ -83,7 +85,7 @@ MatrixFreePDE::reinit() snprintf(buffer, sizeof(buffer), "field '%2s' DOF : %u (Constraint DOF : %u)\n", - it->name.c_str(), + field.name.c_str(), dof_handler->n_dofs(), constraintsDirichlet->n_constraints()); pcout << buffer; @@ -199,6 +201,9 @@ MatrixFreePDE::reinit() solutionSet[fieldIndex]->update_ghost_values(); } + // Once the initial triangulation has been set, compute element volume + compute_element_volume(); + computing_timer.leave_subsection("matrixFreePDE: reinitialization"); } diff --git a/src/matrixfree/setNonlinearEqInitialGuess.cc b/src/matrixfree/setNonlinearEqInitialGuess.cc index af64e56a2..1f8953147 100644 --- a/src/matrixfree/setNonlinearEqInitialGuess.cc +++ b/src/matrixfree/setNonlinearEqInitialGuess.cc @@ -1,6 +1,6 @@ // setNonlinearEqInitialGuess() method for MatrixFreePDE class - #include +#include #include "../../include/matrixFreePDE.h" @@ -24,14 +24,11 @@ MatrixFreePDE::setNonlinearEqInitialGuess() computeLaplaceRHS(fieldIndex); - for (std::map::const_iterator it = - valuesDirichletSet[fieldIndex]->begin(); - it != valuesDirichletSet[fieldIndex]->end(); - ++it) + for (const auto &it : *valuesDirichletSet[fieldIndex]) { - if (residualSet[fieldIndex]->in_local_range(it->first)) + if (residualSet[fieldIndex]->in_local_range(it.first)) { - (*residualSet[fieldIndex])(it->first) = 0.0; + (*residualSet[fieldIndex])(it.first) = 0.0; } } @@ -158,17 +155,20 @@ MatrixFreePDE::getLaplaceRHS( const std::pair &cell_range) const { FEEvaluation mat(data); + + dealii::EvaluationFlags::EvaluationFlags laplace_flags = + dealii::EvaluationFlags::gradients; // loop over all "cells" for (unsigned int cell = cell_range.first; cell < cell_range.second; ++cell) { mat.reinit(cell); mat.read_dof_values(src); - mat.evaluate(false, true, false); + mat.evaluate(laplace_flags); for (unsigned int q = 0; q < mat.n_q_points; ++q) { mat.submit_gradient(mat.get_gradient(q), q); } - mat.integrate(false, true); + mat.integrate(laplace_flags); mat.distribute_local_to_global(dst); } } @@ -182,17 +182,20 @@ MatrixFreePDE::getLaplaceLHS( const std::pair &cell_range) const { FEEvaluation mat(data); + + dealii::EvaluationFlags::EvaluationFlags laplace_flags = + dealii::EvaluationFlags::gradients; // loop over all "cells" for (unsigned int cell = cell_range.first; cell < cell_range.second; ++cell) { mat.reinit(cell); mat.read_dof_values(src); - mat.evaluate(false, true, false); + mat.evaluate(laplace_flags); for (unsigned int q = 0; q < mat.n_q_points; ++q) { mat.submit_gradient(-mat.get_gradient(q), q); } - mat.integrate(false, true); + mat.integrate(laplace_flags); mat.distribute_local_to_global(dst); } } diff --git a/src/matrixfree/solve.cc b/src/matrixfree/solve.cc index 391c68bb1..28d49f4ca 100644 --- a/src/matrixfree/solve.cc +++ b/src/matrixfree/solve.cc @@ -83,7 +83,16 @@ MatrixFreePDE::solve() } // check and perform adaptive mesh refinement - adaptiveRefine(currentIncrement); + if (userInputs.h_adaptivity == true && + currentIncrement % userInputs.skip_remeshing_steps == 0) + { + computing_timer.enter_subsection("matrixFreePDE: AMR"); + + AMR.do_adaptive_refinement(currentIncrement); + reinit(); + + computing_timer.leave_subsection("matrixFreePDE: AMR"); + } // Update the list of nuclei (if relevant) updateNucleiList(); diff --git a/src/matrixfree/solveIncrement.cc b/src/matrixfree/solveIncrement.cc index b65ad0cd0..3199cf0ff 100644 --- a/src/matrixfree/solveIncrement.cc +++ b/src/matrixfree/solveIncrement.cc @@ -101,263 +101,8 @@ MatrixFreePDE::solveIncrement(bool skip_time_dependent) pcout << buffer; } - // apply Dirichlet BC'se - // This clears the residual where we want to apply Dirichlet - // BCs, otherwise the solver sees a positive residual - constraintsDirichletSet[fieldIndex]->set_zero(*residualSet[fieldIndex]); - - // solver controls - - double tol_value; - if (userInputs.linear_solver_parameters.getToleranceType(fieldIndex) == - ABSOLUTE_RESIDUAL) - { - tol_value = - userInputs.linear_solver_parameters.getToleranceValue(fieldIndex); - } - else - { - tol_value = userInputs.linear_solver_parameters.getToleranceValue( - fieldIndex) * - residualSet[fieldIndex]->l2_norm(); - } - - SolverControl solver_control( - userInputs.linear_solver_parameters.getMaxIterations(fieldIndex), - tol_value); - - // Currently the only allowed solver is SolverCG, the - // SolverType input variable is a dummy - SolverCG solver(solver_control); - - // solve - try - { - if (fields[fieldIndex].type == SCALAR) - { - dU_scalar = 0.0; - solver.solve(*this, - dU_scalar, - *residualSet[fieldIndex], - IdentityMatrix(solutionSet[fieldIndex]->size())); - } - else - { - dU_vector = 0.0; - solver.solve(*this, - dU_vector, - *residualSet[fieldIndex], - IdentityMatrix(solutionSet[fieldIndex]->size())); - } - } - catch (...) - { - pcout << "\nWarning: linear solver did not converge as " - "per set tolerances. consider increasing the " - "maximum number of iterations or decreasing the " - "solver tolerance.\n"; - } - - if (userInputs.var_nonlinear[fieldIndex]) - { - // Now that we have the calculated change in the solution, - // we need to select a damping coefficient - double damping_coefficient; - - if (userInputs.nonlinear_solver_parameters.getBacktrackDampingFlag( - fieldIndex)) - { - vectorType solutionSet_old = *solutionSet[fieldIndex]; - double residual_old = residualSet[fieldIndex]->l2_norm(); - - damping_coefficient = 1.0; - bool damping_coefficient_found = false; - while (!damping_coefficient_found) - { - if (fields[fieldIndex].type == SCALAR) - { - solutionSet[fieldIndex]->sadd(1.0, - damping_coefficient, - dU_scalar); - } - else - { - solutionSet[fieldIndex]->sadd(1.0, - damping_coefficient, - dU_vector); - } - - computeNonexplicitRHS(); - - for (std::map::const_iterator it = - valuesDirichletSet[fieldIndex]->begin(); - it != valuesDirichletSet[fieldIndex]->end(); - ++it) - { - if (residualSet[fieldIndex]->in_local_range(it->first)) - { - (*residualSet[fieldIndex])(it->first) = 0.0; - } - } - - double residual_new = residualSet[fieldIndex]->l2_norm(); - - if (currentIncrement % userInputs.skip_print_steps == 0) - { - pcout << " Old residual: " << residual_old - << " Damping Coeff: " << damping_coefficient - << " New Residual: " << residual_new << std::endl; - } - - // An improved approach would use the - // Armijo–Goldstein condition to ensure a - // sufficent decrease in the residual. This way is - // just scales the residual. - if ((residual_new < - (residual_old * - userInputs.nonlinear_solver_parameters - .getBacktrackResidualDecreaseCoeff(fieldIndex))) || - damping_coefficient < 1.0e-4) - { - damping_coefficient_found = true; - } - else - { - damping_coefficient *= - userInputs.nonlinear_solver_parameters - .getBacktrackStepModifier(fieldIndex); - *solutionSet[fieldIndex] = solutionSet_old; - } - } - } - else - { - damping_coefficient = - userInputs.nonlinear_solver_parameters - .getDefaultDampingCoefficient(fieldIndex); - - if (fields[fieldIndex].type == SCALAR) - { - solutionSet[fieldIndex]->sadd(1.0, - damping_coefficient, - dU_scalar); - } - else - { - solutionSet[fieldIndex]->sadd(1.0, - damping_coefficient, - dU_vector); - } - } - - if (currentIncrement % userInputs.skip_print_steps == 0) - { - double dU_norm; - if (fields[fieldIndex].type == SCALAR) - { - dU_norm = dU_scalar.l2_norm(); - } - else - { - dU_norm = dU_vector.l2_norm(); - } - snprintf(buffer, - sizeof(buffer), - "field '%2s' [linear solve]: initial " - "residual:%12.6e, current residual:%12.6e, " - "nsteps:%u, tolerance criterion:%12.6e, " - "solution: %12.6e, dU: %12.6e\n", - fields[fieldIndex].name.c_str(), - residualSet[fieldIndex]->l2_norm(), - solver_control.last_value(), - solver_control.last_step(), - solver_control.tolerance(), - solutionSet[fieldIndex]->l2_norm(), - dU_norm); - pcout << buffer; - } - - // Check to see if this individual variable has converged - if (userInputs.nonlinear_solver_parameters.getToleranceType( - fieldIndex) == ABSOLUTE_SOLUTION_CHANGE) - { - double diff; - - if (fields[fieldIndex].type == SCALAR) - { - diff = dU_scalar.l2_norm(); - } - else - { - diff = dU_vector.l2_norm(); - } - if (currentIncrement % userInputs.skip_print_steps == 0) - { - pcout << "Relative difference between nonlinear " - "iterations: " - << diff << " " << nonlinear_it_index << " " - << currentIncrement << std::endl; - } - - if (diff > - userInputs.nonlinear_solver_parameters.getToleranceValue( - fieldIndex) && - nonlinear_it_index < - userInputs.nonlinear_solver_parameters.getMaxIterations()) - { - nonlinear_it_converged = false; - } - } - else - { - std::cerr << "PRISMS-PF Error: Nonlinear solver tolerance " - "types other than ABSOLUTE_CHANGE have yet to " - "be implemented." - << std::endl; - } - } - else - { - if (nonlinear_it_index == 0) - { - if (fields[fieldIndex].type == SCALAR) - { - *solutionSet[fieldIndex] += dU_scalar; - } - else - { - *solutionSet[fieldIndex] += dU_vector; - } - - if (currentIncrement % userInputs.skip_print_steps == 0) - { - double dU_norm; - if (fields[fieldIndex].type == SCALAR) - { - dU_norm = dU_scalar.l2_norm(); - } - else - { - dU_norm = dU_vector.l2_norm(); - } - snprintf(buffer, - sizeof(buffer), - "field '%2s' [linear solve]: initial " - "residual:%12.6e, current residual:%12.6e, " - "nsteps:%u, tolerance criterion:%12.6e, " - "solution: %12.6e, dU: %12.6e\n", - fields[fieldIndex].name.c_str(), - residualSet[fieldIndex]->l2_norm(), - solver_control.last_value(), - solver_control.last_step(), - solver_control.tolerance(), - solutionSet[fieldIndex]->l2_norm(), - dU_norm); - pcout << buffer; - } - } - } + nonlinear_it_converged = + updateImplicitSolution(fieldIndex, nonlinear_it_index); // Apply Boundary conditions applyBCs(fieldIndex); @@ -550,4 +295,256 @@ MatrixFreePDE::updateExplicitSolution(unsigned int fieldIndex) } } +template +bool +MatrixFreePDE::updateImplicitSolution(unsigned int fieldIndex, + unsigned int nonlinear_it_index) +{ + char buffer[200]; + + // Assume convergence criterion is met, unless otherwise proven later on. + bool nonlinear_it_converged = true; + + // Apply Dirichlet BC's. This clears the residual where we want to apply Dirichlet BCs, + // otherwise the solver sees a positive residual + constraintsDirichletSet[fieldIndex]->set_zero(*residualSet[fieldIndex]); + + // Grab solver controls + double tol_value; + if (userInputs.linear_solver_parameters.getToleranceType(fieldIndex) == + ABSOLUTE_RESIDUAL) + { + tol_value = userInputs.linear_solver_parameters.getToleranceValue(fieldIndex); + } + else + { + tol_value = userInputs.linear_solver_parameters.getToleranceValue(fieldIndex) * + residualSet[fieldIndex]->l2_norm(); + } + + SolverControl solver_control(userInputs.linear_solver_parameters.getMaxIterations( + fieldIndex), + tol_value); + + // Currently the only allowed solver is SolverCG, the + // SolverType input variable is a dummy + SolverCG solver(solver_control); + + // Solve + try + { + if (fields[fieldIndex].type == SCALAR) + { + dU_scalar = 0.0; + solver.solve(*this, + dU_scalar, + *residualSet[fieldIndex], + IdentityMatrix(solutionSet[fieldIndex]->size())); + } + else + { + dU_vector = 0.0; + solver.solve(*this, + dU_vector, + *residualSet[fieldIndex], + IdentityMatrix(solutionSet[fieldIndex]->size())); + } + } + catch (...) + { + pcout << "\nWarning: linear solver did not converge as " + "per set tolerances. consider increasing the " + "maximum number of iterations or decreasing the " + "solver tolerance.\n"; + } + + if (userInputs.var_nonlinear[fieldIndex]) + { + // Now that we have the calculated change in the solution, + // we need to select a damping coefficient + double damping_coefficient; + + if (userInputs.nonlinear_solver_parameters.getBacktrackDampingFlag(fieldIndex)) + { + vectorType solutionSet_old = *solutionSet[fieldIndex]; + double residual_old = residualSet[fieldIndex]->l2_norm(); + + damping_coefficient = 1.0; + bool damping_coefficient_found = false; + while (!damping_coefficient_found) + { + if (fields[fieldIndex].type == SCALAR) + { + solutionSet[fieldIndex]->sadd(1.0, damping_coefficient, dU_scalar); + } + else + { + solutionSet[fieldIndex]->sadd(1.0, damping_coefficient, dU_vector); + } + + computeNonexplicitRHS(); + + for (const auto &it : *valuesDirichletSet[fieldIndex]) + { + if (residualSet[fieldIndex]->in_local_range(it.first)) + { + (*residualSet[fieldIndex])(it.first) = 0.0; + } + } + + double residual_new = residualSet[fieldIndex]->l2_norm(); + + if (currentIncrement % userInputs.skip_print_steps == 0) + { + pcout << " Old residual: " << residual_old + << " Damping Coeff: " << damping_coefficient + << " New Residual: " << residual_new << std::endl; + } + + // An improved approach would use the + // Armijo–Goldstein condition to ensure a + // sufficent decrease in the residual. This way is + // just scales the residual. + if ((residual_new < + (residual_old * userInputs.nonlinear_solver_parameters + .getBacktrackResidualDecreaseCoeff(fieldIndex))) || + damping_coefficient < 1.0e-4) + { + damping_coefficient_found = true; + } + else + { + damping_coefficient *= + userInputs.nonlinear_solver_parameters.getBacktrackStepModifier( + fieldIndex); + *solutionSet[fieldIndex] = solutionSet_old; + } + } + } + else + { + damping_coefficient = + userInputs.nonlinear_solver_parameters.getDefaultDampingCoefficient( + fieldIndex); + + if (fields[fieldIndex].type == SCALAR) + { + solutionSet[fieldIndex]->sadd(1.0, damping_coefficient, dU_scalar); + } + else + { + solutionSet[fieldIndex]->sadd(1.0, damping_coefficient, dU_vector); + } + } + + if (currentIncrement % userInputs.skip_print_steps == 0) + { + double dU_norm; + if (fields[fieldIndex].type == SCALAR) + { + dU_norm = dU_scalar.l2_norm(); + } + else + { + dU_norm = dU_vector.l2_norm(); + } + snprintf(buffer, + sizeof(buffer), + "field '%2s' [linear solve]: initial " + "residual:%12.6e, current residual:%12.6e, " + "nsteps:%u, tolerance criterion:%12.6e, " + "solution: %12.6e, dU: %12.6e\n", + fields[fieldIndex].name.c_str(), + residualSet[fieldIndex]->l2_norm(), + solver_control.last_value(), + solver_control.last_step(), + solver_control.tolerance(), + solutionSet[fieldIndex]->l2_norm(), + dU_norm); + pcout << buffer; + } + + // Check to see if this individual variable has converged + if (userInputs.nonlinear_solver_parameters.getToleranceType(fieldIndex) == + ABSOLUTE_SOLUTION_CHANGE) + { + double diff; + + if (fields[fieldIndex].type == SCALAR) + { + diff = dU_scalar.l2_norm(); + } + else + { + diff = dU_vector.l2_norm(); + } + if (currentIncrement % userInputs.skip_print_steps == 0) + { + pcout << "Relative difference between nonlinear " + "iterations: " + << diff << " " << nonlinear_it_index << " " << currentIncrement + << std::endl; + } + + if (diff > + userInputs.nonlinear_solver_parameters.getToleranceValue(fieldIndex) && + nonlinear_it_index < + userInputs.nonlinear_solver_parameters.getMaxIterations()) + { + nonlinear_it_converged = false; + } + } + else + { + std::cerr << "PRISMS-PF Error: Nonlinear solver tolerance " + "types other than ABSOLUTE_CHANGE have yet to " + "be implemented." + << std::endl; + } + } + else + { + if (nonlinear_it_index == 0) + { + if (fields[fieldIndex].type == SCALAR) + { + *solutionSet[fieldIndex] += dU_scalar; + } + else + { + *solutionSet[fieldIndex] += dU_vector; + } + + if (currentIncrement % userInputs.skip_print_steps == 0) + { + double dU_norm; + if (fields[fieldIndex].type == SCALAR) + { + dU_norm = dU_scalar.l2_norm(); + } + else + { + dU_norm = dU_vector.l2_norm(); + } + snprintf(buffer, + sizeof(buffer), + "field '%2s' [linear solve]: initial " + "residual:%12.6e, current residual:%12.6e, " + "nsteps:%u, tolerance criterion:%12.6e, " + "solution: %12.6e, dU: %12.6e\n", + fields[fieldIndex].name.c_str(), + residualSet[fieldIndex]->l2_norm(), + solver_control.last_value(), + solver_control.last_step(), + solver_control.tolerance(), + solutionSet[fieldIndex]->l2_norm(), + dU_norm); + pcout << buffer; + } + } + } + + return nonlinear_it_converged; +} + #include "../../include/matrixFreePDE_template_instantiations.h" diff --git a/src/matrixfree/utilities.cc b/src/matrixfree/utilities.cc index 23cbb6126..44efbcb43 100644 --- a/src/matrixfree/utilities.cc +++ b/src/matrixfree/utilities.cc @@ -7,11 +7,10 @@ template unsigned int MatrixFreePDE::getFieldIndex(std::string _name) { - for (typename std::vector>::iterator it = fields.begin(); it != fields.end(); - ++it) + for (const auto &field : fields) { - if (it->name.compare(_name) == 0) - return it->index; + if (field.name.compare(_name) == 0) + return field.index; } pcout << "\nutilities.h: field '" << _name.c_str() << "' not initialized\n"; exit(-1); diff --git a/src/models/mechanics/computeStress.h b/src/models/mechanics/computeStress.h index 14db7e431..ae00cc082 100644 --- a/src/models/mechanics/computeStress.h +++ b/src/models/mechanics/computeStress.h @@ -4,7 +4,8 @@ #ifndef COMPUTESTRESS_MECHANICS_H #define COMPUTESTRESS_MECHANICS_H -#include "../../../include/matrixFreePDE.h" +#include +#include // this source file is temporarily treated as a header file (hence // #ifndef's) till library packaging scheme is finalized diff --git a/src/pFunction/pFunction.h b/src/pFunction/pFunction.h index 2dfcb7cb1..394e31020 100644 --- a/src/pFunction/pFunction.h +++ b/src/pFunction/pFunction.h @@ -7,14 +7,20 @@ // take. Currently this is only implemented for scalar functions. Vector // functions can be treated component by component. +#include + +#include "../../include/IntegrationTools/extern/PLibraryExtern.hh" +#include + namespace PFunctions { + using scalarvalueType = dealii::VectorizedArray; class pFunction { public: // Constructor, wraps the IntegrationTools checkout function - pFunction(std::string function_name); + pFunction(const std::string &function_name); // Returns the value of the function for a given input variable scalarvalueType val(scalarvalueType); @@ -33,7 +39,7 @@ namespace PFunctions PRISMS::PFunction fun; }; - pFunction::pFunction(std::string function_name) + pFunction::pFunction(const std::string &function_name) { PRISMS::PLibrary::checkout(function_name, fun); } diff --git a/src/parallelNucleationList/parallelNucleationList.cc b/src/parallelNucleationList/parallelNucleationList.cc index 82dd75444..b50a2b7b3 100644 --- a/src/parallelNucleationList/parallelNucleationList.cc +++ b/src/parallelNucleationList/parallelNucleationList.cc @@ -97,27 +97,24 @@ parallelNucleationList::sendUpdate(int procno) const std::vector s_orderParameterIndex; // Loop to store info of all nuclei into vectors - for (typename std::vector>::const_iterator thisNuclei = - newnuclei.begin(); - thisNuclei != newnuclei.end(); - ++thisNuclei) + for (const auto &thisNuclei : newnuclei) { - s_index.push_back(thisNuclei->index); - dealii::Point s_center = thisNuclei->center; + s_index.push_back(thisNuclei.index); + dealii::Point s_center = thisNuclei.center; s_center_x.push_back(s_center[0]); s_center_y.push_back(s_center[1]); if (dim == 3) s_center_z.push_back(s_center[2]); - s_semiaxis_a.push_back(thisNuclei->semiaxes[0]); - s_semiaxis_b.push_back(thisNuclei->semiaxes[1]); + s_semiaxis_a.push_back(thisNuclei.semiaxes[0]); + s_semiaxis_b.push_back(thisNuclei.semiaxes[1]); if (dim == 3) - s_semiaxis_c.push_back(thisNuclei->semiaxes[2]); + s_semiaxis_c.push_back(thisNuclei.semiaxes[2]); - s_seededTime.push_back(thisNuclei->seededTime); - s_seedingTime.push_back(thisNuclei->seedingTime); - s_seedingTimestep.push_back(thisNuclei->seedingTimestep); - s_orderParameterIndex.push_back(thisNuclei->orderParameterIndex); + s_seededTime.push_back(thisNuclei.seededTime); + s_seedingTime.push_back(thisNuclei.seedingTime); + s_seedingTimestep.push_back(thisNuclei.seedingTimestep); + s_orderParameterIndex.push_back(thisNuclei.orderParameterIndex); } // Send vectors to next processor MPI_Send(&s_index[0], currnonucs, MPI_UNSIGNED, procno, 1, MPI_COMM_WORLD); @@ -272,8 +269,8 @@ parallelNucleationList::receiveUpdate(int procno) // Loop to store info in vectors onto the nuclei structure for (int jnuc = 0; jnuc <= recvnonucs - 1; jnuc++) { - nucleus *temp = new nucleus; - temp->index = r_index[jnuc]; + auto *temp = new nucleus; + temp->index = r_index[jnuc]; dealii::Point r_center; r_center[0] = r_center_x[jnuc]; r_center[1] = r_center_y[jnuc]; @@ -341,13 +338,10 @@ parallelNucleationList::broadcastUpdate(int broadcastProc, int thisProc) if (thisProc == broadcastProc) { - for (typename std::vector>::iterator thisNuclei = - newnuclei.begin(); - thisNuclei != newnuclei.end(); - ++thisNuclei) + for (const auto &thisNuclei : newnuclei) { - r_index.push_back(thisNuclei->index); - dealii::Point s_center = thisNuclei->center; + r_index.push_back(thisNuclei.index); + dealii::Point s_center = thisNuclei.center; r_center_x.push_back(s_center[0]); r_center_y.push_back(s_center[1]); if (dim == 3) @@ -355,17 +349,17 @@ parallelNucleationList::broadcastUpdate(int broadcastProc, int thisProc) r_center_z.push_back(s_center[2]); } - r_semiaxis_a.push_back(thisNuclei->semiaxes[0]); - r_semiaxis_b.push_back(thisNuclei->semiaxes[1]); + r_semiaxis_a.push_back(thisNuclei.semiaxes[0]); + r_semiaxis_b.push_back(thisNuclei.semiaxes[1]); if (dim == 3) { - r_semiaxis_c.push_back(thisNuclei->semiaxes[2]); + r_semiaxis_c.push_back(thisNuclei.semiaxes[2]); } - r_seededTime.push_back(thisNuclei->seededTime); - r_seedingTime.push_back(thisNuclei->seedingTime); - r_seedingTimestep.push_back(thisNuclei->seedingTimestep); - r_orderParameterIndex.push_back(thisNuclei->orderParameterIndex); + r_seededTime.push_back(thisNuclei.seededTime); + r_seedingTime.push_back(thisNuclei.seedingTime); + r_seedingTimestep.push_back(thisNuclei.seedingTimestep); + r_orderParameterIndex.push_back(thisNuclei.orderParameterIndex); } } @@ -403,8 +397,8 @@ parallelNucleationList::broadcastUpdate(int broadcastProc, int thisProc) // Loop to store info in vectors onto the nuclei structure for (int jnuc = 0; jnuc <= currnonucs - 1; jnuc++) { - nucleus *temp = new nucleus; - temp->index = r_index[jnuc]; + auto *temp = new nucleus; + temp->index = r_index[jnuc]; dealii::Point r_center; r_center[0] = r_center_x[jnuc]; r_center[1] = r_center_y[jnuc]; @@ -545,9 +539,9 @@ parallelNucleationList::removeSubsetOfNuclei( nuclei_to_remove = recieved_nuclei_to_remove; } - for (unsigned int i = 0; i < nuclei_to_remove.size(); i++) + for (unsigned int i : nuclei_to_remove) { - std::cout << thisProc << ": " << nuclei_to_remove[i] << std::endl; + std::cout << thisProc << ": " << i << std::endl; } // Remove the nuclei from the list @@ -555,9 +549,9 @@ parallelNucleationList::removeSubsetOfNuclei( for (unsigned int nuc = 0; nuc < newnuclei.size(); nuc++) { bool pruneNucleus = false; - for (unsigned int i = 0; i < nuclei_to_remove.size(); i++) + for (unsigned int i : nuclei_to_remove) { - if (nuclei_to_remove[i] == nuclei_size + nuc) + if (i == nuclei_size + nuc) { pruneNucleus = true; break; diff --git a/src/userInputParameters/loadVariableAttributes.cc b/src/userInputParameters/loadVariableAttributes.cc index e292d47aa..942936973 100644 --- a/src/userInputParameters/loadVariableAttributes.cc +++ b/src/userInputParameters/loadVariableAttributes.cc @@ -1,6 +1,5 @@ -#include "../../include/userInputParameters.h" -// #include "../../include/sortIndexEntryPairList.h" #include "../../include/EquationDependencyParser.h" +#include "../../include/userInputParameters.h" template void @@ -35,14 +34,8 @@ userInputParameters::loadVariableAttributes( } } - if (nucleating_variable_indices.size() > 0) - { - nucleation_occurs = true; - } - else - { - nucleation_occurs = false; - } + nucleating_variable_indices.size() > 0 ? nucleation_occurs = true + : nucleation_occurs = false; // Load these attributes into the varInfoList objects @@ -50,60 +43,28 @@ userInputParameters::loadVariableAttributes( num_var_explicit_RHS = 0; for (unsigned int i = 0; i < number_of_variables; i++) { - if (variable_attributes.equation_dependency_parser.need_value_explicit_RHS[i] or - variable_attributes.equation_dependency_parser.need_gradient_explicit_RHS[i] or - variable_attributes.equation_dependency_parser.need_hessian_explicit_RHS[i]) + if (!(variable_attributes.equation_dependency_parser.eval_flags_explicit_RHS[i] & + dealii::EvaluationFlags::nothing)) { num_var_explicit_RHS++; } } varInfoListExplicitRHS.reserve(num_var_explicit_RHS); - unsigned int scalar_var_index = 0; - unsigned int vector_var_index = 0; for (unsigned int i = 0; i < number_of_variables; i++) { variable_info varInfo; - varInfo.need_value = - variable_attributes.equation_dependency_parser.need_value_explicit_RHS[i]; - varInfo.need_gradient = - variable_attributes.equation_dependency_parser.need_gradient_explicit_RHS[i]; - varInfo.need_hessian = - variable_attributes.equation_dependency_parser.need_hessian_explicit_RHS[i]; - varInfo.value_residual = variable_attributes.equation_dependency_parser - .need_value_residual_explicit_RHS[i]; - varInfo.gradient_residual = variable_attributes.equation_dependency_parser - .need_gradient_residual_explicit_RHS[i]; + varInfo.evaluation_flags = + variable_attributes.equation_dependency_parser.eval_flags_explicit_RHS[i]; + + varInfo.residual_flags = variable_attributes.equation_dependency_parser + .eval_flags_residual_explicit_RHS[i]; varInfo.global_var_index = i; - if (varInfo.need_value or varInfo.need_gradient or varInfo.need_hessian) - { - varInfo.var_needed = true; - } - else - { - varInfo.var_needed = false; - } + varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - if (var_type[i] == SCALAR) - { - varInfo.is_scalar = true; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = scalar_var_index; - scalar_var_index++; - } - } - else - { - varInfo.is_scalar = false; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = vector_var_index; - vector_var_index++; - } - } + varInfo.is_scalar = var_type[i] == SCALAR; varInfoListExplicitRHS.push_back(varInfo); } @@ -112,61 +73,28 @@ userInputParameters::loadVariableAttributes( num_var_nonexplicit_RHS = 0; for (unsigned int i = 0; i < number_of_variables; i++) { - if (variable_attributes.equation_dependency_parser.need_value_nonexplicit_RHS[i] or - variable_attributes.equation_dependency_parser - .need_gradient_nonexplicit_RHS[i] or - variable_attributes.equation_dependency_parser.need_hessian_nonexplicit_RHS[i]) + if (!(variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_RHS[i] & + dealii::EvaluationFlags::nothing)) { num_var_nonexplicit_RHS++; } } varInfoListNonexplicitRHS.reserve(num_var_nonexplicit_RHS); - scalar_var_index = 0; - vector_var_index = 0; for (unsigned int i = 0; i < number_of_variables; i++) { variable_info varInfo; - varInfo.need_value = - variable_attributes.equation_dependency_parser.need_value_nonexplicit_RHS[i]; - varInfo.need_gradient = - variable_attributes.equation_dependency_parser.need_gradient_nonexplicit_RHS[i]; - varInfo.need_hessian = - variable_attributes.equation_dependency_parser.need_hessian_nonexplicit_RHS[i]; - varInfo.value_residual = variable_attributes.equation_dependency_parser - .need_value_residual_nonexplicit_RHS[i]; - varInfo.gradient_residual = variable_attributes.equation_dependency_parser - .need_gradient_residual_nonexplicit_RHS[i]; + varInfo.evaluation_flags = + variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_RHS[i]; + + varInfo.residual_flags = variable_attributes.equation_dependency_parser + .eval_flags_residual_nonexplicit_RHS[i]; varInfo.global_var_index = i; - if (varInfo.need_value or varInfo.need_gradient or varInfo.need_hessian) - { - varInfo.var_needed = true; - } - else - { - varInfo.var_needed = false; - } + varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - if (var_type[i] == SCALAR) - { - varInfo.is_scalar = true; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = scalar_var_index; - scalar_var_index++; - } - } - else - { - varInfo.is_scalar = false; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = vector_var_index; - vector_var_index++; - } - } + varInfo.is_scalar = var_type[i] == SCALAR; varInfoListNonexplicitRHS.push_back(varInfo); } @@ -175,115 +103,50 @@ userInputParameters::loadVariableAttributes( num_var_LHS = 0; for (unsigned int i = 0; i < number_of_variables; i++) { - if (variable_attributes.equation_dependency_parser.need_value_nonexplicit_LHS[i] or - variable_attributes.equation_dependency_parser - .need_gradient_nonexplicit_LHS[i] or - variable_attributes.equation_dependency_parser.need_hessian_nonexplicit_LHS[i]) + if (!(variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_LHS[i] & + dealii::EvaluationFlags::nothing)) { num_var_LHS++; } } varInfoListLHS.reserve(num_var_LHS); - scalar_var_index = 0; - vector_var_index = 0; for (unsigned int i = 0; i < number_of_variables; i++) { variable_info varInfo; - varInfo.need_value = - variable_attributes.equation_dependency_parser.need_value_nonexplicit_LHS[i]; - varInfo.need_gradient = - variable_attributes.equation_dependency_parser.need_gradient_nonexplicit_LHS[i]; - varInfo.need_hessian = - variable_attributes.equation_dependency_parser.need_hessian_nonexplicit_LHS[i]; - varInfo.value_residual = variable_attributes.equation_dependency_parser - .need_value_residual_nonexplicit_LHS[i]; - varInfo.gradient_residual = variable_attributes.equation_dependency_parser - .need_gradient_residual_nonexplicit_LHS[i]; + varInfo.evaluation_flags = + variable_attributes.equation_dependency_parser.eval_flags_nonexplicit_LHS[i]; + + varInfo.residual_flags = variable_attributes.equation_dependency_parser + .eval_flags_residual_nonexplicit_LHS[i]; varInfo.global_var_index = i; - if (varInfo.need_value or varInfo.need_gradient or varInfo.need_hessian) - { - varInfo.var_needed = true; - } - else - { - varInfo.var_needed = false; - } + varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - if (var_type[i] == SCALAR) - { - varInfo.is_scalar = true; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = scalar_var_index; - scalar_var_index++; - } - } - else - { - varInfo.is_scalar = false; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = vector_var_index; - vector_var_index++; - } - } + varInfo.is_scalar = var_type[i] == SCALAR; varInfoListLHS.push_back(varInfo); } varChangeInfoListLHS.reserve(num_var_LHS); - scalar_var_index = 0; - vector_var_index = 0; for (unsigned int i = 0; i < number_of_variables; i++) { variable_info varInfo; - varInfo.need_value = variable_attributes.equation_dependency_parser - .need_value_change_nonexplicit_LHS[i]; - varInfo.need_gradient = variable_attributes.equation_dependency_parser - .need_gradient_change_nonexplicit_LHS[i]; - varInfo.need_hessian = variable_attributes.equation_dependency_parser - .need_hessian_change_nonexplicit_LHS[i]; + varInfo.evaluation_flags = variable_attributes.equation_dependency_parser + .eval_flags_change_nonexplicit_LHS[i]; // FOR NOW, TAKING THESE FROM THE VARIABLE ITSELF!! - varInfo.value_residual = variable_attributes.equation_dependency_parser - .need_value_residual_nonexplicit_LHS[i]; - varInfo.gradient_residual = variable_attributes.equation_dependency_parser - .need_gradient_residual_nonexplicit_LHS[i]; + varInfo.residual_flags = variable_attributes.equation_dependency_parser + .eval_flags_residual_nonexplicit_LHS[i]; varInfo.global_var_index = i; - if (varInfo.need_value or varInfo.need_gradient or varInfo.need_hessian) - { - varInfo.var_needed = true; - } - else - { - varInfo.var_needed = false; - } + varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - if (var_type[i] == SCALAR) - { - varInfo.is_scalar = true; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = scalar_var_index; - scalar_var_index++; - } - } - else - { - varInfo.is_scalar = false; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = vector_var_index; - vector_var_index++; - } - } + varInfo.is_scalar = var_type[i] == SCALAR; varChangeInfoListLHS.push_back(varInfo); } @@ -291,64 +154,26 @@ userInputParameters::loadVariableAttributes( // Load variable information for postprocessing // First, the info list for the base field variables pp_baseVarInfoList.reserve(number_of_variables); - scalar_var_index = 0; - vector_var_index = 0; for (unsigned int i = 0; i < number_of_variables; i++) { variable_info varInfo; - varInfo.need_value = - variable_attributes.equation_dependency_parser.pp_need_value[i]; - varInfo.need_gradient = - variable_attributes.equation_dependency_parser.pp_need_gradient[i]; - varInfo.need_hessian = - variable_attributes.equation_dependency_parser.pp_need_hessian[i]; + varInfo.evaluation_flags = + variable_attributes.equation_dependency_parser.eval_flags_postprocess[i]; varInfo.global_var_index = i; - if (variable_attributes.equation_dependency_parser.pp_need_value[i] or - variable_attributes.equation_dependency_parser.pp_need_gradient[i] or - variable_attributes.equation_dependency_parser.pp_need_hessian[i]) - { - varInfo.var_needed = true; - } - else - { - varInfo.var_needed = false; - } + varInfo.var_needed = !(varInfo.evaluation_flags & dealii::EvaluationFlags::nothing); - if (var_type[i] == SCALAR) - { - varInfo.is_scalar = true; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = scalar_var_index; - scalar_var_index++; - } - } - else - { - varInfo.is_scalar = false; - if (varInfo.var_needed) - { - varInfo.scalar_or_vector_index = vector_var_index; - vector_var_index++; - } - } + varInfo.is_scalar = var_type[i] == SCALAR; pp_baseVarInfoList.push_back(varInfo); } // Now load the information for the post-processing variables // Parameters for postprocessing - if (pp_number_of_variables > 0) - { - postProcessingRequired = true; - } - else - { - postProcessingRequired = false; - } + pp_number_of_variables > 0 ? postProcessingRequired = true + : postProcessingRequired = false; num_integrated_fields = 0; for (unsigned int i = 0; i < pp_number_of_variables; i++) @@ -362,31 +187,18 @@ userInputParameters::loadVariableAttributes( // The info list for the postprocessing field variables pp_varInfoList.reserve(pp_number_of_variables); - scalar_var_index = 0; - vector_var_index = 0; for (unsigned int i = 0; i < pp_number_of_variables; i++) { variable_info varInfo; varInfo.var_needed = true; - varInfo.value_residual = - variable_attributes.equation_dependency_parser.pp_need_value_residual[i]; - varInfo.gradient_residual = - variable_attributes.equation_dependency_parser.pp_need_gradient_residual[i]; + varInfo.residual_flags = + variable_attributes.equation_dependency_parser.eval_flags_residual_postprocess[i]; varInfo.global_var_index = i; - if (pp_var_type[i] == SCALAR) - { - varInfo.is_scalar = true; - varInfo.scalar_or_vector_index = scalar_var_index; - scalar_var_index++; - } - else - { - varInfo.is_scalar = false; - varInfo.scalar_or_vector_index = vector_var_index; - vector_var_index++; - } + + varInfo.is_scalar = pp_var_type[i] == SCALAR; + pp_varInfoList.push_back(varInfo); } } diff --git a/src/userInputParameters/load_BC_list.cc b/src/userInputParameters/load_BC_list.cc index bf423507f..0492cdd84 100644 --- a/src/userInputParameters/load_BC_list.cc +++ b/src/userInputParameters/load_BC_list.cc @@ -1,102 +1,94 @@ +// ------------------------------------------------------------------------ +// Method to extract the list of boundary conditions from input parameters +// and store them in BC_list object +// ------------------------------------------------------------------------ + +#include + #include "../../include/userInputParameters.h" -// ========================================================================================== -// Method to extract the list of boundary conditions -// ========================================================================================== template void -userInputParameters::load_BC_list(std::vector list_of_BCs) +userInputParameters::load_BC_list(const std::vector &list_of_BCs) { - // Load the BC information from the strings into a varBCs object - // Move this to a new method and write a unit test for it!!!! - + // Loop over the list of boundary conditions specified in parameters + // and provided in the input list_of_BCs. Process the BCs and place + // them into the vector BC_list std::vector temp; - - for (unsigned int i = 0; i < list_of_BCs.size(); i++) + for (const auto &boundary_condition : list_of_BCs) { + // Ensure all variables have BCs specified in parameters.prm + AssertThrow(!boundary_condition.empty(), + dealii::ExcMessage(std::string("Boundary condition not specified."))); + varBCs newBC; - temp = dealii::Utilities::split_string_list(list_of_BCs[i]); + temp = dealii::Utilities::split_string_list(boundary_condition); - // If there is only one BC listed, make another dim*2-1 copies of it so - // that the same BC is applied for all boundaries + // If there is only one BC listed, make another 2*dim-1 copies of it so that + // the same BC is applied for all boundaries if (temp.size() == 1) { - for (unsigned int boundary = 0; boundary < (dim * 2 - 1); boundary++) - { - temp.push_back(temp[0]); - } + temp.resize(2 * dim, temp[0]); } - // Load the BC for each boundary into 'newBC' - for (unsigned int i = 0; i < (2 * dim); i++) + // Load the BC for each boundary into 'newBC'. + for (unsigned int j = 0; j < (2 * dim); j++) { - if (boost::iequals(temp[i], "NATURAL")) + if (boost::iequals(temp[j], "NATURAL")) { newBC.var_BC_type.push_back(NATURAL); newBC.var_BC_val.push_back(0.0); } - else if (boost::iequals(temp[i], "PERIODIC")) + else if (boost::iequals(temp[j], "PERIODIC")) { newBC.var_BC_type.push_back(PERIODIC); newBC.var_BC_val.push_back(0.0); } - else if (boost::iequals(temp[i], "NON_UNIFORM_DIRICHLET")) + else if (boost::iequals(temp[j], "NON_UNIFORM_DIRICHLET")) { newBC.var_BC_type.push_back(NON_UNIFORM_DIRICHLET); newBC.var_BC_val.push_back(0.0); } - else if (boost::iequals(temp[i].substr(0, 9), "DIRICHLET")) + else if (boost::iequals(temp[j].substr(0, 9), "DIRICHLET")) { newBC.var_BC_type.push_back(DIRICHLET); - std::string dirichlet_val = temp[i].substr(10, temp[i].size()); + std::string dirichlet_val = temp[j].substr(10, temp[j].size()); dirichlet_val = dealii::Utilities::trim(dirichlet_val); newBC.var_BC_val.push_back( dealii::Utilities::string_to_double(dirichlet_val)); } - else if (boost::iequals(temp[i].substr(0, 7), "NEUMANN")) + else if (boost::iequals(temp[j].substr(0, 7), "NEUMANN")) { newBC.var_BC_type.push_back(NEUMANN); - std::string neumann_val = temp[i].substr(8, temp[i].size()); + std::string neumann_val = temp[j].substr(8, temp[j].size()); neumann_val = dealii::Utilities::trim(neumann_val); newBC.var_BC_val.push_back( dealii::Utilities::string_to_double(neumann_val)); } else { - std::cout << temp[i].substr(0, 8) << std::endl; + std::cout << temp[j].substr(0, 8) << std::endl; std::cout << "Error: Boundary conditions specified improperly." << std::endl; abort(); } + + // If periodic BCs are used, ensure they are applied on both sides of + // domain + if (j % 2 == 0) + { + AssertThrow(!((boost::iequals(temp[j], "PERIODIC") && + !boost::iequals(temp[j + 1], "PERIODIC")) || + (!boost::iequals(temp[j], "PERIODIC") && + boost::iequals(temp[j + 1], "PERIODIC"))), + dealii::ExcMessage( + std::string("Periodic boundary condition must be " + "specified on both sides of domain"))); + } } + // Append BCs for current field to total list BC_list.push_back(newBC); - - // Validate input using something like this: - // try{ - // if ((BC_type_dim1_min == "PERIODIC") && (BC_type_dim1_max != - // "PERIODIC")){ - // throw 0; - // } - // if ((BC_type_dim2_min == "PERIODIC") && (BC_type_dim2_max != - // "PERIODIC")){ - // throw 0; - // } - // if ((BC_type_dim3_min == "PERIODIC") && (BC_type_dim3_max != - // "PERIODIC")){ - // throw 0; - // } - // } - // catch (int e){ - // if (e == 0){ - // std::cout << "Error: For periodic BCs, both faces for a given - // direction must be set as periodic. " - // "Please check the BCs that are set in ICs_and_BCs.h." - // << std::endl; - // } - // abort(); - // } } } -// Template instantiations -#include "../../include/userInputParameters_template_instantiations.h" +#include "../../include/userInputParameters_template_instantiations.h" \ No newline at end of file diff --git a/src/userInputParameters/load_user_constants.cc b/src/userInputParameters/load_user_constants.cc index 11466ec30..5726daff9 100644 --- a/src/userInputParameters/load_user_constants.cc +++ b/src/userInputParameters/load_user_constants.cc @@ -89,7 +89,7 @@ userInputParameters::load_user_constants(inputFileReader &input_fi std::size_t index = 0; while (index != std::string::npos) { - index = model_constants_strings.at(element).find("("); + index = model_constants_strings.at(element).find('('); if (index != std::string::npos) { model_constants_strings.at(element).erase(index, 1); @@ -99,7 +99,7 @@ userInputParameters::load_user_constants(inputFileReader &input_fi index = 0; while (index != std::string::npos) { - index = model_constants_strings.at(element).find(")"); + index = model_constants_strings.at(element).find(')'); if (index != std::string::npos) { model_constants_strings.at(element).erase(index, 1); @@ -191,7 +191,7 @@ userInputParameters::load_user_constants(inputFileReader &input_fi std::size_t index = 0; while (index != std::string::npos) { - index = model_constants_strings.at(element).find("("); + index = model_constants_strings.at(element).find('('); if (index != std::string::npos) { model_constants_strings.at(element).erase(index, 1); @@ -201,7 +201,7 @@ userInputParameters::load_user_constants(inputFileReader &input_fi index = 0; while (index != std::string::npos) { - index = model_constants_strings.at(element).find(")"); + index = model_constants_strings.at(element).find(')'); if (index != std::string::npos) { model_constants_strings.at(element).erase(index, 1); @@ -248,7 +248,7 @@ userInputParameters::load_user_constants(inputFileReader &input_fi template dealii::Tensor<2, 2 * dim - 1 + dim / 3> userInputParameters::get_Cij_tensor(std::vector elastic_constants, - const std::string elastic_const_symmetry) const + const std::string &elastic_const_symmetry) const { // First set the material model elasticityModel mat_model = ISOTROPIC; @@ -284,9 +284,9 @@ userInputParameters::get_Cij_tensor(std::vector elastic_constants, std::vector elastic_constants_temp = elastic_constants; elastic_constants.clear(); std::vector indices_2D = {0, 1, 5, 6, 10, 14}; - for (unsigned int i = 0; i < indices_2D.size(); i++) + for (const auto &index : indices_2D) { - elastic_constants.push_back(elastic_constants_temp.at(indices_2D.at(i))); + elastic_constants.push_back(elastic_constants_temp.at(index)); } } @@ -323,7 +323,7 @@ userInputParameters::get_Cij_tensor(std::vector elastic_constants, template dealii::Tensor<2, 2 * dim - 1 + dim / 3> userInputParameters::getCIJMatrix(const elasticityModel model, - const std::vector constants, + const std::vector &constants, dealii::ConditionalOStream &pcout) const { // CIJ.fill(0.0); diff --git a/src/userInputParameters/setTimeStepList.cc b/src/userInputParameters/setTimeStepList.cc index 287ac68bd..7f7cc56b6 100644 --- a/src/userInputParameters/setTimeStepList.cc +++ b/src/userInputParameters/setTimeStepList.cc @@ -1,63 +1,82 @@ +#include + #include "../../include/userInputParameters.h" +#include template std::vector userInputParameters::setTimeStepList( - const std::string outputSpacingType, + const std::string &outputSpacingType, unsigned int numberOfOutputs, const std::vector &userGivenTimeStepList) { + // Initialize timestep list std::vector timeStepList; - if (numberOfOutputs > 0) + // The number of outputs cannot be greater than the number increments + if (numberOfOutputs > totalIncrements) { - if (outputSpacingType == "EQUAL_SPACING") - { - if (numberOfOutputs > totalIncrements) - numberOfOutputs = totalIncrements; + numberOfOutputs = totalIncrements; + } - for (unsigned int iter = 0; iter <= totalIncrements; - iter += totalIncrements / numberOfOutputs) - { - timeStepList.push_back(iter); - } + // Prevent divide by zero in subsequent output types by returning the a vector where the + // only entry is one greater than the number of increments. This way, we effectively + // have no outputs. While this condition can be ignored for the LIST type, the user + // should just ignore the parameter `set Number of outputs` and use the default value + // of 10. + if (numberOfOutputs == 0) + { + timeStepList.push_back(totalIncrements + 1); + return timeStepList; + } + + // Set output list for all the output list types + if (outputSpacingType == "LIST") + { + timeStepList = userGivenTimeStepList; + } + else if (outputSpacingType == "EQUAL_SPACING") + { + for (unsigned int iter = 0; iter <= totalIncrements; + iter += totalIncrements / numberOfOutputs) + { + timeStepList.push_back(iter); } - else if (outputSpacingType == "LOG_SPACING") + } + else if (outputSpacingType == "LOG_SPACING") + { + timeStepList.push_back(0); + for (unsigned int output = 1; output <= numberOfOutputs; output++) { - timeStepList.push_back(0); - for (unsigned int output = 1; output <= numberOfOutputs; output++) - { - timeStepList.push_back( - round(std::pow(10, - double(output) / double(numberOfOutputs) * - std::log10(totalIncrements)))); - } + timeStepList.push_back(round(std::pow(static_cast(totalIncrements), + static_cast(output) / + static_cast(numberOfOutputs)))); } - else if (outputSpacingType == "N_PER_DECADE") + } + else if (outputSpacingType == "N_PER_DECADE") + { + AssertThrow(totalIncrements > 1, + dealii::ExcMessage( + std::string("PRISMS-PF Error: For n per decaded spaced outputs, " + "the number of increments must be greater than 1."))); + + timeStepList.push_back(0); + timeStepList.push_back(1); + for (unsigned int iter = 2; iter <= totalIncrements; iter++) { - timeStepList.push_back(0); - timeStepList.push_back(1); - for (unsigned int iter = 2; iter <= totalIncrements; iter++) + unsigned int decade = std::ceil(std::log10(iter)); + unsigned int step_size = std::pow(10, decade) / numberOfOutputs; + if (iter % step_size == 0) { - int decade = std::ceil(std::log10(iter)); - int step_size = (std::pow(10, decade)) / numberOfOutputs; - if (iter % step_size == 0) - { - timeStepList.push_back(iter); - } + timeStepList.push_back(iter); } } } - else if (outputSpacingType == "LIST") - { - timeStepList = userGivenTimeStepList; - } else { - // I'm not sure why this is set up this way. It seems like the intuitive - // thing would be to have an empty list, not a list with one entry that is - // higher than will be reached during time stepping. - timeStepList.push_back(totalIncrements + 1); + AssertThrow(false, + dealii::ExcMessage( + std::string("PRISMS-PF Error: Invalid output spacing type."))); } return timeStepList; diff --git a/src/userInputParameters/userInputParameters.cc b/src/userInputParameters/userInputParameters.cc index 49c737eaa..a1f460ddb 100644 --- a/src/userInputParameters/userInputParameters.cc +++ b/src/userInputParameters/userInputParameters.cc @@ -77,7 +77,7 @@ userInputParameters::userInputParameters(inputFileReader &input_fi new_criterion.variable_name = input_file_reader.var_names.at(i); if (boost::iequals(crit_type_string, "VALUE")) { - new_criterion.criterion_type = VALUE; + new_criterion.criterion_type = criterion_value; new_criterion.value_lower_bound = parameter_handler.get_double("Value lower bound"); new_criterion.value_upper_bound = @@ -97,13 +97,13 @@ userInputParameters::userInputParameters(inputFileReader &input_fi } else if (boost::iequals(crit_type_string, "GRADIENT")) { - new_criterion.criterion_type = GRADIENT; + new_criterion.criterion_type = criterion_gradient; new_criterion.gradient_lower_bound = parameter_handler.get_double("Gradient magnitude lower bound"); } else if (boost::iequals(crit_type_string, "VALUE_AND_GRADIENT")) { - new_criterion.criterion_type = VALUE_AND_GRADIENT; + new_criterion.criterion_type = criterion_value | criterion_gradient; new_criterion.value_lower_bound = parameter_handler.get_double("Value lower bound"); new_criterion.value_upper_bound = @@ -313,8 +313,11 @@ userInputParameters::userInputParameters(inputFileReader &input_fi dealii::Utilities::string_to_int(dealii::Utilities::split_string_list( parameter_handler.get("List of time steps to output"))); std::vector user_given_time_step_list; - for (unsigned int i = 0; i < user_given_time_step_list_temp.size(); i++) - user_given_time_step_list.push_back(user_given_time_step_list_temp[i]); + user_given_time_step_list.reserve(user_given_time_step_list_temp.size()); + for (const auto &time_step : user_given_time_step_list_temp) + { + user_given_time_step_list.push_back(time_step); + } skip_print_steps = parameter_handler.get_integer("Skip print steps"); output_file_type = parameter_handler.get("Output file type"); @@ -343,10 +346,9 @@ userInputParameters::userInputParameters(inputFileReader &input_fi // If all of the variables are ELLIPTIC, then totalIncrements should be 1 and // finalTime should be 0 bool only_time_independent_pdes = true; - for (unsigned int i = 0; i < var_eq_type.size(); i++) + for (const auto &var_type : var_eq_type) { - if (var_eq_type.at(i) == EXPLICIT_TIME_DEPENDENT || - var_eq_type.at(i) == IMPLICIT_TIME_DEPENDENT) + if (var_type == EXPLICIT_TIME_DEPENDENT || var_type == IMPLICIT_TIME_DEPENDENT) { only_time_independent_pdes = false; break; @@ -450,10 +452,12 @@ userInputParameters::userInputParameters(inputFileReader &input_fi dealii::Utilities::string_to_int(dealii::Utilities::split_string_list( parameter_handler.get("List of time steps to save checkpoints"))); std::vector user_given_checkpoint_time_step_list; - for (unsigned int i = 0; i < user_given_checkpoint_time_step_list_temp.size(); i++) - user_given_checkpoint_time_step_list.push_back( - user_given_checkpoint_time_step_list_temp[i]); - + user_given_checkpoint_time_step_list.reserve( + user_given_checkpoint_time_step_list_temp.size()); + for (const auto &checkpoint_step : user_given_checkpoint_time_step_list_temp) + { + user_given_checkpoint_time_step_list.push_back(checkpoint_step); + } checkpointTimeStepList = setTimeStepList(checkpoint_condition, num_checkpoints, user_given_checkpoint_time_step_list); @@ -571,13 +575,12 @@ userInputParameters::userInputParameters(inputFileReader &input_fi std::vector variables_for_remapping_str = dealii::Utilities::split_string_list( parameter_handler.get("Order parameter fields for grain reassignment")); - for (unsigned int field = 0; field < variables_for_remapping_str.size(); field++) + for (const auto &field : variables_for_remapping_str) { bool field_found = false; for (unsigned int i = 0; i < number_of_variables; i++) { - if (boost::iequals(variables_for_remapping_str[field], - variable_attributes.var_name_list[i].second)) + if (boost::iequals(field, variable_attributes.var_name_list[i].second)) { variables_for_remapping.push_back( variable_attributes.var_name_list[i].first); @@ -591,7 +594,7 @@ userInputParameters::userInputParameters(inputFileReader &input_fi "parameter fields used for grain reassignment must " "match the variable names in equations.h." << std::endl; - std::cerr << variables_for_remapping_str[field] << std::endl; + std::cerr << field << std::endl; abort(); } } @@ -627,13 +630,47 @@ userInputParameters::userInputParameters(inputFileReader &input_fi bc_text.append(", y component"); list_of_BCs.push_back(parameter_handler.get(bc_text)); - bc_text = "Boundary condition for variable "; - bc_text.append(var_name.at(i)); - bc_text.append(", z component"); - list_of_BCs.push_back(parameter_handler.get(bc_text)); + if (dim > 2) + { + bc_text = "Boundary condition for variable "; + bc_text.append(var_name.at(i)); + bc_text.append(", z component"); + list_of_BCs.push_back(parameter_handler.get(bc_text)); + } } } + /*---------------------- + | Pinning point + -----------------------*/ + for (unsigned int i = 0; i < number_of_variables; i++) + { + std::string pinning_text = "Pinning point: "; + pinning_text.append(input_file_reader.var_names.at(i)); + parameter_handler.enter_subsection(pinning_text); + + // Skip if the default + if (parameter_handler.get_double("x") == -1.0) + { + parameter_handler.leave_subsection(); + continue; + } + + // Otherwise, fill out point + if (dim == 2) + { + pinned_point[i] = dealii::Point(parameter_handler.get_double("x"), + parameter_handler.get_double("y")); + } + else + { + pinned_point[i] = dealii::Point(parameter_handler.get_double("x"), + parameter_handler.get_double("y"), + parameter_handler.get_double("z")); + } + parameter_handler.leave_subsection(); + } + // Load the BC information from the strings into a varBCs object load_BC_list(list_of_BCs); diff --git a/src/utilities/sortIndexEntryPairList.cc b/src/utilities/sortIndexEntryPairList.cc index f70384603..3bf75d1ff 100644 --- a/src/utilities/sortIndexEntryPairList.cc +++ b/src/utilities/sortIndexEntryPairList.cc @@ -2,9 +2,9 @@ std::vector sortIndexEntryPairList( - const std::vector> unsorted_pair_list, - unsigned int number_of_variables, - bool default_value) + const std::vector> &unsorted_pair_list, + unsigned int number_of_variables, + bool default_value) { std::vector sorted_vec; unsigned int entry_index; @@ -35,9 +35,9 @@ sortIndexEntryPairList( std::vector sortIndexEntryPairList( - const std::vector> unsorted_pair_list, - unsigned int number_of_variables, - std::string default_value) + const std::vector> &unsorted_pair_list, + unsigned int number_of_variables, + const std::string &default_value) { std::vector sorted_vec; unsigned int entry_index; @@ -68,9 +68,9 @@ sortIndexEntryPairList( std::vector sortIndexEntryPairList( - const std::vector> unsorted_pair_list, - unsigned int number_of_variables, - fieldType default_value) + const std::vector> &unsorted_pair_list, + unsigned int number_of_variables, + fieldType default_value) { std::vector sorted_vec; unsigned int entry_index; @@ -101,9 +101,9 @@ sortIndexEntryPairList( std::vector sortIndexEntryPairList( - const std::vector> unsorted_pair_list, - unsigned int number_of_variables, - PDEType default_value) + const std::vector> &unsorted_pair_list, + unsigned int number_of_variables, + PDEType default_value) { std::vector sorted_vec; unsigned int entry_index; diff --git a/src/utilities/vectorBCFunction.cc b/src/utilities/vectorBCFunction.cc index 97cd6983a..ff4bfb6b7 100644 --- a/src/utilities/vectorBCFunction.cc +++ b/src/utilities/vectorBCFunction.cc @@ -13,7 +13,7 @@ template vectorBCFunction::vectorBCFunction(std::vector input_values) : dealii::Function(dim) - , BC_values(input_values) + , BC_values(std::move(input_values)) {} template diff --git a/src/variableAttributeLoader/variableAttributeLoader.cc b/src/variableAttributeLoader/variableAttributeLoader.cc index 58eb12eb4..1a15ab204 100644 --- a/src/variableAttributeLoader/variableAttributeLoader.cc +++ b/src/variableAttributeLoader/variableAttributeLoader.cc @@ -70,7 +70,7 @@ variableAttributeLoader::set_variable_name(unsigned int index, std::string name) { std::pair var_pair; var_pair.first = index; - var_pair.second = name; + var_pair.second = std::move(name); if (setting_primary_field_attributes) { @@ -142,7 +142,7 @@ variableAttributeLoader::set_dependencies_value_term_RHS(unsigned int index, { std::pair var_pair; var_pair.first = index; - var_pair.second = dependencies; + var_pair.second = std::move(dependencies); if (setting_primary_field_attributes) { @@ -160,7 +160,7 @@ variableAttributeLoader::set_dependencies_gradient_term_RHS(unsigned int index, { std::pair var_pair; var_pair.first = index; - var_pair.second = dependencies; + var_pair.second = std::move(dependencies); if (setting_primary_field_attributes) { @@ -178,7 +178,7 @@ variableAttributeLoader::set_dependencies_value_term_LHS(unsigned int index, { std::pair var_pair; var_pair.first = index; - var_pair.second = dependencies; + var_pair.second = std::move(dependencies); var_eq_dependencies_value_LHS.push_back(var_pair); } @@ -188,6 +188,6 @@ variableAttributeLoader::set_dependencies_gradient_term_LHS(unsigned int index, { std::pair var_pair; var_pair.first = index; - var_pair.second = dependencies; + var_pair.second = std::move(dependencies); var_eq_dependencies_gradient_LHS.push_back(var_pair); } diff --git a/src/variableContainer/variableContainer.cc b/src/variableContainer/variableContainer.cc index cc1a82d9e..35ca18ffe 100644 --- a/src/variableContainer/variableContainer.cc +++ b/src/variableContainer/variableContainer.cc @@ -1,44 +1,48 @@ -// All of the methods for the 'variableContainer' class #include "../../include/variableContainer.h" template variableContainer::variableContainer( const dealii::MatrixFree &data, - std::vector _varInfoList, - std::vector _varChangeInfoList) + const std::vector &_varInfoList, + const std::vector &_varChangeInfoList) + : varInfoList(_varInfoList) + , varChangeInfoList(_varChangeInfoList) + , num_var(varInfoList.size()) { - varInfoList = _varInfoList; - varChangeInfoList = _varChangeInfoList; - - num_var = varInfoList.size(); - for (unsigned int i = 0; i < num_var; i++) { - if (varInfoList[i].var_needed) + const auto &var_info = varInfoList[i]; + const auto &var_change_info = varChangeInfoList[i]; + + if (var_info.var_needed) { - if (varInfoList[i].is_scalar) + const unsigned int var_index = var_info.global_var_index; + + if (var_info.is_scalar) { - dealii::FEEvaluation var(data, i); - scalar_vars.push_back(var); + scalar_vars_map.emplace(var_index, + std::make_unique(data, i)); } else { - dealii::FEEvaluation var(data, i); - vector_vars.push_back(var); + vector_vars_map.emplace(var_index, + std::make_unique(data, i)); } } - if (varChangeInfoList[i].var_needed) + if (var_change_info.var_needed) { - if (varChangeInfoList[i].is_scalar) + const unsigned int var_index = var_change_info.global_var_index; + + if (var_change_info.is_scalar) { - dealii::FEEvaluation var(data, i); - scalar_change_in_vars.push_back(var); + scalar_change_in_vars_map.emplace(var_index, + std::make_unique(data, i)); } else { - dealii::FEEvaluation var(data, i); - vector_change_in_vars.push_back(var); + vector_change_in_vars_map.emplace(var_index, + std::make_unique(data, i)); } } } @@ -47,26 +51,28 @@ variableContainer::variableContainer( template variableContainer::variableContainer( const dealii::MatrixFree &data, - std::vector _varInfoList) + const std::vector &_varInfoList) + : varInfoList(_varInfoList) + , num_var(varInfoList.size()) { - varInfoList = _varInfoList; - - num_var = varInfoList.size(); - for (unsigned int i = 0; i < num_var; i++) { - if (varInfoList[i].var_needed) + const auto &var_info = varInfoList[i]; + + if (!var_info.var_needed) { - if (varInfoList[i].is_scalar) - { - dealii::FEEvaluation var(data, i); - scalar_vars.push_back(var); - } - else - { - dealii::FEEvaluation var(data, i); - vector_vars.push_back(var); - } + continue; + } + + const unsigned int var_index = var_info.global_var_index; + + if (var_info.is_scalar) + { + scalar_vars_map.emplace(var_index, std::make_unique(data, i)); + } + else + { + vector_vars_map.emplace(var_index, std::make_unique(data, i)); } } } @@ -76,74 +82,90 @@ variableContainer::variableContainer( template variableContainer::variableContainer( const dealii::MatrixFree &data, - std::vector _varInfoList, - unsigned int fixed_index) + const std::vector &_varInfoList, + const unsigned int &fixed_index) + : varInfoList(_varInfoList) + , num_var(varInfoList.size()) { - varInfoList = _varInfoList; - - num_var = varInfoList.size(); - for (unsigned int i = 0; i < num_var; i++) { - if (varInfoList[i].var_needed) + const auto &var_info = varInfoList[i]; + + if (!var_info.var_needed) { - if (varInfoList[i].is_scalar) - { - dealii::FEEvaluation var(data, - fixed_index); - scalar_vars.push_back(var); - } - else - { - dealii::FEEvaluation var(data, - fixed_index); - vector_vars.push_back(var); - } + continue; + } + + const unsigned int var_index = var_info.global_var_index; + + if (var_info.is_scalar) + { + scalar_vars_map.emplace(var_index, + std::make_unique(data, fixed_index)); + } + else + { + vector_vars_map.emplace(var_index, + std::make_unique(data, fixed_index)); } } } template unsigned int -variableContainer::get_num_q_points() +variableContainer::get_num_q_points() const { - if (scalar_vars.size() > 0) + if (!scalar_vars_map.empty()) { - return scalar_vars[0].n_q_points; + return scalar_vars_map.begin()->second->n_q_points; } - else if (vector_vars.size() > 0) + else if (!vector_vars_map.empty()) { - return vector_vars[0].n_q_points; + return vector_vars_map.begin()->second->n_q_points; } - else if (scalar_change_in_vars.size() > 0) + else if (!scalar_change_in_vars_map.empty()) { - return scalar_change_in_vars[0].n_q_points; + return scalar_change_in_vars_map.begin()->second->n_q_points; + } + else if (!vector_change_in_vars_map.empty()) + { + return vector_change_in_vars_map.begin()->second->n_q_points; } else { - return vector_change_in_vars[0].n_q_points; + AssertThrow(false, + dealii::ExcMessage( + "PRISMS-PF Error: When trying to access the number of quadrature " + "points, all FEEvaluation object containers were empty.")); } } template dealii::Point -variableContainer::get_q_point_location() +variableContainer::get_q_point_location() const { - if (scalar_vars.size() > 0) + if (!scalar_vars_map.empty()) + { + return scalar_vars_map.begin()->second->quadrature_point(q_point); + } + else if (!vector_vars_map.empty()) { - return scalar_vars[0].quadrature_point(q_point); + return vector_vars_map.begin()->second->quadrature_point(q_point); } - else if (vector_vars.size() > 0) + else if (!scalar_change_in_vars_map.empty()) { - return vector_vars[0].quadrature_point(q_point); + return scalar_change_in_vars_map.begin()->second->quadrature_point(q_point); } - else if (scalar_change_in_vars.size() > 0) + else if (!vector_change_in_vars_map.empty()) { - return scalar_change_in_vars[0].quadrature_point(q_point); + return vector_change_in_vars_map.begin()->second->quadrature_point(q_point); } else { - return vector_change_in_vars[0].quadrature_point(q_point); + AssertThrow(false, + dealii::ExcMessage( + "PRISMS-PF Error: When trying to access the quadrature point " + "location, all FEEvaluation object containers were empty.")); } } @@ -154,33 +176,35 @@ variableContainer::reinit_and_eval(const std::vectorreinit(cell); + scalar_FEEval_ptr->read_dof_values(*src[i]); + scalar_FEEval_ptr->evaluate(var_info.evaluation_flags); + } + else + { + auto *vector_FEEval_ptr = vector_vars_map[var_index].get(); + vector_FEEval_ptr->reinit(cell); + vector_FEEval_ptr->read_dof_values(*src[i]); + vector_FEEval_ptr->evaluate(var_info.evaluation_flags); } } } /** - * This is specialized for the LHS where there will be only one change in the - * solution needed. The RHS method takes the src as a vector of vectorTypes. + * This is specialized for the LHS where a change in solution is needed. The RHS method + * takes the src as a vector of vectorTypes. */ template void @@ -191,88 +215,42 @@ variableContainer::reinit_and_eval_change_in_solution( { if (varChangeInfoList[var_being_solved].is_scalar) { - scalar_change_in_vars[0].reinit(cell); - scalar_change_in_vars[0].read_dof_values(src); - scalar_change_in_vars[0].evaluate(varChangeInfoList[var_being_solved].need_value, - varChangeInfoList[var_being_solved].need_gradient, - varChangeInfoList[var_being_solved].need_hessian); + auto *scalar_FEEval_ptr = scalar_change_in_vars_map[var_being_solved].get(); + scalar_FEEval_ptr->reinit(cell); + scalar_FEEval_ptr->read_dof_values(src); + scalar_FEEval_ptr->evaluate(varChangeInfoList[var_being_solved].evaluation_flags); } else { - vector_change_in_vars[0].reinit(cell); - vector_change_in_vars[0].read_dof_values(src); - vector_change_in_vars[0].evaluate(varChangeInfoList[var_being_solved].need_value, - varChangeInfoList[var_being_solved].need_gradient, - varChangeInfoList[var_being_solved].need_hessian); + auto *vector_FEEval_ptr = vector_change_in_vars_map[var_being_solved].get(); + vector_FEEval_ptr->reinit(cell); + vector_FEEval_ptr->read_dof_values(src); + vector_FEEval_ptr->evaluate(varChangeInfoList[var_being_solved].evaluation_flags); } } template void -variableContainer::reinit_and_eval_LHS( - const vectorType &src, - const std::vector solutionSet, - unsigned int cell, - unsigned int var_being_solved) +variableContainer::reinit(unsigned int cell) { for (unsigned int i = 0; i < num_var; i++) { - if (varInfoList[i].var_needed) + const auto &var_info = varInfoList[i]; + + if (!var_info.var_needed) { - if (varInfoList[i].is_scalar) - { - scalar_vars[varInfoList[i].scalar_or_vector_index].reinit(cell); - if (i == var_being_solved) - { - scalar_vars[varInfoList[i].scalar_or_vector_index].read_dof_values(src); - } - else - { - scalar_vars[varInfoList[i].scalar_or_vector_index].read_dof_values( - *solutionSet[i]); - } - scalar_vars[varInfoList[i].scalar_or_vector_index].evaluate( - varInfoList[i].need_value, - varInfoList[i].need_gradient, - varInfoList[i].need_hessian); - } - else - { - vector_vars[varInfoList[i].scalar_or_vector_index].reinit(cell); - if (i == var_being_solved) - { - vector_vars[varInfoList[i].scalar_or_vector_index].read_dof_values(src); - } - else - { - vector_vars[varInfoList[i].scalar_or_vector_index].read_dof_values( - *solutionSet[i]); - } - vector_vars[varInfoList[i].scalar_or_vector_index].evaluate( - varInfoList[i].need_value, - varInfoList[i].need_gradient, - varInfoList[i].need_hessian); - } + continue; } - } -} -template -void -variableContainer::reinit(unsigned int cell) -{ - for (unsigned int i = 0; i < num_var; i++) - { - if (varInfoList[i].var_needed) + const unsigned int var_index = var_info.global_var_index; + + if (var_info.is_scalar) { - if (varInfoList[i].is_scalar) - { - scalar_vars[varInfoList[i].scalar_or_vector_index].reinit(cell); - } - else - { - vector_vars[varInfoList[i].scalar_or_vector_index].reinit(cell); - } + scalar_vars_map[var_index]->reinit(cell); + } + else + { + vector_vars_map[var_index]->reinit(cell); } } } @@ -284,24 +262,26 @@ variableContainer::integrate_and_distribute( { for (unsigned int i = 0; i < num_var; i++) { - if (varInfoList[i].value_residual || varInfoList[i].gradient_residual) + const auto &var_info = varInfoList[i]; + + if (var_info.residual_flags & dealii::EvaluationFlags::nothing) { - if (varInfoList[i].is_scalar) - { - scalar_vars[varInfoList[i].scalar_or_vector_index].integrate( - varInfoList[i].value_residual, - varInfoList[i].gradient_residual); - scalar_vars[varInfoList[i].scalar_or_vector_index] - .distribute_local_to_global(*dst[i]); - } - else - { - vector_vars[varInfoList[i].scalar_or_vector_index].integrate( - varInfoList[i].value_residual, - varInfoList[i].gradient_residual); - vector_vars[varInfoList[i].scalar_or_vector_index] - .distribute_local_to_global(*dst[i]); - } + continue; + } + + const unsigned int var_index = var_info.global_var_index; + + if (var_info.is_scalar) + { + auto *scalar_FEEval_ptr = scalar_vars_map[var_index].get(); + scalar_FEEval_ptr->integrate(var_info.residual_flags); + scalar_FEEval_ptr->distribute_local_to_global(*dst[i]); + } + else + { + auto *vector_FEEval_ptr = vector_vars_map[var_index].get(); + vector_FEEval_ptr->integrate(var_info.residual_flags); + vector_FEEval_ptr->distribute_local_to_global(*dst[i]); } } } @@ -315,17 +295,15 @@ variableContainer::integrate_and_distribute_change_in_solution_L // integrate if (varChangeInfoList[var_being_solved].is_scalar) { - scalar_change_in_vars[0].integrate( - varChangeInfoList[var_being_solved].value_residual, - varChangeInfoList[var_being_solved].gradient_residual); - scalar_change_in_vars[0].distribute_local_to_global(dst); + auto *scalar_FEEval_ptr = scalar_change_in_vars_map[var_being_solved].get(); + scalar_FEEval_ptr->integrate(varChangeInfoList[var_being_solved].residual_flags); + scalar_FEEval_ptr->distribute_local_to_global(dst); } else { - vector_change_in_vars[0].integrate( - varChangeInfoList[var_being_solved].value_residual, - varChangeInfoList[var_being_solved].gradient_residual); - vector_change_in_vars[0].distribute_local_to_global(dst); + auto *vector_FEEval_ptr = vector_change_in_vars_map[var_being_solved].get(); + vector_FEEval_ptr->integrate(varChangeInfoList[var_being_solved].residual_flags); + vector_FEEval_ptr->distribute_local_to_global(dst); } } @@ -336,10 +314,10 @@ T variableContainer::get_scalar_value( unsigned int global_variable_index) const { - if (varInfoList[global_variable_index].need_value) + if (varInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::values) { - return scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .get_value(q_point); + return scalar_vars_map.at(global_variable_index)->get_value(q_point); } else { @@ -356,10 +334,10 @@ dealii::Tensor<1, dim, T> variableContainer::get_scalar_gradient( unsigned int global_variable_index) const { - if (varInfoList[global_variable_index].need_gradient) + if (varInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::gradients) { - return scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .get_gradient(q_point); + return scalar_vars_map.at(global_variable_index)->get_gradient(q_point); } else { @@ -376,10 +354,10 @@ dealii::Tensor<2, dim, T> variableContainer::get_scalar_hessian( unsigned int global_variable_index) const { - if (varInfoList[global_variable_index].need_hessian) + if (varInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::hessians) { - return scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .get_hessian(q_point); + return scalar_vars_map.at(global_variable_index)->get_hessian(q_point); } else { @@ -396,10 +374,10 @@ dealii::Tensor<1, dim, T> variableContainer::get_vector_value( unsigned int global_variable_index) const { - if (varInfoList[global_variable_index].need_value) + if (varInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::values) { - return vector_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .get_value(q_point); + return vector_vars_map.at(global_variable_index)->get_value(q_point); } else { @@ -416,10 +394,10 @@ dealii::Tensor<2, dim, T> variableContainer::get_vector_gradient( unsigned int global_variable_index) const { - if (varInfoList[global_variable_index].need_gradient) + if (varInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::gradients) { - return vector_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .get_gradient(q_point); + return vector_vars_map.at(global_variable_index)->get_gradient(q_point); } else { @@ -436,10 +414,10 @@ dealii::Tensor<3, dim, T> variableContainer::get_vector_hessian( unsigned int global_variable_index) const { - if (varInfoList[global_variable_index].need_hessian) + if (varInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::hessians) { - return vector_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .get_hessian(q_point); + return vector_vars_map.at(global_variable_index)->get_hessian(q_point); } else { @@ -458,11 +436,10 @@ T variableContainer::get_change_in_scalar_value( unsigned int global_variable_index) const { - if (varChangeInfoList[global_variable_index].need_value) + if (varChangeInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::values) { - return scalar_change_in_vars[varChangeInfoList[global_variable_index] - .scalar_or_vector_index] - .get_value(q_point); + return scalar_change_in_vars_map.at(global_variable_index)->get_value(q_point); } else { @@ -479,11 +456,10 @@ dealii::Tensor<1, dim, T> variableContainer::get_change_in_scalar_gradient( unsigned int global_variable_index) const { - if (varChangeInfoList[global_variable_index].need_gradient) + if (varChangeInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::gradients) { - return scalar_change_in_vars[varChangeInfoList[global_variable_index] - .scalar_or_vector_index] - .get_gradient(q_point); + return scalar_change_in_vars_map.at(global_variable_index)->get_gradient(q_point); } else { @@ -500,11 +476,10 @@ dealii::Tensor<2, dim, T> variableContainer::get_change_in_scalar_hessian( unsigned int global_variable_index) const { - if (varChangeInfoList[global_variable_index].need_hessian) + if (varChangeInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::hessians) { - return scalar_change_in_vars[varChangeInfoList[global_variable_index] - .scalar_or_vector_index] - .get_hessian(q_point); + return scalar_change_in_vars_map.at(global_variable_index)->get_hessian(q_point); } else { @@ -521,11 +496,10 @@ dealii::Tensor<1, dim, T> variableContainer::get_change_in_vector_value( unsigned int global_variable_index) const { - if (varChangeInfoList[global_variable_index].need_value) + if (varChangeInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::values) { - return vector_change_in_vars[varChangeInfoList[global_variable_index] - .scalar_or_vector_index] - .get_value(q_point); + return vector_change_in_vars_map.at(global_variable_index)->get_value(q_point); } else { @@ -542,11 +516,10 @@ dealii::Tensor<2, dim, T> variableContainer::get_change_in_vector_gradient( unsigned int global_variable_index) const { - if (varChangeInfoList[global_variable_index].need_gradient) + if (varChangeInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::gradients) { - return vector_change_in_vars[varChangeInfoList[global_variable_index] - .scalar_or_vector_index] - .get_gradient(q_point); + return vector_change_in_vars_map.at(global_variable_index)->get_gradient(q_point); } else { @@ -563,11 +536,10 @@ dealii::Tensor<3, dim, T> variableContainer::get_change_in_vector_hessian( unsigned int global_variable_index) const { - if (varChangeInfoList[global_variable_index].need_hessian) + if (varChangeInfoList[global_variable_index].evaluation_flags & + dealii::EvaluationFlags::hessians) { - return vector_change_in_vars[varChangeInfoList[global_variable_index] - .scalar_or_vector_index] - .get_hessian(q_point); + return vector_change_in_vars_map.at(global_variable_index)->get_hessian(q_point); } else { @@ -586,8 +558,7 @@ variableContainer::set_scalar_value_term_RHS( unsigned int global_variable_index, T val) { - scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .submit_value(val, q_point); + scalar_vars_map[global_variable_index]->submit_value(val, q_point); } template @@ -596,8 +567,7 @@ variableContainer::set_scalar_gradient_term_RHS( unsigned int global_variable_index, dealii::Tensor<1, dim, T> grad) { - scalar_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .submit_gradient(grad, q_point); + scalar_vars_map[global_variable_index]->submit_gradient(grad, q_point); } template @@ -606,8 +576,7 @@ variableContainer::set_vector_value_term_RHS( unsigned int global_variable_index, dealii::Tensor<1, dim, T> val) { - vector_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .submit_value(val, q_point); + vector_vars_map[global_variable_index]->submit_value(val, q_point); } template @@ -616,8 +585,7 @@ variableContainer::set_vector_gradient_term_RHS( unsigned int global_variable_index, dealii::Tensor<2, dim, T> grad) { - vector_vars[varInfoList[global_variable_index].scalar_or_vector_index] - .submit_gradient(grad, q_point); + vector_vars_map[global_variable_index]->submit_gradient(grad, q_point); } template @@ -626,8 +594,7 @@ variableContainer::set_scalar_value_term_LHS( unsigned int global_variable_index, T val) { - scalar_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index] - .submit_value(val, q_point); + scalar_change_in_vars_map[global_variable_index]->submit_value(val, q_point); } template @@ -636,8 +603,7 @@ variableContainer::set_scalar_gradient_term_LHS( unsigned int global_variable_index, dealii::Tensor<1, dim, T> grad) { - scalar_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index] - .submit_gradient(grad, q_point); + scalar_change_in_vars_map[global_variable_index]->submit_gradient(grad, q_point); } template @@ -646,8 +612,7 @@ variableContainer::set_vector_value_term_LHS( unsigned int global_variable_index, dealii::Tensor<1, dim, T> val) { - vector_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index] - .submit_value(val, q_point); + vector_change_in_vars_map[global_variable_index]->submit_value(val, q_point); } template @@ -656,15 +621,23 @@ variableContainer::set_vector_gradient_term_LHS( unsigned int global_variable_index, dealii::Tensor<2, dim, T> grad) { - vector_change_in_vars[varChangeInfoList[global_variable_index].scalar_or_vector_index] - .submit_gradient(grad, q_point); + vector_change_in_vars_map[global_variable_index]->submit_gradient(grad, q_point); } template class variableContainer<2, 1, dealii::VectorizedArray>; -template class variableContainer<2, 2, dealii::VectorizedArray>; -template class variableContainer<2, 3, dealii::VectorizedArray>; -template class variableContainer<2, 4, dealii::VectorizedArray>; template class variableContainer<3, 1, dealii::VectorizedArray>; + +template class variableContainer<2, 2, dealii::VectorizedArray>; template class variableContainer<3, 2, dealii::VectorizedArray>; + +template class variableContainer<2, 3, dealii::VectorizedArray>; template class variableContainer<3, 3, dealii::VectorizedArray>; + +template class variableContainer<2, 4, dealii::VectorizedArray>; template class variableContainer<3, 4, dealii::VectorizedArray>; + +template class variableContainer<2, 5, dealii::VectorizedArray>; +template class variableContainer<3, 5, dealii::VectorizedArray>; + +template class variableContainer<2, 6, dealii::VectorizedArray>; +template class variableContainer<3, 6, dealii::VectorizedArray>; \ No newline at end of file diff --git a/applications/CHiMaD_benchmark1a/CMakeLists.txt b/tests/automatic_tests/CHAC_anisotropyRegularized/CMakeLists.txt similarity index 57% rename from applications/CHiMaD_benchmark1a/CMakeLists.txt rename to tests/automatic_tests/CHAC_anisotropyRegularized/CMakeLists.txt index 39b8e6bd3..49489dfc7 100644 --- a/applications/CHiMaD_benchmark1a/CMakeLists.txt +++ b/tests/automatic_tests/CHAC_anisotropyRegularized/CMakeLists.txt @@ -2,7 +2,10 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) + +# Required cmake version. This should be inline with what is required +# for the dealii installation. +CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) # Find deal.II installation FIND_PACKAGE(deal.II 9.2.0 REQUIRED @@ -12,8 +15,8 @@ FIND_PACKAGE(deal.II 9.2.0 REQUIRED IF(NOT ${DEAL_II_WITH_P4EST}) MESSAGE(FATAL_ERROR "\n" "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” + "The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n" + "user guide to confirm that deal.II and p4est were installed and configured correctly." ) ENDIF() @@ -49,21 +52,13 @@ if (EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - ADD_EXECUTABLE(main main.cc ) DEAL_II_SETUP_TARGET(main) set(cmd "cmake") set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) +set(dir ${PROJECT_SOURCE_DIR}/../../..) EXECUTE_PROCESS(COMMAND ${cmd} ${arg} WORKING_DIRECTORY ${dir}) @@ -73,9 +68,9 @@ EXECUTE_PROCESS(COMMAND ${cmd} WORKING_DIRECTORY ${dir}) if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) endif() diff --git a/tests/automatic_tests/CHAC_anisotropyRegularized/ICs_and_BCs.cc b/tests/automatic_tests/CHAC_anisotropyRegularized/ICs_and_BCs.cc new file mode 100644 index 000000000..75b1d8324 --- /dev/null +++ b/tests/automatic_tests/CHAC_anisotropyRegularized/ICs_and_BCs.cc @@ -0,0 +1,80 @@ +// =========================================================================== +// FUNCTION FOR INITIAL CONDITIONS +// =========================================================================== + +template +void +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) +{ + // --------------------------------------------------------------------- + // ENTER THE INITIAL CONDITIONS HERE + // --------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the initial condition for each variable + // according to its variable index + + double r = 0.0; + + if (index == 0) + { + r = 0.0; + for (unsigned int dir = 0; dir < dim; dir++) + { + r += (p[dir] - userInputs.domain_size[dir] / 2.0) * + (p[dir] - userInputs.domain_size[dir] / 2.0); + } + r = std::sqrt(r); + double n = 0.5 * (1.0 - std::tanh((r - userInputs.domain_size[0] / 4.0) / 4.0)); + scalar_IC = 0.082 * 16.0 / (userInputs.domain_size[0] / 4.0) + + (3.0 * n * n - 2.0 * n * n * n); + } + else if (index == 1) + { + r = 0.0; + for (unsigned int dir = 0; dir < dim; dir++) + { + r += (p[dir] - userInputs.domain_size[dir] / 2.0) * + (p[dir] - userInputs.domain_size[dir] / 2.0); + } + r = std::sqrt(r); + scalar_IC = 0.5 * (1.0 - std::tanh((r - userInputs.domain_size[0] / 4.0) / 4.0)); + } + else + { + scalar_IC = 0.0; + } + + // -------------------------------------------------------------------------- +} + +// =========================================================================== +// FUNCTION FOR NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS +// =========================================================================== + +template +void +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) +{ + // -------------------------------------------------------------------------- + // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE + // -------------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the boundary condition for each variable + // according to its variable index. This function can be left blank if there + // are no non-uniform Dirichlet boundary conditions. For BCs that change in + // time, you can access the current time through the variable "time". The + // boundary index can be accessed via the variable "direction", which starts + // at zero and uses the same order as the BC specification in parameters.in + // (i.e. left = 0, right = 1, bottom = 2, top = 3, front = 4, back = 5). + + // ------------------------------------------------------------------------- +} diff --git a/tests/automatic_tests/CHAC_anisotropyRegularized/customPDE.h b/tests/automatic_tests/CHAC_anisotropyRegularized/customPDE.h new file mode 100644 index 000000000..810470fde --- /dev/null +++ b/tests/automatic_tests/CHAC_anisotropyRegularized/customPDE.h @@ -0,0 +1,95 @@ +#include "../../../include/matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "../../../include/typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double McV = userInputs.get_model_constant_double("McV"); + double MnV = userInputs.get_model_constant_double("MnV"); + double epsilonM = userInputs.get_model_constant_double("epsilonM"); + double delta2 = userInputs.get_model_constant_double("delta2"); + + // ================================================================ +}; diff --git a/tests/automatic_tests/CHAC_anisotropyRegularized/equations.cc b/tests/automatic_tests/CHAC_anisotropyRegularized/equations.cc new file mode 100644 index 000000000..34d6efdd6 --- /dev/null +++ b/tests/automatic_tests/CHAC_anisotropyRegularized/equations.cc @@ -0,0 +1,201 @@ +// ================================================================================= +// Set the attributes of the primary field variables +// ================================================================================= +// This function sets attributes for each variable/equation in the app. The +// attributes are set via standardized function calls. The first parameter for +// each function call is the variable index (starting at zero). The first set of +// variable/equation attributes are the variable name (any string), the variable +// type (SCALAR/VECTOR), and the equation type (EXPLICIT_TIME_DEPENDENT/ +// TIME_INDEPENDENT/AUXILIARY). The next set of attributes describe the +// dependencies for the governing equation on the values and derivatives of the +// other variables for the value term and gradient term of the RHS and the LHS. +// The final pair of attributes determine whether a variable represents a field +// that can nucleate and whether the value of the field is needed for nucleation +// rate calculations. + +void +variableAttributeLoader::loadVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "c"); + set_variable_type(0, SCALAR); + set_variable_equation_type(0, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(0, "c"); + set_dependencies_gradient_term_RHS(0, "c, grad(c), n, grad(n)"); + + // Variable 1 + set_variable_name(1, "n"); + set_variable_type(1, SCALAR); + set_variable_equation_type(1, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(1, "c, n"); + set_dependencies_gradient_term_RHS(1, "grad(n), grad(biharm)"); + + // Variable 2 + set_variable_name(2, "biharm"); + set_variable_type(2, SCALAR); + set_variable_equation_type(2, AUXILIARY); + + set_dependencies_value_term_RHS(2, ""); + set_dependencies_gradient_term_RHS(2, "grad(n)"); +} + +// ============================================================================================= +// explicitEquationRHS (needed only if one or more equation is explict time +// dependent) +// ============================================================================================= +// This function calculates the right-hand-side of the explicit time-dependent +// equations for each variable. It takes "variable_list" as an input, which is a +// list of the value and derivatives of each of the variables at a specific +// quadrature point. The (x,y,z) location of that quadrature point is given by +// "q_point_loc". The function outputs two terms to variable_list -- one +// proportional to the test function and one proportional to the gradient of the +// test function. The index for each variable in this list corresponds to the +// index given at the top of this file. + +template +void +customPDE::explicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // Concentration + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // Order parameter + scalarvalueType n = variable_list.get_scalar_value(1); + scalargradType nx = variable_list.get_scalar_gradient(1); + + // Field for split formulation of the biharmonic term + scalargradType biharmx = variable_list.get_scalar_gradient(2); + + // --- Setting the expressions for the terms in the governing equations --- + + // Bulk terms + scalarvalueType faV = 0.5 * c * c / 16.0; + scalarvalueType facV = 0.5 * c / 8.0; + scalarvalueType faccV = constV(0.5 / 8.0); + scalarvalueType fbV = 0.5 * (c - 1.0) * (c - 1.0) / 16.0; + scalarvalueType fbcV = 0.5 * (c - 1.0) / 8.0; + scalarvalueType fbccV = constV(0.5 / 8.0); + scalarvalueType hV = 3.0 * n * n - 2.0 * n * n * n; + scalarvalueType hnV = 6.0 * n - 6.0 * n * n; + + // Calculation of interface normal vector + scalarvalueType normgradn = std::sqrt(nx.norm_square()); + scalargradType normal = nx / (normgradn + constV(1.0e-16)); + + // Calculation of anisotropy gamma + scalarvalueType gamma; + if (dim == 2) + { + gamma = 1.0 + epsilonM * (4.0 * (normal[0] * normal[0] * normal[0] * normal[0] + + normal[1] * normal[1] * normal[1] * normal[1]) - + 3.0); + } + else + { + gamma = 1.0 + epsilonM * (4.0 * (normal[0] * normal[0] * normal[0] * normal[0] + + normal[1] * normal[1] * normal[1] * normal[1] + + normal[2] * normal[2] * normal[2] * normal[2]) - + 3.0); + } + + // Derivatives of gamma with respect to the components of the unit normal + scalargradType dgammadnorm; + dgammadnorm[0] = (epsilonM * 16.0 * normal[0] * normal[0] * normal[0]); + dgammadnorm[1] = (epsilonM * 16.0 * normal[1] * normal[1] * normal[1]); + if (dim == 3) + { + dgammadnorm[2] = (epsilonM * 16.0 * normal[2] * normal[2] * normal[2]); + } + + // Product of projection matrix and dgammadnorm vector + scalargradType aniso; + for (unsigned int i = 0; i < dim; ++i) + { + for (unsigned int j = 0; j < dim; ++j) + { + aniso[i] += -normal[i] * normal[j] * dgammadnorm[j]; + if (i == j) + aniso[i] += dgammadnorm[j]; + } + } + // Anisotropic gradient term (see derivation) + aniso = gamma * (aniso * normgradn + gamma * nx); + + // The terms in the governing equations + scalarvalueType eq_c = c; + scalargradType eqx_c = + constV(-McV * userInputs.dtValue) * + (cx * ((1.0 - hV) * faccV + hV * fbccV) + nx * hnV * (fbcV - facV)); + scalarvalueType eq_n = n - constV(userInputs.dtValue * MnV) * (fbV - faV) * hnV; + scalargradType eqx_n = + constV(userInputs.dtValue * MnV) * (-aniso + constV(delta2) * biharmx); + + // --- Submitting the terms for the governing equations --- + + variable_list.set_scalar_value_term_RHS(0, eq_c); + variable_list.set_scalar_gradient_term_RHS(0, eqx_c); + + variable_list.set_scalar_value_term_RHS(1, eq_n); + variable_list.set_scalar_gradient_term_RHS(1, eqx_n); +} + +// ============================================================================================= +// nonExplicitEquationRHS (needed only if one or more equation is time +// independent or auxiliary) +// ============================================================================================= +// This function calculates the right-hand-side of all of the equations that are +// not explicit time-dependent equations. It takes "variable_list" as an input, +// which is a list of the value and derivatives of each of the variables at a +// specific quadrature point. The (x,y,z) location of that quadrature point is +// given by "q_point_loc". The function outputs two terms to variable_list -- +// one proportional to the test function and one proportional to the gradient of +// the test function. The index for each variable in this list corresponds to +// the index given at the top of this file. + +template +void +customPDE::nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + scalargradType nx = variable_list.get_scalar_gradient(1); + + // --- Setting the expressions for the terms in the governing equations --- + + // --- Submitting the terms for the governing equations --- + variable_list.set_scalar_gradient_term_RHS(2, -nx); +} + +// ============================================================================================= +// equationLHS (needed only if at least one equation is time independent) +// ============================================================================================= +// This function calculates the left-hand-side of time-independent equations. It +// takes "variable_list" as an input, which is a list of the value and +// derivatives of each of the variables at a specific quadrature point. The +// (x,y,z) location of that quadrature point is given by "q_point_loc". The +// function outputs two terms to variable_list -- one proportional to the test +// function and one proportional to the gradient of the test function -- for the +// left-hand-side of the equation. The index for each variable in this list +// corresponds to the index given at the top of this file. If there are multiple +// elliptic equations, conditional statements should be sed to ensure that the +// correct residual is being submitted. The index of the field being solved can +// be accessed by "this->currentFieldIndex". + +template +void +customPDE::equationLHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{} diff --git a/tests/automatic_tests/gold_CHAC_anisotropyRegularized/integratedFields.txt b/tests/automatic_tests/CHAC_anisotropyRegularized/gold_integratedFields.txt similarity index 100% rename from tests/automatic_tests/gold_CHAC_anisotropyRegularized/integratedFields.txt rename to tests/automatic_tests/CHAC_anisotropyRegularized/gold_integratedFields.txt diff --git a/applications/CHiMaD_benchmark1a/main.cc b/tests/automatic_tests/CHAC_anisotropyRegularized/main.cc similarity index 96% rename from applications/CHiMaD_benchmark1a/main.cc rename to tests/automatic_tests/CHAC_anisotropyRegularized/main.cc index aa697a929..3113c62c2 100644 --- a/applications/CHiMaD_benchmark1a/main.cc +++ b/tests/automatic_tests/CHAC_anisotropyRegularized/main.cc @@ -4,9 +4,9 @@ #include "ICs_and_BCs.cc" #include "equations.cc" -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" +#include "../../../include/ParseCommandLineOpts.h" +#include "../../../include/inputFileReader.h" +#include "../../../src/variableAttributeLoader/variableAttributeLoader.cc" // Header file for postprocessing that may or may not exist #ifdef POSTPROCESS_FILE_EXISTS diff --git a/applications/steadyStateAllenCahn/parameters.prm b/tests/automatic_tests/CHAC_anisotropyRegularized/parameters.prm similarity index 74% rename from applications/steadyStateAllenCahn/parameters.prm rename to tests/automatic_tests/CHAC_anisotropyRegularized/parameters.prm index b433c4f30..b79221d02 100644 --- a/applications/steadyStateAllenCahn/parameters.prm +++ b/tests/automatic_tests/CHAC_anisotropyRegularized/parameters.prm @@ -22,66 +22,46 @@ set Subdivisions X = 1 set Subdivisions Y = 1 set Subdivisions Z = 1 -set Refine factor = 8 +set Refine factor = 7 # Set the polynomial degree of the element (allowed values: 1, 2, or 3) set Element degree = 1 # ================================================================================= -# Set the linear solver parameters +# Set the adaptive mesh refinement parameters # ================================================================================= +# Set the flag determining if adaptive meshing is activated +set Mesh adaptivity = true -subsection Linear solver parameters: psi - # Whether the tolerance value is compared to the residual (ABSOLUTE_RESIDUAL) - # or the change in the residual (RELATIVE_RESIDUAL_CHANGE) - set Tolerance type = ABSOLUTE_RESIDUAL +# Set the maximum and minimum level of refinement +# When adaptive meshing is enabled, the refine factor set in the block above is +# only used to generate the first pass of the mesh as the initial conditions are +# applied. It should be set somewhere between the max and min levels below. +set Max refinement level = 7 +set Min refinement level = 4 - # The tolerance for convergence (L2 norm) - set Tolerance value = 1e-10 +# Set the number of time steps between remeshing operations +set Steps between remeshing operations = 1000 - # The maximum number of linear solver iterations per solve - set Maximum linear solver iterations = 10000 -end - -# ================================================================================= -# Set the nonlinear solver parameters -# ================================================================================= - -set Maximum nonlinear solver iterations = 100 - -subsection Nonlinear solver parameters: psi - set Tolerance type = ABSOLUTE_SOLUTION_CHANGE - set Tolerance value = 1e-5 - set Use backtracking line search damping = false - set Backtracking step size modifier = 0.5 - set Backtracking residual decrease coefficient = 1.0 - set Constant damping value = 1.0 - set Use Laplace's equation to determine the initial guess = true +# Set the criteria for adapting the mesh +subsection Refinement criterion: n + # Select whether the mesh is refined based on the variable value (VALUE), + # its gradient (GRADIENT), or both (VALUE_AND_GRADIENT) + set Criterion type = VALUE + # Set the lower and upper bounds for the value-based refinement window + set Value lower bound = 0.001 + set Value upper bound = 0.999 end # ================================================================================= # Set the time step parameters # ================================================================================= # The size of the time step -set Time step = 1.0e-2 +set Time step = 5.0e-2 # The simulation ends when either the number of time steps is reached or the # simulation time is reached. -set Number of time steps = 10 - -# ================================================================================= -# Set the output parameters -# ================================================================================= -# Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", "N_PER_DECADE", -# or "LIST") -set Output condition = EQUAL_SPACING - -# Number of times the program outputs the fields (total number for "EQUAL_SPACING" -# and "LOG_SPACING", number per decade for "N_PER_DECADE", ignored for "LIST") -set Number of outputs = 10 - -# The number of time steps between updates being printed to the screen -set Skip print steps = 1000 +set Number of time steps = 40000 # ================================================================================= # Set the boundary conditions @@ -103,8 +83,9 @@ set Skip print steps = 1000 # 1.5 on the top and bottom for variable 'n' in 2D # set Boundary condition for variable n = NATURAL, NATURAL, DIRICHLET: 1.5, DIRICHLET: 1.5 -set Boundary condition for variable n = DIRICHLET: 1.0, DIRICHLET: 0.0, NATURAL, NATURAL -set Boundary condition for variable psi = DIRICHLET: 0.0, DIRICHLET: 1.0, NATURAL, NATURAL +set Boundary condition for variable c = NATURAL +set Boundary condition for variable n = NATURAL +set Boundary condition for variable biharm = NATURAL # ================================================================================= # Set the model constants @@ -115,8 +96,28 @@ set Boundary condition for variable psi = DIRICHLET: 0.0, DIRICHLET: 1.0, NATURA # options currently are DOUBLE, INT, BOOL, TENSOR, and [symmetry] ELASTIC CONSTANTS # where [symmetry] is ISOTROPIC, TRANSVERSE, ORTHOTROPIC, or ANISOTROPIC. -# The mobility, MnV in equations.h -set Model constant MnV = 1.0, DOUBLE +# The CH mobility, McV in equations.h +set Model constant McV = 1.0, DOUBLE + +# The AC mobility, MnV in equations.h +set Model constant MnV = 0.1, DOUBLE + +# Anisotropy parameter +set Model constant epsilonM = 0.2, DOUBLE + +# Regularization parameter +set Model constant delta2 = 1.0, DOUBLE + +# ================================================================================= +# Set the output parameters +# ================================================================================= +# Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", "N_PER_DECADE", +# or "LIST") +set Output condition = EQUAL_SPACING + +# Number of times the program outputs the fields (total number for "EQUAL_SPACING" +# and "LOG_SPACING", number per decade for "N_PER_DECADE", ignored for "LIST") +set Number of outputs = 10 -# The gradient energy coefficient, KnV in equations.h -set Model constant KnV = 2.0, DOUBLE +# The number of time steps between updates being printed to the screen +set Skip print steps = 1000 diff --git a/tests/automatic_tests/CHAC_anisotropyRegularized/postprocess.cc b/tests/automatic_tests/CHAC_anisotropyRegularized/postprocess.cc new file mode 100644 index 000000000..921fc6952 --- /dev/null +++ b/tests/automatic_tests/CHAC_anisotropyRegularized/postprocess.cc @@ -0,0 +1,102 @@ +// ============================================================================================= +// loadPostProcessorVariableAttributes: Set the attributes of the postprocessing +// variables +// ============================================================================================= +// This function is analogous to 'loadVariableAttributes' in 'equations.h', but +// for the postprocessing expressions. It sets the attributes for each +// postprocessing expression, including its name, whether it is a vector or +// scalar (only scalars are supported at present), its dependencies on other +// variables and their derivatives, and whether to calculate an integral of the +// postprocessed quantity over the entire domain. Note: this function is not a +// member of customPDE. + +void +variableAttributeLoader::loadPostProcessorVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "f_tot"); + set_variable_type(0, SCALAR); + + set_dependencies_value_term_RHS(0, "c, n, biharm, grad(n)"); + set_dependencies_gradient_term_RHS(0, ""); + + set_output_integral(0, true); +} + +// ============================================================================================= +// postProcessedFields: Set the postprocessing expressions +// ============================================================================================= +// This function is analogous to 'explicitEquationRHS' and +// 'nonExplicitEquationRHS' in equations.h. It takes in "variable_list" and +// "q_point_loc" as inputs and outputs two terms in the expression for the +// postprocessing variable -- one proportional to the test function and one +// proportional to the gradient of the test function. The index for each +// variable in this list corresponds to the index given at the top of this file +// (for submitting the terms) and the index in 'equations.h' for assigning the +// values/derivatives of the primary variables. + +template +void +customPDE::postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // c + scalarvalueType c = variable_list.get_scalar_value(0); + + // n1 + scalarvalueType n = variable_list.get_scalar_value(1); + scalargradType nx = variable_list.get_scalar_gradient(1); + + // biharm + scalarvalueType biharm = variable_list.get_scalar_value(2); + + // --- Setting the expressions for the terms in the postprocessing expressions + // --- + + scalarvalueType f_tot = constV(0.0); + + scalarvalueType faV = 0.5 * c * c / 16.0; + scalarvalueType fbV = 0.5 * (c - 1.0) * (c - 1.0) / 16.0; + scalarvalueType hV = 3.0 * n * n - 2.0 * n * n * n; + + scalarvalueType normgradn = std::sqrt(nx.norm_square()); + scalargradType normal = nx / (normgradn + constV(1.0e-16)); + + scalarvalueType gamma; + if (dim == 2) + { + gamma = 1.0 + epsilonM * (4.0 * (normal[0] * normal[0] * normal[0] * normal[0] + + normal[1] * normal[1] * normal[1] * normal[1]) - + 3.0); + } + else + { + gamma = 1.0 + epsilonM * (4.0 * (normal[0] * normal[0] * normal[0] * normal[0] + + normal[1] * normal[1] * normal[1] * normal[1] + + normal[2] * normal[2] * normal[2] * normal[2]) - + 3.0); + } + + scalarvalueType f_chem = (constV(1.0) - hV) * faV + hV * fbV; + + // anisotropy code + scalarvalueType f_grad = constV(0.5) * gamma * gamma * nx * nx; + + scalarvalueType f_reg = constV(0.5 * delta2) * biharm * biharm; + + f_tot = f_chem + f_grad + f_reg; + + // end anisotropy code + f_tot = f_chem + f_grad; + + // --- Submitting the terms for the postprocessing expressions --- + + pp_variable_list.set_scalar_value_term_RHS(0, f_tot); +} diff --git a/applications/CHiMaD_benchmark2a/CMakeLists.txt b/tests/automatic_tests/allenCahn/CMakeLists.txt similarity index 57% rename from applications/CHiMaD_benchmark2a/CMakeLists.txt rename to tests/automatic_tests/allenCahn/CMakeLists.txt index 39b8e6bd3..49489dfc7 100644 --- a/applications/CHiMaD_benchmark2a/CMakeLists.txt +++ b/tests/automatic_tests/allenCahn/CMakeLists.txt @@ -2,7 +2,10 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) + +# Required cmake version. This should be inline with what is required +# for the dealii installation. +CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) # Find deal.II installation FIND_PACKAGE(deal.II 9.2.0 REQUIRED @@ -12,8 +15,8 @@ FIND_PACKAGE(deal.II 9.2.0 REQUIRED IF(NOT ${DEAL_II_WITH_P4EST}) MESSAGE(FATAL_ERROR "\n" "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” + "The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n" + "user guide to confirm that deal.II and p4est were installed and configured correctly." ) ENDIF() @@ -49,21 +52,13 @@ if (EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - ADD_EXECUTABLE(main main.cc ) DEAL_II_SETUP_TARGET(main) set(cmd "cmake") set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) +set(dir ${PROJECT_SOURCE_DIR}/../../..) EXECUTE_PROCESS(COMMAND ${cmd} ${arg} WORKING_DIRECTORY ${dir}) @@ -73,9 +68,9 @@ EXECUTE_PROCESS(COMMAND ${cmd} WORKING_DIRECTORY ${dir}) if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) endif() diff --git a/tests/automatic_tests/allenCahn/ICs_and_BCs.cc b/tests/automatic_tests/allenCahn/ICs_and_BCs.cc new file mode 100644 index 000000000..e68550084 --- /dev/null +++ b/tests/automatic_tests/allenCahn/ICs_and_BCs.cc @@ -0,0 +1,85 @@ +// =========================================================================== +// FUNCTION FOR INITIAL CONDITIONS +// =========================================================================== + +template +void +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) +{ + // --------------------------------------------------------------------- + // ENTER THE INITIAL CONDITIONS HERE + // --------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the initial condition for each variable + // according to its variable index + + // The initial condition is a set of overlapping circles/spheres defined + // by a hyperbolic tangent function. The center of each circle/sphere is + // given by "center" and its radius is given by "radius". + + double center[12][3] = { + {0.1, 0.3, 0}, + {0.8, 0.7, 0}, + {0.5, 0.2, 0}, + {0.4, 0.4, 0}, + {0.3, 0.9, 0}, + {0.8, 0.1, 0}, + {0.9, 0.5, 0}, + {0.0, 0.1, 0}, + {0.1, 0.6, 0}, + {0.5, 0.6, 0}, + {1, 1, 0}, + {0.7, 0.95, 0} + }; + double rad[12] = {12, 14, 19, 16, 11, 12, 17, 15, 20, 10, 11, 14}; + double dist; + scalar_IC = 0; + for (unsigned int i = 0; i < 12; i++) + { + dist = 0.0; + for (unsigned int dir = 0; dir < dim; dir++) + { + dist += (p[dir] - center[i][dir] * userInputs.domain_size[dir]) * + (p[dir] - center[i][dir] * userInputs.domain_size[dir]); + } + dist = std::sqrt(dist); + + scalar_IC += 0.5 * (1.0 - std::tanh((dist - rad[i]) / 1.5)); + } + if (scalar_IC > 1.0) + scalar_IC = 1.0; + + // --------------------------------------------------------------------- +} + +// =========================================================================== +// FUNCTION FOR NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS +// =========================================================================== + +template +void +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) +{ + // -------------------------------------------------------------------------- + // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE + // -------------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the boundary condition for each variable + // according to its variable index. This function can be left blank if there + // are no non-uniform Dirichlet boundary conditions. For BCs that change in + // time, you can access the current time through the variable "time". The + // boundary index can be accessed via the variable "direction", which starts + // at zero and uses the same order as the BC specification in parameters.in + // (i.e. left = 0, right = 1, bottom = 2, top = 3, front = 4, back = 5). + + // ------------------------------------------------------------------------- +} diff --git a/tests/automatic_tests/allenCahn/customPDE.h b/tests/automatic_tests/allenCahn/customPDE.h new file mode 100644 index 000000000..d93507284 --- /dev/null +++ b/tests/automatic_tests/allenCahn/customPDE.h @@ -0,0 +1,93 @@ +#include "../../../include/matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "../../../include/typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.cc) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.cc) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.cc) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double MnV = userInputs.get_model_constant_double("MnV"); + double KnV = userInputs.get_model_constant_double("KnV"); + + // ================================================================ +}; diff --git a/applications/steadyStateAllenCahn/equations.cc b/tests/automatic_tests/allenCahn/equations.cc similarity index 67% rename from applications/steadyStateAllenCahn/equations.cc rename to tests/automatic_tests/allenCahn/equations.cc index 992caec1b..9ba53a23d 100644 --- a/applications/steadyStateAllenCahn/equations.cc +++ b/tests/automatic_tests/allenCahn/equations.cc @@ -23,16 +23,6 @@ variableAttributeLoader::loadVariableAttributes() set_dependencies_value_term_RHS(0, "n"); set_dependencies_gradient_term_RHS(0, "grad(n)"); - - // Variable 1 - set_variable_name(1, "psi"); - set_variable_type(1, SCALAR); - set_variable_equation_type(1, TIME_INDEPENDENT); - - set_dependencies_value_term_RHS(1, "n, psi"); - set_dependencies_gradient_term_RHS(1, "grad(psi)"); - set_dependencies_value_term_LHS(1, "n, psi, change(psi)"); - set_dependencies_gradient_term_LHS(1, "grad(change(psi))"); } // ============================================================================================= @@ -51,8 +41,9 @@ variableAttributeLoader::loadVariableAttributes() template void customPDE::explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -88,30 +79,10 @@ customPDE::explicitEquationRHS( template void customPDE::nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const -{ - // --- Getting the values and derivatives of the model variables --- - - scalarvalueType n = variable_list.get_scalar_value(0); - - scalarvalueType psi = variable_list.get_scalar_value(1); - scalargradType psix = variable_list.get_scalar_gradient(1); - - // --- Setting the expressions for the terms in the governing equations --- - - scalarvalueType W = constV(1.0); - scalarvalueType p = constV(1.5); - scalarvalueType epsilon = constV(2.0); - - scalarvalueType eq_psi = (W * (-psi * psi * psi + psi - 2.0 * p * psi * n * n)); - scalargradType eqx_psi = (-epsilon * epsilon * psix); - - // --- Submitting the terms for the governing equations --- - - variable_list.set_scalar_value_term_RHS(1, eq_psi); - variable_list.set_scalar_gradient_term_RHS(1, eqx_psi); -} + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{} // ============================================================================================= // equationLHS (needed only if at least one equation is time independent) @@ -131,29 +102,7 @@ customPDE::nonExplicitEquationRHS( template void customPDE::equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const -{ - // --- Getting the values and derivatives of the model variables --- - - scalarvalueType n = variable_list.get_scalar_value(0); - - scalarvalueType psi = variable_list.get_scalar_value(1); - - scalarvalueType Dpsi = variable_list.get_change_in_scalar_value(1); - scalargradType Dpsix = variable_list.get_change_in_scalar_gradient(1); - - // --- Setting the expressions for the terms in the governing equations --- - - scalarvalueType W = constV(1.0); - scalarvalueType p = constV(1.5); - scalarvalueType epsilon = constV(2.0); - scalarvalueType eq_Dpsi = - (W * (3.0 * psi * psi * Dpsi - Dpsi + 2.0 * p * Dpsi * n * n)); - scalargradType eqx_Dpsi = (epsilon * epsilon * Dpsix); - - // --- Submitting the terms for the governing equations --- - - variable_list.set_scalar_value_term_LHS(1, eq_Dpsi); - variable_list.set_scalar_gradient_term_LHS(1, eqx_Dpsi); -} + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{} diff --git a/tests/automatic_tests/gold_allenCahn/integratedFields.txt b/tests/automatic_tests/allenCahn/gold_integratedFields.txt similarity index 100% rename from tests/automatic_tests/gold_allenCahn/integratedFields.txt rename to tests/automatic_tests/allenCahn/gold_integratedFields.txt diff --git a/applications/CHAC_anisotropy/main.cc b/tests/automatic_tests/allenCahn/main.cc similarity index 96% rename from applications/CHAC_anisotropy/main.cc rename to tests/automatic_tests/allenCahn/main.cc index aa697a929..3113c62c2 100644 --- a/applications/CHAC_anisotropy/main.cc +++ b/tests/automatic_tests/allenCahn/main.cc @@ -4,9 +4,9 @@ #include "ICs_and_BCs.cc" #include "equations.cc" -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" +#include "../../../include/ParseCommandLineOpts.h" +#include "../../../include/inputFileReader.h" +#include "../../../src/variableAttributeLoader/variableAttributeLoader.cc" // Header file for postprocessing that may or may not exist #ifdef POSTPROCESS_FILE_EXISTS diff --git a/applications/_allenCahn_implicit/parameters.prm b/tests/automatic_tests/allenCahn/parameters.prm similarity index 71% rename from applications/_allenCahn_implicit/parameters.prm rename to tests/automatic_tests/allenCahn/parameters.prm index 8539a6de7..6fa3f6433 100644 --- a/applications/_allenCahn_implicit/parameters.prm +++ b/tests/automatic_tests/allenCahn/parameters.prm @@ -1,6 +1,3 @@ -# Parameter list for the Allen-Cahn example application -# Refer to the PRISMS-PF manual for use of these parameters in the source code. - # ================================================================================= # Set the number of dimensions (2 or 3 for a 2D or 3D calculation) # ================================================================================= @@ -30,38 +27,6 @@ set Refine factor = 8 # Set the polynomial degree of the element (allowed values: 1, 2, or 3) set Element degree = 1 -# ================================================================================= -# Set the linear solver parameters -# ================================================================================= - -subsection Linear solver parameters: psi - # Whether the tolerance value is compared to the residual (ABSOLUTE_RESIDUAL) - # or the change in the residual (RELATIVE_RESIDUAL_CHANGE) - set Tolerance type = ABSOLUTE_RESIDUAL - - # The tolerance for convergence (L2 norm) - set Tolerance value = 1e-10 - - # The maximum number of linear solver iterations per solve - set Maximum linear solver iterations = 10000 -end - -# ================================================================================= -# Set the nonlinear solver parameters -# ================================================================================= - -set Maximum nonlinear solver iterations = 100 - -subsection Nonlinear solver parameters: psi - set Tolerance type = ABSOLUTE_SOLUTION_CHANGE - set Tolerance value = 1e-5 - set Use backtracking line search damping = true - set Backtracking step size modifier = 0.5 - set Backtracking residual decrease coefficient = 1.0 - set Constant damping value = 0.1 - set Use Laplace's equation to determine the initial guess = false -end - # ================================================================================= # Set the time step parameters # ================================================================================= @@ -70,7 +35,7 @@ set Time step = 1.0e-2 # The simulation ends when either the number of time steps is reached or the # simulation time is reached. -set Number of time steps = 5 #5000 +set Number of time steps = 5000 # ================================================================================= # Set the output parameters @@ -83,14 +48,17 @@ set Output condition = EQUAL_SPACING # and "LOG_SPACING", number per decade for "N_PER_DECADE", ignored for "LIST") set Number of outputs = 5 +# Whether to print timing information every time the code outputs +set Print timing information with output = true + # The number of time steps between updates being printed to the screen -set Skip print steps = 1 +set Skip print steps = 1000 # ================================================================================= # Set the boundary conditions # ================================================================================= # Set the boundary condition for each variable, where each variable is given by -# its name, as defined in equations.h. The four boundary condition +# its name, as defined in equations.cc. The four boundary condition # types are NATURAL, DIRICHLET, NON_UNIFORM_DIRICHLET and PERIODIC. If all # of the boundaries have the same boundary condition, only one boundary condition # type needs to be given. If multiple boundary condition types are needed, give a @@ -106,19 +74,19 @@ set Skip print steps = 1 # 1.5 on the top and bottom for variable 'n' in 2D # set Boundary condition for variable n = NATURAL, NATURAL, DIRICHLET: 1.5, DIRICHLET: 1.5 -set Boundary condition for variable psi = NATURAL +set Boundary condition for variable n = NATURAL # ================================================================================= # Set the model constants # ================================================================================= # Set the user-defined model constants, which must have a counter-part given in -# customPDE.h. These are most often used in the residual equations in equations.h, +# customPDE.h. These are most often used in the residual equations in equations.cc, # but may also be used for initial conditions and nucleation calculations. The type # options currently are DOUBLE, INT, BOOL, TENSOR, and [symmetry] ELASTIC CONSTANTS # where [symmetry] is ISOTROPIC, TRANSVERSE, ORTHOTROPIC, or ANISOTROPIC. -# The mobility, MnV in equations.h +# The mobility, MnV in equations.cc set Model constant MnV = 1.0, DOUBLE -# The gradient energy coefficient, KnV in equations.h +# The gradient energy coefficient, KnV in equations.cc set Model constant KnV = 2.0, DOUBLE diff --git a/tests/automatic_tests/allenCahn/postprocess.cc b/tests/automatic_tests/allenCahn/postprocess.cc new file mode 100644 index 000000000..9dc68bc25 --- /dev/null +++ b/tests/automatic_tests/allenCahn/postprocess.cc @@ -0,0 +1,88 @@ +// ================================================================================= +// Set the attributes of the postprocessing variables +// ================================================================================= +// This function is analogous to 'loadVariableAttributes' in 'equations.cc', but +// for the postprocessing expressions. It sets the attributes for each +// postprocessing expression, including its name, whether it is a vector or +// scalar (only scalars are supported at present), its dependencies on other +// variables and their derivatives, and whether to calculate an integral of the +// postprocessed quantity over the entire domain. + +void +variableAttributeLoader::loadPostProcessorVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "mg_n"); + set_variable_type(0, SCALAR); + + set_dependencies_value_term_RHS(0, "grad(n)"); + set_dependencies_gradient_term_RHS(0, ""); + + set_output_integral(0, true); + + // Variable 1 + set_variable_name(1, "f_tot"); + set_variable_type(1, SCALAR); + + set_dependencies_value_term_RHS(1, "n, grad(n)"); + set_dependencies_gradient_term_RHS(1, ""); + + set_output_integral(1, true); +} + +// ============================================================================================= +// postProcessedFields: Set the postprocessing expressions +// ============================================================================================= +// This function is analogous to 'explicitEquationRHS' and +// 'nonExplicitEquationRHS' in equations.cc. It takes in "variable_list" and +// "q_point_loc" as inputs and outputs two terms in the expression for the +// postprocessing variable -- one proportional to the test function and one +// proportional to the gradient of the test function. The index for each +// variable in this list corresponds to the index given at the top of this file +// (for submitting the terms) and the index in 'equations.cc' for assigning the +// values/derivatives of the primary variables. + +template +void +customPDE::postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // The order parameter and its derivatives + scalarvalueType n = variable_list.get_scalar_value(0); + scalargradType nx = variable_list.get_scalar_gradient(0); + + // --- Setting the expressions for the terms in the postprocessing expressions + // --- + + scalarvalueType f_tot = constV(0.0); + + // The homogenous free energy + scalarvalueType f_chem = (n * n * n * n - 2.0 * n * n * n + n * n); + + // The gradient free energy + scalarvalueType f_grad = constV(0.0); + + for (int i = 0; i < dim; i++) + { + for (int j = 0; j < dim; j++) + { + f_grad += constV(0.5 * KnV) * nx[i] * nx[j]; + } + } + + // The total free energy + f_tot = f_chem + f_grad; + + // --- Submitting the terms for the postprocessing expressions --- + + pp_variable_list.set_scalar_value_term_RHS(0, std::sqrt(nx[0] * nx[0] + nx[1] * nx[1])); + + pp_variable_list.set_scalar_value_term_RHS(1, f_tot); +} diff --git a/tests/automatic_tests/application_debug_test.py b/tests/automatic_tests/application_debug_test.py new file mode 100644 index 000000000..37db86151 --- /dev/null +++ b/tests/automatic_tests/application_debug_test.py @@ -0,0 +1,248 @@ +import os +import subprocess +import shutil +import glob +from concurrent.futures import ProcessPoolExecutor + + +def does_filepath_exist(filepath): + """Function to check that a certain filepath exists + + Args: + filepath (string): The absolute filepath + + Raises: + FileNotFoundError: An error if the filepath does not exist + + Returns: + Bool: Whether the filepath exists + """ + if os.path.exists(filepath): + return True + else: + raise FileNotFoundError(f"{filepath} does not exist") + + +def get_application_path(app_name): + """Function that returns that absolute path for the specified application + + Args: + app_name (string): The application name + + Returns: + String: Absolute application path + """ + # Current directory + pwd = os.getcwd() + + # Check that we're in the automatic test directory + assert ( + "tests/automatic_tests" in pwd + ), "Current directory is not within 'tests/automatic_tests'" + + # Application path assuming file structure matches GitHub repo + app_path = pwd.replace("tests/automatic_tests", f"applications/{app_name}") + + return app_path + + +def set_timestep(number, app_dir, new_parameter_file): + """Function that write create a copy of the of the parameters.prm file + in the given application directory and set the number of timesteps + + Args: + number (int): Number of timesteps + app_dir (string): Absolute filepath for application directory + new_parameter_file (string): Name of new parameters.prm + """ + # Absolute path of the parameters file + parameter_file_path = os.path.join(app_dir, "parameters.prm") + + # Check that the filepath exists + does_filepath_exist(parameter_file_path) + + # Make a copy of the original parameters file + new_parameter_file_path = os.path.join(app_dir, new_parameter_file) + shutil.copy(parameter_file_path, new_parameter_file_path) + print(f"Copied {parameter_file_path} to {new_parameter_file_path}.") + + # Set the new number of timesteps, making sure to remove simulation end time if there + with open(new_parameter_file_path, "r") as file: + lines = file.readlines() + + set_n_timesteps = False + with open(new_parameter_file_path, "w") as file: + for line in lines: + if "set Number of time steps" in line and not set_n_timesteps: + file.write(f"set Number of time steps = {number}\n") + set_n_timesteps = True + elif "set Simulation end time" in line and not set_n_timesteps: + file.write(f"set Number of time steps = {number}\n") + set_n_timesteps = True + elif "set Simulation end time" in line and set_n_timesteps: + file.write("\n") + else: + file.write(line) + print( + f"Updated {new_parameter_file} in {app_dir} to set Number of time steps to {number}." + ) + + +def compile_and_run(app_name, new_parameter_file, test_dir): + """Function that compile and runs the application in debug mode + + Args: + app_name (string): Application name + new_parameter_file (string): Parameter file + test_dir (string): Automatic test directory + + Returns: + String: Whether the application was able to succeed or not. The first return + is the application name and the second is success or failure + """ + try: + # Navigate to tests/automatic_tests + os.chdir(test_dir) + + # Grab application path + app_dir = get_application_path(app_name) + + # Navigate to application directory + os.chdir(app_dir) + print(f"Currently in {os.getcwd()}") + + # Compile the application in debug mode + if os.path.exists("CMakeCache.txt"): + os.remove("CMakeCache.txt") + print(f"Compiling {app_dir}") + compile_result = subprocess.run( + ["cmake", "."], check=True, capture_output=True, text=True + ) + make_result = subprocess.run( + ["make", "debug"], check=True, capture_output=True, text=True + ) + + # Run the application + print(f"Running {app_dir} with parameter file {new_parameter_file}") + run_result = subprocess.run( + ["mpirun", "-n", "1", "./main", "-i", new_parameter_file], + check=True, + capture_output=True, + text=True, + ) + + # Clean up + print(f"Cleaning up {app_dir}") + os.remove("CMakeCache.txt") + os.remove("main") + if os.path.exists("integratedFields.txt"): + os.remove("integratedFields.txt") + for solution_file in glob.glob("solution-*.vtu"): + os.remove(solution_file) + for restart_file in glob.glob("restart.*"): + os.remove(restart_file) + os.remove(new_parameter_file) + + # Return success + return ( + app_name, + "Success", + compile_result.stdout + make_result.stdout + run_result.stdout, + ) + + except subprocess.CalledProcessError as exc: + error_output = exc.stderr if exc.stderr else str(exc) + return (app_name, f"Failed: {error_output}", "") + + except Exception as exc: + return (app_name, f"Failed: {str(exc)}", "") + + +def run_tests_in_parallel(application_list): + """Run each test in parallel + + Args: + application_list (list): A list of application names + + Returns: + Dict: Dictionary that track the success/failure of each application + """ + # Parameter file name + new_parameter_file = "parameters_new.prm" + + # Grab currnet directory which should be the automatic test directory + test_dir = os.getcwd() + + # Update parameter file for one timestep + for app_name in application_list: + # Grab application path + app_dir = get_application_path(app_name) + + # Set timestep + set_timestep(1, app_dir, new_parameter_file) + + # Dictionary for results + results = {} + + # Run each task in parallel + with ProcessPoolExecutor() as executor: + futures = [ + executor.submit(compile_and_run, app_name, new_parameter_file, test_dir) + for app_name in application_list + ] + for future in futures: + app_name, status, output = future.result() + results[app_name] = (status, output) + + return results + + +# Application list +application_list = [ + "CHAC_anisotropy", + "corrosion", + "CHAC_anisotropyRegularized", + "corrosion_microgalvanic", + "coupledCahnHilliardAllenCahn", + "dendriticSolidification", + "eshelbyInclusion", + "fickianDiffusion", + "grainGrowth", + "grainGrowth_dream3d", + "mechanics", + "MgNd_precipitate_single_Bppp", + "nucleationModel", + "allenCahn", + "nucleationModel_preferential", + "allenCahn_conserved", + "alloySolidification", + "precipitateEvolution", + "precipitateEvolution_pfunction", + "alloySolidification_uniform", + "spinodalDecomposition", + "anisotropyFacet", + "cahnHilliard", + "CHiMaD_benchmarks/CHiMaD_benchmark1a", + "CHiMaD_benchmarks/CHiMaD_benchmark1b", + "CHiMaD_benchmarks/CHiMaD_benchmark1c", + "CHiMaD_benchmarks/CHiMaD_benchmark2a", + "CHiMaD_benchmarks/CHiMaD_benchmark3a", + "CHiMaD_benchmarks/CHiMaD_benchmark6a", + "CHiMaD_benchmarks/CHiMaD_benchmark7a", +] + +# Run tests in parallel +results = run_tests_in_parallel(application_list) + +# Print the results +print("\n\nCompilation and Execution Results:") +passed_count = 0 + +for app_name, (status, output) in results.items(): + print(f"{app_name}: {status}") + if status == "Success": + passed_count += 1 + else: + print(f"Error details:\n{output}\n") + +print(f"\nTotal applications passed: {passed_count} out of {len(results)}") diff --git a/applications/CHiMaD_benchmark6a/CMakeLists.txt b/tests/automatic_tests/cahnHilliard/CMakeLists.txt similarity index 57% rename from applications/CHiMaD_benchmark6a/CMakeLists.txt rename to tests/automatic_tests/cahnHilliard/CMakeLists.txt index 39b8e6bd3..49489dfc7 100644 --- a/applications/CHiMaD_benchmark6a/CMakeLists.txt +++ b/tests/automatic_tests/cahnHilliard/CMakeLists.txt @@ -2,7 +2,10 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) + +# Required cmake version. This should be inline with what is required +# for the dealii installation. +CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) # Find deal.II installation FIND_PACKAGE(deal.II 9.2.0 REQUIRED @@ -12,8 +15,8 @@ FIND_PACKAGE(deal.II 9.2.0 REQUIRED IF(NOT ${DEAL_II_WITH_P4EST}) MESSAGE(FATAL_ERROR "\n" "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” + "The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n" + "user guide to confirm that deal.II and p4est were installed and configured correctly." ) ENDIF() @@ -49,21 +52,13 @@ if (EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - ADD_EXECUTABLE(main main.cc ) DEAL_II_SETUP_TARGET(main) set(cmd "cmake") set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) +set(dir ${PROJECT_SOURCE_DIR}/../../..) EXECUTE_PROCESS(COMMAND ${cmd} ${arg} WORKING_DIRECTORY ${dir}) @@ -73,9 +68,9 @@ EXECUTE_PROCESS(COMMAND ${cmd} WORKING_DIRECTORY ${dir}) if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) endif() diff --git a/tests/automatic_tests/cahnHilliard/ICs_and_BCs.cc b/tests/automatic_tests/cahnHilliard/ICs_and_BCs.cc new file mode 100644 index 000000000..659087692 --- /dev/null +++ b/tests/automatic_tests/cahnHilliard/ICs_and_BCs.cc @@ -0,0 +1,92 @@ +// =========================================================================== +// FUNCTION FOR INITIAL CONDITIONS +// =========================================================================== + +template +void +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) +{ + // --------------------------------------------------------------------- + // ENTER THE INITIAL CONDITIONS HERE + // --------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the initial condition for each variable + // according to its variable index + + // The initial condition is a set of overlapping circles/spheres defined + // by a hyperbolic tangent function. The center of each circle/sphere is + // given by "center" and its radius is given by "radius". + + if (index == 0) + { + double center[12][3] = { + {0.1, 0.3, 0}, + {0.8, 0.7, 0}, + {0.5, 0.2, 0}, + {0.4, 0.4, 0}, + {0.3, 0.9, 0}, + {0.8, 0.1, 0}, + {0.9, 0.5, 0}, + {0.0, 0.1, 0}, + {0.1, 0.6, 0}, + {0.5, 0.6, 0}, + {1, 1, 0}, + {0.7, 0.95, 0} + }; + double rad[12] = {12, 14, 19, 16, 11, 12, 17, 15, 20, 10, 11, 14}; + double dist; + scalar_IC = 0; + for (unsigned int i = 0; i < 12; i++) + { + dist = 0.0; + for (unsigned int dir = 0; dir < dim; dir++) + { + dist += (p[dir] - center[i][dir] * userInputs.domain_size[dir]) * + (p[dir] - center[i][dir] * userInputs.domain_size[dir]); + } + dist = std::sqrt(dist); + + scalar_IC += 0.5 * (1.0 - std::tanh((dist - rad[i]) / 1.5)); + } + if (scalar_IC > 1.0) + scalar_IC = 1.0; + } + else + { + scalar_IC = 0.0; + } + + // --------------------------------------------------------------------- +} + +// =========================================================================== +// FUNCTION FOR NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS +// =========================================================================== + +template +void +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) +{ + // -------------------------------------------------------------------------- + // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE + // -------------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the boundary condition for each variable + // according to its variable index. This function can be left blank if there + // are no non-uniform Dirichlet boundary conditions. For BCs that change in + // time, you can access the current time through the variable "time". The + // boundary index can be accessed via the variable "direction", which starts + // at zero and uses the same order as the BC specification in parameters.in + // (i.e. left = 0, right = 1, bottom = 2, top = 3, front = 4, back = 5). + + // ------------------------------------------------------------------------- +} diff --git a/tests/automatic_tests/cahnHilliard/customPDE.h b/tests/automatic_tests/cahnHilliard/customPDE.h new file mode 100644 index 000000000..e09e9a782 --- /dev/null +++ b/tests/automatic_tests/cahnHilliard/customPDE.h @@ -0,0 +1,93 @@ +#include "../../../include/matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "../../../include/typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double McV = userInputs.get_model_constant_double("McV"); + double KcV = userInputs.get_model_constant_double("KcV"); + + // ================================================================ +}; diff --git a/tests/automatic_tests/cahnHilliard/equations.cc b/tests/automatic_tests/cahnHilliard/equations.cc new file mode 100644 index 000000000..8dbe9cb53 --- /dev/null +++ b/tests/automatic_tests/cahnHilliard/equations.cc @@ -0,0 +1,130 @@ +// ================================================================================= +// Set the attributes of the primary field variables +// ================================================================================= +// This function sets attributes for each variable/equation in the app. The +// attributes are set via standardized function calls. The first parameter for +// each function call is the variable index (starting at zero). The first set of +// variable/equation attributes are the variable name (any string), the variable +// type (SCALAR/VECTOR), and the equation type (EXPLICIT_TIME_DEPENDENT/ +// TIME_INDEPENDENT/AUXILIARY). The next set of attributes describe the +// dependencies for the governing equation on the values and derivatives of the +// other variables for the value term and gradient term of the RHS and the LHS. +// The final pair of attributes determine whether a variable represents a field +// that can nucleate and whether the value of the field is needed for nucleation +// rate calculations. + +void +variableAttributeLoader::loadVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "c"); + set_variable_type(0, SCALAR); + set_variable_equation_type(0, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(0, "c"); + set_dependencies_gradient_term_RHS(0, "grad(mu)"); + + // Variable 1 + set_variable_name(1, "mu"); + set_variable_type(1, SCALAR); + set_variable_equation_type(1, AUXILIARY); + + set_dependencies_value_term_RHS(1, "c"); + set_dependencies_gradient_term_RHS(1, "grad(c)"); +} + +// ============================================================================================= +// explicitEquationRHS (needed only if one or more equation is explict time +// dependent) +// ============================================================================================= +// This function calculates the right-hand-side of the explicit time-dependent +// equations for each variable. It takes "variable_list" as an input, which is a +// list of the value and derivatives of each of the variables at a specific +// quadrature point. The (x,y,z) location of that quadrature point is given by +// "q_point_loc". The function outputs two terms to variable_list -- one +// proportional to the test function and one proportional to the gradient of the +// test function. The index for each variable in this list corresponds to the +// index given at the top of this file. + +template +void +customPDE::explicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType mux = variable_list.get_scalar_gradient(1); + + // --- Setting the expressions for the terms in the governing equations --- + scalarvalueType eq_c = c; + scalargradType eqx_c = constV(-McV * userInputs.dtValue) * mux; + + // --- Submitting the terms for the governing equations --- + variable_list.set_scalar_value_term_RHS(0, eq_c); + variable_list.set_scalar_gradient_term_RHS(0, eqx_c); +} + +// ============================================================================================= +// nonExplicitEquationRHS (needed only if one or more equation is time +// independent or auxiliary) +// ============================================================================================= +// This function calculates the right-hand-side of all of the equations that are +// not explicit time-dependent equations. It takes "variable_list" as an input, +// which is a list of the value and derivatives of each of the variables at a +// specific quadrature point. The (x,y,z) location of that quadrature point is +// given by "q_point_loc". The function outputs two terms to variable_list -- +// one proportional to the test function and one proportional to the gradient of +// the test function. The index for each variable in this list corresponds to +// the index given at the top of this file. + +template +void +customPDE::nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // --- Setting the expressions for the terms in the governing equations --- + + // The derivative of the local free energy + scalarvalueType fcV = constV(4.0) * (c - constV(1.0)) * (c - constV(0.5)) * c; + + // The terms for the governing equations + scalarvalueType eq_mu = fcV; + scalargradType eqx_mu = constV(KcV) * cx; + + // --- Submitting the terms for the governing equations --- + + variable_list.set_scalar_value_term_RHS(1, eq_mu); + variable_list.set_scalar_gradient_term_RHS(1, eqx_mu); +} + +// ============================================================================================= +// equationLHS (needed only if at least one equation is time independent) +// ============================================================================================= +// This function calculates the left-hand-side of time-independent equations. It +// takes "variable_list" as an input, which is a list of the value and +// derivatives of each of the variables at a specific quadrature point. The +// (x,y,z) location of that quadrature point is given by "q_point_loc". The +// function outputs two terms to variable_list -- one proportional to the test +// function and one proportional to the gradient of the test function -- for the +// left-hand-side of the equation. The index for each variable in this list +// corresponds to the index given at the top of this file. If there are multiple +// elliptic equations, conditional statements should be sed to ensure that the +// correct residual is being submitted. The index of the field being solved can +// be accessed by "this->currentFieldIndex". + +template +void +customPDE::equationLHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{} diff --git a/tests/automatic_tests/gold_cahnHilliard/integratedFields.txt b/tests/automatic_tests/cahnHilliard/gold_integratedFields.txt similarity index 100% rename from tests/automatic_tests/gold_cahnHilliard/integratedFields.txt rename to tests/automatic_tests/cahnHilliard/gold_integratedFields.txt diff --git a/applications/CHAC_anisotropyRegularized/main.cc b/tests/automatic_tests/cahnHilliard/main.cc similarity index 96% rename from applications/CHAC_anisotropyRegularized/main.cc rename to tests/automatic_tests/cahnHilliard/main.cc index aa697a929..3113c62c2 100644 --- a/applications/CHAC_anisotropyRegularized/main.cc +++ b/tests/automatic_tests/cahnHilliard/main.cc @@ -4,9 +4,9 @@ #include "ICs_and_BCs.cc" #include "equations.cc" -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" +#include "../../../include/ParseCommandLineOpts.h" +#include "../../../include/inputFileReader.h" +#include "../../../src/variableAttributeLoader/variableAttributeLoader.cc" // Header file for postprocessing that may or may not exist #ifdef POSTPROCESS_FILE_EXISTS diff --git a/applications/CHiMaD_benchmark1a/parameters.prm b/tests/automatic_tests/cahnHilliard/parameters.prm similarity index 89% rename from applications/CHiMaD_benchmark1a/parameters.prm rename to tests/automatic_tests/cahnHilliard/parameters.prm index 72ad947f1..a10036331 100644 --- a/applications/CHiMaD_benchmark1a/parameters.prm +++ b/tests/automatic_tests/cahnHilliard/parameters.prm @@ -8,8 +8,8 @@ set Number of dimensions = 2 # (Domain size Z ignored in 2D) # ================================================================================= # Each axes spans from zero to the specified length -set Domain size X = 200 -set Domain size Y = 200 +set Domain size X = 100 +set Domain size Y = 100 set Domain size Z = 100 # ================================================================================= @@ -22,20 +22,20 @@ set Subdivisions X = 1 set Subdivisions Y = 1 set Subdivisions Z = 1 -set Refine factor = 7 +set Refine factor = 6 # Set the polynomial degree of the element (allowed values: 1, 2, or 3) -set Element degree = 1 +set Element degree = 2 # ================================================================================= # Set the time step parameters # ================================================================================= # The size of the time step -set Time step = 5.0e-3 +set Time step = 1.0e-3 # The simulation ends when either the number of time steps is reached or the # simulation time is reached. -set Number of time steps = 2000000 +set Number of time steps = 100000 # ================================================================================= # Set the boundary conditions @@ -69,24 +69,22 @@ set Boundary condition for variable mu = NATURAL # options currently are DOUBLE, INT, BOOL, TENSOR, and [symmetry] ELASTIC CONSTANTS # where [symmetry] is ISOTROPIC, TRANSVERSE, ORTHOTROPIC, or ANISOTROPIC. -# The mobility, MnV in equations.h -set Model constant McV = 5.0, DOUBLE +# The mobility, McV in equations.h +set Model constant McV = 1.0, DOUBLE -# The gradient energy coefficient, KnV in equations.h -set Model constant KcV = 2.0, DOUBLE +# The gradient energy coefficient, KcV in equations.h +set Model constant KcV = 1.5, DOUBLE # ================================================================================= # Set the output parameters # ================================================================================= # Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", "N_PER_DECADE", # or "LIST") -set Output condition = LIST +set Output condition = EQUAL_SPACING # Number of times the program outputs the fields (total number for "EQUAL_SPACING" # and "LOG_SPACING", number per decade for "N_PER_DECADE", ignored for "LIST") -#set Number of outputs = 5 - -set List of time steps to output = 0,200,1000,2000,4000,20000,40000,100000,200000,400000,600000,2000000 +set Number of outputs = 10 # The number of time steps between updates being printed to the screen set Skip print steps = 1000 diff --git a/applications/CHiMaD_benchmark1a/postprocess.cc b/tests/automatic_tests/cahnHilliard/postprocess.cc similarity index 87% rename from applications/CHiMaD_benchmark1a/postprocess.cc rename to tests/automatic_tests/cahnHilliard/postprocess.cc index 48487f816..031f595cb 100644 --- a/applications/CHiMaD_benchmark1a/postprocess.cc +++ b/tests/automatic_tests/cahnHilliard/postprocess.cc @@ -38,9 +38,12 @@ variableAttributeLoader::loadPostProcessorVariableAttributes() template void customPDE::postProcessedFields( - const variableContainer> &variable_list, - variableContainer> &pp_variable_list, - const dealii::Point> q_point_loc) const + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const { // --- Getting the values and derivatives of the model variables --- @@ -54,7 +57,7 @@ customPDE::postProcessedFields( scalarvalueType f_tot = constV(0.0); // The homogenous free energy - scalarvalueType f_chem = (5.0 * (c - 0.3) * (c - 0.3) * (c - 0.7) * (c - 0.7)); + scalarvalueType f_chem = c * c * c * c - 2.0 * c * c * c + c * c; // The gradient free energy scalarvalueType f_grad = constV(0.0); diff --git a/applications/CHiMaD_benchmark3/CMakeLists.txt b/tests/automatic_tests/coupledCahnHilliardAllenCahn/CMakeLists.txt similarity index 57% rename from applications/CHiMaD_benchmark3/CMakeLists.txt rename to tests/automatic_tests/coupledCahnHilliardAllenCahn/CMakeLists.txt index 39b8e6bd3..49489dfc7 100644 --- a/applications/CHiMaD_benchmark3/CMakeLists.txt +++ b/tests/automatic_tests/coupledCahnHilliardAllenCahn/CMakeLists.txt @@ -2,7 +2,10 @@ # CMake script for the PRISMS-PF applications: ## -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) + +# Required cmake version. This should be inline with what is required +# for the dealii installation. +CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) # Find deal.II installation FIND_PACKAGE(deal.II 9.2.0 REQUIRED @@ -12,8 +15,8 @@ FIND_PACKAGE(deal.II 9.2.0 REQUIRED IF(NOT ${DEAL_II_WITH_P4EST}) MESSAGE(FATAL_ERROR "\n" "*** deal.II was not installed with p4est. ***\n\n" - “The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n” - “user guide to confirm that deal.II and p4est were installed and configured correctly.” + "The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n" + "user guide to confirm that deal.II and p4est were installed and configured correctly." ) ENDIF() @@ -49,21 +52,13 @@ if (EXISTS "nucleation.cc") add_definitions(-DNUCLEATION_FILE_EXISTS) endif() -# Append extra flags for the GNU compiler to suppress some warnings -#if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-extra") - set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-uninitialized -Wno-unused-parameter -Wno-extra") - #set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") - #set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_RELEASE} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#endif() - ADD_EXECUTABLE(main main.cc ) DEAL_II_SETUP_TARGET(main) set(cmd "cmake") set(arg "CMakeLists.txt") -set(dir ${PROJECT_SOURCE_DIR}/../..) +set(dir ${PROJECT_SOURCE_DIR}/../../..) EXECUTE_PROCESS(COMMAND ${cmd} ${arg} WORKING_DIRECTORY ${dir}) @@ -73,9 +68,9 @@ EXECUTE_PROCESS(COMMAND ${cmd} WORKING_DIRECTORY ${dir}) if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) else() - TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../libprisms_pf_debug.a) + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) endif() diff --git a/tests/automatic_tests/coupledCahnHilliardAllenCahn/ICs_and_BCs.cc b/tests/automatic_tests/coupledCahnHilliardAllenCahn/ICs_and_BCs.cc new file mode 100644 index 000000000..5993e873c --- /dev/null +++ b/tests/automatic_tests/coupledCahnHilliardAllenCahn/ICs_and_BCs.cc @@ -0,0 +1,94 @@ +// =========================================================================== +// FUNCTION FOR INITIAL CONDITIONS +// =========================================================================== + +template +void +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) +{ + // --------------------------------------------------------------------- + // ENTER THE INITIAL CONDITIONS HERE + // --------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the initial condition for each variable + // according to its variable index + // The initial condition is two circles/spheres defined + // by a hyperbolic tangent function. The center of each circle/sphere is + // given by "center" and its radius is given by "rad". + + double dist; + scalar_IC = 0; + + if (index == 0) + { + scalar_IC = matrix_concentration; + } + + dist = 0.0; + for (unsigned int dir = 0; dir < dim; dir++) + { + dist += (p[dir] - center1[dir]) * (p[dir] - center1[dir]); + } + dist = std::sqrt(dist); + + // Initial condition for the concentration field + if (index == 0) + { + scalar_IC += 0.5 * (0.125) * (1.0 - std::tanh((dist - radius1) / (1.0))); + } + else + { + scalar_IC += 0.5 * (1.0 - std::tanh((dist - radius1) / (1.0))); + } + + dist = 0.0; + for (unsigned int dir = 0; dir < dim; dir++) + { + dist += (p[dir] - center2[dir]) * (p[dir] - center2[dir]); + } + dist = std::sqrt(dist); + + // Initial condition for the concentration field + if (index == 0) + { + scalar_IC += 0.5 * (0.125) * (1.0 - std::tanh((dist - radius2) / (1.0))); + } + else + { + scalar_IC += 0.5 * (1.0 - std::tanh((dist - radius2) / (1.0))); + } + + // -------------------------------------------------------------------------- +} + +// =========================================================================== +// FUNCTION FOR NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS +// =========================================================================== + +template +void +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) +{ + // -------------------------------------------------------------------------- + // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE + // -------------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the boundary condition for each variable + // according to its variable index. This function can be left blank if there + // are no non-uniform Dirichlet boundary conditions. For BCs that change in + // time, you can access the current time through the variable "time". The + // boundary index can be accessed via the variable "direction", which starts + // at zero and uses the same order as the BC specification in parameters.in + // (i.e. left = 0, right = 1, bottom = 2, top = 3, front = 4, back = 5). + + // ------------------------------------------------------------------------- +} diff --git a/tests/automatic_tests/coupledCahnHilliardAllenCahn/customPDE.h b/tests/automatic_tests/coupledCahnHilliardAllenCahn/customPDE.h new file mode 100644 index 000000000..dc86a5323 --- /dev/null +++ b/tests/automatic_tests/coupledCahnHilliardAllenCahn/customPDE.h @@ -0,0 +1,103 @@ +#include "../../../include/matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + // Constructor + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "../../../include/typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double Mc = userInputs.get_model_constant_double("Mc"); + double Mn = userInputs.get_model_constant_double("Mn"); + double Kn = userInputs.get_model_constant_double("Kn"); + + Tensor<1, dim> center1 = userInputs.get_model_constant_rank_1_tensor("center1"); + Tensor<1, dim> center2 = userInputs.get_model_constant_rank_1_tensor("center2"); + + double radius1 = userInputs.get_model_constant_double("radius1"); + double radius2 = userInputs.get_model_constant_double("radius2"); + + double matrix_concentration = + userInputs.get_model_constant_double("matrix_concentration"); + + // ================================================================ +}; diff --git a/tests/automatic_tests/coupledCahnHilliardAllenCahn/equations.cc b/tests/automatic_tests/coupledCahnHilliardAllenCahn/equations.cc new file mode 100644 index 000000000..d3e5554c9 --- /dev/null +++ b/tests/automatic_tests/coupledCahnHilliardAllenCahn/equations.cc @@ -0,0 +1,141 @@ +// ================================================================================= +// Set the attributes of the primary field variables +// ================================================================================= +// This function sets attributes for each variable/equation in the app. The +// attributes are set via standardized function calls. The first parameter for +// each function call is the variable index (starting at zero). The first set of +// variable/equation attributes are the variable name (any string), the variable +// type (SCALAR/VECTOR), and the equation type (EXPLICIT_TIME_DEPENDENT/ +// TIME_INDEPENDENT/AUXILIARY). The next set of attributes describe the +// dependencies for the governing equation on the values and derivatives of the +// other variables for the value term and gradient term of the RHS and the LHS. +// The final pair of attributes determine whether a variable represents a field +// that can nucleate and whether the value of the field is needed for nucleation +// rate calculations. + +void +variableAttributeLoader::loadVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "c"); + set_variable_type(0, SCALAR); + set_variable_equation_type(0, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(0, "c"); + set_dependencies_gradient_term_RHS(0, "n,grad(c),grad(n)"); + + // Variable 1 + set_variable_name(1, "n"); + set_variable_type(1, SCALAR); + set_variable_equation_type(1, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(1, "c,n"); + set_dependencies_gradient_term_RHS(1, "grad(n)"); +} + +// ============================================================================================= +// explicitEquationRHS (needed only if one or more equation is explict time +// dependent) +// ============================================================================================= +// This function calculates the right-hand-side of the explicit time-dependent +// equations for each variable. It takes "variable_list" as an input, which is a +// list of the value and derivatives of each of the variables at a specific +// quadrature point. The (x,y,z) location of that quadrature point is given by +// "q_point_loc". The function outputs two terms to variable_list -- one +// proportional to the test function and one proportional to the gradient of the +// test function. The index for each variable in this list corresponds to the +// index given at the top of this file. + +template +void +customPDE::explicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // c + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // n + scalarvalueType n = variable_list.get_scalar_value(1); + scalargradType nx = variable_list.get_scalar_gradient(1); + + // --- Setting the expressions for the terms in the governing equations --- + + // Free energy for each phase and their first and second derivatives + scalarvalueType fa = + (-1.6704 - 4.776 * c + 5.1622 * c * c - 2.7375 * c * c * c + 1.3687 * c * c * c * c); + scalarvalueType fac = (-4.776 + 10.3244 * c - 8.2125 * c * c + 5.4748 * c * c * c); + scalarvalueType facc = (10.3244 - 16.425 * c + 16.4244 * c * c); + scalarvalueType fb = (5.0 * c * c - 5.9746 * c - 1.5924); + scalarvalueType fbc = (10.0 * c - 5.9746); + scalarvalueType fbcc = constV(10.0); + + // Interpolation function and its derivative + scalarvalueType h = (10.0 * n * n * n - 15.0 * n * n * n * n + 6.0 * n * n * n * n * n); + scalarvalueType hn = (30.0 * n * n - 60.0 * n * n * n + 30.0 * n * n * n * n); + + // Residual equations + scalargradType mux = (cx * ((1.0 - h) * facc + h * fbcc) + nx * ((fbc - fac) * hn)); + scalarvalueType eq_c = c; + scalargradType eqx_c = (constV(-Mc * userInputs.dtValue) * mux); + scalarvalueType eq_n = (n - constV(userInputs.dtValue * Mn) * (fb - fa) * hn); + scalargradType eqx_n = (constV(-userInputs.dtValue * Kn * Mn) * nx); + + // --- Submitting the terms for the governing equations --- + + // Terms for the equation to evolve the concentration + variable_list.set_scalar_value_term_RHS(0, eq_c); + variable_list.set_scalar_gradient_term_RHS(0, eqx_c); + + // Terms for the equation to evolve the order parameter + variable_list.set_scalar_value_term_RHS(1, eq_n); + variable_list.set_scalar_gradient_term_RHS(1, eqx_n); +} + +// ============================================================================================= +// nonExplicitEquationRHS (needed only if one or more equation is time +// independent or auxiliary) +// ============================================================================================= +// This function calculates the right-hand-side of all of the equations that are +// not explicit time-dependent equations. It takes "variable_list" as an input, +// which is a list of the value and derivatives of each of the variables at a +// specific quadrature point. The (x,y,z) location of that quadrature point is +// given by "q_point_loc". The function outputs two terms to variable_list -- +// one proportional to the test function and one proportional to the gradient of +// the test function. The index for each variable in this list corresponds to +// the index given at the top of this file. + +template +void +customPDE::nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{} + +// ============================================================================================= +// equationLHS (needed only if at least one equation is time independent) +// ============================================================================================= +// This function calculates the left-hand-side of time-independent equations. It +// takes "variable_list" as an input, which is a list of the value and +// derivatives of each of the variables at a specific quadrature point. The +// (x,y,z) location of that quadrature point is given by "q_point_loc". The +// function outputs two terms to variable_list -- one proportional to the test +// function and one proportional to the gradient of the test function -- for the +// left-hand-side of the equation. The index for each variable in this list +// corresponds to the index given at the top of this file. If there are multiple +// elliptic equations, conditional statements should be sed to ensure that the +// correct residual is being submitted. The index of the field being solved can +// be accessed by "this->currentFieldIndex". + +template +void +customPDE::equationLHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{} diff --git a/tests/automatic_tests/gold_coupledCahnHilliardAllenCahn/integratedFields.txt b/tests/automatic_tests/coupledCahnHilliardAllenCahn/gold_integratedFields.txt similarity index 100% rename from tests/automatic_tests/gold_coupledCahnHilliardAllenCahn/integratedFields.txt rename to tests/automatic_tests/coupledCahnHilliardAllenCahn/gold_integratedFields.txt diff --git a/applications/CHAC_performance_test/main.cc b/tests/automatic_tests/coupledCahnHilliardAllenCahn/main.cc similarity index 96% rename from applications/CHAC_performance_test/main.cc rename to tests/automatic_tests/coupledCahnHilliardAllenCahn/main.cc index aa697a929..3113c62c2 100644 --- a/applications/CHAC_performance_test/main.cc +++ b/tests/automatic_tests/coupledCahnHilliardAllenCahn/main.cc @@ -4,9 +4,9 @@ #include "ICs_and_BCs.cc" #include "equations.cc" -#include "../../include/ParseCommandLineOpts.h" -#include "../../include/inputFileReader.h" -#include "../../src/variableAttributeLoader/variableAttributeLoader.cc" +#include "../../../include/ParseCommandLineOpts.h" +#include "../../../include/inputFileReader.h" +#include "../../../src/variableAttributeLoader/variableAttributeLoader.cc" // Header file for postprocessing that may or may not exist #ifdef POSTPROCESS_FILE_EXISTS diff --git a/tests/automatic_tests/coupledCahnHilliardAllenCahn/parameters.prm b/tests/automatic_tests/coupledCahnHilliardAllenCahn/parameters.prm new file mode 100644 index 000000000..96a09c3ab --- /dev/null +++ b/tests/automatic_tests/coupledCahnHilliardAllenCahn/parameters.prm @@ -0,0 +1,140 @@ +# ================================================================================= +# Set the number of dimensions (2 or 3 for a 2D or 3D calculation) +# ================================================================================= +set Number of dimensions = 2 + +# ================================================================================= +# Set the length of the domain in all three dimensions +# (Domain size Z ignored in 2D) +# ================================================================================= +# Each axes spans from zero to the specified length +set Domain size X = 100 +set Domain size Y = 100 +set Domain size Z = 100 + +# ================================================================================= +# Set the element parameters +# ================================================================================= +# The number of elements in each direction is 2^(refineFactor) * subdivisions +# Subdivisions Z ignored in 2D +# For optimal performance, use refineFactor primarily to determine the element size +set Subdivisions X = 3 +set Subdivisions Y = 3 +set Subdivisions Z = 3 + +set Refine factor = 6 + +# Set the polynomial degree of the element (allowed values: 1, 2, or 3) +set Element degree = 1 + +# ================================================================================= +# Set the adaptive mesh refinement parameters +# ================================================================================= +# Set the flag determining if adaptive meshing is activated +set Mesh adaptivity = true + +# Set the maximum and minimum level of refinement +# When adaptive meshing is enabled, the refine factor set in the block above is +# only used to generate the first pass of the mesh as the initial conditions are +# applied. It should be set somewhere between the max and min levels below. + +set Max refinement level = 6 +set Min refinement level = 3 + +# Set the number of time steps between remeshing operations +set Steps between remeshing operations = 5000 + +# Set the criteria for adapting the mesh +subsection Refinement criterion: n + # Select whether the mesh is refined based on the variable value (VALUE), + # its gradient (GRADIENT), or both (VALUE_AND_GRADIENT) + set Criterion type = VALUE + # Set the lower and upper bounds for the value-based refinement window + set Value lower bound = 0.01 + set Value upper bound = 0.99 +end + +subsection Refinement criterion: c + # Select whether the mesh is refined based on the variable value (VALUE), + # its gradient (GRADIENT), or both (VALUE_AND_GRADIENT) + set Criterion type = VALUE + # Set the lower and upper bounds for the value-based refinement window + set Value lower bound = 0.02 + set Value upper bound = 0.1 +end + +# ================================================================================= +# Set the time step parameters +# ================================================================================= +# The size of the time step +set Time step = 8.0e-4 + +# The simulation ends when either the number of time steps is reached or the +# simulation time is reached. +set Number of time steps = 150000 + +# ================================================================================= +# Set the boundary conditions +# ================================================================================= +# Set the boundary condition for each variable, where each variable is given by +# its name, as defined in equations.h. The four boundary condition +# types are NATURAL, DIRICHLET, NON_UNIFORM_DIRICHLET and PERIODIC. If all +# of the boundaries have the same boundary condition, only one boundary condition +# type needs to be given. If multiple boundary condition types are needed, give a +# comma-separated list of the types. The order is the miniumum of x, maximum of x, +# minimum of y, maximum of y, minimum of z, maximum of z (i.e left, right, bottom, +# top in 2D and left, right, bottom, top, front, back in 3D). The value of a +# Dirichlet BC is specfied in the following way -- DIRCHILET: val -- where 'val' is +# the desired value. If the boundary condition is NON_UNIFORM_DIRICHLET, the +# boundary condition should be specified in the appropriate function in 'ICs_and_BCs.h'. +# Example 1: All periodic BCs for variable 'c' +# set Boundary condition for variable c = PERIODIC +# Example 2: Zero-derivative BCs on the left and right, Dirichlet BCs with value +# 1.5 on the top and bottom for variable 'n' in 2D +# set Boundary condition for variable n = NATURAL, NATURAL, DIRICHLET: 1.5, DIRICHLET: 1.5 + +set Boundary condition for variable c = NATURAL +set Boundary condition for variable n = NATURAL + +# ================================================================================= +# Set the model constants +# ================================================================================= +# Set the user-defined model constants, which must have a counter-part given in +# customPDE.h. These are most often used in the residual equations in equations.h, +# but may also be used for initial conditions and nucleation calculations. The type +# options currently are DOUBLE, INT, BOOL, TENSOR, and [symmetry] ELASTIC CONSTANTS +# where [symmetry] is ISOTROPIC, TRANSVERSE, ORTHOTROPIC, or ANISOTROPIC. + +# The CH mobility, McV in equations.h +set Model constant Mc = 1.0, DOUBLE + +# The AC mobility, MnV in equations.h +set Model constant Mn = 150.0, DOUBLE + +# Gradient energy coefficient +set Model constant Kn = 0.3, DOUBLE + +# Centers for points 1 and 2 +set Model constant center1 = (33.3333333333,33.3333333333,33.3333333333), TENSOR +set Model constant center2 = (75,75,75), TENSOR + +# Radii for points 1 and 2 +set Model constant radius1 = 20.0, DOUBLE +set Model constant radius2 = 8.33333333333, DOUBLE + +# Initial oncentration in the matrix +set Model constant matrix_concentration = 0.009, DOUBLE + +# ================================================================================= +# Set the output parameters +# ================================================================================= +# Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", "N_PER_DECADE", +# or "LIST") +set Output condition = EQUAL_SPACING + +# Number of times the program outputs the fields (total number for "EQUAL_SPACING" +# and "LOG_SPACING", number per decade for "N_PER_DECADE", ignored for "LIST") +set Number of outputs = 10 + +# The number of time steps between updates being printed to the screen +set Skip print steps = 1000 diff --git a/tests/automatic_tests/coupledCahnHilliardAllenCahn/postprocess.cc b/tests/automatic_tests/coupledCahnHilliardAllenCahn/postprocess.cc new file mode 100644 index 000000000..73ec2dab4 --- /dev/null +++ b/tests/automatic_tests/coupledCahnHilliardAllenCahn/postprocess.cc @@ -0,0 +1,101 @@ +// ================================================================================= +// Set the attributes of the postprocessing variables +// ================================================================================= +// This function is analogous to 'loadVariableAttributes' in 'equations.h', but +// for the postprocessing expressions. It sets the attributes for each +// postprocessing expression, including its name, whether it is a vector or +// scalar (only scalars are supported at present), its dependencies on other +// variables and their derivatives, and whether to calculate an integral of the +// postprocessed quantity over the entire domain. + +void +variableAttributeLoader::loadPostProcessorVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "f_tot"); + set_variable_type(0, SCALAR); + + set_dependencies_value_term_RHS(0, "c,n,grad(n)"); + set_dependencies_gradient_term_RHS(0, ""); + + set_output_integral(0, true); + + // Variable 0 + set_variable_name(1, "c_grad"); + set_variable_type(1, SCALAR); + + set_dependencies_value_term_RHS(1, "grad(c)"); + set_dependencies_gradient_term_RHS(1, ""); + + set_output_integral(1, false); +} + +// ============================================================================================= +// postProcessedFields: Set the postprocessing expressions +// ============================================================================================= +// This function is analogous to 'explicitEquationRHS' and +// 'nonExplicitEquationRHS' in equations.h. It takes in "variable_list" and +// "q_point_loc" as inputs and outputs two terms in the expression for the +// postprocessing variable -- one proportional to the test function and one +// proportional to the gradient of the test function. The index for each +// variable in this list corresponds to the index given at the top of this file +// (for submitting the terms) and the index in 'equations.h' for assigning the +// values/derivatives of the primary variables. + +template +void +customPDE::postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // c + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // n + scalarvalueType n = variable_list.get_scalar_value(1); + scalargradType nx = variable_list.get_scalar_gradient(1); + + // --- Setting the expressions for the terms in the postprocessing expressions + // --- + + // Free energy for each phase and their first and second derivatives + scalarvalueType fa = + (-1.6704 - 4.776 * c + 5.1622 * c * c - 2.7375 * c * c * c + 1.3687 * c * c * c * c); + scalarvalueType fb = (5.0 * c * c - 5.9746 * c - 1.5924); + + // Interpolation function and its derivative + scalarvalueType h = (10.0 * n * n * n - 15.0 * n * n * n * n + 6.0 * n * n * n * n * n); + + // The homogenous free energy + scalarvalueType f_chem = (constV(1.0) - h) * fa + h * fb; + + // The gradient free energy + scalarvalueType f_grad = constV(0.5 * Kn) * nx * nx; + + // The total free energy + scalarvalueType f_tot; + f_tot = f_chem + f_grad; + + // The magnitude of the gradient of c + scalarvalueType mag_grad_c = constV(0.0); + for (unsigned int i = 0; i < dim; i++) + { + mag_grad_c = mag_grad_c + cx[i] * cx[i]; + } + for (unsigned int v = 0; v < c.size(); v++) + { + mag_grad_c[v] = sqrt(mag_grad_c[v]); + } + + // --- Submitting the terms for the postprocessing expressions --- + + pp_variable_list.set_scalar_value_term_RHS(0, f_tot); + pp_variable_list.set_scalar_value_term_RHS(1, mag_grad_c); +} diff --git a/tests/automatic_tests/gold_precipitateEvolution/integratedFields.txt b/tests/automatic_tests/gold_precipitateEvolution/integratedFields.txt deleted file mode 100644 index 4bc41c70d..000000000 --- a/tests/automatic_tests/gold_precipitateEvolution/integratedFields.txt +++ /dev/null @@ -1,11 +0,0 @@ -0 f_tot -2961.102683 -1.2 f_tot -2965.677554 -2.4 f_tot -2965.884593 -3.6 f_tot -2966.061718 -4.8 f_tot -2966.199202 -6 f_tot -2966.302875 -7.2 f_tot -2966.375266 -8.4 f_tot -2966.427113 -9.6 f_tot -2966.463564 -10.8 f_tot -2966.488196 -12 f_tot -2966.507928 diff --git a/tests/automatic_tests/precipitateEvolution/CMakeLists.txt b/tests/automatic_tests/precipitateEvolution/CMakeLists.txt new file mode 100644 index 000000000..49489dfc7 --- /dev/null +++ b/tests/automatic_tests/precipitateEvolution/CMakeLists.txt @@ -0,0 +1,76 @@ +## +# CMake script for the PRISMS-PF applications: +## + + +# Required cmake version. This should be inline with what is required +# for the dealii installation. +CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) + +# Find deal.II installation +FIND_PACKAGE(deal.II 9.2.0 REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}) + +# Check to make sure deal.II is configured with p4est +IF(NOT ${DEAL_II_WITH_P4EST}) + MESSAGE(FATAL_ERROR "\n" + "*** deal.II was not installed with p4est. ***\n\n" + "The p4est library is a mandatory prerequisite for PRISMS-PF. Please consult the \n" + "user guide to confirm that deal.II and p4est were installed and configured correctly." + ) +ENDIF() + +DEAL_II_INITIALIZE_CACHED_VARIABLES() + +# Set up the debug, release, and run targets +ADD_CUSTOM_TARGET(debug + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) + +ADD_CUSTOM_TARGET(release + COMMAND +env ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND +env ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) + +ADD_CUSTOM_TARGET(run COMMAND main + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" + ) + +PROJECT(myapp) +if (${CMAKE_BUILD_TYPE} MATCHES DebugRelease) + SET(CMAKE_BUILD_TYPE Debug) +endif() + +# Check if postprocess.cc and nucleation.cc exist and set preprocessor variables +if (EXISTS "postprocess.cc") + add_definitions(-DPOSTPROCESS_FILE_EXISTS) +endif() +if (EXISTS "nucleation.cc") + add_definitions(-DNUCLEATION_FILE_EXISTS) +endif() + +ADD_EXECUTABLE(main main.cc ) + +DEAL_II_SETUP_TARGET(main) + +set(cmd "cmake") +set(arg "CMakeLists.txt") +set(dir ${PROJECT_SOURCE_DIR}/../../..) +EXECUTE_PROCESS(COMMAND ${cmd} ${arg} + WORKING_DIRECTORY ${dir}) + +set(cmd "make") + +EXECUTE_PROCESS(COMMAND ${cmd} + WORKING_DIRECTORY ${dir}) + +if (${CMAKE_BUILD_TYPE} STREQUAL "Release") + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +elseif(${CMAKE_BUILD_TYPE} STREQUAL "DebugRelease") + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf.a) +else() + TARGET_LINK_LIBRARIES(main ${CMAKE_SOURCE_DIR}/../../../libprisms_pf_debug.a) +endif() diff --git a/tests/automatic_tests/precipitateEvolution/ICs_and_BCs.cc b/tests/automatic_tests/precipitateEvolution/ICs_and_BCs.cc new file mode 100644 index 000000000..bfb3b7a84 --- /dev/null +++ b/tests/automatic_tests/precipitateEvolution/ICs_and_BCs.cc @@ -0,0 +1,94 @@ +// =========================================================================== +// FUNCTION FOR INITIAL CONDITIONS +// =========================================================================== + +template +void +customPDE::setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) +{ + // --------------------------------------------------------------------- + // ENTER THE INITIAL CONDITIONS HERE + // --------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the initial condition for each variable + // according to its variable index + + double center[4][3] = { + {1.0 / 3.0, 1.0 / 3.0, 0.5}, + {2.0 / 3.0, 2.0 / 3.0, 0.5}, + {3.0 / 4.0, 1.0 / 4.0, 0.5}, + {1.0 / 4.0, 3.0 / 4, 0.5} + }; + double rad[4] = {userInputs.domain_size[0] / 16.0, + userInputs.domain_size[0] / 16.0, + userInputs.domain_size[0] / 16.0, + userInputs.domain_size[0] / 16.0}; + double orientation[4] = {1, 1, 2, 3}; + double dx = userInputs.domain_size[0] / ((double) userInputs.subdivisions[0]) / + std::pow(2.0, userInputs.refine_factor); + double dist; + scalar_IC = 0; + + if (index == 0) + { + scalar_IC = 0.04; + } + + for (unsigned int i = 0; i < 4; i++) + { + dist = 0.0; + for (unsigned int dir = 0; dir < dim; dir++) + { + dist += (p[dir] - center[i][dir] * userInputs.domain_size[dir]) * + (p[dir] - center[i][dir] * userInputs.domain_size[dir]); + } + dist = std::sqrt(dist); + + if (index == orientation[i]) + { + scalar_IC += 0.5 * (1.0 - std::tanh((dist - rad[i]) / (dx))); + } + } + + if (index == 4) + { + for (unsigned int d = 0; d < dim; d++) + { + vector_IC(d) = 0.0; + } + } + + // -------------------------------------------------------------------------- +} + +// =========================================================================== +// FUNCTION FOR NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS +// =========================================================================== + +template +void +customPDE::setNonUniformDirichletBCs( + [[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) +{ + // -------------------------------------------------------------------------- + // ENTER THE NON-UNIFORM DIRICHLET BOUNDARY CONDITIONS HERE + // -------------------------------------------------------------------------- + // Enter the function describing conditions for the fields at point "p". + // Use "if" statements to set the boundary condition for each variable + // according to its variable index. This function can be left blank if there + // are no non-uniform Dirichlet boundary conditions. For BCs that change in + // time, you can access the current time through the variable "time". The + // boundary index can be accessed via the variable "direction", which starts + // at zero and uses the same order as the BC specification in parameters.in + // (i.e. left = 0, right = 1, bottom = 2, top = 3, front = 4, back = 5). + + // ------------------------------------------------------------------------- +} diff --git a/tests/automatic_tests/precipitateEvolution/customPDE.h b/tests/automatic_tests/precipitateEvolution/customPDE.h new file mode 100644 index 000000000..d09875ce8 --- /dev/null +++ b/tests/automatic_tests/precipitateEvolution/customPDE.h @@ -0,0 +1,121 @@ +#include "../../../include/matrixFreePDE.h" + +using namespace dealii; + +template +class customPDE : public MatrixFreePDE +{ +public: + customPDE(userInputParameters _userInputs) + : MatrixFreePDE(_userInputs) + , userInputs(_userInputs) {}; + // Function to set the initial conditions (in ICs_and_BCs.h) + void + setInitialCondition([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] double &scalar_IC, + [[maybe_unused]] Vector &vector_IC) override; + + // Function to set the non-uniform Dirichlet boundary conditions (in + // ICs_and_BCs.h) + void + setNonUniformDirichletBCs([[maybe_unused]] const Point &p, + [[maybe_unused]] const unsigned int index, + [[maybe_unused]] const unsigned int direction, + [[maybe_unused]] const double time, + [[maybe_unused]] double &scalar_BC, + [[maybe_unused]] Vector &vector_BC) override; + +private: +#include "../../../include/typeDefs.h" + + const userInputParameters userInputs; + + // Function to set the RHS of the governing equations for explicit time + // dependent equations (in equations.h) + void + explicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the RHS of the governing equations for all other equations + // (in equations.h) + void + nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + + // Function to set the LHS of the governing equations (in equations.h) + void + equationLHS( + [[maybe_unused]] variableContainer> + &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; + +// Function to set postprocessing expressions (in postprocess.h) +#ifdef POSTPROCESS_FILE_EXISTS + void + postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const override; +#endif + +// Function to set the nucleation probability (in nucleation.h) +#ifdef NUCLEATION_FILE_EXISTS + double + getNucleationProbability([[maybe_unused]] variableValueContainer variable_value, + [[maybe_unused]] double dV) const override; +#endif + + // ================================================================ + // Methods specific to this subclass + // ================================================================ + + // ================================================================ + // Model constants specific to this subclass + // ================================================================ + + double McV = userInputs.get_model_constant_double("McV"); + double Mn1V = userInputs.get_model_constant_double("Mn1V"); + double Mn2V = userInputs.get_model_constant_double("Mn2V"); + double Mn3V = userInputs.get_model_constant_double("Mn3V"); + Tensor<2, dim> Kn1 = userInputs.get_model_constant_rank_2_tensor("Kn1"); + Tensor<2, dim> Kn2 = userInputs.get_model_constant_rank_2_tensor("Kn2"); + Tensor<2, dim> Kn3 = userInputs.get_model_constant_rank_2_tensor("Kn3"); + bool n_dependent_stiffness = + userInputs.get_model_constant_bool("n_dependent_stiffness"); + Tensor<2, dim> sfts_linear1 = + userInputs.get_model_constant_rank_2_tensor("sfts_linear1"); + Tensor<2, dim> sfts_const1 = userInputs.get_model_constant_rank_2_tensor("sfts_const1"); + Tensor<2, dim> sfts_linear2 = + userInputs.get_model_constant_rank_2_tensor("sfts_linear2"); + Tensor<2, dim> sfts_const2 = userInputs.get_model_constant_rank_2_tensor("sfts_const2"); + Tensor<2, dim> sfts_linear3 = + userInputs.get_model_constant_rank_2_tensor("sfts_linear3"); + Tensor<2, dim> sfts_const3 = userInputs.get_model_constant_rank_2_tensor("sfts_const3"); + double A4 = userInputs.get_model_constant_double("A4"); + double A3 = userInputs.get_model_constant_double("A3"); + double A2 = userInputs.get_model_constant_double("A2"); + double A1 = userInputs.get_model_constant_double("A1"); + double A0 = userInputs.get_model_constant_double("A0"); + double B2 = userInputs.get_model_constant_double("B2"); + double B1 = userInputs.get_model_constant_double("B1"); + double B0 = userInputs.get_model_constant_double("B0"); + + const static unsigned int CIJ_tensor_size = 2 * dim - 1 + dim / 3; + Tensor<2, CIJ_tensor_size> CIJ_Mg = + userInputs.get_model_constant_elasticity_tensor("CIJ_Mg"); + Tensor<2, CIJ_tensor_size> CIJ_Beta = + userInputs.get_model_constant_elasticity_tensor("CIJ_Beta"); + + // ================================================================ +}; diff --git a/tests/automatic_tests/precipitateEvolution/equations.cc b/tests/automatic_tests/precipitateEvolution/equations.cc new file mode 100644 index 000000000..2277cdf5b --- /dev/null +++ b/tests/automatic_tests/precipitateEvolution/equations.cc @@ -0,0 +1,549 @@ +// ================================================================================= +// Set the attributes of the primary field variables +// ================================================================================= +// This function sets attributes for each variable/equation in the app. The +// attributes are set via standardized function calls. The first parameter for +// each function call is the variable index (starting at zero). The first set of +// variable/equation attributes are the variable name (any string), the variable +// type (SCALAR/VECTOR), and the equation type (EXPLICIT_TIME_DEPENDENT/ +// TIME_INDEPENDENT/AUXILIARY). The next set of attributes describe the +// dependencies for the governing equation on the values and derivatives of the +// other variables for the value term and gradient term of the RHS and the LHS. +// The final pair of attributes determine whether a variable represents a field +// that can nucleate and whether the value of the field is needed for nucleation +// rate calculations. + +void +variableAttributeLoader::loadVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "c"); + set_variable_type(0, SCALAR); + set_variable_equation_type(0, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(0, "c"); + set_dependencies_gradient_term_RHS( + 0, + "c, grad(c), n1, grad(n1), n2, grad(n2), n3, grad(n3), grad(u), hess(u)"); + + // Variable 1 + set_variable_name(1, "n1"); + set_variable_type(1, SCALAR); + set_variable_equation_type(1, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(1, "c, n1, n2, n3, grad(u)"); + set_dependencies_gradient_term_RHS(1, "grad(n1)"); + + // Variable 2 + set_variable_name(2, "n2"); + set_variable_type(2, SCALAR); + set_variable_equation_type(2, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(2, "c, n1, n2, n3, grad(u)"); + set_dependencies_gradient_term_RHS(2, "grad(n2)"); + + // Variable 3 + set_variable_name(3, "n3"); + set_variable_type(3, SCALAR); + set_variable_equation_type(3, EXPLICIT_TIME_DEPENDENT); + + set_dependencies_value_term_RHS(3, "c, n1, n2, n3, grad(u)"); + set_dependencies_gradient_term_RHS(3, "grad(n3)"); + + // Variable 2 + set_variable_name(4, "u"); + set_variable_type(4, VECTOR); + set_variable_equation_type(4, TIME_INDEPENDENT); + + set_dependencies_value_term_RHS(4, ""); + set_dependencies_gradient_term_RHS(4, "c, n1, n2, n3, grad(u)"); + set_dependencies_value_term_LHS(4, ""); + set_dependencies_gradient_term_LHS(4, "n1, n2, n3, grad(change(u))"); +} + +// ============================================================================================= +// explicitEquationRHS (needed only if one or more equation is explict time +// dependent) +// ============================================================================================= +// This function calculates the right-hand-side of the explicit time-dependent +// equations for each variable. It takes "variable_list" as an input, which is a +// list of the value and derivatives of each of the variables at a specific +// quadrature point. The (x,y,z) location of that quadrature point is given by +// "q_point_loc". The function outputs two terms to variable_list -- one +// proportional to the test function and one proportional to the gradient of the +// test function. The index for each variable in this list corresponds to the +// index given at the top of this file. + +template +void +customPDE::explicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // The concentration and its derivatives + scalarvalueType c = variable_list.get_scalar_value(0); + scalargradType cx = variable_list.get_scalar_gradient(0); + + // The first order parameter and its derivatives + scalarvalueType n1 = variable_list.get_scalar_value(1); + scalargradType n1x = variable_list.get_scalar_gradient(1); + + // The second order parameter and its derivatives + scalarvalueType n2 = variable_list.get_scalar_value(2); + scalargradType n2x = variable_list.get_scalar_gradient(2); + + // The third order parameter and its derivatives + scalarvalueType n3 = variable_list.get_scalar_value(3); + scalargradType n3x = variable_list.get_scalar_gradient(3); + + // The derivative of the displacement vector + vectorgradType ux = variable_list.get_vector_gradient(4); + + // --- Setting the expressions for the terms in the governing equations --- + + vectorhessType uxx; + + bool c_dependent_misfit = false; + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + if (std::abs(sfts_linear1[i][j]) > 1.0e-12) + { + c_dependent_misfit = true; + } + } + } + + if (c_dependent_misfit == true) + { + uxx = variable_list.get_vector_hessian(4); + } + + // Free energy expressions and interpolation functions + scalarvalueType faV = (A0 + A1 * c + A2 * c * c + A3 * c * c * c + A4 * c * c * c * c); + scalarvalueType facV = (A1 + 2.0 * A2 * c + 3.0 * A3 * c * c + 4.0 * A4 * c * c * c); + scalarvalueType faccV = (2.0 * A2 + 6.0 * A3 * c + 12.0 * A4 * c * c); + scalarvalueType fbV = (B2 * c * c + B1 * c + B0); + scalarvalueType fbcV = (2.0 * B2 * c + B1); + scalarvalueType fbccV = constV(2.0 * B2); + scalarvalueType h1V = + (10.0 * n1 * n1 * n1 - 15.0 * n1 * n1 * n1 * n1 + 6.0 * n1 * n1 * n1 * n1 * n1); + scalarvalueType h2V = + (10.0 * n2 * n2 * n2 - 15.0 * n2 * n2 * n2 * n2 + 6.0 * n2 * n2 * n2 * n2 * n2); + scalarvalueType h3V = + (10.0 * n3 * n3 * n3 - 15.0 * n3 * n3 * n3 * n3 + 6.0 * n3 * n3 * n3 * n3 * n3); + scalarvalueType hn1V = + (30.0 * n1 * n1 - 60.0 * n1 * n1 * n1 + 30.0 * n1 * n1 * n1 * n1); + scalarvalueType hn2V = + (30.0 * n2 * n2 - 60.0 * n2 * n2 * n2 + 30.0 * n2 * n2 * n2 * n2); + scalarvalueType hn3V = + (30.0 * n3 * n3 - 60.0 * n3 * n3 * n3 + 30.0 * n3 * n3 * n3 * n3); + + // Calculate the stress-free transformation strain and its derivatives at the + // quadrature point + Tensor<2, dim, VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, sfts2c, sfts2cc, + sfts3, sfts3c, sfts3cc; + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + // Polynomial fits for the stress-free transformation strains, of the + // form: sfts = a_p * c + b_p + sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); + sfts1c[i][j] = constV(sfts_linear1[i][j]); + sfts1cc[i][j] = constV(0.0); + + // Polynomial fits for the stress-free transformation strains, of the + // form: sfts = a_p * c + b_p + sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); + sfts2c[i][j] = constV(sfts_linear1[i][j]); + sfts2cc[i][j] = constV(0.0); + + // Polynomial fits for the stress-free transformation strains, of the + // form: sfts = a_p * c + b_p + sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); + sfts3c[i][j] = constV(sfts_linear3[i][j]); + sfts3cc[i][j] = constV(0.0); + } + } + + // compute E2=(E-E0) + VectorizedArray E2[dim][dim], S[dim][dim]; + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - + (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); + } + } + + // compute stress + // S=C*(E-E0) + // Compute stress tensor (which is equal to the residual, Rux) + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + + if (n_dependent_stiffness == true) + { + VectorizedArray sum_hV; + sum_hV = h1V + h2V + h3V; + for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) + { + for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) + { + CIJ_combined[i][j] = + CIJ_Mg[i][j] * (constV(1.0) - sum_hV) + CIJ_Beta[i][j] * sum_hV; + } + } + computeStress(CIJ_combined, E2, S); + } + else + { + computeStress(CIJ_Mg, E2, S); + } + + // Compute one of the stress terms in the order parameter chemical potential, + // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) + VectorizedArray nDependentMisfitAC1 = constV(0.0); + VectorizedArray nDependentMisfitAC2 = constV(0.0); + VectorizedArray nDependentMisfitAC3 = constV(0.0); + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + nDependentMisfitAC1 += S[i][j] * (sfts1[i][j]); + nDependentMisfitAC2 += S[i][j] * (sfts2[i][j]); + nDependentMisfitAC3 += S[i][j] * (sfts3[i][j]); + } + } + + nDependentMisfitAC1 *= -hn1V; + nDependentMisfitAC2 *= -hn2V; + nDependentMisfitAC3 *= -hn3V; + + // Compute the other stress term in the order parameter chemical potential, + // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) + VectorizedArray heterMechAC1 = constV(0.0); + VectorizedArray heterMechAC2 = constV(0.0); + VectorizedArray heterMechAC3 = constV(0.0); + VectorizedArray S2[dim][dim]; + + if (n_dependent_stiffness == true) + { + // computeStress(CIJ_diff, E2, S2); + computeStress(CIJ_Beta - CIJ_Mg, E2, S2); + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + heterMechAC1 += S2[i][j] * E2[i][j]; + } + } + // Aside from HnpV, heterMechAC1, heterMechAC2, and heterMechAC3 are equal + heterMechAC2 = 0.5 * hn2V * heterMechAC1; + heterMechAC3 = 0.5 * hn3V * heterMechAC1; + + heterMechAC1 = 0.5 * hn1V * heterMechAC1; + } + + // compute the stress term in the gradient of the concentration chemical + // potential, grad_mu_el = [C*(E-E0)*E0c]x, must be a vector with length dim + scalargradType grad_mu_el; + + if (c_dependent_misfit == true) + { + VectorizedArray E3[dim][dim], S3[dim][dim]; + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + E3[i][j] = -(sfts1c[i][j] * h1V + sfts2c[i][j] * h2V + sfts3c[i][j] * h3V); + } + } + + if (n_dependent_stiffness == true) + { + computeStress(CIJ_combined, E3, S3); + } + else + { + computeStress(CIJ_Mg, E3, S3); + } + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + for (unsigned int k = 0; k < dim; k++) + { + grad_mu_el[k] += + S3[i][j] * + (constV(0.5) * (uxx[i][j][k] + uxx[j][i][k]) + E3[i][j] * cx[k] - + (sfts1[i][j] * hn1V * n1x[k] + sfts2[i][j] * hn2V * n2x[k] + + sfts3[i][j] * hn3V * n3x[k])); + + grad_mu_el[k] += + -S[i][j] * + (sfts1c[i][j] * hn1V * n1x[k] + sfts2c[i][j] * hn2V * n2x[k] + + sfts3c[i][j] * hn3V * n3x[k] + + (sfts1cc[i][j] * h1V + sfts2cc[i][j] * h2V + sfts3cc[i][j] * h3V) * + cx[k]); + + if (n_dependent_stiffness == true) + { + grad_mu_el[k] += S2[i][j] * E3[i][j] * + (hn1V * n1x[k] + hn2V * n2x[k] + hn3V * n3x[k]); + } + } + } + } + } + + // compute K*nx + scalargradType Knx1, Knx2, Knx3; + for (unsigned int a = 0; a < dim; a++) + { + Knx1[a] = 0.0; + Knx2[a] = 0.0; + Knx3[a] = 0.0; + for (unsigned int b = 0; b < dim; b++) + { + Knx1[a] += constV(Kn1[a][b]) * n1x[b]; + Knx2[a] += constV(Kn2[a][b]) * n2x[b]; + Knx3[a] += constV(Kn3[a][b]) * n3x[b]; + } + } + + // The terms in the govering equations + scalarvalueType eq_c = (c); + scalargradType eqx_c_temp = + (cx * ((1.0 - h1V - h2V - h3V) * faccV + (h1V + h2V + h3V) * fbccV) + + n1x * ((fbcV - facV) * hn1V) + n2x * ((fbcV - facV) * hn2V) + + n3x * ((fbcV - facV) * hn3V) + grad_mu_el); + scalargradType eqx_c = (constV(-userInputs.dtValue * McV) * eqx_c_temp); + + scalarvalueType eq_n1 = + (n1 - constV(userInputs.dtValue * Mn1V) * + ((fbV - faV) * hn1V + nDependentMisfitAC1 + heterMechAC1)); + scalarvalueType eq_n2 = + (n2 - constV(userInputs.dtValue * Mn2V) * + ((fbV - faV) * hn2V + nDependentMisfitAC2 + heterMechAC2)); + scalarvalueType eq_n3 = + (n3 - constV(userInputs.dtValue * Mn3V) * + ((fbV - faV) * hn3V + nDependentMisfitAC3 + heterMechAC3)); + scalargradType eqx_n1 = (constV(-userInputs.dtValue * Mn1V) * Knx1); + scalargradType eqx_n2 = (constV(-userInputs.dtValue * Mn2V) * Knx2); + scalargradType eqx_n3 = (constV(-userInputs.dtValue * Mn3V) * Knx3); + + // --- Submitting the terms for the governing equations --- + + variable_list.set_scalar_value_term_RHS(0, eq_c); + variable_list.set_scalar_gradient_term_RHS(0, eqx_c); + + variable_list.set_scalar_value_term_RHS(1, eq_n1); + variable_list.set_scalar_gradient_term_RHS(1, eqx_n1); + + variable_list.set_scalar_value_term_RHS(2, eq_n2); + variable_list.set_scalar_gradient_term_RHS(2, eqx_n2); + + variable_list.set_scalar_value_term_RHS(3, eq_n3); + variable_list.set_scalar_gradient_term_RHS(3, eqx_n3); +} + +// ============================================================================================= +// nonExplicitEquationRHS (needed only if one or more equation is time +// independent or auxiliary) +// ============================================================================================= +// This function calculates the right-hand-side of all of the equations that are +// not explicit time-dependent equations. It takes "variable_list" as an input, +// which is a list of the value and derivatives of each of the variables at a +// specific quadrature point. The (x,y,z) location of that quadrature point is +// given by "q_point_loc". The function outputs two terms to variable_list -- +// one proportional to the test function and one proportional to the gradient of +// the test function. The index for each variable in this list corresponds to +// the index given at the top of this file. + +template +void +customPDE::nonExplicitEquationRHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // The concentration and its derivatives + scalarvalueType c = variable_list.get_scalar_value(0); + + // The first order parameter and its derivatives + scalarvalueType n1 = variable_list.get_scalar_value(1); + + // The second order parameter and its derivatives + scalarvalueType n2 = variable_list.get_scalar_value(2); + + // The third order parameter and its derivatives + scalarvalueType n3 = variable_list.get_scalar_value(3); + + // The derivative of the displacement vector + vectorgradType ux = variable_list.get_vector_gradient(4); + + // --- Setting the expressions for the terms in the governing equations --- + + // Interpolation functions + scalarvalueType h1V = + (10.0 * n1 * n1 * n1 - 15.0 * n1 * n1 * n1 * n1 + 6.0 * n1 * n1 * n1 * n1 * n1); + scalarvalueType h2V = + (10.0 * n2 * n2 * n2 - 15.0 * n2 * n2 * n2 * n2 + 6.0 * n2 * n2 * n2 * n2 * n2); + scalarvalueType h3V = + (10.0 * n3 * n3 * n3 - 15.0 * n3 * n3 * n3 * n3 + 6.0 * n3 * n3 * n3 * n3 * n3); + + // Calculate the stress-free transformation strain and its derivatives at the + // quadrature point + Tensor<2, dim, VectorizedArray> sfts1, sfts2, sfts3; + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + // Polynomial fits for the stress-free transformation strains, of the + // form: sfts = a_p * c + b_p + sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); + // Polynomial fits for the stress-free transformation strains, of the + // form: sfts = a_p * c + b_p + sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); + // Polynomial fits for the stress-free transformation strains, of the + // form: sfts = a_p * c + b_p + sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); + } + } + + // compute E2=(E-E0) + VectorizedArray E2[dim][dim], S[dim][dim]; + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - + (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); + } + } + + // compute stress + // S=C*(E-E0) + // Compute stress tensor (which is equal to the residual, Rux) + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + + if (n_dependent_stiffness == true) + { + VectorizedArray sum_hV; + sum_hV = h1V + h2V + h3V; + for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) + { + for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) + { + CIJ_combined[i][j] = + CIJ_Mg[i][j] * (constV(1.0) - sum_hV) + CIJ_Beta[i][j] * sum_hV; + } + } + computeStress(CIJ_combined, E2, S); + } + else + { + computeStress(CIJ_Mg, E2, S); + } + + vectorgradType eqx_u; + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + eqx_u[i][j] = -S[i][j]; + } + } + + // --- Submitting the terms for the governing equations --- + + variable_list.set_vector_gradient_term_RHS(4, eqx_u); +} + +// ============================================================================================= +// equationLHS (needed only if at least one equation is time independent) +// ============================================================================================= +// This function calculates the left-hand-side of time-independent equations. It +// takes "variable_list" as an input, which is a list of the value and +// derivatives of each of the variables at a specific quadrature point. The +// (x,y,z) location of that quadrature point is given by "q_point_loc". The +// function outputs two terms to variable_list -- one proportional to the test +// function and one proportional to the gradient of the test function -- for the +// left-hand-side of the equation. The index for each variable in this list +// corresponds to the index given at the top of this file. If there are multiple +// elliptic equations, conditional statements should be sed to ensure that the +// correct residual is being submitted. The index of the field being solved can +// be accessed by "this->currentFieldIndex". + +template +void +customPDE::equationLHS( + [[maybe_unused]] variableContainer> &variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // n1 + scalarvalueType n1 = variable_list.get_scalar_value(1); + + // n2 + scalarvalueType n2 = variable_list.get_scalar_value(2); + + // n3 + scalarvalueType n3 = variable_list.get_scalar_value(3); + + // u + vectorgradType Dux = variable_list.get_change_in_vector_gradient(4); + + // --- Setting the expressions for the terms in the governing equations --- + + vectorgradType eqx_Du; + + // Interpolation functions + + scalarvalueType h1V = + (10.0 * n1 * n1 * n1 - 15.0 * n1 * n1 * n1 * n1 + 6.0 * n1 * n1 * n1 * n1 * n1); + scalarvalueType h2V = + (10.0 * n2 * n2 * n2 - 15.0 * n2 * n2 * n2 * n2 + 6.0 * n2 * n2 * n2 * n2 * n2); + scalarvalueType h3V = + (10.0 * n3 * n3 * n3 - 15.0 * n3 * n3 * n3 * n3 + 6.0 * n3 * n3 * n3 * n3 * n3); + + // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the + // dealii "symmetrize" function + Tensor<2, dim, VectorizedArray> E; + E = symmetrize(Dux); + + // Compute stress tensor (which is equal to the residual, Rux) + if (n_dependent_stiffness == true) + { + Tensor<2, CIJ_tensor_size, VectorizedArray> CIJ_combined; + CIJ_combined = + CIJ_Mg * (constV(1.0) - h1V - h2V - h3V) + CIJ_Beta * (h1V + h2V + h3V); + + computeStress(CIJ_combined, E, eqx_Du); + } + else + { + computeStress(CIJ_Mg, E, eqx_Du); + } + + // --- Submitting the terms for the governing equations --- + + variable_list.set_vector_gradient_term_LHS(4, eqx_Du); +} diff --git a/tests/automatic_tests/test_precipitateEvolution/integratedFields.txt b/tests/automatic_tests/precipitateEvolution/gold_integratedFields.txt similarity index 100% rename from tests/automatic_tests/test_precipitateEvolution/integratedFields.txt rename to tests/automatic_tests/precipitateEvolution/gold_integratedFields.txt diff --git a/tests/automatic_tests/precipitateEvolution/main.cc b/tests/automatic_tests/precipitateEvolution/main.cc new file mode 100644 index 000000000..3113c62c2 --- /dev/null +++ b/tests/automatic_tests/precipitateEvolution/main.cc @@ -0,0 +1,165 @@ +// Header files +#include "customPDE.h" + +#include "ICs_and_BCs.cc" +#include "equations.cc" + +#include "../../../include/ParseCommandLineOpts.h" +#include "../../../include/inputFileReader.h" +#include "../../../src/variableAttributeLoader/variableAttributeLoader.cc" + +// Header file for postprocessing that may or may not exist +#ifdef POSTPROCESS_FILE_EXISTS +# include "postprocess.cc" +#else +void +variableAttributeLoader::loadPostProcessorVariableAttributes() +{} +#endif + +// Header files for nucleation that may or may not exist +#ifdef NUCLEATION_FILE_EXISTS +# include "nucleation.cc" + +# include +# include +#endif + +// main +int +main(int argc, char **argv) +{ + dealii::Utilities::MPI::MPI_InitFinalize + mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int); + + // Parse the command line options (if there are any) to get the name of the + // input file + std::string parameters_filename; + try + { + ParseCommandLineOpts cli_options(argc, argv); + parameters_filename = cli_options.getParametersFilename(); + } + catch (const char *msg) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" << std::endl; + std::cerr << "PRISMS-PF: Exception on processing: " << std::endl + << msg << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" << std::endl; + return 1; + } + + // Run the main part of the code + try + { + dealii::deallog.depth_console(0); + + // Before fully parsing the parameter file, we need to know how many field + // variables there are and whether they are scalars or vectors, how many + // postprocessing variables there are, how many sets of elastic constants + // there are, and how many user-defined constants there are. + + variableAttributeLoader variable_attributes; + inputFileReader input_file_reader(parameters_filename, variable_attributes); + + // Continue based on the number of dimensions and degree of the elements + // specified in the input file + switch (input_file_reader.number_of_dimensions) + { + case 2: + { + userInputParameters<2> userInputs(input_file_reader, + input_file_reader.parameter_handler, + variable_attributes); + switch (userInputs.degree) + { + case (1): + { + customPDE<2, 1> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (2): + { + customPDE<2, 2> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (3): + { + customPDE<2, 3> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + } + break; + } + case 3: + { + userInputParameters<3> userInputs(input_file_reader, + input_file_reader.parameter_handler, + variable_attributes); + switch (userInputs.degree) + { + case (1): + { + customPDE<3, 1> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (2): + { + customPDE<3, 2> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + case (3): + { + customPDE<3, 3> problem(userInputs); + problem.buildFields(); + problem.init(); + problem.solve(); + break; + } + } + } + break; + } + } + catch (std::exception &exc) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" << std::endl; + std::cerr << "PRISMS-PF: Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" << std::endl; + return 1; + } + catch (...) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" << std::endl; + return 1; + } + + return 0; +} diff --git a/tests/automatic_tests/precipitateEvolution/parameters.prm b/tests/automatic_tests/precipitateEvolution/parameters.prm new file mode 100644 index 000000000..fd83ec417 --- /dev/null +++ b/tests/automatic_tests/precipitateEvolution/parameters.prm @@ -0,0 +1,200 @@ +# ================================================================================= +# Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) +# ================================================================================= +set Number of dimensions = 2 + +# ================================================================================= +# Set the length of the domain in all three dimensions +# ================================================================================= +# Each axes spans from zero to the specified length +set Domain size X = 40.0 +set Domain size Y = 40.0 +set Domain size Z = 40.0 + +# ================================================================================= +# Set the element parameters +# ================================================================================= +# The number of elements in each direction is 2^(refineFactor) * subdivisions +# For optimal performance, use refineFactor primarily to determine the element size +set Subdivisions X = 3 +set Subdivisions Y = 3 +set Subdivisions Z = 3 + +set Refine factor = 5 + +# Set the polynomial degree of the element (allowed values: 1, 2, or 3) +set Element degree = 2 + +# ================================================================================= +# Set the adaptive mesh refinement parameters +# ================================================================================= +# Set the flag determining if adaptive meshing is activated +set Mesh adaptivity = true + +# Set the maximum and minimum level of refinement +# When adaptive meshing is enabled, the refine factor set in the block above is +# only used to generate the first pass of the mesh as the initial conditions are +# applied. It should be set somewhere between the max and min levels below. +set Max refinement level = 5 +set Min refinement level = 1 + +# Set the number of time steps between remeshing operations +set Steps between remeshing operations = 1000 + +# Set the criteria for adapting the mesh +subsection Refinement criterion: n1 + # Select whether the mesh is refined based on the variable value (VALUE), + # its gradient (GRADIENT), or both (VALUE_AND_GRADIENT) + set Criterion type = VALUE + # Set the lower and upper bounds for the value-based refinement window + set Value lower bound = 0.01 + set Value upper bound = 0.99 +end + +subsection Refinement criterion: n2 + # Select whether the mesh is refined based on the variable value (VALUE), + # its gradient (GRADIENT), or both (VALUE_AND_GRADIENT) + set Criterion type = VALUE + # Set the lower and upper bounds for the value-based refinement window + set Value lower bound = 0.01 + set Value upper bound = 0.99 +end + +subsection Refinement criterion: n3 + # Select whether the mesh is refined based on the variable value (VALUE), + # its gradient (GRADIENT), or both (VALUE_AND_GRADIENT) + set Criterion type = VALUE + # Set the lower and upper bounds for the value-based refinement window + set Value lower bound = 0.01 + set Value upper bound = 0.99 +end + +# ================================================================================= +# Set the time step parameters +# ================================================================================= +# The size of the time step +set Time step = 6.0e-4 + +# The simulation ends when either the number of time steps is reached or the +# simulation time is reached. +set Number of time steps = 20000 + +# ================================================================================= +# Set the linear solver parameters +# ================================================================================= + +subsection Linear solver parameters: u + # Whether the tolerance value is compared to the residual (ABSOLUTE_RESIDUAL) + # or the change in the residual (RELATIVE_RESIDUAL_CHANGE) + set Tolerance type = ABSOLUTE_RESIDUAL + + # The tolerance for convergence (L2 norm) + set Tolerance value = 5e-3 + + # The maximum number of linear solver iterations per solve + set Maximum linear solver iterations = 1000 +end + +# ================================================================================= +# Set the output parameters +# ================================================================================= +# Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", "N_PER_DECADE", +# or "LIST") +set Output condition = EQUAL_SPACING + +# Number of times the program outputs the fields (total number for "EQUAL_SPACING" +# and "LOG_SPACING", number per decade for "N_PER_DECADE", ignored for "LIST") +set Number of outputs = 10 + +# The number of time steps between updates being printed to the screen +set Skip print steps = 1 #1000 + +# ================================================================================= +# Set the checkpoint/restart parameters +# ================================================================================= +# Whether to start this simulation from the checkpoint of a previous simulation +set Load from a checkpoint = false + +# Type of spacing between checkpoints ("EQUAL_SPACING", "LOG_SPACING", "N_PER_DECADE", +# or "LIST") +set Checkpoint condition = EQUAL_SPACING + +# Number of times the creates checkpoints (total number for "EQUAL_SPACING" +# and "LOG_SPACING", number per decade for "N_PER_DECADE", ignored for "LIST") +set Number of checkpoints = 2 + +# ================================================================================= +# Set the boundary conditions +# ================================================================================= +# Set the boundary condition for each variable, where each variable is given by +# its name, as defined in equations.h. The four boundary condition +# types are NATURAL, DIRICHLET, NON_UNIFORM_DIRICHLET and PERIODIC. If all +# of the boundaries have the same boundary condition, only one boundary condition +# type needs to be given. If multiple boundary condition types are needed, give a +# comma-separated list of the types. The order is the miniumum of x, maximum of x, +# minimum of y, maximum of y, minimum of z, maximum of z (i.e left, right, bottom, +# top in 2D and left, right, bottom, top, front, back in 3D). The value of a +# Dirichlet BC is specfied in the following way -- DIRCHILET: val -- where 'val' is +# the desired value. If the boundary condition is NON_UNIFORM_DIRICHLET, the +# boundary condition should be specified in the appropriate function in 'ICs_and_BCs.h'. +# Example 1: All periodic BCs for variable 'c' +# set Boundary condition for variable c = PERIODIC +# Example 2: Zero-derivative BCs on the left and right, Dirichlet BCs with value +# 1.5 on the top and bottom for variable 'n' in 2D +# set Boundary condition for variable n = NATURAL, NATURAL, DIRICHLET: 1.5, DIRICHLET: 1.5 + +set Boundary condition for variable c = NATURAL +set Boundary condition for variable n1 = NATURAL +set Boundary condition for variable n2 = NATURAL +set Boundary condition for variable n3 = NATURAL +set Boundary condition for variable u, x component = DIRICHLET: 0.0 +set Boundary condition for variable u, y component = DIRICHLET: 0.0 +set Boundary condition for variable u, z component = DIRICHLET: 0.0 + +#set Boundary condition for variable u, x component = DIRICHLET: 0.0, DIRICHLET: 1.0, NATURAL, NATURAL +#set Boundary condition for variable u, y component = NATURAL +#set Boundary condition for variable u, z component = NATURAL + +# ================================================================================= +# Set the model constants +# ================================================================================= +# Type options currently are double, int, bool, and tensor + +# McV, the Cahn-Hilliard mobility +set Model constant McV = 1.0, double + +# The Allen-Cahn mobilities +set Model constant Mn1V = 100.0, double +set Model constant Mn2V = 100.0, double +set Model constant Mn3V = 100.0, double + +# The gradient energy coefficients +set Model constant Kn1 = ((0.03,0,0),(0,0.007,0),(0,0,1.0)), tensor +set Model constant Kn2 = ((0.01275,-0.009959,0),(-0.009959,0.02425,0),(0,0,1.0)), tensor +set Model constant Kn3 = ((0.01275,0.009959,0),(0.009959,0.02425,0),(0,0,1.0)), tensor + +# n_dependent_stiffness +set Model constant n_dependent_stiffness = true, bool + +# The linear and constant coefficients of the stress-free transformation strains +set Model constant sfts_linear1 = ((0,0,0),(0,0,0),(0,0,0)), tensor +set Model constant sfts_const1 = ((0.0345,0,0),(0,0.0185,0),(0,0,-0.00270)), tensor +set Model constant sfts_linear2 = ((0,0,0),(0,0,0),(0,0,0)), tensor +set Model constant sfts_const2 = ((0.0225,-0.0069,0),(-0.0069,0.0305,0),(0,0,-0.00270)), tensor +set Model constant sfts_linear3 = ((0,0,0),(0,0,0),(0,0,0)), tensor +set Model constant sfts_const3 = ((0.0225, 0.0069,0),(0.0069,0.0305,0),(0,0,-0.00270)), tensor + +# A4, A3, A2, A1, and A0 Mg-Y matrix free energy parameters +set Model constant A4 = 1.3687, double +set Model constant A3 = -2.7375, double +set Model constant A2 = 5.1622, double +set Model constant A1 = -4.776, double +set Model constant A0 = -1.6704, double + +# B2, B1, and B0 Mg-Y matrix free energy parameters +set Model constant B2 = 5.0, double +set Model constant B1 = -5.9746, double +set Model constant B0 = -1.5924, double + +set Model constant CIJ_Mg = (40.0,0.3), isotropic elastic constants +set Model constant CIJ_Beta = (50.0,0.3), isotropic elastic constants diff --git a/tests/automatic_tests/precipitateEvolution/postprocess.cc b/tests/automatic_tests/precipitateEvolution/postprocess.cc new file mode 100644 index 000000000..7c1950d64 --- /dev/null +++ b/tests/automatic_tests/precipitateEvolution/postprocess.cc @@ -0,0 +1,187 @@ +// ============================================================================================= +// loadPostProcessorVariableAttributes: Set the attributes of the postprocessing +// variables +// ============================================================================================= +// This function is analogous to 'loadVariableAttributes' in 'equations.h', but +// for the postprocessing expressions. It sets the attributes for each +// postprocessing expression, including its name, whether it is a vector or +// scalar (only scalars are supported at present), its dependencies on other +// variables and their derivatives, and whether to calculate an integral of the +// postprocessed quantity over the entire domain. Note: this function is not a +// member of customPDE. + +void +variableAttributeLoader::loadPostProcessorVariableAttributes() +{ + // Variable 0 + set_variable_name(0, "f_tot"); + set_variable_type(0, SCALAR); + + set_dependencies_value_term_RHS( + 0, + "c, grad(c), n1, grad(n1), n2, grad(n2), n3, grad(n3), grad(u)"); + set_dependencies_gradient_term_RHS(0, ""); + + set_output_integral(0, true); +} + +// ================================================================================= +// Define the expressions for the post-processed fields +// ================================================================================= + +template +void +customPDE::postProcessedFields( + [[maybe_unused]] const variableContainer> + &variable_list, + [[maybe_unused]] variableContainer> + &pp_variable_list, + [[maybe_unused]] const Point> q_point_loc, + [[maybe_unused]] const VectorizedArray element_volume) const +{ + // --- Getting the values and derivatives of the model variables --- + + // The concentration and its derivatives + scalarvalueType c = variable_list.get_scalar_value(0); + + // The first order parameter and its derivatives + scalarvalueType n1 = variable_list.get_scalar_value(1); + scalargradType n1x = variable_list.get_scalar_gradient(1); + + // The second order parameter and its derivatives + scalarvalueType n2 = variable_list.get_scalar_value(2); + scalargradType n2x = variable_list.get_scalar_gradient(2); + + // The third order parameter and its derivatives + scalarvalueType n3 = variable_list.get_scalar_value(3); + scalargradType n3x = variable_list.get_scalar_gradient(3); + + // The derivative of the displacement vector + vectorgradType ux = variable_list.get_vector_gradient(4); + + // --- Setting the expressions for the terms in the postprocessing expressions + // --- + + scalarvalueType f_tot = constV(0.0); + + // Free energy expressions and interpolation functions + scalarvalueType faV = (A0 + A1 * c + A2 * c * c + A3 * c * c * c + A4 * c * c * c * c); + scalarvalueType fbV = (B2 * c * c + B1 * c + B0); + scalarvalueType h1V = + (10.0 * n1 * n1 * n1 - 15.0 * n1 * n1 * n1 * n1 + 6.0 * n1 * n1 * n1 * n1 * n1); + scalarvalueType h2V = + (10.0 * n2 * n2 * n2 - 15.0 * n2 * n2 * n2 * n2 + 6.0 * n2 * n2 * n2 * n2 * n2); + scalarvalueType h3V = + (10.0 * n3 * n3 * n3 - 15.0 * n3 * n3 * n3 * n3 + 6.0 * n3 * n3 * n3 * n3 * n3); + + scalarvalueType f_chem = + (constV(1.0) - (h1V + h2V + h3V)) * faV + (h1V + h2V + h3V) * fbV; + + scalarvalueType f_grad = constV(0.0); + + for (int i = 0; i < dim; i++) + { + for (int j = 0; j < dim; j++) + { + f_grad += constV(0.5 * Kn1[i][j]) * n1x[i] * n1x[j]; + } + } + + for (int i = 0; i < dim; i++) + { + for (int j = 0; j < dim; j++) + { + f_grad += constV(0.5 * Kn2[i][j]) * n2x[i] * n2x[j]; + } + } + + for (int i = 0; i < dim; i++) + { + for (int j = 0; j < dim; j++) + { + f_grad += constV(0.5 * Kn3[i][j]) * n3x[i] * n3x[j]; + } + } + + // Calculate the stress-free transformation strain and its derivatives at the + // quadrature point + Tensor<2, dim, VectorizedArray> sfts1, sfts1c, sfts1cc, sfts2, sfts2c, sfts2cc, + sfts3, sfts3c, sfts3cc; + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + // Polynomial fits for the stress-free transformation strains, of the + // form: sfts = a_p * c + b_p + sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); + sfts1c[i][j] = constV(sfts_linear1[i][j]); + sfts1cc[i][j] = constV(0.0); + + // Polynomial fits for the stress-free transformation strains, of the + // form: sfts = a_p * c + b_p + sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); + sfts2c[i][j] = constV(sfts_linear1[i][j]); + sfts2cc[i][j] = constV(0.0); + + // Polynomial fits for the stress-free transformation strains, of the + // form: sfts = a_p * c + b_p + sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); + sfts3c[i][j] = constV(sfts_linear3[i][j]); + sfts3cc[i][j] = constV(0.0); + } + } + + // compute E2=(E-E0) + VectorizedArray E2[dim][dim], S[dim][dim]; + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + // E2[i][j]= constV(0.5)*(ux[i][j]+ux[j][i])-( sfts1[i][j]*h1V + + // sfts2[i][j]*h2V + sfts3[i][j]*h3V); + E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - + (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); + } + } + + // compute stress + // S=C*(E-E0) + VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; + + if (n_dependent_stiffness == true) + { + VectorizedArray sum_hV; + sum_hV = h1V + h2V + h3V; + for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) + { + for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) + { + CIJ_combined[i][j] = + CIJ_Mg[i][j] * (constV(1.0) - sum_hV) + CIJ_Beta[i][j] * sum_hV; + } + } + computeStress(CIJ_combined, E2, S); + } + else + { + computeStress(CIJ_Mg, E2, S); + } + + scalarvalueType f_el = constV(0.0); + + for (unsigned int i = 0; i < dim; i++) + { + for (unsigned int j = 0; j < dim; j++) + { + f_el += constV(0.5) * S[i][j] * E2[i][j]; + } + } + + f_tot = f_chem + f_grad + f_el; + + // --- Submitting the terms for the postprocessing expressions --- + + pp_variable_list.set_scalar_value_term_RHS(0, f_tot); +} diff --git a/tests/automatic_tests/run_automatic_tests.py b/tests/automatic_tests/run_automatic_tests.py index 8afd1efc8..95ed528c3 100644 --- a/tests/automatic_tests/run_automatic_tests.py +++ b/tests/automatic_tests/run_automatic_tests.py @@ -1,252 +1,287 @@ import subprocess import shutil import glob -import math import os import datetime import time import sys +import argparse +from concurrent.futures import ProcessPoolExecutor, as_completed + + +def remove_file(file): + """Remove a file if it exists + + Args: + file (string): Path to file + """ + if os.path.exists(file): + os.remove(file) -# ---------------------------------------------------------------------------------------- -# Function that compiles and runs the unit tests. -# ---------------------------------------------------------------------------------------- -def run_unit_tests(): - # Open file where output is redirected to - if os.path.exists("output.txt") == True: - os.remove("output.txt") - f = open("output.txt",'w+') - - # Remove old files - if os.path.exists("main") == True: - os.remove("main") - if os.path.exists("CMakeCache.txt") == True: - os.remove("CMakeCache.txt") - if os.path.exists("unit_test_results.txt") == True: - os.remove("unit_test_results.txt") - - # Compile and run - subprocess.call(["cmake", "."],stdout=f,stderr=f) - subprocess.call(["make", "release"],stdout=f) - subprocess.call(["make"],stdout=f) - subprocess.call(["mpirun", "-n", "2", "./main"],stdout=f) - f.close() - - result_file = open("unit_test_results.txt","r") - test_results = result_file.read().splitlines() - result_file.close() - - return test_results - - -# ---------------------------------------------------------------------------------------- -# Function that compiles the PRISMS-PF code and runs the executable. -# ---------------------------------------------------------------------------------------- -def run_simulation(run_name,dir_path): - # Delete any pre-existing executables or results - if os.path.exists(run_name) == True: - shutil.rmtree(run_name) - - # Open file where output is redirected to - if os.path.exists("output.txt") == True: - os.remove("output.txt") - f = open("output.txt",'w+') - - # Remove old files - if os.path.exists("main") == True: - os.remove("main") - if os.path.exists("CMakeCache.txt") == True: - os.remove("CMakeCache.txt") - - subprocess.call(["rm", "*vtu"],stdout=f,stderr=f) - - # Compile and run - subprocess.call(["cmake", "."]) # print to the screen to prevent a timeout on Travis - subprocess.call(["make", "release"],stdout=f) - print("Compiling complete, running the regression test...") - sys.stdout.flush() - start = time.time() - subprocess.call(["mpirun", "-n", "1", "./main"],stdout=f) - end = time.time() - f.close() - - # Group the files - subprocess.call(["mkdir",run_name]) - for output_files in glob.glob('*vtu'): - shutil.move(output_files,run_name) - if os.path.exists("integratedFields.txt") == True: - shutil.move("integratedFields.txt",run_name) - - test_time = end-start - return test_time - -# ---------------------------------------------------------------------------------------- -# Function that runs a regression test -# ---------------------------------------------------------------------------------------- -def run_regression_test(applicationName,getNewGoldStandard,dir_path): - - if (getNewGoldStandard == False): - testName = "test_"+applicationName - - else: - testName = "gold_"+applicationName - - if os.path.exists(testName) == True: - shutil.rmtree(testName) - - # Move to the application directory - r_test_dir = dir_path - os.chdir("../../applications/"+applicationName) - - # Run the simulation and move the results to the test directory - test_time = run_simulation(testName,dir_path) - - shutil.move(testName,r_test_dir) - - # Compare the result against the gold standard, if it exists - os.chdir(r_test_dir) - - if (getNewGoldStandard == False): - # Read the gold standard free energies - os.chdir("gold_"+applicationName) - gold_standard_file = open("integratedFields.txt","r") - gold_energy = gold_standard_file.readlines() - gold_standard_file.close() - - last_energy_index = len(gold_energy)-1 - split_last_line = gold_energy[-1].split() - for index, entry in enumerate(split_last_line): - if entry == "f_tot": - gold_last_energy = split_last_line[index+1] - - # Read the test free energies - os.chdir("../"+testName) - test_file = open("integratedFields.txt","r") - test_energy = test_file.readlines() - test_file.close() - - last_energy_index = len(test_energy)-1 - split_last_line = test_energy[-1].split() - for index, entry in enumerate(split_last_line): - if entry == "f_tot": - last_energy = split_last_line[index+1] - - rel_diff = (float(gold_last_energy)-float(last_energy))/float(gold_last_energy) - rel_diff = abs(rel_diff) - - if (rel_diff < 1.0e-9): - test_passed = True - else: - test_passed = False - - else: - test_passed = True - - # Print the results to the screen - print("Regression Test: ", applicationName) - - if test_passed: - if getNewGoldStandard == False: - print("Result: Pass") - else: - print("Result: New Gold Standard") - else: - print("Result: Fail") - - print("Time taken:", test_time) - - sys.stdout.flush() - - # Write the results to a file - os.chdir(r_test_dir) - text_file = open("test_results.txt","a") - now = datetime.datetime.now() - text_file.write("Application: " + applicationName +" \n") - if test_passed: - if getNewGoldStandard == False: - text_file.write("Result: Pass \n") - else: - text_file.write("Result: New Gold Standard \n") - else: - text_file.write("Result: Fail \n") - text_file.write("Time: "+str(test_time)+" \n \n") - text_file.close() - - return (test_passed,test_time) - -# ---------------------------------------------------------------------------------------- -# Test Script -# ---------------------------------------------------------------------------------------- - -# Initialize -dir_path = os.path.dirname(os.path.realpath(__file__)) -os.chdir(dir_path) - -text_file = open("test_results.txt","a") -now = datetime.datetime.now() - -# ------------------------------------ -# Start the unit tests -# ------------------------------------ +def write_to_file(file, text): + """Write text to file + + Args: + file (string): Path to file + text (string): Text to write in file + """ + with open(file, "a") as text_file: + text_file.write(text) + + +def grab_cpu_information(): + # Get the CPU information + cpu_info_raw = subprocess.check_output("lscpu", shell=True).decode() + + # Split into lines + cpu_info_lines = cpu_info_raw.splitlines() + + # Create dict to store parsed info + cpu_info = {} + + for line in cpu_info_lines: + if ":" in line: + key, value = line.split(":", 1) + cpu_info[key.strip()] = value.strip() + + # Grab relevant fields + architecture = cpu_info.get("Architecture") + cpu_model = cpu_info.get("Model name") + cpu_cores = cpu_info.get("CPU(s)") + cpu_max_freq = cpu_info.get("CPU max MHz") + cpu_min_freq = cpu_info.get("CPU min MHz") + hypervisor = cpu_info.get("Hypervisor vendor") + + return architecture, cpu_model, cpu_cores, cpu_max_freq, cpu_min_freq, hypervisor + + +def compile_and_run_unit_tests(): + # Remove old files if they exist + remove_file("main") + remove_file("CMakeCache.txt") + remove_file("unit_test_results.txt") + + # Compile and run + subprocess.call( + ["cmake", "."], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL + ) + subprocess.call(["make"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.call( + ["mpirun", "-n", "1", "./main"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + + with open("unit_test_results.txt", "r") as result_file: + return result_file.read().splitlines() + + +def compile_and_run_simulation(application_path): + # Navigate to test application directory + os.chdir(application_path) + + # Remove old files + remove_file("main") + remove_file("CMakeCache.txt") + remove_file("integratedFields.txt") + for solution_file in glob.glob("solution-*.vtu"): + os.remove(solution_file) + + # Compile application + subprocess.call( + ["cmake", "."], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL + ) + subprocess.call( + ["make", "release"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL + ) + + # Print successful compilation to screen + print(f"Compiling complete, running the regression test for {application_path}...") + sys.stdout.flush() + + # Run application with timer + start = time.time() + subprocess.call( + ["mpirun", "-n", "1", "./main"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + end = time.time() + + return end - start + + +def run_regression_test(application, new_gold_standard, test_dir): + # Move to the application directory + application_path = os.path.join(test_dir, application) + + # Run the simulation and move the results to the test directory + test_time = compile_and_run_simulation(application_path) + + # Compare the result against the gold standard, if it exists + if new_gold_standard: + shutil.move("integratedFields.txt", "gold_integratedFields.txt") + test_passed = True + else: + # Read the gold standard free energies + with open("gold_integratedFields.txt", "r") as gold_standard_file: + gold_energy = gold_standard_file.readlines() + + split_last_line = gold_energy[-1].split() + for index, entry in enumerate(split_last_line): + if entry == "f_tot": + gold_last_energy = split_last_line[index + 1] + + # Read the test free energies + with open("integratedFields.txt", "r") as test_file: + test_energy = test_file.readlines() + + split_last_line = test_energy[-1].split() + for index, entry in enumerate(split_last_line): + if entry == "f_tot": + last_energy = split_last_line[index + 1] + + # Compare the relative difference. If under a certain threshold pass + rel_diff = abs( + (float(gold_last_energy) - float(last_energy)) / float(gold_last_energy) + ) + test_passed = rel_diff < 1.0e-9 + + # Determine test result + test_result = ( + "New Gold Standard" + if test_passed and new_gold_standard + else "Pass" + if test_passed + else "Fail" + ) + + # Print the results to the screen + print( + f"Regression Test: {application}\n" + f"Result: {test_result}\n" + f"Time taken: {test_time}\n" + ) + sys.stdout.flush() + + # Write the results to a file + test_result_file = os.path.join(test_dir, "test_results.txt") + write_to_file( + test_result_file, + f"Application: {application}\n" + f"Result: {test_result}\n" + f"Time: {test_time}\n \n", + ) + + return test_passed, test_time + + +def run_regression_tests_in_parallel( + application_list, gold_standard_list, test_dir, n_processes=None +): + regression_test_counter = 0 + regression_tests_passed = 0 + + with ProcessPoolExecutor(max_workers=n_processes) as executor: + futures = [ + executor.submit(run_regression_test, application, gold_standard, test_dir) + for application, gold_standard in zip(application_list, gold_standard_list) + ] + + for future in as_completed(futures): + test_passed, test_time = future.result() + regression_tests_passed += int(test_passed) + regression_test_counter += 1 + + return regression_tests_passed, regression_test_counter + + +# Initialize arg parser +parser = argparse.ArgumentParser( + description="The maximum processes to use to run the regression tests" +) +parser.add_argument("-n", "--ntasks", type=int, default=1, help="Number of processes") +args = parser.parse_args() +n_processes = args.ntasks + +# Grab current directory and the path to the test results file +pwd = os.path.dirname(os.path.realpath(__file__)) +test_result_file = os.path.join(pwd, "test_results.txt") + +# Grab current date +now = datetime.datetime.now() +# Navigate to the unit test directory os.chdir("../unit_tests/") -unit_test_results = run_unit_tests() + +# Run unit tests +unit_test_results = compile_and_run_unit_tests() unit_tests_passed = unit_test_results[0] unit_test_counter = unit_test_results[1] -print() -print("Unit Tests Passed: "+str(unit_tests_passed)+"/"+str(unit_test_counter)+"\n") - -sys.stdout.flush() - -text_file.write("--------------------------------------------------------- \n") -text_file.write("Unit test on " + now.strftime("%Y-%m-%d %H:%M") + "\n") -text_file.write("--------------------------------------------------------- \n") -text_file.write("Unit Tests Passed: "+str(unit_tests_passed)+"/"+str(unit_test_counter)+"\n") - -os.chdir(dir_path) - -# ------------------------------------ -# Start the regression tests -# ------------------------------------ - -regression_test_counter = 0 -regression_tests_passed = 0 - -text_file.write("--------------------------------------------------------- \n") -text_file.write("Regression test on " + now.strftime("%Y-%m-%d %H:%M") + "\n") -text_file.write("--------------------------------------------------------- \n") -text_file.close() - -#applicationList = ["allenCahn","cahnHilliard","cahnHilliard","CHAC_anisotropy","CHAC_anisotropyRegularized","coupledCahnHilliardAllenCahn","mechanics","precipitateEvolution"] -#getNewGoldStandardList = [False, False, False, False, False, False, False, False] - -# Shorter list of applications so that it completes on Travis -applicationList = ["allenCahn","cahnHilliard","CHAC_anisotropyRegularized","coupledCahnHilliardAllenCahn","precipitateEvolution"] +write_to_file( + test_result_file, + "--------------------------------------------------------- \n" + "Unit test on " + now.strftime("%Y-%m-%d %H:%M") + "\n" + "--------------------------------------------------------- \n" + f"Unit Tests Passed: {unit_tests_passed}/{unit_test_counter}\n", +) + +# List of applications +applicationList = [ + "allenCahn", + "cahnHilliard", + "CHAC_anisotropyRegularized", + "coupledCahnHilliardAllenCahn", + "precipitateEvolution", +] getNewGoldStandardList = [False, False, False, False, False] -#applicationList = ["allenCahn"] -#getNewGoldStandardList = [False] - - - -for applicationName in applicationList: - test_result = run_regression_test(applicationName,getNewGoldStandardList[regression_test_counter],dir_path) - - regression_test_counter += 1 - regression_tests_passed += int(test_result[0]) - -print() -print("Regression Tests Passed: "+str(regression_tests_passed)+"/"+str(regression_test_counter)+"\n") - +# Grab cpu information +architecture, cpu_model, cpu_cores, cpu_max_freq, cpu_min_freq, hypervisor = ( + grab_cpu_information() +) + +# Write to test results file +write_to_file( + test_result_file, + "--------------------------------------------------------- \n" + "Regression test on " + now.strftime("%Y-%m-%d %H:%M") + "\n" + f"Architecture: {architecture}\n" + f"Model name: {cpu_model}\n" + f"CPU(s): {cpu_cores}\n" + f"CPU max/min MHz: {cpu_max_freq}, {cpu_min_freq}\n" + f"Hypervisor vendor: {hypervisor}\n" + f"Number of processes: {n_processes}\n" + "--------------------------------------------------------- \n", +) + +# Run tests in parallel +start_parallel = time.time() +regression_tests_passed, regression_test_counter = run_regression_tests_in_parallel( + applicationList, getNewGoldStandardList, pwd, n_processes +) +end_parallel = time.time() +print(f"Total time spend on regressions tests: {end_parallel - start_parallel}") + + +os.chdir(pwd) # Output the overall test results -text_file = open("test_results.txt","a") -text_file.write("Tests Passed: "+str(regression_tests_passed)+"/"+str(regression_test_counter)+"\n") -text_file.write("--------------------------------------------------------- \n") -text_file.close() - -# Set exit code (passed to Travis CI) -if ((regression_tests_passed < regression_test_counter) or (unit_tests_passed < unit_test_counter)): - sys.exit(1) +write_to_file( + test_result_file, + f"Tests Passed: {regression_tests_passed}/{regression_test_counter}\n" + "--------------------------------------------------------- \n", +) + +# Print overall results +print(f"Unit Tests Passed: {unit_tests_passed}/{unit_test_counter}\n") +print(f"Regression Tests Passed: {regression_tests_passed}/{regression_test_counter}\n") + +# Set exit code +if (regression_tests_passed < regression_test_counter) or ( + unit_tests_passed < unit_test_counter +): + sys.exit(1) else: - sys.exit(0) + sys.exit(0) diff --git a/tests/automatic_tests/test_CHAC_anisotropyRegularized/integratedFields.txt b/tests/automatic_tests/test_CHAC_anisotropyRegularized/integratedFields.txt deleted file mode 100644 index 5180d6c1f..000000000 --- a/tests/automatic_tests/test_CHAC_anisotropyRegularized/integratedFields.txt +++ /dev/null @@ -1,11 +0,0 @@ -0 f_tot 13.75327943 -200 f_tot 12.86862888 -400 f_tot 12.61546875 -600 f_tot 12.47241551 -800 f_tot 12.38346486 -1000 f_tot 12.32727188 -1200 f_tot 12.29142341 -1400 f_tot 12.2682066 -1600 f_tot 12.25308594 -1800 f_tot 12.24307128 -2000 f_tot 12.23634909 diff --git a/tests/automatic_tests/test_coupledCahnHilliardAllenCahn/integratedFields.txt b/tests/automatic_tests/test_coupledCahnHilliardAllenCahn/integratedFields.txt deleted file mode 100644 index 8fd69162b..000000000 --- a/tests/automatic_tests/test_coupledCahnHilliardAllenCahn/integratedFields.txt +++ /dev/null @@ -1,11 +0,0 @@ -0 f_tot -17990.96133 -12 f_tot -17993.23453 -24 f_tot -17993.28446 -36 f_tot -17993.34482 -48 f_tot -17993.41925 -60 f_tot -17993.51311 -72 f_tot -17993.63119 -84 f_tot -17993.76989 -96 f_tot -17994.0319 -108 f_tot -17994.95862 -120 f_tot -17995.02466 diff --git a/tests/automatic_tests/test_results.txt b/tests/automatic_tests/test_results.txt index ca24636ed..c744424ac 100644 --- a/tests/automatic_tests/test_results.txt +++ b/tests/automatic_tests/test_results.txt @@ -1658,3 +1658,102 @@ Time: 105.63543462753296 Tests Passed: 4/5 --------------------------------------------------------- +--------------------------------------------------------- +Unit test on 2024-08-26 11:23 +--------------------------------------------------------- +Unit Tests Passed: 22/24 +--------------------------------------------------------- +Regression test on 2024-08-26 11:23 +--------------------------------------------------------- +Application: allenCahn +Result: Pass +Time: 20.680600881576538 + +Application: cahnHilliard +Result: Pass +Time: 213.79854011535645 + +Application: CHAC_anisotropyRegularized +Result: Pass +Time: 92.19172048568726 + +Application: coupledCahnHilliardAllenCahn +Result: Pass +Time: 239.0977635383606 + +Application: precipitateEvolution +Result: New Gold Standard +Time: 248.99486303329468 + +Tests Passed: 5/5 +--------------------------------------------------------- +--------------------------------------------------------- +Unit test on 2024-09-30 20:35 +--------------------------------------------------------- +Unit Tests Passed: 24/24 +--------------------------------------------------------- +Regression test on 2024-09-30 20:35 +Architecture: x86_64 +Model name: AMD Ryzen 9 7900X 12-Core Processor +CPU(s): 24 +CPU max/min MHz: 4701.0000, 0.0000 +Hypervisor vendor: Windows Subsystem for Linux +Number of processes: 5 +--------------------------------------------------------- +Application: allenCahn +Result: Pass +Time: 5.137420654296875 + +Application: CHAC_anisotropyRegularized +Result: Pass +Time: 21.923932313919067 + +Application: cahnHilliard +Result: Pass +Time: 46.90225148200989 + +Application: precipitateEvolution +Result: Pass +Time: 49.90675449371338 + +Application: coupledCahnHilliardAllenCahn +Result: Pass +Time: 61.51672077178955 + +Tests Passed: 5/5 +--------------------------------------------------------- +--------------------------------------------------------- +Unit test on 2024-09-30 20:37 +--------------------------------------------------------- +Unit Tests Passed: 24/24 +--------------------------------------------------------- +Regression test on 2024-09-30 20:37 +Architecture: x86_64 +Model name: AMD Ryzen 9 7900X 12-Core Processor +CPU(s): 24 +CPU max/min MHz: 4701.0000, 0.0000 +Hypervisor vendor: Windows Subsystem for Linux +Number of processes: 1 +--------------------------------------------------------- +Application: allenCahn +Result: Pass +Time: 3.2358179092407227 + +Application: cahnHilliard +Result: Pass +Time: 37.65849280357361 + +Application: CHAC_anisotropyRegularized +Result: Pass +Time: 23.44599485397339 + +Application: coupledCahnHilliardAllenCahn +Result: Pass +Time: 46.90539360046387 + +Application: precipitateEvolution +Result: Pass +Time: 41.89884090423584 + +Tests Passed: 5/5 +--------------------------------------------------------- diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/CMakeLists.txt b/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/ICs_and_BCs.h b/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/ICs_and_BCs.h deleted file mode 100644 index 3875f926a..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/ICs_and_BCs.h +++ /dev/null @@ -1,96 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - scalar_IC = 1.0; - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // ===================================================================== - } -}; - -// Sets the BCs for the problem variables -// "inputBCs" should be called for each component of each variable and should be -// in numerical order Four input arguments set the same BC on the entire -// boundary Two plus two times the number of dimensions inputs sets separate BCs -// on each face of the domain Inputs to "inputBCs": First input: variable number -// Second input: component number -// Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") -// Fourth input: BC value (ignored unless the BC type is "DIRICHLET") -// Odd inputs after the third: BC type -// Even inputs after the third: BC value -// Face numbering: starts at zero with the minimum of the first direction, one -// for the maximum of the first direction -// two for the minimum of the second direction, etc. -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - - inputBCs(0, - 0, - "DIRICHLET", - 0.0, - "ZERO_DERVIVATIVE", - 0.0, - "ZERO_DERVIVATIVE", - 0, - "ZERO_DERVIVATIVE", - 0); - - // ===================================================================== -} diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/main.cc b/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/main.cc deleted file mode 100644 index 82ace544a..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/main.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/parameters.h b/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/parameters.h deleted file mode 100644 index 38f5ad1f2..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/parameters.h +++ /dev/null @@ -1,36 +0,0 @@ -// Parameter list for the Fickian diffusion problem - -// Define problem dimensions -#define problemDIM 2 -#define spanX 10.0 -#define spanY 1.0 -#define spanZ 10.0 - -// Define mesh parameters -#define subdivisionsX 500 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 0 -#define finiteElementDegree 1 - -// define number of fields in the problem -// c -#define numFields 1 - -// define time step parameters -#define timeStep 1.0e-4 -#define timeFinal 100.0 -#define timeIncrements 10000 - -// define results output parameters -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 10 - -#define calcEnergy false diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/residuals.h b/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/residuals.h deleted file mode 100644 index 751cba19d..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticComparison/residuals.h +++ /dev/null @@ -1,74 +0,0 @@ -// Definition of the variables in the model -#define num_var 1 -#define variable_name \ - { \ - "c" \ - } -#define variable_type \ - { \ - "SCALAR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC" \ - } -#define need_val \ - { \ - true \ - } -#define need_grad \ - { \ - true \ - } -#define need_hess \ - { \ - false \ - } -#define need_val_residual \ - { \ - true \ - } -#define need_grad_residual \ - { \ - true \ - } - -// define Fickian diffusion parameters -#define DcV 1.0 - -// define required residuals -#define rcV (c) -#define rcxV (constV(-DcV * timeStep) * cx) - -// --------------------------------------------- - -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // c - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; -} - -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVarList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{} - -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{} diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/CMakeLists.txt b/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/ICs_and_BCs.h b/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/ICs_and_BCs.h deleted file mode 100644 index 2cc7a4ec0..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/ICs_and_BCs.h +++ /dev/null @@ -1,97 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - double desired_time = 1.0; - scalar_IC = std::erf(p[0] / std::sqrt(4.0 * DcV * desired_time)); - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // ===================================================================== - } -}; - -// Sets the BCs for the problem variables -// "inputBCs" should be called for each component of each variable and should be -// in numerical order Four input arguments set the same BC on the entire -// boundary Two plus two times the number of dimensions inputs sets separate BCs -// on each face of the domain Inputs to "inputBCs": First input: variable number -// Second input: component number -// Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") -// Fourth input: BC value (ignored unless the BC type is "DIRICHLET") -// Odd inputs after the third: BC type -// Even inputs after the third: BC value -// Face numbering: starts at zero with the minimum of the first direction, one -// for the maximum of the first direction -// two for the minimum of the second direction, etc. -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - - inputBCs(0, - 0, - "ZERO_DERVIVATIVE", - 0.0, - "ZERO_DERVIVATIVE", - 0.0, - "ZERO_DERVIVATIVE", - 0, - "ZERO_DERVIVATIVE", - 0); - - // ===================================================================== -} diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/main.cc b/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/main.cc deleted file mode 100644 index 82ace544a..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/main.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/parameters.h b/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/parameters.h deleted file mode 100644 index 0806e7762..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/parameters.h +++ /dev/null @@ -1,36 +0,0 @@ -// Parameter list for the Fickian diffusion problem - -// Define problem dimensions -#define problemDIM 2 -#define spanX 10.0 -#define spanY 1.0 -#define spanZ 10.0 - -// Define mesh parameters -#define subdivisionsX 500 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 0 -#define finiteElementDegree 1 - -// define number of fields in the problem -// c -#define numFields 1 - -// define time step parameters -#define timeStep 1.0e-3 -#define timeFinal 10.0 -#define timeIncrements 0 - -// define results output parameters -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 1 - -#define calcEnergy false diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/residuals.h b/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/residuals.h deleted file mode 100644 index 751cba19d..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/residuals.h +++ /dev/null @@ -1,74 +0,0 @@ -// Definition of the variables in the model -#define num_var 1 -#define variable_name \ - { \ - "c" \ - } -#define variable_type \ - { \ - "SCALAR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC" \ - } -#define need_val \ - { \ - true \ - } -#define need_grad \ - { \ - true \ - } -#define need_hess \ - { \ - false \ - } -#define need_val_residual \ - { \ - true \ - } -#define need_grad_residual \ - { \ - true \ - } - -// define Fickian diffusion parameters -#define DcV 1.0 - -// define required residuals -#define rcV (c) -#define rcxV (constV(-DcV * timeStep) * cx) - -// --------------------------------------------- - -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // c - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; -} - -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVarList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{} - -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{} diff --git a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/visitlog.py b/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/visitlog.py deleted file mode 100644 index 2b2be23bf..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusionAnalyticResult/visitlog.py +++ /dev/null @@ -1,5 +0,0 @@ -# Visit 2.7.0 log file -ScriptVersion = "2.7.0" -if ScriptVersion != Version(): - print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version()) -ShowAllWindows() diff --git a/tests/deprecated_tests/analytic_tests/diffusion_difference.txt b/tests/deprecated_tests/analytic_tests/diffusion_difference.txt deleted file mode 100644 index e721bfdbc..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusion_difference.txt +++ /dev/null @@ -1 +0,0 @@ -1.23977661133e-05 \ No newline at end of file diff --git a/tests/deprecated_tests/analytic_tests/diffusion_test_result.txt b/tests/deprecated_tests/analytic_tests/diffusion_test_result.txt deleted file mode 100644 index bad9d23c4..000000000 --- a/tests/deprecated_tests/analytic_tests/diffusion_test_result.txt +++ /dev/null @@ -1,2 +0,0 @@ -Maximum difference between the calculated and analytic result: -1.23977661133e-05 diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/CMakeLists.txt b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/ICs_and_BCs.h b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/ICs_and_BCs.h deleted file mode 100644 index a51fcb10d..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/ICs_and_BCs.h +++ /dev/null @@ -1,130 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - vector_IC(0) = 0.0; - vector_IC(1) = 0.0; - vector_IC(2) = 0.0; - - // ===================================================================== - } -}; - -// Sets the BCs for the problem variables -// "inputBCs" should be called for each component of each variable and should be -// in numerical order Four input arguments set the same BC on the entire -// boundary Two plus two times the number of dimensions inputs sets separate BCs -// on each face of the domain Inputs to "inputBCs": First input: variable number -// Second input: component number -// Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") -// Fourth input: BC value (ignored unless the BC type is "DIRICHLET") -// Odd inputs after the third: BC type -// Even inputs after the third: BC value -// Face numbering: starts at zero with the minimum of the first direction, one -// for the maximum of the first direction -// two for the minimum of the second direction, etc. -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - - inputBCs(0, - 0, - "DIRICHLET", - 0.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "DIRICHLET", - 0.0); - inputBCs(0, - 1, - "ZERO_DERIVATIVE", - 0.0, - "DIRICHLET", - 0.0, - "DIRICHLET", - 0.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "DIRICHLET", - 0.0); - inputBCs(0, - 2, - "ZERO_DERIVATIVE", - 0.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "DIRICHLET", - 0.0, - "DIRICHLET", - 0.0, - "DIRICHLET", - 0.0); - - // ===================================================================== -} diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/main.cc b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/main.cc deleted file mode 100644 index 82ace544a..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/main.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/parameters.h b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/parameters.h deleted file mode 100644 index 4853fb087..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/parameters.h +++ /dev/null @@ -1,33 +0,0 @@ -// Parameter list for the Beta Prime precipitate evolution problem -//(Coupled Allen Cahn, Cahn Hilliard and Mechanics formulation) -// The free energy expressions in this file are from the reference: -// H. Liu et al, "A simulation study of the shape of beta prime precipitates in -// Mg–Y and Mg–Gd alloys", Acta Materialia, Volume 61, Issue 2, January 2013, -// Pages 453-466. http://dx.doi.org/10.1016/j.actamat.2012.09.044 - -// Define problem dimensions -#define problemDIM 3 -#define spanX 100.0 -#define spanY 100.0 -#define spanZ 100.0 - -// Define mesh parameters -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 6 -#define finiteElementDegree 1 - -// define number of fields in the problem -#define numFields 3 - -// Define solver paramters -#define solverType SolverCG -#define absTol false -#define solverTolerance 1.0e-10 -#define maxSolverIterations 1000 - -// Define results output parameters -#define writeOutput true - -#define calcEnergy false diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/residuals.h b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/residuals.h deleted file mode 100644 index 16779b9cc..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticComparison/residuals.h +++ /dev/null @@ -1,241 +0,0 @@ -// Define required residuals -// Definition of the variables in the model -#define num_var 1 -#define variable_name \ - { \ - "u" \ - } -#define variable_type \ - { \ - "VECTOR" \ - } -#define variable_eq_type \ - { \ - "ELLIPTIC" \ - } -#define need_val \ - { \ - false \ - } -#define need_grad \ - { \ - true \ - } -#define need_hess \ - { \ - false \ - } -#define need_val_residual \ - { \ - false \ - } -#define need_grad_residual \ - { \ - true \ - } - -#define need_val_LHS \ - { \ - false \ - } -#define need_grad_LHS \ - { \ - true \ - } -#define need_hess_LHS \ - { \ - false \ - } -#define need_val_residual_LHS \ - { \ - false \ - } -#define need_grad_residual_LHS \ - { \ - true \ - } - -// Define Mechanical properties -// Mechanical symmetry of the material and stiffness parameters -#define MaterialModels \ - { \ - "ISOTROPIC" \ - } -#define MaterialConstants \ - { \ - { \ - 22.5, 0.3 \ - } \ - } - -// --------------------------------------------- - -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // u - vectorgradType ux = modelVariablesList[0].vectorGrad; - vectorgradType Rux; - - dealii::VectorizedArray sfts[dim][dim]; - - dealii::VectorizedArray dist, a; - - a = constV(10.0); - - dist = std::sqrt((q_point_loc[0] - constV(0.0)) * (q_point_loc[0] - constV(0.0)) + - (q_point_loc[1] - constV(0.0)) * (q_point_loc[1] - constV(0.0)) + - (q_point_loc[2] - constV(0.0)) * (q_point_loc[2] - constV(0.0))); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - if (i == j) - { - sfts[i][j] = - 0.01 * (0.5 + 0.5 * (constV(1.0) - std::exp(-20.0 * (dist - a))) / - (constV(1.0) + std::exp(-20.0 * (dist - a)))); - } - else - { - sfts[i][j] = 0.0; - } - } - } - - // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - sfts[i][j]; - } - } - - // compute stress tensor - computeStress(CIJ_list[0], E, S); - - // compute residual - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - Rux[i][j] = -S[i][j]; - } - } - - modelResidualsList[0].vectorGradResidual = Rux; -} - -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVarList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // u - vectorgradType ux = modelVarList[0].vectorGrad; - vectorgradType Rux; - - // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]); - } - } - - // compute stress tensor - computeStress(CIJ_list[0], E, S); - - // compute residual - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - Rux[i][j] = S[i][j]; - } - } - - modelRes.vectorGradResidual = Rux; -} - -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - // u - vectorgradType ux = modelVarList[0].vectorGrad; - - dealii::VectorizedArray sfts[dim][dim]; - - dealii::VectorizedArray dist; - - dist = std::sqrt((q_point_loc[0] - constV(0.0)) * (q_point_loc[0] - constV(0.0)) + - (q_point_loc[1] - constV(0.0)) * (q_point_loc[1] - constV(0.0)) + - (q_point_loc[2] - constV(0.0)) * (q_point_loc[2] - constV(0.0))); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - if (i == j) - { - sfts[i][j] = - 0.01 * - (0.5 + 0.5 * (constV(1.0) - std::exp(-20.0 * (dist - constV(10.0)))) / - (constV(1.0) + std::exp(-20.0 * (dist - constV(10.0))))); - } - else - { - sfts[i][j] = 0.0; - } - } - } - - // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - sfts[i][j]; - } - } - - // compute stress tensor - computeStress(CIJ_list[0], E, S); - - scalarvalueType f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E[i][j]; - } - } - - assembler_lock.acquire(); - for (unsigned i = 0; i < f_el.size(); i++) - { - // For some reason, some of the values in this loop - if (f_el[i] > 1.0e-10) - { - this->energy += f_el[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/CMakeLists.txt b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/ICs_and_BCs.h b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/ICs_and_BCs.h deleted file mode 100644 index f002c1ca7..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/ICs_and_BCs.h +++ /dev/null @@ -1,206 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - double mater_consts[1][2] = MaterialConstants; - double E = mater_consts[0][0]; - double nu = mater_consts[0][1]; - double e0[dim][dim] = { - {0.01, 0, 0 }, - {0, 0.01, 0 }, - {0, 0, 0.01} - }; - - double a = 10.0; - - Point p_shifted; - p_shifted[0] = p[0]; - p_shifted[1] = p[1]; - p_shifted[2] = p[2]; - - double r = p_shifted.distance(Point(0, 0, 0)); - Tensor<2, dim, double> pT; - Tensor<3, dim, double> S; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - pT[i][j] = E / (1.0 + nu) * (e0[i][j]); - if (i == j) - { - pT[i][j] = - pT[i][j] + E / (1.0 + nu) * - (nu / (1.0 - 2.0 * nu) * (e0[0][0] + e0[1][1] + e0[2][2])); - } - } - } - - if (r > a) - { - for (unsigned int i = 0; i < dim; i++) - { - double front_coeff = (1 + nu) * a * a * a / (2.0 * (1.0 - nu) * E); - - double term1 = 0; - for (unsigned int k = 0; k < dim; k++) - { - term1 = - term1 + (3.0 * a * a - 5.0 * r * r) / (15.0 * r * r * r * r * r) * - (2.0 * pT[i][k] * p_shifted[k] + pT[k][k] * p_shifted[i]); - } - - double term2 = 0; - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - term2 = term2 + (r * r - a * a) / (r * r * r * r * r * r * r) * - pT[j][k] * p_shifted[j] * p_shifted[i] * - p_shifted[k]; - } - } - - double term3 = 0; - for (unsigned int k = 0; k < dim; k++) - { - term3 = - term3 + 4.0 * (1 - nu) / (3.0 * r * r * r) * pT[i][k] * p_shifted[k]; - } - - vector_IC(i) = front_coeff * (term1 + term2 + term3); - } - } - else - { - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - for (unsigned int l = 0; l < dim; l++) - { - if ((i == j) & (i == k) & (i == l)) - { - S[j][k][l] = (7.0 - 5.0 * nu) / (15.0 * (1.0 - nu)); - } - else if ((i == j) & (k == l)) - { - S[j][k][l] = (5.0 * nu - 1.0) / (15.0 * (1.0 - nu)); - } - else if ((i == k) & (j == l)) - { - S[j][k][l] = (4 - 5 * nu) / (15 * (1 - nu)); - } - else if ((i == l) & (j == k)) - { - S[j][k][l] = (4 - 5 * nu) / (15 * (1 - nu)); - } - else - { - S[j][k][l] = 0.0; - } - } - } - } - - vector_IC(i) = 0.0; - - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - for (unsigned int l = 0; l < dim; l++) - { - vector_IC(i) = - vector_IC(i) + S[j][k][l] * e0[k][l] * p_shifted[j]; - } - } - } - } - } - - // ===================================================================== - } -}; - -// Sets the BCs for the problem variables -// "inputBCs" should be called for each component of each variable and should be -// in numerical order Four input arguments set the same BC on the entire -// boundary Two plus two times the number of dimensions inputs sets separate BCs -// on each face of the domain Inputs to "inputBCs": First input: variable number -// Second input: component number -// Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") -// Fourth input: BC value (ignored unless the BC type is "DIRICHLET") -// Odd inputs after the third: BC type -// Even inputs after the third: BC value -// Face numbering: starts at zero with the minimum of the first direction, one -// for the maximum of the first direction -// two for the minimum of the second direction, etc. -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - - inputBCs(4, 0, "ZERO_DERIVATIVE", 0.0); - inputBCs(4, 1, "ZERO_DERIVATIVE", 0.0); - inputBCs(4, 2, "ZERO_DERIVATIVE", 0.0); - - // ===================================================================== -} diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/main.cc b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/main.cc deleted file mode 100644 index 82ace544a..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/main.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/parameters.h b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/parameters.h deleted file mode 100644 index d7362b130..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/parameters.h +++ /dev/null @@ -1,38 +0,0 @@ -// Parameter list for the Beta Prime precipitate evolution problem -//(Coupled Allen Cahn, Cahn Hilliard and Mechanics formulation) -// The free energy expressions in this file are from the reference: -// H. Liu et al, "A simulation study of the shape of beta prime precipitates in -// Mg–Y and Mg–Gd alloys", Acta Materialia, Volume 61, Issue 2, January 2013, -// Pages 453-466. http://dx.doi.org/10.1016/j.actamat.2012.09.044 - -// Define problem dimensions -#define problemDIM 3 -#define spanX 100.0 -#define spanY 100.0 -#define spanZ 100.0 - -// Define mesh parameters -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 6 -#define finiteElementDegree 1 - -// define number of fields in the problem -#define numFields 3 - -// Define solver paramters -#define solverType SolverCG -#define relSolverTolerance 1.0e-10 -#define maxSolverIterations 1000 - -// define time step parameters -#define timeStep 1.0e-3 -#define timeFinal 10.0 -#define timeIncrements 0 - -// Define results output parameters -#define writeOutput true -#define skipOutputSteps 10 - -#define calcEnergy false diff --git a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/residuals.h b/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/residuals.h deleted file mode 100644 index 9962388c7..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelbyAnalyticResult/residuals.h +++ /dev/null @@ -1,221 +0,0 @@ -// Define required residuals -// Definition of the variables in the model -#define num_var 1 -#define variable_name \ - { \ - "u" \ - } -#define variable_type \ - { \ - "VECTOR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC" \ - } -#define need_val \ - { \ - false \ - } -#define need_grad \ - { \ - true \ - } -#define need_hess \ - { \ - false \ - } -#define need_val_residual \ - { \ - false \ - } -#define need_grad_residual \ - { \ - true \ - } - -// Define Mechanical properties -// Mechanical symmetry of the material and stiffness parameters -#define MaterialModels \ - { \ - "ISOTROPIC" \ - } -#define MaterialConstants \ - { \ - { \ - 22.5, 0.3 \ - } \ - } - -// --------------------------------------------- - -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // u - vectorgradType ux = modelVariablesList[0].vectorGrad; - vectorgradType Rux; - - dealii::VectorizedArray sfts[dim][dim]; - - dealii::VectorizedArray dist; - - dist = std::sqrt( - (q_point_loc[0] - constV(spanX / 2.0)) * (q_point_loc[0] - constV(spanX / 2.0)) + - (q_point_loc[1] - constV(spanY / 2.0)) * (q_point_loc[1] - constV(spanY / 2.0)) + - (q_point_loc[2] - constV(spanY / 2.0)) * (q_point_loc[2] - constV(spanY / 2.0))); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - if (i == j) - { - sfts[i][j] = - 0.01 * - (0.5 + 0.5 * (constV(1.0) - std::exp(-20.0 * (dist - constV(5.0)))) / - (constV(1.0) + std::exp(-20.0 * (dist - constV(5.0))))); - } - else - { - sfts[i][j] = 0.0; - } - } - } - - // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - sfts[i][j]; - } - } - - // compute stress tensor - computeStress(CIJ_list[0], E, S); - - // compute residual - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - Rux[i][j] = -S[i][j]; - } - } - - modelResidualsList[0].vectorGradResidual = Rux; -} - -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVarList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // u - vectorgradType ux = modelVarList[0].vectorGrad; - vectorgradType Rux; - - // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]); - } - } - - // compute stress tensor - computeStress(CIJ_list[0], E, S); - - // compute residual - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - Rux[i][j] = S[i][j]; - } - } - - modelRes.vectorGradResidual = Rux; -} - -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - // u - vectorgradType ux = modelVarList[0].vectorGrad; - - dealii::VectorizedArray sfts[dim][dim]; - - dealii::VectorizedArray dist; - - dist = std::sqrt( - (q_point_loc[0] - constV(spanX / 2.0)) * (q_point_loc[0] - constV(spanX / 2.0)) + - (q_point_loc[1] - constV(spanY / 2.0)) * (q_point_loc[1] - constV(spanY / 2.0)) + - (q_point_loc[2] - constV(spanY / 2.0)) * (q_point_loc[2] - constV(spanY / 2.0))); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - if (i == j) - { - sfts[i][j] = - 0.01 * - (0.5 + 0.5 * (constV(1.0) - std::exp(-20.0 * (dist - constV(10.0)))) / - (constV(1.0) + std::exp(-20.0 * (dist - constV(10.0))))); - } - else - { - sfts[i][j] = 0.0; - } - } - } - - // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - sfts[i][j]; - } - } - - // compute stress tensor - computeStress(CIJ_list[0], E, S); - - scalarvalueType f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E[i][j]; - } - } - - assembler_lock.acquire(); - for (unsigned i = 0; i < f_el.size(); i++) - { - // For some reason, some of the values in this loop - if (f_el[i] > 1.0e-10) - { - this->energy += f_el[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/analytic_tests/eshelby_difference.txt b/tests/deprecated_tests/analytic_tests/eshelby_difference.txt deleted file mode 100644 index 51874705a..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelby_difference.txt +++ /dev/null @@ -1 +0,0 @@ -0.00426410918517 \ No newline at end of file diff --git a/tests/deprecated_tests/analytic_tests/eshelby_test_result.txt b/tests/deprecated_tests/analytic_tests/eshelby_test_result.txt deleted file mode 100644 index 80b3def4d..000000000 --- a/tests/deprecated_tests/analytic_tests/eshelby_test_result.txt +++ /dev/null @@ -1,2 +0,0 @@ -Maximum difference between the calculated and analytic result: -0.00426410918517 diff --git a/tests/deprecated_tests/analytic_tests/getDiff_diffusion.py b/tests/deprecated_tests/analytic_tests/getDiff_diffusion.py deleted file mode 100644 index cc3d1d810..000000000 --- a/tests/deprecated_tests/analytic_tests/getDiff_diffusion.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "10000" -output_num_2 = "0" - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = False - -directory_1 = "diffusionAnalyticComparison/solution-"+output_num_1+".pvtu" -directory_2 = "diffusionAnalyticResult/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("diffusion_difference.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() diff --git a/tests/deprecated_tests/analytic_tests/getDiff_eshelby.py b/tests/deprecated_tests/analytic_tests/getDiff_eshelby.py deleted file mode 100644 index 4460cbd66..000000000 --- a/tests/deprecated_tests/analytic_tests/getDiff_eshelby.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys - -variable_1 = 'u_magnitude' -variable_2 = 'u_magnitude' - -output_num_1 = "0" -output_num_2 = "0" - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = False - -directory_1 = "eshelbyAnalyticComparison/solution-"+output_num_1+".pvtu" -directory_2 = "eshelbyAnalyticResult/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("eshelby_difference.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() diff --git a/tests/deprecated_tests/analytic_tests/run_analytic_diffusion_test.py b/tests/deprecated_tests/analytic_tests/run_analytic_diffusion_test.py deleted file mode 100644 index 12b548281..000000000 --- a/tests/deprecated_tests/analytic_tests/run_analytic_diffusion_test.py +++ /dev/null @@ -1,58 +0,0 @@ -import subprocess -import shutil -import glob -import math -import os.path -import os - -# ---------------------------------------------------------------------------------------- - -# If files exist from previous tests, delete them -if os.path.exists("simulation_result_diffusion") == True: - shutil.rmtree("simulation_result_diffusion") -if os.path.exists("analytical_result_diffusion") == True: - shutil.rmtree("analytical_result_diffusion") - -# Run the 1D diffusion simulation - -os.chdir("diffusionAnalyticComparison") -subprocess.call(["rm", "CMakeCache.txt"]) -subprocess.call(["cmake", "."]) -subprocess.call(["make", "debug"]) -subprocess.call(["./main"]) - -# Get the analytic result -os.chdir("../diffusionAnalyticResult") -subprocess.call(["rm", "CMakeCache.txt"]) -subprocess.call(["cmake", "."]) -subprocess.call(["make", "debug"]) -subprocess.call(["./main"]) - -# Find the error -os.chdir("..") -subprocess.call(["visit", "-cli","-s","getDiff_diffusion.py"]) - -f = open('diffusion_difference.txt','r') -diff = float(f.read()) -f.close() - -# Output the difference -print "Maximum difference between the calculated and analytic result: \n" -print str(diff), "\n" - -text_file = open("diffusion_test_result.txt","w") -text_file.write("Maximum difference between the calculated and analytic result: \n") -text_file.write(str(diff) + "\n") -text_file.close() - -# Move the files -subprocess.call(["mkdir","simulation_result_diffusion"]) -os.chdir("diffusionAnalyticComparison") -subprocess.call(["cp *vtu ../simulation_result_diffusion/"],shell=True) - -os.chdir("..") -subprocess.call(["mkdir","analytical_result_diffusion"]) -os.chdir("diffusionAnalyticResult") -subprocess.call(["cp *vtu ../analytical_result_diffusion/"],shell=True) -os.chdir("..") - diff --git a/tests/deprecated_tests/analytic_tests/run_analytic_eshelby_test.py b/tests/deprecated_tests/analytic_tests/run_analytic_eshelby_test.py deleted file mode 100644 index a8492b4c2..000000000 --- a/tests/deprecated_tests/analytic_tests/run_analytic_eshelby_test.py +++ /dev/null @@ -1,57 +0,0 @@ -import subprocess -import shutil -import glob -import math -import os.path -import os - -# ---------------------------------------------------------------------------------------- - -# If files exist from previous tests, delete them -if os.path.exists("simulation_result_eshelby") == True: - shutil.rmtree("simulation_result_eshelby") -if os.path.exists("analytical_result_eshelby") == True: - shutil.rmtree("analytical_result_eshelby") - -# Run the 1D diffusion simulation -os.chdir("eshelbyAnalyticComparison") -subprocess.call(["rm", "CMakeCache.txt"]) -subprocess.call(["cmake", "."]) -subprocess.call(["make", "release"]) -subprocess.call(["./main"]) - -# Get the analytic result -os.chdir("../eshelbyAnalyticResult") -subprocess.call(["rm", "CMakeCache.txt"]) -subprocess.call(["cmake", "."]) -subprocess.call(["make", "release"]) -subprocess.call(["./main"]) - -# Find the error for runs 1-3 (as compared to run 4) -os.chdir("..") -subprocess.call(["visit", "-cli","-s","getDiff_eshelby.py"]) - - -f = open('eshelby_difference.txt','r') -diff = float(f.read()) -f.close() - -# Output the difference -print "Maximum difference between the calculated and analytic result: \n" -print str(diff), "\n" - -text_file = open("eshelby_test_result.txt","w") -text_file.write("Maximum difference between the calculated and analytic result: \n") -text_file.write(str(diff) + "\n") -text_file.close() - -# Move the files -subprocess.call(["mkdir","simulation_result_eshelby"]) -os.chdir("eshelbyAnalyticComparison") -subprocess.call(["cp *vtu ../simulation_result_eshelby/"],shell=True) - -os.chdir("..") -subprocess.call(["mkdir","analytical_result_eshelby"]) -os.chdir("eshelbyAnalyticResult") -subprocess.call(["cp *vtu ../analytical_result_eshelby/"],shell=True) -os.chdir("..") diff --git a/tests/deprecated_tests/analytic_tests/visitlog.py b/tests/deprecated_tests/analytic_tests/visitlog.py deleted file mode 100644 index 04801a787..000000000 --- a/tests/deprecated_tests/analytic_tests/visitlog.py +++ /dev/null @@ -1,57 +0,0 @@ -# Visit 2.7.3 log file -ScriptVersion = "2.7.3" -if ScriptVersion != Version(): - print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version()) -ShowAllWindows() -OpenDatabase("diffusionAnalyticComparison/solution-10000.pvtu", 0) -# The UpdateDBPluginInfo RPC is not supported in the VisIt module so it will not be logged. -DefineScalarExpression("diff", "(c-pos_cmfe(, mesh,0))") -AddPlot("Pseudocolor", "diff", 1, 1) -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.scaling = PseudocolorAtts.Linear # Linear, Log, Skew -PseudocolorAtts.skewFactor = 1 -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot -PseudocolorAtts.minFlag = 0 -PseudocolorAtts.min = 0 -PseudocolorAtts.maxFlag = 0 -PseudocolorAtts.max = 1 -PseudocolorAtts.centering = PseudocolorAtts.Natural # Natural, Nodal, Zonal -PseudocolorAtts.colorTableName = "hot" -PseudocolorAtts.invertColorTable = 0 -PseudocolorAtts.opacityType = PseudocolorAtts.FullyOpaque # ColorTable, FullyOpaque, Constant, Ramp, VariableRange -PseudocolorAtts.opacityVariable = "" -PseudocolorAtts.opacity = 1 -PseudocolorAtts.opacityVarMin = 0 -PseudocolorAtts.opacityVarMax = 1 -PseudocolorAtts.opacityVarMinFlag = 0 -PseudocolorAtts.opacityVarMaxFlag = 0 -PseudocolorAtts.pointSize = 0.05 -PseudocolorAtts.pointType = PseudocolorAtts.Point # Box, Axis, Icosahedron, Octahedron, Tetrahedron, SphereGeometry, Point, Sphere -PseudocolorAtts.pointSizeVarEnabled = 0 -PseudocolorAtts.pointSizeVar = "default" -PseudocolorAtts.pointSizePixels = 2 -PseudocolorAtts.lineType = PseudocolorAtts.Line # Line, Tube, Ribbon -PseudocolorAtts.lineStyle = PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH -PseudocolorAtts.lineWidth = 0 -PseudocolorAtts.tubeDisplayDensity = 10 -PseudocolorAtts.tubeRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.tubeRadiusAbsolute = 0.125 -PseudocolorAtts.tubeRadiusBBox = 0.005 -PseudocolorAtts.varyTubeRadius = 0 -PseudocolorAtts.varyTubeRadiusVariable = "" -PseudocolorAtts.varyTubeRadiusFactor = 10 -PseudocolorAtts.endPointType = PseudocolorAtts.None # None, Tails, Heads, Both -PseudocolorAtts.endPointStyle = PseudocolorAtts.Spheres # Spheres, Cones -PseudocolorAtts.endPointRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.endPointRadiusAbsolute = 1 -PseudocolorAtts.endPointRadiusBBox = 0.005 -PseudocolorAtts.endPointRatio = 2 -PseudocolorAtts.renderSurfaces = 1 -PseudocolorAtts.renderWireframe = 0 -PseudocolorAtts.renderPoints = 0 -PseudocolorAtts.smoothingLevel = 0 -PseudocolorAtts.legendFlag = 1 -PseudocolorAtts.lightingFlag = 1 -SetPlotOptions(PseudocolorAtts) -DrawPlots() -Query("MinMax", use_actual_data=1) diff --git a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/CMakeLists.txt b/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/ICs_and_BCs.h b/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/ICs_and_BCs.h deleted file mode 100644 index eda6e1ed6..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/ICs_and_BCs.h +++ /dev/null @@ -1,120 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // set result equal to the structural order paramter initial condition - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; - - double initial_radius = 40.0; - double initial_interface_coeff = 2.0; - -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (1.0 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); -// return 0.5*(1.0-std::tanh((r-spanX/16.0)/(3*dx))); -#elif problemDIM == 3 - - // r=p.distance(Point(spanX/2.0,spanY/2.0,spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r-spanX/8.0)/(3*dx))); - - r = sqrt((p.operator()(0) - spanX / 2.0) * (p.operator()(0) - spanX / 2.0) + - (p.operator()(1) - spanY / 2.0) * (p.operator()(1) - spanY / 2.0) * 4.0 + - (p.operator()(2) - spanZ / 2.0) * (p.operator()(2) - spanZ / 2.0)); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - -// planar interface -// r=sqrt((p.operator()(2)-spanZ/2.0)*(p.operator()(2)-spanZ/2.0)); -// return 0.5*(1.0-std::tanh((r)/(initial_interface_coeff))); -// return 0.5*(1.0-std::tanh((r-initial_radius)/(initial_interface_coeff))); -#endif - return 0.0; - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // ===================================================================== - } -}; - -// Sets the BCs for the problem variables -// "inputBCs" should be called for each component of each variable and should be -// in numerical order Four input arguments set the same BC on the entire -// boundary Two plus two times the number of dimensions inputs sets separate BCs -// on each face of the domain Inputs to "inputBCs": First input: variable number -// Second input: component number -// Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") -// Fourth input: BC value (ignored unless the BC type is "DIRICHLET") -// Odd inputs after the third: BC type -// Even inputs after the third: BC value -// Face numbering: starts at zero with the minimum of the first direction, one -// for the maximum of the first direction -// two for the minimum of the second direction, etc. -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - - // ===================================================================== -} diff --git a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/finite_difference_AC/AC_finite_difference.f90 b/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/finite_difference_AC/AC_finite_difference.f90 deleted file mode 100644 index 586db993f..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/finite_difference_AC/AC_finite_difference.f90 +++ /dev/null @@ -1,900 +0,0 @@ -MODULE parameters -IMPLICIT NONE -SAVE - - CHARACTER(LEN=3), PARAMETER :: run_num = '001' - CHARACTER(LEN=0), PARAMETER :: output_path = '' - - !! Grid size - - - REAL(KIND=8), PARAMETER :: domain_size_x = 100.0d0 !! nm - REAL(KIND=8), PARAMETER :: domain_size_y = 100.0d0 !! nm - REAL(KIND=8), PARAMETER :: domain_size_z = 100.0d0 !! nm - - INTEGER, PARAMETER :: xg = 128/2 !128 !224 !128 !184 !127 !181 !241 !181 !121 - INTEGER, PARAMETER :: yg = 128/2 !128 !224 !128 !256 !128 !184 !127 !181 !241 !181 !121 - INTEGER, PARAMETER :: zg = 128/2 !92 !92 !163 !91 !195 !195 !121 !91 !61 - - INTEGER, PARAMETER :: bb = 1 - - REAL(KIND=8), PARAMETER :: dz = domain_size_z/DBLE(zg) !! Grid spacing (nm) - REAL(KIND=8), PARAMETER :: dx = domain_size_x/DBLE(xg) !! Grid spacing (nm) - REAL(KIND=8), PARAMETER :: dy = domain_size_y/DBLE(yg) !! Grid spacing (nm) - - !! The number of subdomains in each direction for MPI - INTEGER, PARAMETER :: num_subdomain_x = 4 !8 !8 !8 !8 !8 !4 !8 !6 - INTEGER, PARAMETER :: num_subdomain_y = 2 !4 !4 !4 !4 !4 !1 !1 - INTEGER, PARAMETER :: num_subdomain_z = 2 !4 !2 !2 !3 !6 !4 - - !! Particle initialization - REAL(KIND=8), PARAMETER :: particle_x = domain_size_x/2.0d0 !75.0d0 !! nm - REAL(KIND=8), PARAMETER :: particle_y = domain_size_y/2.0d0 !75.0d0 !! nm - REAL(KIND=8), PARAMETER :: particle_z = domain_size_z/2.0d0 !! nm - REAL(KIND=8), PARAMETER :: rad = 40.0d0 !! nm - - - !! Phase field constants - - REAL(KIND=8), PARAMETER :: A_alpha = 24.7939d0 - REAL(KIND=8), PARAMETER :: B_alpha = -1.6752d0 - REAL(KIND=8), PARAMETER :: C_alpha = 1.9453d-6 - REAL(KIND=8), PARAMETER :: A_beta = 37.9316d0 - REAL(KIND=8), PARAMETER :: B_beta = -10.7373d0 - REAL(KIND=8), PARAMETER :: C_beta = 0.5401d0 - - REAL(KIND=8), PARAMETER :: L = 1.0d0 - REAL(KIND=8), PARAMETER :: kappa = 4.0d0 - - REAL(KIND=8), PARAMETER :: delta = 2.0d0 !0.215d0 - - REAL(KIND=8), PARAMETER :: pi = ACOS(-1.0d0) - - INTEGER, PARAMETER :: max_iter = 30000 - REAL(KIND=8), PARAMETER :: dt = 1.0d-3 !! seconds - - !! Tags for MPI communication - INTEGER, PARAMETER :: c1Tag=91,c2Tag=92,c3Tag=93,c4Tag=94, pTag=95 - INTEGER, PARAMETER :: r1Tag=101,l1Tag=102,f1Tag=103,b1Tag=104,t1Tag=105,d1Tag=106 - INTEGER, PARAMETER :: r2Tag=111,l2Tag=112,f2Tag=113,b2Tag=114,t2Tag=115,d2Tag=116 - INTEGER, PARAMETER :: Sr1Req=81,Sl1Req=82,Sf1Req=83,Sb1Req=84,St1Req=85,Sd1Req=86 - INTEGER, PARAMETER :: Rr1Req=71,Rl1Req=72,Rf1Req=73,Rb1Req=74,Rt1Req=75,Rd1Req=76 - INTEGER, PARAMETER :: Sr2Req=61,Sl2Req=62,Sf2Req=63,Sb2Req=64,St2Req=65,Sd2Req=66 - INTEGER, PARAMETER :: Rr2Req=51,Rl2Req=52,Rf2Req=53,Rb2Req=54,Rt2Req=55,Rd2Req=56 - -END MODULE parameters - -!! CHAC_finite_difference: This program solves the coupled Cahn-Hilliard-Allen-Cahn system -!! of equations. It was developed for comparison to the PRISMS-PF finite element code to -!! ensure that its performance was competitive with finite difference. -!! -!! Author: Stephen DeWitt (stvdwtt@umich.edu) -!! Date Started: 1/6/2016 -!! -!! ============================================================================= - -PROGRAM CHAC_finite_difference -USE parameters -IMPLICIT NONE - -INCLUDE 'mpif.h' -INTEGER :: len -CHARACTER(MPI_MAX_PROCESSOR_NAME) :: hostname - -INTEGER errcode -INTEGER rank, nsize -INTEGER :: dims(1:3),coord(1:3),left,right,front,back,top,bot,ndims,cartcomm -LOGICAL :: reorder,periodic(1:3) -INTEGER L1, L2, L3, S1, S2, S3, Id1, Id2, Id3, Rm1, Rm2, Rm3 - -CALL outputDomainInfo() - -!! Starting the MPI section of the code - -CALL MPI_INIT (errcode) - -CALL MPI_COMM_RANK (MPI_COMM_WORLD, rank, errcode) -CALL MPI_COMM_SIZE (MPI_COMM_WORLD, nsize, errcode) -CALL MPI_GET_PROCESSOR_NAME(hostname, len, errcode) - -IF (rank .eq. 0) PRINT *, 'number of partitions', num_subdomain_x*num_subdomain_y*num_subdomain_z - -!! Start off by partitioning the domain - -!! Number of dimensions (for the MPI Cartesian communicator) -ndims = 3 - -!! Set the number of partitions in each direction -dims(1) = num_subdomain_x -dims(2) = num_subdomain_y -dims(3) = num_subdomain_z - -periodic(1) = .TRUE. -periodic(2) = .TRUE. -periodic(3) = .FALSE. -reorder = .true. - -!! Create the Cartesian communicator -call MPI_CART_CREATE(MPI_COMM_WORLD,ndims,dims,periodic,reorder,cartcomm,errcode) -!PRINT *, 'rank', rank, 'cartcomm', cartcomm - -!! Calculate the non-ghost-zone length of each partition (L#) and the remaining grid points (Rm#) -L1 = floor(xg/real(num_subdomain_x)) -Rm1 = mod(xg,num_subdomain_x) - -L2 = floor(yg/real(num_subdomain_y)) -Rm2 = mod(yg,num_subdomain_y) - -L3 = floor(zg/real(num_subdomain_z)) -Rm3 = mod(zg,num_subdomain_z) - -!! Get coordinates of each partition using MPI_CART_COORDS -call MPI_CART_COORDS(cartcomm,rank,ndims,coord,errcode) - -!! The index of the partition in all three directions -Id3 = coord(3) -Id2 = coord(2) -Id1 = coord(1) - -!! Defines the 6 neighbor partitions -call MPI_CART_SHIFT(cartcomm,0,1,left,right,errcode) !+/- x shifts are left/right -call MPI_CART_SHIFT(cartcomm,1,1,front,back,errcode) !+/- y shifts are front/back -call MPI_CART_SHIFT(cartcomm,2,1,bot,top,errcode) !+/- z shifts are top/bottom - -!! Find the starting point for each partition with respect to the global array location (S#), also find the length of each partition (L#) -if(Id1 == 0)then ! starting point of domain is set to 1, end point is n1 - S1 = 1-bb - L1=L1+2*bb -elseif(Id1 == num_subdomain_x-1)then - S1 = Id1*L1+1-bb - L1 = L1+2*bb+Rm1 -else - S1 = Id1*L1+1-bb - L1= L1+2*bb -endif -if(Id2 == 0)then ! starting point of domain is set to 1, end point is n1 - S2 = 1-bb - L2= L2+2*bb -elseif(Id2 == num_subdomain_y-1)then - S2 = Id2*L2+1-bb - L2 = L2+2*bb+Rm2 -else - S2 = Id2*L2+1-bb - L2 = L2+2*bb -endif -if(Id3 == 0)then ! starting point of domain is set to 1, end point is n1 - S3 = 1-bb - L3= L3+2*bb -elseif(Id3 == num_subdomain_z-1)then - S3 = Id3*L3+1-bb - L3 = L3+2*bb+Rm3 -else - S3 = Id3*L3+1-bb - L3= L3+2*bb -endif - -CALL main_subroutine(Id1,Id2,Id3,S1,S2,S3,L1,L2,L3,left,right,front,back,top,bot,cartcomm) - -CALL MPI_FINALIZE(errcode) - - -END PROGRAM - -!! =================================================================================== -!! Main subroutine where most of the calculations are done -!! =================================================================================== - -SUBROUTINE main_subroutine(Id1,Id2,Id3,S1,S2,S3,L1,L2,L3,left,right,front,back,top,bot,cartcomm) -USE parameters -IMPLICIT NONE - -INCLUDE 'mpif.h' -INTEGER :: L1, L2, L3, S1, S2, S3, Id1, Id2, Id3, Is1, Is2, Is3, Ie1, Ie2, Ie3, k, iter -INTEGER :: left,right,front,back,top,bot, cartcomm -REAL(KIND=8), DIMENSION(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) :: eta, x, y, z -REAL(KIND=8) :: time_elapsed, dist_particle -INTEGER :: i,j, out_num, output_crit -INTEGER :: errcode -CHARACTER(len=3) :: counter - -out_num = 0 - -time_elapsed = 0.0d0 - -!! Real grid points inside the subdomain (without ghost cells) -Is1 = S1 + bb -Ie1 = S1 + L1 - 1 - bb -Is2 = S2 + bb -Ie2 = S2 + L2 - 1 - bb -Is3 = S3 + bb -Ie3 = S3 + L3 - 1 - bb - -!! Initialize the fields - -DO k = Is3-1,Ie3+1 -DO j = Is2-1,Ie2+1 -DO i = Is1-1,Ie1+1 - - x(i,j,k) = dx * DBLE(i) -dx/2.0d0 - y(i,j,k) = dy * DBLE(j) -dy/2.0d0 - z(i,j,k) = dz * DBLE(k) -dz/2.0d0 - - !! Distance functions for spherical particles - !dist_particle = SQRT(DBLE((particle_1_x-x(i,j,k))**2)+DBLE((particle_1_y-y(i,j,k))**2)+DBLE((particle_1_z-z(i,j,k))**2)) - - !! Distance functions for ellipsoidal particles (squished in y direction) - dist_particle = SQRT(DBLE((particle_x-x(i,j,k))**2) + DBLE(((particle_y-y(i,j,k))*2.0d0)**2) & - + DBLE( (particle_z-z(i,j,k))**2) ) - - !! Flat interface - !dist_particle = SQRT((particle_z-z(i,j,k))**2) - - !! 3D Sphere - eta(i,j,k) = 0.5d0*(1.0d0 - ( TANH( (dist_particle - rad)/delta ))) - -END DO -END DO -END DO - -!! Apply boundary conditions - -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,eta,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - -!! Initial Outputs -IF (Id1+Id2+Id3.eq. 0) PRINT *, 'Time step: ', dt -CALL writeLotsFiles(eta,'eta_r',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) -CALL writeLotsFiles(x,'xgrid',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) -CALL writeLotsFiles(y,'ygrid',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) -CALL writeLotsFiles(z,'zgrid',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) - - -out_num = out_num + 1 - - -!! ------------------------------------------------------------------------- -!! Iterate through time -!! ------------------------------------------------------------------------- - -DO iter = 1,max_iter - - CALL allenCahn_solver_explicit(eta,S1,S2,S3,L1,L2,L3,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3, & - left,right,front,back,top,bot,cartcomm) - - IF (ANY(ISNAN(eta))) THEN - PRINT *, 'Error: Element in eta is NAN' - STOP - END IF - - time_elapsed = time_elapsed + dt - - !! ------------------------------------------------------------------------- - !! Output files - IF (max_iter <= 10) THEN - output_crit = 0 - ELSE - output_crit = MOD(iter,max_iter) - END IF - - IF (output_crit == 0) THEN - IF (Id1 .eq. 0 .and. Id2 .eq. 0 .and. Id3 .eq. 0) PRINT *, 'Output number ', out_num, ' complete' - - CALL writeLotsFiles(eta,'eta_r',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) - - out_num = out_num + 1 - - END IF - -END DO - -IF (Id1+Id2+Id3.eq. 0) PRINT *, 'Total time elapsed: ', max_iter*dt - -END SUBROUTINE - -!! =================================================================================== -!! Explicit Allen-Cahn Solver -!! =================================================================================== - -SUBROUTINE allenCahn_solver_explicit(eta,S1,S2,S3,L1,L2,L3,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3, & - left,right,front,back,top,bot,cartcomm) -USE parameters -IMPLICIT NONE - -INCLUDE 'mpif.h' -INTEGER :: L1, L2, L3, S1, S2, S3, Id1, Id2, Id3, Is1, Is2, Is3, Ie1, Ie2, Ie3 -INTEGER :: left,right,front,back,top,bot, cartcomm -REAL(KIND=8), DIMENSION(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) :: c, eta, mu, dfdeta, landau_term -REAL(KIND=8), DIMENSION(S1+1:S1+L1-2,S2+1:S2+L2-2,S3+1:S3+L3-2) :: kappa_Lap_eta - -dfdeta = 4.0d0*eta*(eta-1.0d0)*(eta-0.5) - -kappa_Lap_eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) = kappa*( (eta(Is1+1:Ie1+1,Is2:Ie2,Is3:Ie3) - 2.0d0*eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + eta(Is1-1:Ie1-1,Is2:Ie2,Is3:Ie3))/dx**2 & - + (eta(Is1:Ie1,Is2+1:Ie2+1,Is3:Ie3) - 2.0d0*eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + eta(Is1:Ie1,Is2-1:Ie2-1,Is3:Ie3))/dy**2 & - + (eta(Is1:Ie1,Is2:Ie2,Is3+1:Ie3+1) - 2.0d0*eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + eta(Is1:Ie1,Is2:Ie2,Is3-1:Ie3-1))/dz**2 ) - -eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) = eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - - dt * L * ( dfdeta(Is1:Ie1,Is2:Ie2,Is3:Ie3) - kappa_Lap_eta) - -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,eta,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - - -END SUBROUTINE allenCahn_solver_explicit - - -!! =================================================================================== - -SUBROUTINE applyBCs(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,phi1,U_BC_top,left,right,front,back,top,bot,cartcomm,direction) -use parameters -implicit none -INCLUDE 'mpif.h' - -INTEGER S1, S2, S3, Id1, Id2, Id3,L1,L2,L3 -INTEGER :: left,right,front,back,top,bot,cartcomm !ranks of processors to shift to and cartcomm -INTEGER :: i,j,k, direction -INTEGER :: errcode -REAL(KIND=8) :: phi1(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1), U_BC_top -INTEGER,DIMENSION(MPI_STATUS_SIZE) :: nstatus - -REAL(KIND=8), DIMENSION(1:L2,1:L3) :: Buffer_x1, Buffer_x2, Buffer_x3, Buffer_x4 -REAL(KIND=8), DIMENSION(1:L1,1:L3) :: Buffer_y1, Buffer_y2, Buffer_y3, Buffer_y4 -REAL(KIND=8), DIMENSION(1:L1,1:L2) :: Buffer_z1, Buffer_z2, Buffer_z3, Buffer_z4 -INTEGER,DIMENSION(12) :: req - -!! Communication in n1 direction - -IF ( direction .EQ. 0 .OR. direction .EQ. 1 ) THEN - - ! x-direction - Buffer_x3 = phi1(S1+L1-1-bb,S2:S2+L2-1,S3:S3+L3-1) - Buffer_x2 = phi1(S1+bb,S2:S2+L2-1,S3:S3+L3-1) - - CALL MPI_iSEND(Buffer_x3,L2*L3,MPI_DOUBLE_PRECISION,right,r1Tag,cartcomm,req(1),errcode) - CALL MPI_iRECV(Buffer_x4,L2*L3,MPI_DOUBLE_PRECISION,right,l1Tag,cartcomm,req(2),errcode) - CALL MPI_iSEND(Buffer_x2,L2*L3,MPI_DOUBLE_PRECISION,left ,l1Tag,cartcomm,req(4),errcode) - CALL MPI_iRECV(Buffer_x1,L2*L3,MPI_DOUBLE_PRECISION,left ,r1Tag,cartcomm,req(3),errcode) - call MPI_waitall(4,req(1:4),MPI_STATUS_IGNORE,errcode) - - phi1(S1,S2:S2+L2-1,S3:S3+L3-1) = Buffer_x1 - phi1(S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) = Buffer_x4 - -ENDIF - -!! Communication in n2 direction - -IF ( direction .EQ. 0 .OR. direction .EQ. 2 ) THEN - ! y-direction - Buffer_y3 = phi1(S1:S1+L1-1,S2+L2-1-bb,S3:S3+L3-1) - Buffer_y2 = phi1(S1:S1+L1-1,S2+bb,S3:S3+L3-1) - CALL MPI_iSEND(Buffer_y3,L1*L3,MPI_DOUBLE_PRECISION,back ,b1Tag,cartcomm,req(5),errcode) - CALL MPI_iRECV(Buffer_y4,L1*L3,MPI_DOUBLE_PRECISION,back ,f1Tag,cartcomm,req(6),errcode) - CALL MPI_iSEND(Buffer_y2,L1*L3,MPI_DOUBLE_PRECISION,front,f1Tag,cartcomm,req(8),errcode) - CALL MPI_iRECV(Buffer_y1,L1*L3,MPI_DOUBLE_PRECISION,front,b1Tag,cartcomm,req(7),errcode) - call MPI_waitall(4,req(5:8),MPI_STATUS_IGNORE,errcode) - phi1(S1:S1+L1-1,S2,S3:S3+L3-1) = Buffer_y1 - phi1(S1:S1+L1-1,S2+L2-1,S3:S3+L3-1) = Buffer_y4 - -ENDIF - -!! Communication in n3 direction - -IF ( direction .EQ. 0 .OR. direction .EQ. 3 ) THEN - ! z-direction - Buffer_z3=phi1(S1:S1+L1-1,S2:S2+L2-1,S3+L3-1-bb) - Buffer_z2=phi1(S1:S1+L1-1,S2:S2+L2-1,S3+bb) - IF ( Id3 .NE. num_subdomain_z-1 ) THEN - CALL MPI_iSEND(Buffer_z3,L1*L2,MPI_DOUBLE_PRECISION,top,t1Tag,cartcomm,req(9),errcode) - CALL MPI_iRECV(Buffer_z4,L1*L2,MPI_DOUBLE_PRECISION,top,b1Tag,cartcomm,req(10),errcode) - ELSE - !CALL external_BCs_Dirichlet(phi1,U_BC_top,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - Buffer_z4 = U_BC_top - ENDIF - - IF ( Id3 .NE. 0 ) THEN - CALL MPI_iSEND(Buffer_z2,L1*L2,MPI_DOUBLE_PRECISION,bot,b1Tag,cartcomm,req(12),errcode) - CALL MPI_iRECV(Buffer_z1,L1*L2,MPI_DOUBLE_PRECISION,bot,t1Tag,cartcomm,req(11),errcode) - ELSE - !CALL external_BCs_Zero_Derivative(phi1,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - Buffer_z1 = phi1(S1:S1+L1-1,S2:S2+L2-1,S3+bb) - ENDIF - - IF ( Id3 .NE. num_subdomain_z-1 ) call MPI_waitall(2,req(9:10),MPI_STATUS_IGNORE,errcode) - IF ( Id3 .NE. 0 ) call MPI_waitall(2,req(11:12),MPI_STATUS_IGNORE,errcode) - phi1(S1:S1+L1-1,S2:S2+L2-1,S3)=Buffer_z1 - phi1(S1:S1+L1-1,S2:S2+L2-1,S3+L3-1)=Buffer_z4 - -ENDIF - -!! External BCs in the z-direction -!CALL external_BCs_Dirichlet(phi1,U_BC_top,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -!CALL external_BCs_Zero_Derivative(phi1,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - -RETURN -END SUBROUTINE applyBCs - -!! =================================================================================== -!! External BC calculation subroutines -!! =================================================================================== - -SUBROUTINE external_BCs_Dirichlet(array,BC_value,is_top,dimension_num,Id1,Id2,Id3,px,py,pz) -USE parameters -IMPLICIT NONE - -INTEGER :: px, py, pz -REAL(KIND=8), DIMENSION(0:px+1,0:py+1,0:pz+1) :: array -REAL(KIND=8) :: BC_value -INTEGER :: dimension_num,Id1,Id2,Id3 -LOGICAL :: is_top - -SELECT CASE (dimension_num) - -CASE (1) - IF (is_top .eqv. .TRUE.) THEN - IF (Id1 .eq. num_subdomain_x-1) THEN - array(px+1,0:py+1,0:pz+1) = BC_value - END IF - ELSE - IF (Id1 .eq. 0) THEN - array(0,0:py+1,0:pz+1) = BC_value - END IF - END IF - -CASE (2) - IF (is_top .eqv. .TRUE.) THEN - IF (Id2 .eq. num_subdomain_y-1) THEN - array(0:px+1,py+1,0:pz+1) = BC_value - END IF - ELSE - IF (Id2 .eq. 0) THEN - array(0:px+1,0,0:pz+1) = BC_value - END IF - END IF - -CASE (3) - IF (is_top .eqv. .TRUE.) THEN - IF (Id3 .eq. num_subdomain_z-1) THEN - array(0:px+1,0:py+1,pz+1) = BC_value - END IF - ELSE - IF (Id3 .eq. 0) THEN - array(0:px+1,0:py+1,0) = BC_value - END IF - END IF - -END SELECT - -!PRINT *, 'in BC subroutine', array(40, 10, pz+1), array(40, 10, 0), top_val, bottom_val - -END SUBROUTINE external_BCs_Dirichlet - -!! =================================================================================== - -SUBROUTINE external_BCs_Zero_Derivative(array,is_top,dimension_num,Id1,Id2,Id3,px,py,pz) -USE parameters -IMPLICIT NONE - -INTEGER :: px, py, pz -REAL(KIND=8), DIMENSION(0:px+1,0:py+1,0:pz+1) :: array -REAL(KIND=8) :: BC_value -INTEGER :: dimension_num,Id1,Id2,Id3 -LOGICAL :: is_top - -SELECT CASE (dimension_num) - -CASE (1) - IF (is_top .eqv. .TRUE.) THEN - IF (Id1 .eq. num_subdomain_x-1) THEN - array(px+1,0:py+1,0:pz+1) = array(px,0:py+1,0:pz+1) - END IF - ELSE - IF (Id1 .eq. 0) THEN - array(0,0:py+1,0:pz+1) = array(1,0:py+1,0:pz+1) - END IF - END IF - -CASE (2) - IF (is_top .eqv. .TRUE.) THEN - IF (Id2 .eq. num_subdomain_y-1) THEN - array(0:px+1,py+1,0:pz+1) = array(0:px+1,py,0:pz+1) - END IF - ELSE - IF (Id2 .eq. 0) THEN - array(0:px+1,0,0:pz+1) = array(0:px+1,1,0:pz+1) - END IF - END IF - -CASE (3) - IF (is_top .eqv. .TRUE.) THEN - IF (Id3 .eq. num_subdomain_z-1) THEN - array(0:px+1,0:py+1,pz+1) = array(0:px+1,0:py+1,pz) - END IF - ELSE - IF (Id3 .eq. 0) THEN - array(0:px+1,0:py+1,0) = array(0:px+1,0:py+1,1) - END IF - END IF - -END SELECT - -!PRINT *, 'in BC subroutine', array(40, 10, pz+1), array(40, 10, 0), top_val, bottom_val - -END SUBROUTINE external_BCs_Zero_Derivative - -!! =================================================================================== - -SUBROUTINE external_BCs_Neumann(array,derivative,is_top,dimension_num,Id1,Id2,Id3,px,py,pz) -USE parameters -IMPLICIT NONE - -INTEGER :: px, py, pz -REAL(KIND=8), DIMENSION(0:px+1,0:py+1,0:pz+1) :: array -REAL(KIND=8) :: derivative -INTEGER :: dimension_num,Id1,Id2,Id3 -LOGICAL :: is_top - -SELECT CASE (dimension_num) - -CASE (1) - IF (is_top .eqv. .TRUE.) THEN - IF (Id1 .eq. num_subdomain_x-1) THEN - array(px+1,0:py+1,0:pz+1) = array(px,0:py+1,0:pz+1) + derivative - END IF - ELSE - IF (Id1 .eq. 0) THEN - array(0,0:py+1,0:pz+1) = array(1,0:py+1,0:pz+1) - derivative - END IF - END IF - -CASE (2) - IF (is_top .eqv. .TRUE.) THEN - IF (Id2 .eq. num_subdomain_y-1) THEN - array(0:px+1,py+1,0:pz+1) = array(0:px+1,py,0:pz+1) + derivative - END IF - ELSE - IF (Id2 .eq. 0) THEN - array(0:px+1,0,0:pz+1) = array(0:px+1,1,0:pz+1) - derivative - END IF - END IF - -CASE (3) - IF (is_top .eqv. .TRUE.) THEN - IF (Id3 .eq. num_subdomain_z-1) THEN - array(0:px+1,0:py+1,pz+1) = array(0:px+1,0:py+1,pz) + derivative - END IF - ELSE - IF (Id3 .eq. 0) THEN - array(0:px+1,0:py+1,0) = array(0:px+1,0:py+1,1) - derivative - END IF - END IF - -END SELECT - -END SUBROUTINE external_BCs_Neumann - -!! =================================================================================== - -SUBROUTINE external_BCs_Periodic(array,dimension_num,Id1,Id2,Id3,px,py,pz,left,right,front,back,top,bot,cartcomm) -USE parameters -IMPLICIT NONE -INCLUDE 'mpif.h' - -INTEGER :: px, py, pz -REAL(KIND=8), DIMENSION(0:px+1,0:py+1,0:pz+1) :: array -INTEGER :: dimension_num,Id1,Id2,Id3 -INTEGER :: left,right,front,back,top,bot,cartcomm -INTEGER :: errcode -INTEGER,DIMENSION(MPI_STATUS_SIZE) :: nstatus - -SELECT CASE (dimension_num) - -CASE (1) - IF ( num_subdomain_x .eq. 1) THEN - array(0,0:py+1,0:pz+1) = array(px,0:py+1,0:pz+1) - array(px+1,0:py+1,0:pz+1) = array(1,0:py+1,0:pz+1) - ELSE - IF (Id1 .eq. num_subdomain_x-1) & - call MPI_SEND(array(px,0:py+1,0:pz+1),(py+2)*(pz+2),MPI_DOUBLE_PRECISION,right,r1Tag+100,cartcomm,errcode) - - IF (Id1 .eq. 0) & - call MPI_RECV(array(0,0:py+1,0:pz+1),(py+2)*(pz+2),MPI_DOUBLE_PRECISION,left,r1Tag+100,cartcomm,nstatus,errcode) - - IF (Id1 .eq. 0) & - call MPI_SEND(array(1,0:py+1,0:pz+1),(py+2)*(pz+2),MPI_DOUBLE_PRECISION,left,l1Tag+100,cartcomm,errcode) - - IF (Id1 .eq. num_subdomain_x-1) & - call MPI_RECV(array(px+1,0:py+1,0:pz+1),(py+2)*(pz+2),MPI_DOUBLE_PRECISION,right,l1Tag+100,cartcomm,nstatus,errcode) - END IF - -CASE (2) - IF ( num_subdomain_y .eq. 1) THEN - array(0:px+1,0,0:pz+1) = array(0:px+1,py,0:pz+1) - array(0:px+1,py+1,0:pz+1) = array(0:px+1,1,0:pz+1) - ELSE - IF (Id2 .eq. num_subdomain_y-1) THEN - call MPI_SEND(array(0:px+1,py,0:pz+1),(px+2)*(pz+2),MPI_DOUBLE_PRECISION,back,f1Tag+100,cartcomm,errcode) - END IF - - IF (Id2 .eq. 0) THEN - call MPI_RECV(array(0:px+1,0,0:pz+1),(px+2)*(pz+2),MPI_DOUBLE_PRECISION,front,f1Tag+100,cartcomm,nstatus,errcode) - END IF - - IF (Id2 .eq. 0) & - call MPI_SEND(array(0:px+1,1,0:pz+1),(px+2)*(pz+2),MPI_DOUBLE_PRECISION,front,b1Tag+100,cartcomm,errcode) - - IF (Id2 .eq. num_subdomain_y-1) & - call MPI_RECV(array(0:px+1,py+1,0:pz+1),(px+2)*(pz+2),MPI_DOUBLE_PRECISION,back,b1Tag+100,cartcomm,nstatus,errcode) - END IF -CASE (3) - IF ( num_subdomain_z .eq. 1) THEN - array(0:px+1,0:py+1,0) = array(0:px+1,0:py+1,pz) - array(0:px+1,0:py+1,pz+1) = array(0:px+1,0:py+1,1) - ELSE - IF (Id3 .eq. num_subdomain_z-1) & - call MPI_SEND(array(0:px+1,0:py+1,pz),(px+2)*(py+2),MPI_DOUBLE_PRECISION,top,t1Tag+100,cartcomm,errcode) - - IF (Id3 .eq. 0) & - call MPI_RECV(array(0:px+1,0:py+1,0),(px+2)*(py+2),MPI_DOUBLE_PRECISION,bot,t1Tag+100,cartcomm,nstatus,errcode) - - IF (Id3 .eq. 0) & - call MPI_SEND(array(0:px+1,0:py+1,1),(px+2)*(py+2),MPI_DOUBLE_PRECISION,bot,d1Tag+100,cartcomm,errcode) - - IF (Id3 .eq. num_subdomain_z-1) & - call MPI_RECV(array(0:px+1,0:py+1,pz+1),(px+2)*(py+2),MPI_DOUBLE_PRECISION,top,d1Tag+100,cartcomm,nstatus,errcode) - END IF - -END SELECT - -END SUBROUTINE external_BCs_Periodic - -!!=================================================================================== -!! Internal BC Communication Subroutine -!!=================================================================================== - -SUBROUTINE commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,phi1,left,right,front,back,top,bot,cartcomm) -use parameters -implicit none -INCLUDE 'mpif.h' - -INTEGER S1, S2, S3, Id1, Id2, Id3,L1,L2,L3 -INTEGER :: left,right,front,back,top,bot,cartcomm !ranks of processors to shift to and cartcomm -INTEGER :: i,j,k -INTEGER :: errcode -REAL(KIND=8) :: phi1(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) -INTEGER,DIMENSION(MPI_STATUS_SIZE) :: nstatus - -! Interior boundary condition -! communication in n1 direction - -If(Id1 .NE. num_subdomain_x-1) call MPI_SEND(phi1(S1+L1-1-bb,S2:S2+L2-1,S3:S3+L3-1), & - bb*L2*L3,MPI_DOUBLE_PRECISION,right,r1Tag,cartcomm,errcode) !Send real grid - -If(Id1 .NE. 0) call MPI_RECV(phi1(S1,S2:S2+L2-1,S3:S3+L3-1), & - bb*L2*L3,MPI_DOUBLE_PRECISION,left,r1Tag,cartcomm,nstatus,errcode) !receive by ghost grid - -If(Id1 .NE. 0) call MPI_SEND(phi1(S1+bb,S2:S2+L2-1,S3:S3+L3-1), & - bb*L2*L3,MPI_DOUBLE_PRECISION,left,l1Tag,cartcomm,errcode) - -If(Id1 .NE. num_subdomain_x-1) call MPI_RECV(phi1(S1+L1-1,S2:S2+L2-1,S3:S3+L3-1), & - bb*L2*L3,MPI_DOUBLE_PRECISION,right,l1Tag,cartcomm,nstatus,errcode) - -! communication in n2 direction - -If(Id2 .NE. num_subdomain_y-1) call MPI_SEND(phi1(S1:S1+L1-1,S2+L2-1-bb,S3:S3+L3-1), & - L1*bb*L3,MPI_DOUBLE_PRECISION,back,f1Tag,cartcomm,errcode) - -If(Id2 .NE. 0) call MPI_RECV(phi1(S1:S1+L1-1,S2,S3:S3+L3-1), & - L1*bb*L3,MPI_DOUBLE_PRECISION,front,f1Tag,cartcomm,nstatus,errcode) - -If(Id2 .NE. 0) call MPI_SEND(phi1(S1:S1+L1-1,S2+bb,S3:S3+L3-1), & - L1*bb*L3,MPI_DOUBLE_PRECISION,front,b1Tag,cartcomm,errcode) - -If(Id2 .NE. num_subdomain_y-1) call MPI_RECV(phi1(S1:S1+L1-1,S2+L2-1,S3:S3+L3-1), & - L1*bb*L3,MPI_DOUBLE_PRECISION,back,b1Tag,cartcomm,nstatus,errcode) - -! communication in n3 direction - - -If(Id3 .NE. num_subdomain_z-1) call MPI_SEND(phi1(S1:S1+L1-1,S2:S2+L2-1,S3+L3-1-bb), & - L1*L2*bb,MPI_DOUBLE_PRECISION,top,t1Tag,cartcomm,errcode) - -If(Id3 .NE. 0) call MPI_RECV(phi1(S1:S1+L1-1,S2:S2+L2-1,S3), & - L1*L2*bb,MPI_DOUBLE_PRECISION,bot,t1Tag,cartcomm,nstatus,errcode) - -If(Id3 .NE. 0) call MPI_SEND(phi1(S1:S1+L1-1,S2:S2+L2-1,S3+bb), & - L1*L2*bb,MPI_DOUBLE_PRECISION,bot,d1Tag,cartcomm,errcode) - -If(Id3 .NE. num_subdomain_z-1) call MPI_RECV(phi1(S1:S1+L1-1,S2:S2+L2-1,S3+L3-1), & - L1*L2*bb,MPI_DOUBLE_PRECISION,top,d1Tag,cartcomm,nstatus,errcode) - -RETURN -END SUBROUTINE - -!! =================================================================================== -!! Input subroutine -!! =================================================================================== - -!SUBROUTINE loadLotsFiles(arrIn,name_string,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) -!! Purpose: -!! Write arrIn to an individual file for each core. -!! File has Id1,Id2,Id3 in filename as _XXYYZZ.frt -! -!USE parameters -!IMPLICIT NONE -! -!! Declare variables:--------------------------------------------------------+ -!INTEGER, INTENT(in) :: Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3 -!REAL(KIND=8), DIMENSION(Is1-bb:Ie1+bb,Is2-bb:Ie2+bb,Is3-bb:Ie3+bb) :: arrIn ! Array to load -!CHARACTER(LEN=29) :: filename ! Filename of input or output -!CHARACTER(LEN=5) :: tstring, name_string -!CHARACTER(LEN=2) :: Id1string, Id2string, Id3string -!CHARACTER(LEN=3) :: counter -!INTEGER :: status -!INTEGER :: tpStep, i, outFreq -!!---------------------------------------------------------------------------+ -! -!WRITE(counter,'(I3)') 100+load_from_output -! -!write(Id1string,'(i2.2)')Id1 -!write(Id2string,'(i2.2)')Id2 -!write(Id3string,'(i2.2)')Id3 -! -!filename=name_string//load_from_run//'_'//counter(2:3)//'_'//Id1string//Id2string//Id3string//'.frt' -!!PRINT *,'Filename:', filename -!OPEN (FILE=output_path//filename, UNIT=300, STATUS='UNKNOWN', FORM='UNFORMATTED') -!READ (300) arrIn(Is1:Ie1,Is2:Ie2,Is3:Ie3) -!CLOSE (300) -! -!RETURN -! -!END SUBROUTINE loadLotsFiles - - -!! =================================================================================== -!! Output subroutine -!! =================================================================================== - -SUBROUTINE writeLotsFiles(arrIn,name_string,step,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3) -! Purpose: -! Write arrIn to an individual file for each core. -! File has Id1,Id2,Id3 in filename as _XXYYZZ.frt - -USE parameters -IMPLICIT NONE - -! Declare variables:--------------------------------------------------------+ -INTEGER, INTENT(in) :: Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3 -REAL(KIND=8), DIMENSION(Is1-bb:Ie1+bb,Is2-bb:Ie2+bb,Is3-bb:Ie3+bb), INTENT(IN) :: arrIn ! Array to write -CHARACTER(LEN=29) :: filename ! Filename of input or output -CHARACTER(LEN=5) :: tstring, name_string -CHARACTER(LEN=2) :: Id1string, Id2string, Id3string -CHARACTER(LEN=3) :: counter -INTEGER, INTENT(in) :: step -INTEGER :: tpStep, i, outFreq -!---------------------------------------------------------------------------+ - -WRITE(counter,'(I3)') 100+step - -write(Id1string,'(i2.2)')Id1 -write(Id2string,'(i2.2)')Id2 -write(Id3string,'(i2.2)')Id3 - -filename=name_string//run_num//'_'//counter(2:3)//'_'//Id1string//Id2string//Id3string//'.frt' -OPEN (FILE=output_path//filename, UNIT=300, STATUS='UNKNOWN', FORM='UNFORMATTED') -WRITE (300) arrIn(Is1:Ie1,Is2:Ie2,Is3:Ie3) -CLOSE (300) - -RETURN - -END SUBROUTINE writeLotsFiles - -!! =================================================================================== - -SUBROUTINE writeLotsFiles2(arrIn,name_string,step,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3) -! Purpose: -! Write arrIn to an individual file for each core. -! File has Id1,Id2,Id3 in filename as _XXYYZZ.frt - -USE parameters -IMPLICIT NONE - -! Declare variables:--------------------------------------------------------+ -INTEGER, INTENT(in) :: Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3 -REAL(KIND=8), DIMENSION(Is1:Ie1,Is2:Ie2,Is3:Ie3), INTENT(IN) :: arrIn ! Array to write -CHARACTER(LEN=29) :: filename ! Filename of input or output -CHARACTER(LEN=5) :: tstring, name_string -CHARACTER(LEN=2) :: Id1string, Id2string, Id3string -CHARACTER(LEN=3) :: counter -INTEGER, INTENT(in) :: step -INTEGER :: tpStep, i, outFreq -!---------------------------------------------------------------------------+ - -WRITE(counter,'(I3)') 100+step - -write(Id1string,'(i2.2)')Id1 -write(Id2string,'(i2.2)')Id2 -write(Id3string,'(i2.2)')Id3 - -filename=name_string//run_num//'_'//counter(2:3)//'_'//Id1string//Id2string//Id3string//'.frt' -OPEN (FILE=output_path//filename, UNIT=300, STATUS='UNKNOWN', FORM='UNFORMATTED') -WRITE (300) arrIn(Is1:Ie1,Is2:Ie2,Is3:Ie3) -CLOSE (300) - -RETURN - -END SUBROUTINE writeLotsFiles2 - -!! ================================================================================================= - -SUBROUTINE outputVector(vector,outName,length) -USE parameters -IMPLICIT NONE -INTEGER :: length, outNum -REAL(KIND=8),DIMENSION(1:length) :: vector -CHARACTER(LEN=8) :: outName -CHARACTER(LEN=12) :: filename - -!! This subroutine outputs arrays of length "length" to file. - -WRITE(filename, '(A8,A4)') outName,'.dat' -OPEN(UNIT=300,FILE=output_path//filename,FORM='FORMATTED',ACTION='WRITE') -WRITE(300,'(E25.12)') vector -CLOSE(300) - -END SUBROUTINE outputVector - -!! ================================================================================================= - -!SUBROUTINE loadVector(vector,outName,length) -!USE parameters -!IMPLICIT NONE -!INTEGER :: length, outNum -!REAL(KIND=8),DIMENSION(1:length) :: vector -!CHARACTER(LEN=8) :: outName -!CHARACTER(LEN=12) :: filename -! -!!! This subroutine outputs arrays of length "length" to file. -! -!WRITE(filename, '(A8,A4)') outName,'.dat' -!OPEN(UNIT=300,FILE=output_path//filename,FORM='FORMATTED',ACTION='READ') -!READ(300,'(E25.12)') vector -!CLOSE(300) -! -!END SUBROUTINE loadVector - -!! ================================================================================================= - -SUBROUTINE outputDomainInfo() -USE parameters -IMPLICIT NONE - -CHARACTER(LEN=3) :: counter -CHARACTER(LEN=18) :: filename - -!! This subroutine outputs the dimensions of the domain and the number of subdomains - -WRITE(filename, '(A11,A3,A4)') 'domain_info',run_num,'.frt' -OPEN(UNIT=20,FILE=output_path//filename,ACTION='WRITE') -WRITE(20,*) xg -WRITE(20,*) yg -WRITE(20,*) zg -WRITE(20,*) num_subdomain_x -WRITE(20,*) num_subdomain_y -WRITE(20,*) num_subdomain_z -CLOSE(20) - -END SUBROUTINE - - diff --git a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/finite_difference_AC/parameters.mod b/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/finite_difference_AC/parameters.mod deleted file mode 100644 index eee0a152c..000000000 Binary files a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/finite_difference_AC/parameters.mod and /dev/null differ diff --git a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/main.cc b/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/main.cc deleted file mode 100644 index 82ace544a..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/main.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/parameters.h b/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/parameters.h deleted file mode 100644 index d6c4c7fed..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/parameters.h +++ /dev/null @@ -1,41 +0,0 @@ -// Parameter list for the Beta Prime precipitate evolution problem -//(Coupled Allen Cahn, Cahn Hilliard and Mechanics formulation) -// The free energy expressions in this file are from the reference: -// H. Liu et al, "A simulation study of the shape of beta prime precipitates in -// Mg–Y and Mg–Gd alloys", Acta Materialia, Volume 61, Issue 2, January 2013, -// Pages 453-466. http://dx.doi.org/10.1016/j.actamat.2012.09.044 - -// Define problem dimensions -#define problemDIM 3 -#define spanX 100.0 -#define spanY 100.0 -#define spanZ 100.0 - -// Define mesh parameters -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 7 -#define finiteElementDegree 1 - -// define number of fields in the problem -// n -#define numFields 1 - -// define time step parameters -#define timeStep 1.0e-3 -#define timeFinal 20.0 -#define timeIncrements 30000 - -// define results output parameters -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 1 - -#define calcEnergy false diff --git a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/residuals.h b/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/residuals.h deleted file mode 100644 index 3932a8592..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/AC_speed_comparison/residuals.h +++ /dev/null @@ -1,112 +0,0 @@ -// Definition of the variables in the model -#define num_var 1 -#define variable_name \ - { \ - "n" \ - } -#define variable_type \ - { \ - "SCALAR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC" \ - } -#define need_val \ - { \ - true \ - } -#define need_grad \ - { \ - true \ - } -#define need_hess \ - { \ - false \ - } -#define need_val_residual \ - { \ - true \ - } -#define need_grad_residual \ - { \ - true \ - } - -// define Allen-Cahn parameters -#define MnV 1.0 -#define KnV 4.0 - -// define the free energy and its derivative with respect to n -#define fV (n * n * n * n - 2.0 * n * n * n + n * n) -#define fnV (4.0 * n * (n - 1.0) * (n - 0.5)) - -// Define required residuals -#define rnV (n - constV(timeStep * MnV) * fnV) -#define rnxV (constV(-timeStep * KnV * MnV) * nx) - -// --------------------------------------------- - -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // n - scalarvalueType n = modelVariablesList[0].scalarValue; - scalargradType nx = modelVariablesList[0].scalarGrad; - - modelResidualsList[0].scalarValueResidual = rnV; - modelResidualsList[0].scalarGradResidual = rnxV; -} - -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVarList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{} - -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - scalarvalueType total_energy_density = constV(0.0); - - // n - scalarvalueType n = modelVarList[0].scalarValue; - scalargradType nx = modelVarList[0].scalarGrad; - - scalarvalueType f_chem = fV; - - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * KnV) * nx[i] * nx[j]; - } - } - - total_energy_density = f_chem + f_grad; - - assembler_lock.acquire(); - for (unsigned i = 0; i < n.size(); i++) - { - // For some reason, some of the values in this loop - if (n[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/CMakeLists.txt b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/ICs_and_BCs.h b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/ICs_and_BCs.h deleted file mode 100644 index cf1610f2a..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/ICs_and_BCs.h +++ /dev/null @@ -1,144 +0,0 @@ -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - double avg_c = 0.02; - double initial_radius = 1.0; - double x_denom = 36.0; - double y_denom = 36.0; - double z_denom = 16.0; - double initial_interface_coeff = 0.5; - - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double r = 0.0; - - // Initial condition for the concentration field - if (index == 0) - { - // return the value of the initial concentration field at point p - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double r = 0.0; -#if problemDIM == 1 - r = p[0]; - return 0.005 + - 0.5 * (0.125 - 0.005) * (1 - std::tanh((r - spanX / 2.0) / (3 * dx))); -#elif problemDIM == 2 - r = p.distance(Point(spanX / 2.0, spanY / 2.0)); - return 0.005 + - 0.5 * (0.125 - 0.005) * (1 - std::tanh((r - spanX / 8.0) / (3 * dx))); -#elif problemDIM == 3 - r = sqrt( - (p.operator()(0) - spanX / 2.0) * (p.operator()(0) - spanX / 2.0) / x_denom + - (p.operator()(1) - spanY / 2.0) * (p.operator()(1) - spanY / 2.0) / y_denom + - (p.operator()(2) - spanZ / 2.0) * (p.operator()(2) - spanZ / 2.0) / z_denom); - return 0.5 * (0.12 - avg_c) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_c; -#endif - } - // Initial condition for the structural order parameter field - else - { - // return the value of the initial order parameter field at point p - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double r = 0.0; -#if problemDIM == 1 - r = p[0]; - return 0.5 * (1.0 - std::tanh((r - spanX / 2.0) / (6.2 * dx))); -#elif problemDIM == 2 - r = p.distance(Point(spanX / 2.0, spanY / 2.0)); - return 0.5 * (1.0 - std::tanh((r - spanX / 8.0) / (3 * dx))); -#elif problemDIM == 3 - - r = sqrt( - (p.operator()(0) - spanX / 2.0) * (p.operator()(0) - spanX / 2.0) / x_denom + - (p.operator()(1) - spanY / 2.0) * (p.operator()(1) - spanY / 2.0) / y_denom + - (p.operator()(2) - spanZ / 2.0) * (p.operator()(2) - spanZ / 2.0) / z_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - -#endif - } - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // ===================================================================== - } -}; - -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") - // Fourth input: BC value (ignored unless the BC type is "DIRICHLET") - // Odd inputs after the third: BC type - // Even inputs after the third: BC value - // Face numbering: starts at zero with the minimum of the first direction, one - // for the maximum of the first direction - // two for the minimum of the second direction, etc. - - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - inputBCs(1, 0, "ZERO_DERIVATIVE", 0); - - // ===================================================================== -} diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/equations.h b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/equations.h deleted file mode 100644 index 22736b41b..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/equations.h +++ /dev/null @@ -1,204 +0,0 @@ -// List of variables and residual equations for the coupled -// Allen-Cahn/Cahn-Hilliard example application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 2 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "c", "n" \ - } -#define variable_type \ - { \ - "SCALAR", "SCALAR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC", "PARABOLIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - true, true \ - } -#define need_grad \ - { \ - true, true \ - } -#define need_hess \ - { \ - false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - true, true \ - } -#define need_grad_residual \ - { \ - true, true \ - } - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Cahn-Hilliard mobility -#define McV 1.0 - -// Allen-Cahn mobility -#define MnV 5.0 - -// Allen-Cahn gradient energy coefficient -#define KnV 0.5 - -// Free energy for each phase and they're first and second derivatives -#define faV (24.7939 * c * c - 1.6752 * c - 1.9453e-06) -#define facV (49.5878 * c - 1.6752) -#define faccV (49.5878) -#define fbV (37.9316 * c * c - 10.7373 * c + 0.5401) -#define fbcV (75.8633 * c - 10.7373) -#define fbccV (75.8633) - -// Interpolation function and its derivative -#define hV (3.0 * n * n - 2.0 * n * n * n) -#define hnV (6.0 * n - 6.0 * n * n) - -// Residual equations -#define muxV (cx * ((1.0 - hV) * faccV + hV * fbccV) + nx * ((fbcV - facV) * hnV)) -#define rcV (c) -#define rcxV (constV(-McV * timeStep) * muxV) -#define rnV (n - constV(timeStep * MnV) * (fbV - faV) * hnV) -#define rnxV (constV(-timeStep * KnV * MnV) * nx) - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // The concentration and its derivatives (names here should match those in the - // macros above) - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - // The order parameter and its derivatives (names here should match those in - // the macros above) - scalarvalueType n = modelVariablesList[1].scalarValue; - scalargradType nx = modelVariablesList[1].scalarGrad; - - // Residuals for the equation to evolve the concentration (names here should - // match those in the macros above) - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; - - // Residuals for the equation to evolve the order parameter (names here should - // match those in the macros above) - modelResidualsList[1].scalarValueResidual = rnV; - modelResidualsList[1].scalarGradResidual = rnxV; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVariablesList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVariablesList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - // The concentration and its derivatives (names here should match those in the - // macros above) - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - // The order parameter and its derivatives (names here should match those in - // the macros above) - scalarvalueType n = modelVariablesList[1].scalarValue; - scalargradType nx = modelVariablesList[1].scalarGrad; - - // The homogenous free energy - scalarvalueType f_chem = (constV(1.0) - hV) * faV + hV * fbV; - - // The gradient free energy - scalarvalueType f_grad = constV(0.5 * KnV) * nx * nx; - - // The total free energy - scalarvalueType total_energy_density; - total_energy_density = f_chem + f_grad; - - // Loop to step through each element of the vectorized arrays. Working with - // deal.ii developers to see if there is a more elegant way to do this. - assembler_lock.acquire(); - for (unsigned i = 0; i < c.size(); i++) - { - if (c[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/CHAC_finite_difference.f90 b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/CHAC_finite_difference.f90 deleted file mode 100644 index fb08f5eb2..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/CHAC_finite_difference.f90 +++ /dev/null @@ -1,1048 +0,0 @@ -MODULE parameters -IMPLICIT NONE -SAVE - - CHARACTER(LEN=3), PARAMETER :: run_num = '064' - CHARACTER(LEN=0), PARAMETER :: output_path = '' - - INTEGER, PARAMETER :: num_outputs = 10 - - !! Grid size - - - REAL(KIND=8), PARAMETER :: domain_size_x = 64.0d0 - REAL(KIND=8), PARAMETER :: domain_size_y = 64.0d0 - REAL(KIND=8), PARAMETER :: domain_size_z = 64.0d0 - - INTEGER, PARAMETER :: xg = 128 - INTEGER, PARAMETER :: yg = 128 - INTEGER, PARAMETER :: zg = 128 - - INTEGER, PARAMETER :: bb = 1 - - REAL(KIND=8), PARAMETER :: dz = domain_size_z/DBLE(zg) !! Grid spacing (nm) - REAL(KIND=8), PARAMETER :: dx = domain_size_x/DBLE(xg) !! Grid spacing (nm) - REAL(KIND=8), PARAMETER :: dy = domain_size_y/DBLE(yg) !! Grid spacing (nm) - - !! The number of subdomains in each direction for MPI - INTEGER, PARAMETER :: num_subdomain_x = 2 - INTEGER, PARAMETER :: num_subdomain_y = 2 - INTEGER, PARAMETER :: num_subdomain_z = 1 - - !! Particle initialization - REAL(KIND=8), PARAMETER :: particle_x = domain_size_x/2.0d0 !! nm - REAL(KIND=8), PARAMETER :: particle_y = domain_size_y/2.0d0 !! nm - REAL(KIND=8), PARAMETER :: particle_z = domain_size_z/2.0d0 !! nm - REAL(KIND=8), PARAMETER :: rad = 1.0d0 !! nm - - - !! Phase field constants - - REAL(KIND=8), PARAMETER :: A_alpha = 24.7939d0 - REAL(KIND=8), PARAMETER :: B_alpha = -1.6752d0 - REAL(KIND=8), PARAMETER :: C_alpha = -1.9453d-6 - REAL(KIND=8), PARAMETER :: A_beta = 37.9316d0 - REAL(KIND=8), PARAMETER :: B_beta = -10.7373d0 - REAL(KIND=8), PARAMETER :: C_beta = 0.5401d0 - - REAL(KIND=8), PARAMETER :: M = 1.0d0 - REAL(KIND=8), PARAMETER :: L = 5.0d0 - REAL(KIND=8), PARAMETER :: kappa_x = 0.5d0 - REAL(KIND=8), PARAMETER :: kappa_y = 0.5d0 - REAL(KIND=8), PARAMETER :: kappa_z = 0.5d0 - - REAL(KIND=8), PARAMETER :: avg_Nd = 0.02d0 - REAL(KIND=8), PARAMETER :: delta = 0.5d0 - - REAL(KIND=8), PARAMETER :: pi = ACOS(-1.0d0) - - INTEGER, PARAMETER :: max_iter = 50000 - REAL(KIND=8), PARAMETER :: dt = 3.0d-4 !! seconds - - !! Tags for MPI communication - INTEGER, PARAMETER :: c1Tag=91,c2Tag=92,c3Tag=93,c4Tag=94, pTag=95 - INTEGER, PARAMETER :: r1Tag=101,l1Tag=102,f1Tag=103,b1Tag=104,t1Tag=105,d1Tag=106 - INTEGER, PARAMETER :: r2Tag=111,l2Tag=112,f2Tag=113,b2Tag=114,t2Tag=115,d2Tag=116 - INTEGER, PARAMETER :: Sr1Req=81,Sl1Req=82,Sf1Req=83,Sb1Req=84,St1Req=85,Sd1Req=86 - INTEGER, PARAMETER :: Rr1Req=71,Rl1Req=72,Rf1Req=73,Rb1Req=74,Rt1Req=75,Rd1Req=76 - INTEGER, PARAMETER :: Sr2Req=61,Sl2Req=62,Sf2Req=63,Sb2Req=64,St2Req=65,Sd2Req=66 - INTEGER, PARAMETER :: Rr2Req=51,Rl2Req=52,Rf2Req=53,Rb2Req=54,Rt2Req=55,Rd2Req=56 - -END MODULE parameters - -!! CHAC_finite_difference: This program solves the coupled Cahn-Hilliard-Allen-Cahn system -!! of equations. It was developed for comparison to the PRISMS-PF finite element code to -!! ensure that its performance was competitive with finite difference. -!! -!! Author: Stephen DeWitt (stvdwtt@umich.edu) -!! Date Started: 1/6/2016 -!! -!! ============================================================================= - -PROGRAM CHAC_finite_difference -USE parameters -IMPLICIT NONE - -INCLUDE 'mpif.h' -INTEGER :: len -CHARACTER(MPI_MAX_PROCESSOR_NAME) :: hostname - -INTEGER errcode -INTEGER rank, nsize -INTEGER :: dims(1:3),coord(1:3),left,right,front,back,top,bot,ndims,cartcomm -LOGICAL :: reorder,periodic(1:3) -INTEGER L1, L2, L3, S1, S2, S3, Id1, Id2, Id3, Rm1, Rm2, Rm3 - -CALL outputDomainInfo() - -!! Starting the MPI section of the code - -CALL MPI_INIT (errcode) - -CALL MPI_COMM_RANK (MPI_COMM_WORLD, rank, errcode) -CALL MPI_COMM_SIZE (MPI_COMM_WORLD, nsize, errcode) -CALL MPI_GET_PROCESSOR_NAME(hostname, len, errcode) - -IF (rank .eq. 0) PRINT *, 'number of partitions', num_subdomain_x*num_subdomain_y*num_subdomain_z - -!! Start off by partitioning the domain - -!! Number of dimensions (for the MPI Cartesian communicator) -ndims = 3 - -!! Set the number of partitions in each direction -dims(1) = num_subdomain_x -dims(2) = num_subdomain_y -dims(3) = num_subdomain_z - -periodic(1) = .TRUE. -periodic(2) = .TRUE. -periodic(3) = .FALSE. -reorder = .true. - -!! Create the Cartesian communicator -call MPI_CART_CREATE(MPI_COMM_WORLD,ndims,dims,periodic,reorder,cartcomm,errcode) -!PRINT *, 'rank', rank, 'cartcomm', cartcomm - -!! Calculate the non-ghost-zone length of each partition (L#) and the remaining grid points (Rm#) -L1 = floor(xg/real(num_subdomain_x)) -Rm1 = mod(xg,num_subdomain_x) - -L2 = floor(yg/real(num_subdomain_y)) -Rm2 = mod(yg,num_subdomain_y) - -L3 = floor(zg/real(num_subdomain_z)) -Rm3 = mod(zg,num_subdomain_z) - -!! Get coordinates of each partition using MPI_CART_COORDS -call MPI_CART_COORDS(cartcomm,rank,ndims,coord,errcode) - -!! The index of the partition in all three directions -Id3 = coord(3) -Id2 = coord(2) -Id1 = coord(1) - -!! Defines the 6 neighbor partitions -call MPI_CART_SHIFT(cartcomm,0,1,left,right,errcode) !+/- x shifts are left/right -call MPI_CART_SHIFT(cartcomm,1,1,front,back,errcode) !+/- y shifts are front/back -call MPI_CART_SHIFT(cartcomm,2,1,bot,top,errcode) !+/- z shifts are top/bottom - -!! Find the starting point for each partition with respect to the global array location (S#), also find the length of each partition (L#) -if(Id1 == 0)then ! starting point of domain is set to 1, end point is n1 - S1 = 1-bb - L1=L1+2*bb -elseif(Id1 == num_subdomain_x-1)then - S1 = Id1*L1+1-bb - L1 = L1+2*bb+Rm1 -else - S1 = Id1*L1+1-bb - L1= L1+2*bb -endif -if(Id2 == 0)then ! starting point of domain is set to 1, end point is n1 - S2 = 1-bb - L2= L2+2*bb -elseif(Id2 == num_subdomain_y-1)then - S2 = Id2*L2+1-bb - L2 = L2+2*bb+Rm2 -else - S2 = Id2*L2+1-bb - L2 = L2+2*bb -endif -if(Id3 == 0)then ! starting point of domain is set to 1, end point is n1 - S3 = 1-bb - L3= L3+2*bb -elseif(Id3 == num_subdomain_z-1)then - S3 = Id3*L3+1-bb - L3 = L3+2*bb+Rm3 -else - S3 = Id3*L3+1-bb - L3= L3+2*bb -endif - -CALL main_subroutine(Id1,Id2,Id3,S1,S2,S3,L1,L2,L3,left,right,front,back,top,bot,cartcomm) - -CALL MPI_FINALIZE(errcode) - - -END PROGRAM - -!! =================================================================================== -!! Main subroutine where most of the calculations are done -!! =================================================================================== - -SUBROUTINE main_subroutine(Id1,Id2,Id3,S1,S2,S3,L1,L2,L3,left,right,front,back,top,bot,cartcomm) -USE parameters -IMPLICIT NONE - -INCLUDE 'mpif.h' -INTEGER :: L1, L2, L3, S1, S2, S3, Id1, Id2, Id3, Is1, Is2, Is3, Ie1, Ie2, Ie3, k, iter -INTEGER :: left,right,front,back,top,bot, cartcomm -REAL(KIND=8), DIMENSION(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) :: c, eta, x, y, z -REAL(KIND=8) :: time_elapsed, dist_particle -INTEGER :: i,j, out_num, output_crit -INTEGER :: errcode -CHARACTER(len=3) :: counter - -out_num = 0 - -time_elapsed = 0.0d0 - -!! Real grid points inside the subdomain (without ghost cells) -Is1 = S1 + bb -Ie1 = S1 + L1 - 1 - bb -Is2 = S2 + bb -Ie2 = S2 + L2 - 1 - bb -Is3 = S3 + bb -Ie3 = S3 + L3 - 1 - bb - -!! Initialize the fields - -DO k = Is3-1,Ie3+1 -DO j = Is2-1,Ie2+1 -DO i = Is1-1,Ie1+1 - - x(i,j,k) = dx * DBLE(i) -dx/2.0d0 - y(i,j,k) = dy * DBLE(j) -dy/2.0d0 - z(i,j,k) = dz * DBLE(k) -dz/2.0d0 - - !! Distance functions for spherical particles - !dist_particle = SQRT(DBLE((particle_1_x-x(i,j,k))**2)+DBLE((particle_1_y-y(i,j,k))**2)+DBLE((particle_1_z-z(i,j,k))**2)) - - !! Distance functions for ellipsoidal particles (squished in z direction) - dist_particle = SQRT(DBLE((particle_x-x(i,j,k))**2)/36.0d0 + DBLE((particle_y-y(i,j,k))**2)/36.0d0 & - + DBLE( ((particle_z-z(i,j,k)))**2)/16.0d0 ) - - !! Flat interface - !dist_particle = SQRT((particle_z-z(i,j,k))**2) - - !! 3D Sphere - eta(i,j,k) = 0.5d0*(1.0d0 - ( TANH( (dist_particle - rad)/delta ))) - c(i,j,k) = 0.5d0*(0.12d0-avg_Nd) * (1.0d0 - ( TANH( ( dist_particle - rad )/delta ))) + avg_Nd - -END DO -END DO -END DO - -!! Apply boundary conditions -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,c,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(c,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,eta,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - -!! Initial Outputs -IF (Id1+Id2+Id3.eq. 0) PRINT *, 'Time step: ', dt -CALL writeLotsFiles(c,'con_r',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) -CALL writeLotsFiles(eta,'eta_r',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) -CALL writeLotsFiles(x,'xgrid',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) -CALL writeLotsFiles(y,'ygrid',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) -CALL writeLotsFiles(z,'zgrid',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) - - -out_num = out_num + 1 - - -!! ------------------------------------------------------------------------- -!! Iterate through time -!! ------------------------------------------------------------------------- - -DO iter = 1,max_iter - - CALL simultaneous_CHAC_solver(c,eta,S1,S2,S3,L1,L2,L3,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3, & - left,right,front,back,top,bot,cartcomm) - - - !CALL cahnhilliard_solver_explicit(c,eta,S1,S2,S3,L1,L2,L3,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3, & -! left,right,front,back,top,bot,cartcomm) - - !! Check to see if c contains a NAN - IF (ANY(ISNAN(c))) THEN - PRINT *, 'Error: Element in c is NAN' - STOP - END IF - - !CALL allenCahn_solver_explicit(c,eta,S1,S2,S3,L1,L2,L3,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3, & -! left,right,front,back,top,bot,cartcomm) - - IF (ANY(ISNAN(eta))) THEN - PRINT *, 'Error: Element in eta is NAN' - STOP - END IF - - time_elapsed = time_elapsed + dt - - !! ------------------------------------------------------------------------- - !! Output files - IF (max_iter <= num_outputs) THEN - output_crit = 0 - ELSE - output_crit = MOD(iter,max_iter/num_outputs) - END IF - - IF (output_crit == 0) THEN - IF (Id1 .eq. 0 .and. Id2 .eq. 0 .and. Id3 .eq. 0) PRINT *, 'Output number ', out_num, ' complete' - - - CALL writeLotsFiles(c,'con_r',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) - CALL writeLotsFiles(eta,'eta_r',out_num,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) - - out_num = out_num + 1 - - END IF - -END DO - -IF (Id1+Id2+Id3.eq. 0) PRINT *, 'Total time elapsed: ', max_iter*dt - -END SUBROUTINE - -!! =================================================================================== -!! Explicit Combined Cahn-Hilliard Allen-Cahn Solver -!! =================================================================================== - -SUBROUTINE simultaneous_CHAC_solver(c,eta,S1,S2,S3,L1,L2,L3,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3, & - left,right,front,back,top,bot,cartcomm) -USE parameters -IMPLICIT NONE - -INCLUDE 'mpif.h' -INTEGER :: L1, L2, L3, S1, S2, S3, Id1, Id2, Id3, Is1, Is2, Is3, Ie1, Ie2, Ie3 -INTEGER :: left,right,front,back,top,bot, cartcomm -REAL(KIND=8), DIMENSION(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) :: c, eta, mu, H, dHdeta -REAL(KIND=8), DIMENSION(S1+1:S1+L1-2,S2+1:S2+L2-2,S3+1:S3+L3-2) :: Lap_mu, kappa_Lap_eta - -H = 3.0d0*eta*eta - 2.0d0*eta*eta*eta -mu = (2.0d0*A_alpha*c + B_alpha)*(1.0d0-H) + (2.0d0*A_beta*c + B_beta)*H - -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,mu,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(mu,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - -Lap_mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) = (mu(Is1+1:Ie1+1,Is2:Ie2,Is3:Ie3) - 2.0d0*mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + mu(Is1-1:Ie1-1,Is2:Ie2,Is3:Ie3))/dx**2 & - + (mu(Is1:Ie1,Is2+1:Ie2+1,Is3:Ie3) - 2.0d0*mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + mu(Is1:Ie1,Is2-1:Ie2-1,Is3:Ie3))/dy**2 & - + (mu(Is1:Ie1,Is2:Ie2,Is3+1:Ie3+1) - 2.0d0*mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + mu(Is1:Ie1,Is2:Ie2,Is3-1:Ie3-1))/dz**2 - -dHdeta = 6.0d0*eta - 6.0d0*eta*eta - -kappa_Lap_eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) = kappa_x*(eta(Is1+1:Ie1+1,Is2:Ie2,Is3:Ie3) - 2.0d0*eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + eta(Is1-1:Ie1-1,Is2:Ie2,Is3:Ie3))/dx**2 & - + kappa_y*(eta(Is1:Ie1,Is2+1:Ie2+1,Is3:Ie3) - 2.0d0*eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + eta(Is1:Ie1,Is2-1:Ie2-1,Is3:Ie3))/dy**2 & - + kappa_z*(eta(Is1:Ie1,Is2:Ie2,Is3+1:Ie3+1) - 2.0d0*eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + eta(Is1:Ie1,Is2:Ie2,Is3-1:Ie3-1))/dz**2 - -eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) = eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - - dt * L * ( ((A_beta*c(Is1:Ie1,Is2:Ie2,Is3:Ie3)**2 + B_beta*c(Is1:Ie1,Is2:Ie2,Is3:Ie3) + C_beta) & - - (A_alpha*c(Is1:Ie1,Is2:Ie2,Is3:Ie3)**2 + B_alpha*c(Is1:Ie1,Is2:Ie2,Is3:Ie3) + C_alpha))*dHdeta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - - kappa_Lap_eta) - -c(Is1:Ie1,Is2:Ie2,Is3:Ie3) = c(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + dt*M*Lap_mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) - -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,c,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(c,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,eta,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - - -END SUBROUTINE simultaneous_CHAC_solver - -!! =================================================================================== -!! Explicit Cahn-Hilliard Solver -!! =================================================================================== - -SUBROUTINE cahnhilliard_solver_explicit(c,eta,S1,S2,S3,L1,L2,L3,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3, & - left,right,front,back,top,bot,cartcomm) -USE parameters -IMPLICIT NONE - -INCLUDE 'mpif.h' -INTEGER :: L1, L2, L3, S1, S2, S3, Id1, Id2, Id3, Is1, Is2, Is3, Ie1, Ie2, Ie3 -INTEGER :: left,right,front,back,top,bot, cartcomm -REAL(KIND=8), DIMENSION(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) :: c, eta, mu, H -REAL(KIND=8), DIMENSION(S1+1:S1+L1-2,S2+1:S2+L2-2,S3+1:S3+L3-2) :: Lap_mu - -H = 3.0d0*eta*eta - 2.0d0*eta*eta*eta -mu = (2.0d0*A_alpha*c + B_alpha)*(1.0d0-H) + (2.0d0*A_beta*c + B_beta)*H - -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,mu,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(mu,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(mu,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - -Lap_mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) = (mu(Is1+1:Ie1+1,Is2:Ie2,Is3:Ie3) - 2.0d0*mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + mu(Is1-1:Ie1-1,Is2:Ie2,Is3:Ie3))/dx**2 & - + (mu(Is1:Ie1,Is2+1:Ie2+1,Is3:Ie3) - 2.0d0*mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + mu(Is1:Ie1,Is2-1:Ie2-1,Is3:Ie3))/dy**2 & - + (mu(Is1:Ie1,Is2:Ie2,Is3+1:Ie3+1) - 2.0d0*mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + mu(Is1:Ie1,Is2:Ie2,Is3-1:Ie3-1))/dz**2 - -c(Is1:Ie1,Is2:Ie2,Is3:Ie3) = c(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + dt*M*Lap_mu(Is1:Ie1,Is2:Ie2,Is3:Ie3) - -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,c,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(c,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(c,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - - -END SUBROUTINE cahnhilliard_solver_explicit - -!! =================================================================================== -!! Explicit Allen-Cahn Solver -!! =================================================================================== - -SUBROUTINE allenCahn_solver_explicit(c,eta,S1,S2,S3,L1,L2,L3,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3, & - left,right,front,back,top,bot,cartcomm) -USE parameters -IMPLICIT NONE - -INCLUDE 'mpif.h' -INTEGER :: L1, L2, L3, S1, S2, S3, Id1, Id2, Id3, Is1, Is2, Is3, Ie1, Ie2, Ie3 -INTEGER :: left,right,front,back,top,bot, cartcomm -REAL(KIND=8), DIMENSION(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) :: c, eta, mu, dHdeta -REAL(KIND=8), DIMENSION(S1+1:S1+L1-2,S2+1:S2+L2-2,S3+1:S3+L3-2) :: kappa_Lap_eta - -dHdeta = 6.0d0*eta - 6.0d0*eta*eta - -kappa_Lap_eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) = kappa_x*(eta(Is1+1:Ie1+1,Is2:Ie2,Is3:Ie3) - 2.0d0*eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + eta(Is1-1:Ie1-1,Is2:Ie2,Is3:Ie3))/dx**2 & - + kappa_y*(eta(Is1:Ie1,Is2+1:Ie2+1,Is3:Ie3) - 2.0d0*eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + eta(Is1:Ie1,Is2-1:Ie2-1,Is3:Ie3))/dy**2 & - + kappa_z*(eta(Is1:Ie1,Is2:Ie2,Is3+1:Ie3+1) - 2.0d0*eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - + eta(Is1:Ie1,Is2:Ie2,Is3-1:Ie3-1))/dz**2 - -eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) = eta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - - dt * L * ( ((A_beta*c(Is1:Ie1,Is2:Ie2,Is3:Ie3)**2 + B_beta*c(Is1:Ie1,Is2:Ie2,Is3:Ie3) + C_beta) & - - (A_alpha*c(Is1:Ie1,Is2:Ie2,Is3:Ie3)**2 + B_alpha*c(Is1:Ie1,Is2:Ie2,Is3:Ie3) + C_alpha))*dHdeta(Is1:Ie1,Is2:Ie2,Is3:Ie3) & - - kappa_Lap_eta) - -call commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,eta,left,right,front,back,top,bot,cartcomm) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,1,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,2,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -CALL external_BCs_Zero_Derivative(eta,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - - -END SUBROUTINE allenCahn_solver_explicit - - -!! =================================================================================== - -SUBROUTINE applyBCs(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,phi1,U_BC_top,left,right,front,back,top,bot,cartcomm,direction) -use parameters -implicit none -INCLUDE 'mpif.h' - -INTEGER S1, S2, S3, Id1, Id2, Id3,L1,L2,L3 -INTEGER :: left,right,front,back,top,bot,cartcomm !ranks of processors to shift to and cartcomm -INTEGER :: i,j,k, direction -INTEGER :: errcode -REAL(KIND=8) :: phi1(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1), U_BC_top -INTEGER,DIMENSION(MPI_STATUS_SIZE) :: nstatus - -REAL(KIND=8), DIMENSION(1:L2,1:L3) :: Buffer_x1, Buffer_x2, Buffer_x3, Buffer_x4 -REAL(KIND=8), DIMENSION(1:L1,1:L3) :: Buffer_y1, Buffer_y2, Buffer_y3, Buffer_y4 -REAL(KIND=8), DIMENSION(1:L1,1:L2) :: Buffer_z1, Buffer_z2, Buffer_z3, Buffer_z4 -INTEGER,DIMENSION(12) :: req - -!! Communication in n1 direction - -IF ( direction .EQ. 0 .OR. direction .EQ. 1 ) THEN - - ! x-direction - Buffer_x3 = phi1(S1+L1-1-bb,S2:S2+L2-1,S3:S3+L3-1) - Buffer_x2 = phi1(S1+bb,S2:S2+L2-1,S3:S3+L3-1) - - CALL MPI_iSEND(Buffer_x3,L2*L3,MPI_DOUBLE_PRECISION,right,r1Tag,cartcomm,req(1),errcode) - CALL MPI_iRECV(Buffer_x4,L2*L3,MPI_DOUBLE_PRECISION,right,l1Tag,cartcomm,req(2),errcode) - CALL MPI_iSEND(Buffer_x2,L2*L3,MPI_DOUBLE_PRECISION,left ,l1Tag,cartcomm,req(4),errcode) - CALL MPI_iRECV(Buffer_x1,L2*L3,MPI_DOUBLE_PRECISION,left ,r1Tag,cartcomm,req(3),errcode) - call MPI_waitall(4,req(1:4),MPI_STATUS_IGNORE,errcode) - - phi1(S1,S2:S2+L2-1,S3:S3+L3-1) = Buffer_x1 - phi1(S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) = Buffer_x4 - -ENDIF - -!! Communication in n2 direction - -IF ( direction .EQ. 0 .OR. direction .EQ. 2 ) THEN - ! y-direction - Buffer_y3 = phi1(S1:S1+L1-1,S2+L2-1-bb,S3:S3+L3-1) - Buffer_y2 = phi1(S1:S1+L1-1,S2+bb,S3:S3+L3-1) - CALL MPI_iSEND(Buffer_y3,L1*L3,MPI_DOUBLE_PRECISION,back ,b1Tag,cartcomm,req(5),errcode) - CALL MPI_iRECV(Buffer_y4,L1*L3,MPI_DOUBLE_PRECISION,back ,f1Tag,cartcomm,req(6),errcode) - CALL MPI_iSEND(Buffer_y2,L1*L3,MPI_DOUBLE_PRECISION,front,f1Tag,cartcomm,req(8),errcode) - CALL MPI_iRECV(Buffer_y1,L1*L3,MPI_DOUBLE_PRECISION,front,b1Tag,cartcomm,req(7),errcode) - call MPI_waitall(4,req(5:8),MPI_STATUS_IGNORE,errcode) - phi1(S1:S1+L1-1,S2,S3:S3+L3-1) = Buffer_y1 - phi1(S1:S1+L1-1,S2+L2-1,S3:S3+L3-1) = Buffer_y4 - -ENDIF - -!! Communication in n3 direction - -IF ( direction .EQ. 0 .OR. direction .EQ. 3 ) THEN - ! z-direction - Buffer_z3=phi1(S1:S1+L1-1,S2:S2+L2-1,S3+L3-1-bb) - Buffer_z2=phi1(S1:S1+L1-1,S2:S2+L2-1,S3+bb) - IF ( Id3 .NE. num_subdomain_z-1 ) THEN - CALL MPI_iSEND(Buffer_z3,L1*L2,MPI_DOUBLE_PRECISION,top,t1Tag,cartcomm,req(9),errcode) - CALL MPI_iRECV(Buffer_z4,L1*L2,MPI_DOUBLE_PRECISION,top,b1Tag,cartcomm,req(10),errcode) - ELSE - !CALL external_BCs_Dirichlet(phi1,U_BC_top,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - Buffer_z4 = U_BC_top - ENDIF - - IF ( Id3 .NE. 0 ) THEN - CALL MPI_iSEND(Buffer_z2,L1*L2,MPI_DOUBLE_PRECISION,bot,b1Tag,cartcomm,req(12),errcode) - CALL MPI_iRECV(Buffer_z1,L1*L2,MPI_DOUBLE_PRECISION,bot,t1Tag,cartcomm,req(11),errcode) - ELSE - !CALL external_BCs_Zero_Derivative(phi1,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - Buffer_z1 = phi1(S1:S1+L1-1,S2:S2+L2-1,S3+bb) - ENDIF - - IF ( Id3 .NE. num_subdomain_z-1 ) call MPI_waitall(2,req(9:10),MPI_STATUS_IGNORE,errcode) - IF ( Id3 .NE. 0 ) call MPI_waitall(2,req(11:12),MPI_STATUS_IGNORE,errcode) - phi1(S1:S1+L1-1,S2:S2+L2-1,S3)=Buffer_z1 - phi1(S1:S1+L1-1,S2:S2+L2-1,S3+L3-1)=Buffer_z4 - -ENDIF - -!! External BCs in the z-direction -!CALL external_BCs_Dirichlet(phi1,U_BC_top,.TRUE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) -!CALL external_BCs_Zero_Derivative(phi1,.FALSE.,3,Id1,Id2,Id3,L1-2,L2-2,L3-2) - -RETURN -END SUBROUTINE applyBCs - -!! =================================================================================== -!! External BC calculation subroutines -!! =================================================================================== - -SUBROUTINE external_BCs_Dirichlet(array,BC_value,is_top,dimension_num,Id1,Id2,Id3,px,py,pz) -USE parameters -IMPLICIT NONE - -INTEGER :: px, py, pz -REAL(KIND=8), DIMENSION(0:px+1,0:py+1,0:pz+1) :: array -REAL(KIND=8) :: BC_value -INTEGER :: dimension_num,Id1,Id2,Id3 -LOGICAL :: is_top - -SELECT CASE (dimension_num) - -CASE (1) - IF (is_top .eqv. .TRUE.) THEN - IF (Id1 .eq. num_subdomain_x-1) THEN - array(px+1,0:py+1,0:pz+1) = BC_value - END IF - ELSE - IF (Id1 .eq. 0) THEN - array(0,0:py+1,0:pz+1) = BC_value - END IF - END IF - -CASE (2) - IF (is_top .eqv. .TRUE.) THEN - IF (Id2 .eq. num_subdomain_y-1) THEN - array(0:px+1,py+1,0:pz+1) = BC_value - END IF - ELSE - IF (Id2 .eq. 0) THEN - array(0:px+1,0,0:pz+1) = BC_value - END IF - END IF - -CASE (3) - IF (is_top .eqv. .TRUE.) THEN - IF (Id3 .eq. num_subdomain_z-1) THEN - array(0:px+1,0:py+1,pz+1) = BC_value - END IF - ELSE - IF (Id3 .eq. 0) THEN - array(0:px+1,0:py+1,0) = BC_value - END IF - END IF - -END SELECT - -!PRINT *, 'in BC subroutine', array(40, 10, pz+1), array(40, 10, 0), top_val, bottom_val - -END SUBROUTINE external_BCs_Dirichlet - -!! =================================================================================== - -SUBROUTINE external_BCs_Zero_Derivative(array,is_top,dimension_num,Id1,Id2,Id3,px,py,pz) -USE parameters -IMPLICIT NONE - -INTEGER :: px, py, pz -REAL(KIND=8), DIMENSION(0:px+1,0:py+1,0:pz+1) :: array -REAL(KIND=8) :: BC_value -INTEGER :: dimension_num,Id1,Id2,Id3 -LOGICAL :: is_top - -SELECT CASE (dimension_num) - -CASE (1) - IF (is_top .eqv. .TRUE.) THEN - IF (Id1 .eq. num_subdomain_x-1) THEN - array(px+1,0:py+1,0:pz+1) = array(px,0:py+1,0:pz+1) - END IF - ELSE - IF (Id1 .eq. 0) THEN - array(0,0:py+1,0:pz+1) = array(1,0:py+1,0:pz+1) - END IF - END IF - -CASE (2) - IF (is_top .eqv. .TRUE.) THEN - IF (Id2 .eq. num_subdomain_y-1) THEN - array(0:px+1,py+1,0:pz+1) = array(0:px+1,py,0:pz+1) - END IF - ELSE - IF (Id2 .eq. 0) THEN - array(0:px+1,0,0:pz+1) = array(0:px+1,1,0:pz+1) - END IF - END IF - -CASE (3) - IF (is_top .eqv. .TRUE.) THEN - IF (Id3 .eq. num_subdomain_z-1) THEN - array(0:px+1,0:py+1,pz+1) = array(0:px+1,0:py+1,pz) - END IF - ELSE - IF (Id3 .eq. 0) THEN - array(0:px+1,0:py+1,0) = array(0:px+1,0:py+1,1) - END IF - END IF - -END SELECT - -!PRINT *, 'in BC subroutine', array(40, 10, pz+1), array(40, 10, 0), top_val, bottom_val - -END SUBROUTINE external_BCs_Zero_Derivative - -!! =================================================================================== - -SUBROUTINE external_BCs_Neumann(array,derivative,is_top,dimension_num,Id1,Id2,Id3,px,py,pz) -USE parameters -IMPLICIT NONE - -INTEGER :: px, py, pz -REAL(KIND=8), DIMENSION(0:px+1,0:py+1,0:pz+1) :: array -REAL(KIND=8) :: derivative -INTEGER :: dimension_num,Id1,Id2,Id3 -LOGICAL :: is_top - -SELECT CASE (dimension_num) - -CASE (1) - IF (is_top .eqv. .TRUE.) THEN - IF (Id1 .eq. num_subdomain_x-1) THEN - array(px+1,0:py+1,0:pz+1) = array(px,0:py+1,0:pz+1) + derivative - END IF - ELSE - IF (Id1 .eq. 0) THEN - array(0,0:py+1,0:pz+1) = array(1,0:py+1,0:pz+1) - derivative - END IF - END IF - -CASE (2) - IF (is_top .eqv. .TRUE.) THEN - IF (Id2 .eq. num_subdomain_y-1) THEN - array(0:px+1,py+1,0:pz+1) = array(0:px+1,py,0:pz+1) + derivative - END IF - ELSE - IF (Id2 .eq. 0) THEN - array(0:px+1,0,0:pz+1) = array(0:px+1,1,0:pz+1) - derivative - END IF - END IF - -CASE (3) - IF (is_top .eqv. .TRUE.) THEN - IF (Id3 .eq. num_subdomain_z-1) THEN - array(0:px+1,0:py+1,pz+1) = array(0:px+1,0:py+1,pz) + derivative - END IF - ELSE - IF (Id3 .eq. 0) THEN - array(0:px+1,0:py+1,0) = array(0:px+1,0:py+1,1) - derivative - END IF - END IF - -END SELECT - -END SUBROUTINE external_BCs_Neumann - -!! =================================================================================== - -SUBROUTINE external_BCs_Periodic(array,dimension_num,Id1,Id2,Id3,px,py,pz,left,right,front,back,top,bot,cartcomm) -USE parameters -IMPLICIT NONE -INCLUDE 'mpif.h' - -INTEGER :: px, py, pz -REAL(KIND=8), DIMENSION(0:px+1,0:py+1,0:pz+1) :: array -INTEGER :: dimension_num,Id1,Id2,Id3 -INTEGER :: left,right,front,back,top,bot,cartcomm -INTEGER :: errcode -INTEGER,DIMENSION(MPI_STATUS_SIZE) :: nstatus - -SELECT CASE (dimension_num) - -CASE (1) - IF ( num_subdomain_x .eq. 1) THEN - array(0,0:py+1,0:pz+1) = array(px,0:py+1,0:pz+1) - array(px+1,0:py+1,0:pz+1) = array(1,0:py+1,0:pz+1) - ELSE - IF (Id1 .eq. num_subdomain_x-1) & - call MPI_SEND(array(px,0:py+1,0:pz+1),(py+2)*(pz+2),MPI_DOUBLE_PRECISION,right,r1Tag+100,cartcomm,errcode) - - IF (Id1 .eq. 0) & - call MPI_RECV(array(0,0:py+1,0:pz+1),(py+2)*(pz+2),MPI_DOUBLE_PRECISION,left,r1Tag+100,cartcomm,nstatus,errcode) - - IF (Id1 .eq. 0) & - call MPI_SEND(array(1,0:py+1,0:pz+1),(py+2)*(pz+2),MPI_DOUBLE_PRECISION,left,l1Tag+100,cartcomm,errcode) - - IF (Id1 .eq. num_subdomain_x-1) & - call MPI_RECV(array(px+1,0:py+1,0:pz+1),(py+2)*(pz+2),MPI_DOUBLE_PRECISION,right,l1Tag+100,cartcomm,nstatus,errcode) - END IF - -CASE (2) - IF ( num_subdomain_y .eq. 1) THEN - array(0:px+1,0,0:pz+1) = array(0:px+1,py,0:pz+1) - array(0:px+1,py+1,0:pz+1) = array(0:px+1,1,0:pz+1) - ELSE - IF (Id2 .eq. num_subdomain_y-1) THEN - call MPI_SEND(array(0:px+1,py,0:pz+1),(px+2)*(pz+2),MPI_DOUBLE_PRECISION,back,f1Tag+100,cartcomm,errcode) - END IF - - IF (Id2 .eq. 0) THEN - call MPI_RECV(array(0:px+1,0,0:pz+1),(px+2)*(pz+2),MPI_DOUBLE_PRECISION,front,f1Tag+100,cartcomm,nstatus,errcode) - END IF - - IF (Id2 .eq. 0) & - call MPI_SEND(array(0:px+1,1,0:pz+1),(px+2)*(pz+2),MPI_DOUBLE_PRECISION,front,b1Tag+100,cartcomm,errcode) - - IF (Id2 .eq. num_subdomain_y-1) & - call MPI_RECV(array(0:px+1,py+1,0:pz+1),(px+2)*(pz+2),MPI_DOUBLE_PRECISION,back,b1Tag+100,cartcomm,nstatus,errcode) - END IF -CASE (3) - IF ( num_subdomain_z .eq. 1) THEN - array(0:px+1,0:py+1,0) = array(0:px+1,0:py+1,pz) - array(0:px+1,0:py+1,pz+1) = array(0:px+1,0:py+1,1) - ELSE - IF (Id3 .eq. num_subdomain_z-1) & - call MPI_SEND(array(0:px+1,0:py+1,pz),(px+2)*(py+2),MPI_DOUBLE_PRECISION,top,t1Tag+100,cartcomm,errcode) - - IF (Id3 .eq. 0) & - call MPI_RECV(array(0:px+1,0:py+1,0),(px+2)*(py+2),MPI_DOUBLE_PRECISION,bot,t1Tag+100,cartcomm,nstatus,errcode) - - IF (Id3 .eq. 0) & - call MPI_SEND(array(0:px+1,0:py+1,1),(px+2)*(py+2),MPI_DOUBLE_PRECISION,bot,d1Tag+100,cartcomm,errcode) - - IF (Id3 .eq. num_subdomain_z-1) & - call MPI_RECV(array(0:px+1,0:py+1,pz+1),(px+2)*(py+2),MPI_DOUBLE_PRECISION,top,d1Tag+100,cartcomm,nstatus,errcode) - END IF - -END SELECT - -END SUBROUTINE external_BCs_Periodic - -!!=================================================================================== -!! Internal BC Communication Subroutine -!!=================================================================================== - -SUBROUTINE commuBC(Id1,Id2,Id3,L1,L2,L3,S1,S2,S3,phi1,left,right,front,back,top,bot,cartcomm) -use parameters -implicit none -INCLUDE 'mpif.h' - -INTEGER S1, S2, S3, Id1, Id2, Id3,L1,L2,L3 -INTEGER :: left,right,front,back,top,bot,cartcomm !ranks of processors to shift to and cartcomm -INTEGER :: i,j,k -INTEGER :: errcode -REAL(KIND=8) :: phi1(S1:S1+L1-1,S2:S2+L2-1,S3:S3+L3-1) -INTEGER,DIMENSION(MPI_STATUS_SIZE) :: nstatus - -! Interior boundary condition -! communication in n1 direction - -If(Id1 .NE. num_subdomain_x-1) call MPI_SEND(phi1(S1+L1-1-bb,S2:S2+L2-1,S3:S3+L3-1), & - bb*L2*L3,MPI_DOUBLE_PRECISION,right,r1Tag,cartcomm,errcode) !Send real grid - -If(Id1 .NE. 0) call MPI_RECV(phi1(S1,S2:S2+L2-1,S3:S3+L3-1), & - bb*L2*L3,MPI_DOUBLE_PRECISION,left,r1Tag,cartcomm,nstatus,errcode) !receive by ghost grid - -If(Id1 .NE. 0) call MPI_SEND(phi1(S1+bb,S2:S2+L2-1,S3:S3+L3-1), & - bb*L2*L3,MPI_DOUBLE_PRECISION,left,l1Tag,cartcomm,errcode) - -If(Id1 .NE. num_subdomain_x-1) call MPI_RECV(phi1(S1+L1-1,S2:S2+L2-1,S3:S3+L3-1), & - bb*L2*L3,MPI_DOUBLE_PRECISION,right,l1Tag,cartcomm,nstatus,errcode) - -! communication in n2 direction - -If(Id2 .NE. num_subdomain_y-1) call MPI_SEND(phi1(S1:S1+L1-1,S2+L2-1-bb,S3:S3+L3-1), & - L1*bb*L3,MPI_DOUBLE_PRECISION,back,f1Tag,cartcomm,errcode) - -If(Id2 .NE. 0) call MPI_RECV(phi1(S1:S1+L1-1,S2,S3:S3+L3-1), & - L1*bb*L3,MPI_DOUBLE_PRECISION,front,f1Tag,cartcomm,nstatus,errcode) - -If(Id2 .NE. 0) call MPI_SEND(phi1(S1:S1+L1-1,S2+bb,S3:S3+L3-1), & - L1*bb*L3,MPI_DOUBLE_PRECISION,front,b1Tag,cartcomm,errcode) - -If(Id2 .NE. num_subdomain_y-1) call MPI_RECV(phi1(S1:S1+L1-1,S2+L2-1,S3:S3+L3-1), & - L1*bb*L3,MPI_DOUBLE_PRECISION,back,b1Tag,cartcomm,nstatus,errcode) - -! communication in n3 direction - - -If(Id3 .NE. num_subdomain_z-1) call MPI_SEND(phi1(S1:S1+L1-1,S2:S2+L2-1,S3+L3-1-bb), & - L1*L2*bb,MPI_DOUBLE_PRECISION,top,t1Tag,cartcomm,errcode) - -If(Id3 .NE. 0) call MPI_RECV(phi1(S1:S1+L1-1,S2:S2+L2-1,S3), & - L1*L2*bb,MPI_DOUBLE_PRECISION,bot,t1Tag,cartcomm,nstatus,errcode) - -If(Id3 .NE. 0) call MPI_SEND(phi1(S1:S1+L1-1,S2:S2+L2-1,S3+bb), & - L1*L2*bb,MPI_DOUBLE_PRECISION,bot,d1Tag,cartcomm,errcode) - -If(Id3 .NE. num_subdomain_z-1) call MPI_RECV(phi1(S1:S1+L1-1,S2:S2+L2-1,S3+L3-1), & - L1*L2*bb,MPI_DOUBLE_PRECISION,top,d1Tag,cartcomm,nstatus,errcode) - -RETURN -END SUBROUTINE - -!! =================================================================================== -!! Input subroutine -!! =================================================================================== - -!SUBROUTINE loadLotsFiles(arrIn,name_string,Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3) -!! Purpose: -!! Write arrIn to an individual file for each core. -!! File has Id1,Id2,Id3 in filename as _XXYYZZ.frt -! -!USE parameters -!IMPLICIT NONE -! -!! Declare variables:--------------------------------------------------------+ -!INTEGER, INTENT(in) :: Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3 -!REAL(KIND=8), DIMENSION(Is1-bb:Ie1+bb,Is2-bb:Ie2+bb,Is3-bb:Ie3+bb) :: arrIn ! Array to load -!CHARACTER(LEN=29) :: filename ! Filename of input or output -!CHARACTER(LEN=5) :: tstring, name_string -!CHARACTER(LEN=2) :: Id1string, Id2string, Id3string -!CHARACTER(LEN=3) :: counter -!INTEGER :: status -!INTEGER :: tpStep, i, outFreq -!!---------------------------------------------------------------------------+ -! -!WRITE(counter,'(I3)') 100+load_from_output -! -!write(Id1string,'(i2.2)')Id1 -!write(Id2string,'(i2.2)')Id2 -!write(Id3string,'(i2.2)')Id3 -! -!filename=name_string//load_from_run//'_'//counter(2:3)//'_'//Id1string//Id2string//Id3string//'.frt' -!!PRINT *,'Filename:', filename -!OPEN (FILE=output_path//filename, UNIT=300, STATUS='UNKNOWN', FORM='UNFORMATTED') -!READ (300) arrIn(Is1:Ie1,Is2:Ie2,Is3:Ie3) -!CLOSE (300) -! -!RETURN -! -!END SUBROUTINE loadLotsFiles - - -!! =================================================================================== -!! Output subroutine -!! =================================================================================== - -SUBROUTINE writeLotsFiles(arrIn,name_string,step,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3) -! Purpose: -! Write arrIn to an individual file for each core. -! File has Id1,Id2,Id3 in filename as _XXYYZZ.frt - -USE parameters -IMPLICIT NONE - -! Declare variables:--------------------------------------------------------+ -INTEGER, INTENT(in) :: Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3 -REAL(KIND=8), DIMENSION(Is1-bb:Ie1+bb,Is2-bb:Ie2+bb,Is3-bb:Ie3+bb), INTENT(IN) :: arrIn ! Array to write -CHARACTER(LEN=29) :: filename ! Filename of input or output -CHARACTER(LEN=5) :: tstring, name_string -CHARACTER(LEN=2) :: Id1string, Id2string, Id3string -CHARACTER(LEN=3) :: counter -INTEGER, INTENT(in) :: step -INTEGER :: tpStep, i, outFreq -!---------------------------------------------------------------------------+ - -WRITE(counter,'(I3)') 100+step - -write(Id1string,'(i2.2)')Id1 -write(Id2string,'(i2.2)')Id2 -write(Id3string,'(i2.2)')Id3 - -filename=name_string//run_num//'_'//counter(2:3)//'_'//Id1string//Id2string//Id3string//'.frt' -OPEN (FILE=output_path//filename, UNIT=300, STATUS='UNKNOWN', FORM='UNFORMATTED') -WRITE (300) arrIn(Is1:Ie1,Is2:Ie2,Is3:Ie3) -CLOSE (300) - -RETURN - -END SUBROUTINE writeLotsFiles - -!! =================================================================================== - -SUBROUTINE writeLotsFiles2(arrIn,name_string,step,Is1,Ie1,Is2,Ie2,Is3,Ie3,Id1,Id2,Id3) -! Purpose: -! Write arrIn to an individual file for each core. -! File has Id1,Id2,Id3 in filename as _XXYYZZ.frt - -USE parameters -IMPLICIT NONE - -! Declare variables:--------------------------------------------------------+ -INTEGER, INTENT(in) :: Is1,Ie1,Is2,Ie2,Is3,Ie3, Id1,Id2,Id3 -REAL(KIND=8), DIMENSION(Is1:Ie1,Is2:Ie2,Is3:Ie3), INTENT(IN) :: arrIn ! Array to write -CHARACTER(LEN=29) :: filename ! Filename of input or output -CHARACTER(LEN=5) :: tstring, name_string -CHARACTER(LEN=2) :: Id1string, Id2string, Id3string -CHARACTER(LEN=3) :: counter -INTEGER, INTENT(in) :: step -INTEGER :: tpStep, i, outFreq -!---------------------------------------------------------------------------+ - -WRITE(counter,'(I3)') 100+step - -write(Id1string,'(i2.2)')Id1 -write(Id2string,'(i2.2)')Id2 -write(Id3string,'(i2.2)')Id3 - -filename=name_string//run_num//'_'//counter(2:3)//'_'//Id1string//Id2string//Id3string//'.frt' -OPEN (FILE=output_path//filename, UNIT=300, STATUS='UNKNOWN', FORM='UNFORMATTED') -WRITE (300) arrIn(Is1:Ie1,Is2:Ie2,Is3:Ie3) -CLOSE (300) - -RETURN - -END SUBROUTINE writeLotsFiles2 - -!! ================================================================================================= - -SUBROUTINE outputVector(vector,outName,length) -USE parameters -IMPLICIT NONE -INTEGER :: length, outNum -REAL(KIND=8),DIMENSION(1:length) :: vector -CHARACTER(LEN=8) :: outName -CHARACTER(LEN=12) :: filename - -!! This subroutine outputs arrays of length "length" to file. - -WRITE(filename, '(A8,A4)') outName,'.dat' -OPEN(UNIT=300,FILE=output_path//filename,FORM='FORMATTED',ACTION='WRITE') -WRITE(300,'(E25.12)') vector -CLOSE(300) - -END SUBROUTINE outputVector - -!! ================================================================================================= - -!SUBROUTINE loadVector(vector,outName,length) -!USE parameters -!IMPLICIT NONE -!INTEGER :: length, outNum -!REAL(KIND=8),DIMENSION(1:length) :: vector -!CHARACTER(LEN=8) :: outName -!CHARACTER(LEN=12) :: filename -! -!!! This subroutine outputs arrays of length "length" to file. -! -!WRITE(filename, '(A8,A4)') outName,'.dat' -!OPEN(UNIT=300,FILE=output_path//filename,FORM='FORMATTED',ACTION='READ') -!READ(300,'(E25.12)') vector -!CLOSE(300) -! -!END SUBROUTINE loadVector - -!! ================================================================================================= - -SUBROUTINE outputDomainInfo() -USE parameters -IMPLICIT NONE - -CHARACTER(LEN=3) :: counter -CHARACTER(LEN=18) :: filename - -!! This subroutine outputs the dimensions of the domain and the number of subdomains - -WRITE(filename, '(A11,A3,A4)') 'domain_info',run_num,'.frt' -OPEN(UNIT=20,FILE=output_path//filename,ACTION='WRITE') -WRITE(20,*) xg -WRITE(20,*) yg -WRITE(20,*) zg -WRITE(20,*) num_subdomain_x -WRITE(20,*) num_subdomain_y -WRITE(20,*) num_subdomain_z -CLOSE(20) - -END SUBROUTINE - - diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results.tar b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results.tar deleted file mode 100644 index 7c6404194..000000000 Binary files a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results.tar and /dev/null differ diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results/assemble_MPI_output.m b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results/assemble_MPI_output.m deleted file mode 100644 index dea7b9455..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results/assemble_MPI_output.m +++ /dev/null @@ -1,70 +0,0 @@ -function array_global = assemble_MPI_output(prda,path,run_num) - -domain_info = importdata(['domain_info' run_num '.frt']); - -xg = domain_info(1); -yg = domain_info(2); -zg = domain_info(3); - -num_x_subdomain = domain_info(4); -num_y_subdomain = domain_info(5); -num_z_subdomain = domain_info(6); - -plot_start_x = 1; -plot_end_x = xg; -plot_start_y = 1; -plot_end_y = yg; -plot_start_z = 1; -plot_end_z = zg; - -% Cycle through each subdomain -for x_subdomain = 0:num_x_subdomain-1 - for y_subdomain = 0:num_y_subdomain-1 - for z_subdomain = 0:num_z_subdomain-1 - - if x_subdomain < num_x_subdomain-1 - px = floor(xg/num_x_subdomain); - else - px = xg - (num_x_subdomain-1)*floor(xg/num_x_subdomain); - end - - if y_subdomain < num_y_subdomain-1 - py = floor(yg/num_y_subdomain); - else - py = yg - (num_y_subdomain-1)*floor(yg/num_y_subdomain); - end - - if z_subdomain < num_z_subdomain-1 - pz = floor(zg/num_z_subdomain); - else - pz = zg - (num_z_subdomain-1)*floor(zg/num_z_subdomain); - end - - Is1 = x_subdomain*floor(xg/num_x_subdomain) + 1; - Ie1 = Is1 + px - 1; - - Is2 = y_subdomain*floor(yg/num_y_subdomain) + 1; - Ie2 = Is2 + py - 1; - - Is3 = z_subdomain*floor(zg/num_z_subdomain) + 1; - Ie3 = Is3 + pz - 1; - - subdomain_index = strcat(sprintf('%02d', x_subdomain), sprintf('%02d', y_subdomain), sprintf('%02d', z_subdomain)); - - ext = '.frt'; - - %% domain parameter - fname = [path prda subdomain_index ext]; - fid = fopen(fname); - skip1 = fread(fid,1,'int32'); - BD = fread(fid,inf,'double'); - fclose(fid); - [r1 c1] = size(BD); - [r1 px*py*pz]; - array_local = reshape(BD(1:r1),px,py,pz); - - array_global(Is1:Ie1,Is2:Ie2,Is3:Ie3) = array_local; - - end - end -end diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results/plot_FD_CHAC.m b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results/plot_FD_CHAC.m deleted file mode 100644 index d8ee0684a..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results/plot_FD_CHAC.m +++ /dev/null @@ -1,69 +0,0 @@ -function [z,c_0,c_1] = plot_FD_CHAC() - -% -------------------------------------------------------------------------------------------------------- -% Plot the concentration -% -------------------------------------------------------------------------------------------------------- - -run_num = '001'; - -domain_info = importdata(['domain_info' run_num '.frt']); - -xg = domain_info(1); -yg = domain_info(2); -zg = domain_info(3); - -output_num = '00'; -c_0 = assemble_MPI_output(['con_r' run_num '_' output_num '_'],'',run_num); -eta_0 = assemble_MPI_output(['eta_r' run_num '_' output_num '_'],'',run_num); - -x = assemble_MPI_output(['xgrid' run_num '_' output_num '_'],'',run_num); -y = assemble_MPI_output(['ygrid' run_num '_' output_num '_'],'',run_num); -z = assemble_MPI_output(['zgrid' run_num '_' output_num '_'],'',run_num); - -output_num = '01'; -c_1 = assemble_MPI_output(['con_r' run_num '_' output_num '_'],'',run_num); -eta_1 = assemble_MPI_output(['eta_r' run_num '_' output_num '_'],'',run_num); - -threeD_precipitate_plotter(c_1,xg,yg,zg,1); -drawnow; - -vtkwrite('fd_results.vtk','structured_grid',x,y,z,... - 'scalars','c_0',c_0,'scalars','c_1',c_1); - - -end - -function threeD_precipitate_plotter(c,xg,yg,zg,fig_num) - -plot_start_x = 1; -plot_end_x = xg; -plot_start_y = 1; -plot_end_y = yg; -plot_start_z = 1; -plot_end_z = zg; - -figure(fig_num); -whitebg('w') - -ite = 1; -isovL = 0.06; -isovC = 0.06; - -[NewY,NewX,NewZ] = meshgrid(plot_start_y:plot_end_y,plot_start_x:plot_end_x,plot_start_z:plot_end_z); - -p1 = patch(isosurface(NewY,NewX,NewZ,c(plot_start_x:plot_end_x,plot_start_y:plot_end_y,plot_start_z:plot_end_z),isovL)); -p2 = patch(isocaps(NewY,NewX,NewZ,c(plot_start_x:plot_end_x,plot_start_y:plot_end_y,plot_start_z:plot_end_z),isovL)); - -isocolors(c(plot_start_x:plot_end_x,plot_start_y:plot_end_y,plot_start_z:plot_end_z),p1) -set(p1,'FaceColor','interp','EdgeColor','none') -isonormals(c(plot_start_x:plot_end_x,plot_start_y:plot_end_y,plot_start_z:plot_end_z),p1) -isocolors(c(plot_start_x:plot_end_x,plot_start_y:plot_end_y,plot_start_z:plot_end_z),p2) -set(p2,'FaceColor','interp','EdgeColor','none') - -set(gca,'Projection','perspective') -view(3); daspect([1,1,1]); -axis([1 yg 1 xg 1 zg]);box on; -lightangle(45,60) -lighting phong - -end diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results/vtkwrite.m b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results/vtkwrite.m deleted file mode 100644 index cbb6298f3..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/fd_results/vtkwrite.m +++ /dev/null @@ -1,185 +0,0 @@ -function vtkwrite( filename,dataType,varargin ) -% VTKWRITE Writes 3D Matlab array into VTK file format. -% vtkwrite(filename,'structured_grid',x,y,z,'vectors',title,u,v,w) writes -% a structured 3D vector data into VTK file, with name specified by the string -% filename. (u,v,w) are the vector components at the points (x,y,z). x,y,z -% should be 3-D matrices like those generated by meshgrid, where -% point(ijk) is specified by x(i,j,k), y(i,j,k) and z(i,j,k). -% The matrices x,y,z,u,v,w must all be the same size and contain -% corrresponding position and vector component. The string title specifies -% the name of the vector field to be saved. -% -% vtkwrite(filename,'structured_grid',x,y,z,'scalars',title,r) writes a 3D -% scalar data into VTK file whose name is specified by the string -% filename. r is the scalar value at the points (x,y,z). The matrices -% x,y,z,r must all be the same size and contain the corresponding position -% and scalar values. -% -% vtkwrite(filename,'structured_grid',x,y,z,'vectors',title1,u,v,w,'scalars', -% title2,r) writes a 3D structured grid that contains both vector and scalar values. -% x,y,z,u,v,w,r must all be the same size and contain the corresponding -% positon, vector and scalar values. -% -% vtkwrite(filename,'unstructured_grid',x,y,z,'vectors',title1,u,v,w,'scalars', -% title2,r) writes a 3D unstructured grid that contains both vector and scalar values. -% x,y,z,u,v,w,r must all be the same size and contain the corresponding -% positon, vector and scalar values. -% -% vtkwrite(filename,'polydata','lines',x,y,z) exports a 3D line where -% x,y,z are coordinates of the points that make the line. x,y,z are -% vectors containing the coordinates of points of the line, where point(n) -% is specified by x(n),y(n) and z(n). -% -% vtkwrite(filename,'polydata','lines',x,y,z,'Precision',n) allows you to -% specify precision of the exported number up to n digits after decimal -% point. Default precision is 3 digits. -% -% vtkwrite(filename,'polydata','triangle',x,y,z,tri) exports a list of -% triangles where x,y,z are the coordinates of the points and tri is an -% m*3 matrix whose rows denote the points of the individual triangles. -% -% vtkwrite(filename,'polydata','tetrahedron',x,y,z,tetra) exports a list -% of tetrahedrons where x,y,z are the coordinates of the points -% and tetra is an m*4 matrix whose rows denote the points of individual -% tetrahedrons. -% -% vtkwrite('execute','polydata','lines',x,y,z) will save data with default -% filename ''matlab_export.vtk' and automatically loads data into -% ParaView. -% -% Version 2.2.1 -% Chaoyuan Yeh, 2015 -% Codes are modified from William Thielicke and David Gingras's submission. - -if strcmpi(filename,'execute'), filename = 'matlab_export.vtk'; end -fid = fopen(filename, 'w'); -% VTK files contain five major parts -% 1. VTK DataFile Version -fprintf(fid, '# vtk DataFile Version 2.0\n'); -% 2. Title -fprintf(fid, 'VTK from Matlab\n'); -switch upper(dataType) - case {'STRUCTURED_GRID','UNSTRUCTURED_GRID'} - % 3. The format data proper is saved in (ASCII or Binary). Use - % fprintf to write data in the case of ASCII and fwrite for binary. - if numel(varargin)<6, error('Not enough input arguments'); end - fprintf(fid, 'BINARY\n'); - x = varargin{1}; - y = varargin{2}; - z = varargin{3}; - if sum(size(x)==size(y) & size(y)==size(z))~=length(size(x)) - error('Input dimesions do not match') - end - n_elements = numel(x); - % 4. Type of Dataset ( can be STRUCTURED_POINTS, STRUCTURED_GRID, - % UNSTRUCTURED_GRID, POLYDATA, RECTILINEAR_GRID or FIELD ) - % This part, dataset structure, begins with a line containing the - % keyword 'DATASET' followed by a keyword describing the type of dataset. - % Then the geomettry part describes geometry and topology of the dataset. - if strcmpi(dataType,'STRUCTURED_GRID') - fprintf(fid, 'DATASET STRUCTURED_GRID\n'); - fprintf(fid, ['DIMENSIONS ' num2str(size(x,2)) ' ' num2str(size(x,1)) ' ' num2str(size(x,3)) '\n']); - else - fprintf(fid, 'DATASET UNSTRUCTURED_GRID\n'); - end - fprintf(fid, ['POINTS ' num2str(n_elements) ' float\n']); - fwrite(fid, [x(:)';y(:)';z(:)'],'float','b'); - % 5.This final part describe the dataset attributes and begins with the - % keywords 'POINT_DATA' or 'CELL_DATA', followed by an integer number - % specifying the number of points of cells. Other keyword/data combination - % then define the actual dataset attribute values. - fprintf(fid, ['\nPOINT_DATA ' num2str(n_elements)]); - % Parse remaining argument. - vidx = find(strcmpi(varargin,'VECTORS')); - sidx = find(strcmpi(varargin,'SCALARS')); - if vidx~=0 - for ii = 1:length(vidx) - title = varargin{vidx(ii)+1}; - % Data enteries begin with a keyword specifying data type - % and numeric format. - fprintf(fid, ['\nVECTORS ', title,' float\n']); - fwrite(fid, [reshape(varargin{vidx(ii)+2},1,n_elements);... - reshape(varargin{vidx(ii)+3},1,n_elements);... - reshape(varargin{vidx(ii)+4},1,n_elements)],'float','b'); - end - end - if sidx~=0 - for ii = 1:length(sidx) - title = varargin{sidx(ii)+1}; - fprintf(fid, ['\nSCALARS ', title,' float\n']); - fprintf(fid, 'LOOKUP_TABLE default\n'); - fwrite(fid, reshape(varargin{sidx(ii)+2},1,n_elements),'float','b'); - end - end - - case 'POLYDATA' - fprintf(fid, 'ASCII\n'); - if numel(varargin)<4, error('Not enough input arguments'); end - x = varargin{2}(:); - y = varargin{3}(:); - z = varargin{4}(:); - if numel(varargin)<4, error('Not enough input arguments'); end - if sum(size(x)==size(y) & size(y)==size(z))~= length(size(x)) - error('Input dimesions do not match') - end - n_elements = numel(x); - fprintf(fid, 'DATASET POLYDATA\n'); - if mod(n_elements,3)==1 - x(n_elements+1:n_elements+2,1)=[0;0]; - y(n_elements+1:n_elements+2,1)=[0;0]; - z(n_elements+1:n_elements+2,1)=[0;0]; - elseif mod(n_elements,3)==2 - x(n_elements+1,1)=0; - y(n_elements+1,1)=0; - z(n_elements+1,1)=0; - end - nbpoint = numel(x); - fprintf(fid, ['POINTS ' num2str(nbpoint) ' float\n']); - precision = '3'; - if any(strcmpi(varargin,'PRECISION')) - precision = num2str(uint8(varargin{find(strcmpi(varargin,'PRECISION'))+1})); - if str2double(precision) < 0, error('Invalid precision spec.');end - end - spec = [repmat(['%0.',precision,'f '],1,9),'\n']; - fprintf(fid,spec, [x(1:3:end-2) y(1:3:end-2) z(1:3:end-2) ... - x(2:3:end-1) y(2:3:end-1) z(2:3:end-1) ... - x(3:3:end) y(3:3:end) z(3:3:end)]'); - switch upper(varargin{1}) - case 'LINES' - if mod(n_elements,2)==0 - nbLine = 2*n_elements-2; - else - nbLine = 2*(n_elements-1); - end - conn1 = zeros(nbLine,1); - conn2 = zeros(nbLine,1); - conn2(1:nbLine/2) = 1:nbLine/2; - conn1(1:nbLine/2) = conn2(1:nbLine/2)-1; - conn1(nbLine/2+1:end) = 1:nbLine/2; - conn2(nbLine/2+1:end) = conn1(nbLine/2+1:end)-1; - fprintf(fid,'\nLINES %d %d\n',nbLine,3*nbLine); - fprintf(fid,'2 %d %d\n',[conn1';conn2']); - case 'TRIANGLE' - ntri = length(varargin{5}); - fprintf(fid,'\nPOLYGONS %d %d\n',ntri,4*ntri); - fprintf(fid,'3 %d %d %d\n',(varargin{5}-1)'); - case 'TETRAHEDRON' - ntetra = length(varargin{5}); - fprintf(fid,'\nPOLYGONS %d %d\n',ntetra,5*ntetra); - fprintf(fid,'4 %d %d %d %d\n',(varargin{5}-1)'); - end -end -fclose(fid); -if strcmpi(filename,'matlab_export.vtk') - switch computer - case {'PCWIN','PCWIN64'} - !paraview.exe --data='matlab_export.vtk' & - % Exclamation point character is a shell escape, the rest of the - % input line will be sent to operating system. It can not take - % variables, though. The & at the end of line will return control to - % Matlab even when the outside process is still running. - case {'GLNXA64','MACI64'} - !paraview --data='matlab_export.vtk' & - end -end -end \ No newline at end of file diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/parameters.mod b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/parameters.mod deleted file mode 100644 index fda55eb1e..000000000 Binary files a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/finite_difference_CHAC/parameters.mod and /dev/null differ diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/main.cc b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/main.cc deleted file mode 100644 index 5172f5398..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/main.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "equations.h" -#include "parameters.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/parameters.h b/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/parameters.h deleted file mode 100644 index e6c07eb41..000000000 --- a/tests/deprecated_tests/finite_difference_comparison/CHAC_speed_comparison/parameters.h +++ /dev/null @@ -1,67 +0,0 @@ -// Parameter list for the coupled Allen-Cahn/Cahn-Hilliard example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 3 -// ================================================================================= - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 64.0 -#define spanY 64.0 -#define spanZ 64.0 -// ================================================================================= - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size -#define subdivisionsX 5 -#define subdivisionsY 5 -#define subdivisionsZ 5 -#define refineFactor 3 - -// Set the polynomial degree of the element -// Suggested values are either 1 or 2 -#define finiteElementDegree 2 -// ================================================================================= - -// ================================================================================= -// Set the time step parameters -// ================================================================================= -// The size of the time step -#define timeStep (5.0 / 5500.0) - -// The simulation ends when either timeFinal is reached or the number of time -// steps equals timeIncrements -#define timeFinal 10000.0 -#define timeIncrements 27500 -// ================================================================================= - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 1 -// ================================================================================= - -// ================================================================================= -// Set the flag determining if the total free energy is calculated for each -// output -// ================================================================================= -#define calcEnergy false -// ================================================================================= diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/CMakeLists.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/ICs_and_BCs.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/ICs_and_BCs.h deleted file mode 100644 index 7129dffae..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/ICs_and_BCs.h +++ /dev/null @@ -1,187 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - -#define x_denom 1.0 -#define y_denom 1.0 -#define z_denom 1.0 -#define initial_interface_coeff 1.0 -#define initial_radius 7.0 -#define avg_Nd 0.004 - - if (index == 0) - { - // return the value of the initial concentration field at point p - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; - // return 0.02 + 1.0e-3*(2*(0.5 - (double)(std::rand() % 100 )/100.0)); -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (0.12 - 0.00) * (1 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#elif problemDIM == 3 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#endif - } - else if (index == 1) - { - // set result equal to the structural order paramter initial condition - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (1.0 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - -#elif problemDIM == 3 - // r=p.distance(Point(spanX/2.0,spanY/2.0,spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r-spanX/8.0)/(3*dx))); - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - - // planar interface - // r=sqrt((p.operator()(2)-spanZ/2.0)*(p.operator()(2)-spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r)/(initial_interface_coeff))); - // return - // 0.5*(1.0-std::tanh((r-initial_radius)/(initial_interface_coeff))); -#endif - return 0.0; - } - else if (index == 2) - { - scalar_IC = 0.0; - } - else if (index == 3) - { - scalar_IC = 0.0; - } - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - if (index == 4) - { - vector_IC(0) = 0.0; - vector_IC(1) = 0.0; - if (dim == 3) - { - vector_IC(2) = 0.0; - } - } - // ===================================================================== - } -}; - -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") - // Fourth input: BC value (ignored unless the BC type is "DIRICHLET") - // Odd inputs after the third: BC type - // Even inputs after the third: BC value - // Face numbering: starts at zero with the minimum of the first direction, one - // for the maximum of the first direction - // two for the minimum of the second direction, etc. - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(1, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(2, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(3, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(4, 0, "DIRICHLET", 0.0); - inputBCs(4, 1, "DIRICHLET", 0.0); - if (dim == 3) - { - inputBCs(4, 2, "DIRICHLET", 0.0); - } - - // ===================================================================== -} diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error.txt deleted file mode 100644 index 75061cc13..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error.txt +++ /dev/null @@ -1 +0,0 @@ -9.96684211846e-08 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error1.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error1.txt deleted file mode 100644 index b0183ae2d..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error1.txt +++ /dev/null @@ -1 +0,0 @@ -0.0044260378927 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error2.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error2.txt deleted file mode 100644 index 41b6d8c6c..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error2.txt +++ /dev/null @@ -1 +0,0 @@ -0.00117394141853 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error3.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error3.txt deleted file mode 100644 index 67fa0e06a..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error3.txt +++ /dev/null @@ -1 +0,0 @@ -0.000283651053905 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error4.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error4.txt deleted file mode 100644 index 8cbef5208..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/error4.txt +++ /dev/null @@ -1 +0,0 @@ -5.74858859181e-05 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/getError.py b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/getError.py deleted file mode 100644 index 412740181..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/getError.py +++ /dev/null @@ -1,74 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "100000" -output_num_2 = "100000" - -f = open('run_num_1.txt','r') -run_num_1 = f.read() -f.close() - -f = open('run_num_2.txt','r') -run_num_2 = f.read() -f.close() - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = False - -directory_1 = run_num_1+"/solution-"+output_num_1+".pvtu" -directory_2 = run_num_2+"/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","abs(("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))^2)") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","abs(("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))^2)") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -#Query("MinMax", use_actual_data=1) -#min_max_val = GetQueryOutputValue() -#error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -# Calculate the L2 error: -Query("Weighted Variable Sum", use_actual_data=1) -error = GetQueryOutputValue() - - -text_file = open("error.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/hoe_test_2D.py b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/hoe_test_2D.py deleted file mode 100644 index 5153f4ea9..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/hoe_test_2D.py +++ /dev/null @@ -1,115 +0,0 @@ -import subprocess -import shutil -import glob -import math -import os.path - -# ---------------------------------------------------------------------------------------- -# Function that generates a header file for the simulation, compiles the PRISMS-PF code -# and runs the executable. -# ---------------------------------------------------------------------------------------- -def run_simulation(refineFactor,degree,run_name): - - subdivisionsX = 1 - subdivisionsY = 1 - subdivisionsZ = 1 - finiteElementDegree = degree - - text_file = open("space_parameters.h","w") - text_file.write("// Parameters list for the parameters involved in mesh generation \n") - text_file.write("#define subdivisionsX " + str(subdivisionsX) + "\n") - text_file.write("#define subdivisionsY " + str(subdivisionsY) + "\n") - text_file.write("#define subdivisionsZ " + str(subdivisionsZ) + "\n") - text_file.write("#define refineFactor " + str(refineFactor) + "\n") - text_file.write("#define finiteElementDegree " + str(finiteElementDegree) + "\n") - text_file.close() - - subprocess.call(["make", "release"]) - #subprocess.call(["./main"]) - subprocess.call(["mpirun", "-n", "4", "main"]) - - subprocess.call(["mkdir",run_name]) - for output_files in glob.glob('*vtu'): - shutil.move(output_files,run_name) - -# ---------------------------------------------------------------------------------------- -# Function that calculates the maximum error between a run and a reference result. -# ---------------------------------------------------------------------------------------- -def getError(run_num): - - text_file = open("run_num_1.txt","w") - text_file.write('run_00'+str(run_num)) - text_file.close() - subprocess.call(["visit", "-cli","-s","getError.py"]) - f = open('error.txt','r') - error = float(f.read()) - f.close() - - return error - -# ---------------------------------------------------------------------------------------- - -# If files exist from previous tests, delete them -if os.path.exists("run_001") == True: - shutil.rmtree("run_001") -if os.path.exists("run_002") == True: - shutil.rmtree("run_002") -if os.path.exists("run_003") == True: - shutil.rmtree("run_003") -if os.path.exists("run_004") == True: - shutil.rmtree("run_004") -if os.path.exists("run_005") == True: - shutil.rmtree("run_005") -if os.path.exists("run_006") == True: - shutil.rmtree("run_006") -if os.path.exists("run_007") == True: - shutil.rmtree("run_007") -if os.path.exists("run_008") == True: - shutil.rmtree("run_008") -if os.path.exists("run_009") == True: - shutil.rmtree("run_009") -# -# # Run simulations with a decreasing time step (and an corresponding increase in number of iterations) -run_simulation(4,1,'run_001') -run_simulation(5,1,'run_002') -run_simulation(6,1,'run_003') -run_simulation(3,2,'run_004') -run_simulation(4,2,'run_005') -run_simulation(5,2,'run_006') -run_simulation(3,3,'run_007') -run_simulation(4,3,'run_008') -run_simulation(8,1,'run_009') - -# Find the error for runs 1-8 (as compared to run 9) -text_file = open("run_num_2.txt","w") -text_file.write('run_009') -text_file.close() - -error = [] -error.append(getError(1)) -error.append(getError(2)) -error.append(getError(3)) -error.append(getError(4)) -error.append(getError(5)) -error.append(getError(6)) -error.append(getError(7)) -error.append(getError(8)) - -# Calculate and output the error - -print "Error results: \n" -print "First order element error:", str(error[0]), "(refine level 4)", str(error[1]), "(refine level 5)", \ - str(error[2]), "(refine level 6)", "\n" - -print "Second order element error:", str(error[3]), "(refine level 3)", str(error[4]), "(refine level 4)", \ - str(error[5]), "(refine level 5)", "\n" - -print "Third order element error:", str(error[6]), "(refine level 3)", str(error[7]), "(refine level 4)", "\n" - -# text_file = open("hoe_2D_results.txt","w") -# text_file.write("Results of 2D spatial order of accuracy test: \n") -# text_file.write("From coarse mesh to medium mesh: " + str(ooa_1_to_2) + "\n") -# text_file.write("From from medium mesh to fine mesh: " + str(ooa_2_to_3) + "\n") -# text_file.write("From from fine mesh to very fine mesh: " + str(ooa_3_to_4) + "\n") -# text_file.close() - diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/main.cc b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/main.cc deleted file mode 100644 index a62d5cdca..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/main.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" -#include "space_parameters.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/parameters.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/parameters.h deleted file mode 100644 index 60a9c368d..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/parameters.h +++ /dev/null @@ -1,101 +0,0 @@ -// Parameter list for the precipitate evolution example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 2 - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 16.0 -#define spanY 16.0 -#define spanZ 16.0 - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size #define subdivisionsX 3 #define subdivisionsY 3 #define subdivisionsZ 3 -// #define refineFactor 5 - -// Set the polynomial degree of the element (suggested values: 1 or 2) -// #define finiteElementDegree 2 - -// ================================================================================= -// Set the adaptive mesh refinement parameters -// ================================================================================= -// Set the flag determining if adaptive meshing is activated -#define hAdaptivity false - -// Set the maximum and minimum level of refinement -#define maxRefinementLevel (refineFactor) -#define minRefinementLevel (refineFactor - 2) - -// Set the fields used to determine the refinement. Fields determined by the -// order declared in "equations.h", starting at zero -#define refineCriterionFields \ - { \ - 1, 2, 3 \ - } - -// Set the maximum and minimum value of the fields where the mesh should be -// refined -#define refineWindowMax \ - { \ - 0.99, 0.99, 0.99 \ - } -#define refineWindowMin \ - { \ - 0.01, 0.01, 0.01 \ - } - -// Set the number of time steps between remeshing operations -#define skipRemeshingSteps 1000 - -// ================================================================================= -// Set the time step parameters -// ================================================================================= -// The size of the time step -#define timeStep 9.0e-6 -#define timeFinal 100000000 -#define timeIncrements 100000 - -// ================================================================================= -// Set the elliptic solver parameters -// ================================================================================= -// The solver type (currently the only recommended option is conjugate gradient) -#define solverType SolverCG - -// The flag that determines whether the tolerance for solver convergence should -// be an absolute tolerance (absTol=true) or a relative tolerance (absTol=false) -#define absTol true - -// The tolerance for convergence (L2 norm of the residual) -#define solverTolerance 1.0e-4 - -// The maximum number of solver iterations per time step -#define maxSolverIterations 1000 - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 10 - -// ================================================================================= -// Set the flag determining if the total free energy is calculated for each -// output -// ================================================================================= -#define calcEnergy false diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/residuals.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/residuals.h deleted file mode 100644 index 3c8190016..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/residuals.h +++ /dev/null @@ -1,682 +0,0 @@ -// List of variables and residual equations for the Precipitate Evolution -// example application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 5 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "c", "n1", "n2", "n3", "u" \ - } -#define variable_type \ - { \ - "SCALAR", "SCALAR", "SCALAR", "SCALAR", "VECTOR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC", "PARABOLIC", "PARABOLIC", "PARABOLIC", "ELLIPTIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - true, true, true, true, false \ - } -#define need_grad \ - { \ - true, true, true, true, true \ - } -#define need_hess \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - true, true, true, true, false \ - } -#define need_grad_residual \ - { \ - true, true, true, true, true \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqn for the left-hand-side of the iterative solver for elliptic equations -#define need_val_LHS \ - { \ - false, true, true, true, false \ - } -#define need_grad_LHS \ - { \ - false, false, false, false, true \ - } -#define need_hess_LHS \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation for the left-hand-side of the -// iterative solver for elliptic equations has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual_LHS \ - { \ - false, false, false, false, false \ - } -#define need_grad_residual_LHS \ - { \ - false, false, false, false, true \ - } - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Cahn-Hilliard mobility -#define McV 1.0 - -// Allen-Cahn mobilities -#define Mn1V 50.0 -#define Mn2V 50.0 -#define Mn3V 50.0 - -// Gradient energy coefficients -double Kn1[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn2[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn3[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; - -// define energy barrier coefficient (used to tune the interfacial energy) -#define W -1.0 - -// Define mechanical properties -#define n_dependent_stiffness false -// Mechanical symmetry of the material and stiffness parameters -// If n_dependent_stiffness == false the first entry is used for all phases -#define MaterialModels \ - { \ - { \ - "ISOTROPIC" \ - } \ - } -#define MaterialConstants \ - { \ - { \ - 1.0, 0.3 \ - } \ - } - -// Stress-free transformation strains -// Linear fits for the stress-free transformation strains in for sfts = -// sfts_linear * c + sfts_const -double sfts_linear1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -// Free energy expressions -#define faV (24.7939 * c * c - 1.6752 * c - 1.9453e-06) -#define facV (49.5878 * c - 1.6752) -#define faccV (49.5878) -#define fbV (37.9316 * c * c - 10.7373 * c + 0.5401) -#define fbcV (75.8633 * c - 10.7373) -#define fbccV (75.8633) -#define h1V (3.0 * n1 * n1 - 2.0 * n1 * n1 * n1) -#define h2V (3.0 * n2 * n2 - 2.0 * n2 * n2 * n2) -#define h3V (3.0 * n3 * n3 - 2.0 * n3 * n3 * n3) -#define hn1V (6.0 * n1 - 6.0 * n1 * n1) -#define hn2V (6.0 * n2 - 6.0 * n2 * n2) -#define hn3V (6.0 * n3 - 6.0 * n3 * n3) - -// This double-well function can be used to tune the interfacial energy -#define fbarrierV (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1) -#define fbarriernV (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1) - -// Residuals -#define rcV (c) -#define rcxTemp \ - (cx * ((1.0 - h1V - h2V - h3V) * faccV + (h1V + h2V + h3V) * fbccV) + \ - n1x * ((fbcV - facV) * hn1V) + n2x * ((fbcV - facV) * hn2V) + \ - n3x * ((fbcV - facV) * hn3V)) -#define rcxV (constV(-timeStep * McV) * rcxTemp) - -#define rn1V \ - (n1 - constV(timeStep * Mn1V) * \ - ((fbV - faV) * hn1V + W * fbarriernV + nDependentMisfitAC1)) -#define rn2V (n2 - constV(timeStep * Mn2V) * ((fbV - faV) * hn2V)) -#define rn3V (n3 - constV(timeStep * Mn3V) * ((fbV - faV) * hn3V)) -#define rn1xV (constV(-timeStep * Mn1V) * Knx1) -#define rn2xV (constV(-timeStep * Mn2V) * Knx2) -#define rn3xV (constV(-timeStep * Mn3V) * Knx3) - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // The concentration and its derivatives (names here should match those in the - // macros above) - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - // The first order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n1 = modelVariablesList[1].scalarValue; - scalargradType n1x = modelVariablesList[1].scalarGrad; - - // The second order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n2 = modelVariablesList[2].scalarValue; - scalargradType n2x = modelVariablesList[2].scalarGrad; - - // The third order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n3 = modelVariablesList[3].scalarValue; - scalargradType n3x = modelVariablesList[3].scalarGrad; - - // The derivative of the displacement vector (names here should match those in - // the macros above) - vectorgradType ux = modelVariablesList[4].vectorGrad; - vectorgradType ruxV; - - vectorhessType uxx; - - if (c_dependent_misfit == true) - { - uxx = modelVariablesList[4].vectorHess; - } - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - // Fill residual corresponding to mechanics - // R=-C*(E-E0) - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - ruxV[i][j] = -S[i][j]; - } - } - - // Compute one of the stress terms in the order parameter chemical potential, - // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - nDependentMisfitAC1 += S[i][j] * (sfts1[i][j]); - nDependentMisfitAC2 += S[i][j] * (sfts2[i][j]); - nDependentMisfitAC3 += S[i][j] * (sfts3[i][j]); - } - } - - nDependentMisfitAC1 *= -hn1V; - nDependentMisfitAC2 *= -hn2V; - nDependentMisfitAC3 *= -hn3V; - - // Compute the other stress term in the order parameter chemical potential, - // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray heterMechAC2 = constV(0.0); - dealii::VectorizedArray heterMechAC3 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; - - if (n_dependent_stiffness == true) - { - // computeStress(CIJ_diff, E2, S2); - computeStress(CIJ_list[1] - CIJ_list[0], E2, S2); - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - heterMechAC1 += S2[i][j] * E2[i][j]; - } - } - // Aside from HnpV, heterMechAC1, heterMechAC2, and heterMechAC3 are equal - heterMechAC2 = 0.5 * hn2V * heterMechAC1; - heterMechAC3 = 0.5 * hn3V * heterMechAC1; - - heterMechAC1 = 0.5 * hn1V * heterMechAC1; - } - - // compute the stress term in the gradient of the concentration chemical - // potential, grad_mu_el = [C*(E-E0)*E0c]x, must be a vector with length dim - scalargradType grad_mu_el; - - if (c_dependent_misfit == true) - { - dealii::VectorizedArray E3[dim][dim], S3[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E3[i][j] = -(sfts1c[i][j] * h1V + sfts2c[i][j] * h2V + sfts3c[i][j] * h3V); - } - } - - if (n_dependent_stiffness == true) - { - computeStress(CIJ_combined, E3, S3); - } - else - { - computeStress(CIJ_list[0], E3, S3); - } - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - grad_mu_el[k] += - S3[i][j] * - (constV(0.5) * (uxx[i][j][k] + uxx[j][i][k]) + E3[i][j] * cx[k] - - (sfts1[i][j] * hn1V * n1x[k] + sfts2[i][j] * hn2V * n2x[k] + - sfts3[i][j] * hn3V * n3x[k])); - - grad_mu_el[k] += - -S[i][j] * - (sfts1c[i][j] * hn1V * n1x[k] + sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k] + - (sfts1cc[i][j] * h1V + sfts2cc[i][j] * h2V + sfts3cc[i][j] * h3V) * - cx[k]); - - if (n_dependent_stiffness == true) - { - grad_mu_el[k] += -S2[i][j] * (sfts1c[i][j] * hn1V * n1x[k] + - sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k]); - } - } - } - } - } - - // compute K*nx - scalargradType Knx1, Knx2, Knx3; - for (unsigned int a = 0; a < dim; a++) - { - Knx1[a] = 0.0; - Knx2[a] = 0.0; - Knx3[a] = 0.0; - for (unsigned int b = 0; b < dim; b++) - { - Knx1[a] += constV(Kn1[a][b]) * n1x[b]; - Knx2[a] += constV(Kn2[a][b]) * n2x[b]; - Knx3[a] += constV(Kn3[a][b]) * n3x[b]; - } - } - - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; - - modelResidualsList[1].scalarValueResidual = rn1V; - modelResidualsList[1].scalarGradResidual = rn1xV; - - modelResidualsList[2].scalarValueResidual = rn2V; - modelResidualsList[2].scalarGradResidual = rn2xV; - - modelResidualsList[3].scalarValueResidual = rn3V; - modelResidualsList[3].scalarGradResidual = rn3xV; - - modelResidualsList[4].vectorGradResidual = ruxV; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVariablesList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // n1 - scalarvalueType n1 = modelVariablesList[0].scalarValue; - - // n2 - scalarvalueType n2 = modelVariablesList[1].scalarValue; - - // n3 - scalarvalueType n3 = modelVariablesList[2].scalarValue; - - // u - vectorgradType ux = modelVariablesList[3].vectorGrad; - vectorgradType ruxV; - - // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the - // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; - E = symmetrize(ux); - - // Compute stress tensor (which is equal to the residual, Rux) - if (n_dependent_stiffness == true) - { - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; - CIJ_combined = - CIJ_list[0] * (constV(1.0) - h1V - h2V - h3V) + CIJ_list[1] * (h1V + h2V + h3V); - - computeStress(CIJ_combined, E, ruxV); - } - else - { - computeStress(CIJ_list[0], E, ruxV); - } - - modelRes.vectorGradResidual = ruxV; -} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - scalarvalueType total_energy_density = constV(0.0); - - // c - scalarvalueType c = modelVarList[0].scalarValue; - scalargradType cx = modelVarList[0].scalarGrad; - - // n1 - scalarvalueType n1 = modelVarList[1].scalarValue; - scalargradType n1x = modelVarList[1].scalarGrad; - - // n2 - scalarvalueType n2 = modelVarList[2].scalarValue; - scalargradType n2x = modelVarList[2].scalarGrad; - - // n3 - scalarvalueType n3 = modelVarList[3].scalarValue; - scalargradType n3x = modelVarList[3].scalarGrad; - - // u - vectorgradType ux = modelVarList[4].vectorGrad; - - scalarvalueType f_chem = - (constV(1.0) - (h1V + h2V + h3V)) * faV + (h1V + h2V + h3V) * fbV; - - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn1[i][j]) * n1x[i] * n1x[j]; - } - } -#if num_sop > 1 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn2[i][j]) * n2x[i] * n2x[j]; - } - } -#endif -#if num_sop > 2 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn3[i][j]) * n3x[i] * n3x[j]; - } - } -#endif - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // E2[i][j]= constV(0.5)*(ux[i][j]+ux[j][i])-( sfts1[i][j]*h1V + - // sfts2[i][j]*h2V + sfts3[i][j]*h3V); - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[2 * dim - 1 + dim / 3] - [2 * dim - 1 + dim / 3]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - scalarvalueType f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E2[i][j]; - } - } - - total_energy_density = f_chem + f_grad + f_el; - - assembler_lock.acquire(); - for (unsigned i = 0; i < c.size(); i++) - { - // For some reason, some of the values in this loop - if (c[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - this->energy_components[2] += f_el[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/run_num_1.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/run_num_1.txt deleted file mode 100644 index 39c8b850e..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/run_num_1.txt +++ /dev/null @@ -1 +0,0 @@ -run_008 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/run_num_2.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/run_num_2.txt deleted file mode 100644 index 10b18858f..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/run_num_2.txt +++ /dev/null @@ -1 +0,0 @@ -run_009 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/space_parameters.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/space_parameters.h deleted file mode 100644 index 989383580..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/space_parameters.h +++ /dev/null @@ -1,6 +0,0 @@ -// Parameters list for the parameters involved in mesh generation -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 8 -#define finiteElementDegree 1 diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/spat_ooa_results.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/spat_ooa_results.txt deleted file mode 100644 index 0e29d0d62..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/spat_ooa_results.txt +++ /dev/null @@ -1,4 +0,0 @@ -Results of 2D spatial order of accuracy test: -From coarse mesh to medium mesh: 1.48494896139 -From from medium mesh to fine mesh: 1.96770364326 -From from fine mesh to very fine mesh: 2.30070031779 diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/visitlog.py b/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/visitlog.py deleted file mode 100644 index dfa5cdbca..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_2D/visitlog.py +++ /dev/null @@ -1,57 +0,0 @@ -# Visit 2.7.3 log file -ScriptVersion = "2.7.3" -if ScriptVersion != Version(): - print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version()) -ShowAllWindows() -OpenDatabase("run_008/solution-100000.pvtu", 0) -# The UpdateDBPluginInfo RPC is not supported in the VisIt module so it will not be logged. -DefineScalarExpression("diff", "abs((c-pos_cmfe(, mesh,0))^2)") -AddPlot("Pseudocolor", "diff", 1, 1) -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.scaling = PseudocolorAtts.Linear # Linear, Log, Skew -PseudocolorAtts.skewFactor = 1 -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot -PseudocolorAtts.minFlag = 0 -PseudocolorAtts.min = 0 -PseudocolorAtts.maxFlag = 0 -PseudocolorAtts.max = 1 -PseudocolorAtts.centering = PseudocolorAtts.Natural # Natural, Nodal, Zonal -PseudocolorAtts.colorTableName = "hot" -PseudocolorAtts.invertColorTable = 0 -PseudocolorAtts.opacityType = PseudocolorAtts.FullyOpaque # ColorTable, FullyOpaque, Constant, Ramp, VariableRange -PseudocolorAtts.opacityVariable = "" -PseudocolorAtts.opacity = 1 -PseudocolorAtts.opacityVarMin = 0 -PseudocolorAtts.opacityVarMax = 1 -PseudocolorAtts.opacityVarMinFlag = 0 -PseudocolorAtts.opacityVarMaxFlag = 0 -PseudocolorAtts.pointSize = 0.05 -PseudocolorAtts.pointType = PseudocolorAtts.Point # Box, Axis, Icosahedron, Octahedron, Tetrahedron, SphereGeometry, Point, Sphere -PseudocolorAtts.pointSizeVarEnabled = 0 -PseudocolorAtts.pointSizeVar = "default" -PseudocolorAtts.pointSizePixels = 2 -PseudocolorAtts.lineType = PseudocolorAtts.Line # Line, Tube, Ribbon -PseudocolorAtts.lineStyle = PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH -PseudocolorAtts.lineWidth = 0 -PseudocolorAtts.tubeDisplayDensity = 10 -PseudocolorAtts.tubeRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.tubeRadiusAbsolute = 0.125 -PseudocolorAtts.tubeRadiusBBox = 0.005 -PseudocolorAtts.varyTubeRadius = 0 -PseudocolorAtts.varyTubeRadiusVariable = "" -PseudocolorAtts.varyTubeRadiusFactor = 10 -PseudocolorAtts.endPointType = PseudocolorAtts.None # None, Tails, Heads, Both -PseudocolorAtts.endPointStyle = PseudocolorAtts.Spheres # Spheres, Cones -PseudocolorAtts.endPointRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.endPointRadiusAbsolute = 1 -PseudocolorAtts.endPointRadiusBBox = 0.005 -PseudocolorAtts.endPointRatio = 2 -PseudocolorAtts.renderSurfaces = 1 -PseudocolorAtts.renderWireframe = 0 -PseudocolorAtts.renderPoints = 0 -PseudocolorAtts.smoothingLevel = 0 -PseudocolorAtts.legendFlag = 1 -PseudocolorAtts.lightingFlag = 1 -SetPlotOptions(PseudocolorAtts) -DrawPlots() -Query("Weighted Variable Sum", use_actual_data=1) diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/CMakeLists.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/ICs_and_BCs.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/ICs_and_BCs.h deleted file mode 100644 index 5243f9cd9..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/ICs_and_BCs.h +++ /dev/null @@ -1,187 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - -#define x_denom 1.0 -#define y_denom 1.0 -#define z_denom 1.0 -#define initial_interface_coeff 1.0 -#define initial_radius 5.5 -#define avg_Nd 0.004 - - if (index == 0) - { - // return the value of the initial concentration field at point p - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; - // return 0.02 + 1.0e-3*(2*(0.5 - (double)(std::rand() % 100 )/100.0)); -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (0.12 - 0.00) * (1 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#elif problemDIM == 3 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#endif - } - else if (index == 1) - { - // set result equal to the structural order paramter initial condition - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (1.0 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - -#elif problemDIM == 3 - // r=p.distance(Point(spanX/2.0,spanY/2.0,spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r-spanX/8.0)/(3*dx))); - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - - // planar interface - // r=sqrt((p.operator()(2)-spanZ/2.0)*(p.operator()(2)-spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r)/(initial_interface_coeff))); - // return - // 0.5*(1.0-std::tanh((r-initial_radius)/(initial_interface_coeff))); -#endif - return 0.0; - } - else if (index == 2) - { - scalar_IC = 0.0; - } - else if (index == 3) - { - scalar_IC = 0.0; - } - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - if (index == 4) - { - vector_IC(0) = 0.0; - vector_IC(1) = 0.0; - if (dim == 3) - { - vector_IC(2) = 0.0; - } - } - // ===================================================================== - } -}; - -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") - // Fourth input: BC value (ignored unless the BC type is "DIRICHLET") - // Odd inputs after the third: BC type - // Even inputs after the third: BC value - // Face numbering: starts at zero with the minimum of the first direction, one - // for the maximum of the first direction - // two for the minimum of the second direction, etc. - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(1, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(2, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(3, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(4, 0, "DIRICHLET", 0.0); - inputBCs(4, 1, "DIRICHLET", 0.0); - if (dim == 3) - { - inputBCs(4, 2, "DIRICHLET", 0.0); - } - - // ===================================================================== -} diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error.txt deleted file mode 100644 index 70b153878..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error.txt +++ /dev/null @@ -1 +0,0 @@ -0.000226726733005 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error1.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error1.txt deleted file mode 100644 index b0183ae2d..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error1.txt +++ /dev/null @@ -1 +0,0 @@ -0.0044260378927 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error2.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error2.txt deleted file mode 100644 index 41b6d8c6c..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error2.txt +++ /dev/null @@ -1 +0,0 @@ -0.00117394141853 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error3.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error3.txt deleted file mode 100644 index 67fa0e06a..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error3.txt +++ /dev/null @@ -1 +0,0 @@ -0.000283651053905 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error4.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error4.txt deleted file mode 100644 index 8cbef5208..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/error4.txt +++ /dev/null @@ -1 +0,0 @@ -5.74858859181e-05 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/getError.py b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/getError.py deleted file mode 100644 index bfae94293..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/getError.py +++ /dev/null @@ -1,78 +0,0 @@ -import sys -import math - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "100000" -output_num_2 = "100000" - -f = open('run_num_1.txt','r') -run_num_1 = f.read() -f.close() - -f = open('run_num_2.txt','r') -run_num_2 = f.read() -f.close() - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = False - -directory_1 = run_num_1+"/solution-"+output_num_1+".pvtu" -directory_2 = run_num_2+"/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))^2") - #DefineScalarExpression("diff","abs(("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0)))") -else: - OpenDatabase(directory_2) - #DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))^2") - DefineScalarExpression("diff","abs(("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0)))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -#Query("MinMax", use_actual_data=1) -#min_max_val = GetQueryOutputValue() -#error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -# Calculate the L2 error: -Query("Weighted Variable Sum", use_actual_data=1) -error = math.sqrt(GetQueryOutputValue()) - -text_file = open("error.txt","w") -text_file.write(str(error)) -text_file.close() - - - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/hoe_test_3D.py b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/hoe_test_3D.py deleted file mode 100644 index aa2e4c529..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/hoe_test_3D.py +++ /dev/null @@ -1,107 +0,0 @@ -import subprocess -import shutil -import glob -import math -import os.path - -# ---------------------------------------------------------------------------------------- -# Function that generates a header file for the simulation, compiles the PRISMS-PF code -# and runs the executable. -# ---------------------------------------------------------------------------------------- -def run_simulation(refineFactor,degree,subdivisionsX,subdivisionsY,subdivisionsZ,run_name): - - text_file = open("space_parameters.h","w") - text_file.write("// Parameters list for the parameters involved in mesh generation \n") - text_file.write("#define subdivisionsX " + str(subdivisionsX) + "\n") - text_file.write("#define subdivisionsY " + str(subdivisionsY) + "\n") - text_file.write("#define subdivisionsZ " + str(subdivisionsZ) + "\n") - text_file.write("#define refineFactor " + str(refineFactor) + "\n") - text_file.write("#define finiteElementDegree " + str(degree) + "\n") - text_file.close() - - subprocess.call(["make", "release"]) - #subprocess.call(["./main"]) - subprocess.call(["mpirun", "-n", "6", "main"]) - - subprocess.call(["mkdir",run_name]) - for output_files in glob.glob('*vtu'): - shutil.move(output_files,run_name) - -# ---------------------------------------------------------------------------------------- -# Function that calculates the maximum error between a run and a reference result. -# ---------------------------------------------------------------------------------------- -def getError(run_num): - - text_file = open("run_num_1.txt","w") - - if run_num < 10: - text_file.write('run_00'+str(run_num)) - elif run_num < 100: - text_file.write('run_0'+str(run_num)) - elif run_num < 1000: - text_file.write('run_'+str(run_num)) - else: - print "error: run number must be lower than 1000" - - text_file.close() - subprocess.call(["visit","-nowin", "-cli","-s","getError.py"]) - f = open('error.txt','r') - error = float(f.read()) - f.close() - - return error - -# ---------------------------------------------------------------------------------------- - -# Choose whether or not to re-run the reference simulation (warning, takes several hours) -re_run_ref_simulation = False - -# If files exist from previous tests, delete them -if os.path.exists("run_001") == True: - shutil.rmtree("run_001") -if os.path.exists("run_002") == True: - shutil.rmtree("run_002") -if os.path.exists("run_003") == True: - shutil.rmtree("run_003") -if os.path.exists("run_004") == True: - shutil.rmtree("run_004") -if os.path.exists("run_005") == True: - shutil.rmtree("run_005") -if os.path.exists("run_006") == True: - shutil.rmtree("run_006") -if re_run_ref_simulation == True: - if os.path.exists("reference_solution") == True: - shutil.rmtree("reference_solution") - -# Run simulations with varying mesh size and element order: -run_simulation(3,1,1,1,1,'run_001') -run_simulation(4,1,1,1,1,'run_002') -run_simulation(5,1,1,1,1,'run_003') -run_simulation(2,2,1,1,1,'run_004') -run_simulation(3,2,1,1,1,'run_005') -run_simulation(4,2,1,1,1,'run_006') -if re_run_ref_simulation == True: - run_simulation(7,1,1,1,1,'reference_solution') - - -# Find the error for runs 1-6 (as compared to the reference solution) -text_file = open("run_num_2.txt","w") -text_file.write('reference_solution') -text_file.close() - -error = [] -error.append(getError(1)) -error.append(getError(2)) -error.append(getError(3)) -error.append(getError(4)) -error.append(getError(5)) -error.append(getError(6)) - -# Calculate and output the error - -print "Error results: \n" -print "First order element error:", str(error[0]), "(refine level 3)", str(error[1]), "(refine level 4)", \ - str(error[2]), "(refine level 5)", "\n" - -print "Second order element error:", str(error[3]), "(refine level 2)", str(error[4]), "(refine level 3)", \ - str(error[5]), "(refine level 4)", "\n" diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/main.cc b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/main.cc deleted file mode 100644 index a62d5cdca..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/main.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" -#include "space_parameters.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/parameters.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/parameters.h deleted file mode 100644 index 34415938c..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/parameters.h +++ /dev/null @@ -1,101 +0,0 @@ -// Parameter list for the precipitate evolution example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 3 - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 8.0 -#define spanY 8.0 -#define spanZ 8.0 - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size #define subdivisionsX 3 #define subdivisionsY 3 #define subdivisionsZ 3 -// #define refineFactor 5 - -// Set the polynomial degree of the element (suggested values: 1 or 2) -// #define finiteElementDegree 2 - -// ================================================================================= -// Set the adaptive mesh refinement parameters -// ================================================================================= -// Set the flag determining if adaptive meshing is activated -#define hAdaptivity false - -// Set the maximum and minimum level of refinement -#define maxRefinementLevel (refineFactor) -#define minRefinementLevel (refineFactor - 2) - -// Set the fields used to determine the refinement. Fields determined by the -// order declared in "equations.h", starting at zero -#define refineCriterionFields \ - { \ - 1, 2, 3 \ - } - -// Set the maximum and minimum value of the fields where the mesh should be -// refined -#define refineWindowMax \ - { \ - 0.99, 0.99, 0.99 \ - } -#define refineWindowMin \ - { \ - 0.01, 0.01, 0.01 \ - } - -// Set the number of time steps between remeshing operations -#define skipRemeshingSteps 1000 - -// ================================================================================= -// Set the time step parameters -// ================================================================================= -// The size of the time step -#define timeStep 8.0e-6 -#define timeFinal 100000000 -#define timeIncrements 100000 - -// ================================================================================= -// Set the elliptic solver parameters -// ================================================================================= -// The solver type (currently the only recommended option is conjugate gradient) -#define solverType SolverCG - -// The flag that determines whether the tolerance for solver convergence should -// be an absolute tolerance (absTol=true) or a relative tolerance (absTol=false) -#define absTol true - -// The tolerance for convergence (L2 norm of the residual) -#define solverTolerance 1.0e-4 - -// The maximum number of solver iterations per time step -#define maxSolverIterations 1000 - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 10 - -// ================================================================================= -// Set the flag determining if the total free energy is calculated for each -// output -// ================================================================================= -#define calcEnergy false diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/residuals.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/residuals.h deleted file mode 100644 index 3c8190016..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/residuals.h +++ /dev/null @@ -1,682 +0,0 @@ -// List of variables and residual equations for the Precipitate Evolution -// example application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 5 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "c", "n1", "n2", "n3", "u" \ - } -#define variable_type \ - { \ - "SCALAR", "SCALAR", "SCALAR", "SCALAR", "VECTOR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC", "PARABOLIC", "PARABOLIC", "PARABOLIC", "ELLIPTIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - true, true, true, true, false \ - } -#define need_grad \ - { \ - true, true, true, true, true \ - } -#define need_hess \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - true, true, true, true, false \ - } -#define need_grad_residual \ - { \ - true, true, true, true, true \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqn for the left-hand-side of the iterative solver for elliptic equations -#define need_val_LHS \ - { \ - false, true, true, true, false \ - } -#define need_grad_LHS \ - { \ - false, false, false, false, true \ - } -#define need_hess_LHS \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation for the left-hand-side of the -// iterative solver for elliptic equations has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual_LHS \ - { \ - false, false, false, false, false \ - } -#define need_grad_residual_LHS \ - { \ - false, false, false, false, true \ - } - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Cahn-Hilliard mobility -#define McV 1.0 - -// Allen-Cahn mobilities -#define Mn1V 50.0 -#define Mn2V 50.0 -#define Mn3V 50.0 - -// Gradient energy coefficients -double Kn1[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn2[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn3[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; - -// define energy barrier coefficient (used to tune the interfacial energy) -#define W -1.0 - -// Define mechanical properties -#define n_dependent_stiffness false -// Mechanical symmetry of the material and stiffness parameters -// If n_dependent_stiffness == false the first entry is used for all phases -#define MaterialModels \ - { \ - { \ - "ISOTROPIC" \ - } \ - } -#define MaterialConstants \ - { \ - { \ - 1.0, 0.3 \ - } \ - } - -// Stress-free transformation strains -// Linear fits for the stress-free transformation strains in for sfts = -// sfts_linear * c + sfts_const -double sfts_linear1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -// Free energy expressions -#define faV (24.7939 * c * c - 1.6752 * c - 1.9453e-06) -#define facV (49.5878 * c - 1.6752) -#define faccV (49.5878) -#define fbV (37.9316 * c * c - 10.7373 * c + 0.5401) -#define fbcV (75.8633 * c - 10.7373) -#define fbccV (75.8633) -#define h1V (3.0 * n1 * n1 - 2.0 * n1 * n1 * n1) -#define h2V (3.0 * n2 * n2 - 2.0 * n2 * n2 * n2) -#define h3V (3.0 * n3 * n3 - 2.0 * n3 * n3 * n3) -#define hn1V (6.0 * n1 - 6.0 * n1 * n1) -#define hn2V (6.0 * n2 - 6.0 * n2 * n2) -#define hn3V (6.0 * n3 - 6.0 * n3 * n3) - -// This double-well function can be used to tune the interfacial energy -#define fbarrierV (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1) -#define fbarriernV (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1) - -// Residuals -#define rcV (c) -#define rcxTemp \ - (cx * ((1.0 - h1V - h2V - h3V) * faccV + (h1V + h2V + h3V) * fbccV) + \ - n1x * ((fbcV - facV) * hn1V) + n2x * ((fbcV - facV) * hn2V) + \ - n3x * ((fbcV - facV) * hn3V)) -#define rcxV (constV(-timeStep * McV) * rcxTemp) - -#define rn1V \ - (n1 - constV(timeStep * Mn1V) * \ - ((fbV - faV) * hn1V + W * fbarriernV + nDependentMisfitAC1)) -#define rn2V (n2 - constV(timeStep * Mn2V) * ((fbV - faV) * hn2V)) -#define rn3V (n3 - constV(timeStep * Mn3V) * ((fbV - faV) * hn3V)) -#define rn1xV (constV(-timeStep * Mn1V) * Knx1) -#define rn2xV (constV(-timeStep * Mn2V) * Knx2) -#define rn3xV (constV(-timeStep * Mn3V) * Knx3) - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // The concentration and its derivatives (names here should match those in the - // macros above) - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - // The first order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n1 = modelVariablesList[1].scalarValue; - scalargradType n1x = modelVariablesList[1].scalarGrad; - - // The second order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n2 = modelVariablesList[2].scalarValue; - scalargradType n2x = modelVariablesList[2].scalarGrad; - - // The third order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n3 = modelVariablesList[3].scalarValue; - scalargradType n3x = modelVariablesList[3].scalarGrad; - - // The derivative of the displacement vector (names here should match those in - // the macros above) - vectorgradType ux = modelVariablesList[4].vectorGrad; - vectorgradType ruxV; - - vectorhessType uxx; - - if (c_dependent_misfit == true) - { - uxx = modelVariablesList[4].vectorHess; - } - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - // Fill residual corresponding to mechanics - // R=-C*(E-E0) - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - ruxV[i][j] = -S[i][j]; - } - } - - // Compute one of the stress terms in the order parameter chemical potential, - // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - nDependentMisfitAC1 += S[i][j] * (sfts1[i][j]); - nDependentMisfitAC2 += S[i][j] * (sfts2[i][j]); - nDependentMisfitAC3 += S[i][j] * (sfts3[i][j]); - } - } - - nDependentMisfitAC1 *= -hn1V; - nDependentMisfitAC2 *= -hn2V; - nDependentMisfitAC3 *= -hn3V; - - // Compute the other stress term in the order parameter chemical potential, - // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray heterMechAC2 = constV(0.0); - dealii::VectorizedArray heterMechAC3 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; - - if (n_dependent_stiffness == true) - { - // computeStress(CIJ_diff, E2, S2); - computeStress(CIJ_list[1] - CIJ_list[0], E2, S2); - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - heterMechAC1 += S2[i][j] * E2[i][j]; - } - } - // Aside from HnpV, heterMechAC1, heterMechAC2, and heterMechAC3 are equal - heterMechAC2 = 0.5 * hn2V * heterMechAC1; - heterMechAC3 = 0.5 * hn3V * heterMechAC1; - - heterMechAC1 = 0.5 * hn1V * heterMechAC1; - } - - // compute the stress term in the gradient of the concentration chemical - // potential, grad_mu_el = [C*(E-E0)*E0c]x, must be a vector with length dim - scalargradType grad_mu_el; - - if (c_dependent_misfit == true) - { - dealii::VectorizedArray E3[dim][dim], S3[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E3[i][j] = -(sfts1c[i][j] * h1V + sfts2c[i][j] * h2V + sfts3c[i][j] * h3V); - } - } - - if (n_dependent_stiffness == true) - { - computeStress(CIJ_combined, E3, S3); - } - else - { - computeStress(CIJ_list[0], E3, S3); - } - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - grad_mu_el[k] += - S3[i][j] * - (constV(0.5) * (uxx[i][j][k] + uxx[j][i][k]) + E3[i][j] * cx[k] - - (sfts1[i][j] * hn1V * n1x[k] + sfts2[i][j] * hn2V * n2x[k] + - sfts3[i][j] * hn3V * n3x[k])); - - grad_mu_el[k] += - -S[i][j] * - (sfts1c[i][j] * hn1V * n1x[k] + sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k] + - (sfts1cc[i][j] * h1V + sfts2cc[i][j] * h2V + sfts3cc[i][j] * h3V) * - cx[k]); - - if (n_dependent_stiffness == true) - { - grad_mu_el[k] += -S2[i][j] * (sfts1c[i][j] * hn1V * n1x[k] + - sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k]); - } - } - } - } - } - - // compute K*nx - scalargradType Knx1, Knx2, Knx3; - for (unsigned int a = 0; a < dim; a++) - { - Knx1[a] = 0.0; - Knx2[a] = 0.0; - Knx3[a] = 0.0; - for (unsigned int b = 0; b < dim; b++) - { - Knx1[a] += constV(Kn1[a][b]) * n1x[b]; - Knx2[a] += constV(Kn2[a][b]) * n2x[b]; - Knx3[a] += constV(Kn3[a][b]) * n3x[b]; - } - } - - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; - - modelResidualsList[1].scalarValueResidual = rn1V; - modelResidualsList[1].scalarGradResidual = rn1xV; - - modelResidualsList[2].scalarValueResidual = rn2V; - modelResidualsList[2].scalarGradResidual = rn2xV; - - modelResidualsList[3].scalarValueResidual = rn3V; - modelResidualsList[3].scalarGradResidual = rn3xV; - - modelResidualsList[4].vectorGradResidual = ruxV; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVariablesList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // n1 - scalarvalueType n1 = modelVariablesList[0].scalarValue; - - // n2 - scalarvalueType n2 = modelVariablesList[1].scalarValue; - - // n3 - scalarvalueType n3 = modelVariablesList[2].scalarValue; - - // u - vectorgradType ux = modelVariablesList[3].vectorGrad; - vectorgradType ruxV; - - // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the - // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; - E = symmetrize(ux); - - // Compute stress tensor (which is equal to the residual, Rux) - if (n_dependent_stiffness == true) - { - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; - CIJ_combined = - CIJ_list[0] * (constV(1.0) - h1V - h2V - h3V) + CIJ_list[1] * (h1V + h2V + h3V); - - computeStress(CIJ_combined, E, ruxV); - } - else - { - computeStress(CIJ_list[0], E, ruxV); - } - - modelRes.vectorGradResidual = ruxV; -} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - scalarvalueType total_energy_density = constV(0.0); - - // c - scalarvalueType c = modelVarList[0].scalarValue; - scalargradType cx = modelVarList[0].scalarGrad; - - // n1 - scalarvalueType n1 = modelVarList[1].scalarValue; - scalargradType n1x = modelVarList[1].scalarGrad; - - // n2 - scalarvalueType n2 = modelVarList[2].scalarValue; - scalargradType n2x = modelVarList[2].scalarGrad; - - // n3 - scalarvalueType n3 = modelVarList[3].scalarValue; - scalargradType n3x = modelVarList[3].scalarGrad; - - // u - vectorgradType ux = modelVarList[4].vectorGrad; - - scalarvalueType f_chem = - (constV(1.0) - (h1V + h2V + h3V)) * faV + (h1V + h2V + h3V) * fbV; - - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn1[i][j]) * n1x[i] * n1x[j]; - } - } -#if num_sop > 1 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn2[i][j]) * n2x[i] * n2x[j]; - } - } -#endif -#if num_sop > 2 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn3[i][j]) * n3x[i] * n3x[j]; - } - } -#endif - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // E2[i][j]= constV(0.5)*(ux[i][j]+ux[j][i])-( sfts1[i][j]*h1V + - // sfts2[i][j]*h2V + sfts3[i][j]*h3V); - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[2 * dim - 1 + dim / 3] - [2 * dim - 1 + dim / 3]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - scalarvalueType f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E2[i][j]; - } - } - - total_energy_density = f_chem + f_grad + f_el; - - assembler_lock.acquire(); - for (unsigned i = 0; i < c.size(); i++) - { - // For some reason, some of the values in this loop - if (c[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - this->energy_components[2] += f_el[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/run_num_1.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/run_num_1.txt deleted file mode 100644 index b632c805c..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/run_num_1.txt +++ /dev/null @@ -1 +0,0 @@ -run_006 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/run_num_2.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/run_num_2.txt deleted file mode 100644 index 5396e09d4..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/run_num_2.txt +++ /dev/null @@ -1 +0,0 @@ -reference_solution \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/space_parameters.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/space_parameters.h deleted file mode 100644 index d0a932604..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/space_parameters.h +++ /dev/null @@ -1,6 +0,0 @@ -// Parameters list for the parameters involved in mesh generation -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 4 -#define finiteElementDegree 2 diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/visitlog.py b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/visitlog.py deleted file mode 100644 index 090b61656..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D/visitlog.py +++ /dev/null @@ -1,57 +0,0 @@ -# Visit 2.7.0 log file -ScriptVersion = "2.7.0" -if ScriptVersion != Version(): - print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version()) -ShowAllWindows() -OpenDatabase("run_006/solution-100000.pvtu", 0) -# The UpdateDBPluginInfo RPC is not supported in the VisIt module so it will not be logged. -DefineScalarExpression("diff", "(c-pos_cmfe(, mesh,0))^2") -AddPlot("Pseudocolor", "diff", 1, 1) -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.scaling = PseudocolorAtts.Linear # Linear, Log, Skew -PseudocolorAtts.skewFactor = 1 -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot -PseudocolorAtts.minFlag = 0 -PseudocolorAtts.min = 0 -PseudocolorAtts.maxFlag = 0 -PseudocolorAtts.max = 1 -PseudocolorAtts.centering = PseudocolorAtts.Natural # Natural, Nodal, Zonal -PseudocolorAtts.colorTableName = "hot" -PseudocolorAtts.invertColorTable = 0 -PseudocolorAtts.opacityType = PseudocolorAtts.FullyOpaque # ColorTable, FullyOpaque, Constant, Ramp, VariableRange -PseudocolorAtts.opacityVariable = "" -PseudocolorAtts.opacity = 1 -PseudocolorAtts.opacityVarMin = 0 -PseudocolorAtts.opacityVarMax = 1 -PseudocolorAtts.opacityVarMinFlag = 0 -PseudocolorAtts.opacityVarMaxFlag = 0 -PseudocolorAtts.pointSize = 0.05 -PseudocolorAtts.pointType = PseudocolorAtts.Point # Box, Axis, Icosahedron, Octahedron, Tetrahedron, SphereGeometry, Point, Sphere -PseudocolorAtts.pointSizeVarEnabled = 0 -PseudocolorAtts.pointSizeVar = "default" -PseudocolorAtts.pointSizePixels = 2 -PseudocolorAtts.lineType = PseudocolorAtts.Line # Line, Tube, Ribbon -PseudocolorAtts.lineStyle = PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH -PseudocolorAtts.lineWidth = 0 -PseudocolorAtts.tubeDisplayDensity = 10 -PseudocolorAtts.tubeRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.tubeRadiusAbsolute = 0.125 -PseudocolorAtts.tubeRadiusBBox = 0.005 -PseudocolorAtts.varyTubeRadius = 0 -PseudocolorAtts.varyTubeRadiusVariable = "" -PseudocolorAtts.varyTubeRadiusFactor = 10 -PseudocolorAtts.endPointType = PseudocolorAtts.None # None, Tails, Heads, Both -PseudocolorAtts.endPointStyle = PseudocolorAtts.Spheres # Spheres, Cones -PseudocolorAtts.endPointRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.endPointRadiusAbsolute = 1 -PseudocolorAtts.endPointRadiusBBox = 0.005 -PseudocolorAtts.endPointRatio = 2 -PseudocolorAtts.renderSurfaces = 1 -PseudocolorAtts.renderWireframe = 0 -PseudocolorAtts.renderPoints = 0 -PseudocolorAtts.smoothingLevel = 0 -PseudocolorAtts.legendFlag = 1 -PseudocolorAtts.lightingFlag = 1 -SetPlotOptions(PseudocolorAtts) -DrawPlots() -Query("Weighted Variable Sum", use_actual_data=1) diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/CMakeLists.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/ICs_and_BCs.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/ICs_and_BCs.h deleted file mode 100644 index 5243f9cd9..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/ICs_and_BCs.h +++ /dev/null @@ -1,187 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - -#define x_denom 1.0 -#define y_denom 1.0 -#define z_denom 1.0 -#define initial_interface_coeff 1.0 -#define initial_radius 5.5 -#define avg_Nd 0.004 - - if (index == 0) - { - // return the value of the initial concentration field at point p - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; - // return 0.02 + 1.0e-3*(2*(0.5 - (double)(std::rand() % 100 )/100.0)); -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (0.12 - 0.00) * (1 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#elif problemDIM == 3 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#endif - } - else if (index == 1) - { - // set result equal to the structural order paramter initial condition - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (1.0 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - -#elif problemDIM == 3 - // r=p.distance(Point(spanX/2.0,spanY/2.0,spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r-spanX/8.0)/(3*dx))); - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - - // planar interface - // r=sqrt((p.operator()(2)-spanZ/2.0)*(p.operator()(2)-spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r)/(initial_interface_coeff))); - // return - // 0.5*(1.0-std::tanh((r-initial_radius)/(initial_interface_coeff))); -#endif - return 0.0; - } - else if (index == 2) - { - scalar_IC = 0.0; - } - else if (index == 3) - { - scalar_IC = 0.0; - } - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - if (index == 4) - { - vector_IC(0) = 0.0; - vector_IC(1) = 0.0; - if (dim == 3) - { - vector_IC(2) = 0.0; - } - } - // ===================================================================== - } -}; - -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") - // Fourth input: BC value (ignored unless the BC type is "DIRICHLET") - // Odd inputs after the third: BC type - // Even inputs after the third: BC value - // Face numbering: starts at zero with the minimum of the first direction, one - // for the maximum of the first direction - // two for the minimum of the second direction, etc. - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(1, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(2, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(3, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(4, 0, "DIRICHLET", 0.0); - inputBCs(4, 1, "DIRICHLET", 0.0); - if (dim == 3) - { - inputBCs(4, 2, "DIRICHLET", 0.0); - } - - // ===================================================================== -} diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error.txt deleted file mode 100644 index dc11e02e0..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error.txt +++ /dev/null @@ -1 +0,0 @@ -0.0140394102896 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error1.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error1.txt deleted file mode 100644 index b0183ae2d..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error1.txt +++ /dev/null @@ -1 +0,0 @@ -0.0044260378927 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error2.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error2.txt deleted file mode 100644 index 41b6d8c6c..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error2.txt +++ /dev/null @@ -1 +0,0 @@ -0.00117394141853 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error3.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error3.txt deleted file mode 100644 index 67fa0e06a..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error3.txt +++ /dev/null @@ -1 +0,0 @@ -0.000283651053905 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error4.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error4.txt deleted file mode 100644 index 8cbef5208..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/error4.txt +++ /dev/null @@ -1 +0,0 @@ -5.74858859181e-05 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/getError.py b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/getError.py deleted file mode 100644 index bdb92b746..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/getError.py +++ /dev/null @@ -1,83 +0,0 @@ -import sys -import math - -variable_1 = 'c' -variable_2 = 'c' - -f = open('output_num_1.txt','r') -output_num_1 = f.read() -f.close() - -f = open('output_num_2.txt','r') -output_num_2 = f.read() -f.close() - -f = open('run_num_1.txt','r') -run_num_1 = f.read() -f.close() - -f = open('run_num_2.txt','r') -run_num_2 = f.read() -f.close() - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = False - -directory_1 = run_num_1+"/solution-"+output_num_1+".pvtu" -directory_2 = run_num_2+"/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))^2") - #DefineScalarExpression("diff","abs(("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0)))") -else: - OpenDatabase(directory_2) - #DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))^2") - DefineScalarExpression("diff","abs(("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0)))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -#Query("MinMax", use_actual_data=1) -#min_max_val = GetQueryOutputValue() -#error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -# Calculate the L2 error: -Query("Weighted Variable Sum", use_actual_data=1) -error = math.sqrt(GetQueryOutputValue()) - -text_file = open("error.txt","w") -text_file.write(str(error)) -text_file.close() - - - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/hoe_test_3D_timestep.py b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/hoe_test_3D_timestep.py deleted file mode 100644 index 04f905142..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/hoe_test_3D_timestep.py +++ /dev/null @@ -1,123 +0,0 @@ -import subprocess -import shutil -import glob -import math -import os.path - -# ---------------------------------------------------------------------------------------- -# Function that generates a header file for the simulation, compiles the PRISMS-PF code -# and runs the executable. -# ---------------------------------------------------------------------------------------- -def run_simulation(refineFactor,degree,subdivisionsX,subdivisionsY,subdivisionsZ,timeIncrements,timeStep,run_name): - - timeFinal = 100000000 - skipImplicitSolves = 10000000 - - text_file = open("time_and_space_parameters.h","w") - text_file.write("// Parameters list for the parameters involved in mesh generation and time stepping \n") - text_file.write("#define subdivisionsX " + str(subdivisionsX) + "\n") - text_file.write("#define subdivisionsY " + str(subdivisionsY) + "\n") - text_file.write("#define subdivisionsZ " + str(subdivisionsZ) + "\n") - text_file.write("#define refineFactor " + str(refineFactor) + "\n") - text_file.write("#define finiteElementDegree " + str(degree) + "\n") - - text_file.write("// Parameters list for the parameters involved in time stepping \n") - text_file.write("#define timeStep " + str(timeStep) + "\n") - text_file.write("#define timeIncrements " + str(timeIncrements) + "\n") - text_file.write("#define timeFinal " + str(timeFinal) + "\n") - text_file.write("#define skipImplicitSolves " + str(skipImplicitSolves) + "\n") - text_file.close() - - subprocess.call(["make", "release"]) - #subprocess.call(["./main"]) - subprocess.call(["mpirun", "-n", "4", "main"]) - - subprocess.call(["mkdir",run_name]) - for output_files in glob.glob('*vtu'): - shutil.move(output_files,run_name) - -# ---------------------------------------------------------------------------------------- -# Function that calculates the maximum error between a run and a reference result. -# ---------------------------------------------------------------------------------------- -def getError(run_num,maxIter): - - text_file = open("run_num_1.txt","w") - - if run_num < 10: - text_file.write('run_00'+str(run_num)) - elif run_num < 100: - text_file.write('run_0'+str(run_num)) - elif run_num < 1000: - text_file.write('run_'+str(run_num)) - else: - print "error: run number must be lower than 1000" - - text_file.close() - - text_file = open("output_num_1.txt","w") - text_file.write(maxIter) - text_file.close() - - subprocess.call(["visit","-nowin", "-cli","-s","getError.py"]) - f = open('error.txt','r') - error = float(f.read()) - f.close() - - return error - -# ---------------------------------------------------------------------------------------- - -# Choose whether or not to re-run the reference simulation (warning, takes several hours) -re_run_ref_simulation = False - -# If files exist from previous tests, delete them -if os.path.exists("run_001") == True: - shutil.rmtree("run_001") -if os.path.exists("run_002") == True: - shutil.rmtree("run_002") -if os.path.exists("run_003") == True: - shutil.rmtree("run_003") -if os.path.exists("run_004") == True: - shutil.rmtree("run_004") -if os.path.exists("run_005") == True: - shutil.rmtree("run_005") -if os.path.exists("run_006") == True: - shutil.rmtree("run_006") -if re_run_ref_simulation == True: - if os.path.exists("reference_solution") == True: - shutil.rmtree("reference_solution") - -# Run simulations with varying mesh size and element order: -run_simulation(4,1,1,1,1,1600,5e-4,'run_001') # Highest stable dt for this order and mesh size -run_simulation(0,2,5,5,5,1600,5e-4,'run_002') -run_simulation(0,2,5,5,5,800,1.0e-3,'run_003') -run_simulation(0,2,5,5,5,850,0.8/850.0,'run_004') # Highest stable dt for this order and mesh size -run_simulation(4,1,1,1,1,100000,8.0e-6,'run_005') -run_simulation(0,2,5,5,5,100000,8.0e-6,'run_006') -if re_run_ref_simulation == True: - run_simulation(7,1,1,1,1,100000,8.0e-6,'reference_solution') - - -# Find the error for runs 1-6 (as compared to the reference solution) -text_file = open("run_num_2.txt","w") -text_file.write('reference_solution') -text_file.close() - -text_file = open("output_num_2.txt","w") -text_file.write('100000') -text_file.close() - - - -error = [] -error.append(getError(1,'01600')) -error.append(getError(2,'01600')) -error.append(getError(3,'0800')) -error.append(getError(4,'0850')) -error.append(getError(5,'100000')) -error.append(getError(6,'100000')) - -# Calculate and output the error - -print "Error results: \n" -print str(error[0]), str(error[1]), str(error[2]), str(error[3]), str(error[4]), str(error[5]) diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/main.cc b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/main.cc deleted file mode 100644 index fba809548..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/main.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" -#include "time_and_space_parameters.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/output_num_1.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/output_num_1.txt deleted file mode 100644 index 483fb82b6..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/output_num_1.txt +++ /dev/null @@ -1 +0,0 @@ -100000 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/output_num_2.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/output_num_2.txt deleted file mode 100644 index 483fb82b6..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/output_num_2.txt +++ /dev/null @@ -1 +0,0 @@ -100000 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/parameters.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/parameters.h deleted file mode 100644 index 0112569b6..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/parameters.h +++ /dev/null @@ -1,101 +0,0 @@ -// Parameter list for the precipitate evolution example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 3 - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 8.0 -#define spanY 8.0 -#define spanZ 8.0 - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size #define subdivisionsX 3 #define subdivisionsY 3 #define subdivisionsZ 3 -// #define refineFactor 5 - -// Set the polynomial degree of the element (suggested values: 1 or 2) -// #define finiteElementDegree 2 - -// ================================================================================= -// Set the adaptive mesh refinement parameters -// ================================================================================= -// Set the flag determining if adaptive meshing is activated -#define hAdaptivity false - -// Set the maximum and minimum level of refinement -#define maxRefinementLevel (refineFactor) -#define minRefinementLevel (refineFactor - 2) - -// Set the fields used to determine the refinement. Fields determined by the -// order declared in "equations.h", starting at zero -#define refineCriterionFields \ - { \ - 1, 2, 3 \ - } - -// Set the maximum and minimum value of the fields where the mesh should be -// refined -#define refineWindowMax \ - { \ - 0.99, 0.99, 0.99 \ - } -#define refineWindowMin \ - { \ - 0.01, 0.01, 0.01 \ - } - -// Set the number of time steps between remeshing operations -#define skipRemeshingSteps 1000 - -// ================================================================================= -// Set the time step parameters -// ================================================================================= -// The size of the time step -// #define timeStep 8.0e-6 -// #define timeFinal 100000000 -// #define timeIncrements 100000 - -// ================================================================================= -// Set the elliptic solver parameters -// ================================================================================= -// The solver type (currently the only recommended option is conjugate gradient) -#define solverType SolverCG - -// The flag that determines whether the tolerance for solver convergence should -// be an absolute tolerance (absTol=true) or a relative tolerance (absTol=false) -#define absTol true - -// The tolerance for convergence (L2 norm of the residual) -#define solverTolerance 1.0e-4 - -// The maximum number of solver iterations per time step -#define maxSolverIterations 1000 - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 10 - -// ================================================================================= -// Set the flag determining if the total free energy is calculated for each -// output -// ================================================================================= -#define calcEnergy false diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/residuals.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/residuals.h deleted file mode 100644 index 3c8190016..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/residuals.h +++ /dev/null @@ -1,682 +0,0 @@ -// List of variables and residual equations for the Precipitate Evolution -// example application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 5 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "c", "n1", "n2", "n3", "u" \ - } -#define variable_type \ - { \ - "SCALAR", "SCALAR", "SCALAR", "SCALAR", "VECTOR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC", "PARABOLIC", "PARABOLIC", "PARABOLIC", "ELLIPTIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - true, true, true, true, false \ - } -#define need_grad \ - { \ - true, true, true, true, true \ - } -#define need_hess \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - true, true, true, true, false \ - } -#define need_grad_residual \ - { \ - true, true, true, true, true \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqn for the left-hand-side of the iterative solver for elliptic equations -#define need_val_LHS \ - { \ - false, true, true, true, false \ - } -#define need_grad_LHS \ - { \ - false, false, false, false, true \ - } -#define need_hess_LHS \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation for the left-hand-side of the -// iterative solver for elliptic equations has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual_LHS \ - { \ - false, false, false, false, false \ - } -#define need_grad_residual_LHS \ - { \ - false, false, false, false, true \ - } - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Cahn-Hilliard mobility -#define McV 1.0 - -// Allen-Cahn mobilities -#define Mn1V 50.0 -#define Mn2V 50.0 -#define Mn3V 50.0 - -// Gradient energy coefficients -double Kn1[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn2[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn3[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; - -// define energy barrier coefficient (used to tune the interfacial energy) -#define W -1.0 - -// Define mechanical properties -#define n_dependent_stiffness false -// Mechanical symmetry of the material and stiffness parameters -// If n_dependent_stiffness == false the first entry is used for all phases -#define MaterialModels \ - { \ - { \ - "ISOTROPIC" \ - } \ - } -#define MaterialConstants \ - { \ - { \ - 1.0, 0.3 \ - } \ - } - -// Stress-free transformation strains -// Linear fits for the stress-free transformation strains in for sfts = -// sfts_linear * c + sfts_const -double sfts_linear1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -// Free energy expressions -#define faV (24.7939 * c * c - 1.6752 * c - 1.9453e-06) -#define facV (49.5878 * c - 1.6752) -#define faccV (49.5878) -#define fbV (37.9316 * c * c - 10.7373 * c + 0.5401) -#define fbcV (75.8633 * c - 10.7373) -#define fbccV (75.8633) -#define h1V (3.0 * n1 * n1 - 2.0 * n1 * n1 * n1) -#define h2V (3.0 * n2 * n2 - 2.0 * n2 * n2 * n2) -#define h3V (3.0 * n3 * n3 - 2.0 * n3 * n3 * n3) -#define hn1V (6.0 * n1 - 6.0 * n1 * n1) -#define hn2V (6.0 * n2 - 6.0 * n2 * n2) -#define hn3V (6.0 * n3 - 6.0 * n3 * n3) - -// This double-well function can be used to tune the interfacial energy -#define fbarrierV (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1) -#define fbarriernV (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1) - -// Residuals -#define rcV (c) -#define rcxTemp \ - (cx * ((1.0 - h1V - h2V - h3V) * faccV + (h1V + h2V + h3V) * fbccV) + \ - n1x * ((fbcV - facV) * hn1V) + n2x * ((fbcV - facV) * hn2V) + \ - n3x * ((fbcV - facV) * hn3V)) -#define rcxV (constV(-timeStep * McV) * rcxTemp) - -#define rn1V \ - (n1 - constV(timeStep * Mn1V) * \ - ((fbV - faV) * hn1V + W * fbarriernV + nDependentMisfitAC1)) -#define rn2V (n2 - constV(timeStep * Mn2V) * ((fbV - faV) * hn2V)) -#define rn3V (n3 - constV(timeStep * Mn3V) * ((fbV - faV) * hn3V)) -#define rn1xV (constV(-timeStep * Mn1V) * Knx1) -#define rn2xV (constV(-timeStep * Mn2V) * Knx2) -#define rn3xV (constV(-timeStep * Mn3V) * Knx3) - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // The concentration and its derivatives (names here should match those in the - // macros above) - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - // The first order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n1 = modelVariablesList[1].scalarValue; - scalargradType n1x = modelVariablesList[1].scalarGrad; - - // The second order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n2 = modelVariablesList[2].scalarValue; - scalargradType n2x = modelVariablesList[2].scalarGrad; - - // The third order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n3 = modelVariablesList[3].scalarValue; - scalargradType n3x = modelVariablesList[3].scalarGrad; - - // The derivative of the displacement vector (names here should match those in - // the macros above) - vectorgradType ux = modelVariablesList[4].vectorGrad; - vectorgradType ruxV; - - vectorhessType uxx; - - if (c_dependent_misfit == true) - { - uxx = modelVariablesList[4].vectorHess; - } - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - // Fill residual corresponding to mechanics - // R=-C*(E-E0) - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - ruxV[i][j] = -S[i][j]; - } - } - - // Compute one of the stress terms in the order parameter chemical potential, - // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - nDependentMisfitAC1 += S[i][j] * (sfts1[i][j]); - nDependentMisfitAC2 += S[i][j] * (sfts2[i][j]); - nDependentMisfitAC3 += S[i][j] * (sfts3[i][j]); - } - } - - nDependentMisfitAC1 *= -hn1V; - nDependentMisfitAC2 *= -hn2V; - nDependentMisfitAC3 *= -hn3V; - - // Compute the other stress term in the order parameter chemical potential, - // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray heterMechAC2 = constV(0.0); - dealii::VectorizedArray heterMechAC3 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; - - if (n_dependent_stiffness == true) - { - // computeStress(CIJ_diff, E2, S2); - computeStress(CIJ_list[1] - CIJ_list[0], E2, S2); - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - heterMechAC1 += S2[i][j] * E2[i][j]; - } - } - // Aside from HnpV, heterMechAC1, heterMechAC2, and heterMechAC3 are equal - heterMechAC2 = 0.5 * hn2V * heterMechAC1; - heterMechAC3 = 0.5 * hn3V * heterMechAC1; - - heterMechAC1 = 0.5 * hn1V * heterMechAC1; - } - - // compute the stress term in the gradient of the concentration chemical - // potential, grad_mu_el = [C*(E-E0)*E0c]x, must be a vector with length dim - scalargradType grad_mu_el; - - if (c_dependent_misfit == true) - { - dealii::VectorizedArray E3[dim][dim], S3[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E3[i][j] = -(sfts1c[i][j] * h1V + sfts2c[i][j] * h2V + sfts3c[i][j] * h3V); - } - } - - if (n_dependent_stiffness == true) - { - computeStress(CIJ_combined, E3, S3); - } - else - { - computeStress(CIJ_list[0], E3, S3); - } - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - grad_mu_el[k] += - S3[i][j] * - (constV(0.5) * (uxx[i][j][k] + uxx[j][i][k]) + E3[i][j] * cx[k] - - (sfts1[i][j] * hn1V * n1x[k] + sfts2[i][j] * hn2V * n2x[k] + - sfts3[i][j] * hn3V * n3x[k])); - - grad_mu_el[k] += - -S[i][j] * - (sfts1c[i][j] * hn1V * n1x[k] + sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k] + - (sfts1cc[i][j] * h1V + sfts2cc[i][j] * h2V + sfts3cc[i][j] * h3V) * - cx[k]); - - if (n_dependent_stiffness == true) - { - grad_mu_el[k] += -S2[i][j] * (sfts1c[i][j] * hn1V * n1x[k] + - sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k]); - } - } - } - } - } - - // compute K*nx - scalargradType Knx1, Knx2, Knx3; - for (unsigned int a = 0; a < dim; a++) - { - Knx1[a] = 0.0; - Knx2[a] = 0.0; - Knx3[a] = 0.0; - for (unsigned int b = 0; b < dim; b++) - { - Knx1[a] += constV(Kn1[a][b]) * n1x[b]; - Knx2[a] += constV(Kn2[a][b]) * n2x[b]; - Knx3[a] += constV(Kn3[a][b]) * n3x[b]; - } - } - - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; - - modelResidualsList[1].scalarValueResidual = rn1V; - modelResidualsList[1].scalarGradResidual = rn1xV; - - modelResidualsList[2].scalarValueResidual = rn2V; - modelResidualsList[2].scalarGradResidual = rn2xV; - - modelResidualsList[3].scalarValueResidual = rn3V; - modelResidualsList[3].scalarGradResidual = rn3xV; - - modelResidualsList[4].vectorGradResidual = ruxV; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVariablesList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // n1 - scalarvalueType n1 = modelVariablesList[0].scalarValue; - - // n2 - scalarvalueType n2 = modelVariablesList[1].scalarValue; - - // n3 - scalarvalueType n3 = modelVariablesList[2].scalarValue; - - // u - vectorgradType ux = modelVariablesList[3].vectorGrad; - vectorgradType ruxV; - - // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the - // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; - E = symmetrize(ux); - - // Compute stress tensor (which is equal to the residual, Rux) - if (n_dependent_stiffness == true) - { - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; - CIJ_combined = - CIJ_list[0] * (constV(1.0) - h1V - h2V - h3V) + CIJ_list[1] * (h1V + h2V + h3V); - - computeStress(CIJ_combined, E, ruxV); - } - else - { - computeStress(CIJ_list[0], E, ruxV); - } - - modelRes.vectorGradResidual = ruxV; -} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - scalarvalueType total_energy_density = constV(0.0); - - // c - scalarvalueType c = modelVarList[0].scalarValue; - scalargradType cx = modelVarList[0].scalarGrad; - - // n1 - scalarvalueType n1 = modelVarList[1].scalarValue; - scalargradType n1x = modelVarList[1].scalarGrad; - - // n2 - scalarvalueType n2 = modelVarList[2].scalarValue; - scalargradType n2x = modelVarList[2].scalarGrad; - - // n3 - scalarvalueType n3 = modelVarList[3].scalarValue; - scalargradType n3x = modelVarList[3].scalarGrad; - - // u - vectorgradType ux = modelVarList[4].vectorGrad; - - scalarvalueType f_chem = - (constV(1.0) - (h1V + h2V + h3V)) * faV + (h1V + h2V + h3V) * fbV; - - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn1[i][j]) * n1x[i] * n1x[j]; - } - } -#if num_sop > 1 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn2[i][j]) * n2x[i] * n2x[j]; - } - } -#endif -#if num_sop > 2 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn3[i][j]) * n3x[i] * n3x[j]; - } - } -#endif - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // E2[i][j]= constV(0.5)*(ux[i][j]+ux[j][i])-( sfts1[i][j]*h1V + - // sfts2[i][j]*h2V + sfts3[i][j]*h3V); - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[2 * dim - 1 + dim / 3] - [2 * dim - 1 + dim / 3]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - scalarvalueType f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E2[i][j]; - } - } - - total_energy_density = f_chem + f_grad + f_el; - - assembler_lock.acquire(); - for (unsigned i = 0; i < c.size(); i++) - { - // For some reason, some of the values in this loop - if (c[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - this->energy_components[2] += f_el[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/run_num_1.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/run_num_1.txt deleted file mode 100644 index b632c805c..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/run_num_1.txt +++ /dev/null @@ -1 +0,0 @@ -run_006 \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/run_num_2.txt b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/run_num_2.txt deleted file mode 100644 index 5396e09d4..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/run_num_2.txt +++ /dev/null @@ -1 +0,0 @@ -reference_solution \ No newline at end of file diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/time_and_space_parameters.h b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/time_and_space_parameters.h deleted file mode 100644 index 8effa3187..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/time_and_space_parameters.h +++ /dev/null @@ -1,12 +0,0 @@ -// Parameters list for the parameters involved in mesh generation and time -// stepping -#define subdivisionsX 5 -#define subdivisionsY 5 -#define subdivisionsZ 5 -#define refineFactor 0 -#define finiteElementDegree 2 -// Parameters list for the parameters involved in time stepping -#define timeStep 8e-06 -#define timeIncrements 100000 -#define timeFinal 100000000 -#define skipImplicitSolves 10000000 diff --git a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/visitlog.py b/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/visitlog.py deleted file mode 100644 index 090b61656..000000000 --- a/tests/deprecated_tests/higher_order_element_tests/hoe_test_3D_timestep/visitlog.py +++ /dev/null @@ -1,57 +0,0 @@ -# Visit 2.7.0 log file -ScriptVersion = "2.7.0" -if ScriptVersion != Version(): - print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version()) -ShowAllWindows() -OpenDatabase("run_006/solution-100000.pvtu", 0) -# The UpdateDBPluginInfo RPC is not supported in the VisIt module so it will not be logged. -DefineScalarExpression("diff", "(c-pos_cmfe(, mesh,0))^2") -AddPlot("Pseudocolor", "diff", 1, 1) -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.scaling = PseudocolorAtts.Linear # Linear, Log, Skew -PseudocolorAtts.skewFactor = 1 -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot -PseudocolorAtts.minFlag = 0 -PseudocolorAtts.min = 0 -PseudocolorAtts.maxFlag = 0 -PseudocolorAtts.max = 1 -PseudocolorAtts.centering = PseudocolorAtts.Natural # Natural, Nodal, Zonal -PseudocolorAtts.colorTableName = "hot" -PseudocolorAtts.invertColorTable = 0 -PseudocolorAtts.opacityType = PseudocolorAtts.FullyOpaque # ColorTable, FullyOpaque, Constant, Ramp, VariableRange -PseudocolorAtts.opacityVariable = "" -PseudocolorAtts.opacity = 1 -PseudocolorAtts.opacityVarMin = 0 -PseudocolorAtts.opacityVarMax = 1 -PseudocolorAtts.opacityVarMinFlag = 0 -PseudocolorAtts.opacityVarMaxFlag = 0 -PseudocolorAtts.pointSize = 0.05 -PseudocolorAtts.pointType = PseudocolorAtts.Point # Box, Axis, Icosahedron, Octahedron, Tetrahedron, SphereGeometry, Point, Sphere -PseudocolorAtts.pointSizeVarEnabled = 0 -PseudocolorAtts.pointSizeVar = "default" -PseudocolorAtts.pointSizePixels = 2 -PseudocolorAtts.lineType = PseudocolorAtts.Line # Line, Tube, Ribbon -PseudocolorAtts.lineStyle = PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH -PseudocolorAtts.lineWidth = 0 -PseudocolorAtts.tubeDisplayDensity = 10 -PseudocolorAtts.tubeRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.tubeRadiusAbsolute = 0.125 -PseudocolorAtts.tubeRadiusBBox = 0.005 -PseudocolorAtts.varyTubeRadius = 0 -PseudocolorAtts.varyTubeRadiusVariable = "" -PseudocolorAtts.varyTubeRadiusFactor = 10 -PseudocolorAtts.endPointType = PseudocolorAtts.None # None, Tails, Heads, Both -PseudocolorAtts.endPointStyle = PseudocolorAtts.Spheres # Spheres, Cones -PseudocolorAtts.endPointRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.endPointRadiusAbsolute = 1 -PseudocolorAtts.endPointRadiusBBox = 0.005 -PseudocolorAtts.endPointRatio = 2 -PseudocolorAtts.renderSurfaces = 1 -PseudocolorAtts.renderWireframe = 0 -PseudocolorAtts.renderPoints = 0 -PseudocolorAtts.smoothingLevel = 0 -PseudocolorAtts.legendFlag = 1 -PseudocolorAtts.lightingFlag = 1 -SetPlotOptions(PseudocolorAtts) -DrawPlots() -Query("Weighted Variable Sum", use_actual_data=1) diff --git a/tests/deprecated_tests/indexing_tests/indexTest/CMakeLists.txt b/tests/deprecated_tests/indexing_tests/indexTest/CMakeLists.txt deleted file mode 100644 index 8eecee41b..000000000 --- a/tests/deprecated_tests/indexing_tests/indexTest/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -#set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/indexing_tests/indexTest/ICs_and_BCs.h b/tests/deprecated_tests/indexing_tests/indexTest/ICs_and_BCs.h deleted file mode 100644 index 7b57c0de7..000000000 --- a/tests/deprecated_tests/indexing_tests/indexTest/ICs_and_BCs.h +++ /dev/null @@ -1,112 +0,0 @@ -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double x_loc[12] = {0.1, 0.8, 0.5, 0.4, 0.3, 0.8, 0.9, 0.0, 0.1, 0.5, 1, 0.7}; - double y_loc[12] = {0.3, 0.7, 0.2, 0.4, 0.9, 0.1, 0.5, 0.1, 0.6, 0.6, 1, 0.95}; - double rad[12] = {12, 14, 19, 16, 11, 12, 17, 15, 20, 10, 11, 14}; - double dist; - scalar_IC = 0; - for (unsigned int i = 0; i < 12; i++) - { -#if problemDIM == 2 - dist = p.distance(Point(x_loc[i] * spanX, y_loc[i] * spanY)); -#elif problemDIM == 3 - dist = p.distance(Point(x_loc[i] * spanX, y_loc[i] * spanY, 0.5 * spanZ)); -#endif - if (dist < rad[i]) - { - scalar_IC = 1.0; - } - }; - - // ===================================================================== - return scalar_IC; - } -}; - -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - if (index > 0) - { - vector_IC = 0.0; - } - - // ===================================================================== - } -}; - -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE", "DIRICHLET", and - // "PERIODIC") Fourth input: BC value (ignored unless the BC type is - // "DIRICHLET") Odd inputs after the third: BC type Even inputs after the - // third: BC value Face numbering: starts at zero with the minimum of the - // first direction, one for the maximum of the first direction - // two for the minimum of the second direction, etc. - - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - inputBCs(1, 0, "ZERO_DERIVATIVE", 0); - inputBCs(1, 1, "ZERO_DERIVATIVE", 0); - inputBCs(2, 0, "ZERO_DERIVATIVE", 0); - inputBCs(2, 1, "ZERO_DERIVATIVE", 0); - - // ===================================================================== -} diff --git a/tests/deprecated_tests/indexing_tests/indexTest/equations.h b/tests/deprecated_tests/indexing_tests/indexTest/equations.h deleted file mode 100644 index 61d9a0bd4..000000000 --- a/tests/deprecated_tests/indexing_tests/indexTest/equations.h +++ /dev/null @@ -1,233 +0,0 @@ -// List of variables and residual equations for the coupled Allen-Cahn example -// application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 3 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "n", "vec1", "vec2" \ - } -#define variable_type \ - { \ - "SCALAR", "VECTOR", "VECTOR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC", "PARABOLIC", "PARABOLIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - true, true, true \ - } -#define need_grad \ - { \ - true, true, true \ - } -#define need_hess \ - { \ - false, false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - true, true, true \ - } -#define need_grad_residual \ - { \ - true, true, true \ - } - -//// -///================================================================================= -//// Define the variables in the model -//// -///================================================================================= -//// The number of variables -// #define num_var 2 -// -//// The names of the variables, whether they are scalars or vectors and whether -/// the / governing eqn for the variable is parabolic or elliptic -// #define variable_name {"n","vec1"} -// #define variable_type {"SCALAR","VECTOR"} -// #define variable_eq_type {"PARABOLIC","PARABOLIC"} -// -//// Flags for whether the value, gradient, and Hessian are needed in the -/// residual eqns -// #define need_val {true,true} -// #define need_grad {true,true} -// #define need_hess {false,false} -// -//// Flags for whether the residual equation has a term multiplied by the test -/// function / (need_val_residual) and/or the gradient of the test function -///(need_grad_residual) -// #define need_val_residual {true,true} -// #define need_grad_residual {true,true} - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Mobility -#define MnV 1.0 - -// Gradient energy coefficient -#define KnV 4.0 - -// Free energy and its derivative -#define fV (n * n * n * n - 2.0 * n * n * n + n * n) -#define fnV (4.0 * n * (n - 1.0) * (n - 0.5)) - -// Residual equations -#define rnV (n - constV(timeStep * MnV) * fnV) -#define rnxV (constV(-timeStep * KnV * MnV) * nx) - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // The order parameter and its derivatives (names here should match those in - // the macros above) - scalarvalueType n = modelVariablesList[0].scalarValue; - scalargradType nx = modelVariablesList[0].scalarGrad; - - vectorvalueType vec1 = modelVariablesList[1].vectorValue; - vectorgradType vec1x = modelVariablesList[1].vectorGrad; - - vectorvalueType vec2 = modelVariablesList[2].vectorValue; - vectorgradType vec2x = modelVariablesList[2].vectorGrad; - - // Residuals for the equation to evolve the order parameter (names here should - // match those in the macros above) - modelResidualsList[0].scalarValueResidual = rnV; - modelResidualsList[0].scalarGradResidual = rnxV; - - vectorvalueType rvecV; - rvecV[0] = constV(1.0); - rvecV[1] = constV(1.0); - - vectorgradType rvecxV; - rvecxV[0][0] = constV(1.0); - rvecxV[1][0] = constV(1.0); - rvecxV[0][1] = constV(1.0); - rvecxV[1][1] = constV(1.0); - - modelResidualsList[1].vectorValueResidual = rvecV; - modelResidualsList[1].vectorGradResidual = rvecxV; - - modelResidualsList[2].vectorValueResidual = rvecV; - modelResidualsList[2].vectorGradResidual = rvecxV; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVarList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - scalarvalueType total_energy_density = constV(0.0); - - // The order parameter and its derivatives (names here should match those in - // the macros above) - scalarvalueType n = modelVarList[0].scalarValue; - scalargradType nx = modelVarList[0].scalarGrad; - - // The homogenous free energy - scalarvalueType f_chem = fV; - - // The gradient free energy - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * KnV) * nx[i] * nx[j]; - } - } - - // The total free energy - total_energy_density = f_chem + f_grad; - - // Loop to step through each element of the vectorized arrays. Working with - // deal.ii developers to see if there is a more elegant way to do this. - assembler_lock.acquire(); - for (unsigned i = 0; i < n.size(); i++) - { - // For some reason, some of the values in this loop - if (n[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/indexing_tests/indexTest/formulation_allenCahn.pdf b/tests/deprecated_tests/indexing_tests/indexTest/formulation_allenCahn.pdf deleted file mode 100644 index aa82cf7b1..000000000 Binary files a/tests/deprecated_tests/indexing_tests/indexTest/formulation_allenCahn.pdf and /dev/null differ diff --git a/tests/deprecated_tests/indexing_tests/indexTest/main.cc b/tests/deprecated_tests/indexing_tests/indexTest/main.cc deleted file mode 100644 index 9f717943a..000000000 --- a/tests/deprecated_tests/indexing_tests/indexTest/main.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Allen-Cahn example application - -// Header files -#include "ICs_and_BCs.h" -#include "equations.h" -#include "parameters.h" - -#include "../../../include/dealIIheaders.h" -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/indexing_tests/indexTest/parameters.h b/tests/deprecated_tests/indexing_tests/indexTest/parameters.h deleted file mode 100644 index 097387c48..000000000 --- a/tests/deprecated_tests/indexing_tests/indexTest/parameters.h +++ /dev/null @@ -1,69 +0,0 @@ -// Parameter list for the Allen-Cahn example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 2 - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 100.0 -#define spanY 100.0 -#define spanZ 100.0 - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 7 - -// Set the polynomial degree of the element (suggested values: 1 or 2) -#define finiteElementDegree 1 - -// ================================================================================= -// Set the time step parameters -// ================================================================================= -// The size of the time step -#define timeStep 1.0e-3 - -// The simulation ends when either timeFinal is reached or the number of time -// steps equals timeIncrements -#define timeFinal 20.0 -#define timeIncrements 20000 - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", -// "N_PER_DECADE", or "LIST") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE", -// ignored for "LIST") -#define numOutputs 10 - -// User-defined list of time steps where the program should output. Only used if -// outputCondition is "LIST" -#define outputList \ - {} - -// Status is printed to the screen every skipPrintSteps -#define skipPrintSteps 10 - -// ================================================================================= -// Set the flag determining if the total free energy is calculated for each -// output -// ================================================================================= -#define calcEnergy true diff --git a/tests/deprecated_tests/indexing_tests/indexTest/tex_files/allenCahn.tex b/tests/deprecated_tests/indexing_tests/indexTest/tex_files/allenCahn.tex deleted file mode 100644 index d2b763351..000000000 --- a/tests/deprecated_tests/indexing_tests/indexTest/tex_files/allenCahn.tex +++ /dev/null @@ -1,223 +0,0 @@ -\documentclass[10pt]{article} -\usepackage{amsmath} -\usepackage{bm} -\usepackage{bbm} -\usepackage{mathrsfs} -\usepackage{graphicx} -\usepackage{wrapfig} -\usepackage{subcaption} -\usepackage{epsfig} -\usepackage{amsfonts} -\usepackage{amssymb} -\usepackage{amsmath} -\usepackage{wrapfig} -\usepackage{graphicx} -\usepackage{psfrag} -\newcommand{\sun}{\ensuremath{\odot}} % sun symbol is \sun -\let\vaccent=\v % rename builtin command \v{} to \vaccent{} -\renewcommand{\v}[1]{\ensuremath{\mathbf{#1}}} % for vectors -\newcommand{\gv}[1]{\ensuremath{\mbox{\boldmath$ #1 $}}} -\newcommand{\grad}[1]{\gv{\nabla} #1} -\renewcommand{\baselinestretch}{1.2} -\jot 5mm -\graphicspath{{./figures/}} -%text dimensions -\textwidth 6.5 in -\oddsidemargin .2 in -\topmargin -0.2 in -\textheight 8.5 in -\headheight 0.2in -\overfullrule = 0pt -\pagestyle{plain} -\def\newpar{\par\vskip 0.5cm} -\begin{document} -% -%---------------------------------------------------------------------- -% Define symbols -%---------------------------------------------------------------------- -% -\def\iso{\mathbbm{1}} -\def\half{{\textstyle{1 \over 2}}} -\def\third{{\textstyle{1 \over 3}}} -\def\fourth{{\textstyle{{1 \over 4}}}} -\def\twothird{{\textstyle {{2 \over 3}}}} -\def\ndim{{n_{\rm dim}}} -\def\nint{n_{\rm int}} -\def\lint{l_{\rm int}} -\def\nel{n_{\rm el}} -\def\nf{n_{\rm f}} -\def\DIV {\hbox{\af div}} -\def\GRAD{\hbox{\af Grad}} -\def\sym{\mathop{\rm sym}\nolimits} -\def\tr{\mathop{\rm tr}\nolimits} -\def\dev{\mathop{\rm dev}\nolimits} -\def\Dev{\mathop{\rm Dev}\nolimits} -\def\DEV{\mathop {\rm DEV}\nolimits} -\def\bfb {{\bi b}} -\def\Bnabla{\nabla} -\def\bG{{\bi G}} -\def\jmpdelu{{\lbrack\!\lbrack \Delta u\rbrack\!\rbrack}} -\def\jmpudot{{\lbrack\!\lbrack\dot u\rbrack\!\rbrack}} -\def\jmpu{{\lbrack\!\lbrack u\rbrack\!\rbrack}} -\def\jmphi{{\lbrack\!\lbrack\varphi\rbrack\!\rbrack}} -\def\ljmp{{\lbrack\!\lbrack}} -\def\rjmp{{\rbrack\!\rbrack}} -\def\sign{{\rm sign}} -\def\nn{{n+1}} -\def\na{{n+\vartheta}} -\def\nna{{n+(1-\vartheta)}} -\def\nt{{n+{1\over 2}}} -\def\nb{{n+\beta}} -\def\nbb{{n+(1-\beta)}} -%--------------------------------------------------------- -% Bold Face Math Characters: -% All In Format: \B***** . -%--------------------------------------------------------- -\def\bOne{\mbox{\boldmath$1$}} -\def\BGamma{\mbox{\boldmath$\Gamma$}} -\def\BDelta{\mbox{\boldmath$\Delta$}} -\def\BTheta{\mbox{\boldmath$\Theta$}} -\def\BLambda{\mbox{\boldmath$\Lambda$}} -\def\BXi{\mbox{\boldmath$\Xi$}} -\def\BPi{\mbox{\boldmath$\Pi$}} -\def\BSigma{\mbox{\boldmath$\Sigma$}} -\def\BUpsilon{\mbox{\boldmath$\Upsilon$}} -\def\BPhi{\mbox{\boldmath$\Phi$}} -\def\BPsi{\mbox{\boldmath$\Psi$}} -\def\BOmega{\mbox{\boldmath$\Omega$}} -\def\Balpha{\mbox{\boldmath$\alpha$}} -\def\Bbeta{\mbox{\boldmath$\beta$}} -\def\Bgamma{\mbox{\boldmath$\gamma$}} -\def\Bdelta{\mbox{\boldmath$\delta$}} -\def\Bepsilon{\mbox{\boldmath$\epsilon$}} -\def\Bzeta{\mbox{\boldmath$\zeta$}} -\def\Beta{\mbox{\boldmath$\eta$}} -\def\Btheta{\mbox{\boldmath$\theta$}} -\def\Biota{\mbox{\boldmath$\iota$}} -\def\Bkappa{\mbox{\boldmath$\kappa$}} -\def\Blambda{\mbox{\boldmath$\lambda$}} -\def\Bmu{\mbox{\boldmath$\mu$}} -\def\Bnu{\mbox{\boldmath$\nu$}} -\def\Bxi{\mbox{\boldmath$\xi$}} -\def\Bpi{\mbox{\boldmath$\pi$}} -\def\Brho{\mbox{\boldmath$\rho$}} -\def\Bsigma{\mbox{\boldmath$\sigma$}} -\def\Btau{\mbox{\boldmath$\tau$}} -\def\Bupsilon{\mbox{\boldmath$\upsilon$}} -\def\Bphi{\mbox{\boldmath$\phi$}} -\def\Bchi{\mbox{\boldmath$\chi$}} -\def\Bpsi{\mbox{\boldmath$\psi$}} -\def\Bomega{\mbox{\boldmath$\omega$}} -\def\Bvarepsilon{\mbox{\boldmath$\varepsilon$}} -\def\Bvartheta{\mbox{\boldmath$\vartheta$}} -\def\Bvarpi{\mbox{\boldmath$\varpi$}} -\def\Bvarrho{\mbox{\boldmath$\varrho$}} -\def\Bvarsigma{\mbox{\boldmath$\varsigma$}} -\def\Bvarphi{\mbox{\boldmath$\varphi$}} -\def\bone{\mathbf{1}} -\def\bzero{\mathbf{0}} -%--------------------------------------------------------- -% Bold Face Math Italic: -% All In Format: \b* . -%--------------------------------------------------------- -\def\bA{\mbox{\boldmath$ A$}} -\def\bB{\mbox{\boldmath$ B$}} -\def\bC{\mbox{\boldmath$ C$}} -\def\bD{\mbox{\boldmath$ D$}} -\def\bE{\mbox{\boldmath$ E$}} -\def\bF{\mbox{\boldmath$ F$}} -\def\bG{\mbox{\boldmath$ G$}} -\def\bH{\mbox{\boldmath$ H$}} -\def\bI{\mbox{\boldmath$ I$}} -\def\bJ{\mbox{\boldmath$ J$}} -\def\bK{\mbox{\boldmath$ K$}} -\def\bL{\mbox{\boldmath$ L$}} -\def\bM{\mbox{\boldmath$ M$}} -\def\bN{\mbox{\boldmath$ N$}} -\def\bO{\mbox{\boldmath$ O$}} -\def\bP{\mbox{\boldmath$ P$}} -\def\bQ{\mbox{\boldmath$ Q$}} -\def\bR{\mbox{\boldmath$ R$}} -\def\bS{\mbox{\boldmath$ S$}} -\def\bT{\mbox{\boldmath$ T$}} -\def\bU{\mbox{\boldmath$ U$}} -\def\bV{\mbox{\boldmath$ V$}} -\def\bW{\mbox{\boldmath$ W$}} -\def\bX{\mbox{\boldmath$ X$}} -\def\bY{\mbox{\boldmath$ Y$}} -\def\bZ{\mbox{\boldmath$ Z$}} -\def\ba{\mbox{\boldmath$ a$}} -\def\bb{\mbox{\boldmath$ b$}} -\def\bc{\mbox{\boldmath$ c$}} -\def\bd{\mbox{\boldmath$ d$}} -\def\be{\mbox{\boldmath$ e$}} -\def\bff{\mbox{\boldmath$ f$}} -\def\bg{\mbox{\boldmath$ g$}} -\def\bh{\mbox{\boldmath$ h$}} -\def\bi{\mbox{\boldmath$ i$}} -\def\bj{\mbox{\boldmath$ j$}} -\def\bk{\mbox{\boldmath$ k$}} -\def\bl{\mbox{\boldmath$ l$}} -\def\bm{\mbox{\boldmath$ m$}} -\def\bn{\mbox{\boldmath$ n$}} -\def\bo{\mbox{\boldmath$ o$}} -\def\bp{\mbox{\boldmath$ p$}} -\def\bq{\mbox{\boldmath$ q$}} -\def\br{\mbox{\boldmath$ r$}} -\def\bs{\mbox{\boldmath$ s$}} -\def\bt{\mbox{\boldmath$ t$}} -\def\bu{\mbox{\boldmath$ u$}} -\def\bv{\mbox{\boldmath$ v$}} -\def\bw{\mbox{\boldmath$ w$}} -\def\bx{\mbox{\boldmath$ x$}} -\def\by{\mbox{\boldmath$ y$}} -\def\bz{\mbox{\boldmath$ z$}} -%********************************* -%Start main paper -%********************************* -\centerline{\Large{\bf PRISMS PhaseField}} -\smallskip -\centerline{\Large{\bf Allen-Cahn Dynamics}} -\bigskip -Consider a free energy expression of the form: -\begin{equation} - \Pi(\eta, \grad \eta) = \int_{\Omega} f( \eta ) + \frac{\kappa}{2} \grad \eta \cdot \grad \eta ~dV -\end{equation} -where $\eta$ is the structural order parameter, and $\kappa$ is the gradient length scale parameter. - -\section{Variational treatment} -Considering variations on the primal field $\eta$ of the from $\eta+\epsilon w$, we have -\begin{align} -\delta \Pi &= \left. \frac{d}{d\epsilon} \int_{\Omega} f(\eta+\epsilon w) + \frac{\kappa}{2} \grad (\eta+\epsilon w) \cdot ~\grad (\eta+\epsilon w) ~dV \right\vert_{\epsilon=0} \\ -&= \int_{\Omega} w f_{,\eta} + \kappa \grad w \grad \eta ~dV \\ -&= \int_{\Omega} w \left( f_{,\eta} - \kappa \Delta \eta \right) ~dV + \int_{\partial \Omega} w \kappa \grad \eta \cdot n ~dS -\end{align} -Assuming $\kappa \grad \eta \cdot n = 0$, and using standard variational arguments on the equation $\delta \Pi =0$ we have the expression for chemical potential as -\begin{equation} - \mu = f_{,\eta} - \kappa \Delta \eta -\end{equation} - -\section{Kinetics} -Now the Parabolic PDE for Allen-Cahn dynamics is given by: -\begin{align} - \frac{\partial \eta}{\partial t} &= -M~(f_{,\eta} - \kappa \Delta \eta) -\end{align} -where $M$ is the constant mobility. -\section{Time discretization} -Considering forward Euler explicit time stepping, we have the time discretized kinetics equation: -\begin{align} - \eta^{n+1} &= \eta^{n} - \Delta t M~(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) -\end{align} - -\section{Weak formulation} -In the weak formulation, considering an arbitrary variation $w$, the above equation can be expressed as a residual equation: -\begin{align} -\int_{\Omega} w \eta^{n+1} ~dV&= \int_{\Omega} w \eta^{n} - w \Delta t M~(f_{,\eta}^{n} - \kappa \Delta \eta^{n}) ~dV \\ -&= \int_{\Omega} w ( \underbrace{ \eta^{n} - \Delta t M~f_{,\eta}^{n} }_{r_{\eta}} ) + \grad w \underbrace{ (-\Delta t M \kappa)~ \cdot (\grad \eta^{n})}_{r_{\eta x}} ~dV \quad [\kappa \grad \eta \cdot n = 0 \quad \text{on} \quad \partial \Omega] -\end{align} -\vskip 0.25in -The above values of $r_{\eta}$ and $r_{\eta x}$ are used to define the residuals in the following parameters file: \\ -\textit{applications/allenCahn/parameters.h} - - -\end{document} \ No newline at end of file diff --git a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/CMakeLists.txt b/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/CMakeLists.txt deleted file mode 100644 index 8eecee41b..000000000 --- a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -#set(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -#set(DEAL_II_CXX_FLAGS_RELEASE "${DEAL_II_CXX_FLAGS_DEBUG} -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comment -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable") -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/ICs_and_BCs.h b/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/ICs_and_BCs.h deleted file mode 100644 index ed815b766..000000000 --- a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/ICs_and_BCs.h +++ /dev/null @@ -1,241 +0,0 @@ -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - // ===================================================================== - return scalar_IC; - } -}; - -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - vector_IC(0) = 0.0; - vector_IC(1) = 0.0; - vector_IC(2) = 0.0; - - // ===================================================================== - } -}; - -// Sets the BCs for the problem variables -// "inputBCs" should be called for each component of each variable and should be -// in numerical order Four input arguments set the same BC on the entire -// boundary Two plus two times the number of dimensions inputs sets separate BCs -// on each face of the domain Inputs to "inputBCs": First input: variable number -// Second input: component number -// Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") -// Fourth input: BC value (ignored unless the BC type is "DIRICHLET") -// Odd inputs after the third: BC type -// Even inputs after the third: BC value -// Face numbering: starts at zero with the minimum of the first direction, one -// for the maximum of the first direction -// two for the minimum of the second direction, etc. -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE", "DIRICHLET", and - // "PERIODIC") Fourth input: BC value (ignored unless the BC type is - // "DIRICHLET") Odd inputs after the third: BC type Even inputs after the - // third: BC value Face numbering: starts at zero with the minimum of the - // first direction, one for the maximum of the first direction - // two for the minimum of the second direction, etc. - - inputBCs(0, - 0, - "DIRICHLET", - -1.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); - inputBCs(0, - 1, - "DIRICHLET", - 0.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); - inputBCs(0, - 2, - "DIRICHLET", - 0.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); - - inputBCs(1, - 0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); - inputBCs(1, - 1, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); - inputBCs(1, - 2, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); - - inputBCs(2, - 0, - "DIRICHLET", - -5.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); - inputBCs(2, - 1, - "DIRICHLET", - 0.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); - inputBCs(2, - 2, - "DIRICHLET", - 0.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); - - inputBCs(3, - 0, - "DIRICHLET", - -10.0, - "DIRICHLET", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0, - "ZERO_DERIVATIVE", - 0.0); -} diff --git a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/equations.h b/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/equations.h deleted file mode 100644 index 0e701ea4e..000000000 --- a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/equations.h +++ /dev/null @@ -1,262 +0,0 @@ -// List of variables and residual equations for the mechanics example -// application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 4 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "u", "u2", "u3", "c" \ - } -#define variable_type \ - { \ - "VECTOR", "VECTOR", "VECTOR", "SCALAR" \ - } -#define variable_eq_type \ - { \ - "ELLIPTIC", "PARABOLIC", "ELLIPTIC", "ELLIPTIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - false, false, false, false \ - } -#define need_grad \ - { \ - true, true, true, true \ - } -#define need_hess \ - { \ - false, false, false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - false, false, false, false \ - } -#define need_grad_residual \ - { \ - true, true, true, true \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqn for the left-hand-side of the iterative solver for elliptic equations -#define need_val_LHS \ - { \ - false, false, false, false \ - } -#define need_grad_LHS \ - { \ - true, true, true, true \ - } -#define need_hess_LHS \ - { \ - false, false, false, false \ - } - -// Flags for whether the residual equation for the left-hand-side of the -// iterative solver for elliptic equations has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual_LHS \ - { \ - false, false, false, false \ - } -#define need_grad_residual_LHS \ - { \ - true, false, true, true \ - } - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Define Mechanical properties -// Mechanical symmetry of the material and stiffness parameters -#define MaterialModels \ - { \ - "ISOTROPIC" \ - } -#define MaterialConstants \ - { \ - { \ - 2.0, 0.3 \ - } \ - } - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // u - vectorgradType ux = modelVariablesList[0].vectorGrad; - vectorgradType u2x = modelVariablesList[1].vectorGrad; - vectorgradType u3x = modelVariablesList[2].vectorGrad; - scalargradType cx = modelVariablesList[3].scalarGrad; - vectorgradType Rux, Rux2; - - // compute strain tensor - dealii::VectorizedArray E[dim][dim], S[dim][dim]; - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]); - } - } - - // compute strain tensor - dealii::VectorizedArray E2[dim][dim], S2[dim][dim]; - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (u3x[i][j] + u3x[j][i]); - } - } - - // compute stress tensor - computeStress(CIJ_list[0], E, S); - - computeStress(CIJ_list[0], E2, S2); - - // compute residual - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - Rux[i][j] = -S[i][j]; - Rux2[i][j] = -S2[i][j]; - } - } - - modelResidualsList[0].vectorGradResidual = Rux; - modelResidualsList[1].vectorGradResidual = constV(0.0) * Rux; - modelResidualsList[2].vectorGradResidual = Rux2; - modelResidualsList[3].scalarGradResidual = -cx; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVarList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // u - vectorgradType ux = modelVarList[0].vectorGrad; - vectorgradType u2x = modelVarList[1].vectorGrad; - vectorgradType u3x = modelVarList[2].vectorGrad; - scalargradType cx = modelVarList[3].scalarGrad; - vectorgradType Rux; - - dealii::VectorizedArray E[dim][dim], S[dim][dim]; - if (this->currentFieldIndex == 0) - { - // compute strain tensor - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]); - } - } - } - else - { - // compute strain tensor - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E[i][j] = constV(0.5) * (u3x[i][j] + u3x[j][i]); - } - } - } - - // compute stress tensor - computeStress(CIJ_list[0], E, S); - - // compute residual - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - Rux[i][j] = S[i][j]; - } - } - - if (this->currentFieldIndex < 3) - { - modelRes.vectorGradResidual = Rux; - } - else - { - modelRes.scalarGradResidual = cx; - } -} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{} diff --git a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/formulation_mechanics.pdf b/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/formulation_mechanics.pdf deleted file mode 100644 index 57037ff2e..000000000 Binary files a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/formulation_mechanics.pdf and /dev/null differ diff --git a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/main.cc b/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/main.cc deleted file mode 100644 index 098821797..000000000 --- a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/main.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Linear elasticity example application - -// Header files -#include "ICs_and_BCs.h" -#include "equations.h" -#include "parameters.h" - -#include "../../../include/dealIIheaders.h" -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/parameters.h b/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/parameters.h deleted file mode 100644 index 3f234ee33..000000000 --- a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/parameters.h +++ /dev/null @@ -1,47 +0,0 @@ -// Parameter list for the mechanics example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 3 - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 100.0 -#define spanY 100.0 -#define spanZ 100.0 - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 4 - -// Set the polynomial degree of the element (suggested values: 1 or 2) -#define finiteElementDegree 1 - -// ================================================================================= -// Set the elliptic solver parameters -// ================================================================================= -// The solver type (currently the only recommended option is conjugate gradient) -#define solverType SolverCG - -// The tolerance for convergence (L2 norm of the residual) -#define solverTolerance 1.0e-10 - -// The maximum number of solver iterations per time step -#define maxSolverIterations 1000 - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true diff --git a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/tex_files/mechanics.tex b/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/tex_files/mechanics.tex deleted file mode 100644 index c041b432e..000000000 --- a/tests/deprecated_tests/indexing_tests/mechanics_doubleVec/tex_files/mechanics.tex +++ /dev/null @@ -1,215 +0,0 @@ -\documentclass[10pt]{article} -\usepackage{amsmath} -\usepackage{bm} -\usepackage{bbm} -\usepackage{mathrsfs} -\usepackage{graphicx} -\usepackage{wrapfig} -\usepackage{subcaption} -\usepackage{epsfig} -\usepackage{amsfonts} -\usepackage{amssymb} -\usepackage{amsmath} -\usepackage{wrapfig} -\usepackage{graphicx} -\usepackage{psfrag} -\newcommand{\sun}{\ensuremath{\odot}} % sun symbol is \sun -\let\vaccent=\v % rename builtin command \v{} to \vaccent{} -\renewcommand{\v}[1]{\ensuremath{\mathbf{#1}}} % for vectors -\newcommand{\gv}[1]{\ensuremath{\mbox{\boldmath$ #1 $}}} -\newcommand{\grad}[1]{\gv{\nabla} #1} -\renewcommand{\baselinestretch}{1.2} -\jot 5mm -\graphicspath{{./figures/}} -%text dimensions -\textwidth 6.5 in -\oddsidemargin .2 in -\topmargin -0.2 in -\textheight 8.5 in -\headheight 0.2in -\overfullrule = 0pt -\pagestyle{plain} -\def\newpar{\par\vskip 0.5cm} -\begin{document} -% -%---------------------------------------------------------------------- -% Define symbols -%---------------------------------------------------------------------- -% -\def\iso{\mathbbm{1}} -\def\half{{\textstyle{1 \over 2}}} -\def\third{{\textstyle{1 \over 3}}} -\def\fourth{{\textstyle{{1 \over 4}}}} -\def\twothird{{\textstyle {{2 \over 3}}}} -\def\ndim{{n_{\rm dim}}} -\def\nint{n_{\rm int}} -\def\lint{l_{\rm int}} -\def\nel{n_{\rm el}} -\def\nf{n_{\rm f}} -\def\DIV {\hbox{\af div}} -\def\GRAD{\hbox{\af Grad}} -\def\sym{\mathop{\rm sym}\nolimits} -\def\tr{\mathop{\rm tr}\nolimits} -\def\dev{\mathop{\rm dev}\nolimits} -\def\Dev{\mathop{\rm Dev}\nolimits} -\def\DEV{\mathop {\rm DEV}\nolimits} -\def\bfb {{\bi b}} -\def\Bnabla{\nabla} -\def\bG{{\bi G}} -\def\jmpdelu{{\lbrack\!\lbrack \Delta u\rbrack\!\rbrack}} -\def\jmpudot{{\lbrack\!\lbrack\dot u\rbrack\!\rbrack}} -\def\jmpu{{\lbrack\!\lbrack u\rbrack\!\rbrack}} -\def\jmphi{{\lbrack\!\lbrack\varphi\rbrack\!\rbrack}} -\def\ljmp{{\lbrack\!\lbrack}} -\def\rjmp{{\rbrack\!\rbrack}} -\def\sign{{\rm sign}} -\def\nn{{n+1}} -\def\na{{n+\vartheta}} -\def\nna{{n+(1-\vartheta)}} -\def\nt{{n+{1\over 2}}} -\def\nb{{n+\beta}} -\def\nbb{{n+(1-\beta)}} -%--------------------------------------------------------- -% Bold Face Math Characters: -% All In Format: \B***** . -%--------------------------------------------------------- -\def\bOne{\mbox{\boldmath$1$}} -\def\BGamma{\mbox{\boldmath$\Gamma$}} -\def\BDelta{\mbox{\boldmath$\Delta$}} -\def\BTheta{\mbox{\boldmath$\Theta$}} -\def\BLambda{\mbox{\boldmath$\Lambda$}} -\def\BXi{\mbox{\boldmath$\Xi$}} -\def\BPi{\mbox{\boldmath$\Pi$}} -\def\BSigma{\mbox{\boldmath$\Sigma$}} -\def\BUpsilon{\mbox{\boldmath$\Upsilon$}} -\def\BPhi{\mbox{\boldmath$\Phi$}} -\def\BPsi{\mbox{\boldmath$\Psi$}} -\def\BOmega{\mbox{\boldmath$\Omega$}} -\def\Balpha{\mbox{\boldmath$\alpha$}} -\def\Bbeta{\mbox{\boldmath$\beta$}} -\def\Bgamma{\mbox{\boldmath$\gamma$}} -\def\Bdelta{\mbox{\boldmath$\delta$}} -\def\Bepsilon{\mbox{\boldmath$\epsilon$}} -\def\Bzeta{\mbox{\boldmath$\zeta$}} -\def\Beta{\mbox{\boldmath$\eta$}} -\def\Btheta{\mbox{\boldmath$\theta$}} -\def\Biota{\mbox{\boldmath$\iota$}} -\def\Bkappa{\mbox{\boldmath$\kappa$}} -\def\Blambda{\mbox{\boldmath$\lambda$}} -\def\Bmu{\mbox{\boldmath$\mu$}} -\def\Bnu{\mbox{\boldmath$\nu$}} -\def\Bxi{\mbox{\boldmath$\xi$}} -\def\Bpi{\mbox{\boldmath$\pi$}} -\def\Brho{\mbox{\boldmath$\rho$}} -\def\Bsigma{\mbox{\boldmath$\sigma$}} -\def\Btau{\mbox{\boldmath$\tau$}} -\def\Bupsilon{\mbox{\boldmath$\upsilon$}} -\def\Bphi{\mbox{\boldmath$\phi$}} -\def\Bchi{\mbox{\boldmath$\chi$}} -\def\Bpsi{\mbox{\boldmath$\psi$}} -\def\Bomega{\mbox{\boldmath$\omega$}} -\def\Bvarepsilon{\mbox{\boldmath$\varepsilon$}} -\def\Bvartheta{\mbox{\boldmath$\vartheta$}} -\def\Bvarpi{\mbox{\boldmath$\varpi$}} -\def\Bvarrho{\mbox{\boldmath$\varrho$}} -\def\Bvarsigma{\mbox{\boldmath$\varsigma$}} -\def\Bvarphi{\mbox{\boldmath$\varphi$}} -\def\bone{\mathbf{1}} -\def\bzero{\mathbf{0}} -%--------------------------------------------------------- -% Bold Face Math Italic: -% All In Format: \b* . -%--------------------------------------------------------- -\def\bA{\mbox{\boldmath$ A$}} -\def\bB{\mbox{\boldmath$ B$}} -\def\bC{\mbox{\boldmath$ C$}} -\def\bD{\mbox{\boldmath$ D$}} -\def\bE{\mbox{\boldmath$ E$}} -\def\bF{\mbox{\boldmath$ F$}} -\def\bG{\mbox{\boldmath$ G$}} -\def\bH{\mbox{\boldmath$ H$}} -\def\bI{\mbox{\boldmath$ I$}} -\def\bJ{\mbox{\boldmath$ J$}} -\def\bK{\mbox{\boldmath$ K$}} -\def\bL{\mbox{\boldmath$ L$}} -\def\bM{\mbox{\boldmath$ M$}} -\def\bN{\mbox{\boldmath$ N$}} -\def\bO{\mbox{\boldmath$ O$}} -\def\bP{\mbox{\boldmath$ P$}} -\def\bQ{\mbox{\boldmath$ Q$}} -\def\bR{\mbox{\boldmath$ R$}} -\def\bS{\mbox{\boldmath$ S$}} -\def\bT{\mbox{\boldmath$ T$}} -\def\bU{\mbox{\boldmath$ U$}} -\def\bV{\mbox{\boldmath$ V$}} -\def\bW{\mbox{\boldmath$ W$}} -\def\bX{\mbox{\boldmath$ X$}} -\def\bY{\mbox{\boldmath$ Y$}} -\def\bZ{\mbox{\boldmath$ Z$}} -\def\ba{\mbox{\boldmath$ a$}} -\def\bb{\mbox{\boldmath$ b$}} -\def\bc{\mbox{\boldmath$ c$}} -\def\bd{\mbox{\boldmath$ d$}} -\def\be{\mbox{\boldmath$ e$}} -\def\bff{\mbox{\boldmath$ f$}} -\def\bg{\mbox{\boldmath$ g$}} -\def\bh{\mbox{\boldmath$ h$}} -\def\bi{\mbox{\boldmath$ i$}} -\def\bj{\mbox{\boldmath$ j$}} -\def\bk{\mbox{\boldmath$ k$}} -\def\bl{\mbox{\boldmath$ l$}} -\def\bm{\mbox{\boldmath$ m$}} -\def\bn{\mbox{\boldmath$ n$}} -\def\bo{\mbox{\boldmath$ o$}} -\def\bp{\mbox{\boldmath$ p$}} -\def\bq{\mbox{\boldmath$ q$}} -\def\br{\mbox{\boldmath$ r$}} -\def\bs{\mbox{\boldmath$ s$}} -\def\bt{\mbox{\boldmath$ t$}} -\def\bu{\mbox{\boldmath$ u$}} -\def\bv{\mbox{\boldmath$ v$}} -\def\bw{\mbox{\boldmath$ w$}} -\def\bx{\mbox{\boldmath$ x$}} -\def\by{\mbox{\boldmath$ y$}} -\def\bz{\mbox{\boldmath$ z$}} -%********************************* -%Start main paper -%********************************* -\centerline{\Large{\bf PRISMS-PF}} -\smallskip -\centerline{\Large{\bf Mechanics (Infinitesimal Strain)}} -\bigskip -Consider a strain energy expression of the form: -\begin{equation} - \Pi(\varepsilon) = \int_{\Omega} \frac{1}{2} \varepsilon:C:\varepsilon ~dV -\end{equation} -where $\varepsilon$ is the infinitesimal strain tensor, $C_{ijkl}=\lambda \delta_{ij} \delta_{kl}+\mu ( \delta_{ik} \delta_{jl}+ \delta_{il} \delta_{jk} )$ is the fourth order elasticity tensor and ($\lambda$, $mu$) are the Lame parameters. - -\section{Variational treatment} -Considering variations on the displacement $u$ of the from $u+\epsilon w$, we have -\begin{align} -\delta \Pi &= \left. \frac{d}{d\epsilon} \int_{\Omega} \frac{1}{2} \varepsilon_{\epsilon}:C:\varepsilon_{\epsilon} ~dV \right\vert_{\epsilon=0} \\ -&= -\int_{\Omega} \grad w : C : \varepsilon ~dV + \int_{\partial \Omega} w \cdot (C : \varepsilon \cdot n) ~dS\\ -&= -\int_{\Omega} \grad w : \sigma ~dV + \int_{\partial \Omega} w \cdot (\sigma \cdot n) ~dS\\ -&= -\int_{\Omega} \grad w : \sigma ~dV + \int_{\partial \Omega} w \cdot t ~dS -\end{align} -where $\sigma = C : \varepsilon$ is the stress tensor and $t=\sigma \cdot n$ is the surface traction.\\ - -The minimization of the variation, $\delta \Pi=0$, gives the weak formulation of the governing equation of mechanics: - -\begin{align} -\int_{\Omega} \grad w : \sigma ~dV - \int_{\partial \Omega} w \cdot t ~dS = 0 -\end{align} - -If surface tractions are zero: \\ -\begin{align} -R &= \int_{\Omega} \grad w : \sigma ~dV = 0 -\end{align} -We solve for $R=0$ using a gradient scheme which involves the following linearization: -\begin{align} -R~|_{u}+ \frac{\partial R}{\partial u} \Delta u &= 0 \\ -\Rightarrow \frac{\partial R}{\partial u} \Delta u &= -R~|_{u} -\end{align} -This is the linear system $Ax=b$ which we solve implicitly using the Conjugate Gradient scheme. For clarity, here in the left hand side (LHS) $A=\frac{\partial R}{\partial u}$, $x=\Delta u$ and the right hand side (RHS) is $b=-R~|_{u}$. - -\end{document} \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/CMakeLists.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/ICs_and_BCs.h b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/ICs_and_BCs.h deleted file mode 100644 index 7129dffae..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/ICs_and_BCs.h +++ /dev/null @@ -1,187 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - -#define x_denom 1.0 -#define y_denom 1.0 -#define z_denom 1.0 -#define initial_interface_coeff 1.0 -#define initial_radius 7.0 -#define avg_Nd 0.004 - - if (index == 0) - { - // return the value of the initial concentration field at point p - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; - // return 0.02 + 1.0e-3*(2*(0.5 - (double)(std::rand() % 100 )/100.0)); -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (0.12 - 0.00) * (1 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#elif problemDIM == 3 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#endif - } - else if (index == 1) - { - // set result equal to the structural order paramter initial condition - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (1.0 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - -#elif problemDIM == 3 - // r=p.distance(Point(spanX/2.0,spanY/2.0,spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r-spanX/8.0)/(3*dx))); - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - - // planar interface - // r=sqrt((p.operator()(2)-spanZ/2.0)*(p.operator()(2)-spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r)/(initial_interface_coeff))); - // return - // 0.5*(1.0-std::tanh((r-initial_radius)/(initial_interface_coeff))); -#endif - return 0.0; - } - else if (index == 2) - { - scalar_IC = 0.0; - } - else if (index == 3) - { - scalar_IC = 0.0; - } - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - if (index == 4) - { - vector_IC(0) = 0.0; - vector_IC(1) = 0.0; - if (dim == 3) - { - vector_IC(2) = 0.0; - } - } - // ===================================================================== - } -}; - -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") - // Fourth input: BC value (ignored unless the BC type is "DIRICHLET") - // Odd inputs after the third: BC type - // Even inputs after the third: BC value - // Face numbering: starts at zero with the minimum of the first direction, one - // for the maximum of the first direction - // two for the minimum of the second direction, etc. - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(1, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(2, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(3, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(4, 0, "DIRICHLET", 0.0); - inputBCs(4, 1, "DIRICHLET", 0.0); - if (dim == 3) - { - inputBCs(4, 2, "DIRICHLET", 0.0); - } - - // ===================================================================== -} diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/error1.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/error1.txt deleted file mode 100644 index a99b71117..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/error1.txt +++ /dev/null @@ -1 +0,0 @@ -0.00321809854358 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/error2.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/error2.txt deleted file mode 100644 index cad323574..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/error2.txt +++ /dev/null @@ -1 +0,0 @@ -0.000839648768306 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/error3.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/error3.txt deleted file mode 100644 index c7e786da5..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/error3.txt +++ /dev/null @@ -1 +0,0 @@ -0.000170818530023 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/getError1.py b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/getError1.py deleted file mode 100644 index 9d38eccd1..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/getError1.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "1000" -output_num_2 = "1000" - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = False - -directory_1 = "run_001/solution-"+output_num_1+".pvtu" -directory_2 = "run_004/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("error1.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/getError2.py b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/getError2.py deleted file mode 100644 index 9842a3e8e..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/getError2.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "1000" -output_num_2 = "1000" - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = False - -directory_1 = "run_002/solution-"+output_num_1+".pvtu" -directory_2 = "run_004/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("error2.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/getError3.py b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/getError3.py deleted file mode 100644 index 6cc1dd9cb..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/getError3.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "1000" -output_num_2 = "1000" - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = False - -directory_1 = "run_003/solution-"+output_num_1+".pvtu" -directory_2 = "run_004/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("error3.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/main.cc b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/main.cc deleted file mode 100644 index a62d5cdca..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/main.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" -#include "space_parameters.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/parameters.h b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/parameters.h deleted file mode 100644 index 8bf5faf29..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/parameters.h +++ /dev/null @@ -1,101 +0,0 @@ -// Parameter list for the precipitate evolution example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 3 - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 16.0 -#define spanY 16.0 -#define spanZ 16.0 - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size #define subdivisionsX 3 #define subdivisionsY 3 #define subdivisionsZ 3 -// #define refineFactor 5 - -// Set the polynomial degree of the element (suggested values: 1 or 2) -// #define finiteElementDegree 2 - -// ================================================================================= -// Set the adaptive mesh refinement parameters -// ================================================================================= -// Set the flag determining if adaptive meshing is activated -#define hAdaptivity false - -// Set the maximum and minimum level of refinement -#define maxRefinementLevel (refineFactor) -#define minRefinementLevel (refineFactor - 2) - -// Set the fields used to determine the refinement. Fields determined by the -// order declared in "equations.h", starting at zero -#define refineCriterionFields \ - { \ - 1, 2, 3 \ - } - -// Set the maximum and minimum value of the fields where the mesh should be -// refined -#define refineWindowMax \ - { \ - 0.99, 0.99, 0.99 \ - } -#define refineWindowMin \ - { \ - 0.01, 0.01, 0.01 \ - } - -// Set the number of time steps between remeshing operations -#define skipRemeshingSteps 1000 - -// ================================================================================= -// Set the time step parameters -// ================================================================================= -// The size of the time step -#define timeStep 3.0e-5 -#define timeFinal 100000000 -#define timeIncrements 1000 - -// ================================================================================= -// Set the elliptic solver parameters -// ================================================================================= -// The solver type (currently the only recommended option is conjugate gradient) -#define solverType SolverCG - -// The flag that determines whether the tolerance for solver convergence should -// be an absolute tolerance (absTol=true) or a relative tolerance (absTol=false) -#define absTol true - -// The tolerance for convergence (L2 norm of the residual) -#define solverTolerance 1.0e-4 - -// The maximum number of solver iterations per time step -#define maxSolverIterations 1000 - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 1 - -// ================================================================================= -// Set the flag determining if the total free energy is calculated for each -// output -// ================================================================================= -#define calcEnergy false diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/residuals.h b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/residuals.h deleted file mode 100644 index 3c8190016..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/residuals.h +++ /dev/null @@ -1,682 +0,0 @@ -// List of variables and residual equations for the Precipitate Evolution -// example application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 5 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "c", "n1", "n2", "n3", "u" \ - } -#define variable_type \ - { \ - "SCALAR", "SCALAR", "SCALAR", "SCALAR", "VECTOR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC", "PARABOLIC", "PARABOLIC", "PARABOLIC", "ELLIPTIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - true, true, true, true, false \ - } -#define need_grad \ - { \ - true, true, true, true, true \ - } -#define need_hess \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - true, true, true, true, false \ - } -#define need_grad_residual \ - { \ - true, true, true, true, true \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqn for the left-hand-side of the iterative solver for elliptic equations -#define need_val_LHS \ - { \ - false, true, true, true, false \ - } -#define need_grad_LHS \ - { \ - false, false, false, false, true \ - } -#define need_hess_LHS \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation for the left-hand-side of the -// iterative solver for elliptic equations has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual_LHS \ - { \ - false, false, false, false, false \ - } -#define need_grad_residual_LHS \ - { \ - false, false, false, false, true \ - } - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Cahn-Hilliard mobility -#define McV 1.0 - -// Allen-Cahn mobilities -#define Mn1V 50.0 -#define Mn2V 50.0 -#define Mn3V 50.0 - -// Gradient energy coefficients -double Kn1[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn2[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn3[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; - -// define energy barrier coefficient (used to tune the interfacial energy) -#define W -1.0 - -// Define mechanical properties -#define n_dependent_stiffness false -// Mechanical symmetry of the material and stiffness parameters -// If n_dependent_stiffness == false the first entry is used for all phases -#define MaterialModels \ - { \ - { \ - "ISOTROPIC" \ - } \ - } -#define MaterialConstants \ - { \ - { \ - 1.0, 0.3 \ - } \ - } - -// Stress-free transformation strains -// Linear fits for the stress-free transformation strains in for sfts = -// sfts_linear * c + sfts_const -double sfts_linear1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -// Free energy expressions -#define faV (24.7939 * c * c - 1.6752 * c - 1.9453e-06) -#define facV (49.5878 * c - 1.6752) -#define faccV (49.5878) -#define fbV (37.9316 * c * c - 10.7373 * c + 0.5401) -#define fbcV (75.8633 * c - 10.7373) -#define fbccV (75.8633) -#define h1V (3.0 * n1 * n1 - 2.0 * n1 * n1 * n1) -#define h2V (3.0 * n2 * n2 - 2.0 * n2 * n2 * n2) -#define h3V (3.0 * n3 * n3 - 2.0 * n3 * n3 * n3) -#define hn1V (6.0 * n1 - 6.0 * n1 * n1) -#define hn2V (6.0 * n2 - 6.0 * n2 * n2) -#define hn3V (6.0 * n3 - 6.0 * n3 * n3) - -// This double-well function can be used to tune the interfacial energy -#define fbarrierV (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1) -#define fbarriernV (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1) - -// Residuals -#define rcV (c) -#define rcxTemp \ - (cx * ((1.0 - h1V - h2V - h3V) * faccV + (h1V + h2V + h3V) * fbccV) + \ - n1x * ((fbcV - facV) * hn1V) + n2x * ((fbcV - facV) * hn2V) + \ - n3x * ((fbcV - facV) * hn3V)) -#define rcxV (constV(-timeStep * McV) * rcxTemp) - -#define rn1V \ - (n1 - constV(timeStep * Mn1V) * \ - ((fbV - faV) * hn1V + W * fbarriernV + nDependentMisfitAC1)) -#define rn2V (n2 - constV(timeStep * Mn2V) * ((fbV - faV) * hn2V)) -#define rn3V (n3 - constV(timeStep * Mn3V) * ((fbV - faV) * hn3V)) -#define rn1xV (constV(-timeStep * Mn1V) * Knx1) -#define rn2xV (constV(-timeStep * Mn2V) * Knx2) -#define rn3xV (constV(-timeStep * Mn3V) * Knx3) - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // The concentration and its derivatives (names here should match those in the - // macros above) - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - // The first order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n1 = modelVariablesList[1].scalarValue; - scalargradType n1x = modelVariablesList[1].scalarGrad; - - // The second order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n2 = modelVariablesList[2].scalarValue; - scalargradType n2x = modelVariablesList[2].scalarGrad; - - // The third order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n3 = modelVariablesList[3].scalarValue; - scalargradType n3x = modelVariablesList[3].scalarGrad; - - // The derivative of the displacement vector (names here should match those in - // the macros above) - vectorgradType ux = modelVariablesList[4].vectorGrad; - vectorgradType ruxV; - - vectorhessType uxx; - - if (c_dependent_misfit == true) - { - uxx = modelVariablesList[4].vectorHess; - } - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - // Fill residual corresponding to mechanics - // R=-C*(E-E0) - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - ruxV[i][j] = -S[i][j]; - } - } - - // Compute one of the stress terms in the order parameter chemical potential, - // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - nDependentMisfitAC1 += S[i][j] * (sfts1[i][j]); - nDependentMisfitAC2 += S[i][j] * (sfts2[i][j]); - nDependentMisfitAC3 += S[i][j] * (sfts3[i][j]); - } - } - - nDependentMisfitAC1 *= -hn1V; - nDependentMisfitAC2 *= -hn2V; - nDependentMisfitAC3 *= -hn3V; - - // Compute the other stress term in the order parameter chemical potential, - // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray heterMechAC2 = constV(0.0); - dealii::VectorizedArray heterMechAC3 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; - - if (n_dependent_stiffness == true) - { - // computeStress(CIJ_diff, E2, S2); - computeStress(CIJ_list[1] - CIJ_list[0], E2, S2); - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - heterMechAC1 += S2[i][j] * E2[i][j]; - } - } - // Aside from HnpV, heterMechAC1, heterMechAC2, and heterMechAC3 are equal - heterMechAC2 = 0.5 * hn2V * heterMechAC1; - heterMechAC3 = 0.5 * hn3V * heterMechAC1; - - heterMechAC1 = 0.5 * hn1V * heterMechAC1; - } - - // compute the stress term in the gradient of the concentration chemical - // potential, grad_mu_el = [C*(E-E0)*E0c]x, must be a vector with length dim - scalargradType grad_mu_el; - - if (c_dependent_misfit == true) - { - dealii::VectorizedArray E3[dim][dim], S3[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E3[i][j] = -(sfts1c[i][j] * h1V + sfts2c[i][j] * h2V + sfts3c[i][j] * h3V); - } - } - - if (n_dependent_stiffness == true) - { - computeStress(CIJ_combined, E3, S3); - } - else - { - computeStress(CIJ_list[0], E3, S3); - } - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - grad_mu_el[k] += - S3[i][j] * - (constV(0.5) * (uxx[i][j][k] + uxx[j][i][k]) + E3[i][j] * cx[k] - - (sfts1[i][j] * hn1V * n1x[k] + sfts2[i][j] * hn2V * n2x[k] + - sfts3[i][j] * hn3V * n3x[k])); - - grad_mu_el[k] += - -S[i][j] * - (sfts1c[i][j] * hn1V * n1x[k] + sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k] + - (sfts1cc[i][j] * h1V + sfts2cc[i][j] * h2V + sfts3cc[i][j] * h3V) * - cx[k]); - - if (n_dependent_stiffness == true) - { - grad_mu_el[k] += -S2[i][j] * (sfts1c[i][j] * hn1V * n1x[k] + - sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k]); - } - } - } - } - } - - // compute K*nx - scalargradType Knx1, Knx2, Knx3; - for (unsigned int a = 0; a < dim; a++) - { - Knx1[a] = 0.0; - Knx2[a] = 0.0; - Knx3[a] = 0.0; - for (unsigned int b = 0; b < dim; b++) - { - Knx1[a] += constV(Kn1[a][b]) * n1x[b]; - Knx2[a] += constV(Kn2[a][b]) * n2x[b]; - Knx3[a] += constV(Kn3[a][b]) * n3x[b]; - } - } - - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; - - modelResidualsList[1].scalarValueResidual = rn1V; - modelResidualsList[1].scalarGradResidual = rn1xV; - - modelResidualsList[2].scalarValueResidual = rn2V; - modelResidualsList[2].scalarGradResidual = rn2xV; - - modelResidualsList[3].scalarValueResidual = rn3V; - modelResidualsList[3].scalarGradResidual = rn3xV; - - modelResidualsList[4].vectorGradResidual = ruxV; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVariablesList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // n1 - scalarvalueType n1 = modelVariablesList[0].scalarValue; - - // n2 - scalarvalueType n2 = modelVariablesList[1].scalarValue; - - // n3 - scalarvalueType n3 = modelVariablesList[2].scalarValue; - - // u - vectorgradType ux = modelVariablesList[3].vectorGrad; - vectorgradType ruxV; - - // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the - // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; - E = symmetrize(ux); - - // Compute stress tensor (which is equal to the residual, Rux) - if (n_dependent_stiffness == true) - { - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; - CIJ_combined = - CIJ_list[0] * (constV(1.0) - h1V - h2V - h3V) + CIJ_list[1] * (h1V + h2V + h3V); - - computeStress(CIJ_combined, E, ruxV); - } - else - { - computeStress(CIJ_list[0], E, ruxV); - } - - modelRes.vectorGradResidual = ruxV; -} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - scalarvalueType total_energy_density = constV(0.0); - - // c - scalarvalueType c = modelVarList[0].scalarValue; - scalargradType cx = modelVarList[0].scalarGrad; - - // n1 - scalarvalueType n1 = modelVarList[1].scalarValue; - scalargradType n1x = modelVarList[1].scalarGrad; - - // n2 - scalarvalueType n2 = modelVarList[2].scalarValue; - scalargradType n2x = modelVarList[2].scalarGrad; - - // n3 - scalarvalueType n3 = modelVarList[3].scalarValue; - scalargradType n3x = modelVarList[3].scalarGrad; - - // u - vectorgradType ux = modelVarList[4].vectorGrad; - - scalarvalueType f_chem = - (constV(1.0) - (h1V + h2V + h3V)) * faV + (h1V + h2V + h3V) * fbV; - - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn1[i][j]) * n1x[i] * n1x[j]; - } - } -#if num_sop > 1 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn2[i][j]) * n2x[i] * n2x[j]; - } - } -#endif -#if num_sop > 2 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn3[i][j]) * n3x[i] * n3x[j]; - } - } -#endif - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // E2[i][j]= constV(0.5)*(ux[i][j]+ux[j][i])-( sfts1[i][j]*h1V + - // sfts2[i][j]*h2V + sfts3[i][j]*h3V); - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[2 * dim - 1 + dim / 3] - [2 * dim - 1 + dim / 3]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - scalarvalueType f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E2[i][j]; - } - } - - total_energy_density = f_chem + f_grad + f_el; - - assembler_lock.acquire(); - for (unsigned i = 0; i < c.size(); i++) - { - // For some reason, some of the values in this loop - if (c[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - this->energy_components[2] += f_el[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/run_spatial_ooa_test.py b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/run_spatial_ooa_test.py deleted file mode 100644 index 9f08e318f..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/run_spatial_ooa_test.py +++ /dev/null @@ -1,83 +0,0 @@ -import subprocess -import shutil -import glob -import math -import os.path - -# ---------------------------------------------------------------------------------------- -# Function that generates a header file for the simulation, compiles the PRISMS-PF code -# and runs the executable. -# ---------------------------------------------------------------------------------------- -def run_simulation(refineFactor,run_name): - - subdivisionsX = 1 - subdivisionsY = 1 - subdivisionsZ = 1 - finiteElementDegree = 1 - - text_file = open("space_parameters.h","w") - text_file.write("// Parameters list for the parameters involved in mesh generation \n") - text_file.write("#define subdivisionsX " + str(subdivisionsX) + "\n") - text_file.write("#define subdivisionsY " + str(subdivisionsY) + "\n") - text_file.write("#define subdivisionsZ " + str(subdivisionsZ) + "\n") - text_file.write("#define refineFactor " + str(refineFactor) + "\n") - text_file.write("#define finiteElementDegree " + str(finiteElementDegree) + "\n") - text_file.close() - - subprocess.call(["make", "release"]) - #subprocess.call(["./main"]) - subprocess.call(["mpirun", "-n", "4", "main"]) - - subprocess.call(["mkdir",run_name]) - for output_files in glob.glob('*vtu'): - shutil.move(output_files,run_name) - -# ---------------------------------------------------------------------------------------- - -# If files exist from previous tests, delete them -if os.path.exists("run_001") == True: - shutil.rmtree("run_001") -if os.path.exists("run_002") == True: - shutil.rmtree("run_002") -if os.path.exists("run_003") == True: - shutil.rmtree("run_003") -if os.path.exists("run_004") == True: - shutil.rmtree("run_004") - -# Run simulations with a decreasing time step (and an corresponding increase in number of iterations) -run_simulation(4,'run_001') -run_simulation(5,'run_002') -run_simulation(6,'run_003') -run_simulation(7,'run_004') - -# Find the error for runs 1-3 (as compared to run 4) -subprocess.call(["visit", "-cli","-s","getError1.py"]) -subprocess.call(["visit", "-cli","-s","getError2.py"]) -subprocess.call(["visit", "-cli","-s","getError3.py"]) - -f = open('error1.txt','r') -error1 = float(f.read()) -f.close() - -f = open('error2.txt','r') -error2 = float(f.read()) -f.close() - -f = open('error3.txt','r') -error3 = float(f.read()) -f.close() - -# Calculate and output order of accuracy -ooa_1_to_2 = math.log10(error1/error2)/math.log10(2) -ooa_2_to_3 = math.log10(error2/error3)/math.log10(2) - -print "Order of accuracy results: \n" -print "Mesh refinement of 4 to mesh refinement of 5:", str(ooa_1_to_2), "\n" -print "Mesh refinement of 5 to mesh refinement of 6:", str(ooa_2_to_3), "\n" - -text_file = open("spat_ooa_results.txt","w") -text_file.write("Results of standard spatial order of accuracy test: \n") -text_file.write("From coarse mesh to medium mesh: " + str(ooa_1_to_2) + "\n") -text_file.write("From from medium mesh to fine mesh: " + str(ooa_2_to_3) + "\n") -text_file.close() - diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/space_parameters.h b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/space_parameters.h deleted file mode 100644 index a1f9a2438..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/space_parameters.h +++ /dev/null @@ -1,6 +0,0 @@ -// Parameters list for the parameters involved in mesh generation -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 7 -#define finiteElementDegree 1 diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/spat_ooa_results.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/spat_ooa_results.txt deleted file mode 100644 index a4e02b4a4..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/spat_ooa_results.txt +++ /dev/null @@ -1,3 +0,0 @@ -Results of standard spatial order of accuracy test: -From coarse mesh to medium mesh: 1.93835063599 -From from medium mesh to fine mesh: 2.29732147951 diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/visitlog.py b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/visitlog.py deleted file mode 100644 index 3c673b642..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test/visitlog.py +++ /dev/null @@ -1,57 +0,0 @@ -# Visit 2.7.0 log file -ScriptVersion = "2.7.0" -if ScriptVersion != Version(): - print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version()) -ShowAllWindows() -OpenDatabase("run_003/solution-1000.pvtu", 0) -# The UpdateDBPluginInfo RPC is not supported in the VisIt module so it will not be logged. -DefineScalarExpression("diff", "(c-pos_cmfe(, mesh,0))") -AddPlot("Pseudocolor", "diff", 1, 1) -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.scaling = PseudocolorAtts.Linear # Linear, Log, Skew -PseudocolorAtts.skewFactor = 1 -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot -PseudocolorAtts.minFlag = 0 -PseudocolorAtts.min = 0 -PseudocolorAtts.maxFlag = 0 -PseudocolorAtts.max = 1 -PseudocolorAtts.centering = PseudocolorAtts.Natural # Natural, Nodal, Zonal -PseudocolorAtts.colorTableName = "hot" -PseudocolorAtts.invertColorTable = 0 -PseudocolorAtts.opacityType = PseudocolorAtts.FullyOpaque # ColorTable, FullyOpaque, Constant, Ramp, VariableRange -PseudocolorAtts.opacityVariable = "" -PseudocolorAtts.opacity = 1 -PseudocolorAtts.opacityVarMin = 0 -PseudocolorAtts.opacityVarMax = 1 -PseudocolorAtts.opacityVarMinFlag = 0 -PseudocolorAtts.opacityVarMaxFlag = 0 -PseudocolorAtts.pointSize = 0.05 -PseudocolorAtts.pointType = PseudocolorAtts.Point # Box, Axis, Icosahedron, Octahedron, Tetrahedron, SphereGeometry, Point, Sphere -PseudocolorAtts.pointSizeVarEnabled = 0 -PseudocolorAtts.pointSizeVar = "default" -PseudocolorAtts.pointSizePixels = 2 -PseudocolorAtts.lineType = PseudocolorAtts.Line # Line, Tube, Ribbon -PseudocolorAtts.lineStyle = PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH -PseudocolorAtts.lineWidth = 0 -PseudocolorAtts.tubeDisplayDensity = 10 -PseudocolorAtts.tubeRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.tubeRadiusAbsolute = 0.125 -PseudocolorAtts.tubeRadiusBBox = 0.005 -PseudocolorAtts.varyTubeRadius = 0 -PseudocolorAtts.varyTubeRadiusVariable = "" -PseudocolorAtts.varyTubeRadiusFactor = 10 -PseudocolorAtts.endPointType = PseudocolorAtts.None # None, Tails, Heads, Both -PseudocolorAtts.endPointStyle = PseudocolorAtts.Spheres # Spheres, Cones -PseudocolorAtts.endPointRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.endPointRadiusAbsolute = 1 -PseudocolorAtts.endPointRadiusBBox = 0.005 -PseudocolorAtts.endPointRatio = 2 -PseudocolorAtts.renderSurfaces = 1 -PseudocolorAtts.renderWireframe = 0 -PseudocolorAtts.renderPoints = 0 -PseudocolorAtts.smoothingLevel = 0 -PseudocolorAtts.legendFlag = 1 -PseudocolorAtts.lightingFlag = 1 -SetPlotOptions(PseudocolorAtts) -DrawPlots() -Query("MinMax", use_actual_data=1) diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/CMakeLists.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/ICs_and_BCs.h b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/ICs_and_BCs.h deleted file mode 100644 index 7129dffae..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/ICs_and_BCs.h +++ /dev/null @@ -1,187 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - -#define x_denom 1.0 -#define y_denom 1.0 -#define z_denom 1.0 -#define initial_interface_coeff 1.0 -#define initial_radius 7.0 -#define avg_Nd 0.004 - - if (index == 0) - { - // return the value of the initial concentration field at point p - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; - // return 0.02 + 1.0e-3*(2*(0.5 - (double)(std::rand() % 100 )/100.0)); -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (0.12 - 0.00) * (1 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#elif problemDIM == 3 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#endif - } - else if (index == 1) - { - // set result equal to the structural order paramter initial condition - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (1.0 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - -#elif problemDIM == 3 - // r=p.distance(Point(spanX/2.0,spanY/2.0,spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r-spanX/8.0)/(3*dx))); - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - - // planar interface - // r=sqrt((p.operator()(2)-spanZ/2.0)*(p.operator()(2)-spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r)/(initial_interface_coeff))); - // return - // 0.5*(1.0-std::tanh((r-initial_radius)/(initial_interface_coeff))); -#endif - return 0.0; - } - else if (index == 2) - { - scalar_IC = 0.0; - } - else if (index == 3) - { - scalar_IC = 0.0; - } - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - if (index == 4) - { - vector_IC(0) = 0.0; - vector_IC(1) = 0.0; - if (dim == 3) - { - vector_IC(2) = 0.0; - } - } - // ===================================================================== - } -}; - -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") - // Fourth input: BC value (ignored unless the BC type is "DIRICHLET") - // Odd inputs after the third: BC type - // Even inputs after the third: BC value - // Face numbering: starts at zero with the minimum of the first direction, one - // for the maximum of the first direction - // two for the minimum of the second direction, etc. - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(1, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(2, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(3, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(4, 0, "DIRICHLET", 0.0); - inputBCs(4, 1, "DIRICHLET", 0.0); - if (dim == 3) - { - inputBCs(4, 2, "DIRICHLET", 0.0); - } - - // ===================================================================== -} diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error.txt deleted file mode 100644 index 8cbef5208..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error.txt +++ /dev/null @@ -1 +0,0 @@ -5.74858859181e-05 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error1.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error1.txt deleted file mode 100644 index b0183ae2d..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error1.txt +++ /dev/null @@ -1 +0,0 @@ -0.0044260378927 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error2.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error2.txt deleted file mode 100644 index 41b6d8c6c..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error2.txt +++ /dev/null @@ -1 +0,0 @@ -0.00117394141853 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error3.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error3.txt deleted file mode 100644 index 67fa0e06a..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error3.txt +++ /dev/null @@ -1 +0,0 @@ -0.000283651053905 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error4.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error4.txt deleted file mode 100644 index 8cbef5208..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/error4.txt +++ /dev/null @@ -1 +0,0 @@ -5.74858859181e-05 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/getError.py b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/getError.py deleted file mode 100644 index 66487f042..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/getError.py +++ /dev/null @@ -1,69 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "10000" -output_num_2 = "10000" - -f = open('run_num_1.txt','r') -run_num_1 = f.read() -f.close() - -f = open('run_num_2.txt','r') -run_num_2 = f.read() -f.close() - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = False - -directory_1 = run_num_1+"/solution-"+output_num_1+".pvtu" -directory_2 = run_num_2+"/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("error.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/main.cc b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/main.cc deleted file mode 100644 index a62d5cdca..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/main.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" -#include "space_parameters.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/parameters.h b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/parameters.h deleted file mode 100644 index 73fd7add8..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/parameters.h +++ /dev/null @@ -1,101 +0,0 @@ -// Parameter list for the precipitate evolution example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 2 - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 16.0 -#define spanY 16.0 -#define spanZ 16.0 - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size #define subdivisionsX 3 #define subdivisionsY 3 #define subdivisionsZ 3 -// #define refineFactor 5 - -// Set the polynomial degree of the element (suggested values: 1 or 2) -// #define finiteElementDegree 2 - -// ================================================================================= -// Set the adaptive mesh refinement parameters -// ================================================================================= -// Set the flag determining if adaptive meshing is activated -#define hAdaptivity false - -// Set the maximum and minimum level of refinement -#define maxRefinementLevel (refineFactor) -#define minRefinementLevel (refineFactor - 2) - -// Set the fields used to determine the refinement. Fields determined by the -// order declared in "equations.h", starting at zero -#define refineCriterionFields \ - { \ - 1, 2, 3 \ - } - -// Set the maximum and minimum value of the fields where the mesh should be -// refined -#define refineWindowMax \ - { \ - 0.99, 0.99, 0.99 \ - } -#define refineWindowMin \ - { \ - 0.01, 0.01, 0.01 \ - } - -// Set the number of time steps between remeshing operations -#define skipRemeshingSteps 1000 - -// ================================================================================= -// Set the time step parameters -// ================================================================================= -// The size of the time step -#define timeStep 9.0e-6 -#define timeFinal 100000000 -#define timeIncrements 10000 - -// ================================================================================= -// Set the elliptic solver parameters -// ================================================================================= -// The solver type (currently the only recommended option is conjugate gradient) -#define solverType SolverCG - -// The flag that determines whether the tolerance for solver convergence should -// be an absolute tolerance (absTol=true) or a relative tolerance (absTol=false) -#define absTol true - -// The tolerance for convergence (L2 norm of the residual) -#define solverTolerance 1.0e-4 - -// The maximum number of solver iterations per time step -#define maxSolverIterations 1000 - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 1 - -// ================================================================================= -// Set the flag determining if the total free energy is calculated for each -// output -// ================================================================================= -#define calcEnergy false diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/residuals.h b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/residuals.h deleted file mode 100644 index 3c8190016..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/residuals.h +++ /dev/null @@ -1,682 +0,0 @@ -// List of variables and residual equations for the Precipitate Evolution -// example application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 5 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "c", "n1", "n2", "n3", "u" \ - } -#define variable_type \ - { \ - "SCALAR", "SCALAR", "SCALAR", "SCALAR", "VECTOR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC", "PARABOLIC", "PARABOLIC", "PARABOLIC", "ELLIPTIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - true, true, true, true, false \ - } -#define need_grad \ - { \ - true, true, true, true, true \ - } -#define need_hess \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - true, true, true, true, false \ - } -#define need_grad_residual \ - { \ - true, true, true, true, true \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqn for the left-hand-side of the iterative solver for elliptic equations -#define need_val_LHS \ - { \ - false, true, true, true, false \ - } -#define need_grad_LHS \ - { \ - false, false, false, false, true \ - } -#define need_hess_LHS \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation for the left-hand-side of the -// iterative solver for elliptic equations has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual_LHS \ - { \ - false, false, false, false, false \ - } -#define need_grad_residual_LHS \ - { \ - false, false, false, false, true \ - } - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Cahn-Hilliard mobility -#define McV 1.0 - -// Allen-Cahn mobilities -#define Mn1V 50.0 -#define Mn2V 50.0 -#define Mn3V 50.0 - -// Gradient energy coefficients -double Kn1[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn2[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn3[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; - -// define energy barrier coefficient (used to tune the interfacial energy) -#define W -1.0 - -// Define mechanical properties -#define n_dependent_stiffness false -// Mechanical symmetry of the material and stiffness parameters -// If n_dependent_stiffness == false the first entry is used for all phases -#define MaterialModels \ - { \ - { \ - "ISOTROPIC" \ - } \ - } -#define MaterialConstants \ - { \ - { \ - 1.0, 0.3 \ - } \ - } - -// Stress-free transformation strains -// Linear fits for the stress-free transformation strains in for sfts = -// sfts_linear * c + sfts_const -double sfts_linear1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -// Free energy expressions -#define faV (24.7939 * c * c - 1.6752 * c - 1.9453e-06) -#define facV (49.5878 * c - 1.6752) -#define faccV (49.5878) -#define fbV (37.9316 * c * c - 10.7373 * c + 0.5401) -#define fbcV (75.8633 * c - 10.7373) -#define fbccV (75.8633) -#define h1V (3.0 * n1 * n1 - 2.0 * n1 * n1 * n1) -#define h2V (3.0 * n2 * n2 - 2.0 * n2 * n2 * n2) -#define h3V (3.0 * n3 * n3 - 2.0 * n3 * n3 * n3) -#define hn1V (6.0 * n1 - 6.0 * n1 * n1) -#define hn2V (6.0 * n2 - 6.0 * n2 * n2) -#define hn3V (6.0 * n3 - 6.0 * n3 * n3) - -// This double-well function can be used to tune the interfacial energy -#define fbarrierV (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1) -#define fbarriernV (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1) - -// Residuals -#define rcV (c) -#define rcxTemp \ - (cx * ((1.0 - h1V - h2V - h3V) * faccV + (h1V + h2V + h3V) * fbccV) + \ - n1x * ((fbcV - facV) * hn1V) + n2x * ((fbcV - facV) * hn2V) + \ - n3x * ((fbcV - facV) * hn3V)) -#define rcxV (constV(-timeStep * McV) * rcxTemp) - -#define rn1V \ - (n1 - constV(timeStep * Mn1V) * \ - ((fbV - faV) * hn1V + W * fbarriernV + nDependentMisfitAC1)) -#define rn2V (n2 - constV(timeStep * Mn2V) * ((fbV - faV) * hn2V)) -#define rn3V (n3 - constV(timeStep * Mn3V) * ((fbV - faV) * hn3V)) -#define rn1xV (constV(-timeStep * Mn1V) * Knx1) -#define rn2xV (constV(-timeStep * Mn2V) * Knx2) -#define rn3xV (constV(-timeStep * Mn3V) * Knx3) - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // The concentration and its derivatives (names here should match those in the - // macros above) - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - // The first order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n1 = modelVariablesList[1].scalarValue; - scalargradType n1x = modelVariablesList[1].scalarGrad; - - // The second order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n2 = modelVariablesList[2].scalarValue; - scalargradType n2x = modelVariablesList[2].scalarGrad; - - // The third order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n3 = modelVariablesList[3].scalarValue; - scalargradType n3x = modelVariablesList[3].scalarGrad; - - // The derivative of the displacement vector (names here should match those in - // the macros above) - vectorgradType ux = modelVariablesList[4].vectorGrad; - vectorgradType ruxV; - - vectorhessType uxx; - - if (c_dependent_misfit == true) - { - uxx = modelVariablesList[4].vectorHess; - } - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - // Fill residual corresponding to mechanics - // R=-C*(E-E0) - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - ruxV[i][j] = -S[i][j]; - } - } - - // Compute one of the stress terms in the order parameter chemical potential, - // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - nDependentMisfitAC1 += S[i][j] * (sfts1[i][j]); - nDependentMisfitAC2 += S[i][j] * (sfts2[i][j]); - nDependentMisfitAC3 += S[i][j] * (sfts3[i][j]); - } - } - - nDependentMisfitAC1 *= -hn1V; - nDependentMisfitAC2 *= -hn2V; - nDependentMisfitAC3 *= -hn3V; - - // Compute the other stress term in the order parameter chemical potential, - // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray heterMechAC2 = constV(0.0); - dealii::VectorizedArray heterMechAC3 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; - - if (n_dependent_stiffness == true) - { - // computeStress(CIJ_diff, E2, S2); - computeStress(CIJ_list[1] - CIJ_list[0], E2, S2); - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - heterMechAC1 += S2[i][j] * E2[i][j]; - } - } - // Aside from HnpV, heterMechAC1, heterMechAC2, and heterMechAC3 are equal - heterMechAC2 = 0.5 * hn2V * heterMechAC1; - heterMechAC3 = 0.5 * hn3V * heterMechAC1; - - heterMechAC1 = 0.5 * hn1V * heterMechAC1; - } - - // compute the stress term in the gradient of the concentration chemical - // potential, grad_mu_el = [C*(E-E0)*E0c]x, must be a vector with length dim - scalargradType grad_mu_el; - - if (c_dependent_misfit == true) - { - dealii::VectorizedArray E3[dim][dim], S3[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E3[i][j] = -(sfts1c[i][j] * h1V + sfts2c[i][j] * h2V + sfts3c[i][j] * h3V); - } - } - - if (n_dependent_stiffness == true) - { - computeStress(CIJ_combined, E3, S3); - } - else - { - computeStress(CIJ_list[0], E3, S3); - } - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - grad_mu_el[k] += - S3[i][j] * - (constV(0.5) * (uxx[i][j][k] + uxx[j][i][k]) + E3[i][j] * cx[k] - - (sfts1[i][j] * hn1V * n1x[k] + sfts2[i][j] * hn2V * n2x[k] + - sfts3[i][j] * hn3V * n3x[k])); - - grad_mu_el[k] += - -S[i][j] * - (sfts1c[i][j] * hn1V * n1x[k] + sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k] + - (sfts1cc[i][j] * h1V + sfts2cc[i][j] * h2V + sfts3cc[i][j] * h3V) * - cx[k]); - - if (n_dependent_stiffness == true) - { - grad_mu_el[k] += -S2[i][j] * (sfts1c[i][j] * hn1V * n1x[k] + - sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k]); - } - } - } - } - } - - // compute K*nx - scalargradType Knx1, Knx2, Knx3; - for (unsigned int a = 0; a < dim; a++) - { - Knx1[a] = 0.0; - Knx2[a] = 0.0; - Knx3[a] = 0.0; - for (unsigned int b = 0; b < dim; b++) - { - Knx1[a] += constV(Kn1[a][b]) * n1x[b]; - Knx2[a] += constV(Kn2[a][b]) * n2x[b]; - Knx3[a] += constV(Kn3[a][b]) * n3x[b]; - } - } - - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; - - modelResidualsList[1].scalarValueResidual = rn1V; - modelResidualsList[1].scalarGradResidual = rn1xV; - - modelResidualsList[2].scalarValueResidual = rn2V; - modelResidualsList[2].scalarGradResidual = rn2xV; - - modelResidualsList[3].scalarValueResidual = rn3V; - modelResidualsList[3].scalarGradResidual = rn3xV; - - modelResidualsList[4].vectorGradResidual = ruxV; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVariablesList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // n1 - scalarvalueType n1 = modelVariablesList[0].scalarValue; - - // n2 - scalarvalueType n2 = modelVariablesList[1].scalarValue; - - // n3 - scalarvalueType n3 = modelVariablesList[2].scalarValue; - - // u - vectorgradType ux = modelVariablesList[3].vectorGrad; - vectorgradType ruxV; - - // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the - // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; - E = symmetrize(ux); - - // Compute stress tensor (which is equal to the residual, Rux) - if (n_dependent_stiffness == true) - { - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; - CIJ_combined = - CIJ_list[0] * (constV(1.0) - h1V - h2V - h3V) + CIJ_list[1] * (h1V + h2V + h3V); - - computeStress(CIJ_combined, E, ruxV); - } - else - { - computeStress(CIJ_list[0], E, ruxV); - } - - modelRes.vectorGradResidual = ruxV; -} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - scalarvalueType total_energy_density = constV(0.0); - - // c - scalarvalueType c = modelVarList[0].scalarValue; - scalargradType cx = modelVarList[0].scalarGrad; - - // n1 - scalarvalueType n1 = modelVarList[1].scalarValue; - scalargradType n1x = modelVarList[1].scalarGrad; - - // n2 - scalarvalueType n2 = modelVarList[2].scalarValue; - scalargradType n2x = modelVarList[2].scalarGrad; - - // n3 - scalarvalueType n3 = modelVarList[3].scalarValue; - scalargradType n3x = modelVarList[3].scalarGrad; - - // u - vectorgradType ux = modelVarList[4].vectorGrad; - - scalarvalueType f_chem = - (constV(1.0) - (h1V + h2V + h3V)) * faV + (h1V + h2V + h3V) * fbV; - - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn1[i][j]) * n1x[i] * n1x[j]; - } - } -#if num_sop > 1 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn2[i][j]) * n2x[i] * n2x[j]; - } - } -#endif -#if num_sop > 2 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn3[i][j]) * n3x[i] * n3x[j]; - } - } -#endif - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // E2[i][j]= constV(0.5)*(ux[i][j]+ux[j][i])-( sfts1[i][j]*h1V + - // sfts2[i][j]*h2V + sfts3[i][j]*h3V); - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[2 * dim - 1 + dim / 3] - [2 * dim - 1 + dim / 3]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - scalarvalueType f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E2[i][j]; - } - } - - total_energy_density = f_chem + f_grad + f_el; - - assembler_lock.acquire(); - for (unsigned i = 0; i < c.size(); i++) - { - // For some reason, some of the values in this loop - if (c[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - this->energy_components[2] += f_el[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/run_num_1.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/run_num_1.txt deleted file mode 100644 index 1e67980cc..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/run_num_1.txt +++ /dev/null @@ -1 +0,0 @@ -run_004 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/run_num_2.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/run_num_2.txt deleted file mode 100644 index 66c5b2fa4..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/run_num_2.txt +++ /dev/null @@ -1 +0,0 @@ -run_005 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/run_spatial_ooa_test_2D.py b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/run_spatial_ooa_test_2D.py deleted file mode 100644 index c242d8fa3..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/run_spatial_ooa_test_2D.py +++ /dev/null @@ -1,98 +0,0 @@ -import subprocess -import shutil -import glob -import math -import os.path - -# ---------------------------------------------------------------------------------------- -# Function that generates a header file for the simulation, compiles the PRISMS-PF code -# and runs the executable. -# ---------------------------------------------------------------------------------------- -def run_simulation(refineFactor,run_name): - - subdivisionsX = 1 - subdivisionsY = 1 - subdivisionsZ = 1 - finiteElementDegree = 1 - - text_file = open("space_parameters.h","w") - text_file.write("// Parameters list for the parameters involved in mesh generation \n") - text_file.write("#define subdivisionsX " + str(subdivisionsX) + "\n") - text_file.write("#define subdivisionsY " + str(subdivisionsY) + "\n") - text_file.write("#define subdivisionsZ " + str(subdivisionsZ) + "\n") - text_file.write("#define refineFactor " + str(refineFactor) + "\n") - text_file.write("#define finiteElementDegree " + str(finiteElementDegree) + "\n") - text_file.close() - - subprocess.call(["make", "release"]) - #subprocess.call(["./main"]) - subprocess.call(["mpirun", "-n", "4", "main"]) - - subprocess.call(["mkdir",run_name]) - for output_files in glob.glob('*vtu'): - shutil.move(output_files,run_name) - -# ---------------------------------------------------------------------------------------- -# Function that calculates the maximum error between a run and a reference result. -# ---------------------------------------------------------------------------------------- -def getError(run_num): - - text_file = open("run_num_1.txt","w") - text_file.write('run_00'+str(run_num)) - text_file.close() - subprocess.call(["visit", "-cli","-s","getError.py"]) - f = open('error.txt','r') - error = float(f.read()) - f.close() - - return error - -# ---------------------------------------------------------------------------------------- - -# If files exist from previous tests, delete them -if os.path.exists("run_001") == True: - shutil.rmtree("run_001") -if os.path.exists("run_002") == True: - shutil.rmtree("run_002") -if os.path.exists("run_003") == True: - shutil.rmtree("run_003") -if os.path.exists("run_004") == True: - shutil.rmtree("run_004") -if os.path.exists("run_005") == True: - shutil.rmtree("run_005") - -# Run simulations with a decreasing time step (and an corresponding increase in number of iterations) -run_simulation(4,'run_001') -run_simulation(5,'run_002') -run_simulation(6,'run_003') -run_simulation(7,'run_004') -run_simulation(8,'run_005') - -# Find the error for runs 1-4 (as compared to run 5) -text_file = open("run_num_2.txt","w") -text_file.write('run_005') -text_file.close() - -error = [] -error.append(getError(1)) -error.append(getError(2)) -error.append(getError(3)) -error.append(getError(4)) - -# Calculate and output order of accuracy -ooa_1_to_2 = math.log10(error[0]/error[1])/math.log10(2) -ooa_2_to_3 = math.log10(error[1]/error[2])/math.log10(2) -ooa_3_to_4 = math.log10(error[2]/error[3])/math.log10(2) - -print "Order of accuracy results: \n" -print "Mesh refinement of 4 to mesh refinement of 5:", str(ooa_1_to_2), "\n" -print "Mesh refinement of 5 to mesh refinement of 6:", str(ooa_2_to_3), "\n" -print "Mesh refinement of 6 to mesh refinement of 7:", str(ooa_3_to_4), "\n" - -text_file = open("spat_ooa_results.txt","w") -text_file.write("Results of 2D spatial order of accuracy test: \n") -text_file.write("From coarse mesh to medium mesh: " + str(ooa_1_to_2) + "\n") -text_file.write("From from medium mesh to fine mesh: " + str(ooa_2_to_3) + "\n") -text_file.write("From from fine mesh to very fine mesh: " + str(ooa_3_to_4) + "\n") -text_file.close() - diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/space_parameters.h b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/space_parameters.h deleted file mode 100644 index 989383580..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/space_parameters.h +++ /dev/null @@ -1,6 +0,0 @@ -// Parameters list for the parameters involved in mesh generation -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 8 -#define finiteElementDegree 1 diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/spat_ooa_results.txt b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/spat_ooa_results.txt deleted file mode 100644 index 503ef2981..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/spat_ooa_results.txt +++ /dev/null @@ -1,4 +0,0 @@ -Results of 2D spatial order of accuracy test: -From coarse mesh to medium mesh: 1.914655385 -From from medium mesh to fine mesh: 2.0491712881 -From from fine mesh to very fine mesh: 2.30283753388 diff --git a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/visitlog.py b/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/visitlog.py deleted file mode 100644 index 6acc211fe..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/spatial_ooa_test_2D/visitlog.py +++ /dev/null @@ -1,57 +0,0 @@ -# Visit 2.7.0 log file -ScriptVersion = "2.7.0" -if ScriptVersion != Version(): - print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version()) -ShowAllWindows() -OpenDatabase("run_004/solution-10000.pvtu", 0) -# The UpdateDBPluginInfo RPC is not supported in the VisIt module so it will not be logged. -DefineScalarExpression("diff", "(c-pos_cmfe(, mesh,0))") -AddPlot("Pseudocolor", "diff", 1, 1) -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.scaling = PseudocolorAtts.Linear # Linear, Log, Skew -PseudocolorAtts.skewFactor = 1 -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot -PseudocolorAtts.minFlag = 0 -PseudocolorAtts.min = 0 -PseudocolorAtts.maxFlag = 0 -PseudocolorAtts.max = 1 -PseudocolorAtts.centering = PseudocolorAtts.Natural # Natural, Nodal, Zonal -PseudocolorAtts.colorTableName = "hot" -PseudocolorAtts.invertColorTable = 0 -PseudocolorAtts.opacityType = PseudocolorAtts.FullyOpaque # ColorTable, FullyOpaque, Constant, Ramp, VariableRange -PseudocolorAtts.opacityVariable = "" -PseudocolorAtts.opacity = 1 -PseudocolorAtts.opacityVarMin = 0 -PseudocolorAtts.opacityVarMax = 1 -PseudocolorAtts.opacityVarMinFlag = 0 -PseudocolorAtts.opacityVarMaxFlag = 0 -PseudocolorAtts.pointSize = 0.05 -PseudocolorAtts.pointType = PseudocolorAtts.Point # Box, Axis, Icosahedron, Octahedron, Tetrahedron, SphereGeometry, Point, Sphere -PseudocolorAtts.pointSizeVarEnabled = 0 -PseudocolorAtts.pointSizeVar = "default" -PseudocolorAtts.pointSizePixels = 2 -PseudocolorAtts.lineType = PseudocolorAtts.Line # Line, Tube, Ribbon -PseudocolorAtts.lineStyle = PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH -PseudocolorAtts.lineWidth = 0 -PseudocolorAtts.tubeDisplayDensity = 10 -PseudocolorAtts.tubeRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.tubeRadiusAbsolute = 0.125 -PseudocolorAtts.tubeRadiusBBox = 0.005 -PseudocolorAtts.varyTubeRadius = 0 -PseudocolorAtts.varyTubeRadiusVariable = "" -PseudocolorAtts.varyTubeRadiusFactor = 10 -PseudocolorAtts.endPointType = PseudocolorAtts.None # None, Tails, Heads, Both -PseudocolorAtts.endPointStyle = PseudocolorAtts.Spheres # Spheres, Cones -PseudocolorAtts.endPointRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.endPointRadiusAbsolute = 1 -PseudocolorAtts.endPointRadiusBBox = 0.005 -PseudocolorAtts.endPointRatio = 2 -PseudocolorAtts.renderSurfaces = 1 -PseudocolorAtts.renderWireframe = 0 -PseudocolorAtts.renderPoints = 0 -PseudocolorAtts.smoothingLevel = 0 -PseudocolorAtts.legendFlag = 1 -PseudocolorAtts.lightingFlag = 1 -SetPlotOptions(PseudocolorAtts) -DrawPlots() -Query("MinMax", use_actual_data=1) diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/CMakeLists.txt b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/CMakeLists.txt deleted file mode 100644 index 0444f179d..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/ICs_and_BCs.h b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/ICs_and_BCs.h deleted file mode 100644 index 7129dffae..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/ICs_and_BCs.h +++ /dev/null @@ -1,187 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - -#define x_denom 1.0 -#define y_denom 1.0 -#define z_denom 1.0 -#define initial_interface_coeff 1.0 -#define initial_radius 7.0 -#define avg_Nd 0.004 - - if (index == 0) - { - // return the value of the initial concentration field at point p - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; - // return 0.02 + 1.0e-3*(2*(0.5 - (double)(std::rand() % 100 )/100.0)); -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (0.12 - 0.00) * (1 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#elif problemDIM == 3 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#endif - } - else if (index == 1) - { - // set result equal to the structural order paramter initial condition - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (1.0 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - -#elif problemDIM == 3 - // r=p.distance(Point(spanX/2.0,spanY/2.0,spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r-spanX/8.0)/(3*dx))); - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - - // planar interface - // r=sqrt((p.operator()(2)-spanZ/2.0)*(p.operator()(2)-spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r)/(initial_interface_coeff))); - // return - // 0.5*(1.0-std::tanh((r-initial_radius)/(initial_interface_coeff))); -#endif - return 0.0; - } - else if (index == 2) - { - scalar_IC = 0.0; - } - else if (index == 3) - { - scalar_IC = 0.0; - } - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - if (index == 4) - { - vector_IC(0) = 0.0; - vector_IC(1) = 0.0; - if (dim == 3) - { - vector_IC(2) = 0.0; - } - } - // ===================================================================== - } -}; - -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") - // Fourth input: BC value (ignored unless the BC type is "DIRICHLET") - // Odd inputs after the third: BC type - // Even inputs after the third: BC value - // Face numbering: starts at zero with the minimum of the first direction, one - // for the maximum of the first direction - // two for the minimum of the second direction, etc. - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(1, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(2, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(3, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(4, 0, "DIRICHLET", 0.0); - inputBCs(4, 1, "DIRICHLET", 0.0); - if (dim == 3) - { - inputBCs(4, 2, "DIRICHLET", 0.0); - } - - // ===================================================================== -} diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/error1.txt b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/error1.txt deleted file mode 100644 index e71583817..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/error1.txt +++ /dev/null @@ -1 +0,0 @@ -1.26510858537e-05 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/error2.txt b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/error2.txt deleted file mode 100644 index 33c21f292..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/error2.txt +++ /dev/null @@ -1 +0,0 @@ -5.89340925226e-06 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/error3.txt b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/error3.txt deleted file mode 100644 index 61364fb43..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/error3.txt +++ /dev/null @@ -1 +0,0 @@ -2.52574682245e-06 \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/getError1.py b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/getError1.py deleted file mode 100644 index 200a15971..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/getError1.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "100" -output_num_2 = "01600" - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = True - -directory_1 = "run_001/solution-"+output_num_1+".pvtu" -directory_2 = "run_004/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("error1.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/getError2.py b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/getError2.py deleted file mode 100644 index 7f2b51d99..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/getError2.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "0200" -output_num_2 = "01600" - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = True - -directory_1 = "run_002/solution-"+output_num_1+".pvtu" -directory_2 = "run_004/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("error2.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/getError3.py b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/getError3.py deleted file mode 100644 index 346ef5131..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/getError3.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "0400" -output_num_2 = "01600" - -use_mesh_1 = True -apply_3slice = False -apply_box_crop = True - -directory_1 = "run_003/solution-"+output_num_1+".pvtu" -directory_2 = "run_004/solution-"+output_num_2+".pvtu" - -if use_mesh_1 == True: - OpenDatabase(directory_1) - DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") -else: - OpenDatabase(directory_2) - DefineScalarExpression("diff","("+variable_2+"-pos_cmfe(<"+directory_1+":"+variable_1+">, mesh,0))") - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - -if apply_box_crop == True: - AddOperator("Box", 1) - BoxAtts = BoxAttributes() - BoxAtts.amount = BoxAtts.Some # Some, All - BoxAtts.minx = 2.0 - BoxAtts.maxx = 30.0 - BoxAtts.miny = 2.0 - BoxAtts.maxy = 30.0 - BoxAtts.minz = 2.0 - BoxAtts.maxz = 30.0 - BoxAtts.inverse = 0 - SetOperatorOptions(BoxAtts, 1) - -if apply_3slice == True: - AddOperator("ThreeSlice") - slice_atts = ThreeSliceAttributes() - slice_atts.x = 16 - slice_atts.y = 16 - slice_atts.z = 16 - SetOperatorOptions(slice_atts) - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("error3.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/main.cc b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/main.cc deleted file mode 100644 index 0a10676c0..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/main.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" -#include "time_parameters.h" - -#include "../../../src/models/coupled/generalized_model.h" -#include "../../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/parameters.h b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/parameters.h deleted file mode 100644 index b2bc46490..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/parameters.h +++ /dev/null @@ -1,104 +0,0 @@ -// Parameter list for the precipitate evolution example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 3 - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 32.0 -#define spanY 32.0 -#define spanZ 32.0 - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 4 - -// Set the polynomial degree of the element (suggested values: 1 or 2) -#define finiteElementDegree 1 - -// ================================================================================= -// Set the adaptive mesh refinement parameters -// ================================================================================= -// Set the flag determining if adaptive meshing is activated -#define hAdaptivity false - -// Set the maximum and minimum level of refinement -#define maxRefinementLevel (refineFactor) -#define minRefinementLevel (refineFactor - 2) - -// Set the fields used to determine the refinement. Fields determined by the -// order declared in "equations.h", starting at zero -#define refineCriterionFields \ - { \ - 1, 2, 3 \ - } - -// Set the maximum and minimum value of the fields where the mesh should be -// refined -#define refineWindowMax \ - { \ - 0.99, 0.99, 0.99 \ - } -#define refineWindowMin \ - { \ - 0.01, 0.01, 0.01 \ - } - -// Set the number of time steps between remeshing operations -#define skipRemeshingSteps 1000 - -// ================================================================================= -// Set the time step parameters -// ================================================================================= -// The size of the time step -// #define timeStep 9.0e-6 -// #define timeFinal 100000000 -// #define timeIncrements 10000 - -// ================================================================================= -// Set the elliptic solver parameters -// ================================================================================= -// The solver type (currently the only recommended option is conjugate gradient) -#define solverType SolverCG - -// The flag that determines whether the tolerance for solver convergence should -// be an absolute tolerance (absTol=true) or a relative tolerance (absTol=false) -#define absTol true - -// The tolerance for convergence (L2 norm of the residual) -#define solverTolerance 1.0e-4 - -// The maximum number of solver iterations per time step -#define maxSolverIterations 1000 - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 1 - -// ================================================================================= -// Set the flag determining if the total free energy is calculated for each -// output -// ================================================================================= -#define calcEnergy false diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/residuals.h b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/residuals.h deleted file mode 100644 index 3c8190016..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/residuals.h +++ /dev/null @@ -1,682 +0,0 @@ -// List of variables and residual equations for the Precipitate Evolution -// example application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 5 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "c", "n1", "n2", "n3", "u" \ - } -#define variable_type \ - { \ - "SCALAR", "SCALAR", "SCALAR", "SCALAR", "VECTOR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC", "PARABOLIC", "PARABOLIC", "PARABOLIC", "ELLIPTIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - true, true, true, true, false \ - } -#define need_grad \ - { \ - true, true, true, true, true \ - } -#define need_hess \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - true, true, true, true, false \ - } -#define need_grad_residual \ - { \ - true, true, true, true, true \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqn for the left-hand-side of the iterative solver for elliptic equations -#define need_val_LHS \ - { \ - false, true, true, true, false \ - } -#define need_grad_LHS \ - { \ - false, false, false, false, true \ - } -#define need_hess_LHS \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation for the left-hand-side of the -// iterative solver for elliptic equations has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual_LHS \ - { \ - false, false, false, false, false \ - } -#define need_grad_residual_LHS \ - { \ - false, false, false, false, true \ - } - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Cahn-Hilliard mobility -#define McV 1.0 - -// Allen-Cahn mobilities -#define Mn1V 50.0 -#define Mn2V 50.0 -#define Mn3V 50.0 - -// Gradient energy coefficients -double Kn1[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn2[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn3[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; - -// define energy barrier coefficient (used to tune the interfacial energy) -#define W -1.0 - -// Define mechanical properties -#define n_dependent_stiffness false -// Mechanical symmetry of the material and stiffness parameters -// If n_dependent_stiffness == false the first entry is used for all phases -#define MaterialModels \ - { \ - { \ - "ISOTROPIC" \ - } \ - } -#define MaterialConstants \ - { \ - { \ - 1.0, 0.3 \ - } \ - } - -// Stress-free transformation strains -// Linear fits for the stress-free transformation strains in for sfts = -// sfts_linear * c + sfts_const -double sfts_linear1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -// Free energy expressions -#define faV (24.7939 * c * c - 1.6752 * c - 1.9453e-06) -#define facV (49.5878 * c - 1.6752) -#define faccV (49.5878) -#define fbV (37.9316 * c * c - 10.7373 * c + 0.5401) -#define fbcV (75.8633 * c - 10.7373) -#define fbccV (75.8633) -#define h1V (3.0 * n1 * n1 - 2.0 * n1 * n1 * n1) -#define h2V (3.0 * n2 * n2 - 2.0 * n2 * n2 * n2) -#define h3V (3.0 * n3 * n3 - 2.0 * n3 * n3 * n3) -#define hn1V (6.0 * n1 - 6.0 * n1 * n1) -#define hn2V (6.0 * n2 - 6.0 * n2 * n2) -#define hn3V (6.0 * n3 - 6.0 * n3 * n3) - -// This double-well function can be used to tune the interfacial energy -#define fbarrierV (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1) -#define fbarriernV (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1) - -// Residuals -#define rcV (c) -#define rcxTemp \ - (cx * ((1.0 - h1V - h2V - h3V) * faccV + (h1V + h2V + h3V) * fbccV) + \ - n1x * ((fbcV - facV) * hn1V) + n2x * ((fbcV - facV) * hn2V) + \ - n3x * ((fbcV - facV) * hn3V)) -#define rcxV (constV(-timeStep * McV) * rcxTemp) - -#define rn1V \ - (n1 - constV(timeStep * Mn1V) * \ - ((fbV - faV) * hn1V + W * fbarriernV + nDependentMisfitAC1)) -#define rn2V (n2 - constV(timeStep * Mn2V) * ((fbV - faV) * hn2V)) -#define rn3V (n3 - constV(timeStep * Mn3V) * ((fbV - faV) * hn3V)) -#define rn1xV (constV(-timeStep * Mn1V) * Knx1) -#define rn2xV (constV(-timeStep * Mn2V) * Knx2) -#define rn3xV (constV(-timeStep * Mn3V) * Knx3) - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // The concentration and its derivatives (names here should match those in the - // macros above) - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - // The first order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n1 = modelVariablesList[1].scalarValue; - scalargradType n1x = modelVariablesList[1].scalarGrad; - - // The second order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n2 = modelVariablesList[2].scalarValue; - scalargradType n2x = modelVariablesList[2].scalarGrad; - - // The third order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n3 = modelVariablesList[3].scalarValue; - scalargradType n3x = modelVariablesList[3].scalarGrad; - - // The derivative of the displacement vector (names here should match those in - // the macros above) - vectorgradType ux = modelVariablesList[4].vectorGrad; - vectorgradType ruxV; - - vectorhessType uxx; - - if (c_dependent_misfit == true) - { - uxx = modelVariablesList[4].vectorHess; - } - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - // Fill residual corresponding to mechanics - // R=-C*(E-E0) - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - ruxV[i][j] = -S[i][j]; - } - } - - // Compute one of the stress terms in the order parameter chemical potential, - // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - nDependentMisfitAC1 += S[i][j] * (sfts1[i][j]); - nDependentMisfitAC2 += S[i][j] * (sfts2[i][j]); - nDependentMisfitAC3 += S[i][j] * (sfts3[i][j]); - } - } - - nDependentMisfitAC1 *= -hn1V; - nDependentMisfitAC2 *= -hn2V; - nDependentMisfitAC3 *= -hn3V; - - // Compute the other stress term in the order parameter chemical potential, - // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray heterMechAC2 = constV(0.0); - dealii::VectorizedArray heterMechAC3 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; - - if (n_dependent_stiffness == true) - { - // computeStress(CIJ_diff, E2, S2); - computeStress(CIJ_list[1] - CIJ_list[0], E2, S2); - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - heterMechAC1 += S2[i][j] * E2[i][j]; - } - } - // Aside from HnpV, heterMechAC1, heterMechAC2, and heterMechAC3 are equal - heterMechAC2 = 0.5 * hn2V * heterMechAC1; - heterMechAC3 = 0.5 * hn3V * heterMechAC1; - - heterMechAC1 = 0.5 * hn1V * heterMechAC1; - } - - // compute the stress term in the gradient of the concentration chemical - // potential, grad_mu_el = [C*(E-E0)*E0c]x, must be a vector with length dim - scalargradType grad_mu_el; - - if (c_dependent_misfit == true) - { - dealii::VectorizedArray E3[dim][dim], S3[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E3[i][j] = -(sfts1c[i][j] * h1V + sfts2c[i][j] * h2V + sfts3c[i][j] * h3V); - } - } - - if (n_dependent_stiffness == true) - { - computeStress(CIJ_combined, E3, S3); - } - else - { - computeStress(CIJ_list[0], E3, S3); - } - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - grad_mu_el[k] += - S3[i][j] * - (constV(0.5) * (uxx[i][j][k] + uxx[j][i][k]) + E3[i][j] * cx[k] - - (sfts1[i][j] * hn1V * n1x[k] + sfts2[i][j] * hn2V * n2x[k] + - sfts3[i][j] * hn3V * n3x[k])); - - grad_mu_el[k] += - -S[i][j] * - (sfts1c[i][j] * hn1V * n1x[k] + sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k] + - (sfts1cc[i][j] * h1V + sfts2cc[i][j] * h2V + sfts3cc[i][j] * h3V) * - cx[k]); - - if (n_dependent_stiffness == true) - { - grad_mu_el[k] += -S2[i][j] * (sfts1c[i][j] * hn1V * n1x[k] + - sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k]); - } - } - } - } - } - - // compute K*nx - scalargradType Knx1, Knx2, Knx3; - for (unsigned int a = 0; a < dim; a++) - { - Knx1[a] = 0.0; - Knx2[a] = 0.0; - Knx3[a] = 0.0; - for (unsigned int b = 0; b < dim; b++) - { - Knx1[a] += constV(Kn1[a][b]) * n1x[b]; - Knx2[a] += constV(Kn2[a][b]) * n2x[b]; - Knx3[a] += constV(Kn3[a][b]) * n3x[b]; - } - } - - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; - - modelResidualsList[1].scalarValueResidual = rn1V; - modelResidualsList[1].scalarGradResidual = rn1xV; - - modelResidualsList[2].scalarValueResidual = rn2V; - modelResidualsList[2].scalarGradResidual = rn2xV; - - modelResidualsList[3].scalarValueResidual = rn3V; - modelResidualsList[3].scalarGradResidual = rn3xV; - - modelResidualsList[4].vectorGradResidual = ruxV; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVariablesList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // n1 - scalarvalueType n1 = modelVariablesList[0].scalarValue; - - // n2 - scalarvalueType n2 = modelVariablesList[1].scalarValue; - - // n3 - scalarvalueType n3 = modelVariablesList[2].scalarValue; - - // u - vectorgradType ux = modelVariablesList[3].vectorGrad; - vectorgradType ruxV; - - // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the - // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; - E = symmetrize(ux); - - // Compute stress tensor (which is equal to the residual, Rux) - if (n_dependent_stiffness == true) - { - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; - CIJ_combined = - CIJ_list[0] * (constV(1.0) - h1V - h2V - h3V) + CIJ_list[1] * (h1V + h2V + h3V); - - computeStress(CIJ_combined, E, ruxV); - } - else - { - computeStress(CIJ_list[0], E, ruxV); - } - - modelRes.vectorGradResidual = ruxV; -} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - scalarvalueType total_energy_density = constV(0.0); - - // c - scalarvalueType c = modelVarList[0].scalarValue; - scalargradType cx = modelVarList[0].scalarGrad; - - // n1 - scalarvalueType n1 = modelVarList[1].scalarValue; - scalargradType n1x = modelVarList[1].scalarGrad; - - // n2 - scalarvalueType n2 = modelVarList[2].scalarValue; - scalargradType n2x = modelVarList[2].scalarGrad; - - // n3 - scalarvalueType n3 = modelVarList[3].scalarValue; - scalargradType n3x = modelVarList[3].scalarGrad; - - // u - vectorgradType ux = modelVarList[4].vectorGrad; - - scalarvalueType f_chem = - (constV(1.0) - (h1V + h2V + h3V)) * faV + (h1V + h2V + h3V) * fbV; - - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn1[i][j]) * n1x[i] * n1x[j]; - } - } -#if num_sop > 1 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn2[i][j]) * n2x[i] * n2x[j]; - } - } -#endif -#if num_sop > 2 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn3[i][j]) * n3x[i] * n3x[j]; - } - } -#endif - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // E2[i][j]= constV(0.5)*(ux[i][j]+ux[j][i])-( sfts1[i][j]*h1V + - // sfts2[i][j]*h2V + sfts3[i][j]*h3V); - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[2 * dim - 1 + dim / 3] - [2 * dim - 1 + dim / 3]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - scalarvalueType f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E2[i][j]; - } - } - - total_energy_density = f_chem + f_grad + f_el; - - assembler_lock.acquire(); - for (unsigned i = 0; i < c.size(); i++) - { - // For some reason, some of the values in this loop - if (c[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - this->energy_components[2] += f_el[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/run_time_ooa_test.py b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/run_time_ooa_test.py deleted file mode 100644 index 1b0a5df69..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/run_time_ooa_test.py +++ /dev/null @@ -1,81 +0,0 @@ -import subprocess -import shutil -import glob -import math -import os.path - -# ---------------------------------------------------------------------------------------- -# Function that generates a header file for the simulation, compiles the PRISMS-PF code -# and runs the executable. -# ---------------------------------------------------------------------------------------- -def run_simulation(factor,run_name): - - timeIncrements = int(100*factor) - timeFinal = 100000000 - skipImplicitSolves = 10000000 - timeStep = 1.5e-4/factor - - text_file = open("time_parameters.h","w") - text_file.write("// Parameters list for the parameters involved in time stepping \n") - text_file.write("#define timeStep " + str(timeStep) + "\n") - text_file.write("#define timeIncrements " + str(timeIncrements) + "\n") - text_file.write("#define timeFinal " + str(timeFinal) + "\n") - text_file.write("#define skipImplicitSolves " + str(skipImplicitSolves) + "\n") - text_file.close() - - subprocess.call(["make", "release"]) - subprocess.call(["./main"]) - - subprocess.call(["mkdir",run_name]) - for output_files in glob.glob('*vtu'): - shutil.move(output_files,run_name) - -# ---------------------------------------------------------------------------------------- - -# If files exist from previous tests, delete them -if os.path.exists("run_001") == True: - shutil.rmtree("run_001") -if os.path.exists("run_002") == True: - shutil.rmtree("run_002") -if os.path.exists("run_003") == True: - shutil.rmtree("run_003") -if os.path.exists("run_004") == True: - shutil.rmtree("run_004") - -# Run simulations with a decreasing time step (and an corresponding increase in number of iterations) -run_simulation(1.0,'run_001') -run_simulation(2.0,'run_002') -run_simulation(4.0,'run_003') -run_simulation(16.0,'run_004') - -# Find the error for runs 1-3 (as compared to run 4) -subprocess.call(["visit", "-cli","-s","getError1.py"]) -subprocess.call(["visit", "-cli","-s","getError2.py"]) -subprocess.call(["visit", "-cli","-s","getError3.py"]) - -f = open('error1.txt','r') -error1 = float(f.read()) -f.close() - -f = open('error2.txt','r') -error2 = float(f.read()) -f.close() - -f = open('error3.txt','r') -error3 = float(f.read()) -f.close() - -# Calculate and output order of accuracy -ooa_1_to_2 = math.log10(error1/error2)/math.log10(2) -ooa_2_to_3 = math.log10(error2/error3)/math.log10(2) - -print "Order of accuracy results: \n" -print "Time step 1 to time step 2:", str(ooa_1_to_2), "\n" -print "Time step 2 to time step 3:", str(ooa_2_to_3), "\n" - -text_file = open("time_ooa_results.txt","w") -text_file.write("Results of standard temporal order of accuracy test: \n") -text_file.write("From time step 1 to time step 2: " + str(ooa_1_to_2) + "\n") -text_file.write("From time step 2 to time step 3: " + str(ooa_2_to_3) + "\n") -text_file.close() - diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/time_ooa_results.txt b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/time_ooa_results.txt deleted file mode 100644 index 6866d9f46..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/time_ooa_results.txt +++ /dev/null @@ -1,3 +0,0 @@ -Results of standard temporal order of accuracy test: -From time step 1 to time step 2: 1.10208685907 -From time step 2 to time step 3: 1.22239242131 diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/time_parameters.h b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/time_parameters.h deleted file mode 100644 index c9408f5ec..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/time_parameters.h +++ /dev/null @@ -1,5 +0,0 @@ -// Parameters list for the parameters involved in time stepping -#define timeStep 9.375e-06 -#define timeIncrements 1600 -#define timeFinal 100000000 -#define skipImplicitSolves 10000000 diff --git a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/visitlog.py b/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/visitlog.py deleted file mode 100644 index 48c73e18f..000000000 --- a/tests/deprecated_tests/order_of_accuracy_tests/time_ooa_test/visitlog.py +++ /dev/null @@ -1,70 +0,0 @@ -# Visit 2.7.3 log file -ScriptVersion = "2.7.3" -if ScriptVersion != Version(): - print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version()) -ShowAllWindows() -OpenDatabase("run_003/solution-0400.pvtu", 0) -# The UpdateDBPluginInfo RPC is not supported in the VisIt module so it will not be logged. -DefineScalarExpression("diff", "(c-pos_cmfe(, mesh,0))") -AddPlot("Pseudocolor", "diff", 1, 1) -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.scaling = PseudocolorAtts.Linear # Linear, Log, Skew -PseudocolorAtts.skewFactor = 1 -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot -PseudocolorAtts.minFlag = 0 -PseudocolorAtts.min = 0 -PseudocolorAtts.maxFlag = 0 -PseudocolorAtts.max = 1 -PseudocolorAtts.centering = PseudocolorAtts.Natural # Natural, Nodal, Zonal -PseudocolorAtts.colorTableName = "hot" -PseudocolorAtts.invertColorTable = 0 -PseudocolorAtts.opacityType = PseudocolorAtts.FullyOpaque # ColorTable, FullyOpaque, Constant, Ramp, VariableRange -PseudocolorAtts.opacityVariable = "" -PseudocolorAtts.opacity = 1 -PseudocolorAtts.opacityVarMin = 0 -PseudocolorAtts.opacityVarMax = 1 -PseudocolorAtts.opacityVarMinFlag = 0 -PseudocolorAtts.opacityVarMaxFlag = 0 -PseudocolorAtts.pointSize = 0.05 -PseudocolorAtts.pointType = PseudocolorAtts.Point # Box, Axis, Icosahedron, Octahedron, Tetrahedron, SphereGeometry, Point, Sphere -PseudocolorAtts.pointSizeVarEnabled = 0 -PseudocolorAtts.pointSizeVar = "default" -PseudocolorAtts.pointSizePixels = 2 -PseudocolorAtts.lineType = PseudocolorAtts.Line # Line, Tube, Ribbon -PseudocolorAtts.lineStyle = PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH -PseudocolorAtts.lineWidth = 0 -PseudocolorAtts.tubeDisplayDensity = 10 -PseudocolorAtts.tubeRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.tubeRadiusAbsolute = 0.125 -PseudocolorAtts.tubeRadiusBBox = 0.005 -PseudocolorAtts.varyTubeRadius = 0 -PseudocolorAtts.varyTubeRadiusVariable = "" -PseudocolorAtts.varyTubeRadiusFactor = 10 -PseudocolorAtts.endPointType = PseudocolorAtts.None # None, Tails, Heads, Both -PseudocolorAtts.endPointStyle = PseudocolorAtts.Spheres # Spheres, Cones -PseudocolorAtts.endPointRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.endPointRadiusAbsolute = 1 -PseudocolorAtts.endPointRadiusBBox = 0.005 -PseudocolorAtts.endPointRatio = 2 -PseudocolorAtts.renderSurfaces = 1 -PseudocolorAtts.renderWireframe = 0 -PseudocolorAtts.renderPoints = 0 -PseudocolorAtts.smoothingLevel = 0 -PseudocolorAtts.legendFlag = 1 -PseudocolorAtts.lightingFlag = 1 -SetPlotOptions(PseudocolorAtts) -AddOperator("Box", 1) -SetActivePlots(0) -BoxAtts = BoxAttributes() -BoxAtts.amount = BoxAtts.Some # Some, All -BoxAtts.minx = 0 -BoxAtts.maxx = 1 -BoxAtts.miny = 0 -BoxAtts.maxy = 1 -BoxAtts.minz = 0 -BoxAtts.maxz = 1 -BoxAtts.inverse = 0 -SetOperatorOptions(BoxAtts, 1) -SetActivePlots(0) -DrawPlots() -Query("MinMax", use_actual_data=1) diff --git a/tests/deprecated_tests/regression_tests/CMakeLists.txt b/tests/deprecated_tests/regression_tests/CMakeLists.txt deleted file mode 100644 index d123735f7..000000000 --- a/tests/deprecated_tests/regression_tests/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -## -# CMake script for the phaseField applications: -## - - -# Set the name of the project and target: -SET(TARGET "main") - -# Declare all source files the target consists of: -SET(TARGET_SRC - ${TARGET}.cc - # You can specify additional files here! - ) - -# Usually, you will not need to modify anything beyond this point... - -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - -FIND_PACKAGE(deal.II 8.0 QUIET - HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) -IF(NOT ${deal.II_FOUND}) - MESSAGE(FATAL_ERROR "\n" - "*** Could not locate deal.II. ***\n\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" - "or set an environment variable \"DEAL_II_DIR\" that contains this path." - ) -ENDIF() - - -DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(${TARGET}) -DEAL_II_INVOKE_AUTOPILOT() diff --git a/tests/deprecated_tests/regression_tests/ICs_and_BCs.h b/tests/deprecated_tests/regression_tests/ICs_and_BCs.h deleted file mode 100644 index bd64a6f31..000000000 --- a/tests/deprecated_tests/regression_tests/ICs_and_BCs.h +++ /dev/null @@ -1,188 +0,0 @@ -// initial condition -template -class InitialCondition : public Function -{ -public: - unsigned int index; - Vector values; - - InitialCondition(const unsigned int _index) - : Function(1) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - double - value(const Point &p, const unsigned int component = 0) const - { - double scalar_IC = 0; - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR SCALAR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - -#define x_denom 1.0 -#define y_denom 1.0 -#define z_denom 1.0 -#define initial_interface_coeff 1.0 -#define initial_radius 6.0 -#define avg_Nd 0.004 -#define c_matrix 0.004 - - if (index == 0) - { - // return the value of the initial concentration field at point p - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; - // return 0.02 + 1.0e-3*(2*(0.5 - (double)(std::rand() % 100 )/100.0)); -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (0.12 - 0.00) * (1 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#elif problemDIM == 3 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (0.12 - avg_Nd) * - (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))) + - avg_Nd; - -#endif - } - else if (index == 1) - { - // set result equal to the structural order paramter initial condition - double dx = spanX / ((double) subdivisionsX) / std::pow(2.0, refineFactor); - double dy = spanY / ((double) subdivisionsY) / std::pow(2.0, refineFactor); - double dz = spanZ / ((double) subdivisionsZ) / std::pow(2.0, refineFactor); - double r = 0.0; -#if problemDIM == 1 - r = p.operator()(0); - return 0.5 * (1.0 - std::tanh((r - spanX / 16.0) / (0.1 * dx))); -#elif problemDIM == 2 - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - -#elif problemDIM == 3 - // r=p.distance(Point(spanX/2.0,spanY/2.0,spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r-spanX/8.0)/(3*dx))); - - r = sqrt((p.operator()(0)) * (p.operator()(0)) / x_denom + - (p.operator()(1)) * (p.operator()(1)) / y_denom + - (p.operator()(2)) * (p.operator()(2)) / z_denom); - return 0.5 * (1.0 - std::tanh((r - initial_radius) / (initial_interface_coeff))); - - // planar interface - // r=sqrt((p.operator()(2)-spanZ/2.0)*(p.operator()(2)-spanZ/2.0)); - // return 0.5*(1.0-std::tanh((r)/(initial_interface_coeff))); - // return - // 0.5*(1.0-std::tanh((r-initial_radius)/(initial_interface_coeff))); -#endif - return 0.0; - } - else if (index == 2) - { - scalar_IC = 0.0; - } - else if (index == 3) - { - scalar_IC = 0.0; - } - - // ===================================================================== - return scalar_IC; - } -}; - -// initial condition -template -class InitialConditionVec : public Function -{ -public: - unsigned int index; - - // Vector values; - InitialConditionVec(const unsigned int _index) - : Function(dim) - , index(_index) - { - std::srand(Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) + 1); - } - - void - vector_value(const Point &p, Vector &vector_IC) const - { - // ===================================================================== - // ENTER THE INITIAL CONDITIONS HERE FOR VECTOR FIELDS - // ===================================================================== - // Enter the function describing conditions for the fields at point "p". - // Use "if" statements to set the initial condition for each variable - // according to its variable index. - - if (index == 4) - { - vector_IC(0) = 0.0; - vector_IC(1) = 0.0; - if (dim == 3) - { - vector_IC(2) = 0.0; - } - } - // ===================================================================== - } -}; - -template -void -generalizedProblem::setBCs() -{ - // ===================================================================== - // ENTER THE BOUNDARY CONDITIONS HERE - // ===================================================================== - // This function sets the BCs for the problem variables - // The function "inputBCs" should be called for each component of - // each variable and should be in numerical order. Four input arguments - // set the same BC on the entire boundary. Two plus two times the - // number of dimensions inputs sets separate BCs on each face of the domain. - // Inputs to "inputBCs": - // First input: variable number - // Second input: component number - // Third input: BC type (options are "ZERO_DERIVATIVE" and "DIRICHLET") - // Fourth input: BC value (ignored unless the BC type is "DIRICHLET") - // Odd inputs after the third: BC type - // Even inputs after the third: BC value - // Face numbering: starts at zero with the minimum of the first direction, one - // for the maximum of the first direction - // two for the minimum of the second direction, etc. - inputBCs(0, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(1, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(2, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(3, 0, "ZERO_DERIVATIVE", 0); - - inputBCs(4, 0, "DIRICHLET", 0.0); - inputBCs(4, 1, "DIRICHLET", 0.0); - if (dim == 3) - { - inputBCs(4, 2, "DIRICHLET", 0.0); - } - - // ===================================================================== -} diff --git a/tests/deprecated_tests/regression_tests/error.txt b/tests/deprecated_tests/regression_tests/error.txt deleted file mode 100644 index c8ea45f44..000000000 --- a/tests/deprecated_tests/regression_tests/error.txt +++ /dev/null @@ -1 +0,0 @@ -3.46944695195e-17 \ No newline at end of file diff --git a/tests/deprecated_tests/regression_tests/getError.py b/tests/deprecated_tests/regression_tests/getError.py deleted file mode 100644 index f3f2694f8..000000000 --- a/tests/deprecated_tests/regression_tests/getError.py +++ /dev/null @@ -1,35 +0,0 @@ -import sys - -variable_1 = 'c' -variable_2 = 'c' - -output_num_1 = "1000" -output_num_2 = "1000" - -directory_1 = "reference_solution/solution-"+output_num_1+".pvtu" -directory_2 = "run_001/solution-"+output_num_2+".pvtu" - - -OpenDatabase(directory_1) -DefineScalarExpression("diff","("+variable_1+"-pos_cmfe(<"+directory_2+":"+variable_2+">, mesh,0))") - - -#AddPlot("Contour","diff") -AddPlot("Pseudocolor","diff") - -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot -SetPlotOptions(PseudocolorAtts) - - -DrawPlots() - -Query("MinMax", use_actual_data=1) -min_max_val = GetQueryOutputValue() -error = max(abs(min_max_val[0]),abs(min_max_val[1])) - -text_file = open("error.txt","w") -text_file.write(str(error)) -text_file.close() - -sys.exit() \ No newline at end of file diff --git a/tests/deprecated_tests/regression_tests/main.cc b/tests/deprecated_tests/regression_tests/main.cc deleted file mode 100644 index f9c3859e2..000000000 --- a/tests/deprecated_tests/regression_tests/main.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Coupled Cahn-Hilliard, Allen-Cahn and Mechanics problem -// general headers -#include "../../include/dealIIheaders.h" - -// Coupled Cahn-Hilliard+Allen-Cahn+Mechanics problem headers -#include "ICs_and_BCs.h" -#include "parameters.h" -#include "residuals.h" - -#include "../../src/models/coupled/generalized_model.h" -#include "../../src/models/coupled/generalized_model_functions.h" - -// main -int -main(int argc, char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, - argv, - numbers::invalid_unsigned_int); - try - { - deallog.depth_console(0); - generalizedProblem problem; - - problem.setBCs(); - problem.buildFields(); - problem.init(); - problem.solve(); - } - catch (std::exception &exc) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - catch (...) - { - std::cerr << std::endl - << std::endl - << "----------------------------------------------------" << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" << std::endl; - return 1; - } - - return 0; -} diff --git a/tests/deprecated_tests/regression_tests/parameters.h b/tests/deprecated_tests/regression_tests/parameters.h deleted file mode 100644 index 4c4eb5531..000000000 --- a/tests/deprecated_tests/regression_tests/parameters.h +++ /dev/null @@ -1,104 +0,0 @@ -// Parameter list for the precipitate evolution example application -// All strictly numerical parameters should be set in this file - -// ================================================================================= -// Set the number of dimensions (1, 2, or 3 for a 1D, 2D, or 3D calculation) -// ================================================================================= -#define problemDIM 3 - -// ================================================================================= -// Set the length of the domain in all three dimensions -// ================================================================================= -// Each axes spans from zero to the specified length -#define spanX 8.0 -#define spanY 8.0 -#define spanZ 8.0 - -// ================================================================================= -// Set the element parameters -// ================================================================================= -// The number of elements in each direction is 2^(refineFactor) * subdivisions -// For optimal performance, use refineFactor primarily to determine the element -// size -#define subdivisionsX 1 -#define subdivisionsY 1 -#define subdivisionsZ 1 -#define refineFactor 4 - -// Set the polynomial degree of the element (suggested values: 1 or 2) -#define finiteElementDegree 1 - -// ================================================================================= -// Set the adaptive mesh refinement parameters -// ================================================================================= -// Set the flag determining if adaptive meshing is activated -#define hAdaptivity false - -// Set the maximum and minimum level of refinement -#define maxRefinementLevel (refineFactor) -#define minRefinementLevel (refineFactor - 2) - -// Set the fields used to determine the refinement. Fields determined by the -// order declared in "equations.h", starting at zero -#define refineCriterionFields \ - { \ - 1, 2, 3 \ - } - -// Set the maximum and minimum value of the fields where the mesh should be -// refined -#define refineWindowMax \ - { \ - 0.99, 0.99, 0.99 \ - } -#define refineWindowMin \ - { \ - 0.01, 0.01, 0.01 \ - } - -// Set the number of time steps between remeshing operations -#define skipRemeshingSteps 1000 - -// ================================================================================= -// Set the time step parameters -// ================================================================================= -// The size of the time step -#define timeStep 6.0e-4 -#define timeIncrements 1000 -#define timeFinal 100000000 - -// ================================================================================= -// Set the elliptic solver parameters -// ================================================================================= -// The solver type (currently the only recommended option is conjugate gradient) -#define solverType SolverCG - -// The flag that determines whether the tolerance for solver convergence should -// be an absolute tolerance (absTol=true) or a relative tolerance (absTol=false) -#define absTol false - -// The tolerance for convergence (L2 norm of the residual) -#define solverTolerance 1.0e-8 - -// The maximum number of solver iterations per time step -#define maxSolverIterations 10000 - -// ================================================================================= -// Set the output parameters -// ================================================================================= -// Each field in the problem will be output is writeOutput is set to "true" -#define writeOutput true - -// Type of spacing between outputs ("EQUAL_SPACING", "LOG_SPACING", or -// "N_PER_DECADE") -#define outputCondition "EQUAL_SPACING" - -// Number of times the program outputs the fields (total number for -// "EQUAL_SPACING" and "LOG_SPACING", number per decade for "N_PER_DECADE") -#define numOutputs 1 - -// ================================================================================= -// Set the flag determining if the total free energy is calculated for each -// output -// ================================================================================= -#define calcEnergy false diff --git a/tests/deprecated_tests/regression_tests/regress_test_results.txt b/tests/deprecated_tests/regression_tests/regress_test_results.txt deleted file mode 100644 index 0e783f293..000000000 --- a/tests/deprecated_tests/regression_tests/regress_test_results.txt +++ /dev/null @@ -1,177 +0,0 @@ -Results of the 3D regression test (2016-01-18 14:35): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-01-20 09:44): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-01-20 09:47): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-01-20 10:54): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-01-22 15:38): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-02-10 15:51): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-03-08 11:29): -Difference from reference: 7.4505806108e-09 -Result: Fail - -Results of the 3D regression test (2016-03-08 11:31): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-03-08 11:42): -Difference from reference: 7.4505806108e-09 -Result: Fail - -Results of the 3D regression test (2016-03-08 11:43): - -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-03-22 14:28): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-04-04 08:05): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-04-04 08:21): -Difference from reference: 0.146397091448 -Result: Fail - -Results of the 3D regression test (2016-04-04 08:35): -Difference from reference: 0.146397091448 -Result: Fail - -Results of the 3D regression test (2016-04-04 08:37): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-04-12 11:39): -Difference from reference: 0.146397091448 -Result: Fail - -Results of the 3D regression test (2016-04-12 11:40): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-04-12 14:20): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-04-15 10:17): -Difference from reference: 0.146397091448 -Result: Fail - -Results of the 3D regression test (2016-04-15 10:19): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-04-15 10:22): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-04-15 10:23): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-06-07 10:36): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-06-07 10:55): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-06-28 11:43): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-08-13 19:07): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-09-29 10:29): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-10-10 16:18): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2016-10-12 12:51): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-11 11:36): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-13 16:15): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-16 14:59): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-24 12:45): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-27 13:46): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-27 13:47): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-27 14:02): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-27 14:15): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-27 14:29): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-27 16:22): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-30 08:54): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-30 11:33): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-30 11:54): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-30 12:54): -Difference from reference: 3.46944695195e-17 -Result: Pass - -Results of the 3D regression test (2017-01-30 13:46): -Difference from reference: 3.46944695195e-17 -Result: Pass - diff --git a/tests/deprecated_tests/regression_tests/residuals.h b/tests/deprecated_tests/regression_tests/residuals.h deleted file mode 100644 index ff76a2d3f..000000000 --- a/tests/deprecated_tests/regression_tests/residuals.h +++ /dev/null @@ -1,683 +0,0 @@ -// List of variables and residual equations for the Precipitate Evolution -// example application - -// ================================================================================= -// Define the variables in the model -// ================================================================================= -// The number of variables -#define num_var 5 - -// The names of the variables, whether they are scalars or vectors and whether -// the governing eqn for the variable is parabolic or elliptic -#define variable_name \ - { \ - "c", "n1", "n2", "n3", "u" \ - } -#define variable_type \ - { \ - "SCALAR", "SCALAR", "SCALAR", "SCALAR", "VECTOR" \ - } -#define variable_eq_type \ - { \ - "PARABOLIC", "PARABOLIC", "PARABOLIC", "PARABOLIC", "ELLIPTIC" \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqns -#define need_val \ - { \ - true, true, true, true, false \ - } -#define need_grad \ - { \ - true, true, true, true, true \ - } -#define need_hess \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual \ - { \ - true, true, true, true, false \ - } -#define need_grad_residual \ - { \ - true, true, true, true, true \ - } - -// Flags for whether the value, gradient, and Hessian are needed in the residual -// eqn for the left-hand-side of the iterative solver for elliptic equations -#define need_val_LHS \ - { \ - false, true, true, true, false \ - } -#define need_grad_LHS \ - { \ - false, false, false, false, true \ - } -#define need_hess_LHS \ - { \ - false, false, false, false, false \ - } - -// Flags for whether the residual equation for the left-hand-side of the -// iterative solver for elliptic equations has a term multiplied by the test -// function (need_val_residual) and/or the gradient of the test function -// (need_grad_residual) -#define need_val_residual_LHS \ - { \ - false, false, false, false, false \ - } -#define need_grad_residual_LHS \ - { \ - false, false, false, false, true \ - } - -// ================================================================================= -// Define the model parameters and the residual equations -// ================================================================================= -// Parameters in the residual equations and expressions for the residual -// equations can be set here. For simple cases, the entire residual equation can -// be written here. For more complex cases with loops or conditional statements, -// residual equations (or parts of residual equations) can be written below in -// "residualRHS". - -// Cahn-Hilliard mobility -#define McV 1.0 - -// Allen-Cahn mobilities -#define Mn1V 50.0 -#define Mn2V 50.0 -#define Mn3V 50.0 - -// Gradient energy coefficients -double Kn1[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn2[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; -double Kn3[3][3] = { - {1.0, 0, 0 }, - {0, 0.5, 0 }, - {0, 0, 1.0} -}; - -// define energy barrier coefficient (used to tune the interfacial energy) -#define W -1.0 - -// Define mechanical properties -#define n_dependent_stiffness false -// Mechanical symmetry of the material and stiffness parameters -// If n_dependent_stiffness == false the first entry is used for all phases -#define MaterialModels \ - { \ - { \ - "ANISOTROPIC" \ - } \ - } -#define MaterialConstants \ - { \ - { \ - 31.3, 31.3, 32.45, 6.65, 6.65, 9.15, 13.0, 10.45, 0, 0, 0, 10.45, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0 \ - } \ - } - -// Stress-free transformation strains -// Linear fits for the stress-free transformation strains in for sfts = -// sfts_linear * c + sfts_const -double sfts_linear1[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const1[3][3] = { - {0.1305, 0, 0 }, - {0, -0.0152, 0 }, - {0, 0, -0.014} -}; // Mg-Nd beta-prime - -double sfts_linear2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const2[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -double sfts_linear3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; -double sfts_const3[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - -// Free energy expressions -#define faV (24.7939 * c * c - 1.6752 * c - 1.9453e-06) -#define facV (49.5878 * c - 1.6752) -#define faccV (49.5878) -#define fbV (37.9316 * c * c - 10.7373 * c + 0.5401) -#define fbcV (75.8633 * c - 10.7373) -#define fbccV (75.8633) -#define h1V (3.0 * n1 * n1 - 2.0 * n1 * n1 * n1) -#define h2V (3.0 * n2 * n2 - 2.0 * n2 * n2 * n2) -#define h3V (3.0 * n3 * n3 - 2.0 * n3 * n3 * n3) -#define hn1V (6.0 * n1 - 6.0 * n1 * n1) -#define hn2V (6.0 * n2 - 6.0 * n2 * n2) -#define hn3V (6.0 * n3 - 6.0 * n3 * n3) - -// This double-well function can be used to tune the interfacial energy -#define fbarrierV (n1 * n1 - 2.0 * n1 * n1 * n1 + n1 * n1 * n1 * n1) -#define fbarriernV (2.0 * n1 - 6.0 * n1 * n1 + 4.0 * n1 * n1 * n1) - -// Residuals -#define rcV (c) -#define rcxTemp \ - (cx * ((1.0 - h1V - h2V - h3V) * faccV + (h1V + h2V + h3V) * fbccV) + \ - n1x * ((fbcV - facV) * hn1V) + n2x * ((fbcV - facV) * hn2V) + \ - n3x * ((fbcV - facV) * hn3V)) -#define rcxV (constV(-timeStep * McV) * rcxTemp) - -#define rn1V \ - (n1 - constV(timeStep * Mn1V) * \ - ((fbV - faV) * hn1V + W * fbarriernV + nDependentMisfitAC1)) -#define rn2V (n2 - constV(timeStep * Mn2V) * ((fbV - faV) * hn2V)) -#define rn3V (n3 - constV(timeStep * Mn3V) * ((fbV - faV) * hn3V)) -#define rn1xV (constV(-timeStep * Mn1V) * Knx1) -#define rn2xV (constV(-timeStep * Mn2V) * Knx2) -#define rn3xV (constV(-timeStep * Mn3V) * Knx3) - -// ================================================================================= -// residualRHS -// ================================================================================= -// This function calculates the residual equations for each variable. It takes -// "modelVariablesList" as an input, which is a list of the value and -// derivatives of each of the variables at a specific quadrature point. The -// (x,y,z) location of that quadrature point is given by "q_point_loc". The -// function outputs "modelResidualsList", a list of the value and gradient terms -// of the residual for each residual equation. The index for each variable in -// these lists corresponds to the order it is defined at the top of this file -// (starting at 0). -template -void -generalizedProblem::residualRHS( - const std::vector> &modelVariablesList, - std::vector> &modelResidualsList, - dealii::Point> q_point_loc) const -{ - // The concentration and its derivatives (names here should match those in the - // macros above) - scalarvalueType c = modelVariablesList[0].scalarValue; - scalargradType cx = modelVariablesList[0].scalarGrad; - - // The first order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n1 = modelVariablesList[1].scalarValue; - scalargradType n1x = modelVariablesList[1].scalarGrad; - - // The second order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n2 = modelVariablesList[2].scalarValue; - scalargradType n2x = modelVariablesList[2].scalarGrad; - - // The third order parameter and its derivatives (names here should match - // those in the macros above) - scalarvalueType n3 = modelVariablesList[3].scalarValue; - scalargradType n3x = modelVariablesList[3].scalarGrad; - - // The derivative of the displacement vector (names here should match those in - // the macros above) - vectorgradType ux = modelVariablesList[4].vectorGrad; - vectorgradType ruxV; - - vectorhessType uxx; - - if (c_dependent_misfit == true) - { - uxx = modelVariablesList[4].vectorHess; - } - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - // Compute stress tensor (which is equal to the residual, Rux) - dealii::VectorizedArray CIJ_combined[CIJ_tensor_size][CIJ_tensor_size]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - // Fill residual corresponding to mechanics - // R=-C*(E-E0) - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - ruxV[i][j] = -S[i][j]; - } - } - - // Compute one of the stress terms in the order parameter chemical potential, - // nDependentMisfitACp = C*(E-E0)*(E0_p*Hn) - dealii::VectorizedArray nDependentMisfitAC1 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC2 = constV(0.0); - dealii::VectorizedArray nDependentMisfitAC3 = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - nDependentMisfitAC1 += S[i][j] * (sfts1[i][j]); - nDependentMisfitAC2 += S[i][j] * (sfts2[i][j]); - nDependentMisfitAC3 += S[i][j] * (sfts3[i][j]); - } - } - - nDependentMisfitAC1 *= -hn1V; - nDependentMisfitAC2 *= -hn2V; - nDependentMisfitAC3 *= -hn3V; - - // Compute the other stress term in the order parameter chemical potential, - // heterMechACp = 0.5*Hn*(C_beta-C_alpha)*(E-E0)*(E-E0) - dealii::VectorizedArray heterMechAC1 = constV(0.0); - dealii::VectorizedArray heterMechAC2 = constV(0.0); - dealii::VectorizedArray heterMechAC3 = constV(0.0); - dealii::VectorizedArray S2[dim][dim]; - - if (n_dependent_stiffness == true) - { - // computeStress(CIJ_diff, E2, S2); - computeStress(CIJ_list[1] - CIJ_list[0], E2, S2); - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - heterMechAC1 += S2[i][j] * E2[i][j]; - } - } - // Aside from HnpV, heterMechAC1, heterMechAC2, and heterMechAC3 are equal - heterMechAC2 = 0.5 * hn2V * heterMechAC1; - heterMechAC3 = 0.5 * hn3V * heterMechAC1; - - heterMechAC1 = 0.5 * hn1V * heterMechAC1; - } - - // compute the stress term in the gradient of the concentration chemical - // potential, grad_mu_el = [C*(E-E0)*E0c]x, must be a vector with length dim - scalargradType grad_mu_el; - - if (c_dependent_misfit == true) - { - dealii::VectorizedArray E3[dim][dim], S3[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - E3[i][j] = -(sfts1c[i][j] * h1V + sfts2c[i][j] * h2V + sfts3c[i][j] * h3V); - } - } - - if (n_dependent_stiffness == true) - { - computeStress(CIJ_combined, E3, S3); - } - else - { - computeStress(CIJ_list[0], E3, S3); - } - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - for (unsigned int k = 0; k < dim; k++) - { - grad_mu_el[k] += - S3[i][j] * - (constV(0.5) * (uxx[i][j][k] + uxx[j][i][k]) + E3[i][j] * cx[k] - - (sfts1[i][j] * hn1V * n1x[k] + sfts2[i][j] * hn2V * n2x[k] + - sfts3[i][j] * hn3V * n3x[k])); - - grad_mu_el[k] += - -S[i][j] * - (sfts1c[i][j] * hn1V * n1x[k] + sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k] + - (sfts1cc[i][j] * h1V + sfts2cc[i][j] * h2V + sfts3cc[i][j] * h3V) * - cx[k]); - - if (n_dependent_stiffness == true) - { - grad_mu_el[k] += -S2[i][j] * (sfts1c[i][j] * hn1V * n1x[k] + - sfts2c[i][j] * hn2V * n2x[k] + - sfts3c[i][j] * hn3V * n3x[k]); - } - } - } - } - } - - // compute K*nx - scalargradType Knx1, Knx2, Knx3; - for (unsigned int a = 0; a < dim; a++) - { - Knx1[a] = 0.0; - Knx2[a] = 0.0; - Knx3[a] = 0.0; - for (unsigned int b = 0; b < dim; b++) - { - Knx1[a] += constV(Kn1[a][b]) * n1x[b]; - Knx2[a] += constV(Kn2[a][b]) * n2x[b]; - Knx3[a] += constV(Kn3[a][b]) * n3x[b]; - } - } - - modelResidualsList[0].scalarValueResidual = rcV; - modelResidualsList[0].scalarGradResidual = rcxV; - - modelResidualsList[1].scalarValueResidual = rn1V; - modelResidualsList[1].scalarGradResidual = rn1xV; - - modelResidualsList[2].scalarValueResidual = rn2V; - modelResidualsList[2].scalarGradResidual = rn2xV; - - modelResidualsList[3].scalarValueResidual = rn3V; - modelResidualsList[3].scalarGradResidual = rn3xV; - - modelResidualsList[4].vectorGradResidual = ruxV; -} - -// ================================================================================= -// residualLHS (needed only if at least one equation is elliptic) -// ================================================================================= -// This function calculates the residual equations for the iterative solver for -// elliptic equations.for each variable. It takes "modelVariablesList" as an -// input, which is a list of the value and derivatives of each of the variables -// at a specific quadrature point. The (x,y,z) location of that quadrature point -// is given by "q_point_loc". The function outputs "modelRes", the value and -// gradient terms of for the left-hand-side of the residual equation for the -// iterative solver. The index for each variable in these lists corresponds to -// the order it is defined at the top of this file (starting at 0), not counting -// variables that have "need_val_LHS", "need_grad_LHS", and "need_hess_LHS" all -// set to "false". If there are multiple elliptic equations, conditional -// statements should be used to ensure that the correct residual is being -// submitted. The index of the field being solved can be accessed by -// "this->currentFieldIndex". -template -void -generalizedProblem::residualLHS( - const std::vector> &modelVariablesList, - modelResidual &modelRes, - dealii::Point> q_point_loc) const -{ - // n1 - scalarvalueType n1 = modelVariablesList[0].scalarValue; - - // n2 - scalarvalueType n2 = modelVariablesList[1].scalarValue; - - // n3 - scalarvalueType n3 = modelVariablesList[2].scalarValue; - - // u - vectorgradType ux = modelVariablesList[3].vectorGrad; - vectorgradType ruxV; - - // Take advantage of E being simply 0.5*(ux + transpose(ux)) and use the - // dealii "symmetrize" function - dealii::Tensor<2, dim, dealii::VectorizedArray> E; - E = symmetrize(ux); - - // Compute stress tensor (which is equal to the residual, Rux) - if (n_dependent_stiffness == true) - { - dealii::Tensor<2, CIJ_tensor_size, dealii::VectorizedArray> CIJ_combined; - CIJ_combined = - CIJ_list[0] * (constV(1.0) - h1V - h2V - h3V) + CIJ_list[1] * (h1V + h2V + h3V); - - computeStress(CIJ_combined, E, ruxV); - } - else - { - computeStress(CIJ_list[0], E, ruxV); - } - - modelRes.vectorGradResidual = ruxV; -} - -// ================================================================================= -// energyDensity (needed only if calcEnergy == true) -// ================================================================================= -// This function integrates the free energy density across the computational -// domain. It takes "modelVariablesList" as an input, which is a list of the -// value and derivatives of each of the variables at a specific quadrature -// point. It also takes the mapped quadrature weight, "JxW_value", as an input. -// The (x,y,z) location of the quadrature point is given by "q_point_loc". The -// weighted value of the energy density is added to "energy" variable and the -// components of the energy density are added to the "energy_components" -// variable (index 0: chemical energy, index 1: gradient energy, index 2: -// elastic energy). -template -void -generalizedProblem::energyDensity( - const std::vector> &modelVarList, - const dealii::VectorizedArray &JxW_value, - dealii::Point> q_point_loc) -{ - scalarvalueType total_energy_density = constV(0.0); - - // c - scalarvalueType c = modelVarList[0].scalarValue; - scalargradType cx = modelVarList[0].scalarGrad; - - // n1 - scalarvalueType n1 = modelVarList[1].scalarValue; - scalargradType n1x = modelVarList[1].scalarGrad; - - // n2 - scalarvalueType n2 = modelVarList[2].scalarValue; - scalargradType n2x = modelVarList[2].scalarGrad; - - // n3 - scalarvalueType n3 = modelVarList[3].scalarValue; - scalargradType n3x = modelVarList[3].scalarGrad; - - // u - vectorgradType ux = modelVarList[4].vectorGrad; - - scalarvalueType f_chem = - (constV(1.0) - (h1V + h2V + h3V)) * faV + (h1V + h2V + h3V) * fbV; - - scalarvalueType f_grad = constV(0.0); - - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn1[i][j]) * n1x[i] * n1x[j]; - } - } -#if num_sop > 1 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn2[i][j]) * n2x[i] * n2x[j]; - } - } -#endif -#if num_sop > 2 - for (int i = 0; i < dim; i++) - { - for (int j = 0; j < dim; j++) - { - f_grad += constV(0.5 * Kn3[i][j]) * n3x[i] * n3x[j]; - } - } -#endif - - // Calculate the stress-free transformation strain and its derivatives at the - // quadrature point - dealii::Tensor<2, problemDIM, dealii::VectorizedArray> sfts1, sfts1c, sfts1cc, - sfts2, sfts2c, sfts2cc, sfts3, sfts3c, sfts3cc; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts1[i][j] = constV(sfts_linear1[i][j]) * c + constV(sfts_const1[i][j]); - sfts1c[i][j] = constV(sfts_linear1[i][j]); - sfts1cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts2[i][j] = constV(sfts_linear2[i][j]) * c + constV(sfts_const2[i][j]); - sfts2c[i][j] = constV(sfts_linear1[i][j]); - sfts2cc[i][j] = constV(0.0); - - // Polynomial fits for the stress-free transformation strains, of the - // form: sfts = a_p * c + b_p - sfts3[i][j] = constV(sfts_linear3[i][j]) * c + constV(sfts_const3[i][j]); - sfts3c[i][j] = constV(sfts_linear3[i][j]); - sfts3cc[i][j] = constV(0.0); - } - } - - // compute E2=(E-E0) - dealii::VectorizedArray E2[dim][dim], S[dim][dim]; - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - // E2[i][j]= constV(0.5)*(ux[i][j]+ux[j][i])-( sfts1[i][j]*h1V + - // sfts2[i][j]*h2V + sfts3[i][j]*h3V); - E2[i][j] = constV(0.5) * (ux[i][j] + ux[j][i]) - - (sfts1[i][j] * h1V + sfts2[i][j] * h2V + sfts3[i][j] * h3V); - } - } - - // compute stress - // S=C*(E-E0) - dealii::VectorizedArray CIJ_combined[2 * dim - 1 + dim / 3] - [2 * dim - 1 + dim / 3]; - - if (n_dependent_stiffness == true) - { - dealii::VectorizedArray sum_hV; - sum_hV = h1V + h2V + h3V; - for (unsigned int i = 0; i < 2 * dim - 1 + dim / 3; i++) - { - for (unsigned int j = 0; j < 2 * dim - 1 + dim / 3; j++) - { - CIJ_combined[i][j] = - CIJ_list[0][i][j] * (constV(1.0) - sum_hV) + CIJ_list[1][i][j] * sum_hV; - } - } - computeStress(CIJ_combined, E2, S); - } - else - { - computeStress(CIJ_list[0], E2, S); - } - - scalarvalueType f_el = constV(0.0); - - for (unsigned int i = 0; i < dim; i++) - { - for (unsigned int j = 0; j < dim; j++) - { - f_el += constV(0.5) * S[i][j] * E2[i][j]; - } - } - - total_energy_density = f_chem + f_grad + f_el; - - assembler_lock.acquire(); - for (unsigned i = 0; i < c.size(); i++) - { - // For some reason, some of the values in this loop - if (c[i] > 1.0e-10) - { - this->energy += total_energy_density[i] * JxW_value[i]; - this->energy_components[0] += f_chem[i] * JxW_value[i]; - this->energy_components[1] += f_grad[i] * JxW_value[i]; - this->energy_components[2] += f_el[i] * JxW_value[i]; - } - } - assembler_lock.release(); -} diff --git a/tests/deprecated_tests/regression_tests/run_regression_test.py b/tests/deprecated_tests/regression_tests/run_regression_test.py deleted file mode 100644 index 0adbc1aa6..000000000 --- a/tests/deprecated_tests/regression_tests/run_regression_test.py +++ /dev/null @@ -1,50 +0,0 @@ -import subprocess -import shutil -import glob -import math -import os.path -import datetime - -# ---------------------------------------------------------------------------------------- -# Function that generates a header file for the simulation, compiles the PRISMS-PF code -# and runs the executable. -# ---------------------------------------------------------------------------------------- -def run_simulation(run_name): - - subprocess.call(["make", "release"]) - #subprocess.call(["./main"]) - subprocess.call(["mpirun", "-n", "4", "main"]) - - subprocess.call(["mkdir",run_name]) - for output_files in glob.glob('*vtu'): - shutil.move(output_files,run_name) - -# ---------------------------------------------------------------------------------------- - -# If files exist from previous tests, delete them -if os.path.exists("run_001") == True: - shutil.rmtree("run_001") - -# Run simulation comparison simulation -run_simulation('run_001') - -# Find the error for runs 1 compared to the reference solution -subprocess.call(["visit", "-cli","-s","getError.py"]) - -f = open('error.txt','r') -error = float(f.read()) -f.close() - -print "Regression test results: \n" -print "Difference between calculated result and reference result:", str(error), "\n" - -text_file = open("regress_test_results.txt","a") -now = datetime.datetime.now() -text_file.write("Results of the 3D regression test (" + now.strftime("%Y-%m-%d %H:%M") + "): \n") -text_file.write("Difference from reference: " + str(error) + "\n") -if error < 1e-10: - text_file.write("Result: Pass \n \n") -else: - text_file.write("Result: Fail \n \n") -text_file.close() - diff --git a/tests/deprecated_tests/regression_tests/visitlog.py b/tests/deprecated_tests/regression_tests/visitlog.py deleted file mode 100644 index 697b9ce29..000000000 --- a/tests/deprecated_tests/regression_tests/visitlog.py +++ /dev/null @@ -1,63 +0,0 @@ -# Visit 2.11.0 log file -ScriptVersion = "2.11.0" -if ScriptVersion != Version(): - print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version()) -ShowAllWindows() -OpenDatabase("reference_solution/solution-1000.pvtu", 0) -# The UpdateDBPluginInfo RPC is not supported in the VisIt module so it will not be logged. -DefineScalarExpression("diff", "(c-pos_cmfe(, mesh,0))") -AddPlot("Pseudocolor", "diff", 1, 1) -PseudocolorAtts = PseudocolorAttributes() -PseudocolorAtts.scaling = PseudocolorAtts.Linear # Linear, Log, Skew -PseudocolorAtts.skewFactor = 1 -PseudocolorAtts.limitsMode = PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot -PseudocolorAtts.minFlag = 0 -PseudocolorAtts.min = 0 -PseudocolorAtts.maxFlag = 0 -PseudocolorAtts.max = 1 -PseudocolorAtts.centering = PseudocolorAtts.Natural # Natural, Nodal, Zonal -PseudocolorAtts.colorTableName = "hot" -PseudocolorAtts.invertColorTable = 0 -PseudocolorAtts.opacityType = PseudocolorAtts.FullyOpaque # ColorTable, FullyOpaque, Constant, Ramp, VariableRange -PseudocolorAtts.opacityVariable = "" -PseudocolorAtts.opacity = 1 -PseudocolorAtts.opacityVarMin = 0 -PseudocolorAtts.opacityVarMax = 1 -PseudocolorAtts.opacityVarMinFlag = 0 -PseudocolorAtts.opacityVarMaxFlag = 0 -PseudocolorAtts.pointSize = 0.05 -PseudocolorAtts.pointType = PseudocolorAtts.Point # Box, Axis, Icosahedron, Octahedron, Tetrahedron, SphereGeometry, Point, Sphere -PseudocolorAtts.pointSizeVarEnabled = 0 -PseudocolorAtts.pointSizeVar = "default" -PseudocolorAtts.pointSizePixels = 2 -PseudocolorAtts.lineStyle = PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH -PseudocolorAtts.lineType = PseudocolorAtts.Line # Line, Tube, Ribbon -PseudocolorAtts.lineWidth = 0 -PseudocolorAtts.tubeResolution = 10 -PseudocolorAtts.tubeRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.tubeRadiusAbsolute = 0.125 -PseudocolorAtts.tubeRadiusBBox = 0.005 -PseudocolorAtts.tubeRadiusVarEnabled = 0 -PseudocolorAtts.tubeRadiusVar = "" -PseudocolorAtts.tubeRadiusVarRatio = 10 -PseudocolorAtts.endPointType = PseudocolorAtts.None # None, Heads, Tails, Both -PseudocolorAtts.endPointStyle = PseudocolorAtts.Spheres # Spheres, Cones -PseudocolorAtts.endPointRadiusSizeType = PseudocolorAtts.FractionOfBBox # Absolute, FractionOfBBox -PseudocolorAtts.endPointRadiusAbsolute = 0.125 -PseudocolorAtts.endPointRadiusBBox = 0.05 -PseudocolorAtts.endPointResolution = 10 -PseudocolorAtts.endPointRatio = 5 -PseudocolorAtts.endPointRadiusVarEnabled = 0 -PseudocolorAtts.endPointRadiusVar = "" -PseudocolorAtts.endPointRadiusVarRatio = 10 -PseudocolorAtts.renderSurfaces = 1 -PseudocolorAtts.renderWireframe = 0 -PseudocolorAtts.renderPoints = 0 -PseudocolorAtts.smoothingLevel = 0 -PseudocolorAtts.legendFlag = 1 -PseudocolorAtts.lightingFlag = 1 -PseudocolorAtts.wireframeColor = (0, 0, 0, 0) -PseudocolorAtts.pointColor = (0, 0, 0, 0) -SetPlotOptions(PseudocolorAtts) -DrawPlots() -Query("MinMax", use_actual_data=1) diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index e8ae8456c..7f7cd242a 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -16,7 +16,7 @@ SET(TARGET_SRC CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) -FIND_PACKAGE(deal.II 8.0 QUIET +FIND_PACKAGE(deal.II 9.2.0 QUIET HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} ) IF(NOT ${deal.II_FOUND}) diff --git a/tests/unit_tests/main.cc b/tests/unit_tests/main.cc index dd2e67625..87b14a7ad 100644 --- a/tests/unit_tests/main.cc +++ b/tests/unit_tests/main.cc @@ -107,34 +107,6 @@ main(int argc, char **argv) pass = computeStress_tester_3DT.test_computeStress(); tests_passed += pass; - // Unit tests for the method "setRigidBodyModeConstraints" - total_tests++; - unitTest<2, double> setRigidBodyModeConstraints_tester_null; - std::vector rigidBodyModeComponents; - pass = setRigidBodyModeConstraints_tester_null - .test_setRigidBodyModeConstraints(rigidBodyModeComponents, userInputs); - tests_passed += pass; - - total_tests++; - unitTest<2, double> setRigidBodyModeConstraints_tester_one; - rigidBodyModeComponents.clear(); - rigidBodyModeComponents.push_back(0); - pass = setRigidBodyModeConstraints_tester_one - .test_setRigidBodyModeConstraints(rigidBodyModeComponents, userInputs); - tests_passed += pass; - - // In debug mode this test has an exception because it is trying to access - // components higher than 0 on the mesh for a scalar. To get this test working - // again, I'll need a DoFHandler for a vector field. total_tests++; - // unitTest<2,double> setRigidBodyModeConstraints_tester_three; - // rigidBodyModeComponents.clear(); - // rigidBodyModeComponents.push_back(0); - // rigidBodyModeComponents.push_back(1); - // rigidBodyModeComponents.push_back(2); - // pass = - // setRigidBodyModeConstraints_tester_three.test_setRigidBodyModeConstraints(rigidBodyModeComponents, - // userInputs); tests_passed += pass; - // Unit tests for the "LinearSolverParameters" class total_tests++; unitTest<2, double> LinearSolverParameters_tester; diff --git a/tests/unit_tests/test_EquationDependencyParser.h b/tests/unit_tests/test_EquationDependencyParser.h index fbdd3eb7f..3cce2fdfb 100644 --- a/tests/unit_tests/test_EquationDependencyParser.h +++ b/tests/unit_tests/test_EquationDependencyParser.h @@ -53,10 +53,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_value_explicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_value_explicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_explicit_RHS.size() == 2) { - if (equation_dependency_parser.need_value_explicit_RHS[0] == true && - equation_dependency_parser.need_value_explicit_RHS[1] == true) + if (equation_dependency_parser.eval_flags_explicit_RHS[0] & + dealii::EvaluationFlags::values && + equation_dependency_parser.eval_flags_explicit_RHS[1] & + dealii::EvaluationFlags::values) { result = true; } @@ -68,10 +70,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_gradient_explicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_value_explicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_explicit_RHS.size() == 2) { - if (equation_dependency_parser.need_gradient_explicit_RHS[0] == true && - equation_dependency_parser.need_gradient_explicit_RHS[1] == true) + if (equation_dependency_parser.eval_flags_explicit_RHS[0] & + dealii::EvaluationFlags::gradients && + equation_dependency_parser.eval_flags_explicit_RHS[1] & + dealii::EvaluationFlags::gradients) { result = true; } @@ -84,10 +88,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_hessian_explicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_value_explicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_explicit_RHS.size() == 2) { - if (equation_dependency_parser.need_hessian_explicit_RHS[0] == false && - equation_dependency_parser.need_hessian_explicit_RHS[1] == false) + if (!(equation_dependency_parser.eval_flags_explicit_RHS[0] & + dealii::EvaluationFlags::hessians) && + !(equation_dependency_parser.eval_flags_explicit_RHS[1] & + dealii::EvaluationFlags::hessians)) { result = true; } @@ -100,10 +106,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_value_nonexplicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_value_nonexplicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_nonexplicit_RHS.size() == 2) { - if (equation_dependency_parser.need_value_nonexplicit_RHS[0] == true && - equation_dependency_parser.need_value_nonexplicit_RHS[1] == false) + if (equation_dependency_parser.eval_flags_nonexplicit_RHS[0] & + dealii::EvaluationFlags::values && + !(equation_dependency_parser.eval_flags_nonexplicit_RHS[1] & + dealii::EvaluationFlags::values)) { result = true; } @@ -116,10 +124,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_gradient_nonexplicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_gradient_nonexplicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_nonexplicit_RHS.size() == 2) { - if (equation_dependency_parser.need_gradient_nonexplicit_RHS[0] == false && - equation_dependency_parser.need_gradient_nonexplicit_RHS[1] == true) + if (!(equation_dependency_parser.eval_flags_nonexplicit_RHS[0] & + dealii::EvaluationFlags::gradients) && + equation_dependency_parser.eval_flags_nonexplicit_RHS[1] & + dealii::EvaluationFlags::gradients) { result = true; } @@ -132,10 +142,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_hessian_nonexplicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_hessian_nonexplicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_nonexplicit_RHS.size() == 2) { - if (equation_dependency_parser.need_hessian_nonexplicit_RHS[0] == true && - equation_dependency_parser.need_hessian_nonexplicit_RHS[1] == false) + if (equation_dependency_parser.eval_flags_nonexplicit_RHS[0] & + dealii::EvaluationFlags::hessians && + !(equation_dependency_parser.eval_flags_nonexplicit_RHS[1] & + dealii::EvaluationFlags::hessians)) { result = true; } @@ -148,10 +160,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_value_nonexplicit_LHS subtest_index++; result = false; - if (equation_dependency_parser.need_value_nonexplicit_LHS.size() == 2) + if (equation_dependency_parser.eval_flags_nonexplicit_LHS.size() == 2) { - if (equation_dependency_parser.need_value_nonexplicit_LHS[0] == false && - equation_dependency_parser.need_value_nonexplicit_LHS[1] == true) + if (!(equation_dependency_parser.eval_flags_nonexplicit_LHS[0] & + dealii::EvaluationFlags::values) && + equation_dependency_parser.eval_flags_nonexplicit_LHS[1] & + dealii::EvaluationFlags::values) { result = true; } @@ -164,10 +178,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_gradient_nonexplicit_LHS subtest_index++; result = false; - if (equation_dependency_parser.need_gradient_nonexplicit_LHS.size() == 2) + if (equation_dependency_parser.eval_flags_nonexplicit_LHS.size() == 2) { - if (equation_dependency_parser.need_gradient_nonexplicit_LHS[0] == false && - equation_dependency_parser.need_gradient_nonexplicit_LHS[1] == true) + if (!(equation_dependency_parser.eval_flags_nonexplicit_LHS[0] & + dealii::EvaluationFlags::gradients) && + equation_dependency_parser.eval_flags_nonexplicit_LHS[1] & + dealii::EvaluationFlags::gradients) { result = true; } @@ -180,10 +196,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_hessian_nonexplicit_LHS subtest_index++; result = false; - if (equation_dependency_parser.need_hessian_nonexplicit_LHS.size() == 2) + if (equation_dependency_parser.eval_flags_nonexplicit_LHS.size() == 2) { - if (equation_dependency_parser.need_hessian_nonexplicit_LHS[0] == false && - equation_dependency_parser.need_hessian_nonexplicit_LHS[1] == false) + if (!(equation_dependency_parser.eval_flags_nonexplicit_LHS[0] & + dealii::EvaluationFlags::hessians) && + !(equation_dependency_parser.eval_flags_nonexplicit_LHS[1] & + dealii::EvaluationFlags::hessians)) { result = true; } @@ -196,10 +214,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_value_change_nonexplicit_LHS subtest_index++; result = false; - if (equation_dependency_parser.need_value_change_nonexplicit_LHS.size() == 2) + if (equation_dependency_parser.eval_flags_change_nonexplicit_LHS.size() == 2) { - if (equation_dependency_parser.need_value_change_nonexplicit_LHS[0] == false && - equation_dependency_parser.need_value_change_nonexplicit_LHS[1] == true) + if (!(equation_dependency_parser.eval_flags_change_nonexplicit_LHS[0] & + dealii::EvaluationFlags::values) && + equation_dependency_parser.eval_flags_change_nonexplicit_LHS[1] & + dealii::EvaluationFlags::values) { result = true; } @@ -212,10 +232,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_gradient_change_nonexplicit_LHS subtest_index++; result = false; - if (equation_dependency_parser.need_gradient_change_nonexplicit_LHS.size() == 2) + if (equation_dependency_parser.eval_flags_change_nonexplicit_LHS.size() == 2) { - if (equation_dependency_parser.need_gradient_change_nonexplicit_LHS[0] == false && - equation_dependency_parser.need_gradient_change_nonexplicit_LHS[1] == true) + if (!(equation_dependency_parser.eval_flags_change_nonexplicit_LHS[0] & + dealii::EvaluationFlags::gradients) && + equation_dependency_parser.eval_flags_change_nonexplicit_LHS[1] & + dealii::EvaluationFlags::gradients) { result = true; } @@ -229,10 +251,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_hessian_nonexplicit_LHS subtest_index++; result = false; - if (equation_dependency_parser.need_hessian_change_nonexplicit_LHS.size() == 2) + if (equation_dependency_parser.eval_flags_change_nonexplicit_LHS.size() == 2) { - if (equation_dependency_parser.need_hessian_change_nonexplicit_LHS[0] == false && - equation_dependency_parser.need_hessian_change_nonexplicit_LHS[1] == false) + if (!(equation_dependency_parser.eval_flags_change_nonexplicit_LHS[0] & + dealii::EvaluationFlags::hessians) && + !(equation_dependency_parser.eval_flags_change_nonexplicit_LHS[1] & + dealii::EvaluationFlags::hessians)) { result = true; } @@ -245,10 +269,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_value_residual_explicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_value_residual_explicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_residual_explicit_RHS.size() == 2) { - if (equation_dependency_parser.need_value_residual_explicit_RHS[0] == true && - equation_dependency_parser.need_value_residual_explicit_RHS[1] == false) + if (equation_dependency_parser.eval_flags_residual_explicit_RHS[0] & + dealii::EvaluationFlags::values && + !(equation_dependency_parser.eval_flags_residual_explicit_RHS[1] & + dealii::EvaluationFlags::values)) { result = true; } @@ -260,10 +286,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_gradient_residual_explicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_gradient_residual_explicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_residual_explicit_RHS.size() == 2) { - if (equation_dependency_parser.need_gradient_residual_explicit_RHS[0] == true && - equation_dependency_parser.need_gradient_residual_explicit_RHS[1] == false) + if (equation_dependency_parser.eval_flags_residual_explicit_RHS[0] & + dealii::EvaluationFlags::gradients && + !(equation_dependency_parser.eval_flags_residual_explicit_RHS[1] & + dealii::EvaluationFlags::gradients)) { result = true; } @@ -276,10 +304,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_value_residual_nonexplicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_value_residual_nonexplicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_residual_nonexplicit_RHS.size() == 2) { - if (equation_dependency_parser.need_value_residual_nonexplicit_RHS[0] == false && - equation_dependency_parser.need_value_residual_nonexplicit_RHS[1] == true) + if (!(equation_dependency_parser.eval_flags_residual_nonexplicit_RHS[0] & + dealii::EvaluationFlags::values) && + equation_dependency_parser.eval_flags_residual_nonexplicit_RHS[1] & + dealii::EvaluationFlags::values) { result = true; } @@ -292,10 +322,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_gradient_residual_nonexplicit_RHS subtest_index++; result = false; - if (equation_dependency_parser.need_gradient_residual_nonexplicit_RHS.size() == 2) + if (equation_dependency_parser.eval_flags_residual_nonexplicit_RHS.size() == 2) { - if (equation_dependency_parser.need_gradient_residual_nonexplicit_RHS[0] == false && - equation_dependency_parser.need_gradient_residual_nonexplicit_RHS[1] == true) + if (!(equation_dependency_parser.eval_flags_residual_nonexplicit_RHS[0] & + dealii::EvaluationFlags::gradients) && + equation_dependency_parser.eval_flags_residual_nonexplicit_RHS[1] & + dealii::EvaluationFlags::gradients) { result = true; } @@ -308,10 +340,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_value_residual_nonexplicit_LHS subtest_index++; result = false; - if (equation_dependency_parser.need_value_residual_nonexplicit_LHS.size() == 2) + if (equation_dependency_parser.eval_flags_residual_nonexplicit_LHS.size() == 2) { - if (equation_dependency_parser.need_value_residual_nonexplicit_LHS[0] == false && - equation_dependency_parser.need_value_residual_nonexplicit_LHS[1] == true) + if (!(equation_dependency_parser.eval_flags_residual_nonexplicit_LHS[0] & + dealii::EvaluationFlags::values) && + equation_dependency_parser.eval_flags_residual_nonexplicit_LHS[1] & + dealii::EvaluationFlags::values) { result = true; } @@ -324,10 +358,12 @@ unitTest::test_EquationDependencyParser_variables_and_residuals_needed() // Check need_gradient_residual_nonexplicit_LHS subtest_index++; result = false; - if (equation_dependency_parser.need_gradient_residual_nonexplicit_LHS.size() == 2) + if (equation_dependency_parser.eval_flags_residual_nonexplicit_LHS.size() == 2) { - if (equation_dependency_parser.need_gradient_residual_nonexplicit_LHS[0] == false && - equation_dependency_parser.need_gradient_residual_nonexplicit_LHS[1] == true) + if (!(equation_dependency_parser.eval_flags_residual_nonexplicit_LHS[0] & + dealii::EvaluationFlags::gradients) && + equation_dependency_parser.eval_flags_residual_nonexplicit_LHS[1] & + dealii::EvaluationFlags::gradients) { result = true; } @@ -537,10 +573,12 @@ unitTest::test_EquationDependencyParser_postprocessing() // Check pp_need_value subtest_index++; result = false; - if (equation_dependency_parser.pp_need_value.size() == 2) + if (equation_dependency_parser.eval_flags_postprocess.size() == 2) { - if (equation_dependency_parser.pp_need_value[0] == true && - equation_dependency_parser.pp_need_value[1] == true) + if (equation_dependency_parser.eval_flags_postprocess[0] & + dealii::EvaluationFlags::values && + equation_dependency_parser.eval_flags_postprocess[1] & + dealii::EvaluationFlags::values) { result = true; } @@ -552,10 +590,12 @@ unitTest::test_EquationDependencyParser_postprocessing() // Check pp_need_gradient subtest_index++; result = false; - if (equation_dependency_parser.pp_need_gradient.size() == 2) + if (equation_dependency_parser.eval_flags_postprocess.size() == 2) { - if (equation_dependency_parser.pp_need_gradient[0] == false && - equation_dependency_parser.pp_need_gradient[1] == true) + if (!(equation_dependency_parser.eval_flags_postprocess[0] & + dealii::EvaluationFlags::gradients) && + equation_dependency_parser.eval_flags_postprocess[1] & + dealii::EvaluationFlags::gradients) { result = true; } @@ -568,10 +608,12 @@ unitTest::test_EquationDependencyParser_postprocessing() // Check pp_need_hessian subtest_index++; result = false; - if (equation_dependency_parser.pp_need_hessian.size() == 2) + if (equation_dependency_parser.eval_flags_postprocess.size() == 2) { - if (equation_dependency_parser.pp_need_hessian[0] == true && - equation_dependency_parser.pp_need_hessian[1] == false) + if (equation_dependency_parser.eval_flags_postprocess[0] & + dealii::EvaluationFlags::hessians && + !(equation_dependency_parser.eval_flags_postprocess[1] & + dealii::EvaluationFlags::hessians)) { result = true; } @@ -584,11 +626,14 @@ unitTest::test_EquationDependencyParser_postprocessing() // Check pp_need_value_residual subtest_index++; result = false; - if (equation_dependency_parser.pp_need_value_residual.size() == 3) + if (equation_dependency_parser.eval_flags_residual_postprocess.size() == 3) { - if (equation_dependency_parser.pp_need_value_residual[0] == true && - equation_dependency_parser.pp_need_value_residual[1] == false && - equation_dependency_parser.pp_need_value_residual[2] == true) + if (equation_dependency_parser.eval_flags_residual_postprocess[0] & + dealii::EvaluationFlags::values && + !(equation_dependency_parser.eval_flags_residual_postprocess[1] & + dealii::EvaluationFlags::values) && + equation_dependency_parser.eval_flags_residual_postprocess[2] & + dealii::EvaluationFlags::values) { result = true; } @@ -601,11 +646,14 @@ unitTest::test_EquationDependencyParser_postprocessing() subtest_index++; result = false; - if (equation_dependency_parser.pp_need_gradient_residual.size() == 3) + if (equation_dependency_parser.eval_flags_residual_postprocess.size() == 3) { - if (equation_dependency_parser.pp_need_gradient_residual[0] == true && - equation_dependency_parser.pp_need_gradient_residual[1] == true && - equation_dependency_parser.pp_need_gradient_residual[2] == true) + if (equation_dependency_parser.eval_flags_residual_postprocess[0] & + dealii::EvaluationFlags::gradients && + equation_dependency_parser.eval_flags_residual_postprocess[1] & + dealii::EvaluationFlags::gradients && + equation_dependency_parser.eval_flags_residual_postprocess[2] & + dealii::EvaluationFlags::gradients) { result = true; } diff --git a/tests/unit_tests/test_FloodFiller.h b/tests/unit_tests/test_FloodFiller.h index 6aaba9798..c0cbb1f3b 100644 --- a/tests/unit_tests/test_FloodFiller.h +++ b/tests/unit_tests/test_FloodFiller.h @@ -12,7 +12,7 @@ class InitialConditionFloodFill : public dealii::Function } double - value(const dealii::Point &p, const unsigned int component = 0) const + value(const dealii::Point &p, const unsigned int component = 0) const override { double val; if (p[1] < 0.6 and p[0] > p[1] + 1.0e-10) @@ -360,7 +360,7 @@ unitTest::test_FloodFiller() FloodFiller test_object(fe, quadrature2); std::vector> grain_sets; - test_object.calcGrainSets(fe, dof_handler, solution_field, 0.1, 1.1, 0, grain_sets); + test_object.calcGrainSets(fe, dof_handler, solution_field, 0.1, 1.1, 0, 0, grain_sets); std::vector>> expected_vertex_list0, expected_vertex_list1; diff --git a/tests/unit_tests/test_OrderParameterRemapper.h b/tests/unit_tests/test_OrderParameterRemapper.h index 9fc3d5300..cd6e86876 100644 --- a/tests/unit_tests/test_OrderParameterRemapper.h +++ b/tests/unit_tests/test_OrderParameterRemapper.h @@ -12,7 +12,7 @@ class InitialConditionOrderParameterRemapper : public dealii::Function } double - value(const dealii::Point &p, const unsigned int component = 0) const + value(const dealii::Point &p, const unsigned int component = 0) const override { double val; @@ -49,8 +49,6 @@ template bool unitTest::test_OrderParameterRemapper() { - int thisProc = dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); - char buffer[100]; std::cout << "\nTesting 'OrderParameterRemapper'... " << std::endl; @@ -131,10 +129,12 @@ unitTest::test_OrderParameterRemapper() FloodFiller test_object(fe, quadrature2); std::vector> grain_sets_0; - test_object.calcGrainSets(fe, dof_handler, solution_field_0, 0.1, 1.1, 0, grain_sets_0); + test_object + .calcGrainSets(fe, dof_handler, solution_field_0, 0.1, 1.1, 0, 0, grain_sets_0); std::vector> grain_sets_1; - test_object.calcGrainSets(fe, dof_handler, solution_field_1, 0.1, 1.1, 1, grain_sets_1); + test_object + .calcGrainSets(fe, dof_handler, solution_field_1, 0.1, 1.1, 0, 1, grain_sets_1); std::vector> grain_sets = grain_sets_0; grain_sets.insert(grain_sets.end(), grain_sets_1.begin(), grain_sets_1.end()); @@ -162,17 +162,6 @@ unitTest::test_OrderParameterRemapper() order_parameter_id_list); // ---------- The actual test run of OrderParameterRemapper ----------- - /* - for (unsigned int g=0; gprint(std::cout); - // std::cout << "Field 1, core" << thisProc << std::endl; - // solution_fields.at(1)->print(std::cout); - OrderParameterRemapper order_parameter_remapper; order_parameter_remapper.remap(simplified_grain_representations, solution_fields, @@ -180,19 +169,6 @@ unitTest::test_OrderParameterRemapper() fe.dofs_per_cell, 0.001); - /* - for (unsigned int g=0; gprint(std::cout); - // std::cout << "Field 1, core" << thisProc << std::endl; - // solution_fields.at(1)->print(std::cout); - // ---------- Check the result ----------- pass = true; diff --git a/tests/unit_tests/test_invM.h b/tests/unit_tests/test_invM.h index 66c9e65a3..99664e31f 100644 --- a/tests/unit_tests/test_invM.h +++ b/tests/unit_tests/test_invM.h @@ -40,7 +40,7 @@ class testInvM : public MatrixFreePDE setInitialCondition(const dealii::Point &p, const unsigned int index, double &scalar_IC, - dealii::Vector &vector_IC) {}; + dealii::Vector &vector_IC) override {}; // Function to set the non-uniform Dirichlet boundary conditions (in // ICs_and_BCs.h) @@ -50,7 +50,7 @@ class testInvM : public MatrixFreePDE const unsigned int direction, const double time, double &scalar_BC, - dealii::Vector &vector_BC) {}; + dealii::Vector &vector_BC) override {}; private: // RHS implementation for explicit solve @@ -65,20 +65,23 @@ class testInvM : public MatrixFreePDE void explicitEquationRHS( variableContainer> &variable_list, - dealii::Point> q_point_loc) const {}; + dealii::Point> q_point_loc, + [[maybe_unused]] dealii::VectorizedArray element_volume) const override {}; // Function to set the RHS of the governing equations for all other equations // (in equations.h) void nonExplicitEquationRHS( variableContainer> &variable_list, - dealii::Point> q_point_loc) const {}; + dealii::Point> q_point_loc, + [[maybe_unused]] dealii::VectorizedArray element_volume) const override {}; // Function to set the LHS of the governing equations (in equations.h) void equationLHS( variableContainer> &variable_list, - dealii::Point> q_point_loc) const {}; + dealii::Point> q_point_loc, + [[maybe_unused]] dealii::VectorizedArray element_volume) const override {}; }; template diff --git a/tests/unit_tests/test_setRigidBodyModeConstraints.h b/tests/unit_tests/test_setRigidBodyModeConstraints.h deleted file mode 100644 index 9f31fbd75..000000000 --- a/tests/unit_tests/test_setRigidBodyModeConstraints.h +++ /dev/null @@ -1,117 +0,0 @@ -// Unit test(s) for the method "setRigidBodyModeConstraints" -template -class setRigidBodyModeConstraintsTest : public MatrixFreePDE -{ -public: - setRigidBodyModeConstraintsTest(userInputParameters _userInputs) - : MatrixFreePDE(_userInputs) - { - // init the MatrixFreePDE class for testing - Field scalar_test_field(SCALAR, EXPLICIT_TIME_DEPENDENT, "c"); - this->fields.push_back(scalar_test_field); - this->initForTests(this->fields); - }; - - ~setRigidBodyModeConstraintsTest() - { - this->matrixFreeObject.clear(); - }; - - void - call_setRigidBodyModeConstraints(std::vector rigidBodyModeComponents, - unsigned int &num_constraints) - { - this->setRigidBodyModeConstraints(rigidBodyModeComponents, - this->constraintsOtherSet_nonconst[0], - this->dofHandlersSet_nonconst[0]); - - // Calculate the number of constraints that were set - num_constraints = this->constraintsOtherSet_nonconst[0]->n_constraints(); - }; - - void - setBCs() {}; - - // Function to set the initial conditions (in ICs_and_BCs.h) - void - setInitialCondition(const dealii::Point &p, - const unsigned int index, - double &scalar_IC, - dealii::Vector &vector_IC) {}; - - // Function to set the non-uniform Dirichlet boundary conditions (in - // ICs_and_BCs.h) - void - setNonUniformDirichletBCs(const dealii::Point &p, - const unsigned int index, - const unsigned int direction, - const double time, - double &scalar_BC, - dealii::Vector &vector_BC) {}; - -private: - // RHS implementation for explicit solve - void - getRHS(const MatrixFree &data, - std::vector &dst, - const std::vector &src, - const std::pair &cell_range) const {}; - - // Function to set the RHS of the governing equations for explicit time - // dependent equations (in equations.h) - void - explicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const {}; - - // Function to set the RHS of the governing equations for all other equations - // (in equations.h) - void - nonExplicitEquationRHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const {}; - - // Function to set the LHS of the governing equations (in equations.h) - void - equationLHS( - variableContainer> &variable_list, - dealii::Point> q_point_loc) const {}; -}; - -template -bool -unitTest::test_setRigidBodyModeConstraints( - std::vector rigidBodyModeComponents, - userInputParameters userInputs) -{ - bool pass = false; - std::cout << "\nTesting 'setRigidBodyModeConstraints' with " - << rigidBodyModeComponents.size() << " component(s) needing a constraint...'" - << std::endl; - - // create test problem class object - setRigidBodyModeConstraintsTest test(userInputs); - unsigned int num_constraints; - test.call_setRigidBodyModeConstraints(rigidBodyModeComponents, num_constraints); - - // Add up the total number of constraints across all processors - unsigned int global_num_constraints = rigidBodyModeComponents.size(); - Utilities::MPI::sum(global_num_constraints, MPI_COMM_WORLD); - - // Check if calculated value equals expected value - if (global_num_constraints == rigidBodyModeComponents.size()) - { - pass = true; - } - - char buffer[100]; - snprintf(buffer, - sizeof(buffer), - "Test result for 'setRigidBodyModeConstraints' with %lu " - "component(s) needing a constraint: %u\n", - rigidBodyModeComponents.size(), - pass); - std::cout << buffer; - - return pass; -} diff --git a/tests/unit_tests/unitTest.h b/tests/unit_tests/unitTest.h index a862fd78b..c11df5fdf 100644 --- a/tests/unit_tests/unitTest.h +++ b/tests/unit_tests/unitTest.h @@ -36,6 +36,7 @@ computeStress(const dealii::Table<2, double> &CIJ, #include "../../src/OrderParameterRemapper/OrderParameterRemapper.cc" #include "../../src/SimplifiedGrainRepresentation/SimplifiedGrainRepresentation.cc" #include "../../src/inputFileReader/inputFileReader.cc" +#include "../../src/matrixfree/AdaptiveRefinement.cc" #include "../../src/matrixfree/boundaryConditions.cc" #include "../../src/matrixfree/checkpoint.cc" #include "../../src/matrixfree/computeIntegral.cc" @@ -51,7 +52,6 @@ computeStress(const dealii::Table<2, double> &CIJ, #include "../../src/matrixfree/outputResults.cc" #include "../../src/matrixfree/postprocessor.cc" #include "../../src/matrixfree/reassignGrains.cc" -#include "../../src/matrixfree/refine.cc" #include "../../src/matrixfree/reinit.cc" #include "../../src/matrixfree/setNonlinearEqInitialGuess.cc" #include "../../src/matrixfree/solve.cc" @@ -131,7 +131,6 @@ class unitTest #include "test_outputResults.h" #include "test_parse_line.h" #include "test_setOutputTimeSteps.h" -#include "test_setRigidBodyModeConstraints.h" #include "variableAttributeLoader_test.cc" #include "../../include/SolverParameters.h" diff --git a/tests/unit_tests/unit_test_results.txt b/tests/unit_tests/unit_test_results.txt index e12090502..463ab3429 100644 --- a/tests/unit_tests/unit_test_results.txt +++ b/tests/unit_tests/unit_test_results.txt @@ -1,2 +1,2 @@ -23 -24 +22 +22