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.
fluid_adjoint_element.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: Suneth Warnakulasuriya
11 //
12 
13 #pragma once
14 
15 // System includes
16 
17 // External includes
18 
19 // Project includes
20 #include "includes/checks.h"
22 #include "includes/element.h"
23 #include "includes/properties.h"
25 
26 // Application includes
27 
28 namespace Kratos
29 {
32 
33 template <unsigned int TDim, unsigned int TNumNodes, class TAdjointElementData>
35 {
36  class ThisExtensions : public AdjointExtensions
37  {
38  Element* mpElement;
39 
40  public:
41  explicit ThisExtensions(Element* pElement);
42 
44  std::size_t NodeId,
45  std::vector<IndirectScalar<double>>& rVector,
46  std::size_t Step) override;
47 
49  std::size_t NodeId,
50  std::vector<IndirectScalar<double>>& rVector,
51  std::size_t Step) override;
52 
53  void GetAuxiliaryVector(
54  std::size_t NodeId,
55  std::vector<IndirectScalar<double>>& rVector,
56  std::size_t Step) override;
57 
58  void GetFirstDerivativesVariables(std::vector<VariableData const*>& rVariables) const override;
59 
60  void GetSecondDerivativesVariables(std::vector<VariableData const*>& rVariables) const override;
61 
62  void GetAuxiliaryVariables(std::vector<VariableData const*>& rVariables) const override;
63  };
64 
65 public:
68 
69  using BaseType = Element;
70 
72 
74 
76 
77  using VectorType = typename BaseType::VectorType;
78 
79  using MatrixType = typename BaseType::MatrixType;
80 
81  using IndexType = std::size_t;
82 
84 
85  constexpr static IndexType TBlockSize = TDim + 1;
86 
87  constexpr static IndexType TElementLocalSize = TBlockSize * TNumNodes;
88 
89  constexpr static IndexType TCoordsLocalSize = TDim * TNumNodes;
90 
92 
94 
97 
101  FluidAdjointElement(IndexType NewId = 0);
102 
107  IndexType NewId,
108  GeometryType::Pointer pGeometry);
109 
114  IndexType NewId,
115  GeometryType::Pointer pGeometry,
116  PropertiesType::Pointer pProperties);
117 
121  ~FluidAdjointElement() override;
122 
126 
139  Element::Pointer Create(
140  IndexType NewId,
141  NodesArrayType const& ThisNodes,
142  PropertiesType::Pointer pProperties) const override;
143 
151  Element::Pointer Create(
152  IndexType NewId,
153  GeometryType::Pointer pGeom,
154  PropertiesType::Pointer pProperties) const override;
155 
163  Element::Pointer Clone(
164  IndexType NewId,
165  NodesArrayType const& ThisNodes) const override;
166 
167  int Check(const ProcessInfo& rCurrentProcessInfo) const override;
168 
175  void EquationIdVector(
176  EquationIdVectorType& rElementalEquationIdList,
177  const ProcessInfo& rCurrentProcessInfo) const override;
178 
184  void GetDofList(
185  DofsVectorType& rElementalDofList,
186  const ProcessInfo& rCurrentProcessInfo) const override;
187 
189  void GetValuesVector(
190  VectorType& rValues,
191  int Step = 0) const override;
192 
195  VectorType& rValues,
196  int Step = 0) const override;
197 
199  VectorType& rValues,
200  int Step) const override;
201 
202  void Initialize(const ProcessInfo& rCurrentProcessInfo) override;
203 
205  MatrixType& rLeftHandSideMatrix,
206  VectorType& rRightHandSideVector,
207  const ProcessInfo& rCurrentProcessInfo) override;
208 
210  MatrixType& rLeftHandSideMatrix,
211  const ProcessInfo& rCurrentProcessInfo) override;
212 
214  VectorType& rRightHandSideVector,
215  const ProcessInfo& rCurrentProcessInfo) override;
216 
218  MatrixType &rDampMatrix,
219  VectorType &rRightHandSideVector,
220  const ProcessInfo &rCurrentProcessInfo) override;
221 
223  MatrixType& rLeftHandSideMatrix,
224  const ProcessInfo& rCurrentProcessInfo) override;
225 
227  MatrixType& rLeftHandSideMatrix,
228  const ProcessInfo& rCurrentProcessInfo) override;
229 
230  void CalculateMassMatrix(
231  MatrixType& rMassMatrix,
232  const ProcessInfo& rCurrentProcessInfo) override;
233 
235  MatrixType& rDampingMatrix,
236  const ProcessInfo& rCurrentProcessInfo) override;
237 
239  const Variable<array_1d<double, 3>>& rSensitivityVariable,
240  Matrix& rOutput,
241  const ProcessInfo& rCurrentProcessInfo) override;
242 
243  void Calculate(
244  const Variable<Vector>& rVariable,
245  Vector& rOutput,
246  const ProcessInfo& rCurrentProcessInfo) override;
247 
251 
253  std::string Info() const override;
254 
256  void PrintInfo(std::ostream& rOStream) const override;
257 
259  void PrintData(std::ostream& rOStream) const override;
260 
262 
263 protected:
266 
267  ConstitutiveLaw::Pointer mpConstitutiveLaw = nullptr;
268 
272 
280  VectorType& rResidual,
281  const ProcessInfo& rCurrentProcessInfo);
282 
291  MatrixType& rDerivativesMatrix,
292  const ProcessInfo& rCurrentProcessInfo,
293  const double MassTermsDerivativesWeight = 1.0);
294 
302  MatrixType& rDerivativesMatrix,
303  const ProcessInfo& rCurrentProcessInfo);
304 
312  MatrixType& rDerivativesMatrix,
313  const ProcessInfo& rCurrentProcessInfo);
314 
324  Vector& rGaussWeights,
325  Matrix& rNContainer,
327  const GeometryData::IntegrationMethod& rIntegrationMethod) const;
328 
330 };
331 
333 
334 } // namespace Kratos
Interface extensions for adjoint elements and conditions.
Definition: adjoint_extensions.h:37
Base class for all Elements.
Definition: element.h:60
Vector VectorType
Definition: element.h:88
Properties PropertiesType
Definition: element.h:80
Element(IndexType NewId=0)
Definition: element.h:121
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
Geometry< NodeType >::PointsArrayType NodesArrayType
definition of nodes container type, redefined from GeometryType
Definition: element.h:86
Matrix MatrixType
Definition: element.h:90
Geometry< NodeType > GeometryType
definition of the geometry type with given NodeType
Definition: element.h:83
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
Definition: fluid_adjoint_element.h:35
void CalculateSensitivityMatrix(const Variable< array_1d< double, 3 >> &rSensitivityVariable, Matrix &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:475
void AddFluidSecondDerivatives(MatrixType &rDerivativesMatrix, const ProcessInfo &rCurrentProcessInfo)
Adds fluid residual second derivatives w.r.t. state variables.
Definition: fluid_adjoint_element.cpp:653
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Definition: fluid_adjoint_element.cpp:204
void CalculateDampingMatrix(MatrixType &rDampingMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:462
KRATOS_CLASS_POINTER_DEFINITION(FluidAdjointElement)
void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:379
void CalculateGeometryData(Vector &rGaussWeights, Matrix &rNContainer, ShapeFunctionDerivativesArrayType &rDN_DX, const GeometryData::IntegrationMethod &rIntegrationMethod) const
Computes shape function data for all the gauss points.
Definition: fluid_adjoint_element.cpp:765
std::size_t IndexType
Definition: fluid_adjoint_element.h:81
void Initialize(const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:333
void GetFirstDerivativesVector(VectorType &rValues, int Step=0) const override
Returns the adjoint velocity values stored in this element's nodes.
Definition: fluid_adjoint_element.cpp:302
void AddFluidResidualsContributions(VectorType &rResidual, const ProcessInfo &rCurrentProcessInfo)
Adds fluid residual contributions.
Definition: fluid_adjoint_element.cpp:551
void CalculateSecondDerivativesLHS(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:439
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:362
std::string Info() const override
Turn back information as a string.
Definition: fluid_adjoint_element.cpp:529
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: fluid_adjoint_element.cpp:543
void AddFluidFirstDerivatives(MatrixType &rDerivativesMatrix, const ProcessInfo &rCurrentProcessInfo, const double MassTermsDerivativesWeight=1.0)
Adds fluid residual derivatives w.r.t. state variables.
Definition: fluid_adjoint_element.cpp:601
void CalculateFirstDerivativesLHS(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:424
~FluidAdjointElement() override
Definition: fluid_adjoint_element.cpp:165
Element::Pointer Clone(IndexType NewId, NodesArrayType const &ThisNodes) const override
Definition: fluid_adjoint_element.cpp:193
constexpr static IndexType TBlockSize
Definition: fluid_adjoint_element.h:85
void CalculateLocalVelocityContribution(MatrixType &rDampMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:404
void AddFluidShapeDerivatives(MatrixType &rDerivativesMatrix, const ProcessInfo &rCurrentProcessInfo)
Adds fluid residual derivatives w.r.t. shape variables (nodal coordinates)
Definition: fluid_adjoint_element.cpp:701
constexpr static IndexType TElementLocalSize
Definition: fluid_adjoint_element.h:87
void EquationIdVector(EquationIdVectorType &rElementalEquationIdList, const ProcessInfo &rCurrentProcessInfo) const override
Definition: fluid_adjoint_element.cpp:229
void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
Definition: fluid_adjoint_element.cpp:255
void GetSecondDerivativesVector(VectorType &rValues, int Step) const override
Definition: fluid_adjoint_element.cpp:313
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: fluid_adjoint_element.cpp:537
constexpr static IndexType TCoordsLocalSize
Definition: fluid_adjoint_element.h:89
ConstitutiveLaw::Pointer mpConstitutiveLaw
Definition: fluid_adjoint_element.h:267
void CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:454
void Calculate(const Variable< Vector > &rVariable, Vector &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:498
FluidAdjointElement(IndexType NewId=0)
Definition: fluid_adjoint_element.cpp:142
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_adjoint_element.cpp:391
Element::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Definition: fluid_adjoint_element.cpp:170
void GetValuesVector(VectorType &rValues, int Step=0) const override
Returns the adjoint values stored in this element's nodes.
Definition: fluid_adjoint_element.cpp:281
This defines the geometrical object, base definition of the element and condition entities.
Definition: geometrical_object.h:58
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
GeometryData::ShapeFunctionsGradientsType ShapeFunctionsGradientsType
Definition: geometry.h:189
Wrapper for a function which behaves like an arithmetic type.
Definition: indirect_scalar.h:45
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
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21