Skip to content

Commit bc0fd8f

Browse files
committed
First step of removing optional from solidscatra
1 parent d169dab commit bc0fd8f

File tree

6 files changed

+27
-65
lines changed

6 files changed

+27
-65
lines changed

src/contact/4C_contact_nitsche_integrator_ssi.cpp

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -206,46 +206,20 @@ void CONTACT::IntegratorNitscheSsi::so_ele_cauchy_struct(Mortar::Element& mortar
206206
linearizations.solid.d_cauchyndir_ddir = &d_sigma_nt_dt;
207207
linearizations.solid.d_cauchyndir_dxi = &d_sigma_nt_dxi;
208208

209-
if (mortar_ele.mo_data().parent_scalar().empty())
210-
{
211-
// Note: This branch is only needed since the structure is evaluating itself during setup before
212-
// the ssi problem is setup. Once this is fixed, this can be deleted.
213-
sigma_nt = std::invoke(
214-
[&]()
215-
{
216-
auto* solid_scatra_ele =
217-
dynamic_cast<Discret::Elements::SolidScatra*>(mortar_ele.parent_element());
218-
219-
FOUR_C_ASSERT_ALWAYS(solid_scatra_ele,
220-
"Nitsche contact is not implemented for this element (expecting SOLIDSCATRA "
221-
"element)!");
222-
223-
// SSI is not yet setup, so don't set the scalar.
224-
// Note: Once it is fixed in the structure time integration framework, the
225-
// scalars-parameter can be made non-optional
226-
return solid_scatra_ele->get_normal_cauchy_stress_at_xi(
227-
mortar_ele.mo_data().parent_disp(), std::nullopt, parent_xi, gp_normal, test_dir,
228-
linearizations);
229-
});
230-
}
231-
else
232-
{
233-
linearizations.d_cauchyndir_ds = d_sigma_nt_ds;
234-
sigma_nt = std::invoke(
235-
[&]()
236-
{
237-
auto* solid_scatra_ele =
238-
dynamic_cast<Discret::Elements::SolidScatra*>(mortar_ele.parent_element());
239-
240-
FOUR_C_ASSERT_ALWAYS(solid_scatra_ele,
241-
"Nitsche contact is not implemented for this element (expecting SOLIDSCATRA "
242-
"element)!");
243-
244-
return solid_scatra_ele->get_normal_cauchy_stress_at_xi(
245-
mortar_ele.mo_data().parent_disp(), mortar_ele.mo_data().parent_scalar(), parent_xi,
246-
gp_normal, test_dir, linearizations);
247-
});
248-
}
209+
linearizations.d_cauchyndir_ds = d_sigma_nt_ds;
210+
sigma_nt = std::invoke(
211+
[&]()
212+
{
213+
auto* solid_scatra_ele =
214+
dynamic_cast<Discret::Elements::SolidScatra*>(mortar_ele.parent_element());
215+
216+
FOUR_C_ASSERT_ALWAYS(solid_scatra_ele,
217+
"Nitsche contact is not implemented for this element (expecting SOLIDSCATRA "
218+
"element)!");
219+
220+
return solid_scatra_ele->get_normal_cauchy_stress_at_xi(mortar_ele.mo_data().parent_disp(),
221+
mortar_ele.mo_data().parent_scalar(), parent_xi, gp_normal, test_dir, linearizations);
222+
});
249223

250224
cauchy_nt_wgt += nitsche_wgt * sigma_nt;
251225

src/solid_scatra_3D_ele/4C_solid_scatra_3D_ele.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,9 @@ namespace Discret::Elements
162162
* @param linearizations [in/out] : Struct holding the linearizations that are possible for
163163
* evaluation
164164
* @return double
165-
*
166-
* @note @p scalars is an optional since it might not be set in the very initial call of the
167-
* structure. Once the structure does not evaluate itself after setup, this optional parameter
168-
* can be made mandatory.
169165
*/
170166
double get_normal_cauchy_stress_at_xi(const std::vector<double>& disp,
171-
const std::optional<std::vector<double>>& scalars, const Core::LinAlg::Matrix<3, 1>& xi,
167+
const std::vector<double>& scalars, const Core::LinAlg::Matrix<3, 1>& xi,
172168
const Core::LinAlg::Matrix<3, 1>& n, const Core::LinAlg::Matrix<3, 1>& dir,
173169
SolidScatraCauchyNDirLinearizations<3>& linearizations);
174170

src/solid_scatra_3D_ele/4C_solid_scatra_3D_ele_calc.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ namespace
204204
Discret::Elements::ShapeFunctionsAndDerivatives<celltype> shape_functions,
205205
const Core::LinAlg::Matrix<Core::FE::dim<celltype>, Core::FE::dim<celltype>>&
206206
deformation_gradient,
207-
const std::optional<std::vector<double>>& scalars_at_xi, const Core::LinAlg::Matrix<3, 1>& n,
207+
const std::vector<double>& scalars_at_xi, const Core::LinAlg::Matrix<3, 1>& n,
208208
const Core::LinAlg::Matrix<3, 1>& dir, int eleGID,
209209
const Discret::Elements::ElementFormulationDerivativeEvaluator<celltype, SolidFormulation>&
210210
evaluator,
@@ -220,8 +220,8 @@ namespace
220220
get_ptr(linearization_dependencies.d_cauchyndir_dF),
221221
get_ptr(linearization_dependencies.d2_cauchyndir_dF2),
222222
get_ptr(linearization_dependencies.d2_cauchyndir_dF_dn),
223-
get_ptr(linearization_dependencies.d2_cauchyndir_dF_ddir), -1, eleGID,
224-
get_data(scalars_at_xi), nullptr, nullptr, nullptr);
223+
get_ptr(linearization_dependencies.d2_cauchyndir_dF_ddir), -1, eleGID, scalars_at_xi.data(),
224+
nullptr, nullptr, nullptr);
225225

