Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 63 additions & 90 deletions src/adapter/4C_adapter_fld_base_algorithm.cpp

Large diffs are not rendered by default.

43 changes: 21 additions & 22 deletions src/adapter/4C_adapter_fld_fluid_ale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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<Adapter::AleBaseAlgorithm> ale = std::make_shared<Adapter::AleBaseAlgorithm>(
prbdyn, Global::Problem::instance()->get_dis("ale"));
std::shared_ptr<Adapter::AleBaseAlgorithm> ale =
std::make_shared<Adapter::AleBaseAlgorithm>(prbdyn, problem->get_dis("ale"));
ale_ = std::dynamic_pointer_cast<Adapter::AleFluidWrapper>(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;
Expand All @@ -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<bool>("MATCHGRID_FLUIDALE"))
if (problem->fsi_dynamic_params().get<bool>("MATCHGRID_FLUIDALE"))
{
// the fluid-ale coupling matches
const Core::LinAlg::Map* fluidnodemap = fluid_field()->discretization()->node_row_map();
Expand All @@ -67,8 +69,7 @@ Adapter::FluidAle::FluidAle(const Teuchos::ParameterList& prbdyn, std::string co
std::make_shared<Coupling::Adapter::Coupling>();
coupfa_matching->setup_coupling(*fluid_field()->discretization(),
*ale_field()->discretization(), *fluidnodemap, *alenodemap, ndim,
Global::Problem::instance()->fsi_dynamic_params().get<bool>("MATCHALL"), tolerance,
nds_master, nds_slave);
problem->fsi_dynamic_params().get<bool>("MATCHALL"), tolerance, nds_master, nds_slave);
coupfa_ = coupfa_matching;
}
else
Expand Down Expand Up @@ -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<ALE::InitialDisp>(Global::Problem::instance()->ale_dynamic_params(),
"INITIALDISP") != ALE::initdisp_zero_disp)
if (Teuchos::getIntegralValue<ALE::InitialDisp>(problem->ale_dynamic_params(), "INITIALDISP") !=
ALE::initdisp_zero_disp)
{
fluid_field()->set_mesh_map(coupfa_->master_dof_map(), nds_master);
std::shared_ptr<Core::LinAlg::Vector<double>> initfluiddisp =
Expand All @@ -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<bool>("MATCHGRID_STRUCTALE"))
if (problem->fsi_dynamic_params().get<bool>("MATCHGRID_STRUCTALE"))
{
std::shared_ptr<Coupling::Adapter::Coupling> icoupfa =
std::make_shared<Coupling::Adapter::Coupling>();
Expand Down Expand Up @@ -149,12 +148,10 @@ Adapter::FluidAle::FluidAle(const Teuchos::ParameterList& prbdyn, std::string co
std::pair<int, int> dofsets12(0, 0);
std::pair<int, int> 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;
}
Expand Down Expand Up @@ -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<int>("RESTARTEVERY");
Expand Down
24 changes: 24 additions & 0 deletions src/adapter/4C_adapter_problem_access.hpp
Original file line number Diff line number Diff line change
@@ -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
22 changes: 15 additions & 7 deletions src/fs3i/4C_fs3i.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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<bool>("INF_PERM")),
timemax_(Global::Problem::instance()->f_s3_i_dynamic_params().get<double>("MAXTIME")),
numstep_(Global::Problem::instance()->f_s3_i_dynamic_params().get<int>("NUMSTEP")),
dt_(Global::Problem::instance()->f_s3_i_dynamic_params().get<double>("TIMESTEP")),
: infperm_(fs3i_dynamic_params_from_problem().get<bool>("INF_PERM")),
timemax_(fs3i_dynamic_params_from_problem().get<double>("MAXTIME")),
numstep_(fs3i_dynamic_params_from_problem().get<int>("NUMSTEP")),
dt_(fs3i_dynamic_params_from_problem().get<double>("TIMESTEP")),
time_(0.0),
step_(0),
issetup_(false),
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -228,8 +237,7 @@ void FS3I::FS3IBase::check_f_s3_i_inputs()
"in the structure is NOT divergence free!");
}

auto pstype = Teuchos::getIntegralValue<Inpar::Solid::PreStress>(
Global::Problem::instance()->structural_dynamic_params(), "PRESTRESS");
auto pstype = Teuchos::getIntegralValue<Inpar::Solid::PreStress>(structdynparams, "PRESTRESS");
// is structure calculated dynamic when not prestressing?
if (Teuchos::getIntegralValue<Inpar::Solid::DynamicType>(structdynparams, "DYNAMICTYPE") ==
Inpar::Solid::DynamicType::Statics and
Expand Down
32 changes: 16 additions & 16 deletions src/fs3i/4C_fs3i_biofilm_fsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<bool>("SKIPINITDER"))
FOUR_C_THROW(
"Initial time derivative of phi must not be calculated automatically -> set SKIPINITDER to "
Expand Down Expand Up @@ -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<Core::FE::Discretization> structaledis =
Global::Problem::instance()->get_dis("structale");
std::shared_ptr<Core::FE::Discretization> 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);
Expand All @@ -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<Coupling::Adapter::Coupling>();
Expand Down Expand Up @@ -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<bool>("BIOFILMGROWTH");
const bool outputgmsh_ = biofilmcontrol.get<bool>("OUTPUT_GMSH");

Expand Down Expand Up @@ -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<bool>("AVGROWTH");
// in case of averaged values we need temporary variables
Core::LinAlg::Vector<double> normtempinflux_(
Expand Down Expand Up @@ -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<FsiCoupling>(fsidyn, "COUPALGO");
if (coupling == fsi_iter_monolithicfluidsplit)
{
Expand Down Expand Up @@ -891,12 +891,12 @@ std::shared_ptr<Core::LinAlg::Vector<double>> FS3I::BiofilmFSI::struct_to_ale(
void FS3I::BiofilmFSI::vec_to_scatravec(Core::FE::Discretization& scatradis,
Core::LinAlg::Vector<double>& vec, Core::LinAlg::MultiVector<double>& 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];
Expand Down
3 changes: 2 additions & 1 deletion src/fs3i/4C_fs3i_biofilm_fsi_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -48,7 +49,7 @@ void FS3I::BioFilm::Utils::scatra_change_config(Core::FE::Discretization& scatra
std::vector<double> 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)
{
Expand Down
7 changes: 5 additions & 2 deletions src/fs3i/4C_fs3i_dyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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::FS3IBase> 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)
{
Expand Down
Loading
Loading