From 9a5cd884f832c4a735d30892368433544e3df8a5 Mon Sep 17 00:00:00 2001 From: AlejandroCornejo Date: Mon, 2 Dec 2024 15:28:38 +0100 Subject: [PATCH] avoid more repetition --- .../truss_elements/linear_truss_element.cpp | 48 +++++++------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/applications/StructuralMechanicsApplication/custom_elements/truss_elements/linear_truss_element.cpp b/applications/StructuralMechanicsApplication/custom_elements/truss_elements/linear_truss_element.cpp index 3fc97af4e12..cef754dd87d 100644 --- a/applications/StructuralMechanicsApplication/custom_elements/truss_elements/linear_truss_element.cpp +++ b/applications/StructuralMechanicsApplication/custom_elements/truss_elements/linear_truss_element.cpp @@ -171,21 +171,15 @@ void LinearTrussElement::GetShapeFunctionsValues( noalias(base_N) = GetBaseShapeFunctions(xi); if constexpr (Dimension == 2) { - if constexpr (NNodes == 2) { - rN[0] = base_N[0]; - rN[2] = base_N[1]; - } else { // 3N - rN[0] = base_N[0]; - rN[2] = base_N[1]; + rN[0] = base_N[0]; + rN[2] = base_N[1]; + if constexpr (NNodes == 3) { rN[4] = base_N[2]; } } else { - if constexpr (NNodes == 2) { - rN[0] = base_N[0]; - rN[3] = base_N[1]; - } else { // 3N - rN[0] = base_N[0]; - rN[3] = base_N[1]; + rN[0] = base_N[0]; + rN[3] = base_N[1]; + if constexpr (NNodes == 3) { rN[6] = base_N[2]; } } @@ -210,21 +204,15 @@ void LinearTrussElement::GetShapeFunctionsValuesY( noalias(base_N) = GetBaseShapeFunctions(xi); if constexpr (Dimension == 2) { - if constexpr (NNodes == 2) { - rN[1] = base_N[0]; - rN[3] = base_N[1]; - } else { // 3N - rN[1] = base_N[0]; - rN[3] = base_N[1]; + rN[1] = base_N[0]; + rN[3] = base_N[1]; + if constexpr (NNodes == 3) { rN[5] = base_N[2]; } } else { - if constexpr (NNodes == 2) { - rN[1] = base_N[0]; - rN[4] = base_N[1]; - } else { // 3N - rN[1] = base_N[0]; - rN[4] = base_N[1]; + rN[1] = base_N[0]; + rN[4] = base_N[1]; + if constexpr (NNodes == 3) { rN[7] = base_N[2]; } } @@ -248,12 +236,10 @@ void LinearTrussElement::GetShapeFunctionsValuesZ( if constexpr (Dimension == 3) { array_1d base_N; noalias(base_N) = GetBaseShapeFunctions(xi); - if constexpr (NNodes == 2) { - rN[2] = base_N[0]; - rN[5] = base_N[1]; - } else { // 3N - rN[2] = base_N[0]; - rN[5] = base_N[1]; + + rN[2] = base_N[0]; + rN[5] = base_N[1]; + if constexpr (NNodes == 3) { rN[8] = base_N[2]; } } @@ -493,7 +479,7 @@ void LinearTrussElement::CalculateLocalSystem( noalias(rRHS) += N_shape * local_body_forces[0] * jacobian_weight; noalias(rRHS) += N_shapeY * local_body_forces[1] * jacobian_weight; - noalias(rRHS) += N_shapeZ * local_body_forces[2] * jacobian_weight; // null in this class, full in derived one + noalias(rRHS) += N_shapeZ * local_body_forces[2] * jacobian_weight; } RotateAll(rLHS, rRHS); // rotate to global