52 template <
typename TPrimalElement>
71 bool HasRotationDofs =
false)
79 GeometryType::Pointer pGeometry,
80 bool HasRotationDofs =
false)
88 GeometryType::Pointer pGeometry,
89 PropertiesType::Pointer pProperties,
90 bool HasRotationDofs =
false)
91 :
Element(NewId, pGeometry, pProperties),
108 PropertiesType::Pointer pProperties)
const override
110 return Kratos::make_intrusive<AdjointFiniteDifferencingBaseElement<TPrimalElement>>(
115 GeometryType::Pointer pGeometry,
116 PropertiesType::Pointer pProperties)
const override
118 return Kratos::make_intrusive<AdjointFiniteDifferencingBaseElement<TPrimalElement>>(
119 NewId, pGeometry, pProperties);
169 rRightHandSideVector,
170 rCurrentProcessInfo);
177 rCurrentProcessInfo);
184 rCurrentProcessInfo);
191 mpPrimalElement->CalculateFirstDerivativesContributions(rLeftHandSideMatrix,
192 rRightHandSideVector,
193 rCurrentProcessInfo);
200 rCurrentProcessInfo);
207 rCurrentProcessInfo);
214 mpPrimalElement->CalculateSecondDerivativesContributions(rLeftHandSideMatrix,
215 rRightHandSideVector,
216 rCurrentProcessInfo);
223 rCurrentProcessInfo);
230 rCurrentProcessInfo);
240 mpPrimalElement->CalculateDampingMatrix(rDampingMatrix, rCurrentProcessInfo);
255 rDestinationVariable,
256 rCurrentProcessInfo);
266 rDestinationVariable,
267 rCurrentProcessInfo);
277 rDestinationVariable,
278 rCurrentProcessInfo);
285 KRATOS_ERROR <<
"Calculate of the adjoint base element is called!" << std::endl;
292 KRATOS_ERROR <<
"Calculate of the adjoint base element is called!" << std::endl;
299 KRATOS_ERROR <<
"Calculate of the adjoint base element is called!" << std::endl;
308 std::vector<bool>& rOutput,
311 KRATOS_ERROR <<
"CalculateOnIntegrationPoints of the adjoint base element is called!" << std::endl;
315 std::vector<double>& rOutput,
326 KRATOS_ERROR <<
"CalculateOnIntegrationPoints of the adjoint base element is called!" << std::endl;
330 std::vector< Vector >& rOutput,
333 KRATOS_ERROR <<
"CalculateOnIntegrationPoints of the adjoint base element is called!" << std::endl;
337 std::vector< Matrix >& rOutput,
340 KRATOS_ERROR <<
"CalculateOnIntegrationPoints of the adjoint base element is called!" << std::endl;
410 template <
typename TDataType>
416 <<
"The call of this non shared-memory-parallelized function within a parallel section should be avoided for efficiency reasons!" << std::endl;
421 const SizeType num_dofs = num_nodes * num_dofs_per_node;
422 Vector initial_state_variables;
423 initial_state_variables.
resize(num_dofs);
426 if(this->
Has(ADJOINT_PARTICULAR_DISPLACEMENT)) {
427 particular_solution = this->
GetValue(ADJOINT_PARTICULAR_DISPLACEMENT);
431 std::vector<Variable<double>*> primal_solution_variable_list;
432 (
mHasRotationDofs) ? primal_solution_variable_list = {&DISPLACEMENT_X, &DISPLACEMENT_Y, &DISPLACEMENT_Z, &ROTATION_X, &ROTATION_Y, &ROTATION_Z} :
433 primal_solution_variable_list = {&DISPLACEMENT_X, &DISPLACEMENT_Y, &DISPLACEMENT_Z};
436 std::vector<Variable<double>*> adjoint_solution_variable_list;
437 (
mHasRotationDofs) ? adjoint_solution_variable_list = {&ADJOINT_DISPLACEMENT_X, &ADJOINT_DISPLACEMENT_Y, &ADJOINT_DISPLACEMENT_Z, &ADJOINT_ROTATION_X, &ADJOINT_ROTATION_Y, &ADJOINT_ROTATION_Z} :
438 adjoint_solution_variable_list = {&ADJOINT_DISPLACEMENT_X, &ADJOINT_DISPLACEMENT_Y, &ADJOINT_DISPLACEMENT_Z};
441 const IndexType index =
i * num_dofs_per_node;
442 for(
IndexType j = 0;
j < primal_solution_variable_list.size(); ++
j) {
443 initial_state_variables[index +
j] =
mpPrimalElement->GetGeometry()[
i].FastGetSolutionStepValue(*primal_solution_variable_list[
j]);
444 mpPrimalElement->GetGeometry()[
i].FastGetSolutionStepValue(*primal_solution_variable_list[
j]) =
445 this->
GetGeometry()[
i].FastGetSolutionStepValue(*adjoint_solution_variable_list[
j]) +
446 particular_solution[index +
j];
450 mpPrimalElement->CalculateOnIntegrationPoints(rVariable, rOutput, rCurrentProcessInfo);
453 const IndexType index =
i * num_dofs_per_node;
454 for(
IndexType j = 0;
j < primal_solution_variable_list.size(); ++
j) {
455 mpPrimalElement->GetGeometry()[
i].FastGetSolutionStepValue(*primal_solution_variable_list[
j]) = initial_state_variables[index +
j];
499 virtual double GetPerturbationSizeModificationFactor(
const Variable<double>& rVariable)
const;
524 void save(
Serializer& rSerializer)
const override;
AdjointFiniteDifferencingBaseElement.
Definition: adjoint_finite_difference_base_element.h:54
void FinalizeNonLinearIteration(const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:154
void CalculateSecondDerivativesLHS(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:219
void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:173
void CalculateOnIntegrationPoints(const Variable< array_1d< double, 6 > > &rVariable, std::vector< array_1d< double, 6 > > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:322
void Calculate(const Variable< Vector > &rVariable, Vector &Output, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:295
AdjointFiniteDifferencingBaseElement(IndexType NewId, GeometryType::Pointer pGeometry, bool HasRotationDofs=false)
Definition: adjoint_finite_difference_base_element.h:78
void InitializeSolutionStep(const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:144
Element::Pointer pGetPrimalElement()
Definition: adjoint_finite_difference_base_element.h:386
const Element::Pointer pGetPrimalElement() const
Definition: adjoint_finite_difference_base_element.h:390
void GetDofList(DofsVectorType &ElementalDofList, const ProcessInfo &CurrentProcessInfo) const override
Definition: adjoint_finite_difference_base_element.cpp:67
void CalculateAdjointFieldOnIntegrationPoints(const Variable< TDataType > &rVariable, std::vector< TDataType > &rOutput, const ProcessInfo &rCurrentProcessInfo)
Definition: adjoint_finite_difference_base_element.h:411
void CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:233
void FinalizeSolutionStep(const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:159
void ResetConstitutiveLaw() override
Definition: adjoint_finite_difference_base_element.h:139
void InitializeNonLinearIteration(const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:149
void Initialize(const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:134
void CalculateFirstDerivativesLHS(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:196
virtual void CalculateStressDisplacementDerivative(const Variable< Vector > &rStressVariable, Matrix &rOutput, const ProcessInfo &rCurrentProcessInfo)
Definition: adjoint_finite_difference_base_element.cpp:368
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Definition: adjoint_finite_difference_base_element.cpp:33
Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) const override
It creates a new element pointer.
Definition: adjoint_finite_difference_base_element.h:114
void AddExplicitContribution(const VectorType &rRHSVector, const Variable< VectorType > &rRHSVariable, const Variable< array_1d< double, 3 > > &rDestinationVariable, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to make the element to assemble an rRHS vector identified by a variable rRH...
Definition: adjoint_finite_difference_base_element.h:259
void CalculateOnIntegrationPoints(const Variable< bool > &rVariable, std::vector< bool > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:307
void CalculateDampingMatrix(MatrixType &rDampingMatrix, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:238
AdjointFiniteDifferencingBaseElement(IndexType NewId=0, bool HasRotationDofs=false)
Definition: adjoint_finite_difference_base_element.h:70
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Definition: adjoint_finite_difference_base_element.cpp:254
AdjointFiniteDifferencingBaseElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties, bool HasRotationDofs=false)
Definition: adjoint_finite_difference_base_element.h:87
void Calculate(const Variable< array_1d< double, 3 > > &rVariable, array_1d< double, 3 > &Output, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:288
void CalculateSecondDerivativesContributions(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:210
void AddExplicitContribution(const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:243
void Calculate(const Variable< double > &rVariable, double &Output, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:281
IntegrationMethod GetIntegrationMethod() const override
Definition: adjoint_finite_difference_base_element.h:127
void CalculateFirstDerivativesRHS(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:203
void CalculateOnIntegrationPoints(const Variable< Vector > &rVariable, std::vector< Vector > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:329
void CalculateFirstDerivativesContributions(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:187
Element::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
It creates a new element pointer.
Definition: adjoint_finite_difference_base_element.h:106
void AddExplicitContribution(const MatrixType &rLHSMatrix, const Variable< MatrixType > &rLHSVariable, const Variable< Matrix > &rDestinationVariable, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to make the element to assemble an rRHS vector identified by a variable rRH...
Definition: adjoint_finite_difference_base_element.h:270
bool mHasRotationDofs
Definition: adjoint_finite_difference_base_element.h:470
void CalculateSensitivityMatrix(const Variable< double > &rDesignVariable, Matrix &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.cpp:294
Element::Pointer mpPrimalElement
Definition: adjoint_finite_difference_base_element.h:469
void GetValuesVector(Vector &values, int Step=0) const override
Definition: adjoint_finite_difference_base_element.cpp:100
void CalculateOnIntegrationPoints(const Variable< Matrix > &rVariable, std::vector< Matrix > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:336
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: adjoint_finite_difference_base_element.h:248
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(AdjointFiniteDifferencingBaseElement)
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:180
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:164
void CalculateStressDesignVariableDerivative(const Variable< double > &rDesignVariable, const Variable< Vector > &rStressVariable, Matrix &rOutput, const ProcessInfo &rCurrentProcessInfo)
Definition: adjoint_finite_difference_base_element.cpp:449
void CalculateSecondDerivativesRHS(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: adjoint_finite_difference_base_element.h:226
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
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
std::size_t IndexType
Definition: flags.h:74
GeometryType::Pointer pGetGeometry()
Returns the pointer to the geometry.
Definition: geometrical_object.h:140
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometrical_object.h:248
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
bool Has(const Variable< TDataType > &rThisVariable) const
Definition: geometrical_object.h:230
IntegrationMethod
Definition: geometry_data.h:76
virtual Pointer Create(PointsArrayType const &rThisPoints) const
Creates a new geometry pointer.
Definition: geometry.h:813
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
static int IsInParallel()
Wrapper for omp_in_parallel().
Definition: openmp_utils.h:122
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
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_WARNING_IF(label, conditional)
Definition: logger.h:266
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
intrusive_ptr< C > make_intrusive(Args &&...args)
Definition: smart_pointers.h:36
list values
Definition: bombardelli_test.py:42
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
def load(f)
Definition: ode_solve.py:307
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17