diff --git a/src/adapter/4C_adapter_fld_base_algorithm.cpp b/src/adapter/4C_adapter_fld_base_algorithm.cpp index e03e2705fa..3acb3ece5e 100644 --- a/src/adapter/4C_adapter_fld_base_algorithm.cpp +++ b/src/adapter/4C_adapter_fld_base_algorithm.cpp @@ -14,6 +14,7 @@ #include "4C_adapter_fld_fluid_fsi_msht.hpp" #include "4C_adapter_fld_fluid_xfsi.hpp" #include "4C_adapter_fld_poro.hpp" +#include "4C_adapter_problem_access.hpp" #include "4C_elch_input.hpp" #include "4C_fem_condition_periodic.hpp" #include "4C_fem_discretization.hpp" @@ -76,16 +77,17 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd { auto t = Teuchos::TimeMonitor::getNewTimer("Adapter::FluidBaseAlgorithm::setup_fluid"); Teuchos::TimeMonitor monitor(*t); + Global::Problem* problem = Adapter::Utils::problem_from_instance(); // ------------------------------------------------------------------- // what's the current problem type? // ------------------------------------------------------------------- - Core::ProblemType probtype = Global::Problem::instance()->get_problem_type(); + Core::ProblemType probtype = problem->get_problem_type(); // ------------------------------------------------------------------- // access the discretization // ------------------------------------------------------------------- - std::shared_ptr actdis = Global::Problem::instance()->get_dis(disname); + std::shared_ptr actdis = problem->get_dis(disname); // ------------------------------------------------------------------- // connect degrees of freedom for periodic boundary conditions @@ -130,20 +132,17 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd // FIXME: The solver should not be taken from the contact dynamic section here, // but must be specified in the fluid dynamic section instead (popp 11/2012) - const Teuchos::ParameterList& mshparams = - Global::Problem::instance()->contact_dynamic_params(); + const Teuchos::ParameterList& mshparams = problem->contact_dynamic_params(); const int mshsolver = mshparams.get( "LINEAR_SOLVER"); // meshtying solver (with block preconditioner, e.g. BGS 2x2) const auto solvertype = Teuchos::getIntegralValue( - Global::Problem::instance()->solver_params(mshsolver), "SOLVER"); + problem->solver_params(mshsolver), "SOLVER"); // create solver objects - solver = std::make_shared( - Global::Problem::instance()->solver_params(mshsolver), actdis->get_comm(), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + solver = std::make_shared(problem->solver_params(mshsolver), + actdis->get_comm(), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY")); if (solvertype == Core::LinearSolver::SolverType::Belos) { @@ -170,8 +169,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd case Inpar::FLUID::condensed_bmat_merged: { // meshtying (no saddle point problem) - const Teuchos::ParameterList& mshparams = - Global::Problem::instance()->contact_dynamic_params(); + const Teuchos::ParameterList& mshparams = problem->contact_dynamic_params(); const int mshsolver = mshparams.get( "LINEAR_SOLVER"); // meshtying solver (with block preconditioner, e.g. BGS 2x2) if (mshsolver == (-1)) @@ -179,11 +177,9 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd "no linear solver defined for fluid meshtying problem. Please set LINEAR_SOLVER in " "CONTACT DYNAMIC to a valid number!"); - solver = std::make_shared( - Global::Problem::instance()->solver_params(mshsolver), actdis->get_comm(), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + solver = std::make_shared(problem->solver_params(mshsolver), + actdis->get_comm(), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY")); } break; case Inpar::FLUID::no_meshtying: // no meshtying -> use FLUID SOLVER @@ -197,11 +193,9 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd FOUR_C_THROW( "no linear solver defined for fluid problem. Please set LINEAR_SOLVER in FLUID DYNAMIC " "to a valid number!"); - solver = std::make_shared( - Global::Problem::instance()->solver_params(linsolvernumber), actdis->get_comm(), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + solver = std::make_shared(problem->solver_params(linsolvernumber), + actdis->get_comm(), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY")); break; } @@ -211,8 +205,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd if (probtype != Core::ProblemType::fsi_xfem and probtype != Core::ProblemType::fpsi_xfem and probtype != Core::ProblemType::fluid_xfem and !(probtype == Core::ProblemType::fsi and - Global::Problem::instance()->x_fluid_dynamic_params().sublist("GENERAL").get( - "XFLUIDFLUID"))) + problem->x_fluid_dynamic_params().sublist("GENERAL").get("XFLUIDFLUID"))) { compute_null_space_if_necessary(*actdis, solver->params(), true); } @@ -249,7 +242,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd probtype == Core::ProblemType::fpsi_xfem) and disname == "porofluid") { - const Teuchos::ParameterList& pedyn = Global::Problem::instance()->poroelast_dynamic_params(); + const Teuchos::ParameterList& pedyn = problem->poroelast_dynamic_params(); fluidtimeparams->set("Physical Type", Teuchos::getIntegralValue(pedyn, "PHYSICAL_TYPE")); if (fluidtimeparams->get("Physical Type") != Inpar::FLUID::poro and @@ -282,7 +275,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd // add some loma specific parameters // get also scatra stabilization sublist - const Teuchos::ParameterList& lomadyn = Global::Problem::instance()->loma_control_params(); + const Teuchos::ParameterList& lomadyn = problem->loma_control_params(); fluidtimeparams->sublist("LOMA").set( "update material", lomadyn.get("SGS_MATERIAL_UPDATE")); @@ -290,18 +283,16 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd if (probtype == Core::ProblemType::fluid_xfem or probtype == Core::ProblemType::fsi_xfem or (probtype == Core::ProblemType::fpsi_xfem and disname == "fluid") or (probtype == Core::ProblemType::fluid_ale and - Global::Problem::instance()->x_fluid_dynamic_params().sublist("GENERAL").get( - "XFLUIDFLUID")) or + problem->x_fluid_dynamic_params().sublist("GENERAL").get("XFLUIDFLUID")) or (probtype == Core::ProblemType::fsi and - Global::Problem::instance()->x_fluid_dynamic_params().sublist("GENERAL").get( - "XFLUIDFLUID"))) + problem->x_fluid_dynamic_params().sublist("GENERAL").get("XFLUIDFLUID"))) { // get also scatra stabilization sublist - const Teuchos::ParameterList& xdyn = Global::Problem::instance()->xfem_general_params(); + const Teuchos::ParameterList& xdyn = problem->xfem_general_params(); fluidtimeparams->sublist("XFEM") = xdyn; // ----------------------------- sublist for xfem-specific fluid parameters - const Teuchos::ParameterList& xfdyn = Global::Problem::instance()->x_fluid_dynamic_params(); + const Teuchos::ParameterList& xfdyn = problem->x_fluid_dynamic_params(); fluidtimeparams->sublist("XFLUID DYNAMIC/GENERAL") = xfdyn.sublist("GENERAL"); fluidtimeparams->sublist("XFLUID DYNAMIC/STABILIZATION") = xfdyn.sublist("STABILIZATION"); @@ -334,7 +325,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd if (timeint == Inpar::FLUID::timeint_stationary) FOUR_C_THROW("Stationary fluid solver not allowed for FSI."); - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); const Teuchos::ParameterList& fsimono = fsidyn.sublist("MONOLITHIC SOLVER"); fluidtimeparams->set("interface second order", fsidyn.get("SECONDORDER")); @@ -344,7 +335,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd // sanity checks and default flags if (probtype == Core::ProblemType::fluid_xfem) { - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); fluidtimeparams->set("interface second order", fsidyn.get("SECONDORDER")); } @@ -352,7 +343,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd if (probtype == Core::ProblemType::fsi_xfem or (probtype == Core::ProblemType::fpsi_xfem and disname == "fluid")) { - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); const FsiCoupling coupling = Teuchos::getIntegralValue(fsidyn, "COUPALGO"); @@ -369,14 +360,14 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd if (probtype == Core::ProblemType::fluid_xfem or probtype == Core::ProblemType::fsi_xfem or (probtype == Core::ProblemType::fpsi_xfem and disname == "fluid")) { - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); const FsiCoupling coupling = Teuchos::getIntegralValue(fsidyn, "COUPALGO"); fluidtimeparams->set("COUPALGO", coupling); } if (probtype == Core::ProblemType::elch) { - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); fluidtimeparams->set("interface second order", fsidyn.get("SECONDORDER")); } @@ -385,7 +376,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd (probtype == Core::ProblemType::fps3i and disname == "porofluid") or (probtype == Core::ProblemType::fpsi_xfem and disname == "porofluid")) { - const Teuchos::ParameterList& porodyn = Global::Problem::instance()->poroelast_dynamic_params(); + const Teuchos::ParameterList& porodyn = problem->poroelast_dynamic_params(); fluidtimeparams->set("poroelast", true); fluidtimeparams->set("interface second order", porodyn.get("SECONDORDER")); fluidtimeparams->set("shape derivatives", false); @@ -476,7 +467,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd probtype == Core::ProblemType::fsi_redmodels) { // FSI input parameters - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); const auto coupling = Teuchos::getIntegralValue(fsidyn, "COUPALGO"); if (coupling == fsi_iter_monolithicfluidsplit or coupling == fsi_iter_monolithicstructuresplit or @@ -511,24 +502,21 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd case Core::ProblemType::scatra: { // HDG implements all time stepping schemes within gen-alpha - if (Global::Problem::instance()->spatial_approximation_type() == - Core::FE::ShapeFunctionType::hdg && + if (problem->spatial_approximation_type() == Core::FE::ShapeFunctionType::hdg && timeint != Inpar::FLUID::timeint_stationary && Teuchos::getIntegralValue(fdyn, "PHYSICAL_TYPE") != Inpar::FLUID::weakly_compressible_dens_mom && Teuchos::getIntegralValue(fdyn, "PHYSICAL_TYPE") != Inpar::FLUID::weakly_compressible_stokes_dens_mom) fluid_ = std::make_shared(actdis, solver, fluidtimeparams, output, isale); - else if (Global::Problem::instance()->spatial_approximation_type() == - Core::FE::ShapeFunctionType::hdg && + else if (problem->spatial_approximation_type() == Core::FE::ShapeFunctionType::hdg && (Teuchos::getIntegralValue(fdyn, "PHYSICAL_TYPE") == Inpar::FLUID::weakly_compressible_dens_mom || Teuchos::getIntegralValue(fdyn, "PHYSICAL_TYPE") == Inpar::FLUID::weakly_compressible_stokes_dens_mom)) fluid_ = std::make_shared( actdis, solver, fluidtimeparams, output, isale); - else if (Global::Problem::instance()->spatial_approximation_type() == - Core::FE::ShapeFunctionType::hdg && + else if (problem->spatial_approximation_type() == Core::FE::ShapeFunctionType::hdg && timeint == Inpar::FLUID::timeint_stationary) fluid_ = std::make_shared( actdis, solver, fluidtimeparams, output, isale); @@ -605,12 +593,10 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd break; case Core::ProblemType::fluid_xfem: { - if (Global::Problem::instance()->x_fluid_dynamic_params().sublist("GENERAL").get( - "XFLUIDFLUID")) + if (problem->x_fluid_dynamic_params().sublist("GENERAL").get("XFLUIDFLUID")) { // actdis is the embedded fluid discretization - std::shared_ptr xfluiddis = - Global::Problem::instance()->get_dis("xfluid"); + std::shared_ptr xfluiddis = problem->get_dis("xfluid"); std::shared_ptr tmpfluid; if (timeint == Inpar::FLUID::timeint_stationary) @@ -634,12 +620,10 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd break; } - std::shared_ptr soliddis = - Global::Problem::instance()->get_dis("structure"); + std::shared_ptr soliddis = problem->get_dis("structure"); std::shared_ptr scatradis = nullptr; - if (Global::Problem::instance()->does_exist_dis("scatra")) - scatradis = Global::Problem::instance()->get_dis("scatra"); + if (problem->does_exist_dis("scatra")) scatradis = problem->get_dis("scatra"); std::shared_ptr tmpfluid = std::make_shared( actdis, soliddis, scatradis, solver, fluidtimeparams, output, isale); @@ -663,7 +647,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd std::string condition_name; // FSI input parameters - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); const auto coupling = Teuchos::getIntegralValue(fsidyn, "COUPALGO"); if (coupling == fsi_iter_xfem_monolithic) { @@ -683,19 +667,16 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd else FOUR_C_THROW("non supported COUPALGO for FSI"); - std::shared_ptr soliddis = - Global::Problem::instance()->get_dis("structure"); + std::shared_ptr soliddis = problem->get_dis("structure"); std::shared_ptr tmpfluid; - if (Global::Problem::instance()->x_fluid_dynamic_params().sublist("GENERAL").get( - "XFLUIDFLUID")) + if (problem->x_fluid_dynamic_params().sublist("GENERAL").get("XFLUIDFLUID")) { FOUR_C_THROW( "XFLUIDFLUID with XFSI framework not supported via FLD::XFluidFluid but via " "FLD::XFluid"); // actdis is the embedded fluid discretization - std::shared_ptr xfluiddis = - Global::Problem::instance()->get_dis("xfluid"); + std::shared_ptr xfluiddis = problem->get_dis("xfluid"); std::shared_ptr tmpfluid_emb; if (timeint == Inpar::FLUID::timeint_stationary) @@ -721,8 +702,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd { std::shared_ptr scatradis = nullptr; - if (Global::Problem::instance()->does_exist_dis("scatra")) - scatradis = Global::Problem::instance()->get_dis("scatra"); + if (problem->does_exist_dis("scatra")) scatradis = problem->get_dis("scatra"); tmpfluid = std::make_shared( actdis, soliddis, scatradis, solver, fluidtimeparams, output, isale); @@ -742,8 +722,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd case Core::ProblemType::fluid_ale: { // std::shared_ptr tmpfluid; - if (Global::Problem::instance()->spatial_approximation_type() == - Core::FE::ShapeFunctionType::hdg && + if (problem->spatial_approximation_type() == Core::FE::ShapeFunctionType::hdg && (Teuchos::getIntegralValue(fdyn, "PHYSICAL_TYPE") == Inpar::FLUID::weakly_compressible_dens_mom || Teuchos::getIntegralValue(fdyn, "PHYSICAL_TYPE") == @@ -766,16 +745,14 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd else FOUR_C_THROW("Unknown time integration for this fluid problem type\n"); - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); const auto coupling = Teuchos::getIntegralValue(fsidyn, "COUPALGO"); - if (Global::Problem::instance()->x_fluid_dynamic_params().sublist("GENERAL").get( - "XFLUIDFLUID")) + if (problem->x_fluid_dynamic_params().sublist("GENERAL").get("XFLUIDFLUID")) { fluidtimeparams->set("shape derivatives", false); // actdis is the embedded fluid discretization - std::shared_ptr xfluiddis = - Global::Problem::instance()->get_dis("xfluid"); + std::shared_ptr xfluiddis = problem->get_dis("xfluid"); std::shared_ptr xffluid = std::make_shared( tmpfluid, xfluiddis, solver, fluidtimeparams, false, isale); fluid_ = std::make_shared( @@ -828,7 +805,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd FOUR_C_THROW("Unknown time integration for this fluid problem type\n"); } - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); const auto coupling = Teuchos::getIntegralValue(fsidyn, "COUPALGO"); if (coupling == fsi_iter_sliding_monolithicfluidsplit or @@ -907,12 +884,10 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd } else if (probtype == Core::ProblemType::fpsi_xfem) { - std::shared_ptr soliddis = - Global::Problem::instance()->get_dis("structure"); + std::shared_ptr soliddis = problem->get_dis("structure"); std::shared_ptr scatradis = nullptr; - if (Global::Problem::instance()->does_exist_dis("scatra")) - scatradis = Global::Problem::instance()->get_dis("scatra"); + if (problem->does_exist_dis("scatra")) scatradis = problem->get_dis("scatra"); fluid_ = std::make_shared( actdis, soliddis, scatradis, solver, fluidtimeparams, output, isale); @@ -923,8 +898,7 @@ void Adapter::FluidBaseAlgorithm::setup_fluid(const Teuchos::ParameterList& prbd case Core::ProblemType::elch: { // access the problem-specific parameter list - const Teuchos::ParameterList& elchcontrol = - Global::Problem::instance()->elch_control_params(); + const Teuchos::ParameterList& elchcontrol = problem->elch_control_params(); // is ALE needed or not? const ElCh::ElchMovingBoundary withale = Teuchos::getIntegralValue(elchcontrol, "MOVINGBOUNDARY"); @@ -1040,11 +1014,12 @@ void Adapter::FluidBaseAlgorithm::setup_inflow_fluid( { auto t = Teuchos::TimeMonitor::getNewTimer("Adapter::FluidBaseAlgorithm::setup_fluid"); Teuchos::TimeMonitor monitor(*t); + Global::Problem* problem = Adapter::Utils::problem_from_instance(); // ------------------------------------------------------------------- // what's the current problem type? // ------------------------------------------------------------------- - Core::ProblemType probtype = Global::Problem::instance()->get_problem_type(); + Core::ProblemType probtype = problem->get_problem_type(); // the inflow computation can only deal with standard fluid problems so far // extensions for xfluid, fsi problems have to be added if necessary @@ -1069,7 +1044,7 @@ void Adapter::FluidBaseAlgorithm::setup_inflow_fluid( // ------------------------------------------------------------------- // set some pointers and variables // ------------------------------------------------------------------- - const Teuchos::ParameterList& fdyn = Global::Problem::instance()->fluid_dynamic_params(); + const Teuchos::ParameterList& fdyn = problem->fluid_dynamic_params(); // ------------------------------------------------------------------- // create a solver @@ -1080,11 +1055,10 @@ void Adapter::FluidBaseAlgorithm::setup_inflow_fluid( FOUR_C_THROW( "no linear solver defined for fluid problem. Please set LINEAR_SOLVER in FLUID DYNAMIC to " "a valid number!"); - std::shared_ptr solver = std::make_shared( - Global::Problem::instance()->solver_params(linsolvernumber), discret->get_comm(), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + std::shared_ptr solver = + std::make_shared(problem->solver_params(linsolvernumber), + discret->get_comm(), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY")); compute_null_space_if_necessary(*discret, solver->params(), true); @@ -1218,11 +1192,12 @@ void Adapter::FluidBaseAlgorithm::set_general_parameters( const std::shared_ptr fluidtimeparams, const Teuchos::ParameterList& prbdyn, const Teuchos::ParameterList& fdyn) { + Global::Problem* problem = Adapter::Utils::problem_from_instance(); fluidtimeparams->set("BLOCKMATRIX", fdyn.get("BLOCKMATRIX")); // -------------------------------------- number of degrees of freedom // number of degrees of freedom - const int ndim = Global::Problem::instance()->n_dim(); + const int ndim = problem->n_dim(); fluidtimeparams->set("number of velocity degrees of freedom", ndim); // -------------------------------------------------- time integration @@ -1287,7 +1262,7 @@ void Adapter::FluidBaseAlgorithm::set_general_parameters( fluidtimeparams->set("INFNORMSCALING", (fdyn.get("INFNORMSCALING"))); // ----------------------------------------------- restart and output - const Teuchos::ParameterList& ioflags = Global::Problem::instance()->io_params(); + const Teuchos::ParameterList& ioflags = problem->io_params(); // restart fluidtimeparams->set("write restart every", prbdyn.get("RESTARTEVERY")); // solution output @@ -1305,7 +1280,7 @@ void Adapter::FluidBaseAlgorithm::set_general_parameters( fluidtimeparams->set( "write node data in first step", ioflags.get("FLUID_NODEDATA_FIRST_STEP")); // flag for writing fluid field to gmsh - if (not Global::Problem::instance()->io_params().get("OUTPUT_GMSH")) + if (not problem->io_params().get("OUTPUT_GMSH")) { fluidtimeparams->set("GMSH_OUTPUT", false); if (fdyn.get("GMSH_OUTPUT")) @@ -1361,8 +1336,7 @@ void Adapter::FluidBaseAlgorithm::set_general_parameters( fluidtimeparams->sublist("EDGE-BASED STABILIZATION") = fdyn.sublist("EDGE-BASED STABILIZATION"); // -----------------------------get also scatra stabilization sublist - const Teuchos::ParameterList& scatradyn = - Global::Problem::instance()->scalar_transport_dynamic_params(); + const Teuchos::ParameterList& scatradyn = problem->scalar_transport_dynamic_params(); fluidtimeparams->sublist("SCATRA STABILIZATION") = scatradyn.sublist("STABILIZATION"); // --------------------------sublist containing turbulence parameters @@ -1375,8 +1349,7 @@ void Adapter::FluidBaseAlgorithm::set_general_parameters( fluidtimeparams->sublist("WALL MODEL") = fdyn.sublist("WALL MODEL"); fluidtimeparams->sublist("TURBULENCE MODEL") - .set( - "statistics outfile", Global::Problem::instance()->output_control_file()->file_name()); + .set("statistics outfile", problem->output_control_file()->file_name()); } // ---------------------------parallel evaluation diff --git a/src/adapter/4C_adapter_fld_fluid_ale.cpp b/src/adapter/4C_adapter_fld_fluid_ale.cpp index 70460a6058..2d5d741c93 100644 --- a/src/adapter/4C_adapter_fld_fluid_ale.cpp +++ b/src/adapter/4C_adapter_fld_fluid_ale.cpp @@ -8,6 +8,7 @@ #include "4C_adapter_fld_fluid_ale.hpp" #include "4C_adapter_ale_fluid.hpp" +#include "4C_adapter_problem_access.hpp" #include "4C_ale_input.hpp" #include "4C_coupling_adapter.hpp" #include "4C_coupling_adapter_mortar.hpp" @@ -27,16 +28,17 @@ FOUR_C_NAMESPACE_OPEN Adapter::FluidAle::FluidAle(const Teuchos::ParameterList& prbdyn, std::string condname) : timeparams_(prbdyn) { - Adapter::FluidBaseAlgorithm fluid( - prbdyn, Global::Problem::instance()->fluid_dynamic_params(), "fluid", true, false); + Global::Problem* problem = Adapter::Utils::problem_from_instance(); + + Adapter::FluidBaseAlgorithm fluid(prbdyn, problem->fluid_dynamic_params(), "fluid", true, false); fluid_ = fluid.fluid_field(); - std::shared_ptr ale = std::make_shared( - prbdyn, Global::Problem::instance()->get_dis("ale")); + std::shared_ptr ale = + std::make_shared(prbdyn, problem->get_dis("ale")); ale_ = std::dynamic_pointer_cast(ale->ale_field()); if (ale_ == nullptr) FOUR_C_THROW("Failed to cast to problem-specific ALE-wrapper"); - const int ndim = Global::Problem::instance()->n_dim(); + const int ndim = problem->n_dim(); // default parameters for coupling double tolerance = 1.e-3; @@ -45,13 +47,13 @@ Adapter::FluidAle::FluidAle(const Teuchos::ParameterList& prbdyn, std::string co // set nds_master = 2 in case of HDG discretization // (nds = 0 used for trace values, nds = 1 used for interior values) - if (Global::Problem::instance()->spatial_approximation_type() == Core::FE::ShapeFunctionType::hdg) + if (problem->spatial_approximation_type() == Core::FE::ShapeFunctionType::hdg) { nds_master = 2; } // check for matching fluid and ale meshes (==true in default case) - if (Global::Problem::instance()->fsi_dynamic_params().get("MATCHGRID_FLUIDALE")) + if (problem->fsi_dynamic_params().get("MATCHGRID_FLUIDALE")) { // the fluid-ale coupling matches const Core::LinAlg::Map* fluidnodemap = fluid_field()->discretization()->node_row_map(); @@ -67,8 +69,7 @@ Adapter::FluidAle::FluidAle(const Teuchos::ParameterList& prbdyn, std::string co std::make_shared(); coupfa_matching->setup_coupling(*fluid_field()->discretization(), *ale_field()->discretization(), *fluidnodemap, *alenodemap, ndim, - Global::Problem::instance()->fsi_dynamic_params().get("MATCHALL"), tolerance, - nds_master, nds_slave); + problem->fsi_dynamic_params().get("MATCHALL"), tolerance, nds_master, nds_slave); coupfa_ = coupfa_matching; } else @@ -97,16 +98,15 @@ Adapter::FluidAle::FluidAle(const Teuchos::ParameterList& prbdyn, std::string co &dofsets21, nullptr, false); // setup coupling adapter - coupfa_volmortar->setup(Global::Problem::instance()->volmortar_params(), - Global::Problem::instance()->cut_general_params()); + coupfa_volmortar->setup(problem->volmortar_params(), problem->cut_general_params()); // set pointer to coupling adapter coupfa_ = coupfa_volmortar; } // Apply initial ALE mesh displacement - if (Teuchos::getIntegralValue(Global::Problem::instance()->ale_dynamic_params(), - "INITIALDISP") != ALE::initdisp_zero_disp) + if (Teuchos::getIntegralValue(problem->ale_dynamic_params(), "INITIALDISP") != + ALE::initdisp_zero_disp) { fluid_field()->set_mesh_map(coupfa_->master_dof_map(), nds_master); std::shared_ptr> initfluiddisp = @@ -117,11 +117,10 @@ Adapter::FluidAle::FluidAle(const Teuchos::ParameterList& prbdyn, std::string co // initializing the fluid is done later as for xfluids the first cut is done // there (coupfa_ cannot be build anymore!!!) fluid_field()->init(); - fluid.set_initial_flow_field( - Global::Problem::instance()->fluid_dynamic_params()); // call from base algorithm + fluid.set_initial_flow_field(problem->fluid_dynamic_params()); // call from base algorithm - if (Global::Problem::instance()->fsi_dynamic_params().get("MATCHGRID_STRUCTALE")) + if (problem->fsi_dynamic_params().get("MATCHGRID_STRUCTALE")) { std::shared_ptr icoupfa = std::make_shared(); @@ -149,12 +148,10 @@ Adapter::FluidAle::FluidAle(const Teuchos::ParameterList& prbdyn, std::string co std::pair dofsets12(0, 0); std::pair dofsets21(0, 0); - icoupfa->init(ndim, Global::Problem::instance()->get_dis("fluid"), - Global::Problem::instance()->get_dis("ale"), &coupleddof12, &coupleddof21, &dofsets12, - &dofsets21, nullptr, false); + icoupfa->init(ndim, problem->get_dis("fluid"), problem->get_dis("ale"), &coupleddof12, + &coupleddof21, &dofsets12, &dofsets21, nullptr, false); - icoupfa->setup(Global::Problem::instance()->volmortar_params(), - Global::Problem::instance()->cut_general_params()); + icoupfa->setup(problem->volmortar_params(), problem->cut_general_params()); icoupfa_ = icoupfa; } @@ -202,13 +199,15 @@ void Adapter::FluidAle::update() /*----------------------------------------------------------------------------*/ void Adapter::FluidAle::output() { + Global::Problem* problem = Adapter::Utils::problem_from_instance(); + fluid_field()->statistics_and_output(); // Note: We want to write the fsi interface tractions in order to restart // monolithically from an partitioned fsi scheme (e.g. fsi prestress simulation). // TODO (Thon): this is not the nice way, but fluid-ale and xfem problems may have now FSI // interface, so we can not do this in general :( - if (Global::Problem::instance()->get_problem_type() == Core::ProblemType::fsi) + if (problem->get_problem_type() == Core::ProblemType::fsi) { // we want to be able to restart monolithically from an partitioned fsi scheme const int uprestart = timeparams_.get("RESTARTEVERY"); diff --git a/src/adapter/4C_adapter_problem_access.hpp b/src/adapter/4C_adapter_problem_access.hpp new file mode 100644 index 0000000000..e41ea6df01 --- /dev/null +++ b/src/adapter/4C_adapter_problem_access.hpp @@ -0,0 +1,24 @@ +// This file is part of 4C multiphysics licensed under the +// GNU Lesser General Public License v3.0 or later. +// +// See the LICENSE.md file in the top-level for license information. +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef FOUR_C_ADAPTER_PROBLEM_ACCESS_HPP +#define FOUR_C_ADAPTER_PROBLEM_ACCESS_HPP + +#include "4C_config.hpp" + +#include "4C_global_data.hpp" + +FOUR_C_NAMESPACE_OPEN + +namespace Adapter::Utils +{ + inline Global::Problem* problem_from_instance() { return Global::Problem::instance(); } +} // namespace Adapter::Utils + +FOUR_C_NAMESPACE_CLOSE + +#endif diff --git a/src/fs3i/4C_fs3i.cpp b/src/fs3i/4C_fs3i.cpp index fcf96cb893..7b10a4bae2 100644 --- a/src/fs3i/4C_fs3i.cpp +++ b/src/fs3i/4C_fs3i.cpp @@ -14,6 +14,7 @@ #include "4C_fem_condition_selector.hpp" #include "4C_fluid_implicit_integration.hpp" #include "4C_fs3i_input.hpp" +#include "4C_fs3i_problem_access.hpp" #include "4C_fsi_dyn.hpp" #include "4C_fsi_monolithicfluidsplit.hpp" #include "4C_fsi_monolithicstructuresplit.hpp" @@ -30,13 +31,21 @@ FOUR_C_NAMESPACE_OPEN +namespace +{ + const Teuchos::ParameterList& fs3i_dynamic_params_from_problem() + { + return FS3I::Utils::fs3i_dynamic_params_from_problem(); + } +} // namespace + /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ FS3I::FS3IBase::FS3IBase() - : infperm_(Global::Problem::instance()->f_s3_i_dynamic_params().get("INF_PERM")), - timemax_(Global::Problem::instance()->f_s3_i_dynamic_params().get("MAXTIME")), - numstep_(Global::Problem::instance()->f_s3_i_dynamic_params().get("NUMSTEP")), - dt_(Global::Problem::instance()->f_s3_i_dynamic_params().get("TIMESTEP")), + : infperm_(fs3i_dynamic_params_from_problem().get("INF_PERM")), + timemax_(fs3i_dynamic_params_from_problem().get("MAXTIME")), + numstep_(fs3i_dynamic_params_from_problem().get("NUMSTEP")), + dt_(fs3i_dynamic_params_from_problem().get("TIMESTEP")), time_(0.0), step_(0), issetup_(false), @@ -155,7 +164,7 @@ void FS3I::FS3IBase::check_interface_dirichlet_bc() void FS3I::FS3IBase::check_f_s3_i_inputs() { // Check FS3I dynamic parameters - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FS3I::Utils::problem_from_instance(); const Teuchos::ParameterList& fs3idyn = problem->f_s3_i_dynamic_params(); const Teuchos::ParameterList& structdynparams = problem->structural_dynamic_params(); const Teuchos::ParameterList& scatradynparams = problem->scalar_transport_dynamic_params(); @@ -228,8 +237,7 @@ void FS3I::FS3IBase::check_f_s3_i_inputs() "in the structure is NOT divergence free!"); } - auto pstype = Teuchos::getIntegralValue( - Global::Problem::instance()->structural_dynamic_params(), "PRESTRESS"); + auto pstype = Teuchos::getIntegralValue(structdynparams, "PRESTRESS"); // is structure calculated dynamic when not prestressing? if (Teuchos::getIntegralValue(structdynparams, "DYNAMICTYPE") == Inpar::Solid::DynamicType::Statics and diff --git a/src/fs3i/4C_fs3i_biofilm_fsi.cpp b/src/fs3i/4C_fs3i_biofilm_fsi.cpp index fd8a880544..8bf4dc7dbb 100644 --- a/src/fs3i/4C_fs3i_biofilm_fsi.cpp +++ b/src/fs3i/4C_fs3i_biofilm_fsi.cpp @@ -18,6 +18,7 @@ #include "4C_fem_geometry_update_reference_config.hpp" #include "4C_fluid_utils_mapextractor.hpp" #include "4C_fs3i_biofilm_fsi_utils.hpp" +#include "4C_fs3i_problem_access.hpp" #include "4C_fsi_monolithicfluidsplit.hpp" #include "4C_global_data.hpp" #include "4C_io.hpp" @@ -60,7 +61,7 @@ void FS3I::BiofilmFSI::init() // this algorithm needs an ale discretization also for the structure in order to be able to handle // the growth - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FS3I::Utils::problem_from_instance(); problem->get_dis("structale")->fill_complete(); // create struct ale elements if not yet existing @@ -95,13 +96,11 @@ void FS3I::BiofilmFSI::init() // getting and initializing problem-specific parameters //--------------------------------------------------------------------- - const Teuchos::ParameterList& biofilmcontrol = - Global::Problem::instance()->biofilm_control_params(); + const Teuchos::ParameterList& biofilmcontrol = problem->biofilm_control_params(); // make sure that initial time derivative of concentration is not calculated // automatically (i.e. field-wise) - const Teuchos::ParameterList& scatradyn = - Global::Problem::instance()->scalar_transport_dynamic_params(); + const Teuchos::ParameterList& scatradyn = problem->scalar_transport_dynamic_params(); if (not scatradyn.get("SKIPINITDER")) FOUR_C_THROW( "Initial time derivative of phi must not be calculated automatically -> set SKIPINITDER to " @@ -146,11 +145,12 @@ void FS3I::BiofilmFSI::init() /*----------------------------------------------------------------------*/ void FS3I::BiofilmFSI::setup() { + auto* problem = FS3I::Utils::problem_from_instance(); + // call setup() in base class FS3I::PartFS3I1Wc::setup(); - std::shared_ptr structaledis = - Global::Problem::instance()->get_dis("structale"); + std::shared_ptr structaledis = problem->get_dis("structale"); // create fluid-ALE Dirichlet Map Extractor for FSI step ale_->setup_dbc_map_ex(ALE::Utils::MapExtractor::dbc_set_std); @@ -170,7 +170,7 @@ void FS3I::BiofilmFSI::setup() //--------------------------------------------------------------------- const std::string condname = "FSICoupling"; - const int ndim = Global::Problem::instance()->n_dim(); + const int ndim = problem->n_dim(); // set up ale-fluid couplings icoupfa_ = std::make_shared(); @@ -249,8 +249,8 @@ void FS3I::BiofilmFSI::timeloop() check_is_setup(); - const Teuchos::ParameterList& biofilmcontrol = - Global::Problem::instance()->biofilm_control_params(); + auto* problem = FS3I::Utils::problem_from_instance(); + const Teuchos::ParameterList& biofilmcontrol = problem->biofilm_control_params(); const bool biofilmgrowth = biofilmcontrol.get("BIOFILMGROWTH"); const bool outputgmsh_ = biofilmcontrol.get("OUTPUT_GMSH"); @@ -354,8 +354,8 @@ void FS3I::BiofilmFSI::inner_timeloop() // Calculation of growth can be based both on values averaged during the inner timeloop // (in this case for the time being it takes in account also the initial transient state!), // or only on the last values coming from the fsi-scatra simulation - const Teuchos::ParameterList& biofilmcontrol = - Global::Problem::instance()->biofilm_control_params(); + auto* problem = FS3I::Utils::problem_from_instance(); + const Teuchos::ParameterList& biofilmcontrol = problem->biofilm_control_params(); const bool avgrowth = biofilmcontrol.get("AVGROWTH"); // in case of averaged values we need temporary variables Core::LinAlg::Vector normtempinflux_( @@ -433,7 +433,7 @@ void FS3I::BiofilmFSI::inner_timeloop() // at the purpose to compute lambdafull, it is necessary to know which coupling algorithm is // used however the imposition of a Dirichlet condition on the interface produce wrong lambda_ // when structuresplit is used - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); const auto coupling = Teuchos::getIntegralValue(fsidyn, "COUPALGO"); if (coupling == fsi_iter_monolithicfluidsplit) { @@ -891,12 +891,12 @@ std::shared_ptr> FS3I::BiofilmFSI::struct_to_ale( void FS3I::BiofilmFSI::vec_to_scatravec(Core::FE::Discretization& scatradis, Core::LinAlg::Vector& vec, Core::LinAlg::MultiVector& scatravec) { + auto* problem = FS3I::Utils::problem_from_instance(); + const int numdim = problem->n_dim(); + // loop over all local nodes of scatra discretization for (int lnodeid = 0; lnodeid < scatradis.num_my_row_nodes(); lnodeid++) { - // determine number of space dimensions - const int numdim = Global::Problem::instance()->n_dim(); - for (int index = 0; index < numdim; ++index) { double vecval = vec.local_values_as_span()[index + numdim * lnodeid]; diff --git a/src/fs3i/4C_fs3i_biofilm_fsi_utils.cpp b/src/fs3i/4C_fs3i_biofilm_fsi_utils.cpp index f1da5f731e..3a12ee77fd 100644 --- a/src/fs3i/4C_fs3i_biofilm_fsi_utils.cpp +++ b/src/fs3i/4C_fs3i_biofilm_fsi_utils.cpp @@ -9,6 +9,7 @@ #include "4C_fem_discretization.hpp" #include "4C_fem_general_node.hpp" +#include "4C_fs3i_problem_access.hpp" #include "4C_global_data.hpp" #include "4C_linalg_utils_sparse_algebra_manipulation.hpp" @@ -48,7 +49,7 @@ void FS3I::BioFilm::Utils::scatra_change_config(Core::FE::Discretization& scatra std::vector nvector(3, 0.0); // determine number of space dimensions - const int numdim = Global::Problem::instance()->n_dim(); + const int numdim = FS3I::Utils::problem_from_instance()->n_dim(); for (int i = 0; i < numdim; ++i) { diff --git a/src/fs3i/4C_fs3i_dyn.cpp b/src/fs3i/4C_fs3i_dyn.cpp index 6fcf76eeb5..0fb2f35eb5 100644 --- a/src/fs3i/4C_fs3i_dyn.cpp +++ b/src/fs3i/4C_fs3i_dyn.cpp @@ -14,6 +14,7 @@ #include "4C_fs3i_fps3i_partitioned_1wc.hpp" #include "4C_fs3i_partitioned_1wc.hpp" #include "4C_fs3i_partitioned_2wc.hpp" +#include "4C_fs3i_problem_access.hpp" #include "4C_global_data.hpp" #include "4C_utils_enum.hpp" @@ -25,12 +26,14 @@ FOUR_C_NAMESPACE_OPEN /*----------------------------------------------------------------------*/ void fs3i_dyn() { - MPI_Comm comm = Global::Problem::instance()->get_dis("structure")->get_comm(); + Global::Problem* problem = FS3I::Utils::problem_from_instance(); + + MPI_Comm comm = problem->get_dis("structure")->get_comm(); std::shared_ptr fs3i; // what's the current problem type? - Core::ProblemType probtype = Global::Problem::instance()->get_problem_type(); + Core::ProblemType probtype = problem->get_problem_type(); switch (probtype) { diff --git a/src/fs3i/4C_fs3i_fps3i_partitioned.cpp b/src/fs3i/4C_fs3i_fps3i_partitioned.cpp index 0a0f723f20..a2512b66a2 100644 --- a/src/fs3i/4C_fs3i_fps3i_partitioned.cpp +++ b/src/fs3i/4C_fs3i_fps3i_partitioned.cpp @@ -15,6 +15,7 @@ #include "4C_fluid_utils_mapextractor.hpp" #include "4C_fpsi_monolithic_plain.hpp" #include "4C_fpsi_utils.hpp" +#include "4C_fs3i_problem_access.hpp" #include "4C_fsi_utils.hpp" #include "4C_global_data.hpp" #include "4C_inpar_scatra.hpp" @@ -82,7 +83,7 @@ void FS3I::PartFPS3I::init() std::cout << std::endl; } // ################## 1.- Parameter reading //######################### - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FS3I::Utils::problem_from_instance(); const Teuchos::ParameterList& fs3idyn = problem->f_s3_i_dynamic_params(); const Teuchos::ParameterList& fpsidynparams = problem->fpsi_dynamic_params(); const Teuchos::ParameterList& poroelastdynparams = problem->poroelast_dynamic_params(); @@ -136,8 +137,8 @@ void FS3I::PartFPS3I::init() std::shared_ptr structscatradis = problem->get_dis("scatra2"); // determine type of scalar transport - const auto impltype_fluid = Teuchos::getIntegralValue( - Global::Problem::instance()->f_s3_i_dynamic_params(), "FLUIDSCAL_SCATRATYPE"); + const auto impltype_fluid = + Teuchos::getIntegralValue(fs3idyn, "FLUIDSCAL_SCATRATYPE"); //--------------------------------------------------------------------- // create discretization for fluid-based scalar transport from and @@ -156,7 +157,7 @@ void FS3I::PartFPS3I::init() { // fill fluid-based scatra discretization by cloning fluid discretization Core::FE::clone_discretization( - *fluiddis, *fluidscatradis, Global::Problem::instance()->cloning_material_map()); + *fluiddis, *fluidscatradis, problem->cloning_material_map()); fluidscatradis->fill_complete(); // set implementation type of cloned scatra elements to advanced reactions @@ -184,7 +185,7 @@ void FS3I::PartFPS3I::init() { // fill poro-based scatra discretization by cloning structure discretization Core::FE::clone_discretization( - *structdis, *structscatradis, Global::Problem::instance()->cloning_material_map()); + *structdis, *structscatradis, problem->cloning_material_map()); } else FOUR_C_THROW("Structure AND ScaTra discretization present. This is not supported."); @@ -344,7 +345,7 @@ void FS3I::PartFPS3I::read_restart() { // read restart information, set vectors and variables // (Note that dofmaps might have changed in a redistribution call!) - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FS3I::Utils::problem_from_instance(); const int restart = problem->restart(); if (restart) @@ -371,7 +372,7 @@ void FS3I::PartFPS3I::redistribute_interface() { fpsi_->redistribute_interface(); - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FS3I::Utils::problem_from_instance(); if (Core::Communication::num_mpi_ranks(comm_) > 1) // if we have more than one processor, we need to redistribute at the FPSI interface @@ -402,6 +403,8 @@ void FS3I::PartFPS3I::redistribute_interface() *----------------------------------------------------------------------*/ void FS3I::PartFPS3I::setup_system() { + Global::Problem* problem = FS3I::Utils::problem_from_instance(); + // do the coupling setup and create the combined dofmap // Setup FPSI system @@ -493,7 +496,7 @@ void FS3I::PartFPS3I::setup_system() std::shared_ptr firstscatradis = (scatravec_[0])->scatra_field()->discretization(); - const Teuchos::ParameterList& fs3idyn = Global::Problem::instance()->f_s3_i_dynamic_params(); + const Teuchos::ParameterList& fs3idyn = problem->f_s3_i_dynamic_params(); // get solver number used for fs3i const int linsolvernumber = fs3idyn.get("COUPLED_LINEAR_SOLVER"); // check if LOMA solvers has a valid number @@ -501,8 +504,7 @@ void FS3I::PartFPS3I::setup_system() FOUR_C_THROW( "no linear solver defined for FS3I problems. Please set COUPLED_LINEAR_SOLVER in FS3I " "DYNAMIC to a valid number!"); - const Teuchos::ParameterList& coupledscatrasolvparams = - Global::Problem::instance()->solver_params(linsolvernumber); + const Teuchos::ParameterList& coupledscatrasolvparams = problem->solver_params(linsolvernumber); const auto solvertype = Teuchos::getIntegralValue(coupledscatrasolvparams, "SOLVER"); @@ -518,9 +520,8 @@ void FS3I::PartFPS3I::setup_system() // use coupled scatra solver object scatrasolver_ = std::make_shared(coupledscatrasolvparams, - firstscatradis->get_comm(), Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + firstscatradis->get_comm(), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY")); // get the solver number used for structural ScalarTransport solver const int linsolver1number = fs3idyn.get("LINEAR_SOLVER1"); // get the solver number used for structural ScalarTransport solver @@ -536,16 +537,12 @@ void FS3I::PartFPS3I::setup_system() "no linear solver defined for structural ScalarTransport solver. Please set LINEAR_SOLVER2 " "in FS3I DYNAMIC to a valid number!"); scatrasolver_->put_solver_params_to_sub_params("Inverse1", - Global::Problem::instance()->solver_params(linsolver1number), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"), + problem->solver_params(linsolver1number), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY"), get_comm()); scatrasolver_->put_solver_params_to_sub_params("Inverse2", - Global::Problem::instance()->solver_params(linsolver2number), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"), + problem->solver_params(linsolver2number), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY"), get_comm()); if (azprectype == Core::LinearSolver::PreconditionerType::block_teko) @@ -565,15 +562,16 @@ void FS3I::PartFPS3I::setup_system() *----------------------------------------------------------------------*/ void FS3I::PartFPS3I::test_results(MPI_Comm comm) { - Global::Problem::instance()->add_field_test(fpsi_->fluid_field()->create_field_test()); + auto* problem = FS3I::Utils::problem_from_instance(); + problem->add_field_test(fpsi_->fluid_field()->create_field_test()); fpsi_->poro_field()->structure_field()->create_field_test(); for (unsigned i = 0; i < scatravec_.size(); ++i) { std::shared_ptr scatra = scatravec_[i]; - Global::Problem::instance()->add_field_test(scatra->create_scatra_field_test()); + problem->add_field_test(scatra->create_scatra_field_test()); } - Global::Problem::instance()->test_all(comm); + problem->test_all(comm); } @@ -628,7 +626,7 @@ void FS3I::PartFPS3I::set_mesh_disp() *----------------------------------------------------------------------*/ void FS3I::PartFPS3I::set_velocity_fields() { - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FS3I::Utils::problem_from_instance(); const Teuchos::ParameterList& scatradyn = problem->scalar_transport_dynamic_params(); const auto cdvel = Teuchos::getIntegralValue(scatradyn, "VELOCITYFIELD"); diff --git a/src/fs3i/4C_fs3i_fps3i_partitioned_1wc.cpp b/src/fs3i/4C_fs3i_fps3i_partitioned_1wc.cpp index b1af8dd23f..643e0affa4 100644 --- a/src/fs3i/4C_fs3i_fps3i_partitioned_1wc.cpp +++ b/src/fs3i/4C_fs3i_fps3i_partitioned_1wc.cpp @@ -20,6 +20,7 @@ #include "4C_fpsi_monolithic.hpp" #include "4C_fpsi_monolithic_plain.hpp" #include "4C_fpsi_utils.hpp" +#include "4C_fs3i_problem_access.hpp" #include "4C_fsi_monolithic.hpp" #include "4C_global_data.hpp" #include "4C_inpar_scatra.hpp" @@ -187,7 +188,8 @@ void FS3I::PartFpS3I1Wc::prepare_time_step() *----------------------------------------------------------------------*/ bool FS3I::PartFpS3I1Wc::scatra_convergence_check(const int itnum) { - const Teuchos::ParameterList& fs3idyn = Global::Problem::instance()->f_s3_i_dynamic_params(); + const auto* problem = FS3I::Utils::problem_from_instance(); + const Teuchos::ParameterList& fs3idyn = problem->f_s3_i_dynamic_params(); auto scatra_solvtype = Teuchos::getIntegralValue(fs3idyn, "SCATRA_SOLVERTYPE"); @@ -215,8 +217,7 @@ bool FS3I::PartFpS3I1Wc::scatra_convergence_check(const int itnum) case Inpar::ScaTra::solvertype_nonlinear: { // some input parameters for the scatra fields - const Teuchos::ParameterList& scatradyn = - Global::Problem::instance()->scalar_transport_dynamic_params(); + const Teuchos::ParameterList& scatradyn = problem->scalar_transport_dynamic_params(); const int itemax = scatradyn.sublist("NONLINEAR").get("ITEMAX"); const double ittol = scatradyn.sublist("NONLINEAR").get("CONVTOL"); const double abstolres = scatradyn.sublist("NONLINEAR").get("ABSTOLRES"); diff --git a/src/fs3i/4C_fs3i_partitioned.cpp b/src/fs3i/4C_fs3i_partitioned.cpp index c3f502e705..988411e466 100644 --- a/src/fs3i/4C_fs3i_partitioned.cpp +++ b/src/fs3i/4C_fs3i_partitioned.cpp @@ -19,6 +19,7 @@ #include "4C_fem_dofset_predefineddofnumber.hpp" #include "4C_fem_general_utils_createdis.hpp" #include "4C_fluid_utils_mapextractor.hpp" +#include "4C_fs3i_problem_access.hpp" #include "4C_fsi_monolithicfluidsplit.hpp" #include "4C_fsi_monolithicstructuresplit.hpp" #include "4C_fsi_utils.hpp" @@ -38,6 +39,11 @@ FOUR_C_NAMESPACE_OPEN +namespace +{ + auto* problem_from_instance() { return FS3I::Utils::problem_from_instance(); } +} // namespace + /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ @@ -54,12 +60,12 @@ void FS3I::PartFS3I::init() // call setup in base class FS3I::FS3IBase::init(); + Global::Problem* problem = problem_from_instance(); + volume_fieldcouplings_.push_back(Teuchos::getIntegralValue( - Global::Problem::instance()->f_s3_i_dynamic_params(), "FLUIDSCAL_FIELDCOUPLING")); + problem->f_s3_i_dynamic_params(), "FLUIDSCAL_FIELDCOUPLING")); volume_fieldcouplings_.push_back(Teuchos::getIntegralValue( - Global::Problem::instance()->f_s3_i_dynamic_params(), "STRUCTSCAL_FIELDCOUPLING")); - - Global::Problem* problem = Global::Problem::instance(); + problem->f_s3_i_dynamic_params(), "STRUCTSCAL_FIELDCOUPLING")); const Teuchos::ParameterList& fs3idyn = problem->f_s3_i_dynamic_params(); //--------------------------------------------------------------------- @@ -90,7 +96,7 @@ void FS3I::PartFS3I::init() if (aledis->num_global_nodes() == 0) { Core::FE::clone_discretization( - *fluiddis, *aledis, Global::Problem::instance()->cloning_material_map()); + *fluiddis, *aledis, problem->cloning_material_map()); aledis->fill_complete(); // setup material in every ALE element Teuchos::ParameterList params; @@ -106,7 +112,7 @@ void FS3I::PartFS3I::init() // determine type of scalar transport const auto impltype_fluid = Teuchos::getIntegralValue( - Global::Problem::instance()->f_s3_i_dynamic_params(), "FLUIDSCAL_SCATRATYPE"); + problem->f_s3_i_dynamic_params(), "FLUIDSCAL_SCATRATYPE"); //--------------------------------------------------------------------- // create discretization for fluid-based scalar transport from and @@ -125,7 +131,7 @@ void FS3I::PartFS3I::init() // fill fluid-based scatra discretization by cloning fluid discretization Core::FE::clone_discretization( - *fluiddis, *fluidscatradis, Global::Problem::instance()->cloning_material_map()); + *fluiddis, *fluidscatradis, problem->cloning_material_map()); fluidscatradis->fill_complete(); // set implementation type of cloned scatra elements to advanced reactions for (int i = 0; i < fluidscatradis->num_my_col_elements(); ++i) @@ -179,7 +185,7 @@ void FS3I::PartFS3I::init() // fill structure-based scatra discretization by cloning structure discretization Core::FE::clone_discretization( - *structdis, *structscatradis, Global::Problem::instance()->cloning_material_map()); + *structdis, *structscatradis, problem->cloning_material_map()); structscatradis->fill_complete(); volume_coupling_objects_.push_back(nullptr); @@ -344,6 +350,8 @@ std::shared_ptr FS3I::PartFS3I::create_vol_mo std::shared_ptr masterdis, std::shared_ptr slavedis) { + Global::Problem* problem = problem_from_instance(); + // copy conditions // this is actually only needed for copying TRANSPORT DIRICHLET/NEUMANN CONDITIONS // as standard DIRICHLET/NEUMANN CONDITIONS @@ -395,11 +403,10 @@ std::shared_ptr FS3I::PartFS3I::create_vol_mo std::make_shared(); // setup projection matrices (use default material strategy) - volume_coupling_object->init(Global::Problem::instance()->n_dim(), masterdis, slavedis); - Teuchos::ParameterList binning_params = Global::Problem::instance()->binning_strategy_params(); + volume_coupling_object->init(problem->n_dim(), masterdis, slavedis); + Teuchos::ParameterList binning_params = problem->binning_strategy_params(); Core::Utils::add_enum_class_to_parameter_list( - "spatial_approximation_type", Global::Problem::instance()->spatial_approximation_type(), - binning_params); + "spatial_approximation_type", problem->spatial_approximation_type(), binning_params); auto correct_node = [](const Core::Nodes::Node& node) -> decltype(auto) { @@ -426,10 +433,9 @@ std::shared_ptr FS3I::PartFS3I::create_vol_mo return Core::Binstrategy::DefaultRelevantPoints{}(discret, ele, disnp); }; - volume_coupling_object->redistribute(binning_params, - Global::Problem::instance()->output_control_file(), correct_node, determine_relevant_points); - volume_coupling_object->setup(Global::Problem::instance()->volmortar_params(), - Global::Problem::instance()->cut_general_params()); + volume_coupling_object->redistribute( + binning_params, problem->output_control_file(), correct_node, determine_relevant_points); + volume_coupling_object->setup(problem->volmortar_params(), problem->cut_general_params()); return volume_coupling_object; } @@ -451,13 +457,15 @@ Teuchos::ParameterList& FS3I::PartFS3I::manipulate_fsi_time_params( /*----------------------------------------------------------------------*/ void FS3I::PartFS3I::read_restart() { + const Global::Problem* problem = problem_from_instance(); + // read restart information, set vectors and variables // (Note that dofmaps might have changed in a redistribution call!) - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { - const Teuchos::ParameterList& fs3idynac = Global::Problem::instance()->f_s3_i_dynamic_params(); + const Teuchos::ParameterList& fs3idynac = problem->f_s3_i_dynamic_params(); const bool restartfrompartfsi = fs3idynac.get("RESTART_FROM_PART_FSI"); if (not restartfrompartfsi) // standard restart @@ -494,6 +502,8 @@ void FS3I::PartFS3I::read_restart() /*----------------------------------------------------------------------*/ void FS3I::PartFS3I::setup_system() { + const Global::Problem* problem = problem_from_instance(); + // now do the coupling setup and create the combined dofmap fsi_->setup_system(); @@ -586,7 +596,7 @@ void FS3I::PartFS3I::setup_system() // scatra solver std::shared_ptr firstscatradis = (scatravec_[0])->scatra_field()->discretization(); - const Teuchos::ParameterList& fs3idyn = Global::Problem::instance()->f_s3_i_dynamic_params(); + const Teuchos::ParameterList& fs3idyn = problem->f_s3_i_dynamic_params(); // get solver number used for fs3i const int linsolvernumber = fs3idyn.get("COUPLED_LINEAR_SOLVER"); // check if LOMA solvers has a valid number @@ -595,8 +605,7 @@ void FS3I::PartFS3I::setup_system() "no linear solver defined for FS3I problems. Please set COUPLED_LINEAR_SOLVER in FS3I " "DYNAMIC to a valid number!"); - const Teuchos::ParameterList& coupledscatrasolvparams = - Global::Problem::instance()->solver_params(linsolvernumber); + const Teuchos::ParameterList& coupledscatrasolvparams = problem->solver_params(linsolvernumber); const auto solvertype = Teuchos::getIntegralValue(coupledscatrasolvparams, "SOLVER"); @@ -611,9 +620,8 @@ void FS3I::PartFS3I::setup_system() // use coupled scatra solver object scatrasolver_ = std::make_shared(coupledscatrasolvparams, - firstscatradis->get_comm(), Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + firstscatradis->get_comm(), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY")); // get the solver number used for fluid ScalarTransport solver const int linsolver1number = fs3idyn.get("LINEAR_SOLVER1"); @@ -631,16 +639,12 @@ void FS3I::PartFS3I::setup_system() "in FS3I DYNAMIC to a valid number!"); scatrasolver_->put_solver_params_to_sub_params("Inverse1", - Global::Problem::instance()->solver_params(linsolver1number), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"), + problem->solver_params(linsolver1number), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY"), get_comm()); scatrasolver_->put_solver_params_to_sub_params("Inverse2", - Global::Problem::instance()->solver_params(linsolver2number), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"), + problem->solver_params(linsolver2number), problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY"), get_comm()); if (azprectype == Core::LinearSolver::PreconditionerType::block_teko) @@ -659,16 +663,18 @@ void FS3I::PartFS3I::setup_system() /*----------------------------------------------------------------------*/ void FS3I::PartFS3I::test_results(MPI_Comm comm) { - Global::Problem::instance()->add_field_test(fsi_->fluid_field()->create_field_test()); - Global::Problem::instance()->add_field_test(fsi_->ale_field()->create_field_test()); - Global::Problem::instance()->add_field_test(fsi_->structure_field()->create_field_test()); + Global::Problem* problem = problem_from_instance(); + + problem->add_field_test(fsi_->fluid_field()->create_field_test()); + problem->add_field_test(fsi_->ale_field()->create_field_test()); + problem->add_field_test(fsi_->structure_field()->create_field_test()); for (unsigned i = 0; i < scatravec_.size(); ++i) { std::shared_ptr scatra = scatravec_[i]; - Global::Problem::instance()->add_field_test(scatra->create_scatra_field_test()); + problem->add_field_test(scatra->create_scatra_field_test()); } - Global::Problem::instance()->test_all(comm); + problem->test_all(comm); } @@ -796,6 +802,8 @@ void FS3I::PartFS3I::set_wall_shear_stresses() const void FS3I::PartFS3I::extract_wss( std::vector>>& wss) const { + const Global::Problem* problem = problem_from_instance(); + // ############ Fluid Field ############### std::shared_ptr fluid = @@ -806,8 +814,7 @@ void FS3I::PartFS3I::extract_wss( fluid->calculate_wall_shear_stresses(); if (Teuchos::getIntegralValue( - Global::Problem::instance()->fluid_dynamic_params(), "WSS_TYPE") != - Inpar::FLUID::wss_standard) + problem->fluid_dynamic_params(), "WSS_TYPE") != Inpar::FLUID::wss_standard) FOUR_C_THROW("WSS_TYPE not supported for FS3I!"); wss.push_back(WallShearStress); diff --git a/src/fs3i/4C_fs3i_partitioned_1wc.cpp b/src/fs3i/4C_fs3i_partitioned_1wc.cpp index 86ac4aca9c..10a04dcbcd 100644 --- a/src/fs3i/4C_fs3i_partitioned_1wc.cpp +++ b/src/fs3i/4C_fs3i_partitioned_1wc.cpp @@ -11,6 +11,7 @@ #include "4C_adapter_str_fsiwrapper.hpp" #include "4C_comm_mpi_utils.hpp" #include "4C_fem_discretization.hpp" +#include "4C_fs3i_problem_access.hpp" #include "4C_fsi_monolithic.hpp" #include "4C_global_data.hpp" #include "4C_inpar_scatra.hpp" @@ -54,8 +55,9 @@ void FS3I::PartFS3I1Wc::timeloop() set_fsi_solution(); // calculate initial time derivative, when restart was done from a part. FSI simulation - if (static_cast(Global::Problem::instance()->restart()) and - Global::Problem::instance()->f_s3_i_dynamic_params().get("RESTART_FROM_PART_FSI")) + const auto* problem = FS3I::Utils::problem_from_instance(); + if (static_cast(problem->restart()) and + problem->f_s3_i_dynamic_params().get("RESTART_FROM_PART_FSI")) { scatravec_[0]->scatra_field()->prepare_first_time_step(); scatravec_[1]->scatra_field()->prepare_first_time_step(); @@ -151,7 +153,8 @@ void FS3I::PartFS3I1Wc::prepare_time_step() /*----------------------------------------------------------------------*/ bool FS3I::PartFS3I1Wc::scatra_convergence_check(const int itnum) { - const Teuchos::ParameterList& fs3idyn = Global::Problem::instance()->f_s3_i_dynamic_params(); + const auto* problem = FS3I::Utils::problem_from_instance(); + const Teuchos::ParameterList& fs3idyn = problem->f_s3_i_dynamic_params(); auto scatra_solvtype = Teuchos::getIntegralValue(fs3idyn, "SCATRA_SOLVERTYPE"); @@ -179,8 +182,7 @@ bool FS3I::PartFS3I1Wc::scatra_convergence_check(const int itnum) case Inpar::ScaTra::solvertype_nonlinear: { // some input parameters for the scatra fields - const Teuchos::ParameterList& scatradyn = - Global::Problem::instance()->scalar_transport_dynamic_params(); + const Teuchos::ParameterList& scatradyn = problem->scalar_transport_dynamic_params(); const int itemax = scatradyn.sublist("NONLINEAR").get("ITEMAX"); const double ittol = scatradyn.sublist("NONLINEAR").get("CONVTOL"); const double abstolres = scatradyn.sublist("NONLINEAR").get("ABSTOLRES"); diff --git a/src/fs3i/4C_fs3i_partitioned_2wc.cpp b/src/fs3i/4C_fs3i_partitioned_2wc.cpp index 5aae945fdd..b986dda2e9 100644 --- a/src/fs3i/4C_fs3i_partitioned_2wc.cpp +++ b/src/fs3i/4C_fs3i_partitioned_2wc.cpp @@ -11,6 +11,7 @@ #include "4C_adapter_str_fsiwrapper.hpp" #include "4C_fem_discretization.hpp" #include "4C_fluid_timint_loma.hpp" +#include "4C_fs3i_problem_access.hpp" #include "4C_fsi_monolithic.hpp" #include "4C_global_data.hpp" #include "4C_scatra_algorithm.hpp" @@ -18,20 +19,21 @@ FOUR_C_NAMESPACE_OPEN +namespace +{ + const Teuchos::ParameterList& fs3i_dynamic_params_from_problem() + { + return FS3I::Utils::fs3i_dynamic_params_from_problem(); + } +} // namespace + /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ FS3I::PartFS3I2Wc::PartFS3I2Wc(MPI_Comm comm) : PartFS3I(comm), - itmax_(Global::Problem::instance() - ->f_s3_i_dynamic_params() - .sublist("PARTITIONED") - .get("ITEMAX")), - ittol_(Global::Problem::instance() - ->f_s3_i_dynamic_params() - .sublist("PARTITIONED") - .get("CONVTOL")), - consthermpress_( - Global::Problem::instance()->f_s3_i_dynamic_params().get("CONSTHERMPRESS")) + itmax_(fs3i_dynamic_params_from_problem().sublist("PARTITIONED").get("ITEMAX")), + ittol_(fs3i_dynamic_params_from_problem().sublist("PARTITIONED").get("CONVTOL")), + consthermpress_(fs3i_dynamic_params_from_problem().get("CONSTHERMPRESS")) { // constructor is supposed to stay empty return; @@ -71,8 +73,8 @@ void FS3I::PartFS3I2Wc::timeloop() set_fsi_solution(); // calculate initial time derivative, when restart was done from a part. FSI simulation - if (Global::Problem::instance()->restart() and - Global::Problem::instance()->f_s3_i_dynamic_params().get("RESTART_FROM_PART_FSI")) + const auto* problem = FS3I::Utils::problem_from_instance(); + if (problem->restart() and problem->f_s3_i_dynamic_params().get("RESTART_FROM_PART_FSI")) { scatravec_[0]->scatra_field()->prepare_first_time_step(); scatravec_[1]->scatra_field()->prepare_first_time_step(); diff --git a/src/fs3i/4C_fs3i_problem_access.hpp b/src/fs3i/4C_fs3i_problem_access.hpp new file mode 100644 index 0000000000..d2b700b8c2 --- /dev/null +++ b/src/fs3i/4C_fs3i_problem_access.hpp @@ -0,0 +1,29 @@ +// This file is part of 4C multiphysics licensed under the +// GNU Lesser General Public License v3.0 or later. +// +// See the LICENSE.md file in the top-level for license information. +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef FOUR_C_FS3I_PROBLEM_ACCESS_HPP +#define FOUR_C_FS3I_PROBLEM_ACCESS_HPP + +#include "4C_config.hpp" + +#include "4C_global_data.hpp" + +FOUR_C_NAMESPACE_OPEN + +namespace FS3I::Utils +{ + inline Global::Problem* problem_from_instance() { return Global::Problem::instance(); } + + inline const Teuchos::ParameterList& fs3i_dynamic_params_from_problem() + { + return problem_from_instance()->f_s3_i_dynamic_params(); + } +} // namespace FS3I::Utils + +FOUR_C_NAMESPACE_CLOSE + +#endif diff --git a/src/fsi/src/4C_fsi_dyn.cpp b/src/fsi/src/4C_fsi_dyn.cpp index 4639898e97..f516867647 100644 --- a/src/fsi/src/4C_fsi_dyn.cpp +++ b/src/fsi/src/4C_fsi_dyn.cpp @@ -45,6 +45,7 @@ #include "4C_fsi_mortarmonolithic_fluidsplit.hpp" #include "4C_fsi_mortarmonolithic_fluidsplit_sp.hpp" #include "4C_fsi_mortarmonolithic_structuresplit.hpp" +#include "4C_fsi_problem_access.hpp" #include "4C_fsi_resulttest.hpp" #include "4C_fsi_slidingmonolithic_fluidsplit.hpp" #include "4C_fsi_slidingmonolithic_structuresplit.hpp" @@ -76,7 +77,7 @@ FOUR_C_NAMESPACE_OPEN /*----------------------------------------------------------------------*/ void fluid_ale_drt() { - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FSI::Utils::problem_from_instance(); MPI_Comm comm = problem->get_dis("fluid")->get_comm(); @@ -105,7 +106,7 @@ void fluid_ale_drt() if (aledis->num_global_nodes() == 0) { Core::FE::clone_discretization( - *fluiddis, *aledis, Global::Problem::instance()->cloning_material_map()); + *fluiddis, *aledis, problem->cloning_material_map()); aledis->fill_complete(); // setup material in every ALE element Teuchos::ParameterList params; @@ -130,8 +131,8 @@ void fluid_ale_drt() } fluid->timeloop(); - Global::Problem::instance()->add_field_test(fluid->mb_fluid_field()->create_field_test()); - Global::Problem::instance()->test_all(comm); + problem->add_field_test(fluid->mb_fluid_field()->create_field_test()); + problem->test_all(comm); } /*----------------------------------------------------------------------*/ @@ -139,9 +140,8 @@ void fluid_ale_drt() /*----------------------------------------------------------------------*/ void fluid_xfem_drt() { - MPI_Comm comm = Global::Problem::instance()->get_dis("structure")->get_comm(); - - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FSI::Utils::problem_from_instance(); + MPI_Comm comm = problem->get_dis("structure")->get_comm(); std::shared_ptr soliddis = problem->get_dis("structure"); soliddis->fill_complete(); @@ -160,7 +160,7 @@ void fluid_xfem_drt() if (aledis->num_global_nodes() == 0) { Core::FE::clone_discretization( - *problem->get_dis("fluid"), *aledis, Global::Problem::instance()->cloning_material_map()); + *problem->get_dis("fluid"), *aledis, problem->cloning_material_map()); aledis->fill_complete(); // setup material in every ALE element Teuchos::ParameterList params; @@ -182,7 +182,7 @@ void fluid_xfem_drt() // create instance of fluid xfem algorithm, for moving interfaces FSI::FluidXFEMAlgorithm fluidalgo(comm); - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { // read the restart information, set vectors and variables @@ -200,13 +200,13 @@ void fluid_xfem_drt() { //-------------------------------------------------------------- // create instance of fluid basis algorithm - const Teuchos::ParameterList& fdyn = Global::Problem::instance()->fluid_dynamic_params(); + const Teuchos::ParameterList& fdyn = problem->fluid_dynamic_params(); Adapter::FluidBaseAlgorithm fluidalgo(fdyn, fdyn, "fluid", false); //-------------------------------------------------------------- // restart the simulation - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { // read the restart information, set vectors and variables @@ -229,7 +229,7 @@ void fluid_xfem_drt() /*----------------------------------------------------------------------*/ void fsi_immersed_drt() { - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FSI::Utils::problem_from_instance(); std::shared_ptr structdis = problem->get_dis("structure"); MPI_Comm comm = structdis->get_comm(); @@ -262,13 +262,11 @@ void fsi_immersed_drt() if (structdis->has_condition("PointCoupling")) { structdis->fill_complete(Core::FE::OptionsFillComplete::none()); - Teuchos::ParameterList binning_params = Global::Problem::instance()->binning_strategy_params(); + Teuchos::ParameterList binning_params = problem->binning_strategy_params(); Core::Utils::add_enum_class_to_parameter_list( - "spatial_approximation_type", Global::Problem::instance()->spatial_approximation_type(), - binning_params); + "spatial_approximation_type", problem->spatial_approximation_type(), binning_params); Core::Rebalance::rebalance_discretizations_by_binning(binning_params, - Global::Problem::instance()->output_control_file(), {structdis}, correct_node, - determine_relevant_points, true); + problem->output_control_file(), {structdis}, correct_node, determine_relevant_points, true); } else if (not structdis->filled() || not structdis->have_dofs()) { @@ -286,15 +284,14 @@ void fsi_immersed_drt() dis.push_back(structdis); // binning strategy is created - Teuchos::ParameterList binning_params = Global::Problem::instance()->binning_strategy_params(); + Teuchos::ParameterList binning_params = problem->binning_strategy_params(); Core::Utils::add_enum_class_to_parameter_list( - "spatial_approximation_type", Global::Problem::instance()->spatial_approximation_type(), - binning_params); + "spatial_approximation_type", problem->spatial_approximation_type(), binning_params); auto binningstrategy = std::make_shared(binning_params, - Global::Problem::instance()->output_control_file(), comm, - Core::Communication::my_mpi_rank(comm), correct_node, determine_relevant_points, dis); + problem->output_control_file(), comm, Core::Communication::my_mpi_rank(comm), correct_node, + determine_relevant_points, dis); const Teuchos::ParameterList& fbidyn = problem->fbi_params(); @@ -336,7 +333,7 @@ void fsi_immersed_drt() std::dynamic_pointer_cast(fsi)->set_binning(binningstrategy); } - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { // read the restart information, set vectors and variables @@ -350,18 +347,18 @@ void fsi_immersed_drt() fsi->timeloop(fsi); // create result tests for single fields - Global::Problem::instance()->add_field_test(fsi->mb_fluid_field()->create_field_test()); - Global::Problem::instance()->add_field_test(fsi->structure_field()->create_field_test()); + problem->add_field_test(fsi->mb_fluid_field()->create_field_test()); + problem->add_field_test(fsi->structure_field()->create_field_test()); // do the actual testing - Global::Problem::instance()->test_all(comm); + problem->test_all(comm); } /*----------------------------------------------------------------------*/ // entry point for FSI using ALE in discretization management /*----------------------------------------------------------------------*/ void fsi_ale_drt() { - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = FSI::Utils::problem_from_instance(); std::shared_ptr structdis = problem->get_dis("structure"); MPI_Comm comm = structdis->get_comm(); @@ -400,14 +397,12 @@ void fsi_ale_drt() if (structdis->has_condition("PointCoupling")) { structdis->fill_complete(Core::FE::OptionsFillComplete::none()); - Teuchos::ParameterList binning_params = Global::Problem::instance()->binning_strategy_params(); + Teuchos::ParameterList binning_params = problem->binning_strategy_params(); Core::Utils::add_enum_class_to_parameter_list( - "spatial_approximation_type", Global::Problem::instance()->spatial_approximation_type(), - binning_params); + "spatial_approximation_type", problem->spatial_approximation_type(), binning_params); Core::Rebalance::rebalance_discretizations_by_binning(binning_params, - Global::Problem::instance()->output_control_file(), {structdis}, correct_node, - determine_relevant_points, true); + problem->output_control_file(), {structdis}, correct_node, determine_relevant_points, true); } else if (not structdis->filled() || not structdis->have_dofs()) { @@ -431,7 +426,7 @@ void fsi_ale_drt() if (aledis->num_global_nodes() == 0) // empty ale discretization { Core::FE::clone_discretization( - *fluiddis, *aledis, Global::Problem::instance()->cloning_material_map()); + *fluiddis, *aledis, problem->cloning_material_map()); aledis->fill_complete(); // setup material in every ALE element Teuchos::ParameterList params; @@ -462,14 +457,12 @@ void fsi_ale_drt() if (Core::Communication::num_mpi_ranks(structdis->get_comm()) > 1) { // binning strategy is created and parallel redistribution is performed - Teuchos::ParameterList binning_params = - Global::Problem::instance()->binning_strategy_params(); + Teuchos::ParameterList binning_params = problem->binning_strategy_params(); Core::Utils::add_enum_class_to_parameter_list( - "spatial_approximation_type", Global::Problem::instance()->spatial_approximation_type(), - binning_params); + "spatial_approximation_type", problem->spatial_approximation_type(), binning_params); Core::Binstrategy::BinningStrategy binningstrategy(binning_params, - Global::Problem::instance()->output_control_file(), comm, - Core::Communication::my_mpi_rank(comm), correct_node, determine_relevant_points, dis); + problem->output_control_file(), comm, Core::Communication::my_mpi_rank(comm), + correct_node, determine_relevant_points, dis); binningstrategy .do_weighted_partitioning_of_bins_and_extend_ghosting_of_discret_to_one_bin_layer( dis, stdelecolmap, stdnodecolmap); @@ -546,7 +539,7 @@ void fsi_ale_drt() // read the restart information, set vectors and variables --- // be careful, dofmaps might be changed here in a redistribute() call - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { fsi->read_restart(restart); @@ -566,17 +559,17 @@ void fsi_ale_drt() fsi->fluid_field()->calculate_error(); // create result tests for single fields - Global::Problem::instance()->add_field_test(fsi->ale_field()->create_field_test()); - Global::Problem::instance()->add_field_test(fsi->fluid_field()->create_field_test()); - Global::Problem::instance()->add_field_test(fsi->structure_field()->create_field_test()); + problem->add_field_test(fsi->ale_field()->create_field_test()); + problem->add_field_test(fsi->fluid_field()->create_field_test()); + problem->add_field_test(fsi->structure_field()->create_field_test()); // create fsi specific result test std::shared_ptr fsitest = std::make_shared(fsi, fsidyn); - Global::Problem::instance()->add_field_test(fsitest); + problem->add_field_test(fsitest); // do the actual testing - Global::Problem::instance()->test_all(comm); + problem->test_all(comm); break; } @@ -597,7 +590,7 @@ void fsi_ale_drt() // read the restart information, set vectors and variables --- // be careful, dofmaps might be changed here in a redistribute() call - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { fsi->read_restart(restart); @@ -617,16 +610,16 @@ void fsi_ale_drt() fsi->fluid_field()->calculate_error(); // create result tests for single fields - Global::Problem::instance()->add_field_test(fsi->fluid_field()->create_field_test()); - Global::Problem::instance()->add_field_test(fsi->structure_field()->create_field_test()); + problem->add_field_test(fsi->fluid_field()->create_field_test()); + problem->add_field_test(fsi->structure_field()->create_field_test()); // create fsi specific result test std::shared_ptr fsitest = std::make_shared(fsi, fsidyn); - Global::Problem::instance()->add_field_test(fsitest); + problem->add_field_test(fsitest); // do the actual testing - Global::Problem::instance()->test_all(comm); + problem->test_all(comm); break; } @@ -651,7 +644,7 @@ void fsi_ale_drt() FOUR_C_THROW("unsupported partitioned FSI scheme"); break; } - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { // read the restart information, set vectors and variables @@ -666,11 +659,11 @@ void fsi_ale_drt() fsi->timeloop(fsi); // create result tests for single fields - Global::Problem::instance()->add_field_test(fsi->mb_fluid_field()->create_field_test()); - Global::Problem::instance()->add_field_test(fsi->structure_field()->create_field_test()); + problem->add_field_test(fsi->mb_fluid_field()->create_field_test()); + problem->add_field_test(fsi->structure_field()->create_field_test()); // do the actual testing - Global::Problem::instance()->test_all(comm); + problem->test_all(comm); break; } @@ -682,7 +675,8 @@ void fsi_ale_drt() /*----------------------------------------------------------------------*/ void xfsi_drt() { - MPI_Comm comm = Global::Problem::instance()->get_dis("structure")->get_comm(); + Global::Problem* problem = FSI::Utils::problem_from_instance(); + MPI_Comm comm = problem->get_dis("structure")->get_comm(); if (Core::Communication::my_mpi_rank(comm) == 0) { @@ -697,7 +691,6 @@ void xfsi_drt() std::cout << std::endl << std::endl; } - Global::Problem* problem = Global::Problem::instance(); const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); std::shared_ptr soliddis = problem->get_dis("structure"); @@ -705,8 +698,8 @@ void xfsi_drt() FLD::XFluid::setup_fluid_discretization(); - std::shared_ptr fluiddis = Global::Problem::instance()->get_dis( - "fluid"); // at the moment, 'fluid'-discretization is used for ale!!! + std::shared_ptr fluiddis = + problem->get_dis("fluid"); // at the moment, 'fluid'-discretization is used for ale!!! // CREATE ALE const Teuchos::ParameterList& xfdyn = problem->x_fluid_dynamic_params(); @@ -723,7 +716,7 @@ void xfsi_drt() if (aledis->num_global_nodes() == 0) // ALE discretization still empty { Core::FE::clone_discretization( - *fluiddis, *aledis, Global::Problem::instance()->cloning_material_map()); + *fluiddis, *aledis, problem->cloning_material_map()); aledis->fill_complete(); // setup material in every ALE element Teuchos::ParameterList params; @@ -759,7 +752,7 @@ void xfsi_drt() // read the restart information, set vectors and variables --- // be careful, dofmaps might be changed here in a redistribute() call - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { fsi.read_restart(restart); @@ -771,15 +764,15 @@ void xfsi_drt() // here we go... fsi.timeloop(); - Global::Problem::instance()->add_field_test(fsi.fluid_field()->create_field_test()); - fsi.structure_poro()->test_results(Global::Problem::instance()); + problem->add_field_test(fsi.fluid_field()->create_field_test()); + fsi.structure_poro()->test_results(problem); // // create FSI specific result test // std::shared_ptr fsitest = Teuchos::rcp(new - // FSI::FSIResultTest(fsi,fsidyn)); Global::Problem::instance()->AddFieldTest(fsitest); + // FSI::FSIResultTest(fsi, fsidyn)); problem->add_field_test(fsitest); // do the actual testing - Global::Problem::instance()->test_all(comm); + problem->test_all(comm); break; } @@ -807,7 +800,7 @@ void xfsi_drt() break; } - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { // read the restart information, set vectors and variables @@ -821,9 +814,9 @@ void xfsi_drt() fsi->timeloop(fsi); - Global::Problem::instance()->add_field_test(fsi->mb_fluid_field()->create_field_test()); - Global::Problem::instance()->add_field_test(fsi->structure_field()->create_field_test()); - Global::Problem::instance()->test_all(comm); + problem->add_field_test(fsi->mb_fluid_field()->create_field_test()); + problem->add_field_test(fsi->structure_field()->create_field_test()); + problem->test_all(comm); break; } @@ -835,7 +828,8 @@ void xfsi_drt() /*----------------------------------------------------------------------*/ void xfpsi_drt() { - MPI_Comm comm = Global::Problem::instance()->get_dis("structure")->get_comm(); + Global::Problem* problem = FSI::Utils::problem_from_instance(); + MPI_Comm comm = problem->get_dis("structure")->get_comm(); if (Core::Communication::my_mpi_rank(comm) == 0) { @@ -849,16 +843,14 @@ void xfpsi_drt() std::cout << " _/ \\\\_ | || ______| __|__" << std::endl; std::cout << std::endl << std::endl; } - Global::Problem* problem = Global::Problem::instance(); - // 1.-Initialization. // setup of the discretizations, including clone strategy PoroElast::Utils::setup_poro(); // setup of discretization for xfluid FLD::XFluid::setup_fluid_discretization(); - std::shared_ptr fluiddis = Global::Problem::instance()->get_dis( - "fluid"); // at the moment, 'fluid'-discretization is used for ale!!! + std::shared_ptr fluiddis = + problem->get_dis("fluid"); // at the moment, 'fluid'-discretization is used for ale!!! std::shared_ptr aledis; const Teuchos::ParameterList& xfdyn = problem->x_fluid_dynamic_params(); @@ -874,7 +866,7 @@ void xfpsi_drt() if (aledis->num_global_nodes() == 0) // ALE discretization still empty { Core::FE::clone_discretization( - *fluiddis, *aledis, Global::Problem::instance()->cloning_material_map()); + *fluiddis, *aledis, problem->cloning_material_map()); aledis->fill_complete(); // setup material in every ALE element Teuchos::ParameterList params; @@ -914,8 +906,8 @@ void xfpsi_drt() // read the restart information, set vectors and variables --- // be careful, dofmaps might be changed here in a redistribute() call - const int restart = Global::Problem::instance() - ->restart(); // not adapted at the moment .... Todo check it .. ChrAg + const int restart = + problem->restart(); // not adapted at the moment .... Todo check it .. ChrAg if (restart) { fsi.read_restart(restart); @@ -931,11 +923,11 @@ void xfpsi_drt() // here we go... fsi.timeloop(); - Global::Problem::instance()->add_field_test(fsi.fluid_field()->create_field_test()); - fsi.structure_poro()->test_results(Global::Problem::instance()); + problem->add_field_test(fsi.fluid_field()->create_field_test()); + fsi.structure_poro()->test_results(problem); // do the actual testing - Global::Problem::instance()->test_all(comm); + problem->test_all(comm); break; } case fsi_iter_monolithicfluidsplit: diff --git a/src/fsi/src/4C_fsi_problem_access.hpp b/src/fsi/src/4C_fsi_problem_access.hpp new file mode 100644 index 0000000000..cfb3a4b8f7 --- /dev/null +++ b/src/fsi/src/4C_fsi_problem_access.hpp @@ -0,0 +1,29 @@ +// This file is part of 4C multiphysics licensed under the +// GNU Lesser General Public License v3.0 or later. +// +// See the LICENSE.md file in the top-level for license information. +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef FOUR_C_FSI_PROBLEM_ACCESS_HPP +#define FOUR_C_FSI_PROBLEM_ACCESS_HPP + +#include "4C_config.hpp" + +#include "4C_global_data.hpp" + +FOUR_C_NAMESPACE_OPEN + +namespace FSI::Utils +{ + inline Global::Problem* problem_from_instance() { return Global::Problem::instance(); } + + inline const Teuchos::ParameterList& fsi_dynamic_params_from_problem() + { + return problem_from_instance()->fsi_dynamic_params(); + } +} // namespace FSI::Utils + +FOUR_C_NAMESPACE_CLOSE + +#endif diff --git a/src/fsi/src/monolithic/4C_fsi_monolithic.cpp b/src/fsi/src/monolithic/4C_fsi_monolithic.cpp index e949aeff25..73203eb77f 100644 --- a/src/fsi/src/monolithic/4C_fsi_monolithic.cpp +++ b/src/fsi/src/monolithic/4C_fsi_monolithic.cpp @@ -20,6 +20,7 @@ #include "4C_fsi_nox_group.hpp" #include "4C_fsi_nox_linearsystem.hpp" #include "4C_fsi_nox_newton.hpp" +#include "4C_fsi_problem_access.hpp" #include "4C_fsi_statustest.hpp" #include "4C_global_data.hpp" #include "4C_io_control.hpp" @@ -56,14 +57,14 @@ FSI::MonolithicBase::MonolithicBase(MPI_Comm comm, const Teuchos::ParameterList& isadafluid_(false), isadasolver_(false), verbosity_(Teuchos::getIntegralValue( - Global::Problem::instance()->fsi_dynamic_params(), "VERBOSITY")) + FSI::Utils::fsi_dynamic_params_from_problem(), "VERBOSITY")) { + Global::Problem* problem = FSI::Utils::problem_from_instance(); + // access the discretizations - std::shared_ptr structdis = - Global::Problem::instance()->get_dis("structure"); - std::shared_ptr fluiddis = - Global::Problem::instance()->get_dis("fluid"); - std::shared_ptr aledis = Global::Problem::instance()->get_dis("ale"); + std::shared_ptr structdis = problem->get_dis("structure"); + std::shared_ptr fluiddis = problem->get_dis("fluid"); + std::shared_ptr aledis = problem->get_dis("ale"); create_structure_time_integrator(timeparams, structdis); create_fluid_and_ale_time_integrator(timeparams, fluiddis, aledis); @@ -96,7 +97,8 @@ void FSI::MonolithicBase::create_structure_time_integrator( structure_ = nullptr; // access structural dynamic params - const Teuchos::ParameterList& sdyn = Global::Problem::instance()->structural_dynamic_params(); + const Teuchos::ParameterList& sdyn = + FSI::Utils::problem_from_instance()->structural_dynamic_params(); // ask base algorithm for the structural time integrator std::shared_ptr structure = @@ -120,6 +122,8 @@ void FSI::MonolithicBase::create_fluid_and_ale_time_integrator( const Teuchos::ParameterList& timeparams, std::shared_ptr fluiddis, std::shared_ptr aledis) { + Global::Problem* problem = FSI::Utils::problem_from_instance(); + // delete deprecated time integrators fluid_ = nullptr; ale_ = nullptr; @@ -127,7 +131,7 @@ void FSI::MonolithicBase::create_fluid_and_ale_time_integrator( // ask base algorithm for the fluid time integrator std::shared_ptr fluid = std::make_shared( - timeparams, Global::Problem::instance()->fluid_dynamic_params(), "fluid", true); + timeparams, problem->fluid_dynamic_params(), "fluid", true); fluid_ = std::dynamic_pointer_cast(fluid->fluid_field()); if (fluid_ == nullptr) FOUR_C_THROW("Cast from Adapter::Fluid to Adapter::FluidFSI failed"); @@ -330,17 +334,18 @@ FSI::Monolithic::Monolithic(MPI_Comm comm, const Teuchos::ParameterList& timepar log_(nullptr), logada_(nullptr) { - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + Global::Problem* problem = FSI::Utils::problem_from_instance(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); // write iterations-file - std::string fileiter = Global::Problem::instance()->output_control_file()->file_name(); + std::string fileiter = problem->output_control_file()->file_name(); fileiter.append(".iteration"); log_ = std::make_shared(fileiter.c_str()); // write energy-file if (fsidyn.sublist("MONOLITHIC SOLVER").get("ENERGYFILE")) { - std::string fileiter2 = Global::Problem::instance()->output_control_file()->file_name(); + std::string fileiter2 = problem->output_control_file()->file_name(); fileiter2.append(".fsienergy"); logenergy_ = std::make_shared(fileiter2.c_str()); } @@ -374,7 +379,7 @@ void FSI::Monolithic::setup_system() { // right now we use matching meshes at the interface - const int ndim = Global::Problem::instance()->n_dim(); + const int ndim = FSI::Utils::problem_from_instance()->n_dim(); Coupling::Adapter::Coupling& coupsf = structure_fluid_coupling(); Coupling::Adapter::Coupling& coupsa = structure_ale_coupling(); @@ -425,7 +430,7 @@ void FSI::Monolithic::setup_system() /*----------------------------------------------------------------------------*/ void FSI::Monolithic::timeloop(const std::shared_ptr interface) { - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = FSI::Utils::fsi_dynamic_params_from_problem(); const bool timeadapton = fsidyn.sublist("TIMEADAPTIVITY").get("TIMEADAPTON"); // Run time loop with constant or adaptive time step size (depending on the user's will) @@ -522,10 +527,11 @@ void FSI::Monolithic::prepare_timeloop() // check for prestressing, // do not allow monolithic in the pre-phase // allow monolithic in the post-phase - const Inpar::Solid::PreStress pstype = Teuchos::getIntegralValue( - Global::Problem::instance()->structural_dynamic_params(), "PRESTRESS"); - const double pstime = - Global::Problem::instance()->structural_dynamic_params().get("PRESTRESSTIME"); + auto* problem = FSI::Utils::problem_from_instance(); + const auto& structural_dyn = problem->structural_dynamic_params(); + const Inpar::Solid::PreStress pstype = + Teuchos::getIntegralValue(structural_dyn, "PRESTRESS"); + const double pstime = structural_dyn.get("PRESTRESSTIME"); if (pstype != Inpar::Solid::PreStress::none && time() + dt() <= pstime + 1.0e-15) FOUR_C_THROW("No monolithic FSI in the pre-phase of prestressing, use Aitken!"); @@ -686,7 +692,7 @@ void FSI::Monolithic::time_step(const std::shared_ptrfsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = FSI::Utils::fsi_dynamic_params_from_problem(); const bool timeadapton = fsidyn.sublist("TIMEADAPTIVITY").get("TIMEADAPTON"); if (not timeadapton) @@ -721,7 +727,7 @@ void FSI::Monolithic::non_lin_error_check() // that depends on the user's will given in the input file // get the FSI parameter list - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = FSI::Utils::fsi_dynamic_params_from_problem(); // get the user's will const auto divcontype = @@ -1099,7 +1105,7 @@ bool FSI::BlockMonolithic::compute_jacobian( void FSI::BlockMonolithic::prepare_time_step_preconditioner() { const Teuchos::ParameterList& fsimono = - Global::Problem::instance()->fsi_dynamic_params().sublist("MONOLITHIC SOLVER"); + FSI::Utils::fsi_dynamic_params_from_problem().sublist("MONOLITHIC SOLVER"); if (fsimono.get("REBUILDPRECEVERYSTEP")) precondreusecount_ = 0; } @@ -1119,6 +1125,8 @@ std::shared_ptr FSI::BlockMonolithic::create_linear_ Teuchos::ParameterList& nlParams, NOX::Nln::Vector& noxSoln, std::shared_ptr<::NOX::Utils> utils) { + auto* problem = FSI::Utils::problem_from_instance(); + Teuchos::ParameterList& printParams = nlParams.sublist("Printing"); Teuchos::ParameterList& dirParams = nlParams.sublist("Direction"); Teuchos::ParameterList& newtonParams = dirParams.sublist("Newton"); @@ -1128,7 +1136,7 @@ std::shared_ptr FSI::BlockMonolithic::create_linear_ const std::shared_ptr J = system_matrix(); const std::shared_ptr M = system_matrix(); - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); const Teuchos::ParameterList& fsimono = fsidyn.sublist("MONOLITHIC SOLVER"); const int linsolvernumber = fsimono.get("LINEAR_SOLVER"); @@ -1137,13 +1145,11 @@ std::shared_ptr FSI::BlockMonolithic::create_linear_ "no linear solver defined for monolithic FSI. Please set LINEAR_SOLVER in FSI " "DYNAMIC/MONOLITHIC SOLVER to a valid number!"); - const Teuchos::ParameterList& fsisolverparams = - Global::Problem::instance()->solver_params(linsolvernumber); + const Teuchos::ParameterList& fsisolverparams = problem->solver_params(linsolvernumber); auto solver = std::make_shared(fsisolverparams, get_comm(), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY")); const auto azprectype = Teuchos::getIntegralValue(fsisolverparams, "AZPREC"); @@ -1154,9 +1160,8 @@ std::shared_ptr FSI::BlockMonolithic::create_linear_ case Core::LinearSolver::PreconditionerType::block_teko: { solver->put_solver_params_to_sub_params("Inverse1", fsisolverparams, - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"), + problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY"), get_comm()); compute_null_space_if_necessary( *structure_field()->discretization(), solver->params().sublist("Inverse1")); @@ -1166,9 +1171,8 @@ std::shared_ptr FSI::BlockMonolithic::create_linear_ solver->params().sublist("Inverse1")); solver->put_solver_params_to_sub_params("Inverse2", fsisolverparams, - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"), + problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY"), get_comm()); compute_null_space_if_necessary( *fluid_field()->discretization(), solver->params().sublist("Inverse2")); @@ -1178,9 +1182,8 @@ std::shared_ptr FSI::BlockMonolithic::create_linear_ solver->params().sublist("Inverse2")); solver->put_solver_params_to_sub_params("Inverse3", fsisolverparams, - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"), + problem->solver_params_callback(), + Teuchos::getIntegralValue(problem->io_params(), "VERBOSITY"), get_comm()); compute_null_space_if_necessary( *ale_field()->discretization(), solver->params().sublist("Inverse3")); diff --git a/src/fsi/src/partitioned/4C_fsi_partitioned.cpp b/src/fsi/src/partitioned/4C_fsi_partitioned.cpp index db1f24ed08..f979393f41 100644 --- a/src/fsi/src/partitioned/4C_fsi_partitioned.cpp +++ b/src/fsi/src/partitioned/4C_fsi_partitioned.cpp @@ -24,6 +24,7 @@ #include "4C_fsi_nox_linearsystem_gcr.hpp" #include "4C_fsi_nox_mpe.hpp" #include "4C_fsi_nox_sd.hpp" +#include "4C_fsi_problem_access.hpp" #include "4C_fsi_utils.hpp" #include "4C_global_data.hpp" #include "4C_io_control.hpp" @@ -65,7 +66,7 @@ void FSI::Partitioned::setup() // call setup of base class FSI::Algorithm::setup(); - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = FSI::Utils::fsi_dynamic_params_from_problem(); set_default_parameters(fsidyn, noxparameterlist_); setup_coupling(fsidyn, get_comm()); } @@ -75,22 +76,23 @@ void FSI::Partitioned::setup() /*----------------------------------------------------------------------*/ void FSI::Partitioned::setup_coupling(const Teuchos::ParameterList& fsidyn, MPI_Comm comm) { + Global::Problem* problem = FSI::Utils::problem_from_instance(); + if (Core::Communication::my_mpi_rank(get_comm()) == 0) std::cout << "\n setup_coupling in FSI::Partitioned ..." << std::endl; Coupling::Adapter::Coupling& coupsf = structure_fluid_coupling(); - coupsfm_ = std::make_shared( - Global::Problem::instance()->n_dim(), Global::Problem::instance()->mortar_coupling_params(), - Global::Problem::instance()->contact_dynamic_params(), - Global::Problem::instance()->spatial_approximation_type()); + coupsfm_ = std::make_shared(problem->n_dim(), + problem->mortar_coupling_params(), problem->contact_dynamic_params(), + problem->spatial_approximation_type()); if (fsidyn.sublist("PARTITIONED SOLVER").get("COUPMETHOD") == "conforming" and - (Global::Problem::instance()->get_problem_type() != Core::ProblemType::fsi_xfem) and - (Global::Problem::instance()->get_problem_type() != Core::ProblemType::fbi)) + (problem->get_problem_type() != Core::ProblemType::fsi_xfem) and + (problem->get_problem_type() != Core::ProblemType::fbi)) { matchingnodes_ = true; - const int ndim = Global::Problem::instance()->n_dim(); + const int ndim = problem->n_dim(); coupsf.setup_condition_coupling(*structure_field()->discretization(), structure_field()->interface()->fsi_cond_map(), *mb_fluid_field()->discretization(), mb_fluid_field()->interface()->fsi_cond_map(), "FSICoupling", ndim); @@ -99,13 +101,13 @@ void FSI::Partitioned::setup_coupling(const Teuchos::ParameterList& fsidyn, MPI_ FOUR_C_THROW("No nodes in matching FSI interface. Empty FSI coupling condition?"); } else if ((fsidyn.sublist("PARTITIONED SOLVER").get("COUPMETHOD") == "conforming") and - (Global::Problem::instance()->get_problem_type() == Core::ProblemType::fsi_xfem) and - (Global::Problem::instance()->get_problem_type() != Core::ProblemType::fbi)) + (problem->get_problem_type() == Core::ProblemType::fsi_xfem) and + (problem->get_problem_type() != Core::ProblemType::fbi)) { // matching between structure and boundary dis! non-matching between boundary dis and fluid is // handled bei XFluid itself matchingnodes_ = true; - const int ndim = Global::Problem::instance()->n_dim(); + const int ndim = problem->n_dim(); std::shared_ptr x_movingboundary = std::dynamic_pointer_cast(mb_fluid_field()); @@ -117,27 +119,25 @@ void FSI::Partitioned::setup_coupling(const Teuchos::ParameterList& fsidyn, MPI_ if (coupsf.master_dof_map()->num_global_elements() == 0) FOUR_C_THROW("No nodes in matching FSI interface. Empty FSI coupling condition?"); } - else if ((Global::Problem::instance()->get_problem_type() == Core::ProblemType::fbi)) + else if ((problem->get_problem_type() == Core::ProblemType::fbi)) { matchingnodes_ = true; } else if (fsidyn.sublist("PARTITIONED SOLVER").get("COUPMETHOD") == "mortar" and - (Global::Problem::instance()->get_problem_type() != Core::ProblemType::fsi_xfem)) + (problem->get_problem_type() != Core::ProblemType::fsi_xfem)) { // coupling condition at the fsi interface: displacements (=number of spatial dimensions) are // coupled e.g.: 3D: coupleddof = [1, 1, 1] - std::vector coupleddof(Global::Problem::instance()->n_dim(), 1); + std::vector coupleddof(problem->n_dim(), 1); matchingnodes_ = false; coupsfm_->setup(structure_field()->discretization(), mb_fluid_field()->discretization(), (std::dynamic_pointer_cast(mb_fluid_field())) ->ale_field() ->write_access_discretization(), - coupleddof, "FSICoupling", comm, Global::Problem::instance()->function_manager(), - Global::Problem::instance()->binning_strategy_params(), - Global::Problem::instance()->discretization_map(), - Global::Problem::instance()->output_control_file(), - Global::Problem::instance()->spatial_approximation_type(), true); + coupleddof, "FSICoupling", comm, problem->function_manager(), + problem->binning_strategy_params(), problem->discretization_map(), + problem->output_control_file(), problem->spatial_approximation_type(), true); } else { @@ -338,7 +338,8 @@ void FSI::Partitioned::set_default_parameters( /*----------------------------------------------------------------------*/ void FSI::Partitioned::timeloop(const std::shared_ptr interface) { - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + Global::Problem* problem = FSI::Utils::problem_from_instance(); + const Teuchos::ParameterList& fsidyn = problem->fsi_dynamic_params(); // Get the top level parameter list Teuchos::ParameterList& nlParams = noxparameterlist_; @@ -361,7 +362,7 @@ void FSI::Partitioned::timeloop(const std::shared_ptr log; if (Core::Communication::my_mpi_rank(get_comm()) == 0) { - std::string s = Global::Problem::instance()->output_control_file()->file_name(); + std::string s = problem->output_control_file()->file_name(); s.append(".iteration"); log = std::make_shared(s.c_str()); (*log) << "# num procs = " << Core::Communication::num_mpi_ranks(get_comm()) << "\n" @@ -749,7 +750,7 @@ std::shared_ptr> FSI::Partitioned::struct_op( std::shared_ptr> FSI::Partitioned::interface_velocity( const Core::LinAlg::Vector& idispnp) const { - const Teuchos::ParameterList& fsidyn = Global::Problem::instance()->fsi_dynamic_params(); + const Teuchos::ParameterList& fsidyn = FSI::Utils::fsi_dynamic_params_from_problem(); std::shared_ptr> ivel = nullptr; if (fsidyn.get("SECONDORDER")) @@ -837,7 +838,7 @@ void FSI::Partitioned::output() FSI::Algorithm::output(); switch (Teuchos::getIntegralValue( - Global::Problem::instance()->fsi_dynamic_params(), "COUPALGO")) + FSI::Utils::fsi_dynamic_params_from_problem(), "COUPALGO")) { case fsi_iter_stagg_AITKEN_rel_param: { @@ -864,16 +865,17 @@ void FSI::Partitioned::output() /*----------------------------------------------------------------------*/ void FSI::Partitioned::read_restart(int step) { + Global::Problem* problem = FSI::Utils::problem_from_instance(); + // call base class version FSI::Algorithm::read_restart(step); - switch (Teuchos::getIntegralValue( - Global::Problem::instance()->fsi_dynamic_params(), "COUPALGO")) + switch (Teuchos::getIntegralValue(problem->fsi_dynamic_params(), "COUPALGO")) { case fsi_iter_stagg_AITKEN_rel_param: { double omega = -1234.0; - auto input_control_file = Global::Problem::instance()->input_control_file(); + auto input_control_file = problem->input_control_file(); if (std::dynamic_pointer_cast(mb_fluid_field()) != nullptr) { diff --git a/src/fsi/src/utils/4C_fsi_utils.cpp b/src/fsi/src/utils/4C_fsi_utils.cpp index 98de81aa0e..19245c0666 100644 --- a/src/fsi/src/utils/4C_fsi_utils.cpp +++ b/src/fsi/src/utils/4C_fsi_utils.cpp @@ -15,6 +15,7 @@ #include "4C_fem_general_extract_values.hpp" #include "4C_fem_geometry_searchtree.hpp" #include "4C_fem_geometry_searchtree_service.hpp" +#include "4C_fsi_problem_access.hpp" #include "4C_global_data.hpp" #include "4C_io.hpp" #include "4C_io_control.hpp" @@ -83,12 +84,13 @@ FSI::Utils::SlideAleUtils::SlideAleUtils(std::shared_ptr( - Global::Problem::instance()->n_dim(), Global::Problem::instance()->mortar_coupling_params(), - Global::Problem::instance()->contact_dynamic_params(), - Global::Problem::instance()->spatial_approximation_type()); + coupff_ = std::make_shared(problem->n_dim(), + problem->mortar_coupling_params(), problem->contact_dynamic_params(), + problem->spatial_approximation_type()); // declare struct objects in interface std::map>> structelements; @@ -192,7 +194,7 @@ FSI::Utils::SlideAleUtils::SlideAleUtils(std::shared_ptr>(*fluiddofrowmap_, true); - centerdisptotal_.resize(Global::Problem::instance()->n_dim()); + centerdisptotal_.resize(problem->n_dim()); redundant_elements(coupsf, structdis->get_comm()); @@ -200,16 +202,14 @@ FSI::Utils::SlideAleUtils::SlideAleUtils(std::shared_ptr coupleddof(Global::Problem::instance()->n_dim(), 1); + std::vector coupleddof(problem->n_dim(), 1); // this setup only initialize two sets of identical mortar elements (master and slave) // -> projection matrix is a unity matrix coupff_->setup(fluiddis, fluiddis, nullptr, coupleddof, "FSICoupling", fluiddis->get_comm(), - Global::Problem::instance()->function_manager(), - Global::Problem::instance()->binning_strategy_params(), - Global::Problem::instance()->discretization_map(), - Global::Problem::instance()->output_control_file(), - Global::Problem::instance()->spatial_approximation_type(), false, true); + problem->function_manager(), problem->binning_strategy_params(), + problem->discretization_map(), problem->output_control_file(), + problem->spatial_approximation_type(), false, true); } /*----------------------------------------------------------------------*/ @@ -220,7 +220,7 @@ void FSI::Utils::SlideAleUtils::remeshing(Adapter::FSIStructureWrapper& structur MPI_Comm comm) { std::shared_ptr> idisptotal = structure.extract_interface_dispnp(); - const int dim = Global::Problem::instance()->n_dim(); + const int dim = FSI::Utils::problem_from_instance()->n_dim(); // project sliding fluid nodes onto struct interface surface slide_projection(structure, fluiddis, idispale, iprojdispale, coupsf, comm); @@ -313,7 +313,7 @@ std::vector FSI::Utils::SlideAleUtils::centerdisp( idispstep->update(-1.0, *idispn, 1.0); - const int dim = Global::Problem::instance()->n_dim(); + const int dim = FSI::Utils::problem_from_instance()->n_dim(); // get structure and fluid discretizations and set stated for element evaluation Core::LinAlg::Vector idisptotalcol(*structdis->dof_col_map(), true); export_to(*idisptotal, idisptotalcol); @@ -436,7 +436,7 @@ void FSI::Utils::SlideAleUtils::slide_projection( ) { - const int dim = Global::Problem::instance()->n_dim(); + const int dim = FSI::Utils::problem_from_instance()->n_dim(); std::shared_ptr> idispnp = structure.extract_interface_dispnp(); @@ -601,7 +601,7 @@ void FSI::Utils::SlideAleUtils::redundant_elements( std::map>>::iterator mapit; // build redundant version istructslideles_; std::map>::iterator it; - int dim = Global::Problem::instance()->n_dim(); + int dim = FSI::Utils::problem_from_instance()->n_dim(); for (int i = 0; i <= maxid_; ++i) { diff --git a/src/ssi/4C_ssi_base.cpp b/src/ssi/4C_ssi_base.cpp index b712b9b9af..d6213ddbd6 100644 --- a/src/ssi/4C_ssi_base.cpp +++ b/src/ssi/4C_ssi_base.cpp @@ -31,6 +31,7 @@ #include "4C_ssi_clonestrategy.hpp" #include "4C_ssi_coupling.hpp" #include "4C_ssi_input.hpp" +#include "4C_ssi_problem_access.hpp" #include "4C_ssi_resulttest.hpp" #include "4C_ssi_str_model_evaluator_partitioned.hpp" #include "4C_ssi_utils.hpp" @@ -48,22 +49,23 @@ SSI::SSIBase::SSIBase(MPI_Comm comm, const Teuchos::ParameterList& globaltimepar : AlgorithmBase(comm, globaltimeparams), diff_time_step_size_(globaltimeparams.get("DIFFTIMESTEPSIZE")), fieldcoupling_(Teuchos::getIntegralValue( - Global::Problem::instance()->ssi_control_params(), "FIELDCOUPLING")), + SSI::Utils::problem_from_instance()->ssi_control_params(), "FIELDCOUPLING")), is_scatra_manifold_(globaltimeparams.sublist("MANIFOLD").get("ADD_MANIFOLD")), is_manifold_meshtying_(globaltimeparams.sublist("MANIFOLD").get("MESHTYING_MANIFOLD")), is_s2i_kinetic_with_pseudo_contact_( check_s2i_kinetics_condition_for_pseudo_contact("structure")), - macro_scale_(Global::Problem::instance()->materials()->first_id_by_type( + macro_scale_(SSI::Utils::problem_from_instance()->materials()->first_id_by_type( Core::Materials::m_scatra_multiscale) != -1 or - Global::Problem::instance()->materials()->first_id_by_type( + SSI::Utils::problem_from_instance()->materials()->first_id_by_type( Core::Materials::m_newman_multiscale) != -1), - ssi_interface_contact_( - Global::Problem::instance()->get_dis("structure")->has_condition("SSIInterfaceContact")), - ssi_interface_meshtying_(Global::Problem::instance() + ssi_interface_contact_(SSI::Utils::problem_from_instance() + ->get_dis("structure") + ->has_condition("SSIInterfaceContact")), + ssi_interface_meshtying_(SSI::Utils::problem_from_instance() ->get_dis("structure") ->has_condition("ssi_interface_meshtying")), - temperature_funct_num_( - Global::Problem::instance()->elch_control_params().get("TEMPERATURE_FROM_FUNCT")) + temperature_funct_num_(SSI::Utils::problem_from_instance()->elch_control_params().get( + "TEMPERATURE_FROM_FUNCT")) { // Keep this constructor empty! // First do everything on the more basic objects like the discretizations, like e.g. @@ -124,6 +126,8 @@ void SSI::SSIBase::init(MPI_Comm comm, const Teuchos::ParameterList& globaltimep *----------------------------------------------------------------------*/ void SSI::SSIBase::setup() { + Global::Problem* problem = SSI::Utils::problem_from_instance(); + // check initialization check_is_init(); @@ -131,8 +135,8 @@ void SSI::SSIBase::setup() ssicoupling_->setup(); // in case of an ssi multi scale formulation we need to set the displacement here - auto dummy_vec = Core::LinAlg::Vector( - *Global::Problem::instance()->get_dis("structure")->dof_row_map(), true); + auto dummy_vec = + Core::LinAlg::Vector(*problem->get_dis("structure")->dof_row_map(), true); ssicoupling_->set_mesh_disp(scatra_base_algorithm(), dummy_vec); // set up scalar transport field @@ -147,31 +151,28 @@ void SSI::SSIBase::setup() // pass initial scalar field to structural discretization to correctly compute initial // accelerations - if (Teuchos::getIntegralValue( - Global::Problem::instance()->ssi_control_params(), "COUPALGO") != - SSI::SolutionSchemeOverFields::ssi_OneWay_SolidToScatra) - ssicoupling_->set_scalar_field( - *Global::Problem::instance()->get_dis("structure"), scatra_field()->phinp(), 1); + if (Teuchos::getIntegralValue(problem->ssi_control_params(), + "COUPALGO") != SSI::SolutionSchemeOverFields::ssi_OneWay_SolidToScatra) + ssicoupling_->set_scalar_field(*problem->get_dis("structure"), scatra_field()->phinp(), 1); if (macro_scale_) { scatra_field()->calc_mean_micro_concentration(); ssicoupling_->set_scalar_field_micro( - *Global::Problem::instance()->get_dis("structure"), scatra_field()->phinp_micro(), 2); + *problem->get_dis("structure"), scatra_field()->phinp_micro(), 2); } // temperature is non primary variable. Only set, if function for temperature is given if (temperature_funct_num_ != -1) { temperature_vector_ = std::make_shared>( - *Global::Problem::instance()->get_dis("structure")->dof_row_map(2), true); + *problem->get_dis("structure")->dof_row_map(2), true); - temperature_vector_->put_scalar(Global::Problem::instance() - ->function_by_id(temperature_funct_num_) + temperature_vector_->put_scalar( + problem->function_by_id(temperature_funct_num_) .evaluate(time())); - ssicoupling_->set_temperature_field( - *Global::Problem::instance()->get_dis("structure"), temperature_vector_); + ssicoupling_->set_temperature_field(*problem->get_dis("structure"), temperature_vector_); } // set up structural base algorithm @@ -230,12 +231,13 @@ void SSI::SSIBase::setup() *----------------------------------------------------------------------*/ void SSI::SSIBase::post_setup() const { + const Global::Problem* problem = SSI::Utils::problem_from_instance(); + check_is_setup(); // communicate scatra states to structure if necessary - if (Teuchos::getIntegralValue( - Global::Problem::instance()->ssi_control_params(), "COUPALGO") != - SSI::SolutionSchemeOverFields::ssi_OneWay_SolidToScatra) + if (Teuchos::getIntegralValue(problem->ssi_control_params(), + "COUPALGO") != SSI::SolutionSchemeOverFields::ssi_OneWay_SolidToScatra) { set_scatra_solution(scatra_field()->phinp()); } @@ -252,19 +254,18 @@ void SSI::SSIBase::post_setup() const void SSI::SSIBase::init_discretizations(MPI_Comm comm, const std::string& struct_disname, const std::string& scatra_disname, const bool redistribute_struct_dis) { - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = SSI::Utils::problem_from_instance(); auto structdis = problem->get_dis(struct_disname); auto scatradis = problem->get_dis(scatra_disname); if (redistribute_struct_dis) { - Teuchos::ParameterList binning_params = Global::Problem::instance()->binning_strategy_params(); + Teuchos::ParameterList binning_params = problem->binning_strategy_params(); Core::Utils::add_enum_class_to_parameter_list( - "spatial_approximation_type", Global::Problem::instance()->spatial_approximation_type(), - binning_params); - Core::Rebalance::rebalance_discretizations_by_binning(binning_params, - Global::Problem::instance()->output_control_file(), {structdis}, nullptr, nullptr, false); + "spatial_approximation_type", problem->spatial_approximation_type(), binning_params); + Core::Rebalance::rebalance_discretizations_by_binning( + binning_params, problem->output_control_file(), {structdis}, nullptr, nullptr, false); } if (scatradis->num_global_nodes() == 0) @@ -281,7 +282,7 @@ void SSI::SSIBase::init_discretizations(MPI_Comm comm, const std::string& struct // fill scatra discretization by cloning structure discretization Core::FE::clone_discretization( - *structdis, *scatradis, Global::Problem::instance()->cloning_material_map()); + *structdis, *scatradis, problem->cloning_material_map()); scatradis->fill_complete(); // create discretization for scatra manifold based on SSISurfaceManifold condition @@ -289,8 +290,7 @@ void SSI::SSIBase::init_discretizations(MPI_Comm comm, const std::string& struct { auto scatra_manifold_dis = problem->get_dis("scatra_manifold"); Core::FE::clone_discretization_from_condition( - *structdis, *scatra_manifold_dis, "SSISurfaceManifold", - Global::Problem::instance()->cloning_material_map()); + *structdis, *scatra_manifold_dis, "SSISurfaceManifold", problem->cloning_material_map()); // clone conditions. Needed this way, as many conditions are cloned from SSISurfaceManifold. std::vector> conditions_to_copy = { @@ -414,6 +414,8 @@ void SSI::SSIBase::init_discretizations(MPI_Comm comm, const std::string& struct *----------------------------------------------------------------------*/ SSI::RedistributionType SSI::SSIBase::init_field_coupling(const std::string& struct_disname) { + const Global::Problem* problem = SSI::Utils::problem_from_instance(); + // initialize return variable auto redistribution_required{RedistributionType::none}; @@ -435,8 +437,7 @@ SSI::RedistributionType SSI::SSIBase::init_field_coupling(const std::string& str if (fieldcoupling_ == SSI::FieldCoupling::volume_nonmatch) { - const Teuchos::ParameterList& volmortarparams = - Global::Problem::instance()->volmortar_params(); + const Teuchos::ParameterList& volmortarparams = problem->volmortar_params(); if (Teuchos::getIntegralValue( volmortarparams, "COUPLINGTYPE") != Coupling::VolMortar::couplingtype_coninter) { @@ -472,7 +473,6 @@ SSI::RedistributionType SSI::SSIBase::init_field_coupling(const std::string& str } // initialize coupling objects including dof sets - const Global::Problem* problem = Global::Problem::instance(); ssicoupling_->init( problem->n_dim(), problem->get_dis(struct_disname), Core::Utils::shared_ptr_from_ref(*this)); @@ -483,11 +483,13 @@ SSI::RedistributionType SSI::SSIBase::init_field_coupling(const std::string& str *----------------------------------------------------------------------*/ void SSI::SSIBase::read_restart(const int restart) { + const Global::Problem* problem = SSI::Utils::problem_from_instance(); + if (restart) { structure_->read_restart(restart); - const Teuchos::ParameterList& ssidyn = Global::Problem::instance()->ssi_control_params(); + const Teuchos::ParameterList& ssidyn = problem->ssi_control_params(); const bool restart_from_structure = ssidyn.get("RESTART_FROM_STRUCTURE"); if (not restart_from_structure) // standard restart @@ -516,7 +518,7 @@ void SSI::SSIBase::read_restart(const int restart) /*----------------------------------------------------------------------*/ void SSI::SSIBase::test_results(MPI_Comm comm) const { - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = SSI::Utils::problem_from_instance(); problem->add_field_test(structure_->create_field_test()); problem->add_field_test(scatra_base_algorithm()->create_scatra_field_test()); @@ -581,13 +583,14 @@ void SSI::SSIBase::set_micro_scatra_solution( /*----------------------------------------------------------------------*/ void SSI::SSIBase::evaluate_and_set_temperature_field() { + Global::Problem* problem = SSI::Utils::problem_from_instance(); + // temperature is non primary variable. Only set, if function for temperature is given if (temperature_funct_num_ != -1) { // evaluate temperature at current time and put to scalar const double temperature = - Global::Problem::instance() - ->function_by_id(temperature_funct_num_) + problem->function_by_id(temperature_funct_num_) .evaluate(time()); temperature_vector_->put_scalar(temperature); @@ -684,7 +687,7 @@ void SSI::SSIBase::set_dt_from_scatra_to_ssi() /*----------------------------------------------------------------------*/ void SSI::SSIBase::redistribute(const RedistributionType redistribution_type) const { - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = SSI::Utils::problem_from_instance(); auto structdis = problem->get_dis("structure"); auto scatradis = problem->get_dis("scatra"); @@ -693,13 +696,12 @@ void SSI::SSIBase::redistribute(const RedistributionType redistribution_type) co // first we bin the scatra discretization std::vector> dis; dis.push_back(scatradis); - Teuchos::ParameterList binning_params = Global::Problem::instance()->binning_strategy_params(); + Teuchos::ParameterList binning_params = problem->binning_strategy_params(); Core::Utils::add_enum_class_to_parameter_list( - "spatial_approximation_type", Global::Problem::instance()->spatial_approximation_type(), - binning_params); + "spatial_approximation_type", problem->spatial_approximation_type(), binning_params); - Core::Rebalance::rebalance_discretizations_by_binning(binning_params, - Global::Problem::instance()->output_control_file(), dis, nullptr, nullptr, false); + Core::Rebalance::rebalance_discretizations_by_binning( + binning_params, problem->output_control_file(), dis, nullptr, nullptr, false); Core::Rebalance::match_element_distribution_of_matching_conditioned_elements( *scatradis, *scatradis, "ScatraHeteroReactionMaster", "ScatraHeteroReactionSlave"); @@ -714,13 +716,12 @@ void SSI::SSIBase::redistribute(const RedistributionType redistribution_type) co dis.push_back(structdis); dis.push_back(scatradis); - Teuchos::ParameterList binning_params = Global::Problem::instance()->binning_strategy_params(); + Teuchos::ParameterList binning_params = problem->binning_strategy_params(); Core::Utils::add_enum_class_to_parameter_list( - "spatial_approximation_type", Global::Problem::instance()->spatial_approximation_type(), - binning_params); + "spatial_approximation_type", problem->spatial_approximation_type(), binning_params); - Core::Rebalance::rebalance_discretizations_by_binning(binning_params, - Global::Problem::instance()->output_control_file(), dis, nullptr, nullptr, false); + Core::Rebalance::rebalance_discretizations_by_binning( + binning_params, problem->output_control_file(), dis, nullptr, nullptr, false); } } @@ -745,7 +746,7 @@ void SSI::SSIBase::init_time_integrators(const Teuchos::ParameterList& globaltim const std::string& struct_disname, const std::string& scatra_disname, const bool is_ale) { // get the global problem - auto* problem = Global::Problem::instance(); + auto* problem = SSI::Utils::problem_from_instance(); // time parameter handling // In case of different time stepping, time params have to be read from single field sections. @@ -827,7 +828,8 @@ void SSI::SSIBase::init_time_integrators(const Teuchos::ParameterList& globaltim /*----------------------------------------------------------------------*/ bool SSI::SSIBase::do_calculate_initial_potential_field() const { - const auto ssi_params = Global::Problem::instance()->ssi_control_params(); + const auto* problem = SSI::Utils::problem_from_instance(); + const auto ssi_params = problem->ssi_control_params(); const bool init_pot_calc = ssi_params.sublist("ELCH").get("INITPOTCALC"); return init_pot_calc and is_elch_scatra_time_int_type(); @@ -837,7 +839,8 @@ bool SSI::SSIBase::do_calculate_initial_potential_field() const /*----------------------------------------------------------------------*/ bool SSI::SSIBase::is_elch_scatra_time_int_type() const { - const auto ssi_params = Global::Problem::instance()->ssi_control_params(); + const auto* problem = SSI::Utils::problem_from_instance(); + const auto ssi_params = problem->ssi_control_params(); const auto scatra_type = Teuchos::getIntegralValue(ssi_params, "SCATRATIMINTTYPE"); @@ -849,7 +852,7 @@ bool SSI::SSIBase::is_elch_scatra_time_int_type() const bool SSI::SSIBase::is_restart() const { // get the global problem - const auto* problem = Global::Problem::instance(); + const auto* problem = SSI::Utils::problem_from_instance(); const int restartstep = problem->restart(); @@ -881,9 +884,10 @@ void SSI::SSIBase::check_adaptive_time_stepping( bool SSI::SSIBase::check_s2i_kinetics_condition_for_pseudo_contact( const std::string& struct_disname) const { + const auto* problem = SSI::Utils::problem_from_instance(); bool is_s2i_kinetic_with_pseudo_contact = false; - auto structdis = Global::Problem::instance()->get_dis(struct_disname); + auto structdis = problem->get_dis(struct_disname); // get all s2i kinetics conditions std::vector s2ikinetics_conditions; structdis->get_condition("S2IKinetics", s2ikinetics_conditions); @@ -916,8 +920,8 @@ bool SSI::SSIBase::check_s2i_kinetics_condition_for_pseudo_contact( } const bool do_output_cauchy_stress = - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "STRUCT_STRESS") == Inpar::Solid::stress_cauchy; + Teuchos::getIntegralValue(problem->io_params(), "STRUCT_STRESS") == + Inpar::Solid::stress_cauchy; if (is_s2i_kinetic_with_pseudo_contact and !do_output_cauchy_stress) { @@ -933,8 +937,10 @@ bool SSI::SSIBase::check_s2i_kinetics_condition_for_pseudo_contact( /*----------------------------------------------------------------------*/ void SSI::SSIBase::check_ssi_interface_conditions(const std::string& struct_disname) const { + const auto* problem = SSI::Utils::problem_from_instance(); + // access the structural discretization - auto structdis = Global::Problem::instance()->get_dis(struct_disname); + auto structdis = problem->get_dis(struct_disname); if (ssi_interface_meshtying()) ScaTra::ScaTraUtils::check_consistency_with_s2_i_kinetics_condition( @@ -976,15 +982,16 @@ void SSI::SSIBase::setup_model_evaluator() *----------------------------------------------------------------------*/ void SSI::SSIBase::setup_contact_strategy() { + const auto* problem = SSI::Utils::problem_from_instance(); + // get the contact solution strategy auto contact_solution_type = Teuchos::getIntegralValue( - Global::Problem::instance()->contact_dynamic_params(), "STRATEGY"); + problem->contact_dynamic_params(), "STRATEGY"); if (contact_solution_type == CONTACT::SolvingStrategy::nitsche) { if (Teuchos::getIntegralValue( - Global::Problem::instance()->structural_dynamic_params(), "INT_STRATEGY") != - Inpar::Solid::int_standard) + problem->structural_dynamic_params(), "INT_STRATEGY") != Inpar::Solid::int_standard) { FOUR_C_THROW("ssi contact only with new structural time integration"); } diff --git a/src/ssi/4C_ssi_clonestrategy.cpp b/src/ssi/4C_ssi_clonestrategy.cpp index 2b11d0d41c..996e298674 100644 --- a/src/ssi/4C_ssi_clonestrategy.cpp +++ b/src/ssi/4C_ssi_clonestrategy.cpp @@ -15,6 +15,7 @@ #include "4C_material_parameter_base.hpp" #include "4C_scatra_ele.hpp" #include "4C_ssi_input.hpp" +#include "4C_ssi_problem_access.hpp" FOUR_C_NAMESPACE_OPEN @@ -64,7 +65,7 @@ void SSI::ScatraStructureCloneStrategy::check_material_type(const int matid) // We take the material with the ID specified by the user // Here we check first, whether this material is of admissible type Core::Materials::MaterialType mtype = - Global::Problem::instance()->materials()->parameter_by_id(matid)->type(); + SSI::Utils::problem_from_instance()->materials()->parameter_by_id(matid)->type(); if ((mtype != Core::Materials::m_scatra) && (mtype != Core::Materials::m_elchmat) && (mtype != Core::Materials::m_electrode) && (mtype != Core::Materials::m_matlist) && (mtype != Core::Materials::m_matlist_reactions) && (mtype != Core::Materials::m_myocard) && @@ -120,7 +121,7 @@ void SSI::ScatraStructureCloneStrategyManifold::set_element_data( const int matid, const bool isnurbsdis) { // determine impl type from manifold condition by identifying the condition for this element - auto struct_dis = Global::Problem::instance()->get_dis("structure"); + auto struct_dis = SSI::Utils::problem_from_instance()->get_dis("structure"); std::vector conditions; struct_dis->get_condition("SSISurfaceManifold", conditions); diff --git a/src/ssi/4C_ssi_coupling.cpp b/src/ssi/4C_ssi_coupling.cpp index 0e7c8702ae..a851ec7dc9 100644 --- a/src/ssi/4C_ssi_coupling.cpp +++ b/src/ssi/4C_ssi_coupling.cpp @@ -17,6 +17,7 @@ #include "4C_fem_dofset_predefineddofnumber.hpp" #include "4C_global_data.hpp" #include "4C_mat_par_bundle.hpp" +#include "4C_ssi_problem_access.hpp" FOUR_C_NAMESPACE_OPEN @@ -25,6 +26,8 @@ FOUR_C_NAMESPACE_OPEN void SSI::SSICouplingMatchingVolume::init(const int ndim, std::shared_ptr structdis, std::shared_ptr ssi_base) { + Global::Problem* problem = SSI::Utils::problem_from_instance(); + set_is_setup(false); int scatra_dofset_counter = ssi_base->scatra_field()->get_max_dof_set_number(); @@ -45,7 +48,7 @@ void SSI::SSICouplingMatchingVolume::init(const int ndim, if (structdis->add_dof_set(scatradofset) != ++structure_dofset_counter) FOUR_C_THROW("unexpected dof sets in structure field"); - if (Global::Problem::instance()->elch_control_params().get("TEMPERATURE_FROM_FUNCT") != -1) + if (problem->elch_control_params().get("TEMPERATURE_FROM_FUNCT") != -1) { const int numDofsPerNodeTemp = 1; // defined by temperature field @@ -55,10 +58,8 @@ void SSI::SSICouplingMatchingVolume::init(const int ndim, FOUR_C_THROW("unexpected dof sets in structure field"); } - if (Global::Problem::instance()->materials()->first_id_by_type( - Core::Materials::m_scatra_multiscale) != -1 or - Global::Problem::instance()->materials()->first_id_by_type( - Core::Materials::m_newman_multiscale) != -1) + if (problem->materials()->first_id_by_type(Core::Materials::m_scatra_multiscale) != -1 or + problem->materials()->first_id_by_type(Core::Materials::m_newman_multiscale) != -1) { auto dofsetmicro = std::make_shared(1, 0, 0, true); if (scatradis->add_dof_set(dofsetmicro) != ++scatra_dofset_counter) @@ -180,6 +181,8 @@ void SSI::SSICouplingMatchingVolumeAndBoundary::set_temperature_field( void SSI::SSICouplingNonMatchingBoundary::init(const int ndim, std::shared_ptr structdis, std::shared_ptr ssi_base) { + Global::Problem* problem = SSI::Utils::problem_from_instance(); + set_is_setup(false); int scatra_dofset_counter = ssi_base->scatra_field()->get_max_dof_set_number(); @@ -234,10 +237,9 @@ void SSI::SSICouplingNonMatchingBoundary::init(const int ndim, }); // setup mortar adapter for surface volume coupling - adaptermeshtying_ = std::make_shared( - Global::Problem::instance()->n_dim(), Global::Problem::instance()->mortar_coupling_params(), - Global::Problem::instance()->contact_dynamic_params(), - Global::Problem::instance()->spatial_approximation_type()); + adaptermeshtying_ = std::make_shared(problem->n_dim(), + problem->mortar_coupling_params(), problem->contact_dynamic_params(), + problem->spatial_approximation_type()); set_is_init(true); } @@ -246,17 +248,17 @@ void SSI::SSICouplingNonMatchingBoundary::init(const int ndim, /*----------------------------------------------------------------------*/ void SSI::SSICouplingNonMatchingBoundary::setup() { + Global::Problem* problem = SSI::Utils::problem_from_instance(); + check_is_init(); std::vector coupleddof(problem_dimension_, 1); // Setup of meshtying adapter adaptermeshtying_->setup(structdis_, scatradis_, nullptr, coupleddof, "SSICoupling", - structdis_->get_comm(), Global::Problem::instance()->function_manager(), - Global::Problem::instance()->binning_strategy_params(), - Global::Problem::instance()->discretization_map(), - Global::Problem::instance()->output_control_file(), - Global::Problem::instance()->spatial_approximation_type(), false, false, 0, 1); + structdis_->get_comm(), problem->function_manager(), problem->binning_strategy_params(), + problem->discretization_map(), problem->output_control_file(), + problem->spatial_approximation_type(), false, false, 0, 1); // extractor for coupled surface of structure discretization with surface scatra @@ -385,11 +387,12 @@ void SSI::SSICouplingNonMatchingVolume::init(const int ndim, /*----------------------------------------------------------------------*/ void SSI::SSICouplingNonMatchingVolume::setup() { + const auto* problem = SSI::Utils::problem_from_instance(); + check_is_init(); // setup projection matrices (use default material strategy) - volcoupl_structurescatra_->setup(Global::Problem::instance()->volmortar_params(), - Global::Problem::instance()->cut_general_params()); + volcoupl_structurescatra_->setup(problem->volmortar_params(), problem->cut_general_params()); set_is_setup(true); } @@ -400,9 +403,10 @@ void SSI::SSICouplingNonMatchingVolume::assign_material_pointers( std::shared_ptr structdis, std::shared_ptr scatradis) { - volcoupl_structurescatra_->assign_materials(structdis, scatradis, - Global::Problem::instance()->volmortar_params(), - Global::Problem::instance()->cut_general_params()); + const auto* problem = SSI::Utils::problem_from_instance(); + + volcoupl_structurescatra_->assign_materials( + structdis, scatradis, problem->volmortar_params(), problem->cut_general_params()); } /*----------------------------------------------------------------------*/ @@ -448,6 +452,8 @@ void SSI::SSICouplingNonMatchingVolume::set_scalar_field_micro(Core::FE::Discret void SSI::SSICouplingMatchingVolumeAndBoundary::init(const int ndim, std::shared_ptr structdis, std::shared_ptr ssi_base) { + const auto* problem = SSI::Utils::problem_from_instance(); + set_is_setup(false); int scatra_dofset_counter = ssi_base->scatra_field()->get_max_dof_set_number(); @@ -571,7 +577,7 @@ void SSI::SSICouplingMatchingVolumeAndBoundary::init(const int ndim, scatra_manifold_integrator->set_number_of_dof_set_velocity(scatra_manifold_dofset_counter); } - if (Global::Problem::instance()->elch_control_params().get("TEMPERATURE_FROM_FUNCT") != -1) + if (problem->elch_control_params().get("TEMPERATURE_FROM_FUNCT") != -1) { const int numDofsPerNodeTemp = 1; // defined by temperature field diff --git a/src/ssi/4C_ssi_dyn.cpp b/src/ssi/4C_ssi_dyn.cpp index fc3ad3bfc9..1093a48eba 100644 --- a/src/ssi/4C_ssi_dyn.cpp +++ b/src/ssi/4C_ssi_dyn.cpp @@ -14,6 +14,7 @@ #include "4C_ssi_monolithic_meshtying_strategy.hpp" #include "4C_ssi_partitioned_1wc.hpp" #include "4C_ssi_partitioned_2wc.hpp" +#include "4C_ssi_problem_access.hpp" #include "4C_ssi_utils.hpp" #include @@ -27,7 +28,7 @@ void ssi_drt() { // 1.- Initialization std::shared_ptr ssi = nullptr; - Global::Problem* problem = Global::Problem::instance(); + Global::Problem* problem = SSI::Utils::problem_from_instance(); MPI_Comm comm = problem->get_dis("structure")->get_comm(); { @@ -40,8 +41,7 @@ void ssi_drt() const_cast(problem->scalar_transport_dynamic_params()); // access the structural dynamic params list which will be possibly modified while creating the // time integrator - auto& sdyn = const_cast( - Global::Problem::instance()->structural_dynamic_params()); + auto& sdyn = const_cast(problem->structural_dynamic_params()); FOUR_C_ASSERT_ALWAYS(sdyn.get("INT_STRATEGY") == Inpar::Solid::IntegrationStrategy::int_standard, diff --git a/src/ssi/4C_ssi_manifold_utils.cpp b/src/ssi/4C_ssi_manifold_utils.cpp index ed7617803d..cfe04b3ea3 100644 --- a/src/ssi/4C_ssi_manifold_utils.cpp +++ b/src/ssi/4C_ssi_manifold_utils.cpp @@ -22,6 +22,7 @@ #include "4C_scatra_ele_parameter_boundary.hpp" #include "4C_scatra_timint_implicit.hpp" #include "4C_ssi_monolithic.hpp" +#include "4C_ssi_problem_access.hpp" #include "4C_ssi_utils.hpp" #include "4C_utils_parameter_list.hpp" @@ -93,7 +94,7 @@ SSI::ScaTraManifoldScaTraFluxEvaluator::ScaTraManifoldScaTraFluxEvaluator( : block_map_scatra_(ssi_mono.block_map_scatra()), block_map_scatra_manifold_(ssi_mono.block_map_scatra_manifold()), block_map_structure_(ssi_mono.block_map_structure()), - do_output_(Global::Problem::instance() + do_output_(SSI::Utils::problem_from_instance() ->ssi_control_params() .sublist("MANIFOLD") .get("OUTPUT_INFLOW")), @@ -191,7 +192,7 @@ SSI::ScaTraManifoldScaTraFluxEvaluator::ScaTraManifoldScaTraFluxEvaluator( if (do_output()) { runtime_csvwriter_.emplace(Core::Communication::my_mpi_rank(ssi_mono.get_comm()), - *Global::Problem::instance()->output_control_file(), "manifold_inflow"); + *SSI::Utils::problem_from_instance()->output_control_file(), "manifold_inflow"); for (const auto& condition_manifold : conditions_manifold) { diff --git a/src/ssi/4C_ssi_monolithic.cpp b/src/ssi/4C_ssi_monolithic.cpp index 14a8119d3b..6051922e30 100644 --- a/src/ssi/4C_ssi_monolithic.cpp +++ b/src/ssi/4C_ssi_monolithic.cpp @@ -36,6 +36,7 @@ #include "4C_ssi_monolithic_dbc_handler.hpp" #include "4C_ssi_monolithic_evaluate_OffDiag.hpp" #include "4C_ssi_monolithic_meshtying_strategy.hpp" +#include "4C_ssi_problem_access.hpp" #include "4C_ssi_utils.hpp" #include @@ -60,11 +61,11 @@ SSI::SsiMono::SsiMono(MPI_Comm comm, const Teuchos::ParameterList& globaltimepar relax_lin_solver_iter_step_( globaltimeparams.sublist("MONOLITHIC").get("RELAX_LIN_SOLVER_STEP")), solver_(std::make_shared( - Global::Problem::instance()->solver_params( + SSI::Utils::problem_from_instance()->solver_params( globaltimeparams.sublist("MONOLITHIC").get("LINEAR_SOLVER")), - comm, Global::Problem::instance()->solver_params_callback(), + comm, SSI::Utils::problem_from_instance()->solver_params_callback(), Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"))), + SSI::Utils::problem_from_instance()->io_params(), "VERBOSITY"))), timer_(std::make_shared("SSI_Mono", true)) { const auto init_pot_calc_linear_solver = @@ -73,10 +74,10 @@ SSI::SsiMono::SsiMono(MPI_Comm comm, const Teuchos::ParameterList& globaltimepar if (init_pot_calc_linear_solver.has_value()) { init_pot_calc_solver_ = std::make_shared( - Global::Problem::instance()->solver_params(init_pot_calc_linear_solver.value()), comm, - Global::Problem::instance()->solver_params_callback(), + SSI::Utils::problem_from_instance()->solver_params(init_pot_calc_linear_solver.value()), + comm, SSI::Utils::problem_from_instance()->solver_params_callback(), Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + SSI::Utils::problem_from_instance()->io_params(), "VERBOSITY")); } else { @@ -133,7 +134,7 @@ bool SSI::SsiMono::is_uncomplete_of_matrices_necessary_for_mesh_tying() const // check for first iteration in restart simulations if (is_restart()) { - auto* problem = Global::Problem::instance(); + auto* problem = SSI::Utils::problem_from_instance(); // restart based on time step if (step() == problem->restart() + 1) return true; } @@ -670,10 +671,10 @@ void SSI::SsiMono::setup() "one transported scalar at the moment it is not reasonable to use them with more than one " "transported scalar. So you need to cope with it or change implementation! ;-)"); } - const auto ssi_params = Global::Problem::instance()->ssi_control_params(); + const auto ssi_params = SSI::Utils::problem_from_instance()->ssi_control_params(); const bool calc_initial_pot_elch = - Global::Problem::instance()->elch_control_params().get("INITPOTCALC"); + SSI::Utils::problem_from_instance()->elch_control_params().get("INITPOTCALC"); const bool calc_initial_pot_ssi = ssi_params.sublist("ELCH").get("INITPOTCALC"); if (scatra_field()->equilibration_method() != Core::LinAlg::EquilibrationMethod::none) @@ -693,7 +694,8 @@ void SSI::SsiMono::setup() equilibration_method_.scatra != Core::LinAlg::EquilibrationMethod::none)) FOUR_C_THROW("Block based equilibration only for block matrices"); - if (not Global::Problem::instance()->scalar_transport_dynamic_params().get("SKIPINITDER")) + if (not SSI::Utils::problem_from_instance()->scalar_transport_dynamic_params().get( + "SKIPINITDER")) { FOUR_C_THROW( "Initial derivatives are already calculated in monolithic SSI. Enable 'SKIPINITDER' in the " @@ -1182,7 +1184,7 @@ void SSI::SsiMono::distribute_solution_all_fields(const bool restore_velocity) void SSI::SsiMono::calc_initial_potential_field() { const auto equpot = Teuchos::getIntegralValue( - Global::Problem::instance()->elch_control_params(), "EQUPOT"); + SSI::Utils::problem_from_instance()->elch_control_params(), "EQUPOT"); if (equpot != ElCh::equpot_divi and equpot != ElCh::equpot_enc_pde and equpot != ElCh::equpot_enc_pde_elim) { @@ -1626,7 +1628,7 @@ void SSI::SsiMono::print_system_matrix_rhs_to_mat_lab_format() const for (int col = 0; col < block_matrix->cols(); ++col) { std::ostringstream filename; - filename << Global::Problem::instance()->output_control_file()->file_name() + filename << SSI::Utils::problem_from_instance()->output_control_file()->file_name() << "_block_system_matrix_" << row << "_" << col << ".csv"; Core::LinAlg::print_matrix_in_matlab_format( @@ -1641,8 +1643,9 @@ void SSI::SsiMono::print_system_matrix_rhs_to_mat_lab_format() const auto sparse_matrix = cast_to_const_sparse_matrix_and_check_success(ssi_matrices_->system_matrix()); - const std::string filename = Global::Problem::instance()->output_control_file()->file_name() + - "_sparse_system_matrix.csv"; + const std::string filename = + SSI::Utils::problem_from_instance()->output_control_file()->file_name() + + "_sparse_system_matrix.csv"; Core::LinAlg::print_matrix_in_matlab_format(filename, *sparse_matrix, true); break; @@ -1657,14 +1660,15 @@ void SSI::SsiMono::print_system_matrix_rhs_to_mat_lab_format() const // print rhs { const std::string filename = - Global::Problem::instance()->output_control_file()->file_name() + "_system_vector.csv"; + SSI::Utils::problem_from_instance()->output_control_file()->file_name() + + "_system_vector.csv"; print_vector_in_matlab_format(filename, *ssi_vectors_->residual(), true); } // print full map { const std::string filename = - Global::Problem::instance()->output_control_file()->file_name() + "_full_map.csv"; + SSI::Utils::problem_from_instance()->output_control_file()->file_name() + "_full_map.csv"; print_map_in_matlab_format(filename, *ssi_maps_->map_system_matrix(), true); } } diff --git a/src/ssi/4C_ssi_partitioned_1wc.cpp b/src/ssi/4C_ssi_partitioned_1wc.cpp index 83570c1159..9610e0d829 100644 --- a/src/ssi/4C_ssi_partitioned_1wc.cpp +++ b/src/ssi/4C_ssi_partitioned_1wc.cpp @@ -15,6 +15,7 @@ #include "4C_linalg_utils_sparse_algebra_create.hpp" #include "4C_scatra_timint_cardiac_monodomain.hpp" #include "4C_scatra_timint_implicit.hpp" +#include "4C_ssi_problem_access.hpp" #include @@ -84,7 +85,7 @@ void SSI::SSIPart1WC::do_scatra_step() if (scatra_field()->step() % diffsteps == 0) { Core::IO::DiscretizationReader reader(*scatra_field()->discretization(), - Global::Problem::instance()->input_control_file(), scatra_field()->step()); + SSI::Utils::problem_from_instance()->input_control_file(), scatra_field()->step()); // check if this is a cardiac monodomain problem std::shared_ptr cardmono = @@ -251,8 +252,8 @@ void SSI::SSIPart1WCScatraToSolid::init(MPI_Comm comm, comm, globaltimeparams, scatraparams, structparams, struct_disname, scatra_disname, isAle); // Flag for reading scatra result from restart file instead of computing it - isscatrafromfile_ = - Global::Problem::instance()->ssi_control_params().get("SCATRA_FROM_RESTART_FILE"); + isscatrafromfile_ = SSI::Utils::problem_from_instance()->ssi_control_params().get( + "SCATRA_FROM_RESTART_FILE"); } /*----------------------------------------------------------------------*/ diff --git a/src/ssi/4C_ssi_partitioned_2wc.cpp b/src/ssi/4C_ssi_partitioned_2wc.cpp index 79c5da1a57..2e6423b832 100644 --- a/src/ssi/4C_ssi_partitioned_2wc.cpp +++ b/src/ssi/4C_ssi_partitioned_2wc.cpp @@ -14,12 +14,21 @@ #include "4C_linalg_utils_sparse_algebra_create.hpp" #include "4C_scatra_ele.hpp" #include "4C_scatra_timint_implicit.hpp" +#include "4C_ssi_problem_access.hpp" #include "4C_structure_new_model_evaluator_data.hpp" #include FOUR_C_NAMESPACE_OPEN +namespace +{ + const Teuchos::ParameterList& ssi_control_params_from_problem() + { + return SSI::Utils::ssi_control_params_from_problem(); + } +} // namespace + /*----------------------------------------------------------------------* | constructor Thon 12/14 | *----------------------------------------------------------------------*/ @@ -45,9 +54,9 @@ void SSI::SSIPart2WC::init(MPI_Comm comm, const Teuchos::ParameterList& globalti comm, globaltimeparams, scatraparams, structparams, struct_disname, scatra_disname, isAle); // call the SSI parameter lists - const Teuchos::ParameterList& ssicontrol = Global::Problem::instance()->ssi_control_params(); + const Teuchos::ParameterList& ssicontrol = ssi_control_params_from_problem(); const Teuchos::ParameterList& ssicontrolpart = - Global::Problem::instance()->ssi_control_params().sublist("PARTITIONED"); + ssi_control_params_from_problem().sublist("PARTITIONED"); // do some checks { @@ -441,7 +450,7 @@ void SSI::SSIPart2WCSolidToScatraRelax::init(MPI_Comm comm, comm, globaltimeparams, scatraparams, structparams, struct_disname, scatra_disname, isAle); const Teuchos::ParameterList& ssicontrolpart = - Global::Problem::instance()->ssi_control_params().sublist("PARTITIONED"); + ssi_control_params_from_problem().sublist("PARTITIONED"); // Get minimal relaxation parameter from input file omega_ = ssicontrolpart.get("STARTOMEGA"); @@ -561,7 +570,7 @@ void SSI::SSIPart2WCSolidToScatraRelaxAitken::setup() void SSI::SSIPart2WCSolidToScatraRelaxAitken::calc_omega(double& omega, const int itnum) { const Teuchos::ParameterList& ssicontrolpart = - Global::Problem::instance()->ssi_control_params().sublist("PARTITIONED"); + ssi_control_params_from_problem().sublist("PARTITIONED"); // Get maximal relaxation parameter from input file const double maxomega = ssicontrolpart.get("MAXOMEGA"); @@ -657,7 +666,7 @@ void SSI::SSIPart2WCScatraToSolidRelax::init(MPI_Comm comm, comm, globaltimeparams, scatraparams, structparams, struct_disname, scatra_disname, isAle); const Teuchos::ParameterList& ssicontrolpart = - Global::Problem::instance()->ssi_control_params().sublist("PARTITIONED"); + ssi_control_params_from_problem().sublist("PARTITIONED"); // Get start relaxation parameter from input file omega_ = ssicontrolpart.get("STARTOMEGA"); @@ -777,7 +786,7 @@ void SSI::SSIPart2WCScatraToSolidRelaxAitken::setup() void SSI::SSIPart2WCScatraToSolidRelaxAitken::calc_omega(double& omega, const int itnum) { const Teuchos::ParameterList& ssicontrolpart = - Global::Problem::instance()->ssi_control_params().sublist("PARTITIONED"); + ssi_control_params_from_problem().sublist("PARTITIONED"); // Get maximal relaxation parameter from input file const double maxomega = ssicontrolpart.get("MAXOMEGA"); diff --git a/src/ssi/4C_ssi_problem_access.hpp b/src/ssi/4C_ssi_problem_access.hpp new file mode 100644 index 0000000000..3383e639fa --- /dev/null +++ b/src/ssi/4C_ssi_problem_access.hpp @@ -0,0 +1,29 @@ +// This file is part of 4C multiphysics licensed under the +// GNU Lesser General Public License v3.0 or later. +// +// See the LICENSE.md file in the top-level for license information. +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef FOUR_C_SSI_PROBLEM_ACCESS_HPP +#define FOUR_C_SSI_PROBLEM_ACCESS_HPP + +#include "4C_config.hpp" + +#include "4C_global_data.hpp" + +FOUR_C_NAMESPACE_OPEN + +namespace SSI::Utils +{ + inline Global::Problem* problem_from_instance() { return Global::Problem::instance(); } + + inline const Teuchos::ParameterList& ssi_control_params_from_problem() + { + return problem_from_instance()->ssi_control_params(); + } +} // namespace SSI::Utils + +FOUR_C_NAMESPACE_CLOSE + +#endif diff --git a/src/ssi/4C_ssi_utils.cpp b/src/ssi/4C_ssi_utils.cpp index 3f427e94a4..6e46e262d2 100644 --- a/src/ssi/4C_ssi_utils.cpp +++ b/src/ssi/4C_ssi_utils.cpp @@ -22,6 +22,7 @@ #include "4C_scatra_timint_implicit.hpp" #include "4C_scatra_timint_meshtying_strategy_s2i.hpp" #include "4C_ssi_monolithic.hpp" +#include "4C_ssi_problem_access.hpp" #include @@ -1000,7 +1001,8 @@ void SSI::Utils::SSIMeshTying::setup_mesh_tying_handlers(const Core::FE::Discret Core::Communication::add_owned_node_gid(dis, slave_gid, my_coupled_original_slave_gids); slave_slave_transformation->setup_coupling(dis, dis, inodegidvec_slave, - my_coupled_original_slave_gids, Global::Problem::instance()->n_dim(), true, 1.0e-8); + my_coupled_original_slave_gids, SSI::Utils::problem_from_instance()->n_dim(), true, + 1.0e-8); } // combine coupling adapters and multimap extractor to mesh tying object diff --git a/src/tsi/4C_tsi_algorithm.cpp b/src/tsi/4C_tsi_algorithm.cpp index eaa2a9197e..79e7584ed3 100644 --- a/src/tsi/4C_tsi_algorithm.cpp +++ b/src/tsi/4C_tsi_algorithm.cpp @@ -23,6 +23,7 @@ #include "4C_mortar_multifield_coupling.hpp" #include "4C_thermo_adapter.hpp" #include "4C_tsi_input.hpp" +#include "4C_tsi_problem_access.hpp" #include "4C_tsi_utils.hpp" #include "4C_utils_parameter_list.hpp" @@ -36,23 +37,19 @@ FOUR_C_NAMESPACE_OPEN | constructor (public) dano 12/09 | *----------------------------------------------------------------------*/ TSI::Algorithm::Algorithm(MPI_Comm comm) - : AlgorithmBase(comm, Global::Problem::instance()->tsi_dynamic_params()), + : AlgorithmBase(comm, TSI::Utils::tsi_dynamic_params_from_problem()), dispnp_(nullptr), tempnp_(nullptr), - matchinggrid_(Global::Problem::instance()->tsi_dynamic_params().get("MATCHINGGRID")), + problem_(TSI::Utils::problem_from_instance()), + matchinggrid_(TSI::Utils::tsi_dynamic_params_from_problem().get("MATCHINGGRID")), volcoupl_(nullptr) { // access the structural discretization - std::shared_ptr structdis = - Global::Problem::instance()->get_dis("structure"); + std::shared_ptr structdis = problem_->get_dis("structure"); // access the thermo discretization - std::shared_ptr thermodis = - Global::Problem::instance()->get_dis("thermo"); - - // get the problem instance - Global::Problem* problem = Global::Problem::instance(); + std::shared_ptr thermodis = problem_->get_dis("thermo"); // get the restart step - const int restart = problem->restart(); + const int restart = problem_->restart(); if (!matchinggrid_) { @@ -62,41 +59,37 @@ TSI::Algorithm::Algorithm(MPI_Comm comm) std::shared_ptr materialstrategy = std::make_shared(); // init coupling adapter projection matrices - volcoupl_->init(Global::Problem::instance()->n_dim(), structdis, thermodis, nullptr, nullptr, - nullptr, nullptr, materialstrategy); + volcoupl_->init(problem_->n_dim(), structdis, thermodis, nullptr, nullptr, nullptr, nullptr, + materialstrategy); // redistribute discretizations to meet needs of volmortar coupling - Teuchos::ParameterList binning_params = Global::Problem::instance()->binning_strategy_params(); + Teuchos::ParameterList binning_params = problem_->binning_strategy_params(); Core::Utils::add_enum_class_to_parameter_list( - "spatial_approximation_type", Global::Problem::instance()->spatial_approximation_type(), - binning_params); - volcoupl_->redistribute(binning_params, Global::Problem::instance()->output_control_file()); + "spatial_approximation_type", problem_->spatial_approximation_type(), binning_params); + volcoupl_->redistribute(binning_params, problem_->output_control_file()); // setup projection matrices - volcoupl_->setup(Global::Problem::instance()->volmortar_params(), - Global::Problem::instance()->cut_general_params()); + volcoupl_->setup(problem_->volmortar_params(), problem_->cut_general_params()); } if (Teuchos::getIntegralValue( - Global::Problem::instance()->structural_dynamic_params(), "INT_STRATEGY") == - Inpar::Solid::int_old) + problem_->structural_dynamic_params(), "INT_STRATEGY") == Inpar::Solid::int_old) FOUR_C_THROW("old structural time integration no longer supported in tsi"); else { - Thermo::BaseAlgorithm thermo(Global::Problem::instance()->tsi_dynamic_params(), thermodis); + Thermo::BaseAlgorithm thermo(problem_->tsi_dynamic_params(), thermodis); thermo_ = thermo.thermo_field(); // // access structural dynamic params list which will be possibly modified while creating the // time integrator - const Teuchos::ParameterList& sdyn = Global::Problem::instance()->structural_dynamic_params(); + const Teuchos::ParameterList& sdyn = problem_->structural_dynamic_params(); std::shared_ptr adapterbase_ptr = Adapter::build_structure_algorithm(sdyn); - adapterbase_ptr->init(Global::Problem::instance()->tsi_dynamic_params(), - const_cast(sdyn), structdis); + adapterbase_ptr->init( + problem_->tsi_dynamic_params(), const_cast(sdyn), structdis); // set the temperature; Monolithic does this in it's own constructor with potentially // redistributed discretizations - if (Teuchos::getIntegralValue( - Global::Problem::instance()->tsi_dynamic_params(), "COUPALGO") != - TSI::SolutionSchemeOverFields::Monolithic) + if (Teuchos::getIntegralValue(problem_->tsi_dynamic_params(), + "COUPALGO") != TSI::SolutionSchemeOverFields::Monolithic) { if (matchinggrid_) structdis->set_state(1, "temperature", *thermo_field()->tempnp()); @@ -109,9 +102,9 @@ TSI::Algorithm::Algorithm(MPI_Comm comm) structure_ = std::dynamic_pointer_cast(adapterbase_ptr->structure_field()); - if (restart && Teuchos::getIntegralValue( - Global::Problem::instance()->tsi_dynamic_params(), "COUPALGO") == - TSI::SolutionSchemeOverFields::Monolithic) + if (restart && + Teuchos::getIntegralValue(problem_->tsi_dynamic_params(), + "COUPALGO") == TSI::SolutionSchemeOverFields::Monolithic) structure_->setup(); structure_field()->discretization()->clear_state(true); @@ -135,31 +128,23 @@ TSI::Algorithm::Algorithm(MPI_Comm comm) } // setup mortar coupling - if (Global::Problem::instance()->get_problem_type() == Core::ProblemType::tsi) + if (problem_->get_problem_type() == Core::ProblemType::tsi) { if (structure_field()->discretization()->has_condition("MortarMulti")) { mortar_coupling_ = std::make_shared(); mortar_coupling_->push_back_coupling(structure_field()->discretization(), 0, - std::vector(3, 1), Global::Problem::instance()->mortar_coupling_params(), - Global::Problem::instance()->contact_dynamic_params(), - Global::Problem::instance()->binning_strategy_params(), - {{"structure", Global::Problem::instance()->get_dis("structure")}, - {"thermo", Global::Problem::instance()->get_dis("thermo")}}, - Global::Problem::instance()->function_manager(), - Global::Problem::instance()->output_control_file(), - Global::Problem::instance()->spatial_approximation_type(), - Global::Problem::instance()->n_dim()); + std::vector(3, 1), problem_->mortar_coupling_params(), + problem_->contact_dynamic_params(), problem_->binning_strategy_params(), + {{"structure", problem_->get_dis("structure")}, {"thermo", problem_->get_dis("thermo")}}, + problem_->function_manager(), problem_->output_control_file(), + problem_->spatial_approximation_type(), problem_->n_dim()); mortar_coupling_->push_back_coupling(thermo_field()->discretization(), 0, - std::vector(1, 1), Global::Problem::instance()->mortar_coupling_params(), - Global::Problem::instance()->contact_dynamic_params(), - Global::Problem::instance()->binning_strategy_params(), - {{"structure", Global::Problem::instance()->get_dis("structure")}, - {"thermo", Global::Problem::instance()->get_dis("thermo")}}, - Global::Problem::instance()->function_manager(), - Global::Problem::instance()->output_control_file(), - Global::Problem::instance()->spatial_approximation_type(), - Global::Problem::instance()->n_dim()); + std::vector(1, 1), problem_->mortar_coupling_params(), + problem_->contact_dynamic_params(), problem_->binning_strategy_params(), + {{"structure", problem_->get_dis("structure")}, {"thermo", problem_->get_dis("thermo")}}, + problem_->function_manager(), problem_->output_control_file(), + problem_->spatial_approximation_type(), problem_->n_dim()); } } @@ -180,7 +165,7 @@ void TSI::Algorithm::output(bool forced_writerestart) // defines the dof number ordering of the Discretizations. // call the TSI parameter list - const Teuchos::ParameterList& tsidyn = Global::Problem::instance()->tsi_dynamic_params(); + const Teuchos::ParameterList& tsidyn = problem_->tsi_dynamic_params(); // Get the parameters for the Newton iteration int upres = tsidyn.get("RESULTSEVERY"); int uprestart = tsidyn.get("RESTARTEVERY"); @@ -215,7 +200,7 @@ void TSI::Algorithm::output(bool forced_writerestart) volcoupl_->apply_vector_mapping21(*structure_field()->dispnp()); // determine number of space dimensions - const int numdim = Global::Problem::instance()->n_dim(); + const int numdim = problem_->n_dim(); // loop over all local nodes of thermal discretisation for (int lnodeid = 0; lnodeid < (thermo_field()->discretization()->num_my_row_nodes()); @@ -343,7 +328,7 @@ void TSI::Algorithm::output_deformation_in_thermo( // get the degrees of freedom associated with this structural node std::vector structnodedofs = structdis.dof(0, structlnode); // determine number of space dimensions - const int numdim = Global::Problem::instance()->n_dim(); + const int numdim = problem_->n_dim(); // now we transfer displacement dofs only for (int index = 0; index < numdim; ++index) @@ -444,7 +429,7 @@ void TSI::Algorithm::apply_struct_coupling_state( void TSI::Algorithm::prepare_contact_strategy() { auto stype = Teuchos::getIntegralValue( - Global::Problem::instance()->contact_dynamic_params(), "STRATEGY"); + problem_->contact_dynamic_params(), "STRATEGY"); if (stype == CONTACT::SolvingStrategy::lagmult) { @@ -464,7 +449,7 @@ void TSI::Algorithm::prepare_contact_strategy() // --------------------------------------------------------------------- CONTACT::STRATEGY::Factory factory; factory.init(structure_field()->discretization()); - factory.setup(Global::Problem::instance()->n_dim()); + factory.setup(problem_->n_dim()); // check the problem dimension factory.check_dimension(); @@ -510,14 +495,13 @@ void TSI::Algorithm::prepare_contact_strategy() contact_strategy_lagrange_->inttime_init(); contact_strategy_lagrange_->set_time_integration_info(structure_field()->tim_int_param(), Teuchos::getIntegralValue( - Global::Problem::instance()->structural_dynamic_params(), "DYNAMICTYPE")); + problem_->structural_dynamic_params(), "DYNAMICTYPE")); contact_strategy_lagrange_->redistribute_contact( structure_field()->dispn(), structure_field()->veln()); if (contact_strategy_lagrange_ != nullptr) { - contact_strategy_lagrange_->set_alphaf_thermo( - Global::Problem::instance()->thermal_dynamic_params()); + contact_strategy_lagrange_->set_alphaf_thermo(problem_->thermal_dynamic_params()); contact_strategy_lagrange_->set_coupling(coupST_); } } diff --git a/src/tsi/4C_tsi_algorithm.hpp b/src/tsi/4C_tsi_algorithm.hpp index 2e808a2083..b2ff1adb28 100644 --- a/src/tsi/4C_tsi_algorithm.hpp +++ b/src/tsi/4C_tsi_algorithm.hpp @@ -28,6 +28,12 @@ namespace Core::FE { class Discretization; } // namespace Core::FE + +namespace Global +{ + class Problem; +} + namespace CONTACT { class LagrangeStrategyTsi; @@ -172,6 +178,8 @@ namespace TSI //! @name Volume Mortar stuff + Global::Problem* problem_; + //! flag for matchinggrid const bool matchinggrid_; //! volume coupling (using mortar) adapter diff --git a/src/tsi/4C_tsi_dyn.cpp b/src/tsi/4C_tsi_dyn.cpp index c5c8ef96fe..6cec9f719c 100644 --- a/src/tsi/4C_tsi_dyn.cpp +++ b/src/tsi/4C_tsi_dyn.cpp @@ -16,6 +16,7 @@ #include "4C_tsi_input.hpp" #include "4C_tsi_monolithic.hpp" #include "4C_tsi_partitioned.hpp" +#include "4C_tsi_problem_access.hpp" #include "4C_tsi_utils.hpp" #include @@ -28,8 +29,10 @@ FOUR_C_NAMESPACE_OPEN *----------------------------------------------------------------------*/ void tsi_dyn_drt() { + Global::Problem* problem = TSI::Utils::problem_from_instance(); + // create a communicator - MPI_Comm comm = Global::Problem::instance()->get_dis("structure")->get_comm(); + MPI_Comm comm = problem->get_dis("structure")->get_comm(); // print TSI-Logo to screen if (Core::Communication::my_mpi_rank(comm) == 0) TSI::printlogo(); @@ -38,10 +41,9 @@ void tsi_dyn_drt() TSI::Utils::setup_tsi(comm); // access the problem-specific parameter list - const Teuchos::ParameterList& tsidyn = Global::Problem::instance()->tsi_dynamic_params(); + const Teuchos::ParameterList& tsidyn = problem->tsi_dynamic_params(); // access the problem-specific parameter list - const Teuchos::ParameterList& sdynparams = - Global::Problem::instance()->structural_dynamic_params(); + const Teuchos::ParameterList& sdynparams = problem->structural_dynamic_params(); const auto coupling = Teuchos::getIntegralValue(tsidyn, "COUPALGO"); @@ -74,7 +76,7 @@ void tsi_dyn_drt() break; } // end switch - const int restart = Global::Problem::instance()->restart(); + const int restart = problem->restart(); if (restart) { // read the restart information, set vectors and variables @@ -93,9 +95,9 @@ void tsi_dyn_drt() tsi->time_loop(); // perform the result test - Global::Problem::instance()->add_field_test(tsi->structure_field()->create_field_test()); - Global::Problem::instance()->add_field_test(tsi->thermo_field()->create_field_test()); - Global::Problem::instance()->test_all(comm); + problem->add_field_test(tsi->structure_field()->create_field_test()); + problem->add_field_test(tsi->thermo_field()->create_field_test()); + problem->test_all(comm); } // tsi_dyn_drt() diff --git a/src/tsi/4C_tsi_monolithic.cpp b/src/tsi/4C_tsi_monolithic.cpp index 7582bc2323..99da06134f 100644 --- a/src/tsi/4C_tsi_monolithic.cpp +++ b/src/tsi/4C_tsi_monolithic.cpp @@ -29,6 +29,7 @@ #include "4C_structure_new_timint_base.hpp" #include "4C_thermo_adapter.hpp" #include "4C_thermo_ele_action.hpp" +#include "4C_tsi_problem_access.hpp" #include "4C_tsi_utils.hpp" #include @@ -48,17 +49,16 @@ FOUR_C_NAMESPACE_OPEN *----------------------------------------------------------------------*/ TSI::Monolithic::Monolithic(MPI_Comm comm, const Teuchos::ParameterList& sdynparams) : Algorithm(comm), - solveradapttol_(((Global::Problem::instance()->tsi_dynamic_params()).sublist("MONOLITHIC")) - .get("ADAPTCONV")), + solveradapttol_( + TSI::Utils::tsi_monolithic_dynamic_params_from_problem().get("ADAPTCONV")), solveradaptolbetter_( - ((Global::Problem::instance()->tsi_dynamic_params()).sublist("MONOLITHIC")) - .get("ADAPTCONV_BETTER")), + TSI::Utils::tsi_monolithic_dynamic_params_from_problem().get("ADAPTCONV_BETTER")), printiter_(true), // ADD INPUT PARAMETER zeros_(nullptr), strmethodname_( Teuchos::getIntegralValue(sdynparams, "DYNAMICTYPE")), - tsidyn_(Global::Problem::instance()->tsi_dynamic_params()), - tsidynmono_((Global::Problem::instance()->tsi_dynamic_params()).sublist("MONOLITHIC")), + tsidyn_(TSI::Utils::tsi_dynamic_params_from_problem()), + tsidynmono_(TSI::Utils::tsi_monolithic_dynamic_params_from_problem()), blockrowdofmap_(nullptr), systemmatrix_(nullptr), k_st_(nullptr), @@ -108,16 +108,14 @@ TSI::Monolithic::Monolithic(MPI_Comm comm, const Teuchos::ParameterList& sdynpar // get solver parameter list of linear TSI solver const int linsolvernumber = tsidynmono_.get("LINEAR_SOLVER"); - const Teuchos::ParameterList& tsisolverparams = - Global::Problem::instance()->solver_params(linsolvernumber); + const Teuchos::ParameterList& tsisolverparams = problem_->solver_params(linsolvernumber); Teuchos::ParameterList solverparams; solverparams = tsisolverparams; solver_ = std::make_shared(solverparams, get_comm(), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + problem_->solver_params_callback(), + Teuchos::getIntegralValue(problem_->io_params(), "VERBOSITY")); } // end BlockMatrixMerge // structure_field: check whether we have locsys BCs, i.e. inclined structural @@ -179,8 +177,8 @@ void TSI::Monolithic::read_restart(int step) std::shared_ptr strategy = std::make_shared(); volcoupl_->assign_materials(structure_field()->discretization(), - thermo_field()->discretization(), Global::Problem::instance()->volmortar_params(), - Global::Problem::instance()->cut_general_params(), strategy); + thermo_field()->discretization(), problem_->volmortar_params(), + problem_->cut_general_params(), strategy); } Teuchos::ParameterList p; @@ -232,8 +230,7 @@ void TSI::Monolithic::create_linear_solver() } // get solver parameter list of linear TSI solver - const Teuchos::ParameterList& tsisolverparams = - Global::Problem::instance()->solver_params(linsolvernumber); + const Teuchos::ParameterList& tsisolverparams = problem_->solver_params(linsolvernumber); const auto solvertype = Teuchos::getIntegralValue(tsisolverparams, "SOLVER"); @@ -252,9 +249,8 @@ void TSI::Monolithic::create_linear_solver() // prepare linear solvers and preconditioners solver_ = std::make_shared(tsisolverparams, get_comm(), - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY")); + problem_->solver_params_callback(), + Teuchos::getIntegralValue(problem_->io_params(), "VERBOSITY")); const auto azprectype = Teuchos::getIntegralValue(tsisolverparams, "AZPREC"); @@ -265,17 +261,15 @@ void TSI::Monolithic::create_linear_solver() case Core::LinearSolver::PreconditionerType::block_teko: { solver_->put_solver_params_to_sub_params("Inverse1", tsisolverparams, - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"), + problem_->solver_params_callback(), + Teuchos::getIntegralValue(problem_->io_params(), "VERBOSITY"), get_comm()); compute_null_space_if_necessary( *structure_field()->discretization(), solver_->params().sublist("Inverse1")); solver_->put_solver_params_to_sub_params("Inverse2", tsisolverparams, - Global::Problem::instance()->solver_params_callback(), - Teuchos::getIntegralValue( - Global::Problem::instance()->io_params(), "VERBOSITY"), + problem_->solver_params_callback(), + Teuchos::getIntegralValue(problem_->io_params(), "VERBOSITY"), get_comm()); compute_null_space_if_necessary( *thermo_field()->discretization(), solver_->params().sublist("Inverse2")); @@ -1020,8 +1014,7 @@ void TSI::Monolithic::setup_rhs() std::shared_ptr> str_rhs = std::make_shared>(*structure_field()->rhs()); if (Teuchos::getIntegralValue( - Global::Problem::instance()->structural_dynamic_params(), "INT_STRATEGY") == - Inpar::Solid::int_standard) + problem_->structural_dynamic_params(), "INT_STRATEGY") == Inpar::Solid::int_standard) str_rhs->scale(-1.); // insert vectors to tsi rhs @@ -1717,7 +1710,7 @@ void TSI::Monolithic::apply_thermo_coupl_matrix( tparams.set("total time", time()); // create specific time integrator - const Teuchos::ParameterList& tdyn = Global::Problem::instance()->thermal_dynamic_params(); + const Teuchos::ParameterList& tdyn = problem_->thermal_dynamic_params(); tparams.set( "time integrator", Teuchos::getIntegralValue(tdyn, "DYNAMICTYPE")); tparams.set("structural time integrator", strmethodname_); @@ -1822,7 +1815,7 @@ void TSI::Monolithic::apply_thermo_coupl_matrix_conv_bc( tparams.set("delta time", dt()); tparams.set("total time", time()); // create specific time integrator - const Teuchos::ParameterList& tdyn = Global::Problem::instance()->thermal_dynamic_params(); + const Teuchos::ParameterList& tdyn = problem_->thermal_dynamic_params(); tparams.set( "time integrator", Teuchos::getIntegralValue(tdyn, "DYNAMICTYPE")); tparams.set("structural time integrator", strmethodname_); @@ -2063,7 +2056,7 @@ void TSI::Monolithic::set_default_parameters() { // time parameters // call the TSI parameter list - const Teuchos::ParameterList& tdyn = Global::Problem::instance()->thermal_dynamic_params(); + const Teuchos::ParameterList& tdyn = problem_->thermal_dynamic_params(); // get the parameters for the Newton iteration itermax_ = tsidyn_.get("ITEMAX"); @@ -2238,11 +2231,10 @@ void TSI::Monolithic::prepare_output() void TSI::Monolithic::fix_time_integration_params() { if (Teuchos::getIntegralValue( - Global::Problem::instance()->thermal_dynamic_params(), "DYNAMICTYPE") == - Thermo::DynamicType::GenAlpha) + problem_->thermal_dynamic_params(), "DYNAMICTYPE") == Thermo::DynamicType::GenAlpha) { - Teuchos::ParameterList& ga = const_cast( - Global::Problem::instance()->thermal_dynamic_params().sublist("GENALPHA")); + Teuchos::ParameterList& ga = + const_cast(problem_->thermal_dynamic_params().sublist("GENALPHA")); double rhoinf = ga.get("RHO_INF"); if (rhoinf != -1.) @@ -2257,12 +2249,11 @@ void TSI::Monolithic::fix_time_integration_params() } } - if (Teuchos::getIntegralValue( - Global::Problem::instance()->structural_dynamic_params(), "DYNAMICTYPE") == - Inpar::Solid::DynamicType::GenAlpha) + if (Teuchos::getIntegralValue(problem_->structural_dynamic_params(), + "DYNAMICTYPE") == Inpar::Solid::DynamicType::GenAlpha) { Teuchos::ParameterList& ga = const_cast( - Global::Problem::instance()->structural_dynamic_params().sublist("GENALPHA")); + problem_->structural_dynamic_params().sublist("GENALPHA")); double rhoinf = ga.get("RHO_INF"); if (rhoinf != -1.) diff --git a/src/tsi/4C_tsi_partitioned.cpp b/src/tsi/4C_tsi_partitioned.cpp index 3b8689acd9..3a9830eb6a 100644 --- a/src/tsi/4C_tsi_partitioned.cpp +++ b/src/tsi/4C_tsi_partitioned.cpp @@ -39,10 +39,9 @@ TSI::Partitioned::Partitioned(MPI_Comm comm) mu_(0.0) { // call the TSI parameter list - const Teuchos::ParameterList& tsidyn = Global::Problem::instance()->tsi_dynamic_params(); + const Teuchos::ParameterList& tsidyn = problem_->tsi_dynamic_params(); // call the TSI parameter list - const Teuchos::ParameterList& tsidynpart = - Global::Problem::instance()->tsi_dynamic_params().sublist("PARTITIONED"); + const Teuchos::ParameterList& tsidynpart = problem_->tsi_dynamic_params().sublist("PARTITIONED"); // get the parameters for the convergence_check itmax_ = tsidyn.get("ITEMAX"); // default: =1 @@ -61,7 +60,7 @@ TSI::Partitioned::Partitioned(MPI_Comm comm) std::cout << "Coupling variable: temperature" << std::endl; // if structure field is quasi-static --> calc_velocity - const Teuchos::ParameterList& sdyn = Global::Problem::instance()->structural_dynamic_params(); + const Teuchos::ParameterList& sdyn = problem_->structural_dynamic_params(); // major switch to different time integrators quasistatic_ = (Teuchos::getIntegralValue(sdyn, "DYNAMICTYPE") == Inpar::Solid::DynamicType::Statics); @@ -374,9 +373,8 @@ void TSI::Partitioned::outer_iteration_loop() } // call the TSI parameter lists - const Teuchos::ParameterList& tsidyn = Global::Problem::instance()->tsi_dynamic_params(); - const Teuchos::ParameterList& tsidynpart = - Global::Problem::instance()->tsi_dynamic_params().sublist("PARTITIONED"); + const Teuchos::ParameterList& tsidyn = problem_->tsi_dynamic_params(); + const Teuchos::ParameterList& tsidynpart = problem_->tsi_dynamic_params().sublist("PARTITIONED"); // decide if one-way coupling or full coupling auto coupling = Teuchos::getIntegralValue(tsidyn, "COUPALGO"); diff --git a/src/tsi/4C_tsi_problem_access.hpp b/src/tsi/4C_tsi_problem_access.hpp new file mode 100644 index 0000000000..adf916f22e --- /dev/null +++ b/src/tsi/4C_tsi_problem_access.hpp @@ -0,0 +1,34 @@ +// This file is part of 4C multiphysics licensed under the +// GNU Lesser General Public License v3.0 or later. +// +// See the LICENSE.md file in the top-level for license information. +// +// SPDX-License-Identifier: LGPL-3.0-or-later + +#ifndef FOUR_C_TSI_PROBLEM_ACCESS_HPP +#define FOUR_C_TSI_PROBLEM_ACCESS_HPP + +#include "4C_config.hpp" + +#include "4C_global_data.hpp" + +FOUR_C_NAMESPACE_OPEN + +namespace TSI::Utils +{ + inline Global::Problem* problem_from_instance() { return Global::Problem::instance(); } + + inline const Teuchos::ParameterList& tsi_dynamic_params_from_problem() + { + return problem_from_instance()->tsi_dynamic_params(); + } + + inline const Teuchos::ParameterList& tsi_monolithic_dynamic_params_from_problem() + { + return tsi_dynamic_params_from_problem().sublist("MONOLITHIC"); + } +} // namespace TSI::Utils + +FOUR_C_NAMESPACE_CLOSE + +#endif diff --git a/src/tsi/4C_tsi_utils.cpp b/src/tsi/4C_tsi_utils.cpp index b930f09297..29e8d93d44 100644 --- a/src/tsi/4C_tsi_utils.cpp +++ b/src/tsi/4C_tsi_utils.cpp @@ -18,6 +18,7 @@ #include "4C_mat_material_factory.hpp" #include "4C_solid_scatra_3D_ele.hpp" #include "4C_thermo_element.hpp" +#include "4C_tsi_problem_access.hpp" @@ -45,7 +46,7 @@ void TSI::Utils::ThermoStructureCloneStrategy::check_material_type(const int mat // We take the material with the ID specified by the user // Here we check first, whether this material is of admissible type // Core::Materials::MaterialType mtype = - // Global::Problem::instance()->Materials()->ParameterById(matid)->Type(); if ((mtype != + // Global::Problem singleton -> Materials()->ParameterById(matid)->Type(); if ((mtype != // Core::Materials::m_thermo_fourier)) // FOUR_C_THROW("Material with ID {} is not admissible for thermo elements",matid); @@ -114,9 +115,11 @@ bool TSI::Utils::ThermoStructureCloneStrategy::determine_ele_type( *----------------------------------------------------------------------*/ void TSI::Utils::setup_tsi(MPI_Comm comm) { + Global::Problem* problem = TSI::Utils::problem_from_instance(); + // access the structure discretization, make sure it is filled std::shared_ptr structdis; - structdis = Global::Problem::instance()->get_dis("structure"); + structdis = problem->get_dis("structure"); // set degrees of freedom in the discretization if (!structdis->filled() or !structdis->have_dofs()) { @@ -128,11 +131,11 @@ void TSI::Utils::setup_tsi(MPI_Comm comm) // access the thermo discretization std::shared_ptr thermdis; - thermdis = Global::Problem::instance()->get_dis("thermo"); + thermdis = problem->get_dis("thermo"); if (!thermdis->filled()) thermdis->fill_complete(); // access the problem-specific parameter list - const Teuchos::ParameterList& tsidyn = Global::Problem::instance()->tsi_dynamic_params(); + const Teuchos::ParameterList& tsidyn = problem->tsi_dynamic_params(); bool matchinggrid = tsidyn.get("MATCHINGGRID"); @@ -150,7 +153,7 @@ void TSI::Utils::setup_tsi(MPI_Comm comm) } Core::FE::clone_discretization( - *structdis, *thermdis, Global::Problem::instance()->cloning_material_map()); + *structdis, *thermdis, problem->cloning_material_map()); thermdis->fill_complete(); // connect degrees of freedom for periodic boundary conditions @@ -207,7 +210,7 @@ void TSI::Utils::setup_tsi(MPI_Comm comm) // build auxiliary dofsets, i.e. pseudo dofs on each discretization const int ndofpernode_thermo = 1; const int ndofperelement_thermo = 0; - const int ndofpernode_struct = Global::Problem::instance()->n_dim(); + const int ndofpernode_struct = problem->n_dim(); const int ndofperelement_struct = 0; std::shared_ptr dofsetaux; dofsetaux = std::make_shared(