Skip to content

Commit

Permalink
Merge pull request #458 from sebproell/use-optional-instead-of-noneable
Browse files Browse the repository at this point in the history
Use std::optional instead of Noneable
  • Loading branch information
sebproell authored Feb 28, 2025
2 parents a9008b0 + 5110ace commit 572fd00
Show file tree
Hide file tree
Showing 136 changed files with 785 additions and 954 deletions.
6 changes: 3 additions & 3 deletions src/art_net/4C_art_net_art_terminal_bc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void Arteries::Utils::solve_prescribed_terminal_bc(Core::FE::Discretization& act
// -----------------------------------------------------------------
// Read in the bc curve information
// -----------------------------------------------------------------
const auto& curve = condition->parameters().get<std::vector<Core::IO::Noneable<int>>>("curve");
const auto& curve = condition->parameters().get<std::vector<std::optional<int>>>("curve");
double curvefac = 1.0;
const auto& vals = condition->parameters().get<std::vector<double>>("VAL");

Expand Down Expand Up @@ -546,7 +546,7 @@ void Arteries::Utils::solve_reflective_terminal(Core::FE::Discretization& actdis
// -------------------------------------------------------------------
// Read in the bc curve information
// -------------------------------------------------------------------
const auto& curve = condition->parameters().get<std::vector<Core::IO::Noneable<int>>>("curve");
const auto& curve = condition->parameters().get<std::vector<std::optional<int>>>("curve");
double curvefac = 1.0;
const auto& vals = condition->parameters().get<std::vector<double>>("VAL");

Expand Down Expand Up @@ -625,7 +625,7 @@ void Arteries::Utils::solve_expl_windkessel_bc(Core::FE::Discretization& actdis,
// -------------------------------------------------------------------
// Read in the bc curve information
// -------------------------------------------------------------------
const auto& curve = condition->parameters().get<std::vector<Core::IO::Noneable<int>>>("curve");
const auto& curve = condition->parameters().get<std::vector<std::optional<int>>>("curve");
double curvefac = 1.0;
const auto& vals = condition->parameters().get<std::vector<double>>("VAL");

Expand Down
2 changes: 1 addition & 1 deletion src/beam3/4C_beam3_euler_bernoulli_evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ int Discret::Elements::Beam3eb::evaluate_neumann(Teuchos::ParameterList& params,
time = params.get("total time", -1.0);

// find out whether we will use a time curve and get the factor
const auto tmp_funct = condition.parameters().get<std::vector<Core::IO::Noneable<int>>>("FUNCT");
const auto tmp_funct = condition.parameters().get<std::vector<std::optional<int>>>("FUNCT");

// get values and switches from the condition
// "ONOFF" is related to the first 6 flags of a line Neumann condition in the input file;
Expand Down
4 changes: 2 additions & 2 deletions src/beam3/4C_beam3_kirchhoff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ namespace Discret
const Core::LinAlg::Matrix<6 * nnodecl + BEAM3K_COLLOCATION_POINTS, 1, double>&
disp_totlag,
const Core::LinAlg::Matrix<6, 1, double>& load_vector_neumann,
const std::vector<Core::IO::Noneable<int>>& function_numbers, double time) const;
const std::vector<std::optional<int>>& function_numbers, double time) const;

/** \brief evaluate contributions to element residual vector from line Neumann condition
*
Expand All @@ -900,7 +900,7 @@ namespace Discret
void evaluate_line_neumann_forces(
Core::LinAlg::Matrix<6 * nnodecl + BEAM3K_COLLOCATION_POINTS, 1, T>& force_ext,
const Core::LinAlg::Matrix<6, 1, double>& load_vector_neumann,
const std::vector<Core::IO::Noneable<int>>& function_numbers, double time) const;
const std::vector<std::optional<int>>& function_numbers, double time) const;

/** \brief evaluate all contributions from brownian dynamics (thermal & viscous
* forces/moments)
Expand Down
14 changes: 7 additions & 7 deletions src/beam3/4C_beam3_kirchhoff_evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2114,7 +2114,7 @@ int Discret::Elements::Beam3k::evaluate_neumann(Teuchos::ParameterList& params,
if (condition.type() == Core::Conditions::PointNeumannEB)
{
// find out whether we will use a time curve and get the factor
const auto funct = condition.parameters().get<std::vector<Core::IO::Noneable<int>>>("FUNCT");
const auto funct = condition.parameters().get<std::vector<std::optional<int>>>("FUNCT");
// amplitude of load curve at current time called
std::vector<double> functtimefac(6, 1.0);

Expand Down Expand Up @@ -2159,7 +2159,7 @@ int Discret::Elements::Beam3k::evaluate_neumann(Teuchos::ParameterList& params,
// funct is related to the 6 "FUNCT" fields after the val field of the Neumann condition
// in the input file; funct gives the number of the function defined in the section FUNCT
const auto function_numbers =
condition.parameters().get<std::vector<Core::IO::Noneable<int>>>("FUNCT");
condition.parameters().get<std::vector<std::optional<int>>>("FUNCT");

// Check if distributed moment load is applied and throw error
for (unsigned int idof = 3; idof < 6; ++idof)
Expand Down Expand Up @@ -2437,7 +2437,7 @@ void Discret::Elements::Beam3k::evaluate_line_neumann(Core::LinAlg::SerialDenseV
Core::LinAlg::SerialDenseMatrix* stiffmat,
const Core::LinAlg::Matrix<6 * nnodecl + BEAM3K_COLLOCATION_POINTS, 1, double>& disp_totlag,
const Core::LinAlg::Matrix<6, 1, double>& load_vector_neumann,
const std::vector<Core::IO::Noneable<int>>& function_numbers, double time) const
const std::vector<std::optional<int>>& function_numbers, double time) const
{
if (not use_fad_)
{
Expand Down Expand Up @@ -2527,7 +2527,7 @@ template <unsigned int nnodecl, typename T>
void Discret::Elements::Beam3k::evaluate_line_neumann_forces(
Core::LinAlg::Matrix<6 * nnodecl + BEAM3K_COLLOCATION_POINTS, 1, T>& force_ext,
const Core::LinAlg::Matrix<6, 1, double>& load_vector_neumann,
const std::vector<Core::IO::Noneable<int>>& function_numbers, double time) const
const std::vector<std::optional<int>>& function_numbers, double time) const
{
std::vector<Core::LinAlg::Matrix<3, 3>> Gref(2);

Expand Down Expand Up @@ -3932,16 +3932,16 @@ Discret::Elements::Beam3k::evaluate_stiff_matrix_analytic_from_point_neumann_mom
template void Discret::Elements::Beam3k::evaluate_line_neumann<2>(Core::LinAlg::SerialDenseVector&,
Core::LinAlg::SerialDenseMatrix*,
const Core::LinAlg::Matrix<6 * 2 + BEAM3K_COLLOCATION_POINTS, 1, double>&,
const Core::LinAlg::Matrix<6, 1, double>&, const std::vector<Core::IO::Noneable<int>>&,
const Core::LinAlg::Matrix<6, 1, double>&, const std::vector<std::optional<int>>&,
double) const;

template void Discret::Elements::Beam3k::evaluate_line_neumann_forces<2, double>(
Core::LinAlg::Matrix<6 * 2 + BEAM3K_COLLOCATION_POINTS, 1, double>&,
const Core::LinAlg::Matrix<6, 1, double>&, const std::vector<Core::IO::Noneable<int>>&,
const Core::LinAlg::Matrix<6, 1, double>&, const std::vector<std::optional<int>>&,
double) const;
template void Discret::Elements::Beam3k::evaluate_line_neumann_forces<2, FAD>(
Core::LinAlg::Matrix<6 * 2 + BEAM3K_COLLOCATION_POINTS, 1, FAD>&,
const Core::LinAlg::Matrix<6, 1, double>&, const std::vector<Core::IO::Noneable<int>>&,
const Core::LinAlg::Matrix<6, 1, double>&, const std::vector<std::optional<int>>&,
double) const;

template void Discret::Elements::Beam3k::evaluate_translational_damping<double, 2, 2, 3>(
Expand Down
2 changes: 1 addition & 1 deletion src/beam3/4C_beam3_reissner_evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ int Discret::Elements::Beam3r::evaluate_neumann(Teuchos::ParameterList& params,
const auto val = condition.parameters().get<std::vector<double>>("VAL");
// funct is related to the numdf "FUNCT" fields after the val field of the Neumann condition
// in the input file; funct gives the number of the function defined in the section FUNCT
const auto functions = condition.parameters().get<std::vector<Core::IO::Noneable<int>>>("FUNCT");
const auto functions = condition.parameters().get<std::vector<std::optional<int>>>("FUNCT");

// integration points in parameter space and weights
double xi = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ void BeamInteraction::BeamToBeamPotentialPair<numnodes, numnodalvalues, T>::

// evaluate function in time if specified in line charge conditions
// TODO allow for functions in space, i.e. varying charge along beam centerline
auto function_number = linechargeconds_[0]->parameters().get<Core::IO::Noneable<int>>("FUNCT");
auto function_number = linechargeconds_[0]->parameters().get<std::optional<int>>("FUNCT");

if (function_number.has_value() && function_number.value() > 0)
q1 *= Global::Problem::instance()
->function_by_id<Core::Utils::FunctionOfTime>(function_number.value())
.evaluate(time_);

function_number = linechargeconds_[1]->parameters().get<Core::IO::Noneable<int>>("FUNCT");
function_number = linechargeconds_[1]->parameters().get<std::optional<int>>("FUNCT");

if (function_number.has_value() && function_number.value() > 0)
q2 *= Global::Problem::instance()
Expand Down Expand Up @@ -619,14 +619,14 @@ void BeamInteraction::BeamToBeamPotentialPair<numnodes, numnodalvalues, T>::

// evaluate function in time if specified in line charge conditions
// TODO allow for functions in space, i.e. varying charge along beam centerline
auto function_number = linechargeconds_[0]->parameters().get<Core::IO::Noneable<int>>("FUNCT");
auto function_number = linechargeconds_[0]->parameters().get<std::optional<int>>("FUNCT");

if (function_number.has_value() && function_number.value() > 0)
q1 *= Global::Problem::instance()
->function_by_id<Core::Utils::FunctionOfTime>(function_number.value())
.evaluate(time_);

function_number = linechargeconds_[1]->parameters().get<Core::IO::Noneable<int>>("FUNCT");
function_number = linechargeconds_[1]->parameters().get<std::optional<int>>("FUNCT");

if (function_number.has_value() && function_number.value() > 0)
q2 *= Global::Problem::instance()
Expand Down Expand Up @@ -1204,14 +1204,14 @@ void BeamInteraction::BeamToBeamPotentialPair<numnodes, numnodalvalues, T>::

// evaluate function in time if specified in line charge conditions
// TODO allow for functions in space, i.e. varying charge along beam centerline
auto function_number = linechargeconds_[0]->parameters().get<Core::IO::Noneable<int>>("FUNCT");
auto function_number = linechargeconds_[0]->parameters().get<std::optional<int>>("FUNCT");

if (function_number.has_value() && function_number.value() > 0)
rho1 *= Global::Problem::instance()
->function_by_id<Core::Utils::FunctionOfTime>(function_number.value())
.evaluate(time_);

function_number = linechargeconds_[1]->parameters().get<Core::IO::Noneable<int>>("FUNCT");
function_number = linechargeconds_[1]->parameters().get<std::optional<int>>("FUNCT");

if (function_number.has_value() && function_number.value() > 0)
rho2 *= Global::Problem::instance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ void BeamInteraction::BeamToSpherePotentialPair<numnodes,

// evaluate function in time if specified in line charge conditions
// TODO allow for functions in space, i.e. varying charge along beam centerline
auto function_number = chargeconds_[0]->parameters().get<Core::IO::Noneable<int>>("FUNCT");
auto function_number = chargeconds_[0]->parameters().get<std::optional<int>>("FUNCT");

if (function_number.has_value() && function_number.value() > 0)
q1 *= Global::Problem::instance()
->function_by_id<Core::Utils::FunctionOfTime>(function_number.value())
.evaluate(time_);

function_number = chargeconds_[1]->parameters().get<Core::IO::Noneable<int>>("FUNCT");
function_number = chargeconds_[1]->parameters().get<std::optional<int>>("FUNCT");

if (function_number.has_value() and function_number.value() > 0)
q2 *= Global::Problem::instance()
Expand Down
12 changes: 6 additions & 6 deletions src/bele/4C_bele_bele3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,27 @@ void Discret::Elements::Bele3Type::setup_element_definition(

defs3["TRI3"] = all_of({
parameter<std::vector<int>>("TRI3", {.size = 3}),
parameter<Noneable<int>>("MAT"),
parameter<std::optional<int>>("MAT"),
});

defs3["TRI6"] = all_of({
parameter<std::vector<int>>("TRI6", {.size = 6}),
parameter<Noneable<int>>("MAT"),
parameter<std::optional<int>>("MAT"),
});

defs3["QUAD4"] = all_of({
parameter<std::vector<int>>("QUAD4", {.size = 4}),
parameter<Noneable<int>>("MAT"),
parameter<std::optional<int>>("MAT"),
});

defs3["QUAD8"] = all_of({
parameter<std::vector<int>>("QUAD8", {.size = 8}),
parameter<Noneable<int>>("MAT"),
parameter<std::optional<int>>("MAT"),
});

defs3["QUAD9"] = all_of({
parameter<std::vector<int>>("QUAD9", {.size = 9}),
parameter<Noneable<int>>("MAT"),
parameter<std::optional<int>>("MAT"),
});
}

Expand Down Expand Up @@ -265,7 +265,7 @@ bool Discret::Elements::Bele3::read_element(const std::string& eletype, const st
const Core::IO::InputParameterContainer& container)
{
// check if material is defined
auto material_id = container.get<Core::IO::Noneable<int>>("MAT");
auto material_id = container.get<std::optional<int>>("MAT");
if (material_id)
{
set_material(0, Mat::factory(*material_id));
Expand Down
2 changes: 1 addition & 1 deletion src/bele/4C_bele_bele3_line_evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int Discret::Elements::Bele3Line::evaluate_neumann(Teuchos::ParameterList& param
// (assumed to be constant on element boundary)
const auto& onoff = condition.parameters().get<std::vector<int>>("ONOFF");
const auto& val = condition.parameters().get<std::vector<double>>("VAL");
const auto& functions = condition.parameters().get<std::vector<Core::IO::Noneable<int>>>("FUNCT");
const auto& functions = condition.parameters().get<std::vector<std::optional<int>>>("FUNCT");

// set number of nodes
const size_t iel = this->num_node();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void Utils::Cardiovascular0DArterialProxDist::evaluate(Teuchos::ParameterList& p

// find out whether we will use a time curve and get the factor
const auto curvenum =
cardiovascular0dcond_[condID]->parameters().get<Core::IO::Noneable<int>>("p_at_crv");
cardiovascular0dcond_[condID]->parameters().get<std::optional<int>>("p_at_crv");
double curvefac_np = 1.0;

if (curvenum.has_value() && curvenum.value() > 0 && time >= 0)
Expand Down
2 changes: 1 addition & 1 deletion src/constraint/4C_constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void CONSTRAINTS::Constraint::evaluate_constraint(Teuchos::ParameterList& params
}

// Evaluate loadcurve if defined. Put current load factor in parameterlist
const auto curvenum = cond->parameters().get<Core::IO::Noneable<int>>("curve");
const auto curvenum = cond->parameters().get<std::optional<int>>("curve");
double curvefac = 1.0;
if (curvenum.has_value() && curvenum.value() > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/constraint/4C_constraint_multipointconstraint2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void CONSTRAINTS::MPConstraint2::evaluate_constraint(std::shared_ptr<Core::FE::D
}

// Load curve business
const auto curvenum = cond.parameters().get<Core::IO::Noneable<int>>("curve");
const auto curvenum = cond.parameters().get<std::optional<int>>("curve");
double curvefac = 1.0;
if (curvenum.has_value() && curvenum.value() > 0 && time >= 0.0)
{
Expand Down
4 changes: 2 additions & 2 deletions src/constraint/4C_constraint_multipointconstraint3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void CONSTRAINTS::MPConstraint3::evaluate_constraint(std::shared_ptr<Core::FE::D
}

// loadcurve business
const auto curvenum = cond->parameters().get<Core::IO::Noneable<int>>("curve");
const auto curvenum = cond->parameters().get<std::optional<int>>("curve");
double curvefac = 1.0;
if (curvenum.has_value() && curvenum.value() > 0 && time >= 0.0)
{
Expand Down Expand Up @@ -533,7 +533,7 @@ void CONSTRAINTS::MPConstraint3::initialize_constraint(Core::FE::Discretization&
Core::LinAlg::assemble(systemvector, elevector3, constrlm, constrowner);

// loadcurve business
const auto curvenum = cond->parameters().get<Core::IO::Noneable<int>>("curve");
const auto curvenum = cond->parameters().get<std::optional<int>>("curve");
double curvefac = 1.0;
if (curvenum.has_value() && curvenum.value() > 0 && time >= 0.0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void CONSTRAINTS::MPConstraint3Penalty::evaluate_constraint(
Core::Communication::my_mpi_rank(disc->get_comm()), eid, err);

// loadcurve business
const auto curvenum = cond->parameters().get<Core::IO::Noneable<int>>("curve");
const auto curvenum = cond->parameters().get<std::optional<int>>("curve");
double curvefac = 1.0;
if (curvenum.has_value() && curvenum.value() > 0 && time >= 0.0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/constraint/4C_constraint_penalty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void CONSTRAINTS::ConstraintPenalty::evaluate_constraint(Teuchos::ParameterList&
}

// Evaluate loadcurve if defined. Put current load factor in parameterlist
const auto curvenum = cond->parameters().get<Core::IO::Noneable<int>>("curve");
const auto curvenum = cond->parameters().get<std::optional<int>>("curve");
double curvefac = 1.0;
if (curvenum.has_value() && curvenum.value() > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/constraint/4C_constraint_springdashpot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ CONSTRAINTS::SpringDashpot::SpringDashpot(std::shared_ptr<Core::FE::Discretizati
stiff_comp_((spring_->parameters().get<std::vector<double>>("STIFF"))[0]),
offset_((spring_->parameters().get<std::vector<double>>("DISPLOFFSET"))[0]),
viscosity_((spring_->parameters().get<std::vector<double>>("VISCO"))[0]),
coupling_(spring_->parameters().get<Core::IO::Noneable<int>>("COUPLING").value_or(-1)),
coupling_(spring_->parameters().get<std::optional<int>>("COUPLING").value_or(-1)),
nodes_(spring_->get_nodes()),
area_(),
gap0_(),
Expand Down
2 changes: 1 addition & 1 deletion src/contact/4C_contact_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ CONTACT::Manager::Manager(Core::FE::Discretization& discret, double alphaf)

// In case of MultiScale contact this is the id of the interface's constitutive contact law
auto maybe_contactconstitutivelawid =
currentgroup[0]->parameters().get<Core::IO::Noneable<int>>("ConstitutiveLawID");
currentgroup[0]->parameters().get<std::optional<int>>("ConstitutiveLawID");
auto contactconstitutivelawid = maybe_contactconstitutivelawid.value_or(-1);

bool foundit = false;
Expand Down
2 changes: 1 addition & 1 deletion src/contact/4C_contact_strategy_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ void CONTACT::STRATEGY::Factory::build_interfaces(const Teuchos::ParameterList&

// In case of MultiScale contact this is the id of the interface's constitutive contact law
auto contactconstitutivelaw_id =
currentgroup[0]->parameters().get<Core::IO::Noneable<int>>("ConstitutiveLawID");
currentgroup[0]->parameters().get<std::optional<int>>("ConstitutiveLawID");

// Initialize a flag to check for MIRCO contact consitutive law
bool mircolaw = false;
Expand Down
3 changes: 1 addition & 2 deletions src/core/fem/src/condition/4C_fem_condition_locsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ void Core::Conditions::LocsysManager::update(const double time,
typelocsys_[i] = currlocsys->type();

const auto rotangle = currlocsys->parameters().get<std::vector<double>>("ROTANGLE");
const auto funct =
currlocsys->parameters().get<std::vector<Core::IO::Noneable<int>>>("FUNCT");
const auto funct = currlocsys->parameters().get<std::vector<std::optional<int>>>("FUNCT");
const auto useUpdatedNodePos = currlocsys->parameters().get<int>("USEUPDATEDNODEPOS");
const std::vector<int>* nodes = currlocsys->get_nodes();
const auto useConsistentNodeNormal =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void Core::FE::Discretization::evaluate_neumann(Teuchos::ParameterList& params,
}
const std::vector<int>* nodeids = cond->get_nodes();
if (!nodeids) FOUR_C_THROW("PointNeumann condition does not have nodal cloud");
const auto& tmp_funct = cond->parameters().get<std::vector<Core::IO::Noneable<int>>>("FUNCT");
const auto& tmp_funct = cond->parameters().get<std::vector<std::optional<int>>>("FUNCT");
const auto& onoff = cond->parameters().get<std::vector<int>>("ONOFF");
const auto& val = cond->parameters().get<std::vector<double>>("VAL");

Expand Down Expand Up @@ -406,7 +406,7 @@ void Core::FE::Discretization::evaluate_condition(Teuchos::ParameterList& params
// to the condition geometry

// Evaluate Loadcurve if defined. Put current load factor in parameter list
const auto* curve = cond->parameters().get_if<Core::IO::Noneable<int>>("curve");
const auto* curve = cond->parameters().get_if<std::optional<int>>("curve");

double curvefac = 1.0;
if (curve)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void Core::FE::Utils::DbcHDG::do_dirichlet_condition(const Teuchos::ParameterLis
if (!nodeids) FOUR_C_THROW("Dirichlet condition does not have nodal cloud");

// get curves, functs, vals, and onoff toggles from the condition
const auto funct = cond.parameters().get<std::vector<Core::IO::Noneable<int>>>("FUNCT");
const auto funct = cond.parameters().get<std::vector<std::optional<int>>>("FUNCT");
const auto val = cond.parameters().get<std::vector<double>>("VAL");
const auto onoff = cond.parameters().get<std::vector<int>>("ONOFF");

Expand Down
Loading

0 comments on commit 572fd00

Please sign in to comment.