Skip to content

Commit

Permalink
Merge branch 'master' into core/multistage-project
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenzorrilla committed Jul 7, 2023
2 parents 275821b + 425667f commit 3477001
Show file tree
Hide file tree
Showing 39 changed files with 1,381 additions and 6,728 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/* Utilities */
#include "utilities/math_utils.h"
#include "utilities/exact_mortar_segmentation_utility.h"
#include "custom_utilities/logging_settings.hpp"

namespace Kratos
{
Expand Down Expand Up @@ -132,12 +133,6 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit
// The threshold coefficient considered for checking
static constexpr double CheckThresholdCoefficient = 1.0e-12;

///@}
///@name Enum's
///@{

enum TensorValue {ScalarValue = 1, Vector2DValue = 2, Vector3DValue = 3};

///@}
///@name Life Cycle
///@{
Expand Down Expand Up @@ -391,32 +386,47 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit
/**
* This data will be used to compute teh derivatives
*/
template< const TensorValue TTensor >
struct DofData
{
public:

// Auxiliary types
using MatrixUnknownSlave = BoundedMatrix<double, TNumNodes, TTensor>;
using MatrixUnknownMaster = BoundedMatrix<double, TNumNodesMaster, TTensor>;
using MatrixUnknownSlave = BoundedMatrix<double, TNumNodes, TDim>;
using MatrixUnknownMaster = BoundedMatrix<double, TNumNodesMaster, TDim>;

// The DoF
MatrixUnknownSlave LagrangeMultipliers, u1;
MatrixUnknownMaster u2;

/**
* @brief Default constructor
* @param Dimension The dimension of the problem. Default = TDim
*/
DofData(const std::size_t Dimension = TDim)
{
// Resizing as needed (for scalar cases)
if (Dimension != TDim) {
LagrangeMultipliers.resize(TNumNodes, Dimension, false);
u1.resize(TNumNodes, Dimension, false);
u2.resize(TNumNodesMaster, Dimension, false);
}

// Clearing the values
this->Clear();
}

// Default destructor
~DofData()= default;

/**
* @brief Updating the Slave pair
* @param rGeometryInput The pointer of the current master
* @brief Clearing the values
*/
void Initialize(const GeometryType& rGeometryInput)
void Clear()
{
// The current Lagrange Multipliers
u1 = ZeroMatrix(TNumNodes, TTensor);
u2 = ZeroMatrix(TNumNodesMaster, TTensor);
LagrangeMultipliers = ZeroMatrix(TNumNodes, TTensor);
// Clearing the values
u1.clear();
u2.clear();
LagrangeMultipliers.clear();
}

/**
Expand All @@ -432,7 +442,7 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit
// Fill master information
for (IndexType i_node = 0; i_node < TNumNodesMaster; ++i_node) {
const auto& r_node = rGeometryInput[i_node];
for (IndexType i_dof = 0; i_dof < TTensor; ++i_dof) {
for (IndexType i_dof = 0; i_dof < rpDoFVariables.size(); ++i_dof) {
u2(i_node, i_dof) = r_node.FastGetSolutionStepValue(*rpDoFVariables[i_dof]);
}
}
Expand All @@ -444,11 +454,11 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit
///@name Protected member Variables
///@{

MortarConditionMatrices mMortarConditionMatrices; /// The mortar operators
MortarConditionMatrices mMortarConditionMatrices; /// The mortar operators

std::vector<const Variable<double>*> mpDoFVariables; /// The list of DoF variables
std::vector<const Variable<double>*> mpDoFVariables; /// The list of DoF variables

std::vector<const Variable<double>*> mpLMVariables; /// The list of LM variables
std::vector<const Variable<double>*> mpLMVariables; /// The list of LM variables

///@}
///@name Protected Operators
Expand Down Expand Up @@ -515,19 +525,15 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit
* @param rDofData the DofData object to be initialized
* @tparam TTensor The type of the DoF variables
*/
template<const TensorValue TTensor>
void InitializeDofData(DofData<TTensor>& rDofData)
void InitializeDofData(DofData& rDofData)
{
// The slave geometry
auto& r_slave_geometry = this->GetParentGeometry();

// Slave element info
rDofData.Initialize(r_slave_geometry);

// Retrieve values
for (IndexType i_node = 0; i_node < TNumNodes; i_node++) {
const auto& r_node = r_slave_geometry[i_node];
for (IndexType i_dof = 0; i_dof < TTensor; ++i_dof) {
for (IndexType i_dof = 0; i_dof < mpDoFVariables.size(); ++i_dof) {
rDofData.u1(i_node, i_dof) = r_node.FastGetSolutionStepValue(*mpDoFVariables[i_dof]);
rDofData.LagrangeMultipliers(i_node, i_dof) = r_node.FastGetSolutionStepValue(*mpLMVariables[i_dof]);
}
Expand Down Expand Up @@ -580,11 +586,10 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit
* @param rMortarConditionMatrices The mortar operators to be considered
* @param rDofData The class containing all the information needed in order to compute the jacobian
*/
template< const TensorValue TTensor >
void CalculateLocalLHS(
Matrix& rLocalLHS,
const MortarConditionMatrices& rMortarConditionMatrices,
const DofData<TTensor>& rDofData
const DofData& rDofData
);

/**
Expand All @@ -593,11 +598,10 @@ class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) MeshTyingMortarCondit
* @param rMortarConditionMatrices The mortar operators to be considered
* @param rDofData The class containing all the information needed in order to compute the jacobian
*/
template< const TensorValue TTensor >
void CalculateLocalRHS(
Vector& rLocalRHS,
const MortarConditionMatrices& rMortarConditionMatrices,
const DofData<TTensor>& rDofData
const DofData& rDofData
);

/***********************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Mesh-tying condition
# Mesh-tying condition (LEGACY FILES)

## LEGACY NOTE:

Here only the generation files are preserved. AD has been removed from MeshTying and now is manually constructed for more generality.

## ELEMENT DESCRIPTION:
Current directory contains the documentation for the symbolic derivation of the _"mesh_tying"_ condition. This element includes a formulation of a mesh tying condition using mortar formulation.

## SYMBOLIC GENERATOR SETTINGS:
* Nothing to add

## INSTRUCTIONS
## INSTRUCTIONS:
Run:
~~~py
python generate_mesh_tying_mortar_condition.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

rhs_string = ""

rhs_template_begin_string = "\n/***********************************************************************************/\n/***********************************************************************************/\n\ntemplate<>\ntemplate<>\nvoid MeshTyingMortarCondition<TDim,TNumNodesElem, TNumNodesElemMaster>::CalculateLocalRHS<MeshTyingMortarCondition<TDim,TNumNodesElem,TNumNodesElemMaster>::TTensor>(\n Vector& rLocalRHS,\n const MortarConditionMatrices& rMortarConditionMatrices,\n const DofData<TTensor>& rDofData\n )\n{\n // Initialize values\n const BoundedMatrix<double, TNumNodes, TTensor> u1 = rDofData.u1;\n const BoundedMatrix<double, TNumNodesMaster, TTensor> u2 = rDofData.u2;\n\n const BoundedMatrix<double, TNumNodes, TTensor> lm = rDofData.LagrangeMultipliers; \n\n // Mortar operators\n const BoundedMatrix<double, TNumNodes, TNumNodesMaster>& MOperator = rMortarConditionMatrices.MOperator;\n const BoundedMatrix<double, TNumNodes, TNumNodes>& DOperator = rMortarConditionMatrices.DOperator;\n"
rhs_template_begin_string = "\n/***********************************************************************************/\n/***********************************************************************************/\n\ntemplate<>\ntemplate<>\nvoid MeshTyingMortarCondition<TDim,TNumNodesElem, TNumNodesElemMaster>::CalculateLocalRHS<MeshTyingMortarCondition<TDim,TNumNodesElem,TNumNodesElemMaster>::TTensor>(\n Vector& rLocalRHS,\n const MortarConditionMatrices& rMortarConditionMatrices,\n const DofData<TTensor>& rDofData\n )\n{\n // Initialize values\n const BoundedMatrix<double, TNumNodes, TTensor>& u1 = rDofData.u1;\n const BoundedMatrix<double, TNumNodesMaster, TTensor>& u2 = rDofData.u2;\n\n const BoundedMatrix<double, TNumNodes, TTensor>& lm = rDofData.LagrangeMultipliers; \n\n // Mortar operators\n const BoundedMatrix<double, TNumNodes, TNumNodesMaster>& MOperator = rMortarConditionMatrices.MOperator;\n const BoundedMatrix<double, TNumNodes, TNumNodes>& DOperator = rMortarConditionMatrices.DOperator;\n"

rhs_template_end_string = "\n}\n"

Expand Down
Loading

0 comments on commit 3477001

Please sign in to comment.