From 961f9b698082a9f03c6fbf0ee9379e839feca0a3 Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 24 Oct 2024 14:16:29 -0700 Subject: [PATCH 1/5] fix getOrder but still cant create thermal physics with differing --- src/drivers/serac.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/drivers/serac.cpp b/src/drivers/serac.cpp index cbf32d6c84..5b4e52db32 100644 --- a/src/drivers/serac.cpp +++ b/src/drivers/serac.cpp @@ -204,35 +204,34 @@ std::unique_ptr createPhysics( * @param[in] heat_transfer_options Optional container of input options for HeatTransfer physics module * @param[in] thermomechanics_options Optional container of input options for Thermomechanics physics module * - * @return The order of the discretization + * @return The pair of possible orders of the discretization */ -int getOrder(std::optional solid_mechanics_options, +std::pair getOrder(std::optional solid_mechanics_options, std::optional heat_transfer_options, std::optional thermomechanics_options) { - int order = 0; + int solid_order = 0; + int heat_order = 0; if (thermomechanics_options) { - order = thermomechanics_options->solid_options.order; - int thermal_order = thermomechanics_options->thermal_options.order; - SLIC_ERROR_ROOT_IF( - order != thermal_order, - axom::fmt::format("Solid order '{0}' and thermal order '{1}'' do not match.", order, thermal_order)); + solid_order = thermomechanics_options->solid_options.order; + heat_order = thermomechanics_options->thermal_options.order; } else if (solid_mechanics_options && heat_transfer_options) { - order = solid_mechanics_options->order; - int thermal_order = heat_transfer_options->order; - SLIC_ERROR_ROOT_IF( - order != thermal_order, - axom::fmt::format("Solid order '{0}' and thermal order '{1}'' do not match.", order, thermal_order)); + solid_order = solid_mechanics_options->order; + heat_order = thermomechanics_options->thermal_options.order; } else if (solid_mechanics_options) { - order = solid_mechanics_options->order; + solid_order = solid_mechanics_options->order; } else if (heat_transfer_options) { - order = heat_transfer_options->order; + heat_order = thermomechanics_options->thermal_options.order; } else { SLIC_ERROR_ROOT("Neither solid, heat_transfer, nor thermal_solid blocks specified in the input file."); } - SLIC_ERROR_ROOT_IF(order < 1 || order > 3, - axom::fmt::format("Invalid solver order '{0}' given. Valid values are 1, 2, or 3.", order)); - return order; + SLIC_ERROR_ROOT_IF(solid_order == 0 || heat_order == 0, + axom::fmt::format("No valid solver order given. Solid Mechanics and/or Heat Transfer modules must have a valid value. Valid values are 1, 2, or 3.")); + SLIC_ERROR_ROOT_IF((solid_order != 0 && (solid_order < 1 || solid_order > 3), + axom::fmt::format("Invalid Solid Mechanics solver order '{0}' given. Valid values are 1, 2, or 3.", solid_order)); + SLIC_ERROR_ROOT_IF((heat_order != 0 && (heat_order < 1 || heat_order > 3), + axom::fmt::format("Invalid Heat Transfer solver order '{0}' given. Valid values are 1, 2, or 3.", solid_order)); + return {solid_order, heat_order}; } /** @@ -377,7 +376,7 @@ int main(int argc, char* argv[]) int dim = serac::StateManager::mesh(mesh_tag).Dimension(); SLIC_ERROR_ROOT_IF(dim < 2 || dim > 3, axom::fmt::format("Invalid mesh dimension '{0}' provided. Valid values are 2 or 3.", dim)); - int order = getOrder(solid_mechanics_options, heat_transfer_options, thermomechanics_options); + auto [solid_order, heat_order] = getOrder(solid_mechanics_options, heat_transfer_options, thermomechanics_options); // Create the physics object auto main_physics = createPhysics(dim, order, solid_mechanics_options, heat_transfer_options, thermomechanics_options, From 01bb68d09f1e0b721731982fa3b425c3c89a5911 Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 24 Oct 2024 20:20:03 -0700 Subject: [PATCH 2/5] remove thermomechanics from serac driver --- src/drivers/serac.cpp | 123 ++++++++---------------------------------- 1 file changed, 23 insertions(+), 100 deletions(-) diff --git a/src/drivers/serac.cpp b/src/drivers/serac.cpp index 5b4e52db32..30e766bdfd 100644 --- a/src/drivers/serac.cpp +++ b/src/drivers/serac.cpp @@ -30,7 +30,6 @@ #include "serac/mesh/mesh_utils.hpp" #include "serac/physics/solid_mechanics.hpp" #include "serac/physics/heat_transfer.hpp" -#include "serac/physics/thermomechanics.hpp" #include "serac/numerics/equation_solver.hpp" #include "serac/physics/state/state_manager.hpp" #include "serac/serac_config.hpp" @@ -57,12 +56,8 @@ void defineInputFileSchema(axom::inlet::Inlet& inlet) SolidMechanicsInputOptions::defineInputFileSchema(solid_solver_table); // The heat transfer options - auto& thermal_solver_table = inlet.addStruct("heat_transfer", "Heat transfer module"); - HeatTransferInputOptions::defineInputFileSchema(thermal_solver_table); - - // The thermal solid options - auto& thermal_solid_solver_table = inlet.addStruct("thermal_solid", "Thermal solid module"); - ThermomechanicsInputOptions::defineInputFileSchema(thermal_solid_solver_table); + auto& heat_transfer_solver_table = inlet.addStruct("heat_transfer", "Heat transfer module"); + HeatTransferInputOptions::defineInputFileSchema(heat_transfer_solver_table); // Verify the input file if (!inlet.verify()) { @@ -79,7 +74,6 @@ void defineInputFileSchema(axom::inlet::Inlet& inlet) * @param[in] dim The spatial dimension of the mesh * @param[in] solid_mechanics_options Optional container of input options for SolidMechanics physics module * @param[in] heat_transfer_options Optional container of input options for HeatTransfer physics module - * @param[in] thermomechanics_options Optional container of input options for Thermomechanics physics module * @param[in] mesh_tag The mesh tag to construct the physics class on * @param[in] cycle The simulation timestep cycle to start the physics module at * @param[in] t The simulation time to start the physics module at @@ -88,64 +82,11 @@ void defineInputFileSchema(axom::inlet::Inlet& inlet) */ std::unique_ptr createPhysics( int dim, int order, std::optional solid_mechanics_options, - std::optional heat_transfer_options, - std::optional thermomechanics_options, std::string mesh_tag, int cycle, - double t) + std::optional heat_transfer_options, std::string mesh_tag, int cycle, double t) { std::unique_ptr main_physics; - if (thermomechanics_options) { - if (order == 1) { - if (dim == 2) { - main_physics = - std::make_unique>(*thermomechanics_options, "serac", mesh_tag, cycle, t); - } else if (dim == 3) { - main_physics = - std::make_unique>(*thermomechanics_options, "serac", mesh_tag, cycle, t); - } - } else if (order == 2) { - if (dim == 2) { - main_physics = - std::make_unique>(*thermomechanics_options, "serac", mesh_tag, cycle, t); - } else if (dim == 3) { - main_physics = - std::make_unique>(*thermomechanics_options, "serac", mesh_tag, cycle, t); - } - } else if (order == 3) { - if (dim == 2) { - main_physics = - std::make_unique>(*thermomechanics_options, "serac", mesh_tag, cycle, t); - } else if (dim == 3) { - main_physics = - std::make_unique>(*thermomechanics_options, "serac", mesh_tag, cycle, t); - } - } - } else if (solid_mechanics_options && heat_transfer_options) { - if (order == 1) { - if (dim == 2) { - main_physics = std::make_unique>(*heat_transfer_options, *solid_mechanics_options, - "serac", mesh_tag, cycle, t); - } else if (dim == 3) { - main_physics = std::make_unique>(*heat_transfer_options, *solid_mechanics_options, - "serac", mesh_tag, cycle, t); - } - } else if (order == 2) { - if (dim == 2) { - main_physics = std::make_unique>(*heat_transfer_options, *solid_mechanics_options, - "serac", mesh_tag, cycle, t); - } else if (dim == 3) { - main_physics = std::make_unique>(*heat_transfer_options, *solid_mechanics_options, - "serac", mesh_tag, cycle, t); - } - } else if (order == 3) { - if (dim == 2) { - main_physics = std::make_unique>(*heat_transfer_options, *solid_mechanics_options, - "serac", mesh_tag, cycle, t); - } else if (dim == 3) { - main_physics = std::make_unique>(*heat_transfer_options, *solid_mechanics_options, - "serac", mesh_tag, cycle, t); - } - } - } else if (solid_mechanics_options) { + + if (solid_mechanics_options) { if (order == 1) { if (dim == 2) { main_physics = @@ -192,7 +133,7 @@ std::unique_ptr createPhysics( } } } else { - SLIC_ERROR_ROOT("Neither solid, heat_transfer, nor thermal_solid blocks specified in the input file."); + SLIC_ERROR_ROOT("Neither solid or heat_transfer blocks specified in the input file."); } return main_physics; } @@ -202,36 +143,23 @@ std::unique_ptr createPhysics( * * @param[in] solid_mechanics_options Optional container of input options for SolidMechanics physics module * @param[in] heat_transfer_options Optional container of input options for HeatTransfer physics module - * @param[in] thermomechanics_options Optional container of input options for Thermomechanics physics module * - * @return The pair of possible orders of the discretization + * @return The order of the discretization */ -std::pair getOrder(std::optional solid_mechanics_options, - std::optional heat_transfer_options, - std::optional thermomechanics_options) +int getOrder(std::optional solid_mechanics_options, + std::optional heat_transfer_options) { - int solid_order = 0; - int heat_order = 0; - if (thermomechanics_options) { - solid_order = thermomechanics_options->solid_options.order; - heat_order = thermomechanics_options->thermal_options.order; - } else if (solid_mechanics_options && heat_transfer_options) { - solid_order = solid_mechanics_options->order; - heat_order = thermomechanics_options->thermal_options.order; - } else if (solid_mechanics_options) { - solid_order = solid_mechanics_options->order; + int order = 0; + if (solid_mechanics_options) { + order = solid_mechanics_options->order; } else if (heat_transfer_options) { - heat_order = thermomechanics_options->thermal_options.order; + order = heat_transfer_options->order; } else { - SLIC_ERROR_ROOT("Neither solid, heat_transfer, nor thermal_solid blocks specified in the input file."); + SLIC_ERROR_ROOT("Neither solid or heat_transfer blocks specified in the input file."); } - SLIC_ERROR_ROOT_IF(solid_order == 0 || heat_order == 0, - axom::fmt::format("No valid solver order given. Solid Mechanics and/or Heat Transfer modules must have a valid value. Valid values are 1, 2, or 3.")); - SLIC_ERROR_ROOT_IF((solid_order != 0 && (solid_order < 1 || solid_order > 3), - axom::fmt::format("Invalid Solid Mechanics solver order '{0}' given. Valid values are 1, 2, or 3.", solid_order)); - SLIC_ERROR_ROOT_IF((heat_order != 0 && (heat_order < 1 || heat_order > 3), - axom::fmt::format("Invalid Heat Transfer solver order '{0}' given. Valid values are 1, 2, or 3.", solid_order)); - return {solid_order, heat_order}; + SLIC_ERROR_ROOT_IF(order < 1 || order > 3, + axom::fmt::format("Invalid solver order '{0}' given. Valid values are 1, 2, or 3.", order)); + return order; } /** @@ -338,7 +266,7 @@ int main(int argc, char* argv[]) double dt = inlet["dt"]; int cycle = 0; - std::string mesh_tag{"mesh}"}; + std::string mesh_tag{"mesh"}; // Not restarting, so we need to create the mesh and register it with the StateManager if (!restart_cycle) { @@ -356,10 +284,9 @@ int main(int argc, char* argv[]) cycle = *restart_cycle; } - // Create nullable containers for the solid and thermal input file options - std::optional solid_mechanics_options; - std::optional heat_transfer_options; - std::optional thermomechanics_options; + // Create nullable containers for the solid and heat transfer input file options + std::optional solid_mechanics_options; + std::optional heat_transfer_options; // If the blocks exist, read the appropriate input file options if (inlet.isUserProvided("solid")) { @@ -368,19 +295,15 @@ int main(int argc, char* argv[]) if (inlet.isUserProvided("heat_transfer")) { heat_transfer_options = inlet["heat_transfer"].get(); } - if (inlet.isUserProvided("thermal_solid")) { - thermomechanics_options = inlet["thermal_solid"].get(); - } // Get dimension and order of problem int dim = serac::StateManager::mesh(mesh_tag).Dimension(); SLIC_ERROR_ROOT_IF(dim < 2 || dim > 3, axom::fmt::format("Invalid mesh dimension '{0}' provided. Valid values are 2 or 3.", dim)); - auto [solid_order, heat_order] = getOrder(solid_mechanics_options, heat_transfer_options, thermomechanics_options); + int order = getOrder(solid_mechanics_options, heat_transfer_options); // Create the physics object - auto main_physics = createPhysics(dim, order, solid_mechanics_options, heat_transfer_options, thermomechanics_options, - mesh_tag, cycle, t); + auto main_physics = createPhysics(dim, order, solid_mechanics_options, heat_transfer_options, mesh_tag, cycle, t); // Complete the solver setup main_physics->completeSetup(); From f18c594848a4187c842bd70c2e52ae33b5245177 Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 24 Oct 2024 20:39:41 -0700 Subject: [PATCH 3/5] remove default.lua and use the tested ones --- data/input_files/default.lua | 135 ----------------------------------- src/drivers/CMakeLists.txt | 27 +++---- 2 files changed, 9 insertions(+), 153 deletions(-) delete mode 100644 data/input_files/default.lua diff --git a/data/input_files/default.lua b/data/input_files/default.lua deleted file mode 100644 index 1098d93240..0000000000 --- a/data/input_files/default.lua +++ /dev/null @@ -1,135 +0,0 @@ --- Simulation time parameters -t_final = 1.0 -dt = 0.25 - -main_mesh = { - type = "file", - -- mesh file - mesh = "../meshes/beam-hex.mesh", - -- serial and parallel refinement levels - ser_ref_levels = 0, - par_ref_levels = 0, -} - --- Solver parameters -solid = { - equation_solver = { - linear = { - type = "iterative", - iterative_options = { - rel_tol = 1.0e-6, - abs_tol = 1.0e-8, - max_iter = 5000, - print_level = 0, - solver_type = "gmres", - prec_type = "HypreAMG", - }, - }, - - nonlinear = { - rel_tol = 1.0e-2, - abs_tol = 1.0e-4, - max_iter = 500, - print_level = 0, - }, - }, - - -- polynomial interpolation order - order = 1, - - -- neo-Hookean material parameters - materials = { { model = "NeoHookean", mu = 0.25, K = 5.0, density = 1.0 }, }, - - -- initial conditions - -- initialize x_cur, boundary condition, deformation, and - -- incremental nodal displacment grid functions by projecting the - -- VectorFunctionCoefficient function onto them - - initial_displacement = { - vector_constant = { - x = 0.0, - y = 0.0, - z = 0.0 - } - }, - - initial_velocity = { - vector_constant = { - x = 0.0, - y = 0.0, - z = 0.0 - } - }, - - -- boundary condition parameters - boundary_conds = { - ['displacement'] = { - attrs = {1}, - vector_constant = { - x = 0.0, - y = 0.0, - z = 0.0 - } - }, - ['traction'] = { - attrs = {2}, - vector_function = function (v, t) - return Vector.new(0, 1.0e-3, 0) * t - end - }, - }, -} - -temp_func = function (v) - if v:norm() < 3.0 then return 2.0 else return 1.0 end -end - --- Solver parameters -heat_transfer = { - equation_solver = { - linear = { - type = "iterative", - iterative_options = { - rel_tol = 1.0e-6, - abs_tol = 1.0e-12, - max_iter = 200, - print_level = 0, - solver_type = "cg", - prec_type = "JacobiSmoother", - }, - }, - - nonlinear = { - rel_tol = 1.0e-4, - abs_tol = 1.0e-8, - max_iter = 500, - print_level = 1, - }, - }, - - dynamics = { - timestepper = "BackwardEuler", - enforcement_method = "RateControl", - }, - - -- polynomial interpolation order - order = 2, - - -- material parameters - kappa = 0.5, - rho = 0.5, - cp = 0.5, - - -- initial conditions - initial_temperature = { - scalar_function = temp_func - }, - - -- boundary condition parameters - boundary_conds = { - ['temperature'] = { - attrs = {1}, - scalar_function = temp_func - }, - }, -} diff --git a/src/drivers/CMakeLists.txt b/src/drivers/CMakeLists.txt index e7f81f17da..5c213cb306 100644 --- a/src/drivers/CMakeLists.txt +++ b/src/drivers/CMakeLists.txt @@ -11,32 +11,23 @@ blt_add_executable( NAME serac_driver ) if (SERAC_ENABLE_TESTS) - set(input_files_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../data/input_files) + set(input_files_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../data/input_files/tests) - # Make sure running serac driver doesn't completely fail -#TODO: Turn these back on when input files work with the new physics modules -# blt_add_test(NAME serac_driver_default -# COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o default -i ${input_files_dir}/default.lua -# NUM_MPI_TASKS 1 ) - -# blt_add_test(NAME serac_driver_default_parallel -# COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o default_parallel -i ${input_files_dir}/default.lua -# NUM_MPI_TASKS 2 ) - -# blt_add_test(NAME serac_driver_no_thermal -# COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o default_no_thermal -i ${input_files_dir}/tests/solid/qs_linear.lua -# NUM_MPI_TASKS 1 ) + # Run basic test for the Serac driver + blt_add_test(NAME serac_driver_solid + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o driver_solid -i ${input_files_dir}/solid/dyn_solve.lua + NUM_MPI_TASKS 1 ) -# blt_add_test(NAME serac_driver_no_solid -# COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o default_no_solid -i ${input_files_dir}/tests/heat_transfer/static_solve.lua -# NUM_MPI_TASKS 1 ) + blt_add_test(NAME serac_driver_heat_transfer + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o driver_heat_transfer -i ${input_files_dir}/heat_transfer/static_solve.lua + NUM_MPI_TASKS 1 ) blt_add_test(NAME serac_driver_help COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac --help NUM_MPI_TASKS 1 ) blt_add_test(NAME serac_driver_docs - COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o default_docs -d -i ${input_files_dir}/default.lua + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/serac -o docs -d -i ${input_files_dir}/solid/qs_linear.lua NUM_MPI_TASKS 1 ) endif() From 9973c7c3a7b072be1cc092b6f6c6308d26102bcf Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 24 Oct 2024 20:43:28 -0700 Subject: [PATCH 4/5] remove default from integration tests, it wasnt running anyways --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index 662c093ddd..b3c58cfdca 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit 662c093dddcff184983547ea0212adce3632a751 +Subproject commit b3c58cfdcaf8732ec9fbf43aeed9dd07d0923d3b From d9a1b53c2c1c9e351725cba40968a9e7cef8f3c2 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 25 Oct 2024 11:24:33 -0700 Subject: [PATCH 5/5] bump tests --- tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests b/tests index b3c58cfdca..57f8983b97 160000 --- a/tests +++ b/tests @@ -1 +1 @@ -Subproject commit b3c58cfdcaf8732ec9fbf43aeed9dd07d0923d3b +Subproject commit 57f8983b977f70445342a211c3ee5538bb81dc4f