KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
coupling_nitsche_condition.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Ricky Aristio
11 //
12 
13 #if !defined(KRATOS_COUPLING_NITSCHE_CONDITION_H_INCLUDED )
14 #define KRATOS_COUPLING_NITSCHE_CONDITION_H_INCLUDED
15 
16 // System includes
17 #include "includes/define.h"
18 #include "includes/condition.h"
20 
21 // External includes
22 
23 // Project includes
26 
28 
29 namespace Kratos
30 {
31 
33 
39  : public Condition
40 {
41 protected:
42 
45  {
46  // covariant metric
48 
49  //base vector 1
51  //base vector 2
53  //base vector 3 normalized
55  //not-normalized base vector 3
57 
58  //differential area
59  double dA;
60 
61  //the tangent to the surface vector
63  //the normal to the surface boundary vector
65  //the normal to the surface boundary vector in contravariant basis
67 
73  {
74  noalias(a_ab_covariant) = ZeroVector(Dimension);
75 
76  noalias(a1) = ZeroVector(Dimension);
77  noalias(a2) = ZeroVector(Dimension);
78  noalias(a3) = ZeroVector(Dimension);
79 
80  noalias(a3_tilde) = ZeroVector(Dimension);
81 
82  noalias(n) = ZeroVector(Dimension);
84  noalias(t) = ZeroVector(Dimension);
85 
86  dA = 1.0;
87  }
88  };
89 
94  {
98 
103  {
104  StrainVector = ZeroVector(StrainSize);
105  StressVector = ZeroVector(StrainSize);
106  ConstitutiveMatrix = ZeroMatrix(StrainSize, StrainSize);
107  }
108  };
109 
110 public:
113 
116 
118  typedef std::size_t SizeType;
119  typedef std::size_t IndexType;
120 
124 
127  IndexType NewId,
128  GeometryType::Pointer pGeometry)
129  : Condition(NewId, pGeometry)
130  {};
131 
134  IndexType NewId,
135  GeometryType::Pointer pGeometry,
136  PropertiesType::Pointer pProperties)
137  : Condition(NewId, pGeometry, pProperties)
138  {};
139 
142  : Condition()
143  {};
144 
146  virtual ~CouplingNitscheCondition() = default;
147 
151 
153  Condition::Pointer Create(
154  IndexType NewId,
155  GeometryType::Pointer pGeom,
156  PropertiesType::Pointer pProperties
157  ) const override
158  {
159  return Kratos::make_intrusive<CouplingNitscheCondition>(
160  NewId, pGeom, pProperties);
161  };
162 
164  Condition::Pointer Create(
165  IndexType NewId,
166  NodesArrayType const& ThisNodes,
167  PropertiesType::Pointer pProperties
168  ) const override
169  {
170  return Kratos::make_intrusive< CouplingNitscheCondition >(
171  NewId, GetGeometry().Create(ThisNodes), pProperties);
172  };
173 
177 
185  VectorType& rRightHandSideVector,
186  const ProcessInfo& rCurrentProcessInfo) override
187  {
188  MatrixType left_hand_side_matrix = Matrix(0, 0);
189 
190  CalculateAll(left_hand_side_matrix, rRightHandSideVector,
191  rCurrentProcessInfo, false, true);
192  }
193 
201  MatrixType& rLeftHandSideMatrix,
202  const ProcessInfo& rCurrentProcessInfo) override
203  {
204  VectorType right_hand_side_vector = Vector(0);
205 
206  CalculateAll(rLeftHandSideMatrix, right_hand_side_vector,
207  rCurrentProcessInfo, true, false);
208  }
209 
219  MatrixType& rLeftHandSideMatrix,
220  VectorType& rRightHandSideVector,
221  const ProcessInfo& rCurrentProcessInfo) override
222  {
223  if (rCurrentProcessInfo[BUILD_LEVEL] == 2)
224  {
225  CalculateNitscheStabilizationMatrix(rLeftHandSideMatrix, rRightHandSideVector,
226  rCurrentProcessInfo);
227  }
228  else
229  {
230  CalculateAll(rLeftHandSideMatrix, rRightHandSideVector,
231  rCurrentProcessInfo, true, true);
232  }
233 
234  }
235 
241  void EquationIdVector(
242  EquationIdVectorType& rResult,
243  const ProcessInfo& rCurrentProcessInfo
244  ) const override;
245 
251  void GetDofList(
252  DofsVectorType& rElementalDofList,
253  const ProcessInfo& rCurrentProcessInfo
254  ) const override;
255 
257  void CalculateAll(
258  MatrixType& rLeftHandSideMatrix,
259  VectorType& rRightHandSideVector,
260  const ProcessInfo& rCurrentProcessInfo,
261  const bool CalculateStiffnessMatrixFlag,
262  const bool CalculateResidualVectorFlag
263  );
264 
266  MatrixType& rLeftHandSideMatrix,
267  VectorType& rRightHandSideVector,
268  const ProcessInfo& rCurrentProcessInfo
269  );
270 
272  const GeometryType& rGeometry,
273  Vector& rDeterminantOfJacobian);
274 
278 
279  void GetValuesVector(
280  Vector& rValues,
281  int Step = 0) const override;
282 
283  enum class ConfigurationType {
284  Current,
285  Reference
286  };
287 
288  enum class PatchType {
289  Master,
290  Slave
291  };
292 
296 
298  std::string Info() const override
299  {
300  std::stringstream buffer;
301  buffer << "\"CouplingNitscheCondition\" #" << Id();
302  return buffer.str();
303  }
304 
306  void PrintInfo(std::ostream& rOStream) const override
307  {
308  rOStream << "\"CouplingNitscheCondition\" #" << Id();
309  }
310 
312  void PrintData(std::ostream& rOStream) const override {
313  pGetGeometry()->PrintData(rOStream);
314  }
315 
317 
318 private:
319 
322 
323  // Components of the metric coefficient tensor on the contravariant basis
324  std::vector<array_1d<double, 3>> m_A_ab_covariant_vector_master;
325  std::vector<array_1d<double, 3>> m_A_ab_covariant_vector_slave;
326 
327  // Determinant of the geometrical Jacobian.
328  Vector m_dA_vector_master;
329  Vector m_dA_vector_slave;
330 
331  /* Transformation the strain tensor from the curvilinear system
332  * to the local cartesian in voigt notation including a 2 in the
333  * shear part. */
334  std::vector<Matrix> m_T_vector_master;
335  std::vector<Matrix> m_T_vector_slave;
336 
337  /* Transformation the stress tensor from the local cartesian
338  * to the curvilinear system in voigt notation. */
339  std::vector<Matrix> m_T_hat_vector_master;
340  std::vector<Matrix> m_T_hat_vector_slave;
341 
342  std::vector<array_1d< array_1d<double, 3>,2>> m_reference_contravariant_base_master;
343  std::vector<array_1d< array_1d<double, 3>,2>> m_reference_contravariant_base_slave;
344 
345  // The normal to the boundary vector
346  std::vector<array_1d<double, 2>> m_n_contravariant_vector_master;
347  std::vector<array_1d<double, 2>> m_n_contravariant_vector_slave;
348 
349  void CalculateKinematics(
350  IndexType IntegrationPointIndex,
351  KinematicVariables& rKinematicVariables,
352  const Matrix& rShapeFunctionGradientValues, const ConfigurationType& rConfiguration, const PatchType& rPatch);
353 
354  // Computes transformation
355  void CalculateTransformation(
356  const KinematicVariables& rKinematicVariables,
357  Matrix& rT, Matrix& rT_hat, array_1d<array_1d<double, 3>,2>& rReferenceContraVariantBase);
358 
359  // Traction-related functions
360  void CalculateTraction(
361  IndexType IntegrationPointIndex,
362  array_1d<double, 3>& rTraction,
363  const KinematicVariables& rActualKinematic,
364  ConstitutiveVariables& rThisConstitutiveVariablesMembrane,
365  const PatchType& rPatch);
366 
367  void CalculateFirstVariationStressCovariant(
368  IndexType IntegrationPointIndex,
369  Matrix& rFirstVariationStressCovariant,
370  const KinematicVariables& rActualKinematic,
371  ConstitutiveVariables& rThisConstitutiveVariablesMembrane,
372  const PatchType& rPatch);
373 
374  void CalculateFirstVariationTraction(
375  IndexType IntegrationPointIndex,
376  Matrix& rFirstVariationTraction,
377  Matrix& rFirstVariationStressCovariant,
378  const KinematicVariables& rActualKinematic,
379  ConstitutiveVariables& rThisConstitutiveVariablesMembrane,
380  const PatchType& rPatch);
381 
382  void CalculateSecondVariationTractionProduct(
383  IndexType IntegrationPointIndex,
384  Matrix& rPi,
385  const KinematicVariables& rActualKinematic,
386  ConstitutiveVariables& rThisConstitutiveVariablesMembrane,
387  const PatchType& rPatch);
388 
389  void CalculateSecondVariationTraction(
390  IndexType IntegrationPointIndex,
391  Matrix& rSecondVariationTraction,
392  const KinematicVariables& rActualKinematic,
393  Matrix& rFirstVariationStressCovariant,
394  array_1d<double, 3>& rDisplacementMaster,
395  array_1d<double, 3>& rDisplacementSlave,
396  array_1d<double, 3>& rSecondVariationTractionProduct,
397  array_1d<double, 3>& rSecondVariationTractionProductMasterSlave,
398  const PatchType& rPatch);
399 
407  void CalculateConstitutiveVariables(
408  IndexType IntegrationPointIndex,
409  KinematicVariables& rActualMetric,
410  ConstitutiveVariables& rThisConstitutiveVariablesMembrane,
412  const ConstitutiveLaw::StressMeasure ThisStressMeasure,
413  const PatchType& rPatch
414  );
415 
421  void CalculateTransformationPrestress(
422  Matrix& rTransformationPrestress,
423  const KinematicVariables& rActualKinematic
424  );
425 
426  // void CalculateTransformationmatrixPrestress(
427  // const KinematicVariables& rActualKinematic,
428  // PrestresstransVariables& rPrestresstransVariables
429  // );
430 
434 
435  friend class Serializer;
436 
437  virtual void save(Serializer& rSerializer) const override
438  {
440  rSerializer.save("A_ab_covariant_vector_master", m_A_ab_covariant_vector_master);
441  rSerializer.save("A_ab_covariant_vector_slave", m_A_ab_covariant_vector_slave);
442  rSerializer.save("dA_vector_master", m_dA_vector_master);
443  rSerializer.save("dA_vector_slave", m_dA_vector_slave);
444  rSerializer.save("T_vector_master", m_T_vector_master);
445  rSerializer.save("T_vector_slave", m_T_vector_slave);
446  rSerializer.save("reference_contravariant_base_master", m_reference_contravariant_base_master);
447  rSerializer.save("reference_contravariant_base_slave", m_reference_contravariant_base_slave);
448  }
449 
450  virtual void load(Serializer& rSerializer) override
451  {
453  rSerializer.load("A_ab_covariant_vector_master", m_A_ab_covariant_vector_master);
454  rSerializer.load("A_ab_covariant_vector_slave", m_A_ab_covariant_vector_slave);
455  rSerializer.load("dA_vector_master", m_dA_vector_master);
456  rSerializer.load("dA_vector_slave", m_dA_vector_slave);
457  rSerializer.load("T_vector_master", m_T_vector_master);
458  rSerializer.load("T_vector_slave", m_T_vector_slave);
459  rSerializer.load("reference_contravariant_base_master", m_reference_contravariant_base_master);
460  rSerializer.load("reference_contravariant_base_slave", m_reference_contravariant_base_slave);
461  }
462 
464 
465 }; // Class CouplingNitscheCondition
466 
467 } // namespace Kratos.
468 
469 #endif // KRATOS_COUPLING_NITSCHE_CONDITION_H_INCLUDED defined
470 
471 
472 
Base class for all Conditions.
Definition: condition.h:59
std::size_t SizeType
Definition: condition.h:94
std::vector< std::size_t > EquationIdVectorType
Definition: condition.h:98
Matrix MatrixType
Definition: condition.h:90
std::vector< DofType::Pointer > DofsVectorType
Definition: condition.h:100
StressMeasure
Definition: constitutive_law.h:69
Nitsche factor based coupling condition.
Definition: coupling_nitsche_condition.h:40
Condition::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
Create with Id, pointer to geometry and pointer to property.
Definition: coupling_nitsche_condition.h:153
std::string Info() const override
Turn back information as a string.
Definition: coupling_nitsche_condition.h:298
void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
This is called during the assembling process in order to calculate the condition left hand side matri...
Definition: coupling_nitsche_condition.h:200
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Sets on rResult the ID's of the element degrees of freedom.
Definition: coupling_nitsche_condition.cpp:1337
void CalculateNitscheStabilizationMatrix(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: coupling_nitsche_condition.cpp:669
CouplingNitscheCondition(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor with Id and geometry.
Definition: coupling_nitsche_condition.h:126
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
This function provides a more general interface to the element.
Definition: coupling_nitsche_condition.h:218
CouplingNitscheCondition()
Default constructor.
Definition: coupling_nitsche_condition.h:141
void DeterminantOfJacobianInitial(const GeometryType &rGeometry, Vector &rDeterminantOfJacobian)
Definition: coupling_nitsche_condition.cpp:630
std::size_t SizeType
Size types.
Definition: coupling_nitsche_condition.h:118
Condition::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Create with Id, pointer to geometry and pointer to property.
Definition: coupling_nitsche_condition.h:164
std::size_t IndexType
Definition: coupling_nitsche_condition.h:119
KRATOS_CLASS_POINTER_DEFINITION(CouplingNitscheCondition)
Counted pointer of CouplingNitscheCondition.
void CalculateAll(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo, const bool CalculateStiffnessMatrixFlag, const bool CalculateResidualVectorFlag)
Calculates left (K) and right (u) hand sides.
Definition: coupling_nitsche_condition.cpp:290
PatchType
Definition: coupling_nitsche_condition.h:288
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: coupling_nitsche_condition.h:306
void GetValuesVector(Vector &rValues, int Step=0) const override
Definition: coupling_nitsche_condition.cpp:1302
void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
Sets on rElementalDofList the degrees of freedom of the considered element geometry.
Definition: coupling_nitsche_condition.cpp:1371
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
This is called during the assembling process in order to calculate the condition right hand side matr...
Definition: coupling_nitsche_condition.h:184
virtual ~CouplingNitscheCondition()=default
Destructor.
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: coupling_nitsche_condition.h:312
ConfigurationType
Definition: coupling_nitsche_condition.h:283
CouplingNitscheCondition(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constructor with Id, geometry and property.
Definition: coupling_nitsche_condition.h:133
std::size_t IndexType
Definition: flags.h:74
GeometryType::Pointer pGetGeometry()
Returns the pointer to the geometry.
Definition: geometrical_object.h:140
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
Geometry base class.
Definition: geometry.h:71
IndexType Id() const
Definition: indexed_object.h:107
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
def load(f)
Definition: ode_solve.py:307
Definition: constitutive_law.h:189
Definition: coupling_nitsche_condition.h:94
ConstitutiveVariables(SizeType StrainSize)
Definition: coupling_nitsche_condition.h:102
Vector StrainVector
Definition: coupling_nitsche_condition.h:95
Matrix ConstitutiveMatrix
Definition: coupling_nitsche_condition.h:97
Vector StressVector
Definition: coupling_nitsche_condition.h:96
Internal variables used for metric transformation.
Definition: coupling_nitsche_condition.h:45
array_1d< double, 3 > a2
Definition: coupling_nitsche_condition.h:52
KinematicVariables(SizeType Dimension)
Definition: coupling_nitsche_condition.h:72
array_1d< double, 3 > a1
Definition: coupling_nitsche_condition.h:50
array_1d< double, 3 > t
Definition: coupling_nitsche_condition.h:62
array_1d< double, 3 > a3
Definition: coupling_nitsche_condition.h:54
array_1d< double, 3 > a_ab_covariant
Definition: coupling_nitsche_condition.h:47
array_1d< double, 2 > n_contravariant
Definition: coupling_nitsche_condition.h:66
double dA
Definition: coupling_nitsche_condition.h:59
array_1d< double, 3 > a3_tilde
Definition: coupling_nitsche_condition.h:56
array_1d< double, 3 > n
Definition: coupling_nitsche_condition.h:64