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.
structure_adjoint_sensitivity_strategy.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: Baumgärtner Daniel, https://github.com/dbaumgaertner
11 // Octaviano Malfavón Farías
12 // Eric Gonzales
13 // Philipp Hofer
14 // Erich Wehrle
15 //
16 // ==============================================================================
17 
18 #if !defined(KRATOS_STRUCTURE_ADJOINT_SENSITIVITY_STRATEGY_H_INCLUDED)
19 #define KRATOS_STRUCTURE_ADJOINT_SENSITIVITY_STRATEGY_H_INCLUDED
20 
21 // System includes
22 
23 // External includes
24 
25 // Project includes
26 #include "includes/define.h"
31 
32 // Application includes
34 
35 
36 namespace Kratos {
37 
40 
43 
46 
47 template <class TSparseSpace,
48  class TDenseSpace,
49  class TLinearSolver
50  >
52  : public SolvingStrategy<TSparseSpace, TDenseSpace>
53 {
54 public:
55 
58 
60 
62 
65 
69 
71  typename TLinearSolver::Pointer pNewLinearSolver,
72  const int dimension = 3)
73  : BaseType(rStructureModelPart),
74  mr_structure_model_part(rStructureModelPart),
75  m_dimension(dimension)
76  {}
77 
78 
81  {}
82 
86 
87  // ---------------------------------------------------------------------------------------------------------------------------------------------
88  // --------------------------------- COMPUTE SENSITIVITIES ------------------------------------------------------------------------------------
89  // ---------------------------------------------------------------------------------------------------------------------------------------------
90 
93  {
94  KRATOS_TRY;
95 
96  double Out = 0.0;
97  int i= 0;
98 
100  const ProcessInfo& ConstProcessInfo= mr_structure_model_part.GetProcessInfo();
101 
102  block_for_each(mr_structure_model_part.Elements(), [&](Element& element_i)
103  {
104  element_i.Calculate(DCDX, Out, ConstProcessInfo);
105  i++;
106  });
107 
108  KRATOS_INFO("[TopOpt]") << " Objective Function sensitivities computed [ spent time = " << timer.ElapsedSeconds() << " ] " << std::endl;
109 
110  KRATOS_CATCH("");
111  }
112 
113 
116  {
117  KRATOS_TRY;
118 
119  double Out = 0.0;
120 
122  const ProcessInfo& ConstProcessInfo= mr_structure_model_part.GetProcessInfo();
123 
124  block_for_each(mr_structure_model_part.Elements(), [&](Element& element_i)
125  {
126  element_i.Calculate(DVDX, Out, ConstProcessInfo);
127  });
128 
129  KRATOS_INFO("[TopOpt]") << " Volume fraction sensitivities computed [ spent time = " << timer.ElapsedSeconds() << " ] " << std::endl;
130 
131  KRATOS_CATCH("");
132  }
133 
135 
136 private:
137 
140 
141  ModelPart& mr_structure_model_part;
142  ModelPart* mpAdjointModelPart;
143  typename BaseType::Pointer mpStrategy;
144  int m_dimension;
145 
149 
151 }; // class StructureAdjointSensitivityStrategy
152 
155 }
156 
157 #endif /* KRATOS_STRUCTURE_ADJOINT_SENSITIVITY_STRATEGY_H_INCLUDED */
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
Definition: builtin_timer.h:26
Base class for all Elements.
Definition: element.h:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
Solving strategy base class This is the base class from which we will derive all the strategies (impl...
Definition: solving_strategy.h:64
Definition: structure_adjoint_sensitivity_strategy.h:53
~StructureAdjointSensitivityStrategy() override
virtual ~StructureAdjointSensitivityStrategy()
Definition: structure_adjoint_sensitivity_strategy.h:80
KRATOS_CLASS_POINTER_DEFINITION(StructureAdjointSensitivityStrategy)
SolvingStrategy< TSparseSpace, TDenseSpace > BaseType
Definition: structure_adjoint_sensitivity_strategy.h:61
void ComputeVolumeFractionSensitivities()
Computes DVDX sensitivities from the adjoint solution.
Definition: structure_adjoint_sensitivity_strategy.h:115
BuilderAndSolver< TSparseSpace, TDenseSpace, TLinearSolver >::Pointer BuilderAndSolverPointerType
Definition: structure_adjoint_sensitivity_strategy.h:64
Scheme< TSparseSpace, TDenseSpace >::Pointer SchemePointerType
Definition: structure_adjoint_sensitivity_strategy.h:63
void ComputeStrainEnergySensitivities()
Computes DCDX sensitivities from the adjoint solution.
Definition: structure_adjoint_sensitivity_strategy.h:92
StructureAdjointSensitivityStrategy(ModelPart &rStructureModelPart, typename TLinearSolver::Pointer pNewLinearSolver, const int dimension=3)
Definition: structure_adjoint_sensitivity_strategy.h:70
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_INFO(label)
Definition: logger.h:250
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
integer i
Definition: TensorModule.f:17
Definition: timer.py:1