44 template <
class TSparseSpace,
class TDenseSpace>
71 :
Scheme<TSparseSpace, TDenseSpace>()
114 for (auto& r_dof : rNode.GetDofs()) {
115 if (r_dof->IsFree()) {
116 r_dof->GetSolutionStepValue() = 0.0;
136 this->mpDofUpdater->UpdateDofs(rDofSet, rDx);
151 const auto& r_const_elem_ref = rCurrentElement;
155 if (rRHSContribution.size() != rLHS_Contribution.size1())
156 rRHSContribution.resize(rLHS_Contribution.size1(),
false);
158 mpResponseFunction->CalculateGradient(
159 rCurrentElement, rLHS_Contribution, rRHSContribution, rCurrentProcessInfo);
161 noalias(rRHSContribution) = -rRHSContribution;
164 r_const_elem_ref.GetValuesVector(mAdjointValues[thread_id]);
165 noalias(rRHSContribution) -=
prod(rLHS_Contribution, mAdjointValues[thread_id]);
167 r_const_elem_ref.EquationIdVector(rEquationId, rCurrentProcessInfo);
193 const auto& r_const_elem_ref = rCurrentElement;
194 auto&
lhs = mLHS[thread_id];
198 if (rRHSContribution.size() !=
lhs.size1())
199 rRHSContribution.resize(
lhs.size1(),
false);
201 mpResponseFunction->CalculateGradient(
202 rCurrentElement,
lhs, rRHSContribution, rCurrentProcessInfo);
204 noalias(rRHSContribution) = -rRHSContribution;
207 r_const_elem_ref.GetValuesVector(mAdjointValues[thread_id]);
208 noalias(rRHSContribution) -=
prod(
lhs, mAdjointValues[thread_id]);
210 r_const_elem_ref.EquationIdVector(rEquationId, rCurrentProcessInfo);
222 const auto& r_const_cond_ref = rCurrentCondition;
225 if (rRHSContribution.size() != rLHS_Contribution.size1())
226 rRHSContribution.resize(rLHS_Contribution.size1(),
false);
228 mpResponseFunction->CalculateGradient(
229 rCurrentCondition, rLHS_Contribution, rRHSContribution, rCurrentProcessInfo);
231 noalias(rRHSContribution) = -rRHSContribution;
234 r_const_cond_ref.GetValuesVector(mAdjointValues[thread_id]);
235 noalias(rRHSContribution) -=
prod(rLHS_Contribution, mAdjointValues[thread_id]);
237 r_const_cond_ref.EquationIdVector(rEquationId, rCurrentProcessInfo);
263 const auto& r_const_elem_ref = rCurrentCondition;
264 auto&
lhs = mLHS[thread_id];
268 if (rRHSContribution.size() !=
lhs.size1())
269 rRHSContribution.resize(
lhs.size1(),
false);
271 mpResponseFunction->CalculateGradient(
272 rCurrentCondition,
lhs, rRHSContribution, rCurrentProcessInfo);
274 noalias(rRHSContribution) = -rRHSContribution;
277 r_const_elem_ref.GetValuesVector(mAdjointValues[thread_id]);
278 noalias(rRHSContribution) -=
prod(
lhs, mAdjointValues[thread_id]);
280 r_const_elem_ref.EquationIdVector(rEquationId, rCurrentProcessInfo);
285 this->mpDofUpdater->Clear();
312 std::vector<LocalSystemMatrixType>
mLHS;
344 typename TSparseSpace::DofUpdaterPointerType mpDofUpdater =
345 TSparseSpace::CreateDofUpdater();
Base class for all Conditions.
Definition: condition.h:59
std::vector< std::size_t > EquationIdVectorType
Definition: condition.h:98
virtual void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:426
virtual void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const
Definition: condition.h:260
Base class for all Elements.
Definition: element.h:60
virtual void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:423
virtual void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const
Definition: element.h:258
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
A scheme for static adjoint equations.
Definition: residual_based_adjoint_static_scheme.h:46
~ResidualBasedAdjointStaticScheme() override
Destructor.
Definition: residual_based_adjoint_static_scheme.h:81
void Update(ModelPart &rModelPart, DofsArrayType &rDofSet, SystemMatrixType &rA, SystemVectorType &rDx, SystemVectorType &rb) override
Performing the update of the solution.
Definition: residual_based_adjoint_static_scheme.h:126
void CalculateLHSContribution(Element &rCurrentElement, LocalSystemMatrixType &rLHS_Contribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to calculate just the LHS contribution.
Definition: residual_based_adjoint_static_scheme.h:172
ResidualBasedAdjointStaticScheme(AdjointResponseFunction::Pointer pResponseFunction)
Constructor.
Definition: residual_based_adjoint_static_scheme.h:70
std::vector< LocalSystemMatrixType > mLHS
Definition: residual_based_adjoint_static_scheme.h:312
void CalculateLHSContribution(Condition &rCurrentCondition, LocalSystemMatrixType &rLHS_Contribution, Condition::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
Functions totally analogous to the precedent but applied to the "condition" objects.
Definition: residual_based_adjoint_static_scheme.h:242
void CalculateSystemContributions(Condition &rCurrentCondition, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHSContribution, Condition::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
Functions totally analogous to the precedent but applied to the "condition" objects.
Definition: residual_based_adjoint_static_scheme.h:213
void CalculateSystemContributions(Element &rCurrentElement, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHSContribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to be called in the builder and solver to introduce the selected time integ...
Definition: residual_based_adjoint_static_scheme.h:141
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: residual_based_adjoint_static_scheme.h:61
Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: residual_based_adjoint_static_scheme.h:53
void CalculateRHSContribution(Condition &rCurrentCondition, LocalSystemVectorType &rRHSContribution, Condition::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
Functions totally analogous to the precedent but applied to the "condition" objects.
Definition: residual_based_adjoint_static_scheme.h:255
KRATOS_CLASS_POINTER_DEFINITION(ResidualBasedAdjointStaticScheme)
void CalculateRHSContribution(Element &rCurrentElement, LocalSystemVectorType &rRHSContribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to calculate just the RHS contribution.
Definition: residual_based_adjoint_static_scheme.h:185
BaseType::TSystemVectorType SystemVectorType
Definition: residual_based_adjoint_static_scheme.h:57
void SetResponseFunction(AdjointResponseFunction::Pointer pResponseFunction)
Set the Response Function.
Definition: residual_based_adjoint_static_scheme.h:104
std::vector< LocalSystemVectorType > mAdjointValues
Definition: residual_based_adjoint_static_scheme.h:311
void Clear() override
Liberate internal storage.
Definition: residual_based_adjoint_static_scheme.h:283
BaseType::DofsArrayType DofsArrayType
Definition: residual_based_adjoint_static_scheme.h:63
BaseType::TSystemMatrixType SystemMatrixType
Definition: residual_based_adjoint_static_scheme.h:55
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: residual_based_adjoint_static_scheme.h:59
void Initialize(ModelPart &rModelPart) override
This is the place to initialize the Scheme.
Definition: residual_based_adjoint_static_scheme.h:109
AdjointResponseFunction::Pointer mpResponseFunction
Definition: residual_based_adjoint_static_scheme.h:310
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
typename TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: scheme.h:71
typename TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: scheme.h:74
typename TDenseSpace::VectorType LocalSystemVectorType
Local system vector type definition.
Definition: scheme.h:80
virtual void Initialize(ModelPart &rModelPart)
This is the place to initialize the Scheme.
Definition: scheme.h:168
typename TDenseSpace::MatrixType LocalSystemMatrixType
Local system matrix type definition.
Definition: scheme.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
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
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
lhs
Definition: generate_frictional_mortar_condition.py:297
def num_threads
Definition: script.py:75