13 #if !defined(KRATOS_MORTAR_UTILITIES)
14 #define KRATOS_MORTAR_UTILITIES
18 #include <unordered_map>
91 typedef std::unordered_map<IndexType, IndexType>
IntMap;
105 const double Tolerance = 1.0e-6
138 const PointType& rPointReferenceRotation,
160 template <
typename TType>
161 std::vector<std::size_t>
SortIndexes(
const std::vector<TType> &rThisVector) {
163 std::vector<std::size_t> idx(rThisVector.size());
164 iota(idx.begin(), idx.end(), 0);
167 std::sort(idx.begin(), idx.end(),
168 [&rThisVector](std::size_t i1, std::size_t i2) {return rThisVector[i1] < rThisVector[i2];});
180 const bool ComputeConditions =
true
193 const double SlipCoefficient = 1.0,
194 const bool SlipAlways =
false
212 const std::size_t Dimension = 3
225 const std::size_t StepLM = 0,
227 const double SlipCoefficient = 1.0,
228 const std::size_t Dimension = 3
241 const std::size_t StepLM = 0,
243 const double SlipCoefficient = 1.0,
244 const std::size_t Dimension = 3
252 template<
class TContainerType>
254 TContainerType& rContainer,
258 bool to_invert =
false;
259 const auto it_cont_begin = rContainer.begin();
260 #pragma omp parallel for firstprivate(to_invert)
261 for(
int i = 0; i < static_cast<int>(rContainer.size()); ++
i) {
262 auto it_cont = it_cont_begin +
i;
263 to_invert = Flag ==
Flags() ? true : it_cont->
IsDefined(Flag) ? it_cont->Is(Flag) :
false;
269 std::reverse(data_geom.begin(), data_geom.end());
278 template<
class TContainerType>
292 template< SizeType TDim, SizeType TNumNodes>
295 const bool Current =
true,
302 for (
IndexType i_node = 0; i_node < TNumNodes; ++i_node) {
304 coord = rGeometry[i_node].Coordinates();
306 coord = rGeometry[i_node].GetInitialPosition();
309 coord += rGeometry[i_node].FastGetSolutionStepValue(DISPLACEMENT, Step);
312 for (
IndexType i_dof = 0; i_dof < TDim; ++i_dof)
313 coordinates(i_node, i_dof) = coord[i_dof];
324 template< SizeType TNumNodes, SizeType TDim>
330 for (
IndexType i_node = 0; i_node < TNumNodes; ++i_node) {
331 const auto& r_node = rGeometry[i_node];
332 const auto& r_tangent = r_node.
GetValue(TANGENT_XI);
333 for (std::size_t i_dof = 0; i_dof < TDim; ++i_dof) {
334 tangent_matrix(i_node, i_dof) = r_tangent[i_dof];
338 return tangent_matrix;
348 template< SizeType TNumNodes,
class TVarType = Variable<
double>>
351 const TVarType& rVariable,
357 for (
IndexType i_node = 0; i_node < TNumNodes; ++i_node)
358 var_vector[i_node] = rGeometry[i_node].FastGetSolutionStepValue(rVariable, Step);
370 template< SizeType TNumNodes,
class TVarType = Variable<
double> >
373 const TVarType& rVariable,
374 const unsigned int Step
379 for (
IndexType i_node = 0; i_node < TNumNodes; ++i_node)
380 var_vector(i_node, 0) = rGeometry[i_node].FastGetSolutionStepValue(rVariable, Step);
391 template< SizeType TNumNodes,
class TVarType = Variable<
double> >
394 const TVarType& rVariable
399 for (
IndexType i_node = 0; i_node < TNumNodes; ++i_node)
400 var_vector[i_node] = rGeometry[i_node].
GetValue(rVariable);
411 template< SizeType TNumNodes,
class TVarType = Variable<
double> >
414 const TVarType& rVariable
419 for (
IndexType i_node = 0; i_node < TNumNodes; ++i_node)
420 var_vector(i_node, 0) = rGeometry[i_node].
GetValue(rVariable);
432 template< SizeType TDim, SizeType TNumNodes>
436 const unsigned int Step
441 for (
IndexType i_node = 0; i_node < TNumNodes; ++i_node) {
442 const array_1d<double, 3>& value = rGeometry[i_node].FastGetSolutionStepValue(rVariable, Step);
443 for (
IndexType i_dof = 0; i_dof < TDim; ++i_dof)
444 var_matrix(i_node, i_dof) = value[i_dof];
456 template< SizeType TDim, SizeType TNumNodes>
464 for (
IndexType i_node = 0; i_node < TNumNodes; ++i_node) {
466 for (
IndexType i_dof = 0; i_dof < TDim; ++i_dof)
467 var_matrix(i_node, i_dof) = value[i_dof];
478 template< SizeType TDim, SizeType TNumNodes>
483 for (
IndexType i_node = 0; i_node < TNumNodes; ++i_node) {
484 for (
IndexType i_dof = 0; i_dof < TDim; ++i_dof)
485 AbsMatrix(i_node, i_dof) = std::abs(rInputMatrix(i_node, i_dof));
494 template< SizeType TDim,
class TVarType>
508 template<
class TVarType,
bool THistorical>
511 const TVarType& rThisVariable
518 template<
class TVarType>
525 template<
class TVarType>
534 template<
class TVarType>
537 const std::size_t iSize
546 template<
class TVarType,
bool THistorical>
549 const TVarType& rThisVariable,
560 template<
class TVarType,
bool THistorical>
563 const TVarType& rThisVariable,
572 template<
class TVarType,
bool THistorical>
575 const TVarType& rThisVariable,
576 const double RefArea = 1.0,
577 const double Tolerance = 1.0e-4
588 template<
class TVarType,
bool THistorical>
591 const TVarType& rThisVariable,
593 const std::size_t
Index,
594 IntMap& rConectivityDatabase
bool IsDefined(Flags const &rOther) const
Definition: flags.h:279
Geometry base class.
Definition: geometry.h:71
PointPointerContainerType & GetContainer()
** Gives a reference to underly normal container. */
Definition: geometry.h:573
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class defines the node.
Definition: node.h:65
Point class.
Definition: point.h:59
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
Short class definition.
Definition: array_1d.h:61
#define KRATOS_API(...)
Definition: kratos_export_api.h:40
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
Point PointType
Definition: mortar_utilities.h:77
std::vector< std::size_t > SortIndexes(const std::vector< TType > &rThisVector)
This function gives you the indexes needed to order a vector.
Definition: mortar_utilities.h:161
void InvertNormalForFlag(TContainerType &rContainer, const Flags Flag)
It inverts the order of the nodes in the conditions of a model part in order to invert the normal whe...
Definition: mortar_utilities.h:253
Node NodeType
Definition: mortar_utilities.h:76
void ComputeNodesMeanNormalModelPart(ModelPart &rModelPart, const bool ComputeConditions)
It computes the mean of the normal in the condition in all the nodes.
Definition: mortar_utilities.cpp:133
BoundedMatrix< double, TNumNodes, 1 > GetVariableVectorMatrix(const GeometryType &rGeometry, const TVarType &rVariable, const unsigned int Step)
It calculates the vector of an historical variable of a geometry.
Definition: mortar_utilities.h:371
double GetAuxiliarValue(NodeType &rThisNode, const std::size_t iSize)
This method returns the auxiliar variable.
BoundedMatrix< double, TNumNodes, TDim > GetCoordinates(const GeometryType &rGeometry, const bool Current=true, const IndexType Step=0)
It calculates the matrix of coordinates of a geometry.
Definition: mortar_utilities.h:293
std::size_t IndexType
Index type definition.
Definition: mortar_utilities.h:85
void ResetValue(ModelPart &rThisModelPart, const TVarType &rThisVariable)
This method resets the value.
PointType::CoordinatesArrayType CoordinatesArrayType
Definition: mortar_utilities.h:78
BoundedMatrix< double, TNumNodes, TDim > GetVariableMatrix(const GeometryType &rGeometry, const Variable< array_1d< double, 3 > > &rVariable, const unsigned int Step)
It calculates the matrix of a variable of a geometry.
Definition: mortar_utilities.h:433
BoundedMatrix< double, TNumNodes, TDim > ComputeTangentMatrix(const GeometryType &rGeometry)
It calculates the matrix containing the tangent vector TANGENT_XI.
Definition: mortar_utilities.h:325
unsigned int SizeToCompute()
This method gives the size to be computed.
Definition: mortar_utilities.h:495
std::unordered_map< IndexType, IndexType > IntMap
A map for integers.
Definition: mortar_utilities.h:91
void RotatePoint(PointType &rPointToRotate, const PointType &rPointReferenceRotation, const array_1d< double, 3 > &rSlaveTangentXi, const array_1d< double, 3 > &rSlaveTangentEta, const bool Inversed)
This function rotates to align the projected points to a parallel plane to XY.
Definition: mortar_utilities.cpp:81
void ComputeNodesTangentModelPart(ModelPart &rModelPart, const Variable< array_1d< double, 3 >> *pSlipVariable, const double SlipCoefficient, const bool SlipAlways)
It computes the tangent in all the nodes of the model part.
Definition: mortar_utilities.cpp:149
void ResetAuxiliarValue(ModelPart &rThisModelPart)
This method resets the auxiliar value.
void ComputeTangentNodeWithSlip(NodeType &rNode, const std::size_t StepLM, const Variable< array_1d< double, 3 >> *pSlipVariable, const double SlipCoefficient, const std::size_t Dimension)
It computes the tangent on the given node using the Slip direction.
Definition: mortar_utilities.cpp:295
array_1d< double, 3 > GaussPointUnitNormal(const Vector &rN, const GeometryType &rGeometry)
This function calculates the r_normal in a specific GP with a given shape function.
Definition: mortar_utilities.cpp:113
bool HeronCheck(const GeometryPointType &rGeometryTriangle)
This functions checks if the semiperimeter is smaller than any of the sides of the triangle.
Definition: mortar_utilities.cpp:45
void AddAreaWeightedNodalValue(NodeType &rThisNode, const TVarType &rThisVariable, const double RefArea=1.0, const double Tolerance=1.0e-4)
This method adds the value.
void ComputeNodesTangentFromNormalModelPart(ModelPart &rModelPart)
It computes the tangent in all the nodes of the model part from its normal.
Definition: mortar_utilities.cpp:185
array_1d< double, TNumNodes > GetVariableVector(const GeometryType &rGeometry, const TVarType &rVariable, const IndexType Step)
It calculates the vector of an historical variable of a geometry.
Definition: mortar_utilities.h:349
void UpdateDatabase(ModelPart &rThisModelPart, const TVarType &rThisVariable, Vector &rDx, const std::size_t Index, IntMap &rConectivityDatabase)
This method updates the database in the amster side.
Geometry< NodeType > GeometryType
Definition of geometries.
Definition: mortar_utilities.h:81
BoundedMatrix< double, TNumNodes, TDim > GetAbsMatrix(const BoundedMatrix< double, TNumNodes, TDim > &rInputMatrix)
It calculates the matrix containing the absolute value of another matrix.
Definition: mortar_utilities.h:479
bool LengthCheck(const GeometryPointType &rGeometryLine, const double Tolerance)
This functions checks if the length of the line is to short, with the potential of provoque ill condi...
Definition: mortar_utilities.cpp:30
void AddValue(GeometryType &rThisGeometry, const TVarType &rThisVariable, const Matrix &rThisValue)
This method adds the value.
void InvertNormal(TContainerType &rContainer)
It inverts the order of the nodes in the conditions of a model part in order to invert the normal.
Definition: mortar_utilities.h:279
void MatrixValue(const GeometryType &rThisGeometry, const TVarType &rThisVariable, Matrix &rThisValue)
This method adds the value.
Geometry< PointType > GeometryPointType
Definition: mortar_utilities.h:82
void ComputeTangentsFromNormal(NodeType &rNode, const array_1d< double, 3 > &rNormal, const std::size_t Dimension)
It computes the tangent on the given node using the normal provided.
Definition: mortar_utilities.cpp:210
void ComputeTangentNodeWithLMAndSlip(NodeType &rNode, const std::size_t StepLM, const Variable< array_1d< double, 3 >> *pSlipVariable, const double SlipCoefficient, const std::size_t Dimension)
It computes the tangent on the given node using the LM direction and Slip direction.
Definition: mortar_utilities.cpp:237
std::size_t SizeType
Size type definition.
Definition: mortar_utilities.h:88
const std::string GetAuxiliarVariable()
This method returns the auxiliar variable.
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
This is a class that provides auxiliar utilities for the mortar integration.
integer i
Definition: TensorModule.f:17
@ Current
Definition: particle_mechanics_math_utilities.h:39
This struct is used in order to identify when using the historical and non historical variables.
Definition: mortar_utilities.h:54
constexpr static bool SaveAsNonHistoricalVariable
Definition: mortar_utilities.h:57
constexpr static bool SaveAsHistoricalVariable
Definition: mortar_utilities.h:56