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.
adjoint_local_stress_response_function.h
Go to the documentation of this file.
1 // KRATOS ___| | | |
2 // \___ \ __| __| | | __| __| | | __| _` | |
3 // | | | | | ( | | | | ( | |
4 // _____/ \__|_| \__,_|\___|\__|\__,_|_| \__,_|_| MECHANICS
5 //
6 // License: BSD License
7 // license: StructuralMechanicsApplication/license.txt
8 //
9 // Main authors: Martin Fusseder, https://github.com/MFusseder
10 //
11 
12 #pragma once
13 
14 
15 // System includes
16 
17 // External includes
18 
19 // Project includes
22 
23 namespace Kratos
24 {
25 
28 
32 
36 
40 
44 
51 class KRATOS_API(STRUCTURAL_MECHANICS_APPLICATION) AdjointLocalStressResponseFunction : public AdjointStructuralResponseFunction
52 {
53 public:
56 
59 
64 
68 
70  AdjointLocalStressResponseFunction(ModelPart& rModelPart, Parameters ResponseSettings);
71 
74 
78 
82 
83  void FinalizeSolutionStep() override;
84 
86 
87  void CalculateGradient(const Element& rAdjointElement,
88  const Matrix& rResidualGradient,
89  Vector& rResponseGradient,
90  const ProcessInfo& rProcessInfo) override;
91 
92  void CalculatePartialSensitivity(Element& rAdjointElement,
93  const Variable<double>& rVariable,
94  const Matrix& rSensitivityMatrix,
95  Vector& rSensitivityGradient,
96  const ProcessInfo& rProcessInfo) override;
97 
98  void CalculatePartialSensitivity(Condition& rAdjointCondition,
99  const Variable<double>& rVariable,
100  const Matrix& rSensitivityMatrix,
101  Vector& rSensitivityGradient,
102  const ProcessInfo& rProcessInfo) override;
103 
104  void CalculatePartialSensitivity(Element& rAdjointElement,
105  const Variable<array_1d<double, 3>>& rVariable,
106  const Matrix& rSensitivityMatrix,
107  Vector& rSensitivityGradient,
108  const ProcessInfo& rProcessInfo) override;
109 
110  void CalculatePartialSensitivity(Condition& rAdjointCondition,
111  const Variable<array_1d<double, 3>>& rVariable,
112  const Matrix& rSensitivityMatrix,
113  Vector& rSensitivityGradient,
114  const ProcessInfo& rProcessInfo) override;
115 
116  double CalculateValue(ModelPart& rModelPart) override;
117 
118 
122 
126 
130 
134 
136 
137 protected:
140 
144 
148 
152 
156 
160 
164 
166 
167 private:
170 
174 
175  unsigned int mIdOfLocation;
176  Element::Pointer mpTracedElement;
177  StressTreatment mStressTreatment;
178  TracedStressType mTracedStressType;
179  bool mAddParticularSolution = false;
180 
181 
185 
189 
190  double CalculateMeanElementStress(ModelPart& rModelPart);
191 
192  double CalculateGaussPointStress(ModelPart& rModelPart);
193 
194  double CalculateNodeStress(ModelPart& rModelPart);
195 
196  void CalculateElementContributionToPartialSensitivity(Element& rAdjointElement,
197  const std::string& rVariableName,
198  const Matrix& rSensitivityMatrix,
199  Vector& rSensitivityGradient,
200  const ProcessInfo& rProcessInfo);
201 
202  void ExtractMeanStressDerivative(const Matrix& rStressDerivativesMatrix, Vector& rResponseGradient);
203 
204  void ExtractNodeStressDerivative(const Matrix& rStressDerivativesMatrix, Vector& rResponseGradient);
205 
206  void ExtractGaussPointStressDerivative(const Matrix& rStressDerivativesMatrix, Vector& rResponseGradient);
207 
208  void CalculateParticularSolution() const;
209 
210  void CalculateParticularSolutionLinearElement2N(Vector& rResult) const;
211 
212  void CalculateMeanParticularSolutionLinearElement2N(Vector& rResult, DofsVectorType &rElementalDofList, const Array1DComponentsPointerType TracedDof) const;
213 
214  void CalculateGPParticularSolutionLinearElement2N(Vector& rResult, DofsVectorType &rElementalDofList, const Array1DComponentsPointerType TracedDof) const;
215 
216  void CalculateNodeParticularSolutionLinearElement2N(Vector& rResult, DofsVectorType &rElementalDofList, const Array1DComponentsPointerType TracedDof) const;
217 
218  void FindVariableComponent(Array1DComponentsPointerType& rTracedDof) const;
219 
223 
227 
231 
233 
234 }; // Class AdjointLocalStressResponseFunction
235 
237 
240 
244 
246 
247 } // namespace Kratos.
AdjointLocalStressResponseFunction.
Definition: adjoint_local_stress_response_function.h:52
Variable< double > * Array1DComponentsPointerType
Definition: adjoint_local_stress_response_function.h:58
KRATOS_CLASS_POINTER_DEFINITION(AdjointLocalStressResponseFunction)
Element::DofsVectorType DofsVectorType
Definition: adjoint_local_stress_response_function.h:57
AdjointStructuralResponseFunction.
Definition: adjoint_structural_response_function.h:39
virtual void CalculateGradient(const Element &rAdjointElement, const Matrix &rResidualGradient, Vector &rResponseGradient, const ProcessInfo &rProcessInfo)
Calculate the local gradient w.r.t. primal solution.
Definition: adjoint_response_function.h:88
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
StressTreatment
Definition: stress_response_definitions.h:57
TracedStressType
Definition: stress_response_definitions.h:27