226226
// Evaluate pure solid linearizations
227227
Discret::Elements::evaluate_cauchy_n_dir_linearizations<celltype>(
@@ -231,12 +231,10 @@ namespace
231231
if (linearizations.d_cauchyndir_ds)
232232
{
233233
FOUR_C_ASSERT(linearization_dependencies.d_cauchyndir_dF, "Not all tensors are computed!");
234-
FOUR_C_ASSERT(
235-
scalars_at_xi.has_value(), "Scalar needs to have a value if the derivatives are needed!");
236234
linearizations.d_cauchyndir_ds->shape(Core::FE::num_nodes<celltype>, 1);
237235

238236
static Core::LinAlg::Matrix<9, 1> d_F_dc(Core::LinAlg::Initialization::zero);
239-
mat.evaluate_linearization_od(deformation_gradient, (*scalars_at_xi)[0], &d_F_dc);
237+
mat.evaluate_linearization_od(deformation_gradient, (scalars_at_xi)[0], &d_F_dc);
240238

241239
double d_cauchyndir_ds_gp = (*linearization_dependencies.d_cauchyndir_dF).dot(d_F_dc);
242240

@@ -688,7 +686,7 @@ template <Core::FE::CellType celltype, typename SolidFormulation>
688686
double
689687
Discret::Elements::SolidScatraEleCalc<celltype, SolidFormulation>::get_normal_cauchy_stress_at_xi(
690688
const Core::Elements::Element& ele, Mat::So3Material& solid_material,
691-
const std::vector<double>& disp, const std::optional<std::vector<double>>& scalars,
689+
const std::vector<double>& disp, const std::vector<double>& scalars,
692690
const Core::LinAlg::Matrix<3, 1>& xi, const Core::LinAlg::Matrix<3, 1>& n,
693691
const Core::LinAlg::Matrix<3, 1>& dir, SolidScatraCauchyNDirLinearizations<3>& linearizations)
694692
{
@@ -702,13 +700,8 @@ Discret::Elements::SolidScatraEleCalc<celltype, SolidFormulation>::get_normal_ca
702700
else
703701
{
704702
// project scalar values to xi
705-
const auto scalar_values_at_xi = std::invoke(
706-
[&]() -> std::optional<std::vector<double>>
707-
{
708-
if (!scalars.has_value()) return std::nullopt;
703+
const auto scalar_values_at_xi = Core::FE::interpolate_to_xi<celltype>(xi, scalars);
709704

710-
return Core::FE::interpolate_to_xi<celltype>(xi, *scalars);
711-
});
712705

713706
ElementNodes<celltype> element_nodes = evaluate_element_nodes<celltype>(ele, disp);
714707

src/solid_scatra_3D_ele/4C_solid_scatra_3D_ele_calc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace Discret::Elements
8888

8989
double get_normal_cauchy_stress_at_xi(const Core::Elements::Element& ele,
9090
Mat::So3Material& solid_material, const std::vector<double>& disp,
91-
const std::optional<std::vector<double>>& scalars, const Core::LinAlg::Matrix<3, 1>& xi,
91+
const std::vector<double>& scalars, const Core::LinAlg::Matrix<3, 1>& xi,
9292
const Core::LinAlg::Matrix<3, 1>& n, const Core::LinAlg::Matrix<3, 1>& dir,
9393
SolidScatraCauchyNDirLinearizations<3>& linearizations);
9494

src/solid_scatra_3D_ele/4C_solid_scatra_3D_ele_calc_lib_nitsche.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ namespace Discret::Elements
5858
constexpr bool can_evaluate_solid_scatra_cauchy_n_dir_at_xi<T, dim,
5959
std::void_t<decltype(std::declval<T>()->get_normal_cauchy_stress_at_xi(
6060
std::declval<const Core::Elements::Element&>(), std::declval<Mat::So3Material&>(),
61-
std::declval<const std::vector<double>&>(),
62-
std::declval<const std::optional<std::vector<double>>&>(),
61+
std::declval<const std::vector<double>&>(), std::declval<const std::vector<double>&>(),
6362
std::declval<const Core::LinAlg::Matrix<dim, 1>&>(),
6463
std::declval<const Core::LinAlg::Matrix<dim, 1>&>(),
6564
std::declval<const Core::LinAlg::Matrix<dim, 1>&>(),
@@ -72,7 +71,7 @@ namespace Discret::Elements
7271
struct EvaluateSolidScatraCauchyNDirAction
7372
{
7473
EvaluateSolidScatraCauchyNDirAction(const Core::Elements::Element& e, Mat::So3Material& m,
75-
const std::vector<double>& d, const std::optional<std::vector<double>>& s,
74+
const std::vector<double>& d, const std::vector<double>& s,
7675
const Core::LinAlg::Matrix<dim, 1>& x, const Core::LinAlg::Matrix<dim, 1>& normal,
7776
const Core::LinAlg::Matrix<dim, 1>& direction,
7877
SolidScatraCauchyNDirLinearizations<dim>& lins)
@@ -109,7 +108,7 @@ namespace Discret::Elements
109108
const Core::Elements::Element& element;
110109
Mat::So3Material& mat;
111110
const std::vector<double>& disp;
112-
const std::optional<std::vector<double>>& scalars;
111+
const std::vector<double>& scalars;
113112
const Core::LinAlg::Matrix<dim, 1>& xi;
114113
const Core::LinAlg::Matrix<dim, 1>& n;
115114
const Core::LinAlg::Matrix<dim, 1>& dir;
@@ -120,7 +119,7 @@ namespace Discret::Elements
120119
template <typename VariantType>
121120
double get_normal_cauchy_stress_at_xi(VariantType& variant,
122121
const Core::Elements::Element& element, Mat::So3Material& mat,
123-
const std::vector<double>& disp, const std::optional<std::vector<double>>& scalars,
122+
const std::vector<double>& disp, const std::vector<double>& scalars,
124123
const Core::LinAlg::Matrix<3, 1>& xi, const Core::LinAlg::Matrix<3, 1>& n,
125124
const Core::LinAlg::Matrix<3, 1>& dir, SolidScatraCauchyNDirLinearizations<3>& linearizations)
126125
{

src/solid_scatra_3D_ele/4C_solid_scatra_3D_ele_evaluate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ int Discret::Elements::SolidScatra::evaluate_neumann(Teuchos::ParameterList& par
157157
}
158158

159159
double Discret::Elements::SolidScatra::get_normal_cauchy_stress_at_xi(
160-
const std::vector<double>& disp, const std::optional<std::vector<double>>& scalars,
160+
const std::vector<double>& disp, const std::vector<double>& scalars,
161161
const Core::LinAlg::Matrix<3, 1>& xi, const Core::LinAlg::Matrix<3, 1>& n,
162162
const Core::LinAlg::Matrix<3, 1>& dir,
163163
Discret::Elements::SolidScatraCauchyNDirLinearizations<3>& linearizations)

0 commit comments

Comments
 (0)