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.
truss_element.h
Go to the documentation of this file.
1 // KRATOS _____________
2 // / _/ ____/ |
3 // / // / __/ /| |
4 // _/ // /_/ / ___ |
5 // /___/\____/_/ |_| Application
6 
7 
8 #if !defined(KRATOS_TRUSS_ELEMENT_H_INCLUDED)
9 #define KRATOS_TRUSS_ELEMENT_H_INCLUDED
10 
11 // System includes
12 
13 // External includes
14 
15 // Project includes
16 #include "includes/define.h"
17 #include "includes/element.h"
18 
19 // Application includes
21 
22 namespace Kratos
23 {
24 
26  : public Element
27 {
28 public:
31 
33 
35  typedef std::size_t SizeType;
36  typedef std::size_t IndexType;
37 
41 
44  IndexType NewId,
45  GeometryType::Pointer pGeometry)
46  : Element(NewId, pGeometry)
47  {};
48 
51  IndexType NewId,
52  GeometryType::Pointer pGeometry,
53  PropertiesType::Pointer pProperties)
54  : Element(NewId, pGeometry, pProperties)
55  {};
56 
59  : Element()
60  {};
61 
63  ~TrussElement() override = default;
64 
68 
70  Element::Pointer Create(
71  IndexType NewId,
72  GeometryType::Pointer pGeom,
73  PropertiesType::Pointer pProperties
74  ) const override
75  {
76  return Kratos::make_intrusive<TrussElement>(
77  NewId, pGeom, pProperties);
78  };
79 
81  Element::Pointer Create(
82  IndexType NewId,
83  NodesArrayType const& ThisNodes,
84  PropertiesType::Pointer pProperties
85  ) const override
86  {
87  return Kratos::make_intrusive<TrussElement>(
88  NewId, GetGeometry().Create(ThisNodes), pProperties);
89  };
90 
94 
96  void GetDofList(
97  DofsVectorType& rElementalDofList,
98  const ProcessInfo& rCurrentProcessInfo
99  ) const override;
100 
102  void EquationIdVector(
103  EquationIdVectorType& rResult,
104  const ProcessInfo& rCurrentProcessInfo
105  ) const override;
106 
110 
111  void Initialize(const ProcessInfo& rCurrentProcessInfo) override;
112 
115  VectorType& rRightHandSideVector,
116  const ProcessInfo& rCurrentProcessInfo) override
117  {
118  const SizeType nb_nodes = GetGeometry().size();
119  const SizeType nb_dofs = nb_nodes * 3;
120 
121  if (rRightHandSideVector.size() != nb_dofs)
122  rRightHandSideVector.resize(nb_dofs);
123  noalias(rRightHandSideVector) = ZeroVector(nb_dofs);
124 
125  MatrixType left_hand_side_matrix;
126 
127  CalculateAll(left_hand_side_matrix, rRightHandSideVector,
128  rCurrentProcessInfo, false, true);
129  }
130 
133  MatrixType& rLeftHandSideMatrix,
134  const ProcessInfo& rCurrentProcessInfo) override
135  {
136  const SizeType nb_nodes = GetGeometry().size();
137  const SizeType nb_dofs = nb_nodes * 3;
138 
139  VectorType right_hand_side_vector;
140 
141  if (rLeftHandSideMatrix.size1() != nb_dofs && rLeftHandSideMatrix.size2() != nb_dofs)
142  rLeftHandSideMatrix.resize(nb_dofs, nb_dofs);
143  noalias(rLeftHandSideMatrix) = ZeroMatrix(nb_dofs, nb_dofs);
144 
145  CalculateAll(rLeftHandSideMatrix, right_hand_side_vector,
146  rCurrentProcessInfo, true, false);
147  }
148 
151  MatrixType& rLeftHandSideMatrix,
152  VectorType& rRightHandSideVector,
153  const ProcessInfo& rCurrentProcessInfo) override
154  {
155  const SizeType nb_nodes = GetGeometry().size();
156  const SizeType nb_dofs = nb_nodes * 3;
157 
158  if (rRightHandSideVector.size() != nb_dofs)
159  rRightHandSideVector.resize(nb_dofs);
160  noalias(rRightHandSideVector) = ZeroVector(nb_dofs);
161 
162  if (rLeftHandSideMatrix.size1() != nb_dofs && rLeftHandSideMatrix.size2() != nb_dofs)
163  rLeftHandSideMatrix.resize(nb_dofs, nb_dofs);
164  noalias(rLeftHandSideMatrix) = ZeroMatrix(nb_dofs, nb_dofs);
165 
166  CalculateAll(rLeftHandSideMatrix, rRightHandSideVector,
167  rCurrentProcessInfo, true, true);
168  }
169 
170  void CalculateAll(
171  MatrixType& rLeftHandSideMatrix,
172  VectorType& rRightHandSideVector,
173  const ProcessInfo& rCurrentProcessInfo,
174  const bool ComputeLeftHandSide,
175  const bool ComputeRightHandSide);
176 
179  const ProcessInfo& rCurrentProcessInfo) override;
180 
184 
185  void CalculateBodyForces(Vector& rBodyForces);
186 
187  bool HasSelfWeight() const;
188 
192 
194  const VectorType& rRHSVector,
195  const Variable<VectorType>& rRHSVariable,
196  const Variable<double >& rDestinationVariable,
197  const ProcessInfo& rCurrentProcessInfo) override;
198 
200  const VectorType& rRHSVector, const Variable<VectorType>& rRHSVariable,
201  const Variable<array_1d<double, 3>>& rDestinationVariable,
202  const ProcessInfo& rCurrentProcessInfo) override;
203 
207 
209  MatrixType& rDampingMatrix,
210  const ProcessInfo& rCurrentProcessInfo) override;
211 
213  void CalculateMassMatrix(
214  MatrixType& rMassMatrix,
215  const ProcessInfo& rCurrentProcessInfo) override;
216 
219  VectorType &rLumpedMassVector,
220  const ProcessInfo &rCurrentProcessInfo) const override;
221 
223  void GetValuesVector(
224  Vector& rValues,
225  int Step = 0) const override;
226 
229  Vector& rValues,
230  int Step = 0) const override;
231 
234  Vector& rValues,
235  int Step = 0) const override;
236 
240 
242  const Variable<double>& rVariable,
243  std::vector<double>& rOutput,
244  const ProcessInfo& rCurrentProcessInfo) override;
245 
249 
251  int Check(const ProcessInfo& rCurrentProcessInfo) const override;
252 
253  void PrintInfo(std::ostream& rOStream) const override {
254  rOStream << "\"TrussElement\" #" << Id()
255  << " with geometry #" << this->GetGeometry().Id() << " with center in: "
256  << this->GetGeometry().Center() << std::endl;
257  }
258 
260 private:
263 
264  std::vector<array_1d<double, 3>> mReferenceBaseVector;
265 
267  std::vector<ConstitutiveLaw::Pointer> mConstitutiveLawVector;
268 
272 
274  void InitializeMaterial();
275 
277  array_1d<double, 3> CalculateActualBaseVector(IndexType IntegrationPointIndex) const;
278 
280  void CalculateGreenLagrangeStrain(
281  std::vector<double>& rGreenLagrangeVector) const;
282 
283  void CalculateTangentModulus(
284  std::vector<double>& rTangentModulusVector,
285  const ProcessInfo& rCurrentProcessInfo);
286 
288  double CalculatePrestressPK2(double reference_a, double actual_a) const;
289 
291  void CalculateStressPK2(
292  std::vector<double>& rStressVector,
293  const ProcessInfo& rCurrentProcessInfo) const;
294 
296  void CalculateStressCauchy(
297  std::vector<double>& rStressVector,
298  const ProcessInfo& rCurrentProcessInfo) const;
299 
303 
304  friend class Serializer;
305 
306  void save(Serializer& rSerializer) const override
307  {
309  rSerializer.save("ReferenceBaseVector", mReferenceBaseVector);
310  rSerializer.save("ConstitutiveLawVector", mConstitutiveLawVector);
311  }
312  void load(Serializer& rSerializer) override
313  {
315  rSerializer.load("ReferenceBaseVector", mReferenceBaseVector);
316  rSerializer.load("ConstitutiveLawVector", mConstitutiveLawVector);
317  }
318 
320 };
321 
322 } // namespace Kratos
323 
324 #endif // !defined(KRATOS_TRUSS_ELEMENT_H_INCLUDED)
Base class for all Elements.
Definition: element.h:60
std::size_t SizeType
Definition: element.h:94
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
Matrix MatrixType
Definition: element.h:90
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
std::size_t IndexType
Definition: flags.h:74
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
SizeType size() const
Definition: geometry.h:518
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
virtual Point Center() const
Definition: geometry.h:1514
IndexType Id() const
Definition: indexed_object.h:107
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
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
Definition: truss_element.h:27
void Initialize(const ProcessInfo &rCurrentProcessInfo) override
Definition: truss_element.cpp:63
void GetValuesVector(Vector &rValues, int Step=0) const override
Get Displacemnts.
Definition: truss_element.cpp:582
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Computes RHS.
Definition: truss_element.h:114
Element::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Create with Id, pointer to geometry and pointer to property.
Definition: truss_element.h:81
void GetSecondDerivativesVector(Vector &rValues, int Step=0) const override
Get Accelerations.
Definition: truss_element.cpp:620
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Computes LHS and RHS.
Definition: truss_element.h:150
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Sets the ID's of the element degrees of freedom.
Definition: truss_element.cpp:20
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Check provided parameters.
Definition: truss_element.cpp:680
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(TrussElement)
void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
Computes LHS.
Definition: truss_element.h:132
std::size_t IndexType
Definition: truss_element.h:36
void CalculateAll(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo, const bool ComputeLeftHandSide, const bool ComputeRightHandSide)
Definition: truss_element.cpp:111
void FinalizeSolutionStep(const ProcessInfo &rCurrentProcessInfo) override
Updates the constitutive law.
Definition: truss_element.cpp:205
Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
Create with Id, pointer to geometry and pointer to property.
Definition: truss_element.h:70
bool HasSelfWeight() const
Checks if volume acceleration is bigger than 0.
Definition: truss_element.cpp:393
void AddExplicitContribution(const VectorType &rRHSVector, const Variable< VectorType > &rRHSVariable, const Variable< double > &rDestinationVariable, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to make the element to assemble an rRHS vector identified by a variable rRH...
Definition: truss_element.cpp:405
TrussElement(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor using an array of nodes.
Definition: truss_element.h:43
void CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo) override
Calculates the mass matrix with use of the lumped mass vector.
Definition: truss_element.cpp:525
~TrussElement() override=default
Destructor.
void GetFirstDerivativesVector(Vector &rValues, int Step=0) const override
Get Velocities.
Definition: truss_element.cpp:601
void CalculateOnIntegrationPoints(const Variable< double > &rVariable, std::vector< double > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: truss_element.cpp:643
void CalculateLumpedMassVector(VectorType &rLumpedMassVector, const ProcessInfo &rCurrentProcessInfo) const override
Calculates lumped mass vector.
Definition: truss_element.cpp:549
void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
Relates the degrees of freedom of the element geometry.
Definition: truss_element.cpp:41
void CalculateDampingMatrix(MatrixType &rDampingMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: truss_element.cpp:487
TrussElement()
Default constructor necessary for serialization.
Definition: truss_element.h:58
TrussElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constructor using an array of nodes with properties.
Definition: truss_element.h:50
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: truss_element.h:253
void CalculateBodyForces(Vector &rBodyForces)
Definition: truss_element.cpp:357
std::size_t SizeType
Size types.
Definition: truss_element.h:35
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#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
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
def load(f)
Definition: ode_solve.py:307