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.
generic_total_lagrangian_femdem_element.h
Go to the documentation of this file.
1 // KRATOS ___| | | |
2 // \___ \ __| __| | | __| __| | | __| _` | |
3 // | | | | | ( | | | | ( | |
4 // _____/ \__|_| \__,_|\___|\__|\__,_|_| \__,_|_| MECHANICS
5 //
6 // License: BSD License
7 // Kratos default license: kratos/license.txt
8 //
9 // Main authors: Riccardo Rossi
10 // Vicente Mataix Ferrandiz
11 // Alejandro Cornejo
12 //
13 
14 
15 #pragma once
16 
17 
18 // System includes
19 
20 
21 // External include
22 
23 // Project includes
24 #include "includes/define.h"
25 #include "custom_elements/base_solid_element.h"
26 #include "includes/variables.h"
27 #include "custom_utilities/constitutive_law_utilities.h"
28 
29 namespace Kratos
30 {
39 
43 
47 
57 template<unsigned int TDim, unsigned int TyieldSurf>
58 class KRATOS_API(FEM_TO_DEM_APPLICATION) GenericTotalLagrangianFemDemElement
59  : public BaseSolidElement
60 {
61 public:
64 
67 
69  typedef ConstitutiveLawType::Pointer ConstitutiveLawPointerType;
70 
73 
76 
78  typedef std::size_t IndexType;
79 
81  typedef std::size_t SizeType;
82 
84 
86 
88 
90  static constexpr double tolerance = std::numeric_limits<double>::epsilon();
91 
93  static constexpr SizeType VoigtSize = (TDim == 3) ? 6 : 3;
94 
96  static constexpr SizeType NumberOfEdges = (TDim == 3) ? 6 : 3;
97 
100 
104 
106  GenericTotalLagrangianFemDemElement(IndexType NewId, GeometryType::Pointer pGeometry);
107  GenericTotalLagrangianFemDemElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties);
108 
109  // Copy constructor
111  : BaseSolidElement(rOther)
112  {};
113 
116 
123 
131  Element::Pointer Create(
132  IndexType NewId,
133  GeometryType::Pointer pGeom,
134  PropertiesType::Pointer pProperties
135  ) const override;
136 
144  Element::Pointer Create(
145  IndexType NewId,
146  NodesArrayType const& ThisNodes,
147  PropertiesType::Pointer pProperties
148  ) const override;
149 
157  Element::Pointer Clone(
158  IndexType NewId,
159  NodesArrayType const& rThisNodes
160  ) const override;
161 
169  // int Check(const ProcessInfo& rCurrentProcessInfo) override;
170 
171  //std::string Info() const;
172 
173  void CalculateSensitivityMatrix(const Variable<array_1d<double, 3>>& rDesignVariable,
174  Matrix& rOutput,
175  const ProcessInfo& rCurrentProcessInfo) override;
176 
180 
187 
189  std::string Info() const override
190  {
191  std::stringstream buffer;
192  buffer << "Total Lagrangian FEMDEM Solid Element #" << Id();
193  return buffer.str();
194  }
195 
197  void PrintInfo(std::ostream& rOStream) const override
198  {
199  rOStream << "Total Lagrangian FEMDEM Solid Element #" << Id();
200  }
201 
203  void PrintData(std::ostream& rOStream) const override
204  {
205  pGetGeometry()->PrintData(rOStream);
206  }
207 
212 
213 protected:
214 
218  Vector mThresholds; // Stress mThreshold on edge
219  Vector mDamages; // Converged Damage on each edge
220 
221  double mThreshold = 0.0; // Converged Threshold
222  double mDamage = 0.0; // Converged Damage
225 
229 
231  {
232  }
233 
242  void CalculateAll(
243  MatrixType& rLeftHandSideMatrix,
244  VectorType& rRightHandSideVector,
245  const ProcessInfo& rCurrentProcessInfo,
246  const bool CalculateStiffnessMatrixFlag,
247  const bool CalculateResidualVectorFlag) override;
248 
255  void CalculateKinematicVariables(
256  KinematicVariables& rThisKinematicVariables,
257  const IndexType PointNumber,
258  const GeometryType::IntegrationMethod& rIntegrationMethod) override;
259 
260  // ************** Methods to compute the tangent constitutive tensor via numerical derivation **************
264  void CalculateTangentTensor(Matrix& rTangentTensor, const Vector& rStrainVectorGP, const Vector& rStressVectorGP, const Matrix& rDeformationGradientGP, const Matrix& rElasticMatrix, ConstitutiveLaw::Parameters& rValues);
265  void CalculateTangentTensorSecondOrder(Matrix& rTangentTensor, const Vector& rStrainVectorGP, const Vector& rStressVectorGP, const Matrix& rDeformationGradientGP, const Matrix& rElasticMatrix, ConstitutiveLaw::Parameters& rValues);
266 
270  void CalculatePerturbation(const Vector& rStrainVectorGP, double& rPerturbation, const int Component);
271 
275  void PerturbateStrainVector(Vector& rPerturbedStrainVector, const Vector& rStrainVectorGP, const double Perturbation, const int Component);
276 
280  virtual void IntegratePerturbedStrain(Vector& rPerturbedStressVector, const Vector& rPerturbedStrainVector, const Matrix& rElasticMatrix, ConstitutiveLaw::Parameters& rValues);
281 
285  void AssignComponentsToTangentTensor(Matrix& rTangentTensor, const Vector& rDeltaStress, const double Perturbation, const int Component);
286 
290  void PerturbateDeformationGradient(Matrix& rPerturbedDeformationGradient, const Matrix& rDeformationGradientGP, const double Perturbation, const int ComponentI, const int ComponentJ);
291 
295  int CalculateVoigtIndex(const SizeType VoigtSize, const int ComponentI, const int ComponentJ);
296 
300  double CalculateElementalDamage(const Vector& rEdgeDamages);
301  double CalculateElementalDamage3D(const Vector& rEdgeDamages);
302  double CalculateElementalDamage2D(const Vector& rEdgeDamages);
303 
307  void IntegrateStressDamageMechanics(double& rThreshold,double& rDamage, const Vector& rStrainVector,
308  const Vector& rStressVector, const int Edge, const double CharacteristicLength,
309  ConstitutiveLaw::Parameters& rValues, bool& rIsDamaging);
310 
314  virtual Vector IntegrateSmoothedConstitutiveLaw(const std::string &rYieldSurface, ConstitutiveLaw::Parameters &rValues,
315  const ConstitutiveVariables &rThisConstVars, const KinematicVariables &rKinVariables,
316  Vector &rStrainVector, double& rDamageElement, bool& rIsDamaging, const double CharacteristicLength,
317  const bool SaveIntVars);
318 
322  void ComputeEdgeNeighbours(const ProcessInfo& rCurrentProcessInfo);
323 
327  void AuxComputeEdgeNeighbours(const ProcessInfo& rCurrentProcessInfo);
328 
332  std::vector<Element*> GetEdgeNeighbourElements(const int edge) {return mEdgeNeighboursContainer[edge];}
333 
337  void SaveEdgeNeighboursContainer(const std::vector<std::vector<Element*>>& rtoSave) {mEdgeNeighboursContainer = rtoSave;}
338 
343  void SetNodeIndexes(Matrix& rMatrix)
344  {
345  rMatrix.resize(6, 2);
346  rMatrix(0, 0) = 0; rMatrix(0, 1) = 1; rMatrix(1, 0) = 0;
347  rMatrix(1, 1) = 2; rMatrix(2, 0) = 0; rMatrix(2, 1) = 3;
348  rMatrix(3, 0) = 1; rMatrix(3, 1) = 2; rMatrix(4, 0) = 1;
349  rMatrix(4, 1) = 3; rMatrix(5, 0) = 2; rMatrix(5, 1) = 3;
350  }
351 
352 
356  void CalculateAverageVariableOnEdge(const Element* pCurrentElement, const Variable<Vector>& rThisVariable, Vector& rAverageStress, const int edge);
357  void CalculateAverageVariableOnEdge2D(const Element* pCurrentElement, const Variable<Vector>& rThisVariable, Vector& rAverageStress, const int edge);
358  void CalculateAverageVariableOnEdge3D(const Element* pCurrentElement, const Variable<Vector>& rThisVariable, Vector& rAverageStress, const int edge);
359 
363  void CalculateEquivalentStress(const array_1d<double, VoigtSize>& rPredictiveStressVector, const Vector& rStrainVector, double& rEquivalentStress, ConstitutiveLaw::Parameters& rValues);
364 
368  void GetInitialUniaxialThreshold(ConstitutiveLaw::Parameters& rValues, double& rThreshold);
369 
373  void CalculateDamageParameter(ConstitutiveLaw::Parameters& rValues, double& rAParameter, const double CharacteristicLength);
374 
378  double CalculateCharacteristicLength(GenericTotalLagrangianFemDemElement *pCurrentElement);
379 
383  void CalculateExponentialDamage(double& rDamage, const double DamageParameter, const double UniaxialStress, const double InitialThrehsold);
384 
388  void CalculateGreenLagrangeStrainVector(Vector& rStrainVector, const Matrix& rF);
389 
390  std::size_t GetStrainSize() const;
391 
393  const Variable<double> &rVariable,
394  const std::vector<double> &rValues,
395  const ProcessInfo &rCurrentProcessInfo) override;
396 
398  const Variable<double> &rVariable,
399  std::vector<double> &rOutput,
400  const ProcessInfo &rCurrentProcessInfo) override;
401 
403  const Variable<Vector>& rVariable,
404  std::vector<Vector>& rOutput,
405  const ProcessInfo& rCurrentProcessInfo) override;
406 
408  const Variable<Matrix>& rVariable,
409  std::vector<Matrix>& rOutput,
410  const ProcessInfo& rCurrentProcessInfo) override;
411 
412 
413  virtual void CheckIfEraseElement(
414  const ProcessInfo &rCurrentProcessInfo,
415  const Properties& rProperties)
416  {
417  const double max_damage = 0.98;
418  if (mDamage >= max_damage) {
419  this->Set(ACTIVE, false);
420  mDamage = max_damage;
421  this->SetValue(GENERATE_DEM, true);
422  }
423  }
424 
438 
439 private:
442 
446 
450 
454 
458  void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override;
459 
463  void FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override;
464 
468  void InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override;
469 
470 
477  void CalculateB(Matrix& rB, Matrix const& rF, const Matrix& rDN_DX);
478 
479  void Calculate2DB(Matrix& rB, const Matrix& rF, const Matrix& rDN_DX);
480 
481  void Calculate3DB(Matrix& rB, const Matrix& rF, const Matrix& rDN_DX);
482 
483  void CalculateStress(Vector& rStrain,
484  std::size_t IntegrationPoint,
485  Vector& rStress,
486  ProcessInfo const& rCurrentProcessInfo);
487 
488  void CalculateStress(Matrix const& rF,
489  std::size_t IntegrationPoint,
490  Vector& rStress,
491  ProcessInfo const& rCurrentProcessInfo);
492 
493  void CalculateStrain(Matrix const& rF,
494  std::size_t IntegrationPoint,
495  Vector& rStrain,
496  ProcessInfo const& rCurrentProcessInfo);
497 
498  void CalculateShapeSensitivity(ShapeParameter Deriv,
499  Matrix& rDN_DX0,
500  Matrix& rDN_DX0_Deriv,
501  Matrix& rF_Deriv,
502  double& rDetJ0_Deriv,
503  std::size_t IntegrationPointIndex);
504 
505  void CalculateBSensitivity(Matrix const& rDN_DX,
506  Matrix const& rF,
507  Matrix const& rDN_DX_Deriv,
508  Matrix const& rF_Deriv,
509  Matrix& rB_Deriv);
510 
515 
516  // Vector to storage the neigh elements sharing a certain edge
517  std::vector<std::vector<Element*>> mEdgeNeighboursContainer;
518 
522  friend class Serializer;
523 
524  // A private default constructor necessary for serialization
525 
526  void save(Serializer& rSerializer) const override;
527 
528  void load(Serializer& rSerializer) override;
529 
530 }; // Class GenericTotalLagrangianFemDemElement
531 
532 template<unsigned int TDim, unsigned int TyieldSurf> constexpr SizeType GenericTotalLagrangianFemDemElement<TDim, TyieldSurf>::VoigtSize;
533 template<unsigned int TDim, unsigned int TyieldSurf> constexpr SizeType GenericTotalLagrangianFemDemElement<TDim, TyieldSurf>::NumberOfEdges;
534 
535 
543 
544 } // namespace Kratos.
This is base class used to define the solid elements.
Definition: base_solid_element.h:67
Definition: constitutive_law.h:47
Base class for all Elements.
Definition: element.h:60
std::size_t IndexType
Definition: flags.h:74
Total Lagrangian element for 2D and 3D geometries.
Definition: generic_total_lagrangian_femdem_element.h:60
GenericTotalLagrangianFemDemElement()
Definition: generic_total_lagrangian_femdem_element.h:230
GeometryData::IntegrationMethod IntegrationMethod
Type definition for integration methods.
Definition: generic_total_lagrangian_femdem_element.h:72
void GetInitialUniaxialThreshold(ConstitutiveLaw::Parameters &rValues, double &rThreshold)
Geometry< NodeType >::PointsArrayType NodesArrayType
Definition: generic_total_lagrangian_femdem_element.h:83
Vector mThresholds
Definition: generic_total_lagrangian_femdem_element.h:218
void CalculateDamageParameter(ConstitutiveLaw::Parameters &rValues, double &rAParameter, const double CharacteristicLength)
std::vector< Element * > GetEdgeNeighbourElements(const int edge)
Definition: generic_total_lagrangian_femdem_element.h:332
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(GenericTotalLagrangianFemDemElement)
Counted pointer of GenericTotalLagrangianFemDemElement.
void ComputeEdgeNeighbours(const ProcessInfo &rCurrentProcessInfo)
ConstitutiveLaw ConstitutiveLawType
Reference type definition for constitutive laws.
Definition: generic_total_lagrangian_femdem_element.h:66
virtual void CheckIfEraseElement(const ProcessInfo &rCurrentProcessInfo, const Properties &rProperties)
Definition: generic_total_lagrangian_femdem_element.h:413
void SaveEdgeNeighboursContainer(const std::vector< std::vector< Element * >> &rtoSave)
Definition: generic_total_lagrangian_femdem_element.h:337
void SetNodeIndexes(Matrix &rMatrix)
Definition: generic_total_lagrangian_femdem_element.h:343
std::string Info() const override
Turn back information as a string.
Definition: generic_total_lagrangian_femdem_element.h:189
BaseSolidElement BaseType
The base element type.
Definition: generic_total_lagrangian_femdem_element.h:75
double CalculateElementalDamage(const Vector &rEdgeDamages)
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: generic_total_lagrangian_femdem_element.h:197
Vector mDamages
Definition: generic_total_lagrangian_femdem_element.h:219
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: generic_total_lagrangian_femdem_element.h:203
void CalculateAverageVariableOnEdge(const Element *pCurrentElement, const Variable< Vector > &rThisVariable, Vector &rAverageStress, const int edge)
ConstitutiveLawType::Pointer ConstitutiveLawPointerType
Pointer type for constitutive laws.
Definition: generic_total_lagrangian_femdem_element.h:69
Properties PropertiesType
Definition: generic_total_lagrangian_femdem_element.h:85
std::size_t IndexType
The definition of the index type.
Definition: generic_total_lagrangian_femdem_element.h:78
Geometry< NodeType > GeometryType
Definition: generic_total_lagrangian_femdem_element.h:87
GenericTotalLagrangianFemDemElement(GenericTotalLagrangianFemDemElement const &rOther)
Definition: generic_total_lagrangian_femdem_element.h:110
void CalculateEquivalentStress(const array_1d< double, VoigtSize > &rPredictiveStressVector, const Vector &rStrainVector, double &rEquivalentStress, ConstitutiveLaw::Parameters &rValues)
std::size_t SizeType
The definition of the sizetype.
Definition: generic_total_lagrangian_femdem_element.h:81
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
Short class definition.
Definition: integration_point.h:52
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
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
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
Matrix MatrixType
Definition: geometrical_transformation_utilities.h:55
Modeler::Pointer Create(const std::string &ModelerName, Model &rModel, const Parameters ModelParameters)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:30
void SetValuesOnIntegrationPoints(TObject &dummy, const Variable< TDataType > &rVariable, const std::vector< TDataType > &values, const ProcessInfo &rCurrentProcessInfo)
Definition: add_mesh_to_python.cpp:185
pybind11::list CalculateOnIntegrationPoints(TObject &dummy, const Variable< TDataType > &rVariable, const ProcessInfo &rProcessInfo)
Definition: add_mesh_to_python.cpp:142
void InitializeSolutionStep(ConstructionUtility &rThisUtil, std::string ThermalSubModelPartName, std::string MechanicalSubModelPartName, std::string HeatFluxSubModelPartName, std::string HydraulicPressureSubModelPartName, bool thermal_conditions, bool mechanical_conditions, int phase)
Definition: add_custom_utilities_to_python.cpp:45
void CalculateB(const GeometricalObject &rElement, const TMatrixType1 &rDN_DX, TMatrixType2 &rB)
This method computes the deformation tensor B (for small deformation solid elements)
Definition: structural_mechanics_element_utilities.h:105
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
ModelPart::NodesContainerType NodesArrayType
Definition: gid_gauss_point_container.h:42
def SetValue(entity, variable, value)
Definition: coupling_interface_data.py:256
def load(f)
Definition: ode_solve.py:307
Definition: base_solid_element.h:112
Definition: base_solid_element.h:73
Definition: constitutive_law.h:189
Definition: geometrical_sensitivity_utility.h:33