Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraengelhardt committed Feb 28, 2025
1 parent 82d8bfd commit fa65738
Show file tree
Hide file tree
Showing 35 changed files with 143 additions and 140 deletions.
11 changes: 6 additions & 5 deletions src/fluid_ele/4C_fluid_ele_boundary_parent_calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,7 @@ void Discret::Elements::FluidBoundaryParent<distype>::evaluate_weak_dbc(

// get values and switches from condition
// (assumed to be constant on element boundary)
const auto functions = wdbc_cond->parameters().get<std::vector<int>>("FUNCT");
const auto functions = wdbc_cond->parameters().get<std::vector<std::optional<int>>>("FUNCT");

// find out whether to apply weak DBC only in normal direction
bool onlynormal = false;
Expand Down Expand Up @@ -2185,13 +2185,14 @@ void Discret::Elements::FluidBoundaryParent<distype>::evaluate_weak_dbc(
for (int idim = 0; idim < nsd; idim++)
{
// factor given by spatial function
if (functions[idim] > 0)
if (functions[idim].has_value())
{
// evaluate function at current gauss point
// (important: requires 3D position vector)
functionfac(idim) = Global::Problem::instance()
->function_by_id<Core::Utils::FunctionOfSpaceTime>(functions[idim])
.evaluate(coordgp.data(), time, idim);
functionfac(idim) =
Global::Problem::instance()
->function_by_id<Core::Utils::FunctionOfSpaceTime>(functions[idim].value())
.evaluate(coordgp.data(), time, idim);
}
else
functionfac(idim) = 1.0;
Expand Down
5 changes: 3 additions & 2 deletions src/inpar/4C_inpar_validconditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "4C_inpar_structure.hpp"
#include "4C_inpar_xfem.hpp"
#include "4C_io_input_spec_builders.hpp"
#include "4C_io_input_types.hpp"
#include "4C_thermo_input.hpp"

FOUR_C_NAMESPACE_OPEN
Expand Down Expand Up @@ -579,8 +580,8 @@ std::vector<Core::Conditions::ConditionDefinition> Input::valid_conditions()
cond.add_component(parameter<std::vector<double>>("VAL", {.description = "values", .size = 3}));

// and optional spatial functions
cond.add_component(parameter<std::vector<int>>("FUNCT",
{.description = "function ids", .default_value = std::vector<int>{0, 0, 0}, .size = 3}));
cond.add_component(parameter<std::vector<std::optional<int>>>(
"FUNCT", {.description = "function ids", .size = 3}));
// append the condition to the list of all conditions
condlist.push_back(cond);
};
Expand Down
9 changes: 5 additions & 4 deletions src/inpar/4C_inpar_xfem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "4C_cut_enum.hpp"
#include "4C_fem_condition_definition.hpp"
#include "4C_io_input_spec_builders.hpp"
#include "4C_io_input_types.hpp"
#include "4C_utils_parameter_list.hpp"

FOUR_C_NAMESPACE_OPEN
Expand Down Expand Up @@ -520,8 +521,8 @@ void Inpar::XFEM::set_valid_conditions(std::vector<Core::Conditions::ConditionDe
xfem_levelset_navier_slip.add_component(
parameter<std::optional<int>>("ROBIN_NEUMANN_ID", {.description = ""}));
xfem_levelset_navier_slip.add_component(parameter<double>("SLIPCOEFFICIENT"));
xfem_levelset_navier_slip.add_component(
parameter<int>("FUNCT", {.description = "slip function id", .default_value = 0}));
xfem_levelset_navier_slip.add_component(parameter<std::optional<int>>(
"FUNCT", {.description = "slip function id", .default_value = 0}));
xfem_levelset_navier_slip.add_component(
parameter<bool>("FORCE_ONLY_TANG_VEL", {.description = "", .default_value = false}));

Expand Down Expand Up @@ -705,8 +706,8 @@ void Inpar::XFEM::set_valid_conditions(std::vector<Core::Conditions::ConditionDe
xfem_surf_navier_slip.add_component(
parameter<std::optional<int>>("ROBIN_NEUMANN_ID", {.description = ""}));
xfem_surf_navier_slip.add_component(parameter<double>("SLIPCOEFFICIENT"));
xfem_surf_navier_slip.add_component(
parameter<int>("FUNCT", {.description = "slip function id", .default_value = 0}));
xfem_surf_navier_slip.add_component(parameter<std::optional<int>>(
"FUNCT", {.description = "slip function id", .default_value = 0}));
xfem_surf_navier_slip.add_component(
parameter<bool>("FORCE_ONLY_TANG_VEL", {.description = "", .default_value = false}));

Expand Down
4 changes: 3 additions & 1 deletion src/scatra/4C_scatra_timint_elch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <Teuchos_TimeMonitor.hpp>

#include <iterator>
#include <unordered_set>

FOUR_C_NAMESPACE_OPEN
Expand Down Expand Up @@ -2976,7 +2977,8 @@ void ScaTra::ScaTraTimIntElch::apply_neumann_bc(
// condition.
const std::vector<int> onoff = {0, 1};
const std::vector<double> val = {0.0, condition->parameters().get<double>("CURRENT")};
const std::vector<std::optional<int>> funct = {0, 0};
const std::vector<std::optional<int>> funct = {std::nullopt, std::nullopt};

condition->parameters().add("NUMDOF", 2);
condition->parameters().add("FUNCT", funct);
condition->parameters().add("ONOFF", onoff);
Expand Down
7 changes: 2 additions & 5 deletions src/xfem/4C_xfem_coupling_levelset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "4C_io_control.hpp"
#include "4C_io_gmsh.hpp"
#include "4C_io_input_parameter_container.hpp"
#include "4C_io_input_types.hpp"
#include "4C_io_pstream.hpp"
#include "4C_linalg_utils_sparse_algebra_create.hpp"
#include "4C_linalg_utils_sparse_algebra_manipulation.hpp"
Expand Down Expand Up @@ -1398,12 +1399,8 @@ void XFEM::LevelSetCouplingNavierSlip::set_condition_specific_parameters()
// Get the scaling factor for the slip length
sliplength_ = cond->parameters().get<double>("SLIPCOEFFICIENT");

// Temporary variable for readability.
bool tmp_bool;

// Is the slip length constant? Don't call functions at GP-level unnecessary.
tmp_bool = (cond->parameters().get<int>("FUNCT") < 1);
is_constant_sliplength_ = (tmp_bool) ? true : false;
is_constant_sliplength_ = !cond->parameters().get<std::optional<int>>("FUNCT").has_value();

// Project the prescribed velocity in tangential direction, to remove "spurious velocities"
// from the geometry approximation.
Expand Down
4 changes: 2 additions & 2 deletions src/xfem/4C_xfem_coupling_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ void XFEM::MeshCouplingNavierSlip::set_condition_specific_parameters()
double sliplength = cond->parameters().get<double>("SLIPCOEFFICIENT");

// Is the slip length constant? Don't call functions at GP-level unnecessary.
bool slip_bool = (cond->parameters().get<int>("FUNCT") < 1);
bool slip_bool = (!cond->parameters().get<std::optional<int>>("FUNCT").has_value());

bool force_tangential = cond->parameters().get<bool>("FORCE_ONLY_TANG_VEL");

Expand Down Expand Up @@ -1816,7 +1816,7 @@ void XFEM::MeshCouplingFSI::set_condition_specific_parameters()
double sliplength = cond->parameters().get<double>("SLIPCOEFFICIENT");

// Is the slip length constant? Don't call functions at GP-level unnecessary.
bool slip_bool = (cond->parameters().get<int>("SLIP_FUNCT") < 1);
bool slip_bool = (!cond->parameters().get<std::optional<int>>("FUNCT").has_value());

if (!sliplength_map_.insert(std::make_pair(cond_int, std::make_pair(sliplength, slip_bool)))
.second)
Expand Down
16 changes: 8 additions & 8 deletions tests/framework-test/tutorial_battery.bc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Property Name: INFLOW
has 45107 Nodes
'*ns0="CONDITION"'
sectionname="DESIGN SURF DIRICH CONDITIONS"
description="NUMDOF 6 ONOFF 1 1 1 0 0 0 VAL 2.0 0.0 0.0 0.0 0.0 0.0 FUNCT 1 0 0 0 0 0"
description="NUMDOF 6 ONOFF 1 1 1 0 0 0 VAL 2.0 0.0 0.0 0.0 0.0 0.0 FUNCT 1 none none none none none"

MIND that you can specify a condition also on an ElementBlock, just replace 'ELEMENT' with 'CONDITION'
The 'E num' in the dat-file depends on the order of the specification below
Expand Down Expand Up @@ -55,7 +55,7 @@ sectionname="DESIGN VOL INITIAL FIELD CONDITIONS"
description="FIELD ScaTra FUNCT 2"
*eb2="CONDITION"
sectionname="DESIGN VOL TRANSPORT DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 1 0 VAL 1.2e3 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 1 0 VAL 1.2e3 0.0 FUNCT none none"

Element Block, named: cathode
of Shape: TET4
Expand Down Expand Up @@ -83,7 +83,7 @@ sectionname="DESIGN VOL INITIAL FIELD CONDITIONS"
description="FIELD ScaTra FUNCT 4"
*eb4="CONDITION"
sectionname="DESIGN VOL TRANSPORT DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 1 0 VAL 1.2e3 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 1 0 VAL 1.2e3 0.0 FUNCT none none"

Element Block, named: cathode_cc
of Shape: TET4
Expand All @@ -97,7 +97,7 @@ sectionname="DESIGN VOL INITIAL FIELD CONDITIONS"
description="FIELD ScaTra FUNCT 5"
*eb5="CONDITION"
sectionname="DESIGN VOL TRANSPORT DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 1 0 VAL 1.2e3 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 1 0 VAL 1.2e3 0.0 FUNCT none none"

Node Set, named: an-side_cc
Property Name: none
Expand All @@ -107,7 +107,7 @@ sectionname="DESIGN SURF DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 0 0 VAL 0.0 0.0 0.0 FUNCT none none none"
*ns1="CONDITION"
sectionname="DESIGN SURF TRANSPORT DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 0 1 VAL 0.0 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 0 1 VAL 0.0 0.0 FUNCT none none"
*ns1="CONDITION"
sectionname="DESIGN CELL VOLTAGE SURF CONDITIONS"
description="ConditionID 0"
Expand Down Expand Up @@ -220,7 +220,7 @@ sectionname="DESIGN SURF DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 0 0 VAL 0.0 0.0 0.0 FUNCT none none none"
*ns12="CONDITION"
sectionname="DESIGN SURF TRANSPORT NEUMANN CONDITIONS"
description="NUMDOF 2 ONOFF 0 1 VAL 0.0 5.839316572e-6 FUNCT 0 0"
description="NUMDOF 2 ONOFF 0 1 VAL 0.0 5.839316572e-6 FUNCT none none"
*ns12="CONDITION"
sectionname="DESIGN CELL VOLTAGE SURF CONDITIONS"
description="ConditionID 1"
Expand All @@ -244,7 +244,7 @@ Property Name: none
has 248 Nodes
*ns15="CONDITION"
sectionname="DESIGN SURF LOCSYS CONDITIONS"
description="ROTANGLE 0.7853981634 0.0 0.0 FUNCT 0 0 0 USEUPDATEDNODEPOS 0 USECONSISTENTNODENORMAL 0"
description="ROTANGLE 0.7853981634 0.0 0.0 FUNCT none none none USEUPDATEDNODEPOS 0 USECONSISTENTNODENORMAL 0"
*ns15="CONDITION"
sectionname="DESIGN SURF DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 0 1 0 VAL 0.0 0.0 0.0 FUNCT none none none"
Expand All @@ -268,7 +268,7 @@ Property Name: none
has 19 Nodes
*ns18="CONDITION"
sectionname="DESIGN LINE LOCSYS CONDITIONS"
description="ROTANGLE 0.7853981634 0.0 0.0 FUNCT 0 0 0 USEUPDATEDNODEPOS 0 USECONSISTENTNODENORMAL 0"
description="ROTANGLE 0.7853981634 0.0 0.0 FUNCT none none none USEUPDATEDNODEPOS 0 USECONSISTENTNODENORMAL 0"
*ns18="CONDITION"
sectionname="DESIGN LINE DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT none none none"
Expand Down
4 changes: 2 additions & 2 deletions tests/framework-test/tutorial_contact_3d.bc
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ Property Name: none
has 36 Nodes
*ns4="CONDITION"
sectionname="DESIGN SURF DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 0 0 VAL -1.0 0.0 0.0 FUNCT 1 0 0"
description="NUMDOF 3 ONOFF 1 0 0 VAL -1.0 0.0 0.0 FUNCT 1 none none"

Node Set, named: wall
Property Name: none
has 121 Nodes
*ns3="CONDITION"
sectionname="DESIGN SURF DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 1 VAL 0.0 0.0 0.0 FUNCT 0 0 0"
description="NUMDOF 3 ONOFF 1 1 1 VAL 0.0 0.0 0.0 FUNCT none none none"
-----------------------------------------VALIDCONDITIONS
10 changes: 5 additions & 5 deletions tests/framework-test/tutorial_fluid.bc
Original file line number Diff line number Diff line change
Expand Up @@ -45,35 +45,35 @@ Property Name: none
has 23 Nodes
*ns1="CONDITION"
sectionname="DESIGN LINE DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT 1 0 0"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT 1 none none"

Node Set, named: top
Property Name: none
has 68 Nodes
*ns2="CONDITION"
sectionname="DESIGN LINE DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 0 1 0 VAL 0.0 0.0 0.0 FUNCT 0 0 0"
description="NUMDOF 3 ONOFF 0 1 0 VAL 0.0 0.0 0.0 FUNCT none none none"

Node Set, named: bottom
Property Name: none
has 68 Nodes
*ns3="CONDITION"
sectionname="DESIGN LINE DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 0 1 0 VAL 0.0 0.0 0.0 FUNCT 0 0 0"
description="NUMDOF 3 ONOFF 0 1 0 VAL 0.0 0.0 0.0 FUNCT none none none"

Node Set, named: cylinder
Property Name: none
has 116 Nodes
*ns4="CONDITION"
sectionname="DESIGN LINE DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT 0 0 0"
description="NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT none none none"

Node Set, named: edges
Property Name: none
has 2 Nodes
*ns5="CONDITION"
sectionname="DESIGN POINT DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT 0 0 0"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT none none none"

-----------------------------------------VALIDCONDITIONS

Expand Down
24 changes: 12 additions & 12 deletions tests/framework-test/tutorial_fsi.bc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Property Name: none
has 4 Nodes
*ns1="CONDITION"
sectionname="DESIGN LINE DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT none none"

Node Set, named: structure_fsi_curve
Property Name: none
Expand All @@ -35,42 +35,42 @@ Property Name: none
has 4 Nodes
*ns3="CONDITION"
sectionname="DESIGN POINT DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT none none"

Node Set, named: structure_fsi_vertices
Property Name: none
has 2 Nodes
*ns4="CONDITION"
sectionname="DESIGN POINT DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT none none"

Node Set, named: cavity_wall_curves
Property Name: none
has 66 Nodes
*ns5="CONDITION"
sectionname="DESIGN LINE DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT 0 0 0"
description="NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT none none none"

Node Set, named: inflow_volume_curve_top
Property Name: none
has 33 Nodes
*ns6="CONDITION"
sectionname="DESIGN LINE DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT 1 0 0"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT 1 none none"

Node Set, named: inflow_area_curve
Property Name: none
has 5 Nodes
*ns7="CONDITION"
sectionname="DESIGN LINE DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT 2 0 0"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT 2 none none"

Node Set, named: fluid_curves_in_y-direction
Property Name: none
has 76 Nodes
*ns8="CONDITION"
sectionname="DESIGN LINE ALE DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT none none"

Node Set, named: fluid_fsi_curve
Property Name: none
Expand All @@ -84,34 +84,34 @@ Property Name: none
has 2 Nodes
*ns10="CONDITION"
sectionname="DESIGN POINT DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT 1 0 0"
description="NUMDOF 3 ONOFF 1 1 0 VAL 1.0 0.0 0.0 FUNCT 1 none none"

Node Set, named: cavity_vertices
Property Name: none
has 4 Nodes
*ns11="CONDITION"
sectionname="DESIGN POINT DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT 0 0 0"
description="NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT none none none"

Node Set, named: fluid_fsi_vertices
Property Name: none
has 2 Nodes
*ns12="CONDITION"
sectionname="DESIGN POINT DIRICH CONDITIONS"
description="NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT 0 0 0"
description="NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT none none none"

Node Set, named: fluid_vertices_all
Property Name: none
has 8 Nodes
*ns13="CONDITION"
sectionname="DESIGN POINT ALE DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT none none"

Node Set, named: inflow_volume_curve_top
Property Name: none
has 33 Nodes
*ns6="CONDITION"
sectionname="DESIGN LINE ALE DIRICH CONDITIONS"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT 0 0"
description="NUMDOF 2 ONOFF 1 1 VAL 0.0 0.0 FUNCT none none"

-----------------------------------------VALIDCONDITIONS
Loading

0 comments on commit fa65738

Please sign in to comment.