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.
support_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_SUPPORT_NITSCHE_CONDITION_H_INCLUDED )
14 #define KRATOS_SUPPORT_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 
35  : public Condition
36  {
37  protected:
38 
41  {
42  // covariant metric
44 
45  //base vector 1
47  //base vector 2
49  //base vector 3 normalized
51  //not-normalized base vector 3
53 
54  //differential area
55  double dA;
56 
57  //the tangent to the surface vector
59  //the normal to the surface boundary vector
61  //the normal to the surface boundary vector in contravariant basis
63 
69  {
70  noalias(a_ab_covariant) = ZeroVector(Dimension);
71 
72  noalias(a1) = ZeroVector(Dimension);
73  noalias(a2) = ZeroVector(Dimension);
74  noalias(a3) = ZeroVector(Dimension);
75 
76  noalias(a3_tilde) = ZeroVector(Dimension);
77 
78  noalias(n) = ZeroVector(Dimension);
80  noalias(t) = ZeroVector(Dimension);
81 
82  dA = 1.0;
83  }
84  };
85 
90  {
94 
99  {
100  StrainVector = ZeroVector(StrainSize);
101  StressVector = ZeroVector(StrainSize);
102  ConstitutiveMatrix = ZeroMatrix(StrainSize, StrainSize);
103  }
104  };
105 
106  public:
109 
112 
114  typedef std::size_t SizeType;
115  typedef std::size_t IndexType;
116 
120 
123  IndexType NewId,
124  GeometryType::Pointer pGeometry)
125  : Condition(NewId, pGeometry)
126  {};
127 
130  IndexType NewId,
131  GeometryType::Pointer pGeometry,
132  PropertiesType::Pointer pProperties)
133  : Condition(NewId, pGeometry, pProperties)
134  {};
135 
138  : Condition()
139  {};
140 
142  virtual ~SupportNitscheCondition() = default;
143 
147 
149  Condition::Pointer Create(
150  IndexType NewId,
151  GeometryType::Pointer pGeom,
152  PropertiesType::Pointer pProperties
153  ) const override
154  {
155  return Kratos::make_intrusive<SupportNitscheCondition>(
156  NewId, pGeom, pProperties);
157  };
158 
160  Condition::Pointer Create(
161  IndexType NewId,
162  NodesArrayType const& ThisNodes,
163  PropertiesType::Pointer pProperties
164  ) const override
165  {
166  return Kratos::make_intrusive< SupportNitscheCondition >(
167  NewId, GetGeometry().Create(ThisNodes), pProperties);
168  };
169 
173 
181  VectorType& rRightHandSideVector,
182  const ProcessInfo& rCurrentProcessInfo) override
183  {
184  MatrixType left_hand_side_matrix = Matrix(0, 0);
185 
186  CalculateAll(left_hand_side_matrix, rRightHandSideVector,
187  rCurrentProcessInfo, false, true);
188  }
189 
197  MatrixType& rLeftHandSideMatrix,
198  const ProcessInfo& rCurrentProcessInfo) override
199  {
200  VectorType right_hand_side_vector = Vector(0);
201 
202  CalculateAll(rLeftHandSideMatrix, right_hand_side_vector,
203  rCurrentProcessInfo, true, false);
204  }
205 
215  MatrixType& rLeftHandSideMatrix,
216  VectorType& rRightHandSideVector,
217  const ProcessInfo& rCurrentProcessInfo) override
218  {
219  if (rCurrentProcessInfo[BUILD_LEVEL] == 2)
220  {
221  CalculateNitscheStabilizationMatrix(rLeftHandSideMatrix, rRightHandSideVector,
222  rCurrentProcessInfo);
223  }
224  else
225  {
226  CalculateAll(rLeftHandSideMatrix, rRightHandSideVector,
227  rCurrentProcessInfo, true, true);
228  }
229 
230  }
231 
237  void EquationIdVector(
238  EquationIdVectorType& rResult,
239  const ProcessInfo& rCurrentProcessInfo
240  ) const override;
241 
247  void GetDofList(
248  DofsVectorType& rElementalDofList,
249  const ProcessInfo& rCurrentProcessInfo
250  ) const override;
251 
253  void CalculateAll(
254  MatrixType& rLeftHandSideMatrix,
255  VectorType& rRightHandSideVector,
256  const ProcessInfo& rCurrentProcessInfo,
257  const bool CalculateStiffnessMatrixFlag,
258  const bool CalculateResidualVectorFlag
259  );
260 
262  MatrixType& rLeftHandSideMatrix,
263  VectorType& rRightHandSideVector,
264  const ProcessInfo& rCurrentProcessInfo
265  );
266 
268  const GeometryType& rGeometry,
269  Vector& rDeterminantOfJacobian);
270 
274 
275  void GetValuesVector(
276  Vector& rValues,
277  int Step = 0) const override;
278 
279  enum class ConfigurationType {
280  Current,
281  Reference
282  };
283 
287 
289  std::string Info() const override
290  {
291  std::stringstream buffer;
292  buffer << "\"SupportNitscheCondition\" #" << Id();
293  return buffer.str();
294  }
295 
297  void PrintInfo(std::ostream& rOStream) const override
298  {
299  rOStream << "\"SupportNitscheCondition\" #" << Id();
300  }
301 
303  void PrintData(std::ostream& rOStream) const override {
304  pGetGeometry()->PrintData(rOStream);
305  }
306 
308 
309  private:
310 
313 
314  // Components of the metric coefficient tensor on the contravariant basis
315  std::vector<array_1d<double, 3>> m_A_ab_covariant_vector;
316 
317  // Determinant of the geometrical Jacobian.
318  Vector m_dA_vector;
319 
320  /* Transformation the strain tensor from the curvilinear system
321  * to the local cartesian in voigt notation including a 2 in the
322  * shear part. */
323  std::vector<Matrix> m_T_vector;
324 
325  /* Transformation the stress tensor from the local cartesian
326  * to the curvilinear system in voigt notation. */
327  std::vector<Matrix> m_T_hat_vector;
328 
329  // The reference contravariant basis vector
330  std::vector<array_1d< array_1d<double, 3>,2>> m_reference_contravariant_base;
331 
332  // The normal to the boundary vector
333  std::vector<array_1d<double, 2>> m_n_contravariant_vector;
334 
335  void CalculateKinematics(
336  IndexType IntegrationPointIndex,
337  KinematicVariables& rKinematicVariables,
338  const Matrix& rShapeFunctionGradientValues, const ConfigurationType& rConfiguration);
339 
340  // Computes transformation
341  void CalculateTransformation(
342  const KinematicVariables& rKinematicVariables,
343  Matrix& rT, Matrix& rT_hat, array_1d<array_1d<double, 3>,2>& rReferenceContraVariantBase);
344 
346  // Computes the traction
347  void CalculateTraction(
348  IndexType IntegrationPointIndex,
349  array_1d<double, 3>& rTraction,
350  const KinematicVariables& rActualKinematic,
351  ConstitutiveVariables& rThisConstitutiveVariablesMembrane);
352 
353  // Computes the first derivatives of the stresses at the covariant bases
354  void CalculateFirstVariationStressCovariant(
355  IndexType IntegrationPointIndex,
356  Matrix& rFirstVariationStressCovariant,
357  const KinematicVariables& rActualKinematic,
358  ConstitutiveVariables& rThisConstitutiveVariablesMembrane);
359 
360  // Computes the first derivatives of traction
361  void CalculateFirstVariationTraction(
362  IndexType IntegrationPointIndex,
363  Matrix& rFirstVariationTraction,
364  Matrix& rFirstVariationStressCovariant,
365  const KinematicVariables& rActualKinematic,
366  ConstitutiveVariables& rThisConstitutiveVariablesMembrane);
367 
368  // Computes the necessary products needed for second derivatives of traction
369  void CalculateSecondVariationTractionProduct(
370  IndexType IntegrationPointIndex,
371  Matrix& rPi,
372  const KinematicVariables& rActualKinematic,
373  ConstitutiveVariables& rThisConstitutiveVariablesMembrane);
374 
375  // Computes the second derivatives of traction
376  void CalculateSecondVariationTraction(
377  IndexType IntegrationPointIndex,
378  Matrix& rSecondVariationTraction,
379  const KinematicVariables& rActualKinematic,
380  Matrix& rFirstVariationStressCovariant,
381  array_1d<double, 3>& rDisplacement,
382  array_1d<double, 3>& rSecondVariationTractionProduct);
383 
391  void CalculateConstitutiveVariables(
392  IndexType IntegrationPointIndex,
393  KinematicVariables& rActualMetric,
394  ConstitutiveVariables& rThisConstitutiveVariablesMembrane,
396  const ConstitutiveLaw::StressMeasure ThisStressMeasure
397  );
398 
404  void CalculateTransformationPrestress(
405  Matrix& rTransformationPrestress,
406  const KinematicVariables& rActualKinematic
407  );
408 
412 
413  friend class Serializer;
414 
415  virtual void save(Serializer& rSerializer) const override
416  {
418  rSerializer.save("A_ab_covariant_vector", m_A_ab_covariant_vector);
419  rSerializer.save("dA_vector", m_dA_vector);
420  rSerializer.save("T_vector", m_T_vector);
421  rSerializer.save("reference_contravariant_base", m_reference_contravariant_base);
422  }
423 
424  virtual void load(Serializer& rSerializer) override
425  {
427  rSerializer.load("A_ab_covariant_vector", m_A_ab_covariant_vector);
428  rSerializer.load("dA_vector", m_dA_vector);
429  rSerializer.load("T_vector", m_T_vector);
430  rSerializer.load("reference_contravariant_base", m_reference_contravariant_base);
431  }
432 
434 
435  }; // Class SupportNitscheCondition
436 
437 } // namespace Kratos.
438 
439 #endif // KRATOS_SUPPORT_NITSCHE_CONDITION_H_INCLUDED defined
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
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
Nitsche-type based support condition.
Definition: support_nitsche_condition.h:36
std::size_t IndexType
Definition: support_nitsche_condition.h:115
KRATOS_CLASS_POINTER_DEFINITION(SupportNitscheCondition)
Counted pointer of SupportNitscheCondition.
ConfigurationType
Definition: support_nitsche_condition.h:279
void CalculateAll(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo, const bool CalculateStiffnessMatrixFlag, const bool CalculateResidualVectorFlag)
Calculates left (K) and right (u) hand sides.
Definition: support_nitsche_condition.cpp:254
void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
Sets on rElementalDofList the degrees of freedom of the considered element geometry.
Definition: support_nitsche_condition.cpp:962
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: support_nitsche_condition.h:180
void GetValuesVector(Vector &rValues, int Step=0) const override
Definition: support_nitsche_condition.cpp:915
void CalculateNitscheStabilizationMatrix(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: support_nitsche_condition.cpp:517
std::size_t SizeType
Size types.
Definition: support_nitsche_condition.h:114
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
This function provides a more general interface to the element.
Definition: support_nitsche_condition.h:214
void DeterminantOfJacobianInitial(const GeometryType &rGeometry, Vector &rDeterminantOfJacobian)
Definition: support_nitsche_condition.cpp:479
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: support_nitsche_condition.h:297
std::string Info() const override
Turn back information as a string.
Definition: support_nitsche_condition.h:289
SupportNitscheCondition(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constructor with Id, geometry and property.
Definition: support_nitsche_condition.h:129
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: support_nitsche_condition.h:196
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Sets on rResult the ID's of the element degrees of freedom.
Definition: support_nitsche_condition.cpp:938
Condition::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
Create with Id, pointer to geometry and pointer to property.
Definition: support_nitsche_condition.h:149
SupportNitscheCondition(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor with Id and geometry.
Definition: support_nitsche_condition.h:122
SupportNitscheCondition()
Default constructor.
Definition: support_nitsche_condition.h:137
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: support_nitsche_condition.h:303
virtual ~SupportNitscheCondition()=default
Destructor.
Condition::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Create with Id, pointer to geometry and pointer to property.
Definition: support_nitsche_condition.h:160
#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: support_nitsche_condition.h:90
Vector StrainVector
Definition: support_nitsche_condition.h:91
ConstitutiveVariables(SizeType StrainSize)
Definition: support_nitsche_condition.h:98
Matrix ConstitutiveMatrix
Definition: support_nitsche_condition.h:93
Vector StressVector
Definition: support_nitsche_condition.h:92
Internal variables used for metric transformation.
Definition: support_nitsche_condition.h:41
array_1d< double, 3 > n
Definition: support_nitsche_condition.h:60
array_1d< double, 3 > a1
Definition: support_nitsche_condition.h:46
array_1d< double, 3 > a3
Definition: support_nitsche_condition.h:50
array_1d< double, 3 > t
Definition: support_nitsche_condition.h:58
double dA
Definition: support_nitsche_condition.h:55
array_1d< double, 2 > n_contravariant
Definition: support_nitsche_condition.h:62
KinematicVariables(SizeType Dimension)
Definition: support_nitsche_condition.h:68
array_1d< double, 3 > a2
Definition: support_nitsche_condition.h:48
array_1d< double, 3 > a3_tilde
Definition: support_nitsche_condition.h:52
array_1d< double, 3 > a_ab_covariant
Definition: support_nitsche_condition.h:43