diff --git a/.gitignore b/.gitignore index f4dd1f61b..cc966aa2e 100644 --- a/.gitignore +++ b/.gitignore @@ -56,7 +56,7 @@ main-debug main #Output files -*.vtk +applications/*/*.vtk *.vtu *.vts *.frt diff --git a/applications/precipitateEvolution_pfunction/CMakeLists.txt b/applications/precipitateEvolution_pfunction/CMakeLists.txt deleted file mode 100644 index 916a7f00e..000000000 --- a/applications/precipitateEvolution_pfunction/CMakeLists.txt +++ /dev/null @@ -1,165 +0,0 @@ -## -# CMake script for the PRISMS-PF applications -# Adapted from the ASPECT CMake file -## - -cmake_minimum_required(VERSION 3.3.0) - -project(myapp) - -message(STATUS "") -message(STATUS "=========================================================") -message(STATUS "Configuring PRISMS-PF application") -message(STATUS "=========================================================") -message(STATUS "") - -# Setup the build type (debug, release, debugrelease) -if("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CMAKE_BUILD_TYPE "DebugRelease" - CACHE STRING - "Choose the type of build, options are: Debug, Release and DebugRelease." - FORCE) -endif() - -# Convert build type into the debug and release builds, which may or may -# not be built. -if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR - "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR - "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease" ) - message(STATUS "Setting up PRISMS-PF application for ${CMAKE_BUILD_TYPE} mode.") -else() - message(FATAL_ERROR - "CMAKE_BUILD_TYPE must either be 'Release', 'Debug', or 'DebugRelease', but is set to '${CMAKE_BUILD_TYPE}'.") -endif() - -if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR - "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease") - set(PRISMS_PF_BUILD_DEBUG "ON") -else() - set(PRISMS_PF_BUILD_DEBUG "OFF") -endif() - -if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR - "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease") - set(PRISMS_PF_BUILD_RELEASE "ON") -else() - set(PRISMS_PF_BUILD_RELEASE "OFF") -endif() - -# Find deal.II installation -find_package(deal.II 9.6.0 QUIET - HINTS ${DEAL_II_DIR} $ENV{DEAL_II_DIR} - ) -if(NOT ${deal.II_FOUND}) - message(FATAL_ERROR "\n*** Could not find a recent version of deal.II. ***\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake " - "or set an environment variable \"DEAL_II_DIR\" that contains a path to a " - "recent version of deal.II." - ) -endif() - -message(STATUS "Found deal.II version ${DEAL_II_PACKAGE_VERSION} at '${deal.II_DIR}'") - -set(DEALII_INSTALL_VALID ON) - -if(NOT DEAL_II_WITH_P4EST) - message(SEND_ERROR - "\n**deal.II was built without support for p4est!\n" - ) - set(DEALII_INSTALL_VALID OFF) -endif() - -if(NOT DEALII_INSTALL_VALID) - message(FATAL_ERROR - "\nPRISMS-PF requires a deal.II installation with certain features enabled!\n" - ) -endif() - -deal_ii_initialize_cached_variables() - -# Make and ninja build options -if(CMAKE_GENERATOR MATCHES "Ninja") - set(_make_command "$ ninja") -else() - set(_make_command " $ make") -endif() - -# Debug and release targets -if(${DEAL_II_BUILD_TYPE} MATCHES "DebugRelease") - add_custom_target(release - COMMAND ${CMAKE_COMMAND} -D CMAKE_BUILD_TYPE=Release . - COMMAND ${CMAKE_COMMAND} -E echo "***" - COMMAND ${CMAKE_COMMAND} -E echo "*** Switched to Release mode. Now recompile with: ${_make_command}" - COMMAND ${CMAKE_COMMAND} -E echo "***" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - VERBATIM - COMMENT "switching to RELEASE mode..." - ) - - add_custom_target(debug - COMMAND ${CMAKE_COMMAND} -D CMAKE_BUILD_TYPE=Debug . - COMMAND ${CMAKE_COMMAND} -E echo "***" - COMMAND ${CMAKE_COMMAND} -E echo "*** Switched to Debug mode. Now recompile with: ${_make_command}" - COMMAND ${CMAKE_COMMAND} -E echo "***" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - VERBATIM - COMMENT "switching to DEBUG mode..." - ) - - add_custom_target(debugrelease - COMMAND ${CMAKE_COMMAND} -D CMAKE_BUILD_TYPE=DebugRelease . - COMMAND ${CMAKE_COMMAND} -E echo "***" - COMMAND ${CMAKE_COMMAND} -E echo "*** Switched to Debug and Release mode. Now recompile with: ${_make_command}" - COMMAND ${CMAKE_COMMAND} -E echo "***" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - VERBATIM - COMMENT "switching to DEBUG/RELEASE mode..." - ) -endif() - -# Add distclean target to clean build -add_custom_target(distclean - COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean - COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles - COMMAND ${CMAKE_COMMAND} -E remove - CMakeCache.txt cmake_install.cmake Makefile - build.ninja rules.ninja .ninja_deps .ninja_log - COMMENT "distclean invoked" - ) - -# 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(TARGET_SRC "${CMAKE_SOURCE_DIR}/../main.cc") - -# Check if there has been updates to main library -set(dir ${PROJECT_SOURCE_DIR}/../..) -EXECUTE_PROCESS(COMMAND "rm" "CMakeCache.txt" WORKING_DIRECTORY ${dir}) -EXECUTE_PROCESS(COMMAND "cmake" "CMakeLists.txt" WORKING_DIRECTORY ${dir}) -EXECUTE_PROCESS(COMMAND "make" WORKING_DIRECTORY ${dir}) - -# Set targets & link libraries for the build type -if(${PRISMS_PF_BUILD_DEBUG} STREQUAL "ON") - add_executable(main_debug ${TARGET_SRC}) - set_property(TARGET main_debug PROPERTY OUTPUT_NAME main-debug) - deal_ii_setup_target(main_debug DEBUG) - target_link_libraries(main_debug ${CMAKE_SOURCE_DIR}/../../libprisms-pf-debug.a) -endif() - -if(${PRISMS_PF_BUILD_RELEASE} STREQUAL "ON") - add_executable(main_release ${TARGET_SRC}) - set_property(TARGET main_release PROPERTY OUTPUT_NAME main) - deal_ii_setup_target(main_release RELEASE) - target_link_libraries(main_release ${CMAKE_SOURCE_DIR}/../../libprisms-pf-release.a) -endif() \ No newline at end of file diff --git a/applications/precipitateEvolution_pfunction/ICs_and_BCs.cc b/applications/precipitateEvolution_pfunction/ICs_and_BCs.cc deleted file mode 100644 index bfb3b7a84..000000000 --- a/applications/precipitateEvolution_pfunction/ICs_and_BCs.cc +++ /dev/null @@ -1,94 +0,0 @@ -// =========================================================================== -// 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/applications/precipitateEvolution_pfunction/PLibrary/.PLibrary.hh.swp b/applications/precipitateEvolution_pfunction/PLibrary/.PLibrary.hh.swp deleted file mode 100644 index eee036601..000000000 Binary files a/applications/precipitateEvolution_pfunction/PLibrary/.PLibrary.hh.swp and /dev/null differ diff --git a/applications/precipitateEvolution_pfunction/PLibrary/Mc.txt b/applications/precipitateEvolution_pfunction/PLibrary/Mc.txt deleted file mode 100644 index d3827e75a..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/Mc.txt +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/applications/precipitateEvolution_pfunction/PLibrary/Mn.txt b/applications/precipitateEvolution_pfunction/PLibrary/Mn.txt deleted file mode 100644 index bd9e0289f..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/Mn.txt +++ /dev/null @@ -1,3 +0,0 @@ -100.0 -100.0 -100.0 diff --git a/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.cc b/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.cc deleted file mode 100644 index 5f03c1aff..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.cc +++ /dev/null @@ -1,217 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: issue-1 -// url: https://github.com/prisms-center/IntegrationTools -// commit: 34f71553d3b1b3cdbbc6a02cfb8be793a16396b5 - -#ifndef PLIBRARY_CC -#define PLIBRARY_CC - -#include "PLibrary.hh" - -#include "pfunct_McV.hh" -#include "pfunct_Mn1V.hh" -#include "pfunct_Mn2V.hh" -#include "pfunct_Mn3V.hh" -#include "pfunct_faV.hh" -#include "pfunct_fbV.hh" - -#include -#include - -namespace PRISMS -{ - - void - PLibrary::checkout(std::string name, PSimpleFunction &simplefunc) - { - typedef PSimpleFunction psf; - if (name == "pfunct_faV_f") - { - simplefunc = psf(pfunct_faV_f()); - return; - } - if (name == "pfunct_faV_grad_0") - { - simplefunc = psf(pfunct_faV_grad_0()); - return; - } - if (name == "pfunct_faV_hess_0_0") - { - simplefunc = psf(pfunct_faV_hess_0_0()); - return; - } - if (name == "pfunct_fbV_f") - { - simplefunc = psf(pfunct_fbV_f()); - return; - } - if (name == "pfunct_fbV_grad_0") - { - simplefunc = psf(pfunct_fbV_grad_0()); - return; - } - if (name == "pfunct_fbV_hess_0_0") - { - simplefunc = psf(pfunct_fbV_hess_0_0()); - return; - } - if (name == "pfunct_McV_f") - { - simplefunc = psf(pfunct_McV_f()); - return; - } - if (name == "pfunct_Mn1V_f") - { - simplefunc = psf(pfunct_Mn1V_f()); - return; - } - if (name == "pfunct_Mn2V_f") - { - simplefunc = psf(pfunct_Mn2V_f()); - return; - } - if (name == "pfunct_Mn3V_f") - { - simplefunc = psf(pfunct_Mn3V_f()); - return; - } - else - throw std::runtime_error("PSimpleFunction< double*, double > " + name + - " was not found in the PLibrary"); - } - - void - PLibrary::checkout(std::string name, PFunction &func) - { - typedef PFunction pf; - if (name == "pfunct_faV") - { - func = pf(pfunct_faV()); - return; - } - if (name == "pfunct_fbV") - { - func = pf(pfunct_fbV()); - return; - } - if (name == "pfunct_McV") - { - func = pf(pfunct_McV()); - return; - } - if (name == "pfunct_Mn1V") - { - func = pf(pfunct_Mn1V()); - return; - } - if (name == "pfunct_Mn2V") - { - func = pf(pfunct_Mn2V()); - return; - } - if (name == "pfunct_Mn3V") - { - func = pf(pfunct_Mn3V()); - return; - } - throw std::runtime_error("PFunction< double*, double > " + name + - " was not found in the PLibrary"); - } - - void - PLibrary::checkout(std::string name, PSimpleBase *&simplefunc) - { - if (name == "pfunct_faV_f") - { - simplefunc = new pfunct_faV_f(); - return; - } - if (name == "pfunct_faV_grad_0") - { - simplefunc = new pfunct_faV_grad_0(); - return; - } - if (name == "pfunct_faV_hess_0_0") - { - simplefunc = new pfunct_faV_hess_0_0(); - return; - } - if (name == "pfunct_fbV_f") - { - simplefunc = new pfunct_fbV_f(); - return; - } - if (name == "pfunct_fbV_grad_0") - { - simplefunc = new pfunct_fbV_grad_0(); - return; - } - if (name == "pfunct_fbV_hess_0_0") - { - simplefunc = new pfunct_fbV_hess_0_0(); - return; - } - if (name == "pfunct_McV_f") - { - simplefunc = new pfunct_McV_f(); - return; - } - if (name == "pfunct_Mn1V_f") - { - simplefunc = new pfunct_Mn1V_f(); - return; - } - if (name == "pfunct_Mn2V_f") - { - simplefunc = new pfunct_Mn2V_f(); - return; - } - if (name == "pfunct_Mn3V_f") - { - simplefunc = new pfunct_Mn3V_f(); - return; - } - throw std::runtime_error("PSimpleBase< double*, double > " + name + - " was not found in the PLibrary"); - } - - void - PLibrary::checkout(std::string name, PFuncBase *&func) - { - if (name == "pfunct_faV") - { - func = new pfunct_faV(); - return; - } - if (name == "pfunct_fbV") - { - func = new pfunct_fbV(); - return; - } - if (name == "pfunct_McV") - { - func = new pfunct_McV(); - return; - } - if (name == "pfunct_Mn1V") - { - func = new pfunct_Mn1V(); - return; - } - if (name == "pfunct_Mn2V") - { - func = new pfunct_Mn2V(); - return; - } - if (name == "pfunct_Mn3V") - { - func = new pfunct_Mn3V(); - return; - } - throw std::runtime_error("PFuncBase< double*, double > " + name + - " was not found in the PLibrary"); - } - -} // namespace PRISMS - -#endif diff --git a/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.hh b/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.hh deleted file mode 100644 index 488e936cc..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/PLibrary.hh +++ /dev/null @@ -1,40 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: issue-1 -// url: https://github.com/prisms-center/IntegrationTools -// commit: 34f71553d3b1b3cdbbc6a02cfb8be793a16396b5 - -#ifndef PLIBRARY_HH -#define PLIBRARY_HH - -#include -#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 &simplefunc); - - 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); - - } // namespace PLibrary - -} // namespace PRISMS - -#endif diff --git a/applications/precipitateEvolution_pfunction/PLibrary/createPLib.py b/applications/precipitateEvolution_pfunction/PLibrary/createPLib.py deleted file mode 100644 index 2c668971d..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/createPLib.py +++ /dev/null @@ -1,90 +0,0 @@ -import os.path -import subprocess -import shutil -import glob -#import math -import os.path -import sys - -# ----------------------------------------------------------------------------------------- -# Function that creates a PFunction using the IntegrationToolsWriter command line interface -# ----------------------------------------------------------------------------------------- -# Inputs: -# f_name = The name the function is referred to in the code that calls the PLibrary -# var = The variable(s) used in the function express, should match the variable names in the code that calls the PLibrary -# expression = The expression for the desired function in terms of "var" -# need_grad = Flag set to true if the gradient of the expression is needed, false if not -# need_hess = Flag set to true if the hessian of the expression is needed, false if not -# dir = Directory to write the PFunction to - -def write_pfunction(f_name, var, var_name, expression, need_grad, need_hess, dir): - f_writer_string = 'fw -n ' + f_name + ' -v ' + var + ' -d ' + var_name + ' --sym "'+ expression +'"' - if need_grad == True: - f_writer_string += " --grad " - if need_hess == True: - f_writer_string += " --hess " - - f_writer_string += ' -l '+dir - - subprocess.call([f_writer_string],shell=True) - -# ----------------------------------------------------------------------------------------- -# Function that creates a PLibrary using the IntegrationTools command line interface -# ----------------------------------------------------------------------------------------- -# Inputs: -# data_type = Data type for the container holding the PLibrary -# pfunction_dir = Directory containing the PFunctions to be assembled into the PLibrary -# plibrary_dir = Directory where the PLibrary should be written - -def write_plibrary(data_type, pfunction_dir, plibrary_dir): - #l_writer_string = 'lw -d ' + pfunction_dir + ' -v "'+ data_type + '" -l '+ plibrary_dir +' -c --include ""' - l_writer_string = 'lw -d ' + pfunction_dir + ' -l ' + plibrary_dir - - - - print l_writer_string - - subprocess.call([l_writer_string],shell=True) - -# ----------------------------------------------------------------------------------------- -# Main script to generate a PLibrary -# ----------------------------------------------------------------------------------------- - -# Get parameters that will be placed in the library (eventually through the MC API, currently in text files) -coeff_file = open('fa.txt','r') -fa_coeffs = coeff_file.read().splitlines() -coeff_file.close() - -coeff_file = open('fb.txt','r') -fb_coeffs = coeff_file.read().splitlines() -coeff_file.close() - -CH_mobility_file = open('Mc.txt','r') -Mc = CH_mobility_file.read() -CH_mobility_file.close() - -AC_mobility_file = open('Mn.txt','r') -Mn = AC_mobility_file.read().splitlines() -AC_mobility_file.close() - -# Get the current directory, which is where the PFunctions and PLibrary will be created -dir = os.getcwd() - -# Write PFunctions for the free energies and their first two derivatives -write_pfunction("pfunct_faV", "c", "concentration", fa_coeffs[0]+'*c^4 +'+fa_coeffs[1]+'*c^3 + '+fa_coeffs[2]+'*c^2 +'+fa_coeffs[3]+'*c +'+fa_coeffs[4], True, True, dir) -write_pfunction("pfunct_fbV", "c", "concentration", fb_coeffs[0]+'*c^2 +'+fb_coeffs[1]+'*c +'+fb_coeffs[2], True, True, dir) - -# Write a PFunction for the Cahn-Hilliard mobility -write_pfunction("pfunct_McV", "c", "concentration", Mc, False, False, dir) - -# Write PFunctions for the Allen-Cahn mobilities -write_pfunction("pfunct_Mn1V", "n1", "concentration", Mn[0], False, False, dir) -write_pfunction("pfunct_Mn2V", "n2", "concentration", Mn[1], False, False, dir) -write_pfunction("pfunct_Mn3V", "n3", "concentration", Mn[2], False, False, dir) - -# Write the PLibrary -#write_plibrary("dealii::VectorizedArray", dir, dir) -write_plibrary("double", dir, dir) - - - diff --git a/applications/precipitateEvolution_pfunction/PLibrary/fa.txt b/applications/precipitateEvolution_pfunction/PLibrary/fa.txt deleted file mode 100644 index 9630fe8d3..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/fa.txt +++ /dev/null @@ -1,5 +0,0 @@ -1.3687 --2.7375 -5.1622 --4.776 --1.6704 diff --git a/applications/precipitateEvolution_pfunction/PLibrary/fb.txt b/applications/precipitateEvolution_pfunction/PLibrary/fb.txt deleted file mode 100644 index 5617ed23c..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/fb.txt +++ /dev/null @@ -1,3 +0,0 @@ -5.0 --5.9746 --1.5924 diff --git a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh b/applications/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh deleted file mode 100644 index 24892f24c..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh +++ /dev/null @@ -1,141 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_McV_HH -#define pfunct_McV_HH - -#include -#include -#include - -namespace PRISMS -{ - 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 deleted file mode 100644 index 05e6dd063..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn1V.hh +++ /dev/null @@ -1,141 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_Mn1V_HH -#define pfunct_Mn1V_HH - -#include -#include -#include - -namespace PRISMS -{ - 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 deleted file mode 100644 index 7439b6093..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn2V.hh +++ /dev/null @@ -1,141 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_Mn2V_HH -#define pfunct_Mn2V_HH - -#include -#include -#include - -namespace PRISMS -{ - 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 deleted file mode 100644 index ae765e522..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_Mn3V.hh +++ /dev/null @@ -1,141 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_Mn3V_HH -#define pfunct_Mn3V_HH - -#include -#include -#include - -namespace PRISMS -{ - 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 deleted file mode 100644 index 8b9d14008..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_faV.hh +++ /dev/null @@ -1,300 +0,0 @@ -// created: 2017-1-11 12:28:13 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_faV_HH -#define pfunct_faV_HH - -#include -#include -#include - -namespace PRISMS -{ - 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 deleted file mode 100644 index dcf1f9ef2..000000000 --- a/applications/precipitateEvolution_pfunction/PLibrary/pfunct_fbV.hh +++ /dev/null @@ -1,291 +0,0 @@ -// created: 2017-1-11 12:28:13 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_fbV_HH -#define pfunct_fbV_HH - -#include -#include -#include - -namespace PRISMS -{ - 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 deleted file mode 100644 index 2985af610..000000000 --- a/applications/precipitateEvolution_pfunction/customPDE.h +++ /dev/null @@ -1,129 +0,0 @@ -#include - -using namespace dealii; - -// Header files for PFunctions -typedef VectorizedArray scalarvalueType; -#include "PLibrary/PLibrary.cc" -#include "PLibrary/PLibrary.hh" - -#include - -// Declare the PFunctions to be used -PFunctions::pFunction pfunct_McV("pfunct_McV"), pfunct_Mn1V("pfunct_Mn1V"), - pfunct_Mn2V("pfunct_Mn1V"), pfunct_Mn3V("pfunct_Mn1V"), pfunct_faV("pfunct_faV"), - pfunct_fbV("pfunct_fbV"); - -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 - - 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 - // ================================================================ - - 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/applications/precipitateEvolution_pfunction/equations.cc b/applications/precipitateEvolution_pfunction/equations.cc deleted file mode 100644 index edaa6603b..000000000 --- a/applications/precipitateEvolution_pfunction/equations.cc +++ /dev/null @@ -1,558 +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, - "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); - } - - // Cahn-Hilliard mobility - scalarvalueType McV = pfunct_McV.val(c); - - // Allen-Cahn mobilities - scalarvalueType Mn1V = pfunct_Mn1V.val(c); - scalarvalueType Mn2V = pfunct_Mn2V.val(c); - scalarvalueType Mn3V = pfunct_Mn3V.val(c); - - // Free energy expressions and interpolation functions - scalarvalueType faV = pfunct_faV.val(c); - scalarvalueType facV = pfunct_faV.grad(c, 0); - scalarvalueType faccV = pfunct_faV.hess(c, 0, 0); - scalarvalueType fbV = pfunct_fbV.val(c); - scalarvalueType fbcV = pfunct_fbV.grad(c, 0); - scalarvalueType fbccV = pfunct_fbV.hess(c, 0, 0); - - 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/applications/precipitateEvolution_pfunction/formulation_precipitateEvolution.pdf b/applications/precipitateEvolution_pfunction/formulation_precipitateEvolution.pdf deleted file mode 100644 index ed7299858..000000000 Binary files a/applications/precipitateEvolution_pfunction/formulation_precipitateEvolution.pdf and /dev/null differ diff --git a/applications/precipitateEvolution_pfunction/parameters.prm b/applications/precipitateEvolution_pfunction/parameters.prm deleted file mode 100644 index 3bfb60b87..000000000 --- a/applications/precipitateEvolution_pfunction/parameters.prm +++ /dev/null @@ -1,192 +0,0 @@ -# ================================================================================= -# 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 - -# 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/applications/precipitateEvolution_pfunction/postprocess.cc b/applications/precipitateEvolution_pfunction/postprocess.cc deleted file mode 100644 index 077889a5c..000000000 --- a/applications/precipitateEvolution_pfunction/postprocess.cc +++ /dev/null @@ -1,187 +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, 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 = pfunct_faV.val(c); - scalarvalueType fbV = pfunct_fbV.val(c); - 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/applications/precipitateEvolution_pfunction/tex_files/precipitateEvolution.tex b/applications/precipitateEvolution_pfunction/tex_files/precipitateEvolution.tex deleted file mode 100644 index 34d911e7e..000000000 --- a/applications/precipitateEvolution_pfunction/tex_files/precipitateEvolution.tex +++ /dev/null @@ -1,444 +0,0 @@ -% *********************************************************** -% ******************* PHYSICS HEADER ************************ -% *********************************************************** -% Version 2 -\documentclass[11pt]{article} -\usepackage{amsmath} % AMS Math Package -\usepackage{amsthm} % Theorem Formatting -\usepackage{amssymb} % Math symbols such as \mathbb -\usepackage{graphicx} % Allows for eps images -\usepackage{multicol} % Allows for multiple columns -\usepackage[dvips,letterpaper,margin=0.75in,bottom=0.5in]{geometry} - % Sets margins and page size -\pagestyle{empty} % Removes page numbers -\makeatletter % Need for anything that contains an @ command -\renewcommand{\maketitle} % Redefine maketitle to conserve space -{ \begingroup \vskip 10pt \begin{center} \large {\bf \@title} - \vskip 10pt \end{center} - \vskip 10pt \endgroup \setcounter{footnote}{0} } -\makeatother % End of region containing @ commands -\renewcommand{\labelenumi}{(\alph{enumi})} % Use letters for enumerate -% \DeclareMathOperator{\Sample}{Sample} -\let\vaccent=\v % rename builtin command \v{} to \vaccent{} -\renewcommand{\v}[1]{\ensuremath{\mathbf{#1}}} % for vectors -\newcommand{\gv}[1]{\ensuremath{\mbox{\boldmath$ #1 $}}} -% for vectors of Greek letters -\newcommand{\uv}[1]{\ensuremath{\mathbf{\hat{#1}}}} % for unit vector -\newcommand{\abs}[1]{\left| #1 \right|} % for absolute value -\newcommand{\avg}[1]{\left< #1 \right>} % for average -\let\underdot=\d % rename builtin command \d{} to \underdot{} -\renewcommand{\d}[2]{\frac{d #1}{d #2}} % for derivatives -\newcommand{\dd}[2]{\frac{d^2 #1}{d #2^2}} % for double derivatives -\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}} -% for partial derivatives -\newcommand{\pdd}[2]{\frac{\partial^2 #1}{\partial #2^2}} -% for double partial derivatives -\newcommand{\pdc}[3]{\left( \frac{\partial #1}{\partial #2} - \right)_{#3}} % for thermodynamic partial derivatives -\newcommand{\ket}[1]{\left| #1 \right>} % for Dirac bras -\newcommand{\bra}[1]{\left< #1 \right|} % for Dirac kets -\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| - \left. #2 \vphantom{#1} \right>} % for Dirac brackets -\newcommand{\matrixel}[3]{\left< #1 \vphantom{#2#3} \right| - #2 \left| #3 \vphantom{#1#2} \right>} % for Dirac matrix elements -\newcommand{\grad}[1]{\gv{\nabla} #1} % for gradient -\let\divsymb=\div % rename builtin command \div to \divsymb -\renewcommand{\div}[1]{\gv{\nabla} \cdot #1} % for divergence -\newcommand{\curl}[1]{\gv{\nabla} \times #1} % for curl -\let\baraccent=\= % rename builtin command \= to \baraccent -\renewcommand{\=}[1]{\stackrel{#1}{=}} % for putting numbers above = -\newtheorem{prop}{Proposition} -\newtheorem{thm}{Theorem}[section] -\newtheorem{lem}[thm]{Lemma} -\theoremstyle{definition} -\newtheorem{dfn}{Definition} -\theoremstyle{remark} -\newtheorem*{rmk}{Remark} - -% *********************************************************** -% ********************** END HEADER ************************* -% *********************************************************** - - -\usepackage[noprefix]{nomencl} -\usepackage{amsfonts} -\usepackage{amssymb} -\usepackage{amsmath} - -%--------------------------------------------------------- -% Bold Face Math Characters: -% All In Format: \B***** . -%--------------------------------------------------------- -\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{\mbox{\boldmath$1$}} -\def\bzero{\mbox{\boldmath$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$}} - - - -\makenomenclature -\makeindex -\begin{document} -\centerline{\Large{\bf PRISMS-PF Application Formulation:}} -\smallskip -\centerline{\Large{\bf precipitateEvolution}} -\bigskip - - -\nomenclature[a]{$c$}{Concentration (Cahn-Hilliard order parameter)} -\nomenclature[b]{$\eta$}{Structural order parameter (Allen-Cahn order parameter)} -\nomenclature[c]{$\bE$}{Lagrange strain tensor (Mechanics order parameter)} -\nomenclature[d]{$\Pi$}{Total free energy of the system} -\nomenclature[e]{$F$}{Local free energy density} -\nomenclature[f]{$\mathcal{J}$}{Concentration flux} -\nomenclature[g]{$\mu$}{Chemical potential} -\nomenclature[h]{$\kappa^c$}{Cahn-Hilliard gradient coefficient} -\nomenclature[i]{$\kappa^{\eta}$}{Allen-Cahn gradient coefficient} -\nomenclature[j]{$L^{c}$}{Concentration mobility} -\nomenclature[k]{$L^{\eta}$}{Structural order parameter mobility} -\nomenclature[l]{$\omega$}{Variations over primal field} -\nomenclature[m]{$\mathcal{M}$}{Boundary chemical potential like term} -\nomenclature[n]{$\bn$}{Nomal vector in the current configuration} -\nomenclature[o]{$(\theta,~\phi)$}{Polar angles of the interface normal, $\bn$} -%\centerline{\today} -%\printnomenclature[1cm] -%\vspace{.5in} - -\section{Variational formulation} -The total free energy of the system (neglecting boundary terms) is of the form, -\begin{equation} -\Pi(c, \eta_1, \eta_2, \eta_3, \Bepsilon) = \int_{\Omega} f(c, \eta_1, \eta_2, \eta_3, \Bepsilon) ~dV -\end{equation} -where $c$ is the concentration of the $\beta$ phase, $\eta_p$ are the structural order parameters and $\Bvarepsilon$ is the small strain tensor. $f$, the free energy density is given by -\begin{equation} - f(c, \eta_1, \eta_2, \eta_3, \Bepsilon) = f_{chem}(c, \eta_1, \eta_2, \eta_3) + f_{grad}(\eta_1, \eta_2, \eta_3) + f_{elastic}(c,\eta_1, \eta_2, \eta_3,\Bepsilon) -\end{equation} -where -\begin{gather} -f_{chem}(c, \eta_1, \eta_2, \eta_3) = f_{\alpha}(c) \left( 1- H(\eta_1)-H(\eta_2)-H(\eta_3)\right) + f_{\beta}(c) \left( H(\eta_1) + H(\eta_2) + H(\eta_3)) \right) + W f_{Landau}(\eta_1, \eta_2, \eta_3) \\ -f_{grad}(\eta_1, \eta_2, \eta_3) = \frac{1}{2} \sum_{p=1}^3 \Bkappa^{\eta_p}_{ij} \eta_{p,i} \eta_{p,j} \\ -f_{elastic}(c,\eta_1, \eta_2, \eta_3,\Bepsilon) = \frac{1}{2} \bC_{ijkl}(\eta_1, \eta_2, \eta_3) \left( \Bvarepsilon_{ij} - \Bvarepsilon ^0_{ij}(c, \eta_1, \eta_2, \eta_3) \right)\left( \Bvarepsilon_{kl} - \Bvarepsilon^0_{kl}(c, \eta_1, \eta_2, \eta_3)\right) \\ -\Bvarepsilon^0(c, \eta_1, \eta_2, \eta_3) = H(\eta_1) \Bvarepsilon^0_{\eta_1} (c)+ H(\eta_2) \Bvarepsilon^0_{\eta_2} (c) + H(\eta_3) \Bvarepsilon^0_{\eta_3} (c) \\ -\bC(\eta_1, \eta_2, \eta_3) = H(\eta_1) \bC_{\eta_1}+ H(\eta_2) \bC_{\eta_2} + H(\eta_3) \bC_{\eta_3} + \left( 1- H(\eta_1)-H(\eta_2)-H(\eta_3)\right) \bC_{\alpha} -\end{gather} -Here $\Bvarepsilon^0_{\eta_p}$ are the composition dependent stress free strain transformation tensor corresponding to each structural order parameter. - -\section{Required inputs} -\begin{itemize} -\item $f_{\alpha}(c), f_{\beta}(c)$ - Homogeneous chemical free energy of the components of the binary system, example form given in Appendix I -\item $f_{Landau}(\eta_1, \eta_2, \eta_3)$ - Landau free energy term that controls the interfacial energy and prevents precipitates with different orientation varients from overlapping, example form given in Appendix I -\item $W$ - Barrier height for the Landau free energy term, used to control the thickness of the interface -\item $H(\eta_p)$ - Interpolation function for connecting the $\alpha$ phase and the $p^{th}$ orientation variant of the $\beta$ phase, example form given in Appendix I -\item $\Bkappa^{\eta_p}$ - gradient penalty tensor for the $p^{th}$ orientation variant of the $\beta$ phase -\item $\bC_{\eta_p}$ - fourth order elasticity tensor (or its equivalent second order Voigt representation) for the $p^{th}$ orientation variant of the $\beta$ phase -\item $\bC_{\alpha}$ - fourth order elasticity tensor (or its equivalent second order Voigt representation) for the $\alpha$ phase -\item $\Bvarepsilon^0_{\eta_p}$ - stress free strain transformation tensor for the $p^{th}$ orientation variant of the $\beta$ phase -\end{itemize} -In addition, to drive the kinetics, we need: -\begin{itemize} -\item $M$ - mobility value for the concentration field -\item $L$ - mobility value for the structural order parameter field -\end{itemize} - -\section{Variational treatment} -From the variational derivatives given in Appendix II, we obtain the chemical potentials for the concentration and the structural order parameters: -\begin{align} - \mu_{c} &= f_{\alpha,c} \left( 1- H(\eta_1)-H(\eta_2)-H(\eta_3)\right) +f_{\beta,c} \left( H(\eta_1) + H(\eta_2) + H(\eta_3) \right) + \bC_{ijkl} (- \Bvarepsilon^0_{ij,c}) \left( \Bvarepsilon_{kl} - \Bvarepsilon^0_{kl}\right) \\ - \mu_{\eta_p} &= (f_{\beta}-f_{\alpha})H(\eta_p)_{,\eta_p} + W f_{Landau,\eta_p}- \Bkappa^{\eta_p}_{ij} \eta_{p,ij} + \bC_{ijkl} (- \Bvarepsilon^0_{ij,\eta_p}) \left( \Bvarepsilon_{kl} - \Bvarepsilon^0_{kl}\right) + \frac{1}{2} \bC_{ijkl,\eta_p} \left( \Bvarepsilon_{ij} - \Bvarepsilon ^0_{ij} \right) \left( \Bvarepsilon_{kl} - \Bvarepsilon^0_{kl}\right) -\end{align} - -\section{Kinetics} -Now the PDE for Cahn-Hilliard dynamics is given by: -\begin{align} - \frac{\partial c}{\partial t} &= ~\grad \cdot (M \grad \mu_c) \label{CH_eqn} - \end{align} - and the PDE for Allen-Cahn dynamics is given by: - \begin{align} - \frac{\partial \eta_p}{\partial t} &= - L \mu_{\eta_p} \label{AC_eqn} -\end{align} -where $M$ and $L$ are the constant mobilities. - -\section{Mechanics} -Considering variations on the displacement $u$ of the from $u+\epsilon w$, we have -\begin{align} -\delta_u \Pi &= \int_{\Omega} \grad w : \bC(\eta_1, \eta_2, \eta_3) : \left( \Bvarepsilon - \Bvarepsilon^0(c,\eta_1, \eta_2, \eta_3)\right) ~dV = 0 \\ -\end{align} -where $\Bsigma = \bC(\eta_1, \eta_2, \eta_3) : \left( \Bvarepsilon - \Bvarepsilon^0(c,\eta_1, \eta_2, \eta_3)\right)$ is the stress tensor. \\ - -Now consider\\ -\begin{align} -R &= \int_{\Omega} \grad w : \bC(\eta_1, \eta_2, \eta_3) : \left( \Bvarepsilon - \Bvarepsilon^0(c,\eta_1, \eta_2, \eta_3)\right) ~dV = 0 -\end{align} -We solve for $R=0$ using a gradient scheme which involves the following linearization: -\begin{align} -R~|_{u}+ \frac{\delta R}{\delta u} \Delta u &= 0 \\ -\Rightarrow \frac{\delta R}{\delta 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{\delta R}{\delta u}$, $x=\Delta u$ and the right hand side (RHS) is $b=-R~|_{u}$. - - -\section{Time discretization} -Using forward Euler explicit time stepping, equations \ref{CH_eqn} and \ref{AC_eqn} become: -\begin{align} -c^{n+1} = c^{n}+\Delta t [\nabla \cdot (M \nabla \mu_c) ]\\ -\eta_p^{n+1} = \eta_p^n -\Delta t L \mu_{\eta_p} -\end{align} - -\section{Weak formulation and residual expressions} -\subsection{The Cahn-Hillard and Allen-Cahn equations} -Writing equations \ref{CH_eqn} and \ref{AC_eqn} in the weak form, with the arbirary variation given by $w$ yields: -\begin{align} -\int_\Omega w c^{n+1} dV &= \int_\Omega wc^{n}+w \Delta t [\nabla \cdot (M \nabla \mu_c) ] dV \label{CH_weak} \\ -%&= \int_\Omega w\underbrace{c^{n}}_{r_c}+\nabla w \cdot (\underbrace{\Delta t M \nabla \mu_c}_{r_{cx}} ) dV \\ -\int_\Omega w \eta_p^{n+1} dV &= \int_\Omega w \eta_p^{n}-w \Delta t L \mu_{\eta_p} dV \label{AC_weak} -%&= \int_\Omega w\underbrace{c^{n}}_{r_c}+\nabla w \cdot (\underbrace{\Delta t M \nabla \mu_c}_{r_{cx}} ) dV -\end{align} - -The gradient of $\mu_c$ is: -\begin{equation} -\begin{split} -\nabla \mu_c = & \nabla c \left[f_{\alpha,cc}+ \sum_{p=1}^3 H(\eta_p)(f_{\beta,cc}-f_{\alpha,cc}) \right]+ \sum_{p=1}^3 \nabla \eta_p H(\eta_p)_{,\eta_p} (f_{\beta,c}-f_{\alpha,c}) \\ -&+ \left[ \sum_{p=1}^3 (C_{ijkl}^{\eta_p} - C_{ijkl}^{\alpha} )\nabla \eta_p H(\eta_p)_{,\eta_p} \right](-\epsilon_{ij,c}^0)(\epsilon_{ij} - \epsilon_{ij}^0) \\ -&- C_{ijkl} \left[ \sum_{p=1}^3 H(\eta_p)_{,\eta_p} \epsilon_{ij,c}^{0\eta_p} \nabla \eta_p + H(\eta_p) \epsilon_{ij,cc}^{0\eta_p} \nabla c \right](\epsilon_{kl}-\epsilon_{kl}^0)\\ -&+ C_{ijkl} (-\epsilon_{ij,c}^0) \left[ \nabla \epsilon_{ij} - \left( \sum_{p=1}^3 H(\eta_p)_{,\eta_p} \epsilon_{kl}^{0\eta_p} \nabla \eta_p + H(\eta_p) \epsilon_{kl,c}^{0\eta_p} \nabla c \right) \right] -\end{split} -\end{equation} - -Applying the divergence theorem to equation \ref{CH_weak}, one can derive the residual terms $r_c$ and $r_{cx}$: -\begin{equation} -\int_\Omega w c^{n+1} dV = \int_\Omega w\underbrace{c^{n}}_{r_c}+\nabla w \cdot (\underbrace{-\Delta t M \nabla \mu_c}_{r_{cx}} ) dV -\end{equation} - -Expanding $\mu_{\eta_p}$ in equation \ref{AC_weak} and applying the divergence theorem yields the residual terms $r_{\eta_p}$ and $r_{\eta_p x}$: -\begin{equation} -\begin{split} -\int_\Omega w \eta_p^{n+1} dV &= \\ -&\int_\Omega w \Bigg\{\underbrace{\eta_p^{n}-\Delta t L \bigg[(f_{\beta}-f_{\alpha})H(\eta_p^n)_{,\eta_p} + W f_{Landau,\eta_p} - C_{ijkl} \left( H(\eta_p)_{,\eta_p} \epsilon_{ij}^{0 \eta_p}\right)\left(\epsilon_{kl} - \epsilon_{kl}^{0} \right) }_{r_{\eta_p}} \\ -&\underbrace{+ \frac{1}{2} \left[ (C_{ijkl}^{\eta_p} - C_{ijkl}^{\alpha}) H(\eta_p)_{,\eta_p} \right] \left(\epsilon_{ij} - \epsilon_{ij}^{0} \right) \left(\epsilon_{kl} - \epsilon_{kl}^{0} \right) \bigg] \Bigg\}}_{r_{\eta_p}~cont.} \\ -&+ \nabla w \cdot (\underbrace{-\Delta t L \Bkappa^{\eta_p}_{ij} \eta_{p,i}^n}_{r_{\eta_p x}} ) dV -\end{split} -\end{equation} - -The above values of $r_c$, $r_{cx}$, $r_{\eta_p}$, and $r_{\eta_p x}$are used to define the residuals in the following input file: \\ -$applications/precipitateEvolution/equations.h$ - -\subsection{The mechanical equilbrium equation} -In PRISMS-PF, two sets of residuals are required for elliptic PDEs (such as this one), one for the left-hand side of the equation (LHS) and one for the right-hand side of the equation (RHS). We solve $R=\delta_u \Pi$ by casting this in a form that can be solved as a matrix inversion problem. This will involve a brief detour into the discretized form of the equation. First we derive an expression for the solution, given an initial guess, $u_0$: -\begin{gather} -0 = R(u) = R(u_0 + \Delta u) -\end{gather} -where $\Delta u = u - u_0$. Then, applying the discretization that $u = \sum_i w^i U^i$, we can write the following linearization: -\begin{equation} -\frac{\delta R(u)}{\delta u} \Delta U = -R(u_0) \label{matrix_eqn} -\end{equation} -The discretized form of this equation can be written as a matrix inversion problem. However, in PRISMS-PF, we only care about the product $\frac{\delta R(u)}{\delta u} \Delta U$. Taking the variational derivative of $R(u)$ yields: -\begin{align} -\frac{\delta R(u)}{\delta u} &= \frac{d}{d\alpha} \int_{\Omega} \nabla w :C: \left[ \epsilon (u+\alpha w) - \epsilon^0 \right] ~dV \bigg{|}_{\alpha=0} \\ -&= \int_{\Omega} \nabla w :C: \frac{1}{2}\frac{d}{d\alpha}\left[ \nabla(u+\alpha w) + \nabla(u+\alpha w)^T - \epsilon^0\right] ~dV \bigg{|}_{\alpha=0}\\ -&= \int_{\Omega} \nabla w :C: \frac{d}{d\alpha} \left[ \nabla(u+\alpha w) - \epsilon^0 \right] ~dV \bigg{|}_{\alpha=0} \quad (due ~to ~the ~symmetry ~of ~C) \\ -&= \int_{\Omega} \nabla w :C: \nabla w ~dV -\end{align} -In its discretized form $\frac{\delta R(u)}{\delta u} \Delta U$ is: -\begin{equation} -\frac{\delta R(u)}{\delta u} \Delta U = \sum_i \sum_j \int_{\Omega} \nabla N^i : C : \nabla N^j dV ~\Delta U^j -\end{equation} -Moving back to the non-discretized form yields: -\begin{equation} -\frac{\delta R(u)}{\delta u} \Delta U = \int_{\Omega} \nabla w : C : \nabla (\Delta u) dV -\end{equation} -Thus, the full equation relating $u_0$ and $\Delta u$ is: -\begin{equation} -\int_{\Omega} \nabla w : \underbrace{C : \nabla (\Delta u)}_{r_{ux}^{LHS}} dV = -\int_{\Omega} \grad w : \underbrace{\sigma}_{r_{ux}} ~dV -\end{equation} -The above values of $r_{ux}^{LHS}$ and $r_{ux}$ are used to define the residuals in the following input file: \\ -$applications/precipitateEvolution/equations.h$ - -\section{Appendix I: Example functions for $f_{\alpha}$, $f_{\beta}$, $f_{Landau}$, $H(\eta_p)$ } -\begin{gather} -f_{\alpha}(c) = A_{2, \alpha} c^2 + A_{1, \alpha} c + A_{0, \alpha} \\ -f_{\beta}(c) = A_{2, \beta} c^2 + A_{1, \beta} c + A_{0, \beta} \\ -f_{Landau}(\eta_1, \eta_2, \eta_3) = (\eta_1^2 + \eta_2^2 + \eta_3^2) - 2(\eta_1^3 + \eta_2^3 + \eta_3^3) + (\eta_1^4 + \eta_2^4 + \eta_3^4) + 5 (\eta_1^2 \eta_2^2 + \eta_2^2 \eta_3^2 + \eta_1^2 \eta_3^2) + 5(\eta_1^2 \eta_2^2 \eta_3^2) \\ -H(\eta_p) = 3 \eta_p^2 - 2 \eta_p^3 -\end{gather} - -\section{Appendix II: Variational Derivatives} -Variational derivative of $\Pi$ with respect to $\eta_p$ (where $\eta_q$ and $\eta_r$ correspond to the structural order parameters for the other two orientational variants): -\begin{gather} -\delta_{\eta_p} \Pi = \frac{d}{d\alpha} \left[\int_{\Omega} f_{chem}(c,\eta_p+\alpha w,\eta_q,\eta_r) + f_{grad}(\eta_p+\alpha w,\eta_q,\eta_r) + f_{el}(c,\eta_p+\alpha w,\eta_q,\eta_r,\epsilon) dV \right]_{\alpha=0} -\end{gather} -Breaking up each of these terms yields: - -\begin{align} -\begin{split} -\frac{d}{d\alpha} \left[ f_{chem}(c,\eta_p+\alpha w,\eta_q,\eta_r)\right]_{\alpha=0} &= f_{\alpha}(c) \left[ -\frac{\partial H(\eta_p+\alpha w)}{\partial (\eta_p + \alpha w)} \frac{\partial(\eta_p + \alpha w)}{\partial \alpha} \right]_{\alpha=0} \\ -&+f_{\beta}(c) \left[ \frac{\partial H(\eta_p+\alpha w)}{\partial (\eta_p + \alpha w)} \frac{\partial(\eta_p + \alpha w)}{\partial \alpha} \right]_{\alpha=0} \\ -&+ W \left[\frac{\partial f_{Landau}(\eta_p+\alpha w,\eta_q,\eta_r)}{\partial (\eta_p + \alpha w)} \frac{\partial(\eta_p + \alpha w)}{\partial \alpha} \right]_{\alpha=0}\\ -\\ -&=f_{\alpha}(c) \left[ -\frac{\partial H(\eta_p)}{\partial \eta_p} w \right] -+f_{\beta}(c) \left[ \frac{\partial H(\eta_p)}{\partial \eta_p } w \right] -+ W \left[\frac{\partial f_{Landau}(\eta_p,\eta_q,\eta_r)}{\partial \eta_p} w \right] -\end{split} -\end{align} - -\begin{align} -\begin{split} -\frac{d}{d\alpha} \left[ f_{grad}(\eta_p+\alpha w,\eta_q,\eta_r)\right]_{\alpha=0} &= \frac{1}{2} \left[ \kappa_{ij}^{\eta_p} (\eta_p+\alpha w)_{,i}(\eta_p+\alpha w)_{,j} +\kappa_{ij}^{\eta_q} (\eta_q)_{,i}(\eta_q)_{,j} + \kappa_{ij}^{\eta_r} (\eta_r)_{,i}(\eta_r)_{,j} \right]_{\alpha=0} \\ -\\ -&= \kappa_{ij} w_{,i} \eta_{p,j} -\end{split} -\end{align} - -\begin{align} -\begin{split} -\frac{d}{d\alpha} \left[ f_{el}(c,\eta_p+\alpha w,\eta_q,\eta_r,\epsilon)\right]_{\alpha=0} &= \frac{1}{2} \bigg[ \frac{\partial C_{ijkl}(\eta_p+\alpha w,\eta_q,\eta_r)}{\partial (\eta_p + \alpha w)} \frac{\partial(\eta_p + \alpha w)}{\partial \alpha} \\ -&\cdot\big (\epsilon_{ij}-\epsilon_{ij}^0 (c,\eta_p+\alpha w,\eta_q,\eta_r)\big) \big(\epsilon_{kl}-\epsilon_{kl}^0 (c,\eta_p+\alpha w,\eta_q,\eta_r)\big) \\ -&+ C_{ijkl}(\eta_p+\alpha w,\eta_q,\eta_r) \bigg (-\frac{\partial\epsilon_{ij}^0 (c,\eta_p+\alpha w,\eta_q,\eta_r)}{\partial (\eta_p + \alpha w)} \frac{\partial(\eta_p + \alpha w)}{\partial \alpha} \bigg) \\ &\cdot \big(\epsilon_{kl}-\epsilon_{kl}^0 (c,\eta_p+\alpha w,\eta_q,\eta_r)\big) \\ -&+ C_{ijkl}(\eta_p+\alpha w,\eta_q,\eta_r) \big(\epsilon_{ij}-\epsilon_{ij}^0 (c,\eta_p+\alpha w,\eta_q,\eta_r)\big) \\ -&\cdot\bigg (-\frac{\partial\epsilon_{kl}^0 (c,\eta_p+\alpha w,\eta_q,\eta_r)}{\partial (\eta_p + \alpha w)} \frac{\partial(\eta_p + \alpha w)}{\partial \alpha} \bigg)\bigg]_{\alpha=0} \\ -\\ -&= \frac{1}{2} \bigg[ \frac{\partial C_{ijkl}(\eta_p,\eta_q,\eta_r)}{\partial \eta_p} w \big(\epsilon_{ij}-\epsilon_{ij}^0 (c,\eta_p,\eta_q,\eta_r) \big) \big(\epsilon_{kl}-\epsilon_{kl}^0 (c,\eta_p,\eta_q,\eta_r) \big) \bigg] \\ -&+ C_{ijkl}(\eta_p,\eta_q,\eta_r) \bigg (-\frac{\partial\epsilon_{ij}^0 (c,\eta_p,\eta_q,\eta_r)}{\partial \eta_p} w \bigg) \big(\epsilon_{kl}-\epsilon_{kl}^0 (c,\eta_p,\eta_q,\eta_r)\big) \\ -\end{split} -\end{align} - -Putting the terms back together yields: -\begin{gather} -\begin{split} -\delta_{\eta_p} \Pi &= \int_{\Omega} f_{\alpha}(c) \left[ -\frac{\partial H(\eta_p)}{\partial \eta_p} w \right] +f_{\beta}(c) \left[ \frac{\partial H(\eta_p)}{\partial \eta_p } w \right] -+ W \left[\frac{\partial f_{Landau}(\eta_p,\eta_q,\eta_r)}{\partial \eta_p} w \right] \\ -&+ \kappa_{ij} w_{,i} \eta_{p,j} \\ -&+\frac{1}{2} \bigg[ \frac{\partial C_{ijkl}(\eta_p,\eta_q,\eta_r)}{\partial (\eta_p)} w \big(\epsilon_{ij}-\epsilon_{ij}^0 (c,\eta_p,\eta_q,\eta_r) \big) \big(\epsilon_{kl}-\epsilon_{kl}^0 (c,\eta_p,\eta_q,\eta_r) \big) \bigg] \\ -&+ C_{ijkl}(\eta_p,\eta_q,\eta_r) \bigg (-\frac{\partial\epsilon_{ij}^0 (c,\eta_p,\eta_q,\eta_r)}{\partial \eta_p} w \bigg) \big(\epsilon_{kl}-\epsilon_{kl}^0 (c,\eta_p,\eta_q,\eta_r)\big) ~dV -\end{split} -\end{gather} - -Variational derivative of $\Pi$ with respect to $c$ : -\begin{gather} -\delta_{c} \Pi = \frac{d}{d\alpha} \left[\int_{\Omega} f_{chem}(c+\alpha w,\eta_p,\eta_q,\eta_r) + f_{grad}(\eta_p,\eta_q,\eta_r) + f_{el}(c+\alpha w,\eta_p,\eta_q,\eta_r,\epsilon) dV \right]_{\alpha=0} -\end{gather} -Breaking up each of these terms yields: -\begin{align} -\begin{split} -\frac{d}{d\alpha} \left[ f_{chem}(c+\alpha w,\eta_p,\eta_q,\eta_r)\right]_{\alpha=0} &= \bigg[ \frac{\partial f_{\alpha}(c + \alpha w)}{\partial(c+\alpha w)} \frac{\partial(c+\alpha w)}{\partial \alpha} \left(1-\sum_{p=1}^3 H(\eta_p)\right) \\ -&+ \frac{\partial f_{\beta}(c+\alpha w)}{\partial(c+\alpha w)} \frac{\partial(c+\alpha w)}{\partial \alpha} \left(\sum_{p=1}^3 H(\eta_p)\right) + W \frac{\partial f_{Landau}(\eta_p,\eta_q,\eta_r)}{\partial(c+\alpha w)} \frac{\partial(c+\alpha w)}{\partial \alpha} \bigg]_{\alpha=0} -\\ -&= \frac{\partial f_{\alpha}(c)}{\partial c} w \left(1-\sum_{p=1}^3 H(\eta_p)\right) +\frac{\partial f_{\beta}(c)}{\partial c} w \left(\sum_{p=1}^3 H(\eta_p)\right) -\end{split} -\end{align} - -\begin{align} -\frac{d}{d\alpha} \left[ f_{grad}(\eta_p,\eta_q,\eta_r)\right]_{\alpha=0} = 0 -\end{align} - -\begin{align} -\begin{split} -\frac{d}{d\alpha} \left[ f_{el}(c+\alpha w,\eta_p,\eta_q,\eta_r,\epsilon)\right]_{\alpha=0} &= \frac{1}{2} C_{ijkl}(\eta_p,\eta_q,\eta_r) \bigg[ -\frac{\partial \epsilon_{ij}^0 (c+\alpha w,\eta_p,\eta_q,\eta_r)}{\partial (c + \alpha w)} \frac{\partial(c + \alpha w)}{\partial \alpha} \big(\epsilon_{kl}-\epsilon_{kl}^0 (c+\alpha w,\eta_p,\eta_q,\eta_r)\big) \\ -&- \big(\epsilon_{ij}-\epsilon_{ij}^0 (c+\alpha w,\eta_p,\eta_q,\eta_r)\big) \frac{\partial \epsilon_{ij}^0 (c+\alpha w,\eta_p,\eta_q,\eta_r)}{\partial (c + \alpha w)} \frac{\partial(c + \alpha w)}{\partial \alpha} \bigg]_{\alpha=0} \\ -\\ -&= -C_{ijkl}(\eta_p,\eta_q,\eta_r) \frac{\partial \epsilon_{ij}^0 (c,\eta_p,\eta_q,\eta_r)}{\partial c} w \big(\epsilon_{kl}-\epsilon_{kl}^0 (c+\alpha w,\eta_p,\eta_q,\eta_r)\big) -\end{split} -\end{align} - -Putting the terms back together yields: -\begin{gather} -\begin{split} -\delta_{c} \Pi &= \int_{\Omega} \frac{\partial f_{\alpha}(c)}{\partial c} w \left(1-\sum_{p=1}^3 H(\eta_p)\right) +\frac{\partial f_{\beta}(c)}{\partial c} w \left(\sum_{p=1}^3 H(\eta_p)\right) \\ -&-C_{ijkl}(\eta_p,\eta_q,\eta_r) \frac{\partial \epsilon_{ij}^0 (c,\eta_p,\eta_q,\eta_r)}{\partial c} w \big(\epsilon_{kl}-\epsilon_{kl}^0 (c+\alpha w,\eta_p,\eta_q,\eta_r)\big) ~dV -\end{split} -\end{gather} - -\end{document} \ No newline at end of file diff --git a/automatic_tests/application_debug_test.py b/automatic_tests/application_debug_test.py index 586f0c0df..6b4663d7e 100644 --- a/automatic_tests/application_debug_test.py +++ b/automatic_tests/application_debug_test.py @@ -215,7 +215,6 @@ def run_tests_in_parallel(application_list): "allenCahn_conserved", "alloySolidification", "precipitateEvolution", - "precipitateEvolution_pfunction", "alloySolidification_uniform", "spinodalDecomposition", "anisotropyFacet", diff --git a/automatic_tests/precipitateEvolution_pfunction/CMakeLists.txt b/automatic_tests/precipitateEvolution_pfunction/CMakeLists.txt deleted file mode 100644 index 4c3907304..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/CMakeLists.txt +++ /dev/null @@ -1,165 +0,0 @@ -## -# CMake script for the PRISMS-PF applications -# Adapted from the ASPECT CMake file -## - -cmake_minimum_required(VERSION 3.3.0) - -project(myapp) - -message(STATUS "") -message(STATUS "=========================================================") -message(STATUS "Configuring PRISMS-PF application") -message(STATUS "=========================================================") -message(STATUS "") - -# Setup the build type (debug, release, debugrelease) -if("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CMAKE_BUILD_TYPE "DebugRelease" - CACHE STRING - "Choose the type of build, options are: Debug, Release and DebugRelease." - FORCE) -endif() - -# Convert build type into the debug and release builds, which may or may -# not be built. -if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR - "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR - "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease" ) - message(STATUS "Setting up PRISMS-PF application for ${CMAKE_BUILD_TYPE} mode.") -else() - message(FATAL_ERROR - "CMAKE_BUILD_TYPE must either be 'Release', 'Debug', or 'DebugRelease', but is set to '${CMAKE_BUILD_TYPE}'.") -endif() - -if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR - "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease") - set(PRISMS_PF_BUILD_DEBUG "ON") -else() - set(PRISMS_PF_BUILD_DEBUG "OFF") -endif() - -if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR - "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease") - set(PRISMS_PF_BUILD_RELEASE "ON") -else() - set(PRISMS_PF_BUILD_RELEASE "OFF") -endif() - -# Find deal.II installation -find_package(deal.II 9.6.0 QUIET - HINTS ${DEAL_II_DIR} $ENV{DEAL_II_DIR} - ) -if(NOT ${deal.II_FOUND}) - message(FATAL_ERROR "\n*** Could not find a recent version of deal.II. ***\n" - "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake " - "or set an environment variable \"DEAL_II_DIR\" that contains a path to a " - "recent version of deal.II." - ) -endif() - -message(STATUS "Found deal.II version ${DEAL_II_PACKAGE_VERSION} at '${deal.II_DIR}'") - -set(DEALII_INSTALL_VALID ON) - -if(NOT DEAL_II_WITH_P4EST) - message(SEND_ERROR - "\n**deal.II was built without support for p4est!\n" - ) - set(DEALII_INSTALL_VALID OFF) -endif() - -if(NOT DEALII_INSTALL_VALID) - message(FATAL_ERROR - "\nPRISMS-PF requires a deal.II installation with certain features enabled!\n" - ) -endif() - -deal_ii_initialize_cached_variables() - -# Make and ninja build options -if(CMAKE_GENERATOR MATCHES "Ninja") - set(_make_command "$ ninja") -else() - set(_make_command " $ make") -endif() - -# Debug and release targets -if(${DEAL_II_BUILD_TYPE} MATCHES "DebugRelease") - add_custom_target(release - COMMAND ${CMAKE_COMMAND} -D CMAKE_BUILD_TYPE=Release . - COMMAND ${CMAKE_COMMAND} -E echo "***" - COMMAND ${CMAKE_COMMAND} -E echo "*** Switched to Release mode. Now recompile with: ${_make_command}" - COMMAND ${CMAKE_COMMAND} -E echo "***" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - VERBATIM - COMMENT "switching to RELEASE mode..." - ) - - add_custom_target(debug - COMMAND ${CMAKE_COMMAND} -D CMAKE_BUILD_TYPE=Debug . - COMMAND ${CMAKE_COMMAND} -E echo "***" - COMMAND ${CMAKE_COMMAND} -E echo "*** Switched to Debug mode. Now recompile with: ${_make_command}" - COMMAND ${CMAKE_COMMAND} -E echo "***" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - VERBATIM - COMMENT "switching to DEBUG mode..." - ) - - add_custom_target(debugrelease - COMMAND ${CMAKE_COMMAND} -D CMAKE_BUILD_TYPE=DebugRelease . - COMMAND ${CMAKE_COMMAND} -E echo "***" - COMMAND ${CMAKE_COMMAND} -E echo "*** Switched to Debug and Release mode. Now recompile with: ${_make_command}" - COMMAND ${CMAKE_COMMAND} -E echo "***" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - VERBATIM - COMMENT "switching to DEBUG/RELEASE mode..." - ) -endif() - -# Add distclean target to clean build -add_custom_target(distclean - COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean - COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles - COMMAND ${CMAKE_COMMAND} -E remove - CMakeCache.txt cmake_install.cmake Makefile - build.ninja rules.ninja .ninja_deps .ninja_log - COMMENT "distclean invoked" - ) - -# 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(TARGET_SRC "${CMAKE_SOURCE_DIR}/../main.cc") - -# Check if there has been updates to main library -set(dir ${PROJECT_SOURCE_DIR}/../../..) -EXECUTE_PROCESS(COMMAND "rm" "CMakeCache.txt" WORKING_DIRECTORY ${dir}) -EXECUTE_PROCESS(COMMAND "cmake" "CMakeLists.txt" WORKING_DIRECTORY ${dir}) -EXECUTE_PROCESS(COMMAND "make" WORKING_DIRECTORY ${dir}) - -# Set targets & link libraries for the build type -if(${PRISMS_PF_BUILD_DEBUG} STREQUAL "ON") - add_executable(main_debug ${TARGET_SRC}) - set_property(TARGET main_debug PROPERTY OUTPUT_NAME main-debug) - deal_ii_setup_target(main_debug DEBUG) - target_link_libraries(main_debug ${CMAKE_SOURCE_DIR}/../../libprisms-pf-debug.a) -endif() - -if(${PRISMS_PF_BUILD_RELEASE} STREQUAL "ON") - add_executable(main_release ${TARGET_SRC}) - set_property(TARGET main_release PROPERTY OUTPUT_NAME main) - deal_ii_setup_target(main_release RELEASE) - target_link_libraries(main_release ${CMAKE_SOURCE_DIR}/../../libprisms-pf-release.a) -endif() \ No newline at end of file diff --git a/automatic_tests/precipitateEvolution_pfunction/ICs_and_BCs.cc b/automatic_tests/precipitateEvolution_pfunction/ICs_and_BCs.cc deleted file mode 100644 index bfb3b7a84..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/ICs_and_BCs.cc +++ /dev/null @@ -1,94 +0,0 @@ -// =========================================================================== -// 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/automatic_tests/precipitateEvolution_pfunction/PLibrary/.PLibrary.hh.swp b/automatic_tests/precipitateEvolution_pfunction/PLibrary/.PLibrary.hh.swp deleted file mode 100644 index eee036601..000000000 Binary files a/automatic_tests/precipitateEvolution_pfunction/PLibrary/.PLibrary.hh.swp and /dev/null differ diff --git a/automatic_tests/precipitateEvolution_pfunction/PLibrary/Mc.txt b/automatic_tests/precipitateEvolution_pfunction/PLibrary/Mc.txt deleted file mode 100644 index d3827e75a..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/Mc.txt +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/automatic_tests/precipitateEvolution_pfunction/PLibrary/Mn.txt b/automatic_tests/precipitateEvolution_pfunction/PLibrary/Mn.txt deleted file mode 100644 index bd9e0289f..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/Mn.txt +++ /dev/null @@ -1,3 +0,0 @@ -100.0 -100.0 -100.0 diff --git a/automatic_tests/precipitateEvolution_pfunction/PLibrary/PLibrary.cc b/automatic_tests/precipitateEvolution_pfunction/PLibrary/PLibrary.cc deleted file mode 100644 index 5f03c1aff..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/PLibrary.cc +++ /dev/null @@ -1,217 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: issue-1 -// url: https://github.com/prisms-center/IntegrationTools -// commit: 34f71553d3b1b3cdbbc6a02cfb8be793a16396b5 - -#ifndef PLIBRARY_CC -#define PLIBRARY_CC - -#include "PLibrary.hh" - -#include "pfunct_McV.hh" -#include "pfunct_Mn1V.hh" -#include "pfunct_Mn2V.hh" -#include "pfunct_Mn3V.hh" -#include "pfunct_faV.hh" -#include "pfunct_fbV.hh" - -#include -#include - -namespace PRISMS -{ - - void - PLibrary::checkout(std::string name, PSimpleFunction &simplefunc) - { - typedef PSimpleFunction psf; - if (name == "pfunct_faV_f") - { - simplefunc = psf(pfunct_faV_f()); - return; - } - if (name == "pfunct_faV_grad_0") - { - simplefunc = psf(pfunct_faV_grad_0()); - return; - } - if (name == "pfunct_faV_hess_0_0") - { - simplefunc = psf(pfunct_faV_hess_0_0()); - return; - } - if (name == "pfunct_fbV_f") - { - simplefunc = psf(pfunct_fbV_f()); - return; - } - if (name == "pfunct_fbV_grad_0") - { - simplefunc = psf(pfunct_fbV_grad_0()); - return; - } - if (name == "pfunct_fbV_hess_0_0") - { - simplefunc = psf(pfunct_fbV_hess_0_0()); - return; - } - if (name == "pfunct_McV_f") - { - simplefunc = psf(pfunct_McV_f()); - return; - } - if (name == "pfunct_Mn1V_f") - { - simplefunc = psf(pfunct_Mn1V_f()); - return; - } - if (name == "pfunct_Mn2V_f") - { - simplefunc = psf(pfunct_Mn2V_f()); - return; - } - if (name == "pfunct_Mn3V_f") - { - simplefunc = psf(pfunct_Mn3V_f()); - return; - } - else - throw std::runtime_error("PSimpleFunction< double*, double > " + name + - " was not found in the PLibrary"); - } - - void - PLibrary::checkout(std::string name, PFunction &func) - { - typedef PFunction pf; - if (name == "pfunct_faV") - { - func = pf(pfunct_faV()); - return; - } - if (name == "pfunct_fbV") - { - func = pf(pfunct_fbV()); - return; - } - if (name == "pfunct_McV") - { - func = pf(pfunct_McV()); - return; - } - if (name == "pfunct_Mn1V") - { - func = pf(pfunct_Mn1V()); - return; - } - if (name == "pfunct_Mn2V") - { - func = pf(pfunct_Mn2V()); - return; - } - if (name == "pfunct_Mn3V") - { - func = pf(pfunct_Mn3V()); - return; - } - throw std::runtime_error("PFunction< double*, double > " + name + - " was not found in the PLibrary"); - } - - void - PLibrary::checkout(std::string name, PSimpleBase *&simplefunc) - { - if (name == "pfunct_faV_f") - { - simplefunc = new pfunct_faV_f(); - return; - } - if (name == "pfunct_faV_grad_0") - { - simplefunc = new pfunct_faV_grad_0(); - return; - } - if (name == "pfunct_faV_hess_0_0") - { - simplefunc = new pfunct_faV_hess_0_0(); - return; - } - if (name == "pfunct_fbV_f") - { - simplefunc = new pfunct_fbV_f(); - return; - } - if (name == "pfunct_fbV_grad_0") - { - simplefunc = new pfunct_fbV_grad_0(); - return; - } - if (name == "pfunct_fbV_hess_0_0") - { - simplefunc = new pfunct_fbV_hess_0_0(); - return; - } - if (name == "pfunct_McV_f") - { - simplefunc = new pfunct_McV_f(); - return; - } - if (name == "pfunct_Mn1V_f") - { - simplefunc = new pfunct_Mn1V_f(); - return; - } - if (name == "pfunct_Mn2V_f") - { - simplefunc = new pfunct_Mn2V_f(); - return; - } - if (name == "pfunct_Mn3V_f") - { - simplefunc = new pfunct_Mn3V_f(); - return; - } - throw std::runtime_error("PSimpleBase< double*, double > " + name + - " was not found in the PLibrary"); - } - - void - PLibrary::checkout(std::string name, PFuncBase *&func) - { - if (name == "pfunct_faV") - { - func = new pfunct_faV(); - return; - } - if (name == "pfunct_fbV") - { - func = new pfunct_fbV(); - return; - } - if (name == "pfunct_McV") - { - func = new pfunct_McV(); - return; - } - if (name == "pfunct_Mn1V") - { - func = new pfunct_Mn1V(); - return; - } - if (name == "pfunct_Mn2V") - { - func = new pfunct_Mn2V(); - return; - } - if (name == "pfunct_Mn3V") - { - func = new pfunct_Mn3V(); - return; - } - throw std::runtime_error("PFuncBase< double*, double > " + name + - " was not found in the PLibrary"); - } - -} // namespace PRISMS - -#endif diff --git a/automatic_tests/precipitateEvolution_pfunction/PLibrary/PLibrary.hh b/automatic_tests/precipitateEvolution_pfunction/PLibrary/PLibrary.hh deleted file mode 100644 index 488e936cc..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/PLibrary.hh +++ /dev/null @@ -1,40 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: issue-1 -// url: https://github.com/prisms-center/IntegrationTools -// commit: 34f71553d3b1b3cdbbc6a02cfb8be793a16396b5 - -#ifndef PLIBRARY_HH -#define PLIBRARY_HH - -#include -#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 &simplefunc); - - 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); - - } // namespace PLibrary - -} // namespace PRISMS - -#endif diff --git a/automatic_tests/precipitateEvolution_pfunction/PLibrary/createPLib.py b/automatic_tests/precipitateEvolution_pfunction/PLibrary/createPLib.py deleted file mode 100644 index 2c668971d..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/createPLib.py +++ /dev/null @@ -1,90 +0,0 @@ -import os.path -import subprocess -import shutil -import glob -#import math -import os.path -import sys - -# ----------------------------------------------------------------------------------------- -# Function that creates a PFunction using the IntegrationToolsWriter command line interface -# ----------------------------------------------------------------------------------------- -# Inputs: -# f_name = The name the function is referred to in the code that calls the PLibrary -# var = The variable(s) used in the function express, should match the variable names in the code that calls the PLibrary -# expression = The expression for the desired function in terms of "var" -# need_grad = Flag set to true if the gradient of the expression is needed, false if not -# need_hess = Flag set to true if the hessian of the expression is needed, false if not -# dir = Directory to write the PFunction to - -def write_pfunction(f_name, var, var_name, expression, need_grad, need_hess, dir): - f_writer_string = 'fw -n ' + f_name + ' -v ' + var + ' -d ' + var_name + ' --sym "'+ expression +'"' - if need_grad == True: - f_writer_string += " --grad " - if need_hess == True: - f_writer_string += " --hess " - - f_writer_string += ' -l '+dir - - subprocess.call([f_writer_string],shell=True) - -# ----------------------------------------------------------------------------------------- -# Function that creates a PLibrary using the IntegrationTools command line interface -# ----------------------------------------------------------------------------------------- -# Inputs: -# data_type = Data type for the container holding the PLibrary -# pfunction_dir = Directory containing the PFunctions to be assembled into the PLibrary -# plibrary_dir = Directory where the PLibrary should be written - -def write_plibrary(data_type, pfunction_dir, plibrary_dir): - #l_writer_string = 'lw -d ' + pfunction_dir + ' -v "'+ data_type + '" -l '+ plibrary_dir +' -c --include ""' - l_writer_string = 'lw -d ' + pfunction_dir + ' -l ' + plibrary_dir - - - - print l_writer_string - - subprocess.call([l_writer_string],shell=True) - -# ----------------------------------------------------------------------------------------- -# Main script to generate a PLibrary -# ----------------------------------------------------------------------------------------- - -# Get parameters that will be placed in the library (eventually through the MC API, currently in text files) -coeff_file = open('fa.txt','r') -fa_coeffs = coeff_file.read().splitlines() -coeff_file.close() - -coeff_file = open('fb.txt','r') -fb_coeffs = coeff_file.read().splitlines() -coeff_file.close() - -CH_mobility_file = open('Mc.txt','r') -Mc = CH_mobility_file.read() -CH_mobility_file.close() - -AC_mobility_file = open('Mn.txt','r') -Mn = AC_mobility_file.read().splitlines() -AC_mobility_file.close() - -# Get the current directory, which is where the PFunctions and PLibrary will be created -dir = os.getcwd() - -# Write PFunctions for the free energies and their first two derivatives -write_pfunction("pfunct_faV", "c", "concentration", fa_coeffs[0]+'*c^4 +'+fa_coeffs[1]+'*c^3 + '+fa_coeffs[2]+'*c^2 +'+fa_coeffs[3]+'*c +'+fa_coeffs[4], True, True, dir) -write_pfunction("pfunct_fbV", "c", "concentration", fb_coeffs[0]+'*c^2 +'+fb_coeffs[1]+'*c +'+fb_coeffs[2], True, True, dir) - -# Write a PFunction for the Cahn-Hilliard mobility -write_pfunction("pfunct_McV", "c", "concentration", Mc, False, False, dir) - -# Write PFunctions for the Allen-Cahn mobilities -write_pfunction("pfunct_Mn1V", "n1", "concentration", Mn[0], False, False, dir) -write_pfunction("pfunct_Mn2V", "n2", "concentration", Mn[1], False, False, dir) -write_pfunction("pfunct_Mn3V", "n3", "concentration", Mn[2], False, False, dir) - -# Write the PLibrary -#write_plibrary("dealii::VectorizedArray", dir, dir) -write_plibrary("double", dir, dir) - - - diff --git a/automatic_tests/precipitateEvolution_pfunction/PLibrary/fa.txt b/automatic_tests/precipitateEvolution_pfunction/PLibrary/fa.txt deleted file mode 100644 index 9630fe8d3..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/fa.txt +++ /dev/null @@ -1,5 +0,0 @@ -1.3687 --2.7375 -5.1622 --4.776 --1.6704 diff --git a/automatic_tests/precipitateEvolution_pfunction/PLibrary/fb.txt b/automatic_tests/precipitateEvolution_pfunction/PLibrary/fb.txt deleted file mode 100644 index 5617ed23c..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/fb.txt +++ /dev/null @@ -1,3 +0,0 @@ -5.0 --5.9746 --1.5924 diff --git a/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh b/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh deleted file mode 100644 index 24892f24c..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_McV.hh +++ /dev/null @@ -1,141 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_McV_HH -#define pfunct_McV_HH - -#include -#include -#include - -namespace PRISMS -{ - 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/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_Mn1V.hh b/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_Mn1V.hh deleted file mode 100644 index 05e6dd063..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_Mn1V.hh +++ /dev/null @@ -1,141 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_Mn1V_HH -#define pfunct_Mn1V_HH - -#include -#include -#include - -namespace PRISMS -{ - 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/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_Mn2V.hh b/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_Mn2V.hh deleted file mode 100644 index 7439b6093..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_Mn2V.hh +++ /dev/null @@ -1,141 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_Mn2V_HH -#define pfunct_Mn2V_HH - -#include -#include -#include - -namespace PRISMS -{ - 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/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_Mn3V.hh b/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_Mn3V.hh deleted file mode 100644 index ae765e522..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_Mn3V.hh +++ /dev/null @@ -1,141 +0,0 @@ -// created: 2017-1-11 12:28:14 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_Mn3V_HH -#define pfunct_Mn3V_HH - -#include -#include -#include - -namespace PRISMS -{ - 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/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_faV.hh b/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_faV.hh deleted file mode 100644 index 8b9d14008..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_faV.hh +++ /dev/null @@ -1,300 +0,0 @@ -// created: 2017-1-11 12:28:13 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_faV_HH -#define pfunct_faV_HH - -#include -#include -#include - -namespace PRISMS -{ - 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/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_fbV.hh b/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_fbV.hh deleted file mode 100644 index dcf1f9ef2..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/PLibrary/pfunct_fbV.hh +++ /dev/null @@ -1,291 +0,0 @@ -// created: 2017-1-11 12:28:13 -// version: master -// url: https://github.com/bpuchala/IntegrationToolsWriter.git -// commit: 13e063c3ac8e8911a726a243fdbd68f291cc58cc - -#ifndef pfunct_fbV_HH -#define pfunct_fbV_HH - -#include -#include -#include - -namespace PRISMS -{ - 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/automatic_tests/precipitateEvolution_pfunction/customPDE.h b/automatic_tests/precipitateEvolution_pfunction/customPDE.h deleted file mode 100644 index 2985af610..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/customPDE.h +++ /dev/null @@ -1,129 +0,0 @@ -#include - -using namespace dealii; - -// Header files for PFunctions -typedef VectorizedArray scalarvalueType; -#include "PLibrary/PLibrary.cc" -#include "PLibrary/PLibrary.hh" - -#include - -// Declare the PFunctions to be used -PFunctions::pFunction pfunct_McV("pfunct_McV"), pfunct_Mn1V("pfunct_Mn1V"), - pfunct_Mn2V("pfunct_Mn1V"), pfunct_Mn3V("pfunct_Mn1V"), pfunct_faV("pfunct_faV"), - pfunct_fbV("pfunct_fbV"); - -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 - - 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 - // ================================================================ - - 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/automatic_tests/precipitateEvolution_pfunction/equations.cc b/automatic_tests/precipitateEvolution_pfunction/equations.cc deleted file mode 100644 index edaa6603b..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/equations.cc +++ /dev/null @@ -1,558 +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, - "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); - } - - // Cahn-Hilliard mobility - scalarvalueType McV = pfunct_McV.val(c); - - // Allen-Cahn mobilities - scalarvalueType Mn1V = pfunct_Mn1V.val(c); - scalarvalueType Mn2V = pfunct_Mn2V.val(c); - scalarvalueType Mn3V = pfunct_Mn3V.val(c); - - // Free energy expressions and interpolation functions - scalarvalueType faV = pfunct_faV.val(c); - scalarvalueType facV = pfunct_faV.grad(c, 0); - scalarvalueType faccV = pfunct_faV.hess(c, 0, 0); - scalarvalueType fbV = pfunct_fbV.val(c); - scalarvalueType fbcV = pfunct_fbV.grad(c, 0); - scalarvalueType fbccV = pfunct_fbV.hess(c, 0, 0); - - 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/automatic_tests/precipitateEvolution_pfunction/gold_integratedFields.txt b/automatic_tests/precipitateEvolution_pfunction/gold_integratedFields.txt deleted file mode 100644 index a540bf6be..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/gold_integratedFields.txt +++ /dev/null @@ -1,7 +0,0 @@ -0 f_tot -2961.102683 -0.6 f_tot -2965.562629 -1.2 f_tot -2965.677538 -1.8 f_tot -2965.781569 -2.4 f_tot -2965.884576 -3 f_tot -2965.976361 -3.6 f_tot -2966.061707 diff --git a/automatic_tests/precipitateEvolution_pfunction/parameters.prm b/automatic_tests/precipitateEvolution_pfunction/parameters.prm deleted file mode 100644 index b9b19c596..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/parameters.prm +++ /dev/null @@ -1,127 +0,0 @@ -# ================================================================================= -# 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 -# ================================================================================= -set Domain size X = 40.0 -set Domain size Y = 40.0 -set Domain size Z = 40.0 - -# ================================================================================= -# Set the element parameters -# ================================================================================= -set Subdivisions X = 3 -set Subdivisions Y = 3 -set Subdivisions Z = 3 - -set Refine factor = 5 - -set Element degree = 2 - -# ================================================================================= -# Set the adaptive mesh refinement parameters -# ================================================================================= -set Mesh adaptivity = true - -set Max refinement level = 5 -set Min refinement level = 1 - -set Steps between remeshing operations = 1000 - -subsection Refinement criterion: n1 - set Criterion type = VALUE - set Value lower bound = 0.01 - set Value upper bound = 0.99 -end - -subsection Refinement criterion: n2 - set Criterion type = VALUE - set Value lower bound = 0.01 - set Value upper bound = 0.99 -end - -subsection Refinement criterion: n3 - set Criterion type = VALUE - set Value lower bound = 0.01 - set Value upper bound = 0.99 -end - -# ================================================================================= -# Set the time step parameters -# ================================================================================= -set Time step = 6.0e-4 - -set Number of time steps = 6000 - -# ================================================================================= -# Set the linear solver parameters -# ================================================================================= - -subsection Linear solver parameters: u - set Tolerance type = ABSOLUTE_RESIDUAL - - set Tolerance value = 5e-3 - - set Maximum linear solver iterations = 1000 -end - -# ================================================================================= -# Set the output parameters -# ================================================================================= -set Output condition = EQUAL_SPACING - -set Number of outputs = 6 - -set Skip print steps = 1000 - -# ================================================================================= -# Set the boundary conditions -# ================================================================================= -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 -# ================================================================================= -# 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/automatic_tests/precipitateEvolution_pfunction/postprocess.cc b/automatic_tests/precipitateEvolution_pfunction/postprocess.cc deleted file mode 100644 index 077889a5c..000000000 --- a/automatic_tests/precipitateEvolution_pfunction/postprocess.cc +++ /dev/null @@ -1,187 +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, 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 = pfunct_faV.val(c); - scalarvalueType fbV = pfunct_fbV.val(c); - 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/automatic_tests/run_automatic_tests.py b/automatic_tests/run_automatic_tests.py index c1973a1af..d6fb7ebcd 100644 --- a/automatic_tests/run_automatic_tests.py +++ b/automatic_tests/run_automatic_tests.py @@ -225,7 +225,6 @@ def run_regression_tests_in_parallel( "coupledCahnHilliardAllenCahn", "grainGrowth", "precipitateEvolution", - "precipitateEvolution_pfunction", "spinodalDecomposition", ] getNewGoldStandardList = [ @@ -238,7 +237,6 @@ def run_regression_tests_in_parallel( False, False, False, - False, ] # Grab cpu information diff --git a/include/field_input/IntegrationTools/PExtern.hh b/include/field_input/IntegrationTools/PExtern.hh deleted file mode 100644 index 0000442d1..000000000 --- a/include/field_input/IntegrationTools/PExtern.hh +++ /dev/null @@ -1,2 +0,0 @@ -#include "extern/PExtern.hh" -#include "extern/PLibraryExtern.hh" \ No newline at end of file diff --git a/include/field_input/IntegrationTools/PField.hh b/include/field_input/IntegrationTools/PField.hh index 8dff31c78..134878c72 100644 --- a/include/field_input/IntegrationTools/PField.hh +++ b/include/field_input/IntegrationTools/PField.hh @@ -1,2 +1,2 @@ -#include "pfield/Body.hh" -#include "pfield/Coordinate.hh" \ No newline at end of file +#include +#include \ No newline at end of file diff --git a/include/field_input/IntegrationTools/PFunction.hh b/include/field_input/IntegrationTools/PFunction.hh deleted file mode 100644 index 9098e8bd5..000000000 --- a/include/field_input/IntegrationTools/PFunction.hh +++ /dev/null @@ -1,9 +0,0 @@ -#include "datastruc/PNDArray.hh" -#include "pfunction/PBasisSet.hh" -#include "pfunction/PBasisSetBase.hh" -#include "pfunction/PFlexFunction.hh" -#include "pfunction/PFuncBase.hh" -#include "pfunction/PFunction.hh" -#include "pfunction/PSeriesFunction.hh" -#include "pfunction/PSimpleBase.hh" -#include "pfunction/PSimpleFunction.hh" \ No newline at end of file diff --git a/include/field_input/IntegrationTools/PPieceWise.hh b/include/field_input/IntegrationTools/PPieceWise.hh deleted file mode 100644 index 23c7288be..000000000 --- a/include/field_input/IntegrationTools/PPieceWise.hh +++ /dev/null @@ -1,4 +0,0 @@ -#include "piecewise/PPieceWiseFuncBase.hh" -#include "piecewise/PPieceWiseSimpleBase.hh" -#include "piecewise/Piece.hh" -#include "piecewise/SimplePiece.hh" diff --git a/include/field_input/IntegrationTools/datastruc/Bin.hh b/include/field_input/IntegrationTools/datastruc/Bin.hh index ac1c1137a..21d876fe8 100644 --- a/include/field_input/IntegrationTools/datastruc/Bin.hh +++ b/include/field_input/IntegrationTools/datastruc/Bin.hh @@ -1,246 +1,196 @@ - #ifndef Bin_HH #define Bin_HH -#include "PNDArray.hh" - #include +#include #include -namespace PRISMS +/** + * \brief A class for binning things. + * + * \tparam T typename thats being binned. + * \tparam Coordinate class. + */ +template +class Bin { - - /// 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 +private: + 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() = default; + + /// 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 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) + { + _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++) + { + if (singlebin[i] == newitem) + { + return; + } + } + + 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) + { + int i; + std::vector index_min(_item.order()); + std::vector index_max(_item.order()); + indices(min, index_min); + indices(max, index_max); + + _indices = index_min; + + while (true) + { + _item(_indices).push_back(newitem); + + i = 0; + while (_indices[i] == index_max[i]) + { + i++; + if (i == _item.order()) + { + return; + } + } + + _indices[i]++; + + for (i = i - 1; i >= 0; i--) + { + _indices[i] = index_min[i]; + } + } + } + + 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++) + { + 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]); + } + } + + /// 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) { - 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) - { - indices(coord, _indices); - std::vector &singlebin = _item(_indices); - for (int i = 0; i < singlebin.size(); i++) - { - if (singlebin[i] == newitem) - { - return; - } - } - - 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= 0; i--) - { - _indices[i] = index_min[i]; - } - /////////////// - } - - // 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++) - { - // 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]); - } - } - - /// 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++) - { - // 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]); - } - } - } - }; - -} // namespace PRISMS + for (int i = 0; i < _item.order(); i++) + { + if ((coord[i] < _min[i]) || (coord[i] > _max[i])) + throw std::domain_error("Invalid coord, out of bin range"); + + if (std::floor((coord[i] - _min[i]) / _incr[i]) == + (coord[i] - _min[i]) / _incr[i]) + { + term[i] = std::floor((coord[i] - _min[i]) / _incr[i]); + term[i]--; + } + else + { + term[i] = std::floor((coord[i] - _min[i]) / _incr[i]); + } + } + } +}; #endif diff --git a/include/field_input/IntegrationTools/datastruc/PNDArray.hh b/include/field_input/IntegrationTools/datastruc/PNDArray.hh index 1de524573..a5fe2fce2 100644 --- a/include/field_input/IntegrationTools/datastruc/PNDArray.hh +++ b/include/field_input/IntegrationTools/datastruc/PNDArray.hh @@ -1,4 +1,3 @@ - #ifndef PNDArray_HH #define PNDArray_HH @@ -6,171 +5,171 @@ #include #include -namespace PRISMS +/** + * \brief A Tensor class, takes int valued IndexContainer and returns OutType value. + */ +template +class PNDArray { +private: + 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) + { + resize(dim); + } + + [[nodiscard]] 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; + } + + [[nodiscard]] int + order() const + { + return _order; + } + + [[nodiscard]] 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; + } + + [[nodiscard]] const std::vector & + dim() const + { + return _dim; + } + + [[nodiscard]] 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)]; + } - /// A Tensor class, - /// takes int valued IndexContainer and returns OutType value - /// - template - class PNDArray + template + int + linear_index(const IndexContainer &term) const { - 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) - { - resize(dim); - } - - [[nodiscard]] 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; - } - - [[nodiscard]] int - order() const - { - return _order; - } - - [[nodiscard]] 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; - } - - [[nodiscard]] const std::vector & - dim() const - { - return _dim; - } - - [[nodiscard]] 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++) + 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]; - } - } - - private: - int - calc_volume(const std::vector &dim) - { - if (dim.size() == 0) - { - return 0; - } - - int vol = 1; - for (unsigned int i = 0; i < dim.size(); i++) - { - 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--) + } + 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]; + } + } + +private: + int + calc_volume(const std::vector &dim) + { + if (dim.empty()) + { + return 0; + } + + int vol = 1; + for (int i : dim) + { + vol *= 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/field_input/IntegrationTools/extern/PExtern.hh b/include/field_input/IntegrationTools/extern/PExtern.hh deleted file mode 100644 index e193a6002..000000000 --- a/include/field_input/IntegrationTools/extern/PExtern.hh +++ /dev/null @@ -1,511 +0,0 @@ - -#ifndef PExtern_HH -#define PExtern_HH - -#include "../PField.hh" -#include "../PFunction.hh" -#include -#include -#include -#include - -// 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); -} - -#endif \ No newline at end of file diff --git a/include/field_input/IntegrationTools/extern/PLibraryExtern.hh b/include/field_input/IntegrationTools/extern/PLibraryExtern.hh deleted file mode 100644 index d2a27768a..000000000 --- a/include/field_input/IntegrationTools/extern/PLibraryExtern.hh +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef PLIBRARY_HH -#define PLIBRARY_HH - -#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 &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/field_input/IntegrationTools/pfield/Body.hh b/include/field_input/IntegrationTools/pfield/Body.hh index 9d28d0201..e6c13ea1f 100644 --- a/include/field_input/IntegrationTools/pfield/Body.hh +++ b/include/field_input/IntegrationTools/pfield/Body.hh @@ -1,8 +1,8 @@ #ifndef Body_HH #define Body_HH -#include "./Mesh.hh" -#include "./PField.hh" +#include +#include #include #include #include @@ -11,8 +11,9 @@ namespace PRISMS { - /// A class for a Body: a combination of Mesh and Field(s)) - /// + /** + * \brief A class for a Body-a combination of Mesh and Field(s)-used in file read-in. + */ template class Body { @@ -21,109 +22,82 @@ namespace PRISMS std::vector> scalar_field; - // std::vector< PField, DIM > > vector_field; + /** + * \brief Constructor. + */ + Body() = default; - // std::vector< PField, DIM > > tensor_field; - - // ---------------------------------------------------------- - // 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 - /// + /** + * \brief Read from a 2D/3D vtk file with quad/hex elements + */ void read_vtk(const std::string &vtkfile) { - std::cout << "Begin reading unstructured vtk file" << std::endl; - - // read in vtk file here - std::ifstream infile_mesh(vtkfile.c_str()); - - // read mesh info - mesh.read_vtk(infile_mesh); - + // Read vtk file std::ifstream infile(vtkfile.c_str()); + if (!infile.is_open()) + { + throw std::runtime_error("Could not open VTK file: " + vtkfile); + } - // read point data - std::istringstream ss; - std::string str, name, type, line; - int numcomp; - unsigned long int Npoints, u, p; + // Read mesh info + mesh.read_vtk(infile); - while (!infile.eof()) + // Read point data + std::istringstream ss; + std::string str; + std::string name; + std::string type; + std::string line; + int numcomp = 0; + unsigned long int Npoints = 0; + + while (std::getline(infile, line)) { - std::getline(infile, line); - - if (line[0] == 'P') + // Check for Point data + if (line.rfind("POINT_DATA", 0) == 0) { - if (line.size() > 9 && line.substr(0, 10) == "POINT_DATA") - { - // std::cout << line << "\n"; - ss.clear(); - ss.str(line); - ss >> str >> Npoints; - } + ss.clear(); + ss.str(line); + ss >> str >> Npoints; } - if (line[0] == 'S') + // Check for Scalar data + if (line.rfind("SCALARS", 0) == 0) { - 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); - - // read data - std::cout << "begin reading data" << std::endl; + ss.clear(); + ss.str(line); + ss >> str >> name >> type >> numcomp; - std::vector gid(Npoints); - for (unsigned int i = 0; i < Npoints; i++) - { - infile >> gid[i]; - // std::cout << data[i] << std::endl; - } - std::cout << " done" << std::endl; + // Skip LOOKUP_TABLE line that follows SCALAR line + std::getline(infile, line); - // 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 > 2) - { - 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, - gid, - 0.0)); - std::cout << " done" << std::endl; + // Read data + std::vector gid(Npoints); + for (auto &value : gid) + { + infile >> value; + } - gid.clear(); - // + // Check dim + switch (DIM) + { + case 1: + throw std::runtime_error( + "1D dimensional vtk read-in is not currently supported."); + break; + case 2: + break; + case 3: + break; + default: + throw std::runtime_error("Invalid dimension for vtk read-in."); } + + // Construct field + scalar_field.emplace_back(name, mesh, gid, 0.0); } } - - infile.close(); } void @@ -284,36 +258,13 @@ namespace PRISMS } data.clear(); - // MPI_Barrier(MPI_COMM_WORLD); - - // 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 > 2) - { - 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, - gid, - 0.0)); + scalar_field.push_back( + PField(name, mesh, gid, 0.0)); std::cout << " done" << std::endl; gid.clear(); - // } } } @@ -327,11 +278,17 @@ namespace PRISMS for (unsigned int i = 0; i < scalar_field.size(); i++) { if (scalar_field[i].name() == name) - return scalar_field[i]; + { + return scalar_field[i]; + } } throw std::invalid_argument("Could not find scalar_field named '" + name + "'"); } }; + + template class Body; + template class Body; + } // namespace PRISMS #endif diff --git a/include/field_input/IntegrationTools/pfield/Coordinate.hh b/include/field_input/IntegrationTools/pfield/Coordinate.hh index b2fc93c5f..1c31188e8 100644 --- a/include/field_input/IntegrationTools/pfield/Coordinate.hh +++ b/include/field_input/IntegrationTools/pfield/Coordinate.hh @@ -1,42 +1,56 @@ - #ifndef Coordinate_HH #define Coordinate_HH +#include + namespace PRISMS { - /// 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 + /** + * \brief 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 { - float _coord[DIM]; - public: + /** + * \brief Get the number of dimensions. + */ [[nodiscard]] int size() const { - return DIM; + return dim; } + /** + * \brief Get the ith coordinate. + */ float & operator[](int i) { - return _coord[i]; + return coordinate[i]; } + /** + * \brief Get a const reference to the ith coordinate. + */ const float & operator[](int i) const { - return _coord[i]; + return coordinate[i]; } + /** + * \brief Friend function for output stream. + */ template friend std::ostream & operator<<(std::ostream &outstream, const Coordinate &coord); + + private: + float coordinate[dim]; }; template diff --git a/include/field_input/IntegrationTools/pfield/Mesh.hh b/include/field_input/IntegrationTools/pfield/Mesh.hh index 413d369e4..adb994a24 100644 --- a/include/field_input/IntegrationTools/pfield/Mesh.hh +++ b/include/field_input/IntegrationTools/pfield/Mesh.hh @@ -1,14 +1,16 @@ - #ifndef Mesh_HH #define Mesh_HH -#include "../datastruc/Bin.hh" -#include "../pfunction/PFuncBase.hh" -#include "./interpolation/Hexahedron.hh" -#include "./interpolation/Interpolator.hh" -#include "./interpolation/Quad.hh" +#include + #include +#include #include +#include +#include +#include +#include +#include #include #include @@ -19,32 +21,22 @@ namespace PRISMS 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); - } + AssertThrow(name == "Quad", + dealii::ExcMessage( + "Error in construct_basis_function (2D): unknown name: " + name)); + + bfunc = new Quad(); } 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); - } + AssertThrow(name == "Hexahedron", + dealii::ExcMessage( + "Error in construct_basis_function (3D): unknown name: " + name)); + + bfunc = new Hexahedron(); } template @@ -57,34 +49,27 @@ namespace PRISMS const std::vector &cell_node, const std::vector> &node) { - if (name == "Quad") - { - Interpolator *interp_ptr; - - // 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 + AssertThrow(name == "Quad", + dealii::ExcMessage( + "Error in construct_interpolating_function (2D): unknown name: " + + name)); + + Interpolator *interp_ptr = nullptr; + + 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++) { - std::cout << "Error in construct_interpolating_function (2D): unknown name: " - << name << std::endl; - exit(1); + interp.push_back(interp_ptr); + interp.back() = new PRISMS::QuadValues(cell_node[j], + cell, + bfunc_ptr, + node[cell_node[j]], + dim, + j); } } @@ -98,71 +83,66 @@ namespace PRISMS const std::vector &cell_node, const std::vector> &node) { - if (name == "Hexahedron") - { - 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); - } - } - else + AssertThrow(name == "Hexahedron", + dealii::ExcMessage( + "Error in construct_interpolating_function (3D): unknown name: " + + name)); + + 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++) { - std::cout << "Error in construct_interpolating_function (3D): unknown name: " - << name << std::endl; - exit(1); + interp.push_back(interp_ptr); + interp.back() = new PRISMS::HexahedronValues(cell_node[j], + cell, + bfunc_ptr, + node[cell_node[j]], + dim, + j); } } /// A template class for a finite element mesh /// Needs: Coordinate::operator[]() for use in Bin /// - template + template class Mesh { // min and max coordinate of cuboid surrounding the body - PRISMS::Coordinate _min; - PRISMS::Coordinate _max; + PRISMS::Coordinate _min; + PRISMS::Coordinate _max; /// Vector of nodal coordinates /// nodal values live in 'Field' class /// - std::vector> _node; + 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; + 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>, double> *> _bfunc; + std::vector>, double> *> _bfunc; /// bin of interpolating functions (this might be updated to be either Element or /// Spline Bins) /// - Bin *, Coordinate> _bin; + Bin *, Coordinate> _bin; public: - // still need a constructor - Mesh() {}; + Mesh() = default; ~Mesh() { @@ -180,204 +160,163 @@ namespace PRISMS void read_vtk(std::ifstream &infile) { - std::cout << "Read unstructured mesh" << std::endl; - std::istringstream ss; - std::string line, str, type; + std::string line; + std::string str; + std::string type; - unsigned int uli_dummy; - double d_dummy; + unsigned int uli_dummy = 0; + double d_dummy = NAN; - unsigned long int Npoints, Ncells, Ncell_numbers, u; + unsigned long int Npoints = 0; + unsigned long int Ncells = 0; + unsigned long int Ncell_numbers = 0; std::vector cell_node; - PRISMS::Coordinate _coord; + PRISMS::Coordinate coord; std::vector min; std::vector N; std::vector incr; - while (!infile.eof()) + while (std::getline(infile, line)) { - std::getline(infile, line); - // std::cout << "line: " << line << std::endl; - - if (line[0] == 'P') + // read POINTS info: + if (line.compare(0, 6, "POINTS") == 0) { - // 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 header line + ss.clear(); + ss.str(line); + ss >> str >> Npoints >> type; - // read points - std::vector> value(DIM); - std::vector> hist(DIM); + // 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++) + _node.reserve(Npoints); + for (unsigned int i = 0; i < Npoints; i++) + { + if (dim == 2) { - if (DIM == 2) - { - infile >> _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 < DIM; j++) - add_once(value[j], hist[j], _coord[j]); - _node.push_back(_coord); + infile >> coord[0] >> coord[1] >> d_dummy; + } + else if (dim == 3) + { + infile >> coord[0] >> coord[1] >> coord[2]; } - std::cout << " done" << std::endl; - - // create bins - std::cout << "Determine Body size" << std::endl; - for (int j = 0; j < DIM; j++) + for (int j = 0; j < dim; j++) { - 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())); - - // get min and max surrounding coordinates - _min[j] = value[j][0]; - _max[j] = value[j].back(); - - // for short term, expand bin to avoid edge issues - min[j] -= incr[j]; - N[j] += 2; + add_once(value[j], hist[j], coord[j]); } - 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; + _node.push_back(coord); } - } - else if (line[0] == 'C') - { - if (line.size() > 4 && line.substr(0, 5) == "CELLS") + // create bins + for (int j = 0; j < dim; j++) { - // std::cout << line << "\n"; - ss.clear(); - ss.str(line); + std::sort(value[j].begin(), value[j].end()); + 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())); + + // get min and max surrounding coordinates + _min[j] = value[j][0]; + _max[j] = value[j].back(); + + // for short term, expand bin to avoid edge issues + min[j] -= incr[j]; + N[j] += 2; + } - ss >> str >> Ncells >> Ncell_numbers; + _bin = Bin *, Coordinate>(min, incr, N); + } - PFuncBase>, double> *bfunc_ptr; - _bfunc.push_back(bfunc_ptr); + if (line.compare(0, 5, "CELLS") == 0) + { + ss.clear(); + ss.str(line); - 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(); + ss >> str >> Ncells >> Ncell_numbers; - std::cout << "Read CELLS: " << Ncells << std::endl; - for (unsigned int i = 0; i < Ncells; i++) - { - infile >> uli_dummy; + PFuncBase>, double> *bfunc_ptr = + nullptr; + _bfunc.push_back(bfunc_ptr); - cell_node.resize(uli_dummy); - for (unsigned int j = 0; j < uli_dummy; j++) - { - infile >> cell_node[j]; - } + 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(); - // std::cout << cell_node[0] << " " << cell_node[1] << " " << - // cell_node[2] << " " << cell_node[3] << std::endl; + for (unsigned int i = 0; i < Ncells; i++) + { + infile >> uli_dummy; - // 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); - } + cell_node.resize(uli_dummy); + for (unsigned int j = 0; j < uli_dummy; j++) + { + infile >> cell_node[j]; } - std::cout << " done" << std::endl; - - // bin interpolators - std::cout << "Bin interpolating functions" << std::endl; - for (unsigned int i = 0; i < _interp.size(); i++) + // create interpolator + if (dim == 2) { - _bin.add_range(_interp[i], _interp[i]->min(), _interp[i]->max()); + 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 max_bin_size: " << _bin.max_size() << std::endl; } - else if (line.size() > 9 && line.substr(0, 10) == "CELL_TYPES") + + // bin interpolators + for (unsigned int i = 0; i < _interp.size(); i++) { - // std::cout << line << "\n"; - ss.clear(); - ss.str(line); + _bin.add_range(_interp[i], _interp[i]->min(), _interp[i]->max()); + } + } + else if (line.size() > 9 && line.substr(0, 10) == "CELL_TYPES") + { + // 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 < Ncells; i++) - { - infile >> uli_dummy; + for (unsigned int i = 0; i < Ncells; i++) + { + infile >> uli_dummy; - 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); - } + 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); } - - return; } + + return; } } } @@ -401,7 +340,7 @@ namespace PRISMS unsigned long int Npoints, Ncells, Ncell_numbers, u; std::vector cell_node; - PRISMS::Coordinate _coord; + PRISMS::Coordinate _coord; std::vector min; std::vector N; @@ -487,15 +426,15 @@ namespace PRISMS if (mesh_as_points) { - std::vector> value(DIM); - std::vector> hist(DIM); + std::vector> value(dim); + std::vector> hist(dim); - if (DIM > 2) + if (dim > 2) { Npoints = 8 * (x_coord.size() - 1) * (y_coord.size() - 1) * (z_coord.size() - 1); } - if (DIM == 2) + if (dim == 2) { Npoints = 4 * (x_coord.size() - 1) * (y_coord.size() - 1); } @@ -504,7 +443,7 @@ namespace PRISMS std::vector COORD_X(Npoints), COORD_Y(Npoints), COORD_Z(Npoints); u = 0; //(defined at the beginning of read_vtk) - if (DIM > 2) + if (dim > 2) { for (unsigned int i = 0; i < (z_coord.size() - 1); i++) { @@ -550,7 +489,7 @@ namespace PRISMS } } - if (DIM == 2) + if (dim == 2) { for (unsigned int j = 0; j < (y_coord.size() - 1); j++) { @@ -582,12 +521,12 @@ namespace PRISMS { _coord[0] = COORD_X[i]; _coord[1] = COORD_Y[i]; - if (DIM > 2) + if (dim > 2) { _coord[2] = COORD_Z[i]; } - for (int m = 0; m < DIM; m++) + for (int m = 0; m < dim; m++) add_once(value[m], hist[m], _coord[m]); _node.push_back(_coord); @@ -603,7 +542,7 @@ namespace PRISMS std::cout << "point coordinates done" << std::endl; std::cout << "Determine Body size" << std::endl; - for (int j = 0; j < DIM; j++) + for (int j = 0; j < dim; j++) { std::sort(value[j].begin(), value[j].end()); // std::cout << "j: " << j << " back(): " << value[j].back() << std::endl; @@ -620,41 +559,41 @@ namespace PRISMS N[j] += 2; } std::cout << " Min Coordinate: "; - for (int j = 0; j < DIM; j++) + 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++) + 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); + _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) + if (dim == 2) { Ncells = (_node.size() / 4); } - else if (DIM > 2) + else if (dim > 2) { Ncells = (_node.size() / 8); } - PFuncBase>, double> *bfunc_ptr; + PFuncBase>, double> *bfunc_ptr; _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"); } - else if (DIM > 2) + else if (dim > 2) { // add Hexahedron basis function // _interp.reserve(Ncells*8); @@ -664,7 +603,7 @@ namespace PRISMS std::cout << "Read CELLS: " << Ncells << std::endl; - if (DIM > 2) + if (dim > 2) { uli_dummy = 8; } @@ -681,11 +620,11 @@ namespace PRISMS cell_node[j] = i * uli_dummy + j; } - if (DIM == 2) + if (dim == 2) { std::swap(cell_node[2], cell_node[3]); } - if (DIM > 2) + if (dim > 2) { std::swap(cell_node[2], cell_node[3]); std::swap(cell_node[6], cell_node[7]); @@ -694,7 +633,7 @@ namespace PRISMS // << " " << cell_node[3] << std::endl; // create interpolator - if (DIM == 2) + if (dim == 2) { construct_interpolating_functions(_interp, "Quad", @@ -703,7 +642,7 @@ namespace PRISMS cell_node, _node); } - else if (DIM > 2) + else if (dim > 2) { construct_interpolating_functions(_interp, "Hexahedron", @@ -731,7 +670,7 @@ namespace PRISMS void min(Coordinate &coord) { - for (int i = 0; i < DIM; i++) + for (int i = 0; i < dim; i++) { coord[i] = _min[i]; } @@ -740,7 +679,7 @@ namespace PRISMS void max(Coordinate &coord) { - for (int i = 0; i < DIM; i++) + for (int i = 0; i < dim; i++) { coord[i] = _max[i]; } @@ -775,7 +714,7 @@ namespace PRISMS std::vector &node_index, int &s) { - std::vector *> &bin = _bin.contents(coord); + std::vector *> &bin = _bin.contents(coord); s = bin.size(); int i = 0; @@ -797,8 +736,6 @@ namespace PRISMS bfunc[i] = 0.0; } node_index[i] = (*bin[i]).node(); - // std::cout << "i: " << i << " bfunc: " << bfunc[i] << " node: " << - // _node[ node_index[i]] << std::endl; } return; } @@ -807,110 +744,13 @@ namespace PRISMS // bfunc[i] = 0.0; // node_index[i] = (*bin[i]).node(); // } - // std::cout << "i: " << i << " bfunc: " << bfunc[i] << " node: " << _node[ - // node_index[i]] << std::endl; } }; - // 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; - - for (i = 0; i < s; i++) - { - if ((*bin[i]).is_in_range(coord)) - { - element = (*bin[i]).element(); - for (i = 0; i < s; i++) - { - if ((*bin[i]).element() == element) - { - bfunc[i] = (*bin[i]).grad(coord, di); - } - else - { - bfunc[i] = 0.0; - } - node_index[i] = (*bin[i]).node(); - // std::cout << "i: " << i << " bfunc: " << bfunc[i] << " node: " << - // _node[ node_index[i]] << std::endl; - } - return; - } - // else - //{ - // bfunc[i] = 0.0; - // node_index[i] = (*bin[i]).node(); - // } - // std::cout << "i: " << i << " bfunc: " << bfunc[i] << " node: " << _node[ - // node_index[i]] << std::endl; - } - // std::cout << "finish Mesh::grad_basis_functions()" << std::endl; - } - - // 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; - - for (i = 0; i < s; i++) - { - if ((*bin[i]).is_in_range(coord)) - { - element = (*bin[i]).element(); - for (i = 0; i < s; i++) - { - if ((*bin[i]).element() == element) - { - bfunc[i] = (*bin[i]).hess(coord, di, dj); - } - else - { - bfunc[i] = 0.0; - } - node_index[i] = (*bin[i]).node(); - // std::cout << "i: " << i << " bfunc: " << bfunc[i] << " node: " << - // _node[ node_index[i]] << std::endl; - } - return; - } - // else - //{ - // bfunc[i] = 0.0; - // node_index[i] = (*bin[i]).node(); - // } - // std::cout << "i: " << i << " bfunc: " << bfunc[i] << " node: " << _node[ - // node_index[i]] << std::endl; - } - } - private: void add_once(std::vector &list, std::vector &hist, double val) { - // std::cout << "begin add_once()" << std::endl; - for (unsigned int i = 0; i < list.size(); i++) { if (list[i] == val) @@ -922,8 +762,6 @@ namespace PRISMS list.push_back(val); hist.push_back(1); - - // std::cout << "finish add_once()" << std::endl; } }; } // namespace PRISMS diff --git a/include/field_input/IntegrationTools/pfield/PField.hh b/include/field_input/IntegrationTools/pfield/PField.hh index 6026cdd7e..029a7dc97 100644 --- a/include/field_input/IntegrationTools/pfield/PField.hh +++ b/include/field_input/IntegrationTools/pfield/PField.hh @@ -1,9 +1,8 @@ - #ifndef PField_HH #define PField_HH -#include "../pfunction/PFuncBase.hh" -#include "./Mesh.hh" +#include +#include //_name(name), //_var_name(var_name), @@ -34,21 +33,17 @@ namespace PRISMS FieldType _zero; - FieldType _val; - std::vector _grad_val; - std::vector> _hess_val; + FieldType _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) + PField(const std::string &name, + Mesh &mesh, + const std::vector &field, + const FieldType &zero) + : PFuncBase(name) , _mesh(&mesh) , _field(field) , _zero(zero) @@ -57,46 +52,21 @@ namespace PRISMS 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 < DIM; i++) - _hess_val[i].resize(DIM); - } - - // ---------------------------------------------------------- - // Clone - - PField * - clone() const override - { - return new PField(*this); } // ---------------------------------------------------------- // 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 ------------------------------------------ @@ -111,13 +81,6 @@ namespace PRISMS 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]; + return _val; } template @@ -173,29 +101,6 @@ namespace PRISMS (*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 @@ -203,20 +108,6 @@ namespace PRISMS 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/field_input/IntegrationTools/pfield/interpolation/Hexahedron.hh b/include/field_input/IntegrationTools/pfield/interpolation/Hexahedron.hh index dc0067fce..d65b41aec 100644 --- a/include/field_input/IntegrationTools/pfield/interpolation/Hexahedron.hh +++ b/include/field_input/IntegrationTools/pfield/interpolation/Hexahedron.hh @@ -1,12 +1,10 @@ - #ifndef Hexahedron_HH #define Hexahedron_HH -#include "../../pfunction/PFuncBase.hh" -#include "../../pfunction/PSimpleBase.hh" -#include "../../pfunction/PSimpleFunction.hh" -#include "../Coordinate.hh" -#include "./Interpolator.hh" +#include +#include +#include +#include namespace PRISMS { @@ -33,344 +31,22 @@ namespace PRISMS { this->_name = "Hexahedron_f"; } - - [[nodiscard]] Hexahedron_f * - clone() const override - { - return new Hexahedron_f(*this); - } - }; - - class Hexahedron_grad_0 : public PSimpleBase>, double> - { - [[nodiscard]] 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]; - } - - public: - Hexahedron_grad_0() - { - this->_name = "Hexahedron_grad_0"; - } - - [[nodiscard]] Hexahedron_grad_0 * - clone() const override - { - return new Hexahedron_grad_0(*this); - } - }; - - class Hexahedron_grad_1 : public PSimpleBase>, double> - { - [[nodiscard]] 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: - Hexahedron_grad_1() - { - this->_name = "Hexahedron_grad_1"; - } - - [[nodiscard]] Hexahedron_grad_1 * - clone() const override - { - return new Hexahedron_grad_1(*this); - } - }; - - class Hexahedron_grad_2 : public PSimpleBase>, double> - { - [[nodiscard]] 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]; - } - - public: - Hexahedron_grad_2() - { - this->_name = "Hexahedron_grad_2"; - } - - [[nodiscard]] Hexahedron_grad_2 * - clone() const override - { - return new Hexahedron_grad_2(*this); - } - }; - - class Hexahedron_hess_0_0 - : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return 0.0; - } - - public: - Hexahedron_hess_0_0() - { - this->_name = "Hexahedron_hess_0_0"; - } - - [[nodiscard]] Hexahedron_hess_0_0 * - clone() const override - { - return new Hexahedron_hess_0_0(*this); - } - }; - - class Hexahedron_hess_0_1 - : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return var[3][0] * var[3][1] / var[2][0] / var[2][1]; - } - - public: - Hexahedron_hess_0_1() - { - this->_name = "Hexahedron_hess_0_1"; - } - - [[nodiscard]] Hexahedron_hess_0_1 * - clone() const override - { - return new Hexahedron_hess_0_1(*this); - } - }; - - class Hexahedron_hess_0_2 - : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return var[3][0] * var[3][2] / var[2][0] / var[2][2]; - } - - public: - Hexahedron_hess_0_2() - { - this->_name = "Hexahedron_hess_0_2"; - } - - [[nodiscard]] Hexahedron_hess_0_2 * - clone() const override - { - return new Hexahedron_hess_0_2(*this); - } - }; - - class Hexahedron_hess_1_0 - : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return var[3][1] * var[3][0] / var[2][1] / var[2][0]; - } - - public: - Hexahedron_hess_1_0() - { - this->_name = "Hexahedron_hess_1_0"; - } - - [[nodiscard]] Hexahedron_hess_1_0 * - clone() const override - { - return new Hexahedron_hess_1_0(*this); - } - }; - - class Hexahedron_hess_1_1 - : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return 0.0; - } - - public: - Hexahedron_hess_1_1() - { - this->_name = "Hexahedron_hess_1_1"; - } - - [[nodiscard]] Hexahedron_hess_1_1 * - clone() const override - { - return new Hexahedron_hess_1_1(*this); - } - }; - - class Hexahedron_hess_1_2 - : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return var[3][1] * var[3][2] / var[2][1] / var[2][2]; - } - - public: - Hexahedron_hess_1_2() - { - this->_name = "Hexahedron_hess_1_2"; - } - - [[nodiscard]] Hexahedron_hess_1_2 * - clone() const override - { - return new Hexahedron_hess_1_2(*this); - } - }; - - class Hexahedron_hess_2_0 - : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return var[3][2] * var[3][0] / var[2][2] / var[2][0]; - } - - public: - Hexahedron_hess_2_0() - { - this->_name = "Hexahedron_hess_2_0"; - } - - [[nodiscard]] Hexahedron_hess_2_0 * - clone() const override - { - return new Hexahedron_hess_2_0(*this); - } - }; - - class Hexahedron_hess_2_1 - : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return var[3][2] * var[3][1] / var[2][2] / var[2][1]; - } - - public: - Hexahedron_hess_2_1() - { - this->_name = "Hexahedron_hess_2_1"; - } - - [[nodiscard]] Hexahedron_hess_2_1 * - clone() const override - { - return new Hexahedron_hess_2_1(*this); - } - }; - - class Hexahedron_hess_2_2 - : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return 0.0; - } - - public: - Hexahedron_hess_2_2() - { - this->_name = "Hexahedron_hess_2_2"; - } - - [[nodiscard]] 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; + PSimpleBase>, double> *_val; public: Hexahedron() : PFuncBase>, double>() { - construct(); - } - - Hexahedron(const Hexahedron &RHS) - : PFuncBase>, double>(RHS) - { - construct(); + _val = new Hexahedron_f(); } ~Hexahedron() { 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; - } - - [[nodiscard]] Hexahedron * - clone() const override - { - return new Hexahedron(*this); - } - - PSimpleFunction>, double> - simplefunction() const override - { - return PSimpleFunction>, double>(*_val); - } - - PSimpleFunction>, double> - grad_simplefunction(size_type di) const override - { - return PSimpleFunction>, double>(*_grad_val[di]); - } - - PSimpleFunction>, double> - hess_simplefunction(size_type di, size_type dj) const override - { - return PSimpleFunction>, double>( - *_hess_val[di][dj]); } double @@ -379,98 +55,17 @@ namespace PRISMS return (*_val)(var); } - double - grad(const std::vector> &var, size_type di) override - { - return (*_grad_val[di])(var); - } - - double - hess(const std::vector> &var, - size_type di, - size_type dj) override - { - return (*_hess_val[di][dj])(var); - } - void eval(const std::vector> &var) override { (*_val)(var); } - void - eval_grad(const std::vector> &var) override - { - (*_grad_val[0])(var); - (*_grad_val[1])(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 - 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() - { - 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 @@ -569,11 +164,17 @@ namespace PRISMS PRISMS::Coordinate<3> coord = _var[1]; if (_var[3][0] == -1.0) - coord[0] -= _var[2][0]; + { + coord[0] -= _var[2][0]; + } if (_var[3][1] == -1.0) - coord[1] -= _var[2][1]; + { + coord[1] -= _var[2][1]; + } if (_var[3][2] == -1.0) - coord[2] -= _var[2][2]; + { + coord[2] -= _var[2][2]; + } return coord; } @@ -584,11 +185,17 @@ namespace PRISMS PRISMS::Coordinate<3> coord = _var[1]; if (_var[3][0] == 1.0) - coord[0] += _var[2][0]; + { + coord[0] += _var[2][0]; + } if (_var[3][1] == 1.0) - coord[1] += _var[2][1]; + { + coord[1] += _var[2][1]; + } if (_var[3][2] == 1.0) - coord[2] += _var[2][2]; + { + coord[2] += _var[2][2]; + } return coord; } @@ -608,19 +215,8 @@ namespace PRISMS { 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; } @@ -635,24 +231,6 @@ namespace PRISMS _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 diff --git a/include/field_input/IntegrationTools/pfield/interpolation/Interpolator.hh b/include/field_input/IntegrationTools/pfield/interpolation/Interpolator.hh index 8094d6d18..c760162ab 100644 --- a/include/field_input/IntegrationTools/pfield/interpolation/Interpolator.hh +++ b/include/field_input/IntegrationTools/pfield/interpolation/Interpolator.hh @@ -1,9 +1,8 @@ - #ifndef Interpolator_HH #define Interpolator_HH -#include "../../pfunction/PFuncBase.hh" -#include "../Coordinate.hh" +#include +#include namespace PRISMS { @@ -20,8 +19,8 @@ namespace PRISMS // evaluate public: - typedef typename PFuncBase>, double>::size_type - size_type; + using size_type = + typename PFuncBase>, double>::size_type; Interpolator(unsigned long int node, unsigned long int element, @@ -72,20 +71,6 @@ namespace PRISMS 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 diff --git a/include/field_input/IntegrationTools/pfield/interpolation/Quad.hh b/include/field_input/IntegrationTools/pfield/interpolation/Quad.hh index 635b2d8ec..199a8bb37 100644 --- a/include/field_input/IntegrationTools/pfield/interpolation/Quad.hh +++ b/include/field_input/IntegrationTools/pfield/interpolation/Quad.hh @@ -1,12 +1,10 @@ - #ifndef Quad_HH #define Quad_HH -#include "../../pfunction/PFuncBase.hh" -#include "../../pfunction/PSimpleBase.hh" -#include "../../pfunction/PSimpleFunction.hh" -#include "../Coordinate.hh" -#include "./Interpolator.hh" +#include +#include +#include +#include namespace PRISMS { @@ -32,203 +30,24 @@ namespace PRISMS { this->_name = "Quad_f"; } - - [[nodiscard]] Quad_f * - clone() const override - { - return new Quad_f(*this); - } - }; - - class Quad_grad_0 : public PSimpleBase>, double> - { - [[nodiscard]] 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]; - } - - public: - Quad_grad_0() - { - this->_name = "Quad_grad_0"; - } - - [[nodiscard]] Quad_grad_0 * - clone() const override - { - return new Quad_grad_0(*this); - } - }; - - class Quad_grad_1 : public PSimpleBase>, double> - { - [[nodiscard]] 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: - Quad_grad_1() - { - this->_name = "Quad_grad_1"; - } - - [[nodiscard]] Quad_grad_1 * - clone() const override - { - return new Quad_grad_1(*this); - } - }; - - class Quad_hess_0_0 : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return 0.0; - } - - public: - Quad_hess_0_0() - { - this->_name = "Quad_hess_0_0"; - } - - [[nodiscard]] Quad_hess_0_0 * - clone() const override - { - return new Quad_hess_0_0(*this); - } - }; - - class Quad_hess_0_1 : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return var[3][0] * var[3][1] / var[2][0] / var[2][1]; - } - - public: - Quad_hess_0_1() - { - this->_name = "Quad_hess_0_1"; - } - - [[nodiscard]] Quad_hess_0_1 * - clone() const override - { - return new Quad_hess_0_1(*this); - } - }; - - class Quad_hess_1_0 : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return var[3][0] * var[3][1] / var[2][0] / var[2][1]; - } - - public: - Quad_hess_1_0() - { - this->_name = "Quad_hess_1_0"; - } - - [[nodiscard]] Quad_hess_1_0 * - clone() const override - { - return new Quad_hess_1_0(*this); - } - }; - - class Quad_hess_1_1 : public PSimpleBase>, double> - { - [[nodiscard]] double - eval(const std::vector> &var) const override - { - return 0.0; - } - - public: - Quad_hess_1_1() - { - this->_name = "Quad_hess_1_1"; - } - - [[nodiscard]] Quad_hess_1_1 * - clone() const override - { - return new Quad_hess_1_1(*this); - } }; class Quad : public PFuncBase>, double> { - PSimpleBase>, double> *_val; - PSimpleBase>, double> **_grad_val; - PSimpleBase>, double> ***_hess_val; + PSimpleBase>, double> *_val; public: - typedef PFuncBase>, double>::size_type size_type; + using size_type = PFuncBase>, double>::size_type; Quad() : PFuncBase>, double>() { - construct(); - } - - Quad(const Quad &RHS) - : PFuncBase>, double>(RHS) - { - construct(); + _val = new Quad_f(); } ~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; - } - - [[nodiscard]] Quad * - clone() const override - { - return new Quad(*this); - } - - PSimpleFunction>, double> - simplefunction() const override - { - return PSimpleFunction>, double>(*_val); - } - - PSimpleFunction>, double> - grad_simplefunction(size_type di) const override - { - return PSimpleFunction>, double>(*_grad_val[di]); - } - - PSimpleFunction>, double> - hess_simplefunction(size_type di, size_type dj) const override - { - return PSimpleFunction>, double>( - *_hess_val[di][dj]); } double @@ -237,91 +56,17 @@ namespace PRISMS return (*_val)(var); } - double - grad(const std::vector> &var, size_type di) override - { - return (*_grad_val[di])(var); - } - - double - hess(const std::vector> &var, - size_type di, - size_type dj) override - { - return (*_hess_val[di][dj])(var); - } - void eval(const std::vector> &var) override { (*_val)(var); } - void - eval_grad(const std::vector> &var) override - { - (*_grad_val[0])(var); - (*_grad_val[1])(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 - 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() - { - 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 @@ -364,33 +109,21 @@ namespace PRISMS 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; } @@ -402,9 +135,13 @@ namespace PRISMS PRISMS::Coordinate<2> coord = _var[1]; if (_var[3][0] == -1.0) - coord[0] -= _var[2][0]; + { + coord[0] -= _var[2][0]; + } if (_var[3][1] == -1.0) - coord[1] -= _var[2][1]; + { + coord[1] -= _var[2][1]; + } return coord; } @@ -415,9 +152,13 @@ namespace PRISMS PRISMS::Coordinate<2> coord = _var[1]; if (_var[3][0] == 1.0) - coord[0] += _var[2][0]; + { + coord[0] += _var[2][0]; + } if (_var[3][1] == 1.0) - coord[1] += _var[2][1]; + { + coord[1] += _var[2][1]; + } return coord; } @@ -427,33 +168,20 @@ namespace PRISMS { _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]; + double 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!!! + // for the following, you are expected to KNOW that the coord is_in_range!!! double operator()(const Coordinate &coord) override @@ -462,22 +190,6 @@ namespace PRISMS _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 diff --git a/include/field_input/IntegrationTools/pfunction/PBasisSet.hh b/include/field_input/IntegrationTools/pfunction/PBasisSet.hh deleted file mode 100644 index e48a849b9..000000000 --- a/include/field_input/IntegrationTools/pfunction/PBasisSet.hh +++ /dev/null @@ -1,214 +0,0 @@ - -#ifndef PBasisSet_HH -#define PBasisSet_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 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); - } - - // 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 ------------------------------------------ - - 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) - { - std::cout << "Error in PBasisSet::set. RHS == NULL." << std::endl; - exit(1); - } - if (ptr != NULL) - delete ptr; - ptr = RHS; - return *this; - } - - PBasisSet() - { - ptr = NULL; - } - - 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/field_input/IntegrationTools/pfunction/PBasisSetBase.hh b/include/field_input/IntegrationTools/pfunction/PBasisSetBase.hh deleted file mode 100644 index bf96d42da..000000000 --- a/include/field_input/IntegrationTools/pfunction/PBasisSetBase.hh +++ /dev/null @@ -1,214 +0,0 @@ - -#ifndef PBasisSetBase_HH -#define PBasisSetBase_HH - -#include "./PFunction.hh" -#include -#include -#include -#include - -namespace PRISMS -{ - /// 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/field_input/IntegrationTools/pfunction/PFlexFunction.hh b/include/field_input/IntegrationTools/pfunction/PFlexFunction.hh deleted file mode 100644 index f10fcf229..000000000 --- a/include/field_input/IntegrationTools/pfunction/PFlexFunction.hh +++ /dev/null @@ -1,220 +0,0 @@ - -#ifndef PFlexFunction_HH -#define PFlexFunction_HH - -#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 - { - 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(); - } - - 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; - - 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; - } - - 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; - } - - ~PFlexFunction() - {} - - PFlexFunction * - clone() const - { - return new PFlexFunction(*this); - } - - PSimpleFunction - simplefunction() const - { - return _val; - } - - PSimpleFunction - grad_simplefunction(size_type di) const - { - return _grad_val[di]; - } - - PSimpleFunction - hess_simplefunction(size_type di, size_type dj) const - { - return _hess_val[di][dj]; - } - - 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 - 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) - { - 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); - } - } - } - }; - -} // namespace PRISMS - -#endif \ No newline at end of file diff --git a/include/field_input/IntegrationTools/pfunction/PFuncBase.hh b/include/field_input/IntegrationTools/pfunction/PFuncBase.hh index 58b2d30f4..6b5bb8de0 100644 --- a/include/field_input/IntegrationTools/pfunction/PFuncBase.hh +++ b/include/field_input/IntegrationTools/pfunction/PFuncBase.hh @@ -1,8 +1,6 @@ - #ifndef PFuncBase_HH #define PFuncBase_HH -#include "./PSimpleFunction.hh" #include #include #include @@ -17,22 +15,15 @@ namespace PRISMS class PFuncBase { protected: - std::string _name; - std::vector _var_name; - std::vector _var_description; + std::string _name; public: using size_type = std::vector::size_type; - PFuncBase() - {} + PFuncBase() = default; - PFuncBase(const std::string &name, - const std::vector &var_name, - const std::vector &var_description) + PFuncBase(const std::string &name) : _name(name) - , _var_name(var_name) - , _var_description(var_description) {} virtual ~PFuncBase() @@ -44,71 +35,6 @@ namespace PRISMS return _name; } - [[nodiscard]] 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 @@ -118,22 +44,6 @@ namespace PRISMS 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 @@ -143,18 +53,6 @@ namespace PRISMS 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 { @@ -162,20 +60,6 @@ namespace PRISMS 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 diff --git a/include/field_input/IntegrationTools/pfunction/PFunction.hh b/include/field_input/IntegrationTools/pfunction/PFunction.hh deleted file mode 100644 index c2238b225..000000000 --- a/include/field_input/IntegrationTools/pfunction/PFunction.hh +++ /dev/null @@ -1,236 +0,0 @@ - -#ifndef PFunction_HH -#define PFunction_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 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); - } - - // ---------------------------------------------------------- - // 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); - } - - // ---------------------------------------------------------- - // 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); - } - - 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 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) - { - std::cout << "Error in PFunction::set. RHS == NULL." << std::endl; - exit(1); - } - if (ptr != NULL) - delete ptr; - ptr = RHS; - return *this; - } - - PFunction() - { - ptr = NULL; - } - - 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/field_input/IntegrationTools/pfunction/PSeriesFunction.hh b/include/field_input/IntegrationTools/pfunction/PSeriesFunction.hh deleted file mode 100644 index a001ae5fc..000000000 --- a/include/field_input/IntegrationTools/pfunction/PSeriesFunction.hh +++ /dev/null @@ -1,618 +0,0 @@ - -#ifndef PSeriesFunction_HH -#define PSeriesFunction_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 > - /// - 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 - /// - void - set(const std::vector> &basis_set) - { - // std::cout << "begin PSeriesFunction::set()" << std::endl; - 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++) - { - // 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]; - } - } - - 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++) - { - if (i == di) - { - _basis_set[i].eval_grad(var[i]); - } - else - { - _basis_set[i](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++) - { - 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]); - } - } - - // 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]; - } - - // 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++) - { - if (i == di) - { - 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) - { - // evaluate basis functions needed - OutType tmp = _identity_val; - for (int i = 0; i < _coeff.order(); i++) - { - 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]); - } - } - else - { - tmp *= _basis_set[i](term[i], var[i]); - } - } - - return tmp; - } - - // ---------------------------------------------------------- - // Use these functions to evaluate all basis functions, - // then use following methods to access results. - - 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 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++) - { - if (i == di) - { - 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 - { - // evaluate basis function product - OutType tmp = _identity_val; - for (int i = 0; i < _coeff.order(); i++) - { - if (i == di || i == dj) - { - if (di == dj) - { - tmp *= _basis_set[i].hess(term[i]); - } - else - { - tmp *= _basis_set[i].grad(term[i]); - } - } - else - { - tmp *= _basis_set[i](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++) - { - _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++) - { - _coeff.tensor_indices(i, term); - for (int j = 0; j < term.size(); j++) - sout << term[j] << " "; - sout << basis_grad(term, di) << "\n"; - } - } - - void - print_basis_hess(std::ostream &sout, int di, int dj) - { - 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.size(); j++) - sout << term[j] << " "; - sout << basis_hess(term, di, dj) << "\n"; - } - } - - void - print_coeff(std::ostream &sout) - { - 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.size(); j++) - sout << term[j] << " "; - sout << _coeff(i) << "\n"; - } - } - - void - read_coeff(std::istream &sin) - { - // 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++) - { - 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() - { - 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 *= _basis_set[j](tindex[j]); - } - _val += tmp; - } - - 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++) - { - if (j == di) - { - tmp *= _basis_set[j].grad(tindex[j]); - } - else - { - tmp *= _basis_set[j](tindex[j]); - } - } - - _grad_val[di] += tmp; - } - 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++) - { - if (j == di || j == dj) - { - if (di == dj) - { - tmp *= _basis_set[j].hess(tindex[j]); - } - else - { - tmp *= _basis_set[j].grad(tindex[j]); - } - } - else - { - tmp *= _basis_set[j](tindex[j]); - } - } - _hess_val[di][dj] += tmp; - } - return _hess_val[di][dj]; - } - }; - -} // namespace PRISMS - -#endif \ No newline at end of file diff --git a/include/field_input/IntegrationTools/pfunction/PSimpleBase.hh b/include/field_input/IntegrationTools/pfunction/PSimpleBase.hh index da0aebe9b..31746d121 100644 --- a/include/field_input/IntegrationTools/pfunction/PSimpleBase.hh +++ b/include/field_input/IntegrationTools/pfunction/PSimpleBase.hh @@ -1,4 +1,3 @@ - #ifndef PSimpleBase_HH #define PSimpleBase_HH @@ -44,39 +43,6 @@ namespace PRISMS return _val; } - void - is_derived_from_PSimpleBase() const - { - return; - } - - virtual PSimpleBase * - clone() const - { - return new PSimpleBase(*this); - } - - [[nodiscard]] virtual std::string - csrc() const - { - undefined("std::string csrc()"); - return std::string(); - } - - [[nodiscard]] virtual std::string - sym() const - { - undefined("std::string sym()"); - return std::string(); - } - - [[nodiscard]] virtual std::string - latex() const - { - undefined("std::string latex()"); - return std::string(); - } - private: virtual OutType eval([[maybe_unused]] const VarContainer &var) const diff --git a/include/field_input/IntegrationTools/pfunction/PSimpleFunction.hh b/include/field_input/IntegrationTools/pfunction/PSimpleFunction.hh deleted file mode 100644 index 35d7cc6b2..000000000 --- a/include/field_input/IntegrationTools/pfunction/PSimpleFunction.hh +++ /dev/null @@ -1,148 +0,0 @@ - -#ifndef PSimpleFunction_HH -#define PSimpleFunction_HH - -#include "./PSimpleBase.hh" -#include -#include -#include -#include - -namespace PRISMS -{ - template - class PSimpleFunction - { - private: - PSimpleBase *ptr; - - public: - [[nodiscard]] std::string - name() const - { - return (*ptr).name(); - } - - [[nodiscard]] std::string - csrc() const - { - return (*ptr).csrc(); - } - - [[nodiscard]] std::string - sym() const - { - return (*ptr).sym(); - } - - [[nodiscard]] 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); - } - - // ---------------------------------------------------------- - // Then use 'get' methods to access results later - void - eval(const VarContainer &var) - { - (*ptr)(var); - } - - OutType - operator()() const - { - return (*ptr)(); - } - - // PFunction unique members ------------------------------------------ - - 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) - { - std::cout << "Error in PSimpleFunction::set. RHS == NULL." << std::endl; - exit(1); - } - if (ptr != NULL) - { - delete ptr; - } - ptr = RHS; - return *this; - } - - PSimpleFunction() - { - ptr = NULL; - } - - 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/field_input/IntegrationTools/piecewise/PPieceWiseFuncBase.hh b/include/field_input/IntegrationTools/piecewise/PPieceWiseFuncBase.hh deleted file mode 100644 index bd802ab74..000000000 --- a/include/field_input/IntegrationTools/piecewise/PPieceWiseFuncBase.hh +++ /dev/null @@ -1,173 +0,0 @@ - -#ifndef PPieceWiseFuncBase_HH -#define PPieceWiseFuncBase_HH - -#include "../pfunction/PFuncBase.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 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); - } - - // ---------------------------------------------------------- - // 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/field_input/IntegrationTools/piecewise/PPieceWiseSimpleBase.hh b/include/field_input/IntegrationTools/piecewise/PPieceWiseSimpleBase.hh deleted file mode 100644 index 6672b930d..000000000 --- a/include/field_input/IntegrationTools/piecewise/PPieceWiseSimpleBase.hh +++ /dev/null @@ -1,144 +0,0 @@ - -#ifndef PPieceWiseSimpleBase_HH -#define PPieceWiseSimpleBase_HH - -#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 PPieceWiseSimpleBase : public PSimpleBase - { - public: - mutable std::vector> _piece; - - PPieceWiseSimpleBase() - {} - - PPieceWiseSimpleBase(const std::vector> &piece) - { - _piece = piece; - } - - virtual std::string - csrc() const - { - std::string str = ""; - for (int i = 0; i < _piece.size(); i++) - { - if (i == 0) - { - str += _piece[i].csrc(); - } - else if (i == _piece.size() - 1) - { - str += "; and " + _piece[i].csrc(); - } - else - { - str += "; " + _piece[i].csrc(); - } - } - return str; - } - - virtual std::string - sym() const - { - std::string str = ""; - for (int i = 0; i < _piece.size(); i++) - { - if (i == 0) - { - str += _piece[i].sym(); - } - else if (i == _piece.size() - 1) - { - str += "; and " + _piece[i].sym(); - } - else - { - str += "; " + _piece[i].sym(); - } - } - return str; - } - - virtual std::string - latex() const - { - std::string str = ""; - for (int i = 0; i < _piece.size(); i++) - { - 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 += " \\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/field_input/IntegrationTools/piecewise/Piece.hh b/include/field_input/IntegrationTools/piecewise/Piece.hh deleted file mode 100644 index 61ed1e72d..000000000 --- a/include/field_input/IntegrationTools/piecewise/Piece.hh +++ /dev/null @@ -1,178 +0,0 @@ - -#ifndef Piece_HH -#define Piece_HH - -#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 Piece : public PFuncBase - { - protected: - PFunction _expr; - mutable std::vector> _condition; - - 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++) - { - 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/field_input/IntegrationTools/piecewise/SimplePiece.hh b/include/field_input/IntegrationTools/piecewise/SimplePiece.hh deleted file mode 100644 index 9c1a20e2e..000000000 --- a/include/field_input/IntegrationTools/piecewise/SimplePiece.hh +++ /dev/null @@ -1,142 +0,0 @@ - -#ifndef SimplePiece_HH -#define SimplePiece_HH - -#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 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) - { - _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++) - { - if (i == 0) - { - str += " if " + _condition[i].csrc(); - } - else if (i == _condition.size() - 1) - { - str += " and " + _condition[i].csrc(); - } - else - { - str += ", " + _condition[i].csrc(); - } - } - return str; - } - - virtual std::string - sym() const - { - std::string str = _expr.sym(); - 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 - { - str += ", " + _condition[i].sym(); - } - } - return str; - } - - virtual std::string - latex() const - { - std::string str = _expr.latex(); - for (size_type i = 0; i < _condition.size(); i++) - { - 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(); - } - } - 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++) - { - 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/field_input/pFunction.h b/include/field_input/pFunction.h deleted file mode 100644 index cc7b4b5c7..000000000 --- a/include/field_input/pFunction.h +++ /dev/null @@ -1,80 +0,0 @@ -// pFunction: An interface for PFunctions in PRISMS-PF -// This class is used to declare and load PFunctions from a pre-existing -// PLibrary that was created using PRISMS IntegrationTools. The class is a -// wrapper for the PFunctions in IntegrationTools so that they can be used for -// vectorized arrays. This class also calls the IntegrationTools checkout -// function in the constructor to reduce the number of steps the user needs to -// take. Currently this is only implemented for scalar functions. Vector -// functions can be treated component by component. - -#include - -#include -#include - -namespace PFunctions -{ - using scalarvalueType = dealii::VectorizedArray; - - class pFunction - { - public: - // Constructor, wraps the IntegrationTools checkout function - explicit pFunction(const std::string &function_name); - - // Returns the value of the function for a given input variable - scalarvalueType val(scalarvalueType); - - // Returns one of first derivatives of the function for a given input - // variable - scalarvalueType - grad(scalarvalueType, unsigned int); - - // Returns one of the second derivatives of the function for a given input - // variable - scalarvalueType - hess(scalarvalueType, unsigned int, unsigned int); - - private: - PRISMS::PFunction fun; - }; - - pFunction::pFunction(const std::string &function_name) - { - PRISMS::PLibrary::checkout(function_name, fun); - } - - scalarvalueType - pFunction::val(scalarvalueType var) - { - scalarvalueType fun_val; - for (unsigned i = 0; i < var.size(); i++) - { - fun_val[i] = fun(&var[i]); - } - return fun_val; - } - - scalarvalueType - pFunction::grad(scalarvalueType var, unsigned int dir) - { - scalarvalueType fun_grad; - for (unsigned i = 0; i < var.size(); i++) - { - fun_grad[i] = fun.grad(&var[i], dir); - } - return fun_grad; - } - - scalarvalueType - pFunction::hess(scalarvalueType var, unsigned int dir1, unsigned int dir2) - { - scalarvalueType fun_hess; - for (unsigned i = 0; i < var.size(); i++) - { - fun_hess[i] = fun.hess(&var[i], dir1, dir2); - } - return fun_hess; - } - -} // namespace PFunctions diff --git a/tests/field_input/field_input.cc b/tests/field_input/field_input.cc index e69de29bb..6d5ff2775 100644 --- a/tests/field_input/field_input.cc +++ b/tests/field_input/field_input.cc @@ -0,0 +1,64 @@ +#include "catch.hpp" + +#include + +TEST_CASE("Unstructured vtk File read-in") +{ + SECTION("2D") + { + using ScalarField = PRISMS::PField; + using Body = PRISMS::Body; + Body body; + + REQUIRE_THROWS_AS(body.read_vtk("invalid"), std::runtime_error); + + body.read_vtk("field_input/test_2D_1degree.vtk"); + + ScalarField n_field = body.find_scalar_field("n"); + ScalarField nx_field = body.find_scalar_field("|nx|"); + + for (auto x : {0.0, 5.0, 10.0}) + { + for (auto y : {0.0, 5.0, 10.0}) + { + double point[2] = {x, y}; + REQUIRE(n_field(point) == x); + REQUIRE(nx_field(point) == 1.0); + } + } + + REQUIRE_THROWS_AS(body.find_scalar_field("invalid"), std::invalid_argument); + } + + SECTION("3D") + { + using ScalarField = PRISMS::PField; + using Body = PRISMS::Body; + Body body; + + REQUIRE_THROWS_AS(body.read_vtk("invalid"), std::runtime_error); + + body.read_vtk("field_input/test_3D_1degree.vtk"); + + ScalarField n_field = body.find_scalar_field("n"); + ScalarField nx_field = body.find_scalar_field("|nx|"); + + for (auto x : {0.0, 5.0, 10.0}) + { + for (auto y : {0.0, 5.0, 10.0}) + { + for (auto z : {0.0, 5.0, 10.0}) + { + double point[3] = {x, y, z}; + REQUIRE(n_field(point) == x); + REQUIRE(nx_field(point) == 1.0); + } + } + } + + REQUIRE_THROWS_AS(body.find_scalar_field("invalid"), std::invalid_argument); + } +} + +TEST_CASE("Rectilinear vtk File read-in") +{} \ No newline at end of file diff --git a/tests/field_input/test_2D_1degree.vtk b/tests/field_input/test_2D_1degree.vtk new file mode 100644 index 000000000..728f097be --- /dev/null +++ b/tests/field_input/test_2D_1degree.vtk @@ -0,0 +1,38 @@ +# vtk DataFile Version 3.0 +#This file was generated by the deal.II library on 2024/12/17 at 7:19:10 +ASCII +DATASET UNSTRUCTURED_GRID + +POINTS 16 double +0 0 0 +5 0 0 +0 5 0 +5 5 0 +5 0 0 +10 0 0 +5 5 0 +10 5 0 +0 5 0 +5 5 0 +0 10 0 +5 10 0 +5 5 0 +10 5 0 +5 10 0 +10 10 0 + +CELLS 4 20 +4 0 1 3 2 +4 4 5 7 6 +4 8 9 11 10 +4 12 13 15 14 + +CELL_TYPES 4 + 9 9 9 9 +POINT_DATA 16 +SCALARS n double 1 +LOOKUP_TABLE default +0 5 0 5 5 10 5 10 0 5 0 5 5 10 5 10 +SCALARS |nx| double 1 +LOOKUP_TABLE default +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 diff --git a/tests/field_input/test_2D_2degree.vtk b/tests/field_input/test_2D_2degree.vtk new file mode 100644 index 000000000..694993214 --- /dev/null +++ b/tests/field_input/test_2D_2degree.vtk @@ -0,0 +1,70 @@ +# vtk DataFile Version 3.0 +#This file was generated by the deal.II library on 2024/12/17 at 7:20:15 +ASCII +DATASET UNSTRUCTURED_GRID + +POINTS 36 double +0 0 0 +2.5 0 0 +5 0 0 +0 2.5 0 +2.5 2.5 0 +5 2.5 0 +0 5 0 +2.5 5 0 +5 5 0 +5 0 0 +7.5 0 0 +10 0 0 +5 2.5 0 +7.5 2.5 0 +10 2.5 0 +5 5 0 +7.5 5 0 +10 5 0 +0 5 0 +2.5 5 0 +5 5 0 +0 7.5 0 +2.5 7.5 0 +5 7.5 0 +0 10 0 +2.5 10 0 +5 10 0 +5 5 0 +7.5 5 0 +10 5 0 +5 7.5 0 +7.5 7.5 0 +10 7.5 0 +5 10 0 +7.5 10 0 +10 10 0 + +CELLS 16 80 +4 0 1 4 3 +4 1 2 5 4 +4 3 4 7 6 +4 4 5 8 7 +4 9 10 13 12 +4 10 11 14 13 +4 12 13 16 15 +4 13 14 17 16 +4 18 19 22 21 +4 19 20 23 22 +4 21 22 25 24 +4 22 23 26 25 +4 27 28 31 30 +4 28 29 32 31 +4 30 31 34 33 +4 31 32 35 34 + +CELL_TYPES 16 + 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 +POINT_DATA 36 +SCALARS n double 1 +LOOKUP_TABLE default +0 2.5 5 0 2.5 5 0 2.5 5 5 7.5 10 5 7.5 10 5 7.5 10 0 2.5 5 0 2.5 5 0 2.5 5 5 7.5 10 5 7.5 10 5 7.5 10 +SCALARS |nx| double 1 +LOOKUP_TABLE default +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 diff --git a/tests/field_input/test_3D_1degree.vtk b/tests/field_input/test_3D_1degree.vtk new file mode 100644 index 000000000..c6c3ea58a --- /dev/null +++ b/tests/field_input/test_3D_1degree.vtk @@ -0,0 +1,90 @@ +# vtk DataFile Version 3.0 +#This file was generated by the deal.II library on 2024/12/17 at 10:15:23 +ASCII +DATASET UNSTRUCTURED_GRID + +POINTS 64 double +0 0 0 +5 0 0 +0 5 0 +5 5 0 +0 0 5 +5 0 5 +0 5 5 +5 5 5 +5 0 0 +10 0 0 +5 5 0 +10 5 0 +5 0 5 +10 0 5 +5 5 5 +10 5 5 +0 5 0 +5 5 0 +0 10 0 +5 10 0 +0 5 5 +5 5 5 +0 10 5 +5 10 5 +5 5 0 +10 5 0 +5 10 0 +10 10 0 +5 5 5 +10 5 5 +5 10 5 +10 10 5 +0 0 5 +5 0 5 +0 5 5 +5 5 5 +0 0 10 +5 0 10 +0 5 10 +5 5 10 +5 0 5 +10 0 5 +5 5 5 +10 5 5 +5 0 10 +10 0 10 +5 5 10 +10 5 10 +0 5 5 +5 5 5 +0 10 5 +5 10 5 +0 5 10 +5 5 10 +0 10 10 +5 10 10 +5 5 5 +10 5 5 +5 10 5 +10 10 5 +5 5 10 +10 5 10 +5 10 10 +10 10 10 + +CELLS 8 72 +8 0 1 3 2 4 5 7 6 +8 8 9 11 10 12 13 15 14 +8 16 17 19 18 20 21 23 22 +8 24 25 27 26 28 29 31 30 +8 32 33 35 34 36 37 39 38 +8 40 41 43 42 44 45 47 46 +8 48 49 51 50 52 53 55 54 +8 56 57 59 58 60 61 63 62 + +CELL_TYPES 8 + 12 12 12 12 12 12 12 12 +POINT_DATA 64 +SCALARS n double 1 +LOOKUP_TABLE default +0 5 0 5 0 5 0 5 5 10 5 10 5 10 5 10 0 5 0 5 0 5 0 5 5 10 5 10 5 10 5 10 0 5 0 5 0 5 0 5 5 10 5 10 5 10 5 10 0 5 0 5 0 5 0 5 5 10 5 10 5 10 5 10 +SCALARS |nx| double 1 +LOOKUP_TABLE default +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1