13 #if !defined(KRATOS_SENSITIVITY_BUILDER_SCHEME_H_INCLUDED)
14 #define KRATOS_SENSITIVITY_BUILDER_SCHEME_H_INCLUDED
95 const ModelPart& rSensitivityModelPart)
const
106 const auto& r_nodes = rModelPart.
Nodes();
107 const int number_of_nodes = r_nodes.size();
109 std::vector<int> indices;
110 indices.resize(number_of_nodes);
112 indices[
Index] = (r_nodes.begin() +
Index)->Id();
115 const auto& r_data_communicator = r_communicator.GetDataCommunicator();
117 r_nodes, indices, r_data_communicator);
177 CalculateLocalSensitivityAndGlobalPointersVector(
178 rCurrentElement, rResponseFunction, rSensitivity,
179 rGPSensitivityVector, rVariable, rCurrentProcessInfo);
233 CalculateLocalSensitivityAndGlobalPointersVector(
234 rCurrentElement, rResponseFunction, rSensitivity,
235 rGPSensitivityVector, rVariable, rCurrentProcessInfo);
263 CalculateLocalSensitivityAndGlobalPointersVector(
264 rCurrentCondition, rResponseFunction, rSensitivity,
265 rGPSensitivityVector, rVariable, rCurrentProcessInfo);
293 CalculateLocalSensitivityAndGlobalPointersVector(
294 rCurrentCondition, rResponseFunction, rSensitivity,
295 rGPSensitivityVector, rVariable, rCurrentProcessInfo);
349 CalculateLocalSensitivityAndGlobalPointersVector(
350 rCurrentElement, rResponseFunction, rSensitivity,
351 rGPSensitivityVector, rVariable, rCurrentProcessInfo);
405 CalculateLocalSensitivityAndGlobalPointersVector(
406 rCurrentElement, rResponseFunction, rSensitivity,
407 rGPSensitivityVector, rVariable, rCurrentProcessInfo);
435 CalculateLocalSensitivityAndGlobalPointersVector(
436 rCurrentCondition, rResponseFunction, rSensitivity,
437 rGPSensitivityVector, rVariable, rCurrentProcessInfo);
465 CalculateLocalSensitivityAndGlobalPointersVector(
466 rCurrentCondition, rResponseFunction, rSensitivity,
467 rGPSensitivityVector, rVariable, rCurrentProcessInfo);
501 virtual std::string
Info()
const
503 return "SensitivityBuilderScheme";
536 template <
typename TEntityType,
typename TDerivativeEntityType,
typename TDataType>
537 void CalculateLocalSensitivityAndGlobalPointersVector(
538 TEntityType& rEntity,
540 Vector& rSensitivityVector,
547 this->CalculateLocalSensitivity(rEntity, rResponseFunction,
548 rSensitivityVector, rVariable, rProcessInfo);
550 if (rGPSensitivityVector.
size() != 1) {
551 rGPSensitivityVector.
resize(1);
559 template <
typename TEntityType,
typename TDataType>
560 void CalculateLocalSensitivityAndGlobalPointersVector(
561 TEntityType& rEntity,
563 Vector& rSensitivityVector,
570 this->CalculateLocalSensitivity(rEntity, rResponseFunction,
571 rSensitivityVector, rVariable, rProcessInfo);
573 auto& r_geometry = rEntity.GetGeometry();
574 if (rGPSensitivityVector.
size() != r_geometry.PointsNumber()) {
575 rGPSensitivityVector.
resize(r_geometry.PointsNumber());
578 for (
unsigned int i = 0;
i < r_geometry.PointsNumber(); ++
i) {
585 template <
class TEntityType,
class TDataType>
586 void CalculateLocalSensitivity(
587 TEntityType& rCurrentEntity,
588 AdjointResponseFunction& rResponseFunction,
590 const Variable<TDataType>& rVariable,
591 const ProcessInfo& rCurrentProcessInfo)
602 <<
" incompatible with mSensitivityMatrices[k].size1(): "
605 rResponseFunction.CalculatePartialSensitivity(
610 <<
" incompatible with mSensitivityMatrices.size1(): "
A base class for adjoint response functions.
Definition: adjoint_response_function.h:39
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
This class is a wrapper for a pointer to a data that is located in a different rank.
Definition: global_pointer.h:44
static std::unordered_map< int, GlobalPointer< typename TContainerType::value_type > > RetrieveGlobalIndexedPointersMap(const TContainerType &rContainer, const std::vector< int > &rIdList, const DataCommunicator &rDataCommunicator)
Retrieves a map of global pointers corresponding to the given entity ids, where the global pointers p...
Definition: global_pointer_utilities.h:95
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
size_type size() const
Definition: global_pointers_vector.h:307
void resize(size_type new_dim) const
Definition: global_pointers_vector.h:366
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Element ElementType
Definition: model_part.h:120
Communicator & GetCommunicator()
Definition: model_part.h:1821
Node NodeType
Definition: model_part.h:117
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Condition ConditionType
Definition: model_part.h:121
This class defines the node.
Definition: node.h:65
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
Holder for general data related to MPI (or suitable serial equivalents for non-MPI runs).
Definition: parallel_environment.h:57
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Scheme used in the Sensitivity Builder.
Definition: sensitivity_builder_scheme.h:53
virtual void FinalizeSolutionStep(ModelPart &rModelPart, ModelPart &rSensitivityModelPart, AdjointResponseFunction &rResponseFunction)
Definition: sensitivity_builder_scheme.h:126
virtual void CalculateSensitivity(ConditionType &rCurrentCondition, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< ConditionType > &rGPSensitivityVector, const Variable< array_1d< double, 3 >> &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given condition.
Definition: sensitivity_builder_scheme.h:457
std::vector< Vector > mPartialSensitivity
Definition: sensitivity_builder_scheme.h:526
virtual void Update(ModelPart &rModelPart, ModelPart &rSensitivityModelPart, AdjointResponseFunction &rResponseFunction)
Definition: sensitivity_builder_scheme.h:138
virtual void CalculateSensitivity(ElementType &rCurrentElement, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< ConditionType > &rGPSensitivityVector, const Variable< array_1d< double, 3 >> &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given element.
Definition: sensitivity_builder_scheme.h:371
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: sensitivity_builder_scheme.h:513
virtual std::string Info() const
Turn back information as a string.
Definition: sensitivity_builder_scheme.h:501
virtual void CalculateSensitivity(ConditionType &rCurrentCondition, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< ElementType > &rGPSensitivityVector, const Variable< array_1d< double, 3 >> &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given condition.
Definition: sensitivity_builder_scheme.h:487
KRATOS_CLASS_POINTER_DEFINITION(SensitivityBuilderScheme)
virtual void CalculateSensitivity(ElementType &rCurrentElement, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< NodeType > &rGPSensitivityVector, const Variable< double > &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given element.
Definition: sensitivity_builder_scheme.h:169
virtual void Finalize(ModelPart &rModelPart, ModelPart &rSensitivityModelPart, AdjointResponseFunction &rResponseFunction)
Definition: sensitivity_builder_scheme.h:132
virtual void CalculateSensitivity(ElementType &rCurrentElement, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< NodeType > &rGPSensitivityVector, const Variable< array_1d< double, 3 >> &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given element.
Definition: sensitivity_builder_scheme.h:341
virtual void Clear()
Definition: sensitivity_builder_scheme.h:144
std::vector< Vector > mAdjointVectors
Definition: sensitivity_builder_scheme.h:525
virtual void CalculateSensitivity(ElementType &rCurrentElement, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< ElementType > &rGPSensitivityVector, const Variable< array_1d< double, 3 >> &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given element.
Definition: sensitivity_builder_scheme.h:397
virtual void CalculateSensitivity(ConditionType &rCurrentCondition, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< NodeType > &rGPSensitivityVector, const Variable< array_1d< double, 3 >> &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given condition.
Definition: sensitivity_builder_scheme.h:427
virtual ~SensitivityBuilderScheme()=default
Destructor.
virtual void CalculateSensitivity(ConditionType &rCurrentCondition, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< ElementType > &rGPSensitivityVector, const Variable< double > &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given condition.
Definition: sensitivity_builder_scheme.h:315
virtual void CalculateSensitivity(ElementType &rCurrentElement, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< ConditionType > &rGPSensitivityVector, const Variable< double > &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given element.
Definition: sensitivity_builder_scheme.h:199
const int mRank
Definition: sensitivity_builder_scheme.h:529
virtual void Initialize(ModelPart &rModelPart, ModelPart &rSensitivityModelPart, AdjointResponseFunction &rResponseFunction)
Definition: sensitivity_builder_scheme.h:100
virtual void InitializeSolutionStep(ModelPart &rModelPart, ModelPart &rSensitivityModelPart, AdjointResponseFunction &rResponseFunction)
Definition: sensitivity_builder_scheme.h:120
std::vector< Matrix > mSensitivityMatrices
Definition: sensitivity_builder_scheme.h:524
virtual void CalculateSensitivity(ConditionType &rCurrentCondition, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< ConditionType > &rGPSensitivityVector, const Variable< double > &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given condition.
Definition: sensitivity_builder_scheme.h:285
virtual void CalculateSensitivity(ElementType &rCurrentElement, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< ElementType > &rGPSensitivityVector, const Variable< double > &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given element.
Definition: sensitivity_builder_scheme.h:225
virtual void CalculateSensitivity(ConditionType &rCurrentCondition, AdjointResponseFunction &rResponseFunction, Vector &rSensitivity, GlobalPointersVector< NodeType > &rGPSensitivityVector, const Variable< double > &rVariable, const ProcessInfo &rCurrentProcessInfo)
Calculates sensitivity from a given condition.
Definition: sensitivity_builder_scheme.h:255
virtual int Check(const ModelPart &rModelPart, const ModelPart &rSensitivityModelPart) const
Definition: sensitivity_builder_scheme.h:93
std::unordered_map< int, GlobalPointer< ModelPart::NodeType > > mGlobalPointerNodalMap
Definition: sensitivity_builder_scheme.h:528
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: sensitivity_builder_scheme.h:507
SensitivityBuilderScheme()
Constructor.
Definition: sensitivity_builder_scheme.h:71
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
DataCommunicator & GetDefaultDataCommunicator()
Definition: testing.cpp:24
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int k
Definition: quadrature.py:595
integer i
Definition: TensorModule.f:17