44 #ifndef ROL_CONSTRAINT_PINTSIMOPT_H
45 #define ROL_CONSTRAINT_PINTSIMOPT_H
112 template <
class Real>
113 Ptr<PinTVector<Real>>
116 const std::vector<int> & stencil,
118 {
return makePtr<PinTVector<Real>>(communicators,localVector,steps,stencil); }
120 template <
class Real>
155 const std::vector<int> stencil = src.
stencil();
157 std::vector<Ptr<Vector<Real>>> vecs;
158 for(std::size_t i=0;i<stencil.size();i++) {
162 if(accessor==
PAST && stencil[i]<0)
164 if(accessor==
CURRENT && stencil[i]==0)
166 if(accessor==
FUTURE && stencil[i]>0)
176 TEUCHOS_ASSERT(vecs.size()>0);
181 return makePtr<PartitionedVector<Real>>(vecs);
190 std::vector<Ptr<Vector<Real>>> vecs;
191 vecs.push_back(u_old);
192 vecs.push_back(u_now);
193 return makePtr<PartitionedVector<Real>>(vecs);
252 Real &tol)
override {
266 const std::vector<int> & stencil = pint_c.
stencil();
267 for(
size_t i=0;i<stencil.size();i++) {
268 int offset = stencil[i];
278 Ptr<const Vector<Real>> z_all =
getVector(pint_z,i,
ALL);
289 Real &tol)
override {
305 const std::vector<int> & stencil = pint_c.
stencil();
306 for(
size_t i=0;i<stencil.size();i++) {
307 int offset = stencil[i];
321 Ptr<const Vector<Real>> z_all =
getVector(pint_z,i,
ALL);
338 Real &tol)
override {
355 const std::vector<int> & stencil = pint_jv.
stencil();
356 for(
size_t i=0;i<stencil.size();i++) {
357 int offset = stencil[i];
372 Ptr<const Vector<Real>> z_all =
getVector(pint_z,i,
ALL);
376 stepConstraint_->applyJacobian_1(*jv_now,*v_state,*u_state,*z_all,tol);
384 Real &tol)
override {
399 const std::vector<int> & stencil = pint_jv.
stencil();
400 for(
size_t i=0;i<stencil.size();i++) {
401 int offset = stencil[i];
410 Ptr<const Vector<Real>> v_control =
getVector(pint_v,i,
ALL);
411 Ptr<const Vector<Real>> z_all =
getVector(pint_z,i,
ALL);
415 stepConstraint_->applyJacobian_2(*jv_now,*v_control,*u_state,*z_all,tol);
423 Real &tol)
override final {
424 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
425 "The method applyInverseJacobian_1 is used but not implemented!\n");
432 Real &tol)
override {
451 Ptr<Vector<Real>> scratch;
456 Ptr<const Vector<Real>> z_all =
getVector(pint_z,i,
ALL);
461 if(scratch==ROL::nullPtr) {
462 scratch = ajv_now->clone();
465 stepConstraint_->applyAdjointJacobian_1(*scratch,*v_dual,*u_state,*z_all,tol);
467 ajv_now->axpy(1.0,*scratch);
471 const std::vector<int> & stencil = pint_u.
stencil();
472 for(
size_t i=0;i<stencil.size();i++) {
473 int offset = stencil[i];
489 Real &tol)
override {
508 Ptr<Vector<Real>> scratch;
513 Ptr<const Vector<Real>> z_all =
getVector(pint_z,i,
ALL);
517 stepConstraint_->applyAdjointJacobian_2(*ajv_now,*v_dual,*u_state,*z_all,tol);
527 Real &tol)
override final {
528 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
529 "The method applyInverseAdjointJacobian_1 is used but not implemented!\n");
575 Ptr<Vector<Real>> scratch;
581 Ptr<const Vector<Real>> z_all =
getVector(pint_z,i,
ALL);
586 if(scratch==ROL::nullPtr) {
587 scratch = ahwv_now->clone();
590 stepConstraint_->applyAdjointHessian_11(*scratch,*w_dual,*v_dual,*u_state,*z_all,tol);
592 ahwv_now->axpy(1.0,*scratch);
648 Real &tol)
override {
674 Real &tol)
override {
virtual void update_1(const Vector< Real > &u, bool flag=true, int iter=-1)
Update constraint functions with respect to Opt variable. u is the state variable, flag = true if optimization variable is changed, iter is the outer algorithm iterations count.
Ptr< Vector< Real > > getVectorPtr(int i) const
Ptr< PinTVector< Real > > buildPinTVector(const Ptr< const PinTCommunicators > &communicators, int steps, const std::vector< int > &stencil, const Ptr< Vector< Real >> &localVector)
virtual void applyInverseAdjointJacobian_1(Vector< Real > &iajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) overridefinal
Apply the inverse of the adjoint of the partial constraint Jacobian at , , to the vector ...
void boundaryExchange(ESendRecv send_recv=SEND_AND_RECV) const
Exchange unknowns with neighboring processors.
int numOwnedSteps() const
virtual void applyAdjointHessian_11(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the simulation-space derivative of the adjoint of the constraint simulation-space Jacobian at ...
virtual void zeroAll()
Zeros all entries of the vector, including boundary exchange fields.
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
const std::vector< int > & stencil() const
Defines the time dependent constraint operator interface for simulation-based optimization.
Constraint_PinTSimOpt()
Default constructor.
virtual void applyAdjointJacobian_1(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the adjoint of the partial constraint Jacobian at , , to the vector . This is the primary inter...
virtual void value(Vector< Real > &c, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Evaluate the constraint operator at .
Ptr< Vector< Real > > getStateVector(const PinTVector< double > &src, int step)
void initialize(const Ptr< Constraint_TimeSimOpt< Real >> &stepConstraint)
Initialize this class, setting up parallel distribution.
Defines a parallel in time vector.
virtual void applyAdjointHessian_12(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the optimization-space derivative of the adjoint of the constraint simulation-space Jacobian at...
ETimeAccessor
Enumeration to define which components of a a vector are required.
virtual void applyInverseJacobian_1(Vector< Real > &ijv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) overridefinal
Apply the inverse partial constraint Jacobian at , , to the vector .
virtual void applyAdjointHessian_22(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the optimization-space derivative of the adjoint of the constraint optimization-space Jacobian ...
Ptr< Vector< Real > > getNonconstVector(const PinTVector< double > &src, int step, ETimeAccessor accessor)
Build a vector composed of all vectors required by accessor.
virtual void applyJacobian_2(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the partial constraint Jacobian at , , to the vector .
void boundaryExchangeSumInto()
Exchange unknowns with neighboring processors using summation.
Ptr< const Vector< Real > > getVector(const PinTVector< double > &src, int step, ETimeAccessor accessor)
Build a vector composed of all vectors required by accessor.
Ptr< Vector< Real > > getRemoteBufferPtr(int i) const
Ptr< Constraint_TimeSimOpt< Real > > stepConstraint_
virtual void solve(Vector< Real > &c, Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Given , solve for .
const PinTCommunicators & communicators() const
virtual void applyAdjointJacobian_2(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the adjoint of the partial constraint Jacobian at , , to vector . This is the primary interface...
Defines the constraint operator interface for simulation-based optimization.
virtual void applyJacobian_1(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the partial constraint Jacobian at , , to the vector .
Constraint_PinTSimOpt(const Ptr< Constraint_TimeSimOpt< Real >> &stepConstraint)
Constructor.
virtual void update_2(const Vector< Real > &z, bool flag=true, int iter=-1)
Update constraint functions with respect to Opt variable. z is the control variable, flag = true if optimization variable is changed, iter is the outer algorithm iterations count.
virtual void applyAdjointHessian_21(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the simulation-space derivative of the adjoint of the constraint optimization-space Jacobian at...