From 3d3c0b35711f91372104353b5a1cdbff19c3756a Mon Sep 17 00:00:00 2001 From: Dharini Balachandran Date: Sat, 11 Jul 2026 18:31:04 +0000 Subject: [PATCH] Modify dual shape functions --- ..._to_solid_volume_meshtying_pair_mortar.cpp | 174 +++++- ..._to_solid_volume_meshtying_mortar_test.cpp | 581 +++++++++++++----- 2 files changed, 598 insertions(+), 157 deletions(-) diff --git a/src/beaminteraction/src/contact/beam_to_solid/volume/4C_beaminteraction_contact_beam_to_solid_volume_meshtying_pair_mortar.cpp b/src/beaminteraction/src/contact/beam_to_solid/volume/4C_beaminteraction_contact_beam_to_solid_volume_meshtying_pair_mortar.cpp index 72997e2820..d4d02b78a9 100644 --- a/src/beaminteraction/src/contact/beam_to_solid/volume/4C_beaminteraction_contact_beam_to_solid_volume_meshtying_pair_mortar.cpp +++ b/src/beaminteraction/src/contact/beam_to_solid/volume/4C_beaminteraction_contact_beam_to_solid_volume_meshtying_pair_mortar.cpp @@ -17,6 +17,7 @@ #include "4C_geometry_pair_element.hpp" #include "4C_geometry_pair_element_evaluation_functions.hpp" #include "4C_geometry_pair_line_to_volume.hpp" +#include "4C_linalg_fixedsizematrix_solver.hpp" #include @@ -297,6 +298,14 @@ void BeamInteraction::BeamToSolidVolumeMeshtyingPairMortar: Core::LinAlg::Initialization::zero); Core::LinAlg::Matrix<1, Solid::n_nodes_ * Solid::n_val_, double> N_solid( Core::LinAlg::Initialization::zero); + Core::LinAlg::Matrix<1, Beam::n_nodes_ * Beam::n_val_, double> N_mortar_primal( + Core::LinAlg::Initialization::zero); + Core::LinAlg::Matrix local_D_mortar( + Core::LinAlg::Initialization::zero); + Core::LinAlg::Matrix local_M_mortar( + Core::LinAlg::Initialization::zero); + Core::LinAlg::Matrix local_A( + Core::LinAlg::Initialization::zero); // Initialize variable for beam position derivative. Core::LinAlg::Matrix<3, 1, double> dr_beam_ref(Core::LinAlg::Initialization::zero); @@ -305,9 +314,132 @@ void BeamInteraction::BeamToSolidVolumeMeshtyingPairMortar: double segment_jacobian = 0.0; double beam_segmentation_factor = 0.0; + // compute local_A matrix + const unsigned int n_segments = this->line_to_3D_segments_.size(); + if constexpr (std::is_same_v) + { + // Helper: hard-coded primal cubic Hermite mortar shape functions on [-1, 1]. + auto evaluate_primal_mortar_shape_functions = + [](const double r, Core::LinAlg::Matrix<1, Mortar::n_nodes_ * Mortar::n_val_, double>& N) + { + N.clear(); + + if constexpr (Mortar::n_nodes_ == 2 && Mortar::n_val_ == 2) + { + const double r2 = r * r; + const double r3 = r2 * r; + + N(0) = 0.25 * (2.0 - 3.0 * r + r3); + N(1) = 1.0 / 8.0 * (1.0 - r - r2 + r3); + N(2) = 0.25 * (2.0 + 3.0 * r - r3); + N(3) = 1.0 / 8.0 * (-1.0 - r + r2 + r3); + } + }; + + // Assemble local_M_mortar and local_D_mortar. + for (unsigned int i_segment = 0; i_segment < n_segments; ++i_segment) + { + const double beam_segmentation_factor = + 0.5 * this->line_to_3D_segments_[i_segment].get_segment_length(); + + const unsigned int n_gp = + this->line_to_3D_segments_[i_segment].get_projection_points().size(); + + for (unsigned int i_gp = 0; i_gp < n_gp; ++i_gp) + { + const GeometryPair::ProjectionPoint1DTo3D& projected_gauss_point = + this->line_to_3D_segments_[i_segment].get_projection_points()[i_gp]; + + const double eta = projected_gauss_point.get_eta(); + + GeometryPair::evaluate_position_derivative1(eta, this->ele1posref_, dr_beam_ref); + + const double segment_jacobian = dr_beam_ref.norm2() * beam_segmentation_factor; + + const double integration_factor = + projected_gauss_point.get_gauss_weight() * segment_jacobian; + + N_mortar_primal.clear(); + + GeometryPair::EvaluateShapeFunction::evaluate( + N_mortar_primal, eta, this->ele1pos_.shape_function_data_); + + for (unsigned int j_shape = 0; j_shape < Beam::n_nodes_ * Beam::n_val_; ++j_shape) + { + const double N_j = N_mortar_primal(j_shape); + + for (unsigned int k_shape = 0; k_shape < Beam::n_nodes_ * Beam::n_val_; ++k_shape) + { + const double N_k = N_mortar_primal(k_shape); + + for (unsigned int i_dim = 0; i_dim < 3; ++i_dim) + { + const unsigned int j_dof = j_shape * 3 + i_dim; + const unsigned int k_dof = k_shape * 3 + i_dim; + + local_M_mortar(j_dof, k_dof) += N_j * N_k * integration_factor; + + if (j_dof == k_dof) + { + const double N_k_measure = N_mortar_primal(k_shape); + + local_D_mortar(j_dof, k_dof) += N_k_measure * integration_factor; + } + } + } + } + } + } + + // Compute A = D M^{-1}. + Core::LinAlg::Matrix M_trans_const( + Core::LinAlg::Initialization::zero); + + for (unsigned int i = 0; i < Mortar::n_dof_; ++i) + { + for (unsigned int j = 0; j < Mortar::n_dof_; ++j) + { + M_trans_const(i, j) = local_M_mortar(j, i); + } + } + + for (unsigned int row = 0; row < Mortar::n_dof_; ++row) + { + Core::LinAlg::Matrix M_trans_work( + Core::LinAlg::Initialization::zero); + + for (unsigned int i = 0; i < Mortar::n_dof_; ++i) + { + for (unsigned int j = 0; j < Mortar::n_dof_; ++j) + { + M_trans_work(i, j) = M_trans_const(i, j); + } + } + + Core::LinAlg::Matrix rhs(Core::LinAlg::Initialization::zero); + + Core::LinAlg::Matrix sol(Core::LinAlg::Initialization::zero); + + for (unsigned int i = 0; i < Mortar::n_dof_; ++i) + { + rhs(i) = local_D_mortar(row, i); + } + + Core::LinAlg::FixedSizeSerialDenseSolver solver; + + solver.set_matrix(M_trans_work); + solver.set_vectors(sol, rhs); + solver.solve(); + + for (unsigned int j = 0; j < Mortar::n_dof_; ++j) + { + local_A(row, j) = sol(j); + } + } + } + // Calculate the mortar matrices. // Loop over segments. - const unsigned int n_segments = this->line_to_3D_segments_.size(); for (unsigned int i_segment = 0; i_segment < n_segments; i_segment++) { // Factor to account for the integration segment length. @@ -321,6 +453,8 @@ void BeamInteraction::BeamToSolidVolumeMeshtyingPairMortar: const GeometryPair::ProjectionPoint1DTo3D& projected_gauss_point = this->line_to_3D_segments_[i_segment].get_projection_points()[i_gp]; + const double eta = projected_gauss_point.get_eta(); + // Get the jacobian in the reference configuration. GeometryPair::evaluate_position_derivative1( projected_gauss_point.get_eta(), this->ele1posref_, dr_beam_ref); @@ -332,12 +466,40 @@ void BeamInteraction::BeamToSolidVolumeMeshtyingPairMortar: N_mortar.clear(); N_beam.clear(); N_solid.clear(); - GeometryPair::ShapeFunctionData shape_function_data; - GeometryPair::SetShapeFunctionData::set(shape_function_data, this->element1()); - GeometryPair::EvaluateShapeFunction::evaluate( - N_mortar, projected_gauss_point.get_eta(), shape_function_data); + GeometryPair::EvaluateShapeFunction::evaluate( - N_beam, projected_gauss_point.get_eta(), this->ele1pos_.shape_function_data_); + N_beam, eta, this->ele1pos_.shape_function_data_); + + if constexpr (std::is_same_v) + { + // Build dual mortar shape functions from the same primal beam basis + // used in the final local_D integral: + // + // Phi_j = sum_k A_jk N_beam_k + // + N_mortar.clear(); + + for (unsigned int j_shape = 0; j_shape < Mortar::n_nodes_ * Mortar::n_val_; ++j_shape) + { + const unsigned int j_dof_x = j_shape * 3; + + for (unsigned int k_shape = 0; k_shape < Beam::n_nodes_ * Beam::n_val_; ++k_shape) + { + const unsigned int k_dof_x = k_shape * 3; + + N_mortar(j_shape) += local_A(j_dof_x, k_dof_x) * N_beam(k_shape); + } + } + } + else + { + GeometryPair::ShapeFunctionData shape_function_data; + GeometryPair::SetShapeFunctionData::set(shape_function_data, this->element1()); + + GeometryPair::EvaluateShapeFunction::evaluate(N_mortar, eta, shape_function_data); + } + /*GeometryPair::EvaluateShapeFunction::evaluate( + N_beam, projected_gauss_point.get_eta(), this->ele1pos_.shape_function_data_);*/ GeometryPair::EvaluateShapeFunction::evaluate( N_solid, projected_gauss_point.get_xi(), this->ele2pos_.shape_function_data_); diff --git a/src/beaminteraction/tests/4C_beaminteraction_beam_to_solid_volume_meshtying_mortar_test.cpp b/src/beaminteraction/tests/4C_beaminteraction_beam_to_solid_volume_meshtying_mortar_test.cpp index bd98b3c85f..7eb6e8732c 100644 --- a/src/beaminteraction/tests/4C_beaminteraction_beam_to_solid_volume_meshtying_mortar_test.cpp +++ b/src/beaminteraction/tests/4C_beaminteraction_beam_to_solid_volume_meshtying_mortar_test.cpp @@ -116,7 +116,7 @@ namespace // Check the results for D. for (unsigned int i_row = 0; i_row < LambdaType::n_dof_; i_row++) for (unsigned int i_col = 0; i_col < BeamType::n_dof_; i_col++) - EXPECT_NEAR(local_D(i_row, i_col), result_local_D(i_row, i_col), 1e-11); + EXPECT_NEAR(local_D(i_row, i_col), result_local_D(i_row, i_col), 1e-11; // Check the results for M. for (unsigned int i_row = 0; i_row < LambdaType::n_dof_; i_row++) @@ -4427,160 +4427,439 @@ namespace q_solid.element_position_(23) = 0.6; // Results for D. - result_local_D(0, 0) = 0.2121320343549544; - result_local_D(0, 3) = -0.00000000000002726811831887943; - result_local_D(0, 6) = 0.00000000000004586608870482678; - result_local_D(1, 1) = 0.2121320343549544; - result_local_D(1, 4) = -0.00000000000002726811831887943; - result_local_D(1, 7) = 0.00000000000004586608870482678; - result_local_D(2, 2) = 0.2121320343549544; - result_local_D(2, 5) = -0.00000000000002726811831887943; - result_local_D(2, 8) = 0.00000000000004586608870482678; - result_local_D(3, 0) = 0.00000000001687716633114178; - result_local_D(3, 3) = 0.2121320343565151; - result_local_D(3, 6) = -0.000000000003244071677954707; - result_local_D(3, 9) = -0.0000000000001377231662047507; - result_local_D(4, 1) = 0.00000000001687716633114178; - result_local_D(4, 4) = 0.2121320343565151; - result_local_D(4, 7) = -0.000000000003244071677954707; - result_local_D(4, 10) = -0.0000000000001377231662047507; - result_local_D(5, 2) = 0.00000000001687716633114178; - result_local_D(5, 5) = 0.2121320343565151; - result_local_D(5, 8) = -0.000000000003244071677954707; - result_local_D(5, 11) = -0.0000000000001377231662047507; - result_local_D(6, 0) = 0.00000000000004585221091701897; - result_local_D(6, 6) = 0.2121320343549544; - result_local_D(6, 9) = 0.00000000000002726985304235541; - result_local_D(7, 1) = 0.00000000000004585221091701897; - result_local_D(7, 7) = 0.2121320343549544; - result_local_D(7, 10) = 0.00000000000002726985304235541; - result_local_D(8, 2) = 0.00000000000004585221091701897; - result_local_D(8, 8) = 0.2121320343549544; - result_local_D(8, 11) = 0.00000000000002726985304235541; - result_local_D(9, 0) = 0.000000000003244959856374408; - result_local_D(9, 3) = -0.0000000000001378064329315976; - result_local_D(9, 6) = -0.00000000001687716633114178; - result_local_D(9, 9) = 0.2121320343565152; - result_local_D(10, 1) = 0.000000000003244959856374408; - result_local_D(10, 4) = -0.0000000000001378064329315976; - result_local_D(10, 7) = -0.00000000001687716633114178; - result_local_D(10, 10) = 0.2121320343565152; - result_local_D(11, 2) = 0.000000000003244959856374408; - result_local_D(11, 5) = -0.0000000000001378064329315976; - result_local_D(11, 8) = -0.00000000001687716633114178; - result_local_D(11, 11) = 0.2121320343565152; + result_local_D(0, 0) = 0.2121320343559642; + result_local_D(1, 1) = 0.2121320343559642; + result_local_D(2, 2) = 0.2121320343559642; + result_local_D(3, 3) = 0.01500000000001366; + result_local_D(4, 4) = 0.01500000000001366; + result_local_D(5, 5) = 0.01500000000001366; + result_local_D(6, 6) = 0.2121320343559645; + result_local_D(7, 7) = 0.2121320343559645; + result_local_D(8, 8) = 0.2121320343559645; + result_local_D(9, 9) = -0.01500000000001367; + result_local_D(10, 10) = -0.01500000000001367; + result_local_D(11, 11) = -0.01500000000001367; // Results for M. - result_local_M(0, 0) = 0.0994368911039243; - result_local_M(0, 3) = 0.01988737822076901; - result_local_M(0, 6) = 0.006629126073596114; - result_local_M(0, 9) = 0.03314563036796071; - result_local_M(0, 12) = 0.03314563036796071; - result_local_M(0, 15) = 0.006629126073596114; - result_local_M(0, 18) = 0.002209708691205467; - result_local_M(0, 21) = 0.01104854345598777; - result_local_M(1, 1) = 0.0994368911039243; - result_local_M(1, 4) = 0.01988737822076901; - result_local_M(1, 7) = 0.006629126073596114; - result_local_M(1, 10) = 0.03314563036796071; - result_local_M(1, 13) = 0.03314563036796071; - result_local_M(1, 16) = 0.006629126073596114; - result_local_M(1, 19) = 0.002209708691205467; - result_local_M(1, 22) = 0.01104854345598777; - result_local_M(2, 2) = 0.0994368911039243; - result_local_M(2, 5) = 0.01988737822076901; - result_local_M(2, 8) = 0.006629126073596114; - result_local_M(2, 11) = 0.03314563036796071; - result_local_M(2, 14) = 0.03314563036796071; - result_local_M(2, 17) = 0.006629126073596114; - result_local_M(2, 20) = 0.002209708691205467; - result_local_M(2, 23) = 0.01104854345598777; - result_local_M(3, 0) = -0.1718749999916556; - result_local_M(3, 3) = 0.07812500000167466; - result_local_M(3, 6) = 0.03645833333327941; - result_local_M(3, 9) = -0.005208333331326864; - result_local_M(3, 12) = -0.005208333331326864; - result_local_M(3, 15) = 0.03645833333327941; - result_local_M(3, 18) = 0.01562499999958342; - result_local_M(3, 21) = 0.01562500000012557; - result_local_M(4, 1) = -0.1718749999916556; - result_local_M(4, 4) = 0.07812500000167466; - result_local_M(4, 7) = 0.03645833333327941; - result_local_M(4, 10) = -0.005208333331326864; - result_local_M(4, 13) = -0.005208333331326864; - result_local_M(4, 16) = 0.03645833333327941; - result_local_M(4, 19) = 0.01562499999958342; - result_local_M(4, 22) = 0.01562500000012557; - result_local_M(5, 2) = -0.1718749999916556; - result_local_M(5, 5) = 0.07812500000167466; - result_local_M(5, 8) = 0.03645833333327941; - result_local_M(5, 11) = -0.005208333331326864; - result_local_M(5, 14) = -0.005208333331326864; - result_local_M(5, 17) = 0.03645833333327941; - result_local_M(5, 20) = 0.01562499999958342; - result_local_M(5, 23) = 0.01562500000012557; - result_local_M(6, 0) = 0.04143203795997785; - result_local_M(6, 3) = 0.04143203795994982; - result_local_M(6, 6) = 0.02485922277597786; - result_local_M(6, 9) = 0.02485922277596961; - result_local_M(6, 12) = 0.02485922277596961; - result_local_M(6, 15) = 0.02485922277597786; - result_local_M(6, 18) = 0.01491553366559461; - result_local_M(6, 21) = 0.01491553366558303; - result_local_M(7, 1) = 0.04143203795997785; - result_local_M(7, 4) = 0.04143203795994982; - result_local_M(7, 7) = 0.02485922277597786; - result_local_M(7, 10) = 0.02485922277596961; - result_local_M(7, 13) = 0.02485922277596961; - result_local_M(7, 16) = 0.02485922277597786; - result_local_M(7, 19) = 0.01491553366559461; - result_local_M(7, 22) = 0.01491553366558303; - result_local_M(8, 2) = 0.04143203795997785; - result_local_M(8, 5) = 0.04143203795994982; - result_local_M(8, 8) = 0.02485922277597786; - result_local_M(8, 11) = 0.02485922277596961; - result_local_M(8, 14) = 0.02485922277596961; - result_local_M(8, 17) = 0.02485922277597786; - result_local_M(8, 20) = 0.01491553366559461; - result_local_M(8, 23) = 0.01491553366558303; - result_local_M(9, 0) = -0.1041666666670169; - result_local_M(9, 3) = 0.02604166666414387; - result_local_M(9, 6) = 0.0468749999979674; - result_local_M(9, 9) = -0.03125000000186939; - result_local_M(9, 12) = -0.03125000000186939; - result_local_M(9, 15) = 0.0468749999979674; - result_local_M(9, 18) = 0.04687499999864936; - result_local_M(9, 21) = -0.000000000001606603738935064; - result_local_M(10, 1) = -0.1041666666670169; - result_local_M(10, 4) = 0.02604166666414387; - result_local_M(10, 7) = 0.0468749999979674; - result_local_M(10, 10) = -0.03125000000186939; - result_local_M(10, 13) = -0.03125000000186939; - result_local_M(10, 16) = 0.0468749999979674; - result_local_M(10, 19) = 0.04687499999864936; - result_local_M(10, 22) = -0.000000000001606603738935064; - result_local_M(11, 2) = -0.1041666666670169; - result_local_M(11, 5) = 0.02604166666414387; - result_local_M(11, 8) = 0.0468749999979674; - result_local_M(11, 11) = -0.03125000000186939; - result_local_M(11, 14) = -0.03125000000186939; - result_local_M(11, 17) = 0.0468749999979674; - result_local_M(11, 20) = 0.04687499999864936; - result_local_M(11, 23) = -0.000000000001606603738935064; + result_local_M(0, 0) = 0.0994368911043705; + result_local_M(0, 3) = 0.01988737822086382; + result_local_M(0, 6) = 0.006629126073625256; + result_local_M(0, 9) = 0.0331456303681136; + result_local_M(0, 12) = 0.0331456303681136; + result_local_M(0, 15) = 0.006629126073625256; + result_local_M(0, 18) = 0.002209708691213046; + result_local_M(0, 21) = 0.01104854345603915; + result_local_M(1, 1) = 0.0994368911043705; + result_local_M(1, 4) = 0.01988737822086382; + result_local_M(1, 7) = 0.006629126073625256; + result_local_M(1, 10) = 0.0331456303681136; + result_local_M(1, 13) = 0.0331456303681136; + result_local_M(1, 16) = 0.006629126073625256; + result_local_M(1, 19) = 0.002209708691213046; + result_local_M(1, 22) = 0.01104854345603915; + result_local_M(2, 2) = 0.0994368911043705; + result_local_M(2, 5) = 0.01988737822086382; + result_local_M(2, 8) = 0.006629126073625256; + result_local_M(2, 11) = 0.0331456303681136; + result_local_M(2, 14) = 0.0331456303681136; + result_local_M(2, 17) = 0.006629126073625256; + result_local_M(2, 20) = 0.002209708691213046; + result_local_M(2, 23) = 0.01104854345603915; + result_local_M(3, 0) = -0.01215339780155269; + result_local_M(3, 3) = 0.005524271728063162; + result_local_M(3, 6) = 0.002577993473059571; + result_local_M(3, 9) = -0.0003682847818865103; + result_local_M(3, 12) = -0.0003682847818865103; + result_local_M(3, 15) = 0.002577993473059571; + result_local_M(3, 18) = 0.001104854345578537; + result_local_M(3, 21) = 0.001104854345564982; + result_local_M(4, 1) = -0.01215339780155269; + result_local_M(4, 4) = 0.005524271728063162; + result_local_M(4, 7) = 0.002577993473059571; + result_local_M(4, 10) = -0.0003682847818865103; + result_local_M(4, 13) = -0.0003682847818865103; + result_local_M(4, 16) = 0.002577993473059571; + result_local_M(4, 19) = 0.001104854345578537; + result_local_M(4, 22) = 0.001104854345564982; + result_local_M(5, 2) = -0.01215339780155269; + result_local_M(5, 5) = 0.005524271728063162; + result_local_M(5, 8) = 0.002577993473059571; + result_local_M(5, 11) = -0.0003682847818865103; + result_local_M(5, 14) = -0.0003682847818865103; + result_local_M(5, 17) = 0.002577993473059571; + result_local_M(5, 20) = 0.001104854345578537; + result_local_M(5, 23) = 0.001104854345564982; + result_local_M(6, 0) = 0.04143203796016073; + result_local_M(6, 3) = 0.04143203796014237; + result_local_M(6, 6) = 0.02485922277609012; + result_local_M(6, 9) = 0.02485922277608465; + result_local_M(6, 12) = 0.02485922277608465; + result_local_M(6, 15) = 0.02485922277609012; + result_local_M(6, 18) = 0.01491553366565971; + result_local_M(6, 21) = 0.01491553366565225; + result_local_M(7, 1) = 0.04143203796016073; + result_local_M(7, 4) = 0.04143203796014237; + result_local_M(7, 7) = 0.02485922277609012; + result_local_M(7, 10) = 0.02485922277608465; + result_local_M(7, 13) = 0.02485922277608465; + result_local_M(7, 16) = 0.02485922277609012; + result_local_M(7, 19) = 0.01491553366565971; + result_local_M(7, 22) = 0.01491553366565225; + result_local_M(8, 2) = 0.04143203796016073; + result_local_M(8, 5) = 0.04143203796014237; + result_local_M(8, 8) = 0.02485922277609012; + result_local_M(8, 11) = 0.02485922277608465; + result_local_M(8, 14) = 0.02485922277608465; + result_local_M(8, 17) = 0.02485922277609012; + result_local_M(8, 20) = 0.01491553366565971; + result_local_M(8, 23) = 0.01491553366565225; + result_local_M(9, 0) = 0.007365695637254727; + result_local_M(9, 3) = -0.00184142390937364; + result_local_M(9, 6) = -0.003314563036796989; + result_local_M(9, 9) = 0.002209708691232701; + result_local_M(9, 12) = 0.002209708691232701; + result_local_M(9, 15) = -0.003314563036796989; + result_local_M(9, 18) = -0.003314563036793089; + result_local_M(10, 1) = 0.007365695637254727; + result_local_M(10, 4) = -0.00184142390937364; + result_local_M(10, 7) = -0.003314563036796989; + result_local_M(10, 10) = 0.002209708691232701; + result_local_M(10, 13) = 0.002209708691232701; + result_local_M(10, 16) = -0.003314563036796989; + result_local_M(10, 19) = -0.003314563036793089; + result_local_M(11, 2) = 0.007365695637254727; + result_local_M(11, 5) = -0.00184142390937364; + result_local_M(11, 8) = -0.003314563036796989; + result_local_M(11, 11) = 0.002209708691232701; + result_local_M(11, 14) = 0.002209708691232701; + result_local_M(11, 17) = -0.003314563036796989; + result_local_M(11, 20) = -0.003314563036793089; // Results for Kappa. - result_local_kappa(0) = 0.2121320343550003; - result_local_kappa(1) = 0.2121320343550003; - result_local_kappa(2) = 0.2121320343550003; - result_local_kappa(3) = 0.00000000001363265056397722; - result_local_kappa(4) = 0.00000000001363265056397722; - result_local_kappa(5) = 0.00000000001363265056397722; - result_local_kappa(6) = 0.2121320343550003; - result_local_kappa(7) = 0.2121320343550003; - result_local_kappa(8) = 0.2121320343550003; - result_local_kappa(9) = -0.00000000001363353874239692; - result_local_kappa(10) = -0.00000000001363353874239692; - result_local_kappa(11) = -0.00000000001363353874239692; + result_local_kappa(0) = 0.2121320343559643; + result_local_kappa(1) = 0.2121320343559643; + result_local_kappa(2) = 0.2121320343559643; + result_local_kappa(6) = 0.2121320343559646; + result_local_kappa(7) = 0.2121320343559646; + result_local_kappa(8) = 0.2121320343559646; + + // Perform the unit tests. + perform_mortar_pair_unit_test(contact_pair, q_beam, q_beam_rot, q_solid, result_local_D, + result_local_M, result_local_kappa); + } + + /** + * \brief Test a non straight beam in a hex8 element, with line2 mortar shape functions. + */ + TEST_F(BeamToSolidVolumeMeshtyingPairMortarTest, + TestBeamToSolidMeshtyingMortarHermite2Hex8DualHermite2Rot) + { + // Element types. + using beam_type = GeometryPair::t_hermite; + using solid_type = GeometryPair::t_hex8; + using lambda_type = BeamInteraction::HermiteDual; + + // Create the mesh tying mortar pair. + BeamInteraction::BeamToSolidVolumeMeshtyingPairMortar + contact_pair = BeamInteraction::BeamToSolidVolumeMeshtyingPairMortar(); + + // Definition of variables for this test case. + GeometryPair::ElementData q_beam; + GeometryPair::ElementData q_solid; + Core::LinAlg::Matrix<9, 1> q_beam_rot; + Core::LinAlg::SerialDenseMatrix local_D; + Core::LinAlg::SerialDenseMatrix local_M; + Core::LinAlg::SerialDenseVector local_kappa; + + // Matrices for the results. + Core::LinAlg::Matrix result_local_D( + Core::LinAlg::Initialization::zero); + Core::LinAlg::Matrix result_local_M( + Core::LinAlg::Initialization::zero); + Core::LinAlg::Matrix result_local_kappa( + Core::LinAlg::Initialization::zero); + + // Define the geometry of the two elements. + q_beam.shape_function_data_.ref_length_ = 0.6192043571449604711; + q_beam.element_position_(0) = 0.15; + q_beam.element_position_(1) = 0.2; + q_beam.element_position_(2) = 0.3; + q_beam.element_position_(3) = 0.5773502691896255; + q_beam.element_position_(4) = 0.5773502691896258; + q_beam.element_position_(5) = 0.577350269189626; + q_beam.element_position_(6) = 0.65; + q_beam.element_position_(7) = 0.1; + q_beam.element_position_(8) = 0.1; + q_beam.element_position_(9) = 0.8017837257372733; + q_beam.element_position_(10) = -0.5345224838248488; + q_beam.element_position_(11) = 0.2672612419124244; + + q_beam_rot(0) = 1.674352746442651; + q_beam_rot(1) = 0.1425949677148126; + q_beam_rot(2) = 1.0831163124736984; + q_beam_rot(3) = 1.4331999091513161; + q_beam_rot(4) = -0.6560404572957742; + q_beam_rot(5) = -0.2491376152457331; + q_beam_rot(6) = 0.0; + q_beam_rot(7) = 0.0; + q_beam_rot(8) = 0.0; + + /*// Positional DOFs of the solid. + q_solid.element_position_(0) = -0.954193516126594; + q_solid.element_position_(1) = -0.975482672114534; + q_solid.element_position_(2) = -1.00311316662815; + q_solid.element_position_(3) = 0.923762409575691; + q_solid.element_position_(4) = -1.010615727466753; + q_solid.element_position_(5) = -1.014160992102648; + q_solid.element_position_(6) = 0.905563488894572; + q_solid.element_position_(7) = 1.069973754602123; + q_solid.element_position_(8) = -0.935488788632622; + q_solid.element_position_(9) = -1.047838992508937; + q_solid.element_position_(10) = 1.08888017769104; + q_solid.element_position_(11) = -1.036911970151991; + q_solid.element_position_(12) = -1.089167378981223; + q_solid.element_position_(13) = -1.063820485514786; + q_solid.element_position_(14) = 1.081000671652452; + q_solid.element_position_(15) = 0.972887477248942; + q_solid.element_position_(16) = -1.008995039455167; + q_solid.element_position_(17) = 0.923459231565508; + q_solid.element_position_(18) = 1.089192110164642; + q_solid.element_position_(19) = 1.026798931538616; + q_solid.element_position_(20) = 0.964761788314679; + q_solid.element_position_(21) = -0.941489453299989; + q_solid.element_position_(22) = 0.954327975326486; + q_solid.element_position_(23) = 0.963168067937965; + + // Results for D. + result_local_D(0, 0) = 0.1954215935447702; + result_local_D(0, 3) = 0.01819251719410916; + result_local_D(0, 6) = 0.0989414627904878; + result_local_D(0, 9) = -0.01347747062937554; + result_local_D(1, 1) = 0.1954215935447702; + result_local_D(1, 4) = 0.01819251719410916; + result_local_D(1, 7) = 0.0989414627904878; + result_local_D(1, 10) = -0.01347747062937554; + result_local_D(2, 2) = 0.1954215935447702; + result_local_D(2, 5) = 0.01819251719410916; + result_local_D(2, 8) = 0.0989414627904878; + result_local_D(2, 11) = -0.01347747062937554; + result_local_D(3, 0) = 0.0946778368171451; + result_local_D(3, 3) = 0.01347747062937554; + result_local_D(3, 6) = 0.2300774860559777; + result_local_D(3, 9) = -0.02083257297403942; + result_local_D(4, 1) = 0.0946778368171451; + result_local_D(4, 4) = 0.01347747062937554; + result_local_D(4, 7) = 0.2300774860559777; + result_local_D(4, 10) = -0.02083257297403942; + result_local_D(5, 2) = 0.0946778368171451; + result_local_D(5, 5) = 0.01347747062937554; + result_local_D(5, 8) = 0.2300774860559777; + result_local_D(5, 11) = -0.02083257297403942; + + // Results for M. + result_local_M(0, 0) = 0.01401807776555987; + result_local_M(0, 3) = 0.02820630234659772; + result_local_M(0, 6) = 0.04334313657153085; + result_local_M(0, 9) = 0.02180811652516679; + result_local_M(0, 12) = 0.02499407921495017; + result_local_M(0, 15) = 0.048221643722761; + result_local_M(0, 18) = 0.07468795643554835; + result_local_M(0, 21) = 0.03908374375314327; + result_local_M(1, 1) = 0.01401807776555987; + result_local_M(1, 4) = 0.02820630234659772; + result_local_M(1, 7) = 0.04334313657153085; + result_local_M(1, 10) = 0.02180811652516679; + result_local_M(1, 13) = 0.02499407921495017; + result_local_M(1, 16) = 0.048221643722761; + result_local_M(1, 19) = 0.07468795643554835; + result_local_M(1, 22) = 0.03908374375314327; + result_local_M(2, 2) = 0.01401807776555987; + result_local_M(2, 5) = 0.02820630234659772; + result_local_M(2, 8) = 0.04334313657153085; + result_local_M(2, 11) = 0.02180811652516679; + result_local_M(2, 14) = 0.02499407921495017; + result_local_M(2, 17) = 0.048221643722761; + result_local_M(2, 20) = 0.07468795643554835; + result_local_M(2, 23) = 0.03908374375314327; + result_local_M(3, 0) = 0.01374032046076183; + result_local_M(3, 3) = 0.04167222214705426; + result_local_M(3, 6) = 0.05814720173702535; + result_local_M(3, 9) = 0.01976961944249095; + result_local_M(3, 12) = 0.02025971859166802; + result_local_M(3, 15) = 0.05866143799154906; + result_local_M(3, 18) = 0.0829388844532102; + result_local_M(3, 21) = 0.02956591804936312; + result_local_M(4, 1) = 0.01374032046076183; + result_local_M(4, 4) = 0.04167222214705426; + result_local_M(4, 7) = 0.05814720173702535; + result_local_M(4, 10) = 0.01976961944249095; + result_local_M(4, 13) = 0.02025971859166802; + result_local_M(4, 16) = 0.05866143799154906; + result_local_M(4, 19) = 0.0829388844532102; + result_local_M(4, 22) = 0.02956591804936312; + result_local_M(5, 2) = 0.01374032046076183; + result_local_M(5, 5) = 0.04167222214705426; + result_local_M(5, 8) = 0.05814720173702535; + result_local_M(5, 11) = 0.01976961944249095; + result_local_M(5, 14) = 0.02025971859166802; + result_local_M(5, 17) = 0.05866143799154906; + result_local_M(5, 20) = 0.0829388844532102; + result_local_M(5, 23) = 0.02956591804936312; + + // Results for Kappa. + result_local_kappa(0) = 0.294363056335258; + result_local_kappa(1) = 0.294363056335258; + result_local_kappa(2) = 0.294363056335258; + result_local_kappa(3) = 0.3247553228731228; + result_local_kappa(4) = 0.3247553228731228; + result_local_kappa(5) = 0.3247553228731228;*/ + + // Positional DOFs of the solid. + q_solid.element_position_(0) = -0.954193516126594; + q_solid.element_position_(1) = -0.975482672114534; + q_solid.element_position_(2) = -1.00311316662815; + q_solid.element_position_(3) = 0.923762409575691; + q_solid.element_position_(4) = -1.010615727466753; + q_solid.element_position_(5) = -1.014160992102648; + q_solid.element_position_(6) = 0.905563488894572; + q_solid.element_position_(7) = 1.069973754602123; + q_solid.element_position_(8) = -0.935488788632622; + q_solid.element_position_(9) = -1.047838992508937; + q_solid.element_position_(10) = 1.08888017769104; + q_solid.element_position_(11) = -1.036911970151991; + q_solid.element_position_(12) = -1.089167378981223; + q_solid.element_position_(13) = -1.063820485514786; + q_solid.element_position_(14) = 1.081000671652452; + q_solid.element_position_(15) = 0.972887477248942; + q_solid.element_position_(16) = -1.008995039455167; + q_solid.element_position_(17) = 0.923459231565508; + q_solid.element_position_(18) = 1.089192110164642; + q_solid.element_position_(19) = 1.026798931538616; + q_solid.element_position_(20) = 0.964761788314679; + q_solid.element_position_(21) = -0.941489453299989; + q_solid.element_position_(22) = 0.954327975326486; + q_solid.element_position_(23) = 0.963168067937965; + + // Results for D. + result_local_D(0, 0) = 0.2900994303619146; + result_local_D(1, 1) = 0.2900994303619146; + result_local_D(2, 2) = 0.2900994303619146; + result_local_D(3, 3) = 0.0316699878234846; + result_local_D(4, 4) = 0.0316699878234846; + result_local_D(5, 5) = 0.0316699878234846; + result_local_D(6, 6) = 0.3290189488464655; + result_local_D(7, 7) = 0.3290189488464655; + result_local_D(8, 8) = 0.3290189488464655; + result_local_D(9, 9) = -0.03431004360341489; + result_local_D(10, 10) = -0.03431004360341489; + result_local_D(11, 11) = -0.03431004360341489; + + // Results for M. + result_local_M(0, 0) = 0.01678382743230986; + result_local_M(0, 3) = 0.02341579717639822; + result_local_M(0, 6) = 0.03453546021843923; + result_local_M(0, 9) = 0.02485317428320211; + result_local_M(0, 12) = 0.03263413489738847; + result_local_M(0, 15) = 0.04412495117244463; + result_local_M(0, 18) = 0.06518953415078565; + result_local_M(0, 21) = 0.04856255103094648; + result_local_M(1, 1) = 0.01678382743230986; + result_local_M(1, 4) = 0.02341579717639822; + result_local_M(1, 7) = 0.03453546021843923; + result_local_M(1, 10) = 0.02485317428320211; + result_local_M(1, 13) = 0.03263413489738847; + result_local_M(1, 16) = 0.04412495117244463; + result_local_M(1, 19) = 0.06518953415078565; + result_local_M(1, 22) = 0.04856255103094648; + result_local_M(2, 2) = 0.01678382743230986; + result_local_M(2, 5) = 0.02341579717639822; + result_local_M(2, 8) = 0.03453546021843923; + result_local_M(2, 11) = 0.02485317428320211; + result_local_M(2, 14) = 0.03263413489738847; + result_local_M(2, 17) = 0.04412495117244463; + result_local_M(2, 20) = 0.06518953415078565; + result_local_M(2, 23) = 0.04856255103094648; + result_local_M(3, 0) = -0.003283708896656953; + result_local_M(3, 3) = -0.003576400477631067; + result_local_M(3, 6) = -0.000841767368393045; + result_local_M(3, 9) = -0.001809114176039919; + result_local_M(3, 12) = -0.00358145292820812; + result_local_M(3, 15) = 0.001420374047450476; + result_local_M(3, 18) = 0.01134013584674359; + result_local_M(3, 21) = 0.0003319339527347726; + result_local_M(4, 1) = -0.003283708896656953; + result_local_M(4, 4) = -0.003576400477631067; + result_local_M(4, 7) = -0.000841767368393045; + result_local_M(4, 10) = -0.001809114176039919; + result_local_M(4, 13) = -0.00358145292820812; + result_local_M(4, 16) = 0.001420374047450476; + result_local_M(4, 19) = 0.01134013584674359; + result_local_M(4, 22) = 0.0003319339527347726; + result_local_M(5, 2) = -0.003283708896656953; + result_local_M(5, 5) = -0.003576400477631067; + result_local_M(5, 8) = -0.000841767368393045; + result_local_M(5, 11) = -0.001809114176039919; + result_local_M(5, 14) = -0.00358145292820812; + result_local_M(5, 17) = 0.001420374047450476; + result_local_M(5, 20) = 0.01134013584674359; + result_local_M(5, 23) = 0.0003319339527347726; + result_local_M(6, 0) = 0.01088717419316493; + result_local_M(6, 3) = 0.05612619505456333; + result_local_M(6, 6) = 0.06589915343857811; + result_local_M(6, 9) = 0.01275770567124155; + result_local_M(6, 12) = 0.01407382952891469; + result_local_M(6, 15) = 0.06963049218283635; + result_local_M(6, 18) = 0.0824826247640758; + result_local_M(6, 21) = 0.01716177401309099; + result_local_M(7, 1) = 0.01088717419316493; + result_local_M(7, 4) = 0.05612619505456333; + result_local_M(7, 7) = 0.06589915343857811; + result_local_M(7, 10) = 0.01275770567124155; + result_local_M(7, 13) = 0.01407382952891469; + result_local_M(7, 16) = 0.06963049218283635; + result_local_M(7, 19) = 0.0824826247640758; + result_local_M(7, 22) = 0.01716177401309099; + result_local_M(8, 2) = 0.01088717419316493; + result_local_M(8, 5) = 0.05612619505456333; + result_local_M(8, 8) = 0.06589915343857811; + result_local_M(8, 11) = 0.01275770567124155; + result_local_M(8, 14) = 0.01407382952891469; + result_local_M(8, 17) = 0.06963049218283635; + result_local_M(8, 20) = 0.0824826247640758; + result_local_M(8, 23) = 0.01716177401309099; + result_local_M(9, 0) = 0.003371105497503822; + result_local_M(9, 3) = -0.006087067259678641; + result_local_M(9, 6) = 0.001897492019931696; + result_local_M(9, 9) = 0.005775970189253944; + result_local_M(9, 12) = 0.002127286308523081; + result_local_M(9, 15) = -0.00829273568842159; + result_local_M(9, 18) = -0.001385453872846804; + result_local_M(9, 21) = 0.00259340280573403; + result_local_M(10, 1) = 0.003371105497503822; + result_local_M(10, 4) = -0.006087067259678641; + result_local_M(10, 7) = 0.001897492019931696; + result_local_M(10, 10) = 0.005775970189253944; + result_local_M(10, 13) = 0.002127286308523081; + result_local_M(10, 16) = -0.00829273568842159; + result_local_M(10, 19) = -0.001385453872846804; + result_local_M(10, 22) = 0.00259340280573403; + result_local_M(11, 2) = 0.003371105497503822; + result_local_M(11, 5) = -0.006087067259678641; + result_local_M(11, 8) = 0.001897492019931696; + result_local_M(11, 11) = 0.005775970189253944; + result_local_M(11, 14) = 0.002127286308523081; + result_local_M(11, 17) = -0.00829273568842159; + result_local_M(11, 20) = -0.001385453872846804; + result_local_M(11, 23) = 0.00259340280573403; + + // Results for Kappa. + result_local_kappa(0) = 0.2900994303619146; + result_local_kappa(1) = 0.2900994303619146; + result_local_kappa(2) = 0.2900994303619146; + result_local_kappa(6) = 0.3290189488464658; + result_local_kappa(7) = 0.3290189488464658; + result_local_kappa(8) = 0.3290189488464658; // Perform the unit tests. perform_mortar_pair_unit_test(contact_pair, q_beam, q_beam_rot, q_solid, result_local_D